/* Track One — mobile first. Light and dark follow the phone/computer setting. */
:root {
  --bg: #f6f3ee; --surface: #ffffff; --surface-2: #f0ece5; --line: #e2dcd2; --line-strong: #cfc6b8;
  --text: #1f2421; --muted: #6a6f6b; --faint: #9a9e9a;
  --brand: #b4461c; --brand-ink: #ffffff; --brand-soft: #f8e6dc;
  --ok: #2f7d4f; --ok-soft: #e2f1e7; --warn: #a86a06; --warn-soft: #fbefd6;
  --danger: #b42318; --danger-soft: #fbe4e1; --info: #2458a6; --info-soft: #e3ecf8;
  --grey-soft: #eceae6;
  --radius: 12px; --radius-sm: 8px; --shadow: 0 1px 2px rgba(20,20,10,.06), 0 2px 8px rgba(20,20,10,.05);
  --tabbar: 64px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #141a17; --surface: #1c2420; --surface-2: #232d28; --line: #2f3a34; --line-strong: #3d4a43;
    --text: #e9ece8; --muted: #a3aca6; --faint: #74807a;
    --brand: #f07a45; --brand-ink: #1a0f08; --brand-soft: #3a2519;
    --ok: #5cc486; --ok-soft: #1c3527; --warn: #e3a93a; --warn-soft: #3a2f16;
    --danger: #f2766b; --danger-soft: #3d1f1c; --info: #7fa9ea; --info-soft: #1d2a3d; --grey-soft: #2a322e;
    --shadow: 0 1px 2px rgba(0,0,0,.3);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #141a17; --surface: #1c2420; --surface-2: #232d28; --line: #2f3a34; --line-strong: #3d4a43;
  --text: #e9ece8; --muted: #a3aca6; --faint: #74807a;
  --brand: #f07a45; --brand-ink: #1a0f08; --brand-soft: #3a2519;
  --ok: #5cc486; --ok-soft: #1c3527; --warn: #e3a93a; --warn-soft: #3a2f16;
  --danger: #f2766b; --danger-soft: #3d1f1c; --info: #7fa9ea; --info-soft: #1d2a3d; --grey-soft: #2a322e;
  --shadow: 0 1px 2px rgba(0,0,0,.3);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body { font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; -webkit-font-smoothing: antialiased; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; line-height: 1.2; }
h1 { font-size: 22px; font-weight: 700; letter-spacing: -.01em; }
h2 { font-size: 16px; font-weight: 650; }
h3 { font-size: 14px; font-weight: 650; }
p { margin: 0; }
.boot { padding: 40px 16px; color: var(--muted); text-align: center; }
.muted { color: var(--muted); } .faint { color: var(--faint); } .small { font-size: 13px; } .tiny { font-size: 12px; }
.num { font-variant-numeric: tabular-nums; }
.row { display: flex; align-items: center; gap: 8px; }
.row.wrap { flex-wrap: wrap; } .row.between { justify-content: space-between; } .row.top { align-items: flex-start; }
.grow { flex: 1; min-width: 0; }
.stack { display: grid; gap: 12px; } .stack.tight { gap: 6px; } .stack.loose { gap: 20px; }
.grid2 { display: grid; gap: 12px; grid-template-columns: 1fr; }
@media (min-width: 640px) { .grid2 { grid-template-columns: 1fr 1fr; } }
.grid3 { display: grid; gap: 12px; grid-template-columns: 1fr; }
@media (min-width: 640px) { .grid3 { grid-template-columns: repeat(3, 1fr); } }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pre { white-space: pre-wrap; }
.hidden { display: none !important; }

/* ---------- shell ---------- */
.shell { min-height: 100vh; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 20; background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line); padding: calc(env(safe-area-inset-top) + 8px) 16px 8px; display: flex; align-items: center; gap: 10px; }
.brandmark { display: flex; align-items: center; gap: 8px; font-weight: 750; letter-spacing: -.01em; white-space: nowrap; }
.brandmark img { width: 28px; height: 28px; border-radius: 7px; }
.topbar select { max-width: min(48vw, 260px); }
.iconbtn { position: relative; display: inline-flex; align-items: center; justify-content: center; width: 38px; height: 38px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--surface); color: var(--text); cursor: pointer; }
.iconbtn:hover { border-color: var(--line-strong); text-decoration: none; }
.iconbtn .dot { position: absolute; top: -4px; right: -4px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--danger); color: #fff; font-size: 11px; font-weight: 700; display: flex; align-items: center; justify-content: center; }
.main { flex: 1; width: 100%; max-width: 1100px; margin: 0 auto; padding: 16px 16px calc(var(--tabbar) + 24px + env(safe-area-inset-bottom)); }
.tabbar { position: fixed; bottom: 0; left: 0; right: 0; z-index: 20; height: calc(var(--tabbar) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
  background: var(--surface); border-top: 1px solid var(--line); display: grid; grid-template-columns: repeat(5, 1fr); }
.tabbar a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; font-size: 11px; color: var(--muted); text-decoration: none; }
.tabbar a.on { color: var(--brand); font-weight: 650; }
.tabbar svg { width: 22px; height: 22px; }
.sidenav { display: none; }
@media (min-width: 900px) {
  .shell { display: grid; grid-template-columns: 232px 1fr; grid-template-rows: auto 1fr; }
  .topbar { grid-column: 1 / -1; }
  .tabbar { display: none; }
  .sidenav { display: block; position: sticky; top: 57px; height: calc(100vh - 57px); overflow-y: auto; padding: 12px 10px 24px; border-right: 1px solid var(--line); }
  .sidenav .grp { margin: 14px 10px 4px; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--faint); font-weight: 650; }
  .sidenav a { display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: 8px; color: var(--text); font-size: 14px; }
  .sidenav a svg { width: 18px; height: 18px; color: var(--muted); }
  .sidenav a:hover { background: var(--surface-2); text-decoration: none; }
  .sidenav a.on { background: var(--brand-soft); color: var(--brand); font-weight: 650; }
  .sidenav a.on svg { color: var(--brand); }
  .main { padding-bottom: 40px; }
}

