/* Home Setup — calm neutral palette, one accent. Mobile first; sidebar layout from 900px. */
:root {
  --bg: #f6f4f0;
  --card: #ffffff;
  --ink: #2b2a27;
  --muted: #7a766e;
  --line: #e6e1d8;
  --soft: #efebe4;
  --accent: #4f7a6a;
  --accent-ink: #ffffff;
  --accent-soft: #e3ece8;
  --danger: #b4483c;
  --danger-soft: #f6e3e0;
  --amber: #a86b12; --amber-bg: #fbefd9;
  --blue: #2d64a8;  --blue-bg: #e2ecf8;
  --green: #2f7d4a; --green-bg: #e1f1e6;
  --grey: #6b6760;  --grey-bg: #ece9e3;
  --radius: 14px;
  --tap: 48px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  padding-bottom: calc(72px + var(--safe-b));
}
a { color: var(--accent); text-decoration: none; }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .5rem; font-weight: 650; }
h2 { font-size: 1.15rem; margin-top: 1.5rem; }
h3 { font-size: 1rem; }
p { margin: .25rem 0 .75rem; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
hr { border: 0; border-top: 1px solid var(--line); margin: 1rem 0; }

/* ---------- chrome ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: .5rem;
  padding: calc(.6rem + env(safe-area-inset-top, 0px)) 1rem .6rem; background: rgba(246,244,240,.94);
  backdrop-filter: blur(8px); border-bottom: 1px solid var(--line);
}
.topbar h1 { flex: 1; font-size: 1.15rem; margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .back { font-size: 2rem; line-height: 1; padding: 0 .4rem 0 0; color: var(--ink); min-width: 32px; }
.bell { position: relative; color: var(--ink); display: grid; place-items: center; width: 44px; height: 44px; }
.badge {
  position: absolute; top: 4px; right: 2px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
  background: var(--danger); color: #fff; font-size: 11px; font-weight: 700; display: grid; place-items: center;
}
.main { max-width: 860px; margin: 0 auto; padding: 1rem; }
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; display: flex; background: #fff;
  border-top: 1px solid var(--line); padding-bottom: var(--safe-b);
}
.tabbar a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 0 6px; color: var(--muted); font-size: 11px; min-height: 58px; }
.tabbar a.on { color: var(--accent); }
.sidebar { display: none; }
@media (min-width: 900px) {
  body { padding-bottom: 0; padding-left: 230px; }
  .tabbar { display: none; }
  .sidebar { display: block; position: fixed; left: 0; top: 0; bottom: 0; width: 230px; background: #fff; border-right: 1px solid var(--line); padding: 1.25rem .75rem; overflow-y: auto; }
  .sidebar .brand { display: block; font-weight: 700; font-size: 1.1rem; color: var(--ink); padding: 0 .75rem 1rem; }
  .sidebar nav a { display: block; padding: .6rem .75rem; border-radius: 10px; color: var(--ink); }
  .sidebar nav a.on { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
  .main { padding: 1.5rem 2rem; max-width: 1100px; }
  .main.wide { max-width: none; }
}

/* ---------- building blocks ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem; margin-bottom: .75rem; }
.card.tight { padding: .75rem; }
.card > h2:first-child, .card > h3:first-child { margin-top: 0; }
.list { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; margin-bottom: 1rem; }
.list > .row, .list > a.row { display: flex; align-items: center; gap: .75rem; padding: .8rem 1rem; border-top: 1px solid var(--line); color: var(--ink); min-height: var(--tap); }
.list > .row:first-child, .list > a.row:first-child { border-top: 0; }
.row .grow { flex: 1; min-width: 0; }
.row .title { font-weight: 600; }
.row .sub { color: var(--muted); font-size: .88rem; }
a.row:active { background: var(--soft); }
.chev::after { content: "›"; color: var(--muted); font-size: 1.4rem; }
.grid2 { display: grid; gap: .75rem; grid-template-columns: 1fr 1fr; }
.grid3 { display: grid; gap: .75rem; grid-template-columns: repeat(3, 1fr); }
@media (max-width: 600px) { .grid3 { grid-template-columns: 1fr 1fr; } .grid2.stack { grid-template-columns: 1fr; } }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: .9rem 1rem; color: var(--ink); display: block; }
.stat b { display: block; font-size: 1.6rem; font-weight: 700; }
.stat span { color: var(--muted); font-size: .85rem; }
.stat.alert b { color: var(--danger); }
.toolbar { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin-bottom: 1rem; }
.toolbar .grow { flex: 1; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: .5rem; margin: 1.25rem 0 .5rem; }
.section-head h2 { margin: 0; }
.empty { text-align: center; color: var(--muted); padding: 1.5rem 1rem; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: .3rem 1rem; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; white-space: pre-wrap; }
.pre { white-space: pre-wrap; }

/* ---------- chips ---------- */
.chip { display: inline-flex; align-items: center; gap: .3rem; padding: .15rem .6rem; border-radius: 999px; font-size: .78rem; font-weight: 600; background: var(--grey-bg); color: var(--grey); white-space: nowrap; }
.chip-needed, .chip-in_progress, .chip-draft, .chip-flag { background: var(--amber-bg); color: var(--amber); }
.chip-ordered, .chip-scheduled, .chip-sent, .chip-open { background: var(--blue-bg); color: var(--blue); }
.chip-installed, .chip-done, .chip-active, .chip-accepted, .chip-paid, .chip-ok { background: var(--green-bg); color: var(--green); }
.chip-declined, .chip-overdue { background: var(--danger-soft); color: var(--danger); }
.chip-complete, .chip-invoiced, .chip-not_started { background: var(--grey-bg); color: var(--grey); }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); display: inline-grid; place-items: center; font-size: .8rem; font-weight: 700; flex: none; object-fit: cover; }
.avatar.sm { width: 26px; height: 26px; font-size: .7rem; }
.avatars { display: inline-flex; }
.avatars .avatar { margin-left: -6px; border: 2px solid #fff; }
.avatars .avatar:first-child { margin-left: 0; }

/* ---------- forms ---------- */
label { display: block; font-size: .88rem; color: var(--muted); margin: .75rem 0 .25rem; }
input, select, textarea {
  width: 100%; font: inherit; color: var(--ink); background: #fff; border: 1px solid var(--line); border-radius: 10px;
  padding: .7rem .8rem; min-height: var(--tap);
}
textarea { min-height: 90px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
input[type=checkbox], input[type=radio] { width: auto; min-height: 0; }
.check { display: flex; align-items: center; gap: .6rem; color: var(--ink); font-size: 1rem; margin: .6rem 0; }
.check input { width: 22px; height: 22px; accent-color: var(--accent); }
.checks { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: .25rem .75rem; }
.form-actions { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: 1.25rem; }
.hint { font-size: .8rem; color: var(--muted); margin-top: .25rem; }
fieldset { border: 1px solid var(--line); border-radius: var(--radius); padding: .5rem 1rem 1rem; margin: 1rem 0; }
legend { padding: 0 .4rem; color: var(--muted); font-size: .85rem; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem; min-height: var(--tap);
  padding: .6rem 1.1rem; border-radius: 12px; border: 1px solid var(--line); background: #fff; color: var(--ink);
  font: inherit; font-weight: 600; cursor: pointer; text-align: center;
}
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.danger { color: var(--danger); border-color: var(--danger-soft); }
.btn.danger.solid { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn.small { min-height: 36px; padding: .35rem .8rem; font-size: .88rem; border-radius: 10px; }
.btn.block { display: flex; width: 100%; }
.btn.link { border: 0; background: none; color: var(--accent); padding: .3rem .4rem; min-height: 0; }
.btn[disabled] { opacity: .5; }
.btn-clock { width: 100%; min-height: 64px; font-size: 1.15rem; border-radius: 16px; }
.btn-clock.in { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn-clock.out { background: var(--danger); color: #fff; border-color: var(--danger); }
form.inline { display: inline; margin: 0; }

.flash { padding: .75rem 1rem; border-radius: 12px; margin-bottom: 1rem; background: var(--accent-soft); color: var(--accent); }
.flash-err { background: var(--danger-soft); color: var(--danger); }
.flash-warn { background: var(--amber-bg); color: var(--amber); }

/* ---------- checklists ---------- */
.checkitem { display: flex; align-items: flex-start; gap: .75rem; padding: .7rem 1rem; border-top: 1px solid var(--line); }
.checkitem:first-child { border-top: 0; }
.checkitem .tick {
  flex: none; width: 30px; height: 30px; border-radius: 50%; border: 2px solid var(--line); background: #fff; cursor: pointer;
  display: grid; place-items: center; color: transparent; font-size: 16px; padding: 0;
}
.checkitem.done .tick { background: var(--accent); border-color: var(--accent); color: #fff; }
.checkitem.done .text { color: var(--muted); text-decoration: line-through; }
.checkitem .grow { flex: 1; min-width: 0; }
.progress { height: 6px; background: var(--soft); border-radius: 3px; overflow: hidden; margin-top: .35rem; }
.progress > i { display: block; height: 100%; background: var(--accent); }

/* ---------- photos ---------- */
.thumbs { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .4rem; }
.thumbs img, img.thumb { width: 64px; height: 64px; border-radius: 10px; object-fit: cover; cursor: zoom-in; background: var(--soft); }
.thumbs .ph { position: relative; }
.thumbs .ph .kind { position: absolute; left: 3px; bottom: 3px; font-size: 10px; background: rgba(0,0,0,.55); color: #fff; padding: 0 4px; border-radius: 4px; }
.photo-btn { position: relative; overflow: hidden; }
.photo-btn input[type=file] { position: absolute; inset: 0; opacity: 0; cursor: pointer; min-height: 0; }
.lightbox { position: fixed; inset: 0; background: rgba(0,0,0,.88); z-index: 100; display: grid; place-items: center; padding: 1rem; }
.lightbox[hidden] { display: none; }
.lightbox img { max-width: 100%; max-height: 100%; border-radius: 8px; }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 1rem; }
table { width: 100%; border-collapse: collapse; font-size: .92rem; }
th, td { padding: .6rem .75rem; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { color: var(--muted); font-weight: 600; font-size: .8rem; background: #fbfaf8; }
tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; white-space: nowrap; }
tfoot td { font-weight: 700; }
.strike { text-decoration: line-through; color: var(--muted); }

/* ---------- calendar ---------- */
.cal-nav { display: flex; align-items: center; gap: .5rem; margin-bottom: .75rem; flex-wrap: wrap; }
.cal-nav h2 { margin: 0; flex: 1; font-size: 1.1rem; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.seg a { padding: .45rem .8rem; color: var(--ink); background: #fff; }
.seg a.on { background: var(--accent); color: #fff; }
.month { display: grid; grid-template-columns: repeat(7, 1fr); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: var(--line); gap: 1px; }
.month .dow { background: #fbfaf8; font-size: .75rem; color: var(--muted); text-align: center; padding: .3rem; }
.day { background: #fff; min-height: 96px; padding: .3rem; display: flex; flex-direction: column; gap: 3px; }
.day.other { background: #faf9f6; }
.day.today .dnum { background: var(--accent); color: #fff; }
.day.drop { outline: 2px dashed var(--accent); outline-offset: -3px; }
.dnum { font-size: .75rem; width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; color: var(--muted); }
.day .add { font-size: .7rem; color: var(--muted); align-self: flex-end; margin-top: auto; }
.ev { display: block; font-size: .74rem; padding: 2px 5px; border-radius: 6px; color: var(--ink); overflow: hidden; white-space: nowrap; text-overflow: ellipsis; border-left: 3px solid; cursor: grab; }
.ev.conflict { box-shadow: inset 0 0 0 1.5px var(--danger); }
.week { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: .5rem; }
.week .day { min-height: 220px; border: 1px solid var(--line); border-radius: 12px; }
.week .ev { white-space: normal; font-size: .8rem; padding: 4px 6px; }
@media (max-width: 700px) {
  .month .day { min-height: 64px; }
  .month .ev { font-size: 0; height: 6px; padding: 0; border-left-width: 0; }
  .week { grid-template-columns: 1fr; }
  .week .day { min-height: 0; }
}

/* ---------- misc ---------- */
.timer { font-variant-numeric: tabular-nums; font-weight: 700; font-size: 1.25rem; }
.visit-card .meta { display: flex; flex-wrap: wrap; gap: .4rem .75rem; color: var(--muted); font-size: .9rem; margin: .25rem 0 .75rem; }
.tabs-inline { display: flex; gap: .25rem; border-bottom: 1px solid var(--line); margin-bottom: 1rem; overflow-x: auto; }
.tabs-inline a { padding: .6rem .9rem; color: var(--muted); border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs-inline a.on { color: var(--ink); border-color: var(--accent); font-weight: 600; }
.mention-pop { position: absolute; z-index: 50; background: #fff; border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 6px 24px rgba(0,0,0,.12); max-height: 220px; overflow-y: auto; min-width: 200px; }
.mention-pop button { display: block; width: 100%; text-align: left; padding: .6rem .8rem; border: 0; background: none; font: inherit; cursor: pointer; }
.mention-pop button:hover, .mention-pop button.on { background: var(--accent-soft); }
.comment { display: flex; gap: .6rem; padding: .75rem 0; border-top: 1px solid var(--line); }
.comment:first-child { border-top: 0; }
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 1rem; }
.login-card { width: 100%; max-width: 380px; }
.sticky-actions { position: sticky; bottom: calc(66px + var(--safe-b)); background: var(--bg); padding: .5rem 0; z-index: 10; }
@media (min-width: 900px) { .sticky-actions { bottom: 0; } }
details summary { cursor: pointer; padding: .4rem 0; color: var(--accent); }
.danger-zone { border-color: var(--danger-soft); }
@media print { .tabbar, .sidebar, .topbar, .no-print { display: none !important; } body { padding: 0; } }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