/* ---------- page ---------- */
.pagehead { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.pagehead .sub { color: var(--muted); font-size: 13px; margin-top: 3px; }
.back { display: inline-flex; align-items: center; gap: 4px; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px; }
.card.flush { padding: 0; overflow: hidden; }
.card > h2 + *, .card > .row.between + * { margin-top: 10px; }
.section-title { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 650; margin: 18px 2px 8px; }
.list { list-style: none; margin: 0; padding: 0; }
.list > li { padding: 11px 14px; border-top: 1px solid var(--line); }
.list > li:first-child { border-top: 0; }
.list > li.link { cursor: pointer; }
.card:not(.flush) .list > li { padding-left: 0; padding-right: 0; }
.list > li.link:hover { background: var(--surface-2); }
.kv { display: grid; grid-template-columns: minmax(110px, 38%) 1fr; gap: 6px 12px; font-size: 14px; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; overflow-wrap: anywhere; }
.stat { display: flex; flex-direction: column; gap: 2px; }
.stat b { font-size: 22px; font-variant-numeric: tabular-nums; }
.tiles { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
@media (min-width: 700px) { .tiles { grid-template-columns: repeat(4, 1fr); } }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; color: var(--text); display: block; }
.tile:hover { border-color: var(--line-strong); text-decoration: none; }
.tile .t { font-size: 12px; color: var(--muted); } .tile .v { font-size: 20px; font-weight: 700; margin-top: 2px; font-variant-numeric: tabular-nums; }
.tile.warn { border-color: color-mix(in srgb, var(--warn) 45%, var(--line)); } .tile.danger { border-color: color-mix(in srgb, var(--danger) 55%, var(--line)); }
.table-wrap { overflow-x: auto; }
table.t { width: 100%; border-collapse: collapse; font-size: 14px; }
table.t th { text-align: left; font-weight: 600; font-size: 12px; color: var(--muted); padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.t td { padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.t tr:last-child td { border-bottom: 0; }

/* ---------- forms ---------- */
label.f { display: grid; gap: 5px; font-size: 13px; font-weight: 600; color: var(--text); }
label.f .hint { font-weight: 400; color: var(--muted); font-size: 12px; }
input, select, textarea { font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--radius-sm); padding: 9px 11px; width: 100%; min-height: 42px; }
textarea { min-height: 84px; resize: vertical; }
input:focus, select:focus, textarea:focus, button:focus-visible, a:focus-visible { outline: 2px solid color-mix(in srgb, var(--brand) 60%, transparent); outline-offset: 1px; }
input[type="checkbox"], input[type="radio"] { width: 20px; height: 20px; min-height: 0; accent-color: var(--brand); }
.check { display: flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 500; cursor: pointer; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; font: inherit; font-weight: 600; font-size: 14px; border-radius: 10px; padding: 9px 14px; min-height: 42px;
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--text); cursor: pointer; white-space: nowrap; }
.btn:hover { border-color: var(--text); text-decoration: none; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn.primary:hover { filter: brightness(1.06); }
.btn.danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 45%, var(--line)); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.sm { min-height: 34px; padding: 6px 10px; font-size: 13px; border-radius: 8px; }
.btn[disabled] { opacity: .55; cursor: default; }
.seg { display: inline-flex; border: 1px solid var(--line-strong); border-radius: 10px; overflow: hidden; }
.seg button { font: inherit; font-size: 13px; font-weight: 600; padding: 8px 12px; border: 0; background: var(--surface); color: var(--muted); cursor: pointer; min-height: 38px; }
.seg button + button { border-left: 1px solid var(--line-strong); }
.seg button.on { background: var(--brand-soft); color: var(--brand); }
.err { background: var(--danger-soft); color: var(--danger); border-radius: var(--radius-sm); padding: 9px 12px; font-size: 14px; }
.note { background: var(--info-soft); color: var(--info); border-radius: var(--radius-sm); padding: 9px 12px; font-size: 14px; }
.warnbox { background: var(--warn-soft); color: var(--warn); border-radius: var(--radius-sm); padding: 9px 12px; font-size: 14px; }
.stars { display: flex; gap: 6px; }
.stars button { width: 40px; height: 40px; border-radius: 10px; border: 1px solid var(--line-strong); background: var(--surface); font-weight: 700; cursor: pointer; color: var(--muted); }
.stars button.on { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }

/* ---------- badges ---------- */
.badge { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 650; padding: 2px 8px; border-radius: 999px; background: var(--grey-soft); color: var(--muted); white-space: nowrap; }
.badge.ok { background: var(--ok-soft); color: var(--ok); } .badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.danger { background: var(--danger-soft); color: var(--danger); } .badge.info { background: var(--info-soft); color: var(--info); }
.badge.brand { background: var(--brand-soft); color: var(--brand); }
.status { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 700; padding: 3px 9px; border-radius: 999px; }
.status::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.status.active { background: var(--ok-soft); color: var(--ok); }
.status.suspended { background: var(--grey-soft); color: var(--muted); }
.status.inactive { background: var(--danger-soft); color: var(--danger); }
.person-suspended { opacity: .6; }
.prio-urgent { color: var(--info); } .prio-standard { color: var(--warn); } .prio-monitor { color: #c2410c; }
.badge.prio-urgent { background: var(--info-soft); color: var(--info); }
.badge.prio-standard { background: var(--warn-soft); color: var(--warn); }
.badge.prio-monitor { background: #fde7d6; color: #b4461c; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .badge.prio-monitor { background: #3d2616; color: #f39a5e; } }

/* ---------- log grids ---------- */
.slotgrid { display: grid; gap: 8px; grid-template-columns: repeat(var(--cols, 3), minmax(0, 1fr)); }
.slot { border: 1px dashed var(--line-strong); border-radius: 10px; padding: 8px; min-height: 64px; display: flex; flex-direction: column; justify-content: center; gap: 2px; background: var(--surface); text-align: center; }
.slot.done { border-style: solid; }
.slot.good { background: var(--ok-soft); border-color: transparent; }
.slot.bad { background: var(--danger-soft); border-color: transparent; color: var(--danger); }
.slot .v { font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums; }
.slot button { font: inherit; }
.datenav { display: flex; align-items: center; gap: 6px; }
.datenav input { width: auto; }

/* ---------- calendar ---------- */
.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); border-top: 1px solid var(--line); border-left: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: var(--surface); }
.cal .dow { font-size: 11px; font-weight: 650; color: var(--muted); text-transform: uppercase; padding: 6px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); background: var(--surface-2); text-align: center; }
.cal .day { min-height: 74px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); padding: 4px; cursor: pointer; display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.cal .day:hover { background: var(--surface-2); }
.cal .day.other { background: var(--bg); color: var(--faint); }
.cal .day.today .dnum { background: var(--brand); color: var(--brand-ink); }
.cal .day.sel { box-shadow: inset 0 0 0 2px var(--brand); }
.cal .dnum { font-size: 12px; font-weight: 650; width: 22px; height: 22px; display: inline-flex; align-items: center; justify-content: center; border-radius: 50%; }
.cal .chip { font-size: 11px; line-height: 1.25; padding: 1px 4px; border-radius: 4px; background: var(--grey-soft); color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cal .dots { display: flex; gap: 3px; flex-wrap: wrap; }
.cal .dots i { width: 7px; height: 7px; border-radius: 50%; display: block; }
@media (max-width: 640px) { .cal .chip { display: none; } .cal .day { min-height: 52px; } }
@media (min-width: 641px) { .cal .dots { display: none; } }
.layer-events { background: var(--info-soft) !important; color: var(--info) !important; } i.layer-events { background: var(--info) !important; }
.layer-permits { background: var(--warn-soft) !important; color: var(--warn) !important; } i.layer-permits { background: var(--warn) !important; }
.layer-certs { background: #efe3f7 !important; color: #7a3fa3 !important; } i.layer-certs { background: #8b4bb8 !important; }
.layer-maintenance { background: var(--grey-soft) !important; color: var(--text) !important; } i.layer-maintenance { background: var(--muted) !important; }
.layer-temps, .layer-fryer { background: var(--danger-soft) !important; color: var(--danger) !important; } i.layer-temps, i.layer-fryer { background: var(--danger) !important; }
.layer-recaps { background: var(--ok-soft) !important; color: var(--ok) !important; } i.layer-recaps { background: var(--ok) !important; }
.layer-evals { background: var(--brand-soft) !important; color: var(--brand) !important; } i.layer-evals { background: var(--brand) !important; }
.layer-birthdays { background: #fdf0c9 !important; color: #8a6200 !important; } i.layer-birthdays { background: #d9a400 !important; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .layer-certs { background: #2e2238 !important; color: #c79be6 !important; } :root:not([data-theme="light"]) .layer-birthdays { background: #33290f !important; color: #e8c257 !important; } }
.filters { display: flex; gap: 6px; flex-wrap: wrap; }
.filters button { font: inherit; font-size: 12px; font-weight: 600; border-radius: 999px; padding: 5px 10px; border: 1px solid var(--line-strong); background: var(--surface); color: var(--muted); cursor: pointer; }
.filters button.on { color: var(--text); border-color: var(--text); }

/* ---------- spine map ---------- */
.spine { display: grid; gap: 12px; }
@media (min-width: 800px) { .spine { grid-template-columns: repeat(2, 1fr); } }
.spine .node { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 9px 12px; border-top: 1px solid var(--line); color: var(--text); font-size: 14px; }
.spine .node:hover { background: var(--surface-2); text-decoration: none; }
.spine .node.later { color: var(--faint); cursor: default; }
.spine .node.later:hover { background: none; }
.spine .sub { padding-left: 26px; }

/* ---------- overlays ---------- */
.overlay { position: fixed; inset: 0; background: rgba(10,12,10,.45); z-index: 50; display: flex; align-items: flex-end; justify-content: center; }
.sheet { background: var(--surface); width: 100%; max-width: 640px; max-height: 92vh; overflow-y: auto; border-radius: 16px 16px 0 0; padding: 16px 16px calc(16px + env(safe-area-inset-bottom)); box-shadow: 0 -4px 30px rgba(0,0,0,.2); }
@media (min-width: 700px) { .overlay { align-items: center; } .sheet { border-radius: 16px; } }
.sheet .sheethead { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; gap: 10px; }
.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--tabbar) + 16px + env(safe-area-inset-bottom)); z-index: 60; background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 10px; font-size: 14px; box-shadow: var(--shadow); max-width: calc(100vw - 32px); }
.toast.error { background: var(--danger); color: #fff; }
@media (min-width: 900px) { .toast { bottom: 24px; } }
.auth { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px 16px; }
.auth .card { width: 100%; max-width: 400px; padding: 22px; }
.empty { text-align: center; color: var(--muted); padding: 22px 12px; font-size: 14px; }
.filechip { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; padding: 4px 9px; border-radius: 8px; background: var(--surface-2); border: 1px solid var(--line); max-width: 100%; }
.filechip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
