/* Styrka Hub. One stylesheet, light + dark, phone-first. */

:root {
  --bg: #f5f4f0;
  --surface: #ffffff;
  --surface-2: #f0efea;
  --surface-3: #e7e5df;
  --ink: #16181a;
  --ink-2: #4a4f55;
  --ink-3: #7b8188;
  --line: #e3e1db;
  --line-2: #d4d2cb;
  --accent: #0c8f7b;
  --accent-ink: #ffffff;
  --accent-soft: rgba(12, 143, 123, .1);
  --good: #1e8a4c;
  --good-soft: rgba(30, 138, 76, .1);
  --due: #b86e0a;
  --due-soft: rgba(214, 139, 25, .14);
  --bad: #c2412f;
  --bad-soft: rgba(194, 65, 47, .1);
  --gold: #a87a12;
  --gold-soft: rgba(211, 160, 40, .16);
  --shadow: 0 1px 2px rgba(20, 20, 15, .05), 0 4px 16px rgba(20, 20, 15, .05);
  --shadow-lg: 0 24px 64px rgba(20, 20, 15, .18);
  --avatar-l: 88%;
  --avatar-ink: 32%;
  --radius: 14px;
  --top-h: 60px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1113;
    --surface: #171a1d;
    --surface-2: #1e2226;
    --surface-3: #272c31;
    --ink: #eef0f2;
    --ink-2: #b3bac1;
    --ink-3: #7a828a;
    --line: #262b30;
    --line-2: #333a40;
    --accent: #19c2a7;
    --accent-ink: #03120f;
    --accent-soft: rgba(25, 194, 167, .12);
    --good: #45c27d;
    --good-soft: rgba(69, 194, 125, .13);
    --due: #eaa94a;
    --due-soft: rgba(234, 169, 74, .14);
    --bad: #ef7a68;
    --bad-soft: rgba(239, 122, 104, .13);
    --gold: #e9c05a;
    --gold-soft: rgba(233, 192, 90, .14);
    --shadow: 0 1px 2px rgba(0, 0, 0, .3);
    --shadow-lg: 0 24px 64px rgba(0, 0, 0, .55);
    --avatar-l: 26%;
    --avatar-ink: 84%;
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #0f1113;
  --surface: #171a1d;
  --surface-2: #1e2226;
  --surface-3: #272c31;
  --ink: #eef0f2;
  --ink-2: #b3bac1;
  --ink-3: #7a828a;
  --line: #262b30;
  --line-2: #333a40;
  --accent: #19c2a7;
  --accent-ink: #03120f;
  --accent-soft: rgba(25, 194, 167, .12);
  --good: #45c27d;
  --good-soft: rgba(69, 194, 125, .13);
  --due: #eaa94a;
  --due-soft: rgba(234, 169, 74, .14);
  --bad: #ef7a68;
  --bad-soft: rgba(239, 122, 104, .13);
  --gold: #e9c05a;
  --gold-soft: rgba(233, 192, 90, .14);
  --shadow: 0 1px 2px rgba(0, 0, 0, .3);
  --shadow-lg: 0 24px 64px rgba(0, 0, 0, .55);
  --avatar-l: 26%;
  --avatar-ink: 84%;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.5 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  -webkit-font-smoothing: antialiased;
  font-variant-numeric: tabular-nums;
}
a { color: var(--accent); }
button { font: inherit; color: inherit; }
h1, h2, h3 { margin: 0; line-height: 1.25; }
svg { display: block; flex: none; }
[hidden] { display: none !important; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }

.wrap { width: 100%; max-width: 1200px; margin: 0 auto; padding: 0 16px; }
.muted { color: var(--ink-3); }
.skip { position: absolute; left: -999px; top: 8px; background: var(--surface); padding: 8px 12px; border-radius: 8px; z-index: 50; }
.skip:focus { left: 8px; }

/* ------------------------------------------------------------ buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 36px; padding: 0 14px; border-radius: 10px;
  border: 1px solid var(--line-2); background: var(--surface); color: var(--ink);
  font-size: 14px; font-weight: 600; cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: background .12s, border-color .12s, transform .06s;
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { background: var(--accent); filter: brightness(1.06); }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-sm { min-height: 30px; padding: 0 10px; font-size: 13px; border-radius: 8px; }
.btn-block { width: 100%; min-height: 44px; }
.btn-gold { background: var(--gold-soft); border-color: transparent; color: var(--gold); }
.btn-gold:hover { background: var(--gold-soft); filter: brightness(1.1); }

.icon-btn {
  display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: 10px;
  border: 1px solid transparent; background: transparent; color: var(--ink-2); cursor: pointer;
}
.icon-btn:hover { background: var(--surface-2); color: var(--ink); }

/* ------------------------------------------------------------ top bar */
.top {
  position: sticky; top: 0; z-index: 20;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(1.4) blur(12px); -webkit-backdrop-filter: saturate(1.4) blur(12px);
  border-bottom: 1px solid var(--line);
}
.top-in { display: flex; align-items: center; gap: 20px; height: var(--top-h); }
.brand { display: flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; flex: none; }
.brand img { border-radius: 9px; }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-text b { font-size: 15px; letter-spacing: -.01em; }
.brand-text small { font-size: 12px; color: var(--ink-3); white-space: nowrap; }

.tabs { display: flex; gap: 2px; height: 100%; }
.tabs a {
  display: flex; align-items: center; gap: 7px; padding: 0 12px; height: 100%;
  color: var(--ink-3); text-decoration: none; font-weight: 600; font-size: 14px;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tabs a:hover { color: var(--ink); }
.tabs a[aria-current="page"] { color: var(--ink); border-bottom-color: var(--accent); }
.tab-count {
  min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px; font-size: 11px; font-weight: 700;
  display: inline-grid; place-items: center; background: var(--surface-3); color: var(--ink-2);
}
.tab-count:empty { display: none; }
.tab-count.alert { background: var(--due-soft); color: var(--due); }

.top-actions { margin-left: auto; display: flex; align-items: center; gap: 4px; }
.sync {
  display: inline-flex; align-items: center; gap: 8px; height: 32px; padding: 0 12px; margin-right: 4px;
  border-radius: 999px; border: 1px solid var(--line); background: var(--surface); color: var(--ink-2);
  font-size: 12px; cursor: pointer; white-space: nowrap;
}
.sync:hover { border-color: var(--line-2); color: var(--ink); }
.sync-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ink-3); }
.sync.live .sync-dot { background: var(--good); box-shadow: 0 0 0 0 var(--good); animation: pulse 2.4s infinite; }
.sync.busy .sync-dot { background: var(--accent); animation: blink 1s infinite; }
.sync.err .sync-dot { background: var(--bad); }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--good) 60%, transparent); } 70% { box-shadow: 0 0 0 7px transparent; } 100% { box-shadow: 0 0 0 0 transparent; } }
@keyframes blink { 50% { opacity: .35; } }

.bottom-nav { display: none; }

/* ------------------------------------------------------------ page */
main.wrap { padding-top: 28px; padding-bottom: 64px; outline: none; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.page-head h1 { font-size: 26px; letter-spacing: -.02em; }
.page-head p { margin: 4px 0 0; color: var(--ink-3); }

.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 20px; }
.kpi {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px;
  box-shadow: var(--shadow); text-align: left; cursor: pointer; display: flex; flex-direction: column; gap: 2px;
  font: inherit; color: inherit; text-decoration: none; transition: border-color .12s;
}
.kpi:hover { border-color: var(--line-2); }
.kpi-label { font-size: 12px; font-weight: 600; color: var(--ink-3); text-transform: uppercase; letter-spacing: .04em; }
.kpi-value { font-size: 30px; font-weight: 750; letter-spacing: -.03em; line-height: 1.15; }
.kpi-sub { font-size: 13px; color: var(--ink-3); }
.kpi.is-due .kpi-value { color: var(--due); }
.kpi.is-bad .kpi-value { color: var(--bad); }
.kpi.is-gold .kpi-value { color: var(--gold); }

.grid-2 { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.stack { display: grid; gap: 16px; }

.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 16px 12px; border-bottom: 1px solid var(--line); }
.panel-head h2 { font-size: 15px; display: flex; align-items: center; gap: 8px; }
.panel-head .muted { font-size: 13px; }
.panel-empty { padding: 28px 16px; text-align: center; color: var(--ink-3); font-size: 14px; }
.panel-empty svg { margin: 0 auto 8px; color: var(--good); }
.panel-foot { padding: 10px 16px; border-top: 1px solid var(--line); }
.subhead { padding: 10px 16px 4px; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-3); }

/* list rows inside panels */
.item {
  display: flex; align-items: center; gap: 12px; padding: 11px 16px; border-top: 1px solid var(--line);
  cursor: pointer; transition: background .1s;
}
.item:first-child, .subhead + .item { border-top: 0; }
.item:hover { background: var(--surface-2); }
.item-top { align-items: flex-start; }
.item-top > .avatar { margin-top: 2px; }
.item-main { flex: 1; min-width: 0; }
.item-title { font-weight: 600; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.item-sub { font-size: 13px; color: var(--ink-3); }
.item-note { font-size: 12.5px; color: var(--ink-3); margin-top: 6px; }
.item-side { flex: none; display: flex; align-items: center; gap: 8px; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 7px; }
.step-chip {
  display: inline-flex; align-items: center; gap: 6px; min-height: 28px; padding: 0 10px 0 7px; border-radius: 8px;
  border: 1px solid transparent; font-size: 13px; font-weight: 500; cursor: pointer; background: var(--surface-2); color: var(--ink-2);
}
.step-chip .box { width: 15px; height: 15px; border-radius: 4px; border: 1.5px solid currentColor; opacity: .7; display: grid; place-items: center; }
.step-chip:hover .box { opacity: 1; background: color-mix(in srgb, currentColor 15%, transparent); }
.step-chip.due { background: var(--due-soft); color: var(--due); }
.step-chip.overdue { background: var(--bad-soft); color: var(--bad); }
.step-chip.more { cursor: pointer; color: var(--ink-3); padding: 0 10px; }

/* ------------------------------------------------------------ bits */
.avatar {
  --h: 170;
  width: 36px; height: 36px; border-radius: 50%; flex: none; display: grid; place-items: center;
  font-size: 13px; font-weight: 700; letter-spacing: .02em;
  background: hsl(var(--h) 45% var(--avatar-l)); color: hsl(var(--h) 55% var(--avatar-ink));
}
.avatar.lg { width: 52px; height: 52px; font-size: 18px; }

.pill {
  display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 8px; border-radius: 999px;
  font-size: 12px; font-weight: 600; white-space: nowrap; background: var(--surface-3); color: var(--ink-2);
}
.pill.good { background: var(--good-soft); color: var(--good); }
.pill.due { background: var(--due-soft); color: var(--due); }
.pill.bad { background: var(--bad-soft); color: var(--bad); }
.pill.accent { background: var(--accent-soft); color: var(--accent); }
.pill.gold { background: var(--gold-soft); color: var(--gold); }

.week { font-weight: 700; font-size: 13px; }
.track { display: flex; gap: 2px; margin-top: 5px; width: 104px; }
.track i { flex: 1; height: 5px; border-radius: 2px; background: var(--surface-3); }
.track i.past { background: color-mix(in srgb, var(--accent) 45%, var(--surface-3)); }
.track i.now { background: var(--accent); }

.bar { height: 6px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.bar > i { display: block; height: 100%; border-radius: inherit; background: var(--accent); }
.bar.gold > i { background: var(--gold); }
.progress-cell { display: flex; align-items: center; gap: 10px; min-width: 130px; }
.progress-cell .bar { flex: 1; min-width: 60px; }
.progress-cell span { font-size: 12px; color: var(--ink-3); white-space: nowrap; }

.spark { display: flex; align-items: flex-end; gap: 3px; height: 26px; }
.spark i { width: 7px; border-radius: 2px; background: var(--accent); min-height: 2px; }
.spark i.zero { background: var(--surface-3); }

.badge-num {
  width: 44px; height: 44px; border-radius: 12px; flex: none; display: grid; place-items: center;
  background: var(--gold-soft); color: var(--gold); font-weight: 800; font-size: 16px; letter-spacing: -.02em;
}
.badge-num.soon { background: var(--surface-2); color: var(--ink-2); }

.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex: none; }
.dot.good { background: var(--good); }
.dot.due { background: var(--due); }
.dot.bad { background: var(--bad); }
.dot.off { background: var(--ink-3); }

.note-flag { color: var(--ink-3); display: inline-flex; }

/* ------------------------------------------------------------ toolbar */
.toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.search { position: relative; flex: 1 1 240px; max-width: 360px; }
.search svg { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--ink-3); pointer-events: none; }
.search input {
  width: 100%; height: 38px; padding: 0 12px 0 36px; border-radius: 10px; border: 1px solid var(--line-2);
  background: var(--surface); color: var(--ink); font-size: 15px;
}
.search input:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
.search kbd { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); font: 11px/1 ui-monospace, monospace; color: var(--ink-3); border: 1px solid var(--line-2); border-radius: 5px; padding: 3px 5px; }
.filters { display: flex; gap: 6px; flex-wrap: wrap; }
.filter {
  display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 12px; border-radius: 999px;
  border: 1px solid var(--line-2); background: var(--surface); color: var(--ink-2); font-size: 13px; font-weight: 600; cursor: pointer;
}
.filter:hover { color: var(--ink); }
.filter[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: var(--bg); }
.filter .n { font-weight: 700; opacity: .6; }

/* ------------------------------------------------------------ tables */
.table-wrap { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.rows th:first-child { border-top-left-radius: calc(var(--radius) - 1px); }
.rows th:last-child { border-top-right-radius: calc(var(--radius) - 1px); }
.rows tbody tr:last-child td:first-child { border-bottom-left-radius: calc(var(--radius) - 1px); }
.rows tbody tr:last-child td:last-child { border-bottom-right-radius: calc(var(--radius) - 1px); }
table.rows { width: 100%; border-collapse: collapse; font-size: 14px; }
.rows th {
  position: sticky; top: var(--top-h); z-index: 2; background: var(--surface-2);
  text-align: left; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-3);
  padding: 0; border-bottom: 1px solid var(--line); white-space: nowrap;
}
.rows th > span, .rows th > button { display: flex; align-items: center; gap: 4px; padding: 10px 14px; }
.rows th button { all: unset; display: flex; align-items: center; gap: 4px; padding: 10px 14px; cursor: pointer; }
.rows th button:hover { color: var(--ink); }
.rows th button:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.rows th[aria-sort] button { color: var(--ink); }
.rows td { padding: 11px 14px; border-top: 1px solid var(--line); vertical-align: middle; }
@media (min-width: 761px) { .rows td:not(.cell-who):not(.next-cell) { white-space: nowrap; } }
.rows tbody tr:first-child td { border-top: 0; }
.rows tbody tr { cursor: pointer; transition: background .1s; }
.rows tbody tr:hover td { background: var(--surface-2); }
.rows .who { display: flex; align-items: center; gap: 11px; min-width: 200px; }
.rows .who b { font-weight: 600; display: block; }
.rows .who small { display: block; color: var(--ink-3); font-size: 12.5px; max-width: 240px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rows .num { font-weight: 650; }
.rows .sub { display: block; font-size: 12px; color: var(--ink-3); white-space: nowrap; }
.next-cell { font-size: 13px; }
.next-cell .pill { margin-bottom: 3px; }

.skeleton { height: 12px; border-radius: 6px; background: linear-gradient(90deg, var(--surface-2), var(--surface-3), var(--surface-2)); background-size: 200% 100%; animation: shimmer 1.3s infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }

.state-box { padding: 56px 20px; text-align: center; color: var(--ink-3); }
.state-box h2 { font-size: 17px; color: var(--ink); margin-bottom: 6px; }
.state-box p { margin: 0 0 16px; }

/* ------------------------------------------------------------ drawer */
.scrim { position: fixed; inset: 0; background: rgba(8, 10, 12, .45); z-index: 30; animation: fade .15s; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(520px, 100%); z-index: 31;
  background: var(--bg); border-left: 1px solid var(--line); box-shadow: var(--shadow-lg);
  overflow-y: auto; overscroll-behavior: contain; animation: slide .2s cubic-bezier(.2, .8, .2, 1);
}
@keyframes slide { from { transform: translateX(40px); opacity: 0; } }
@keyframes fade { from { opacity: 0; } }
.d-head { position: sticky; top: 0; z-index: 2; display: flex; align-items: center; gap: 14px; padding: 18px 20px; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.d-head h2 { font-size: 20px; letter-spacing: -.01em; }
.d-head p { margin: 2px 0 0; font-size: 13px; color: var(--ink-3); }
.d-head .icon-btn { margin-left: auto; align-self: flex-start; }
.d-body { padding: 16px 20px 40px; display: grid; gap: 16px; }
.d-contact { display: flex; gap: 8px; flex-wrap: wrap; }
.d-contact .btn { flex: 1 1 0; min-width: 90px; }
.d-stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.d-stat { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 11px 13px; }
.d-stat > span { display: block; font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-3); }
.d-stat > b { display: block; font-size: 19px; letter-spacing: -.01em; margin-top: 2px; }
.d-stat > small { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-top: 4px; font-size: 12.5px; color: var(--ink-3); }
.d-sec { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.d-sec > header { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 13px 16px; }
.d-sec > header h3 { font-size: 14px; }
.d-sec > header .muted { font-size: 13px; }
.d-sec-body { padding: 0 16px 16px; }

.cal { display: grid; grid-template-columns: 26px repeat(7, minmax(0, 1fr)); gap: 4px; font-size: 11px; color: var(--ink-3); }
.cal .dow { text-align: center; font-weight: 600; }
.cal .wk { display: flex; align-items: center; font-size: 10.5px; }
.cal .day { aspect-ratio: 1; border-radius: 5px; background: var(--surface-2); max-height: 34px; }
.cal .day.hit { background: var(--accent); }
.cal .day.hit2 { background: color-mix(in srgb, var(--accent) 75%, var(--ink)); }
.cal .day.today { box-shadow: inset 0 0 0 2px var(--ink-2); }
.cal .day.future { background: transparent; border: 1px dashed var(--line-2); }

.mile-row { display: flex; flex-wrap: wrap; gap: 6px; }
.mile {
  display: inline-flex; align-items: center; gap: 5px; height: 30px; padding: 0 10px; border-radius: 9px;
  font-weight: 700; font-size: 13px; background: var(--surface-2); color: var(--ink-3); border: 1px solid transparent;
}
.mile.hit { background: var(--good-soft); color: var(--good); }
.mile.pending { background: var(--gold-soft); color: var(--gold); cursor: pointer; border-color: color-mix(in srgb, var(--gold) 40%, transparent); }
.mile.next { border: 1px dashed var(--line-2); color: var(--ink-2); background: transparent; }
.mile-next { margin-top: 12px; }
.mile-next .bar { margin-top: 6px; }
.mile-next p { margin: 0; font-size: 13px; color: var(--ink-2); }

.phase { border-top: 1px solid var(--line); }
.phase-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 16px 4px; }
.phase-head b { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-3); }
.step {
  display: flex; align-items: center; gap: 12px; padding: 8px 16px; min-height: 44px; cursor: pointer;
}
.step:hover { background: var(--surface-2); }
.step input { position: absolute; opacity: 0; pointer-events: none; }
.check {
  width: 22px; height: 22px; border-radius: 7px; flex: none; display: grid; place-items: center;
  border: 2px solid var(--line-2); color: transparent; transition: background .12s, border-color .12s;
}
.step input:checked + .check { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.step input:focus-visible + .check { outline: 2px solid var(--accent); outline-offset: 2px; }
.step.auto { cursor: default; }
.step.auto:hover { background: transparent; }
.step.auto input:checked + .check { background: var(--good); border-color: var(--good); }
.step-label { flex: 1; min-width: 0; }
.step-label small { display: block; color: var(--ink-3); font-size: 12.5px; }
.step.is-done .step-text { color: var(--ink-3); }
.step-state { flex: none; }

.notes textarea {
  width: 100%; min-height: 96px; resize: vertical; padding: 10px 12px; border-radius: 10px;
  border: 1px solid var(--line-2); background: var(--bg); color: var(--ink); font: inherit; font-size: 14px;
}
.notes textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
.notes .meta { display: flex; justify-content: space-between; font-size: 12px; color: var(--ink-3); margin-top: 6px; }

.field { display: grid; gap: 6px; font-size: 13px; font-weight: 600; color: var(--ink-2); }
.field input {
  height: 44px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--line-2);
  background: var(--bg); color: var(--ink); font: inherit; font-size: 15px; font-weight: 400;
}
.field input:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
.inline-form { display: flex; gap: 8px; align-items: flex-end; flex-wrap: wrap; }
.inline-form .field { flex: 1 1 180px; }

details.more-sec > summary { list-style: none; cursor: pointer; }
details.more-sec > summary::-webkit-details-marker { display: none; }
details.more-sec > summary .chev { transition: transform .15s; }
details.more-sec[open] > summary .chev { transform: rotate(90deg); }

/* ------------------------------------------------------------ toast */
.toasts { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 40; display: grid; gap: 8px; width: min(420px, calc(100% - 32px)); }
.toast {
  display: flex; align-items: center; gap: 12px; padding: 11px 12px 11px 16px; border-radius: 12px;
  background: var(--ink); color: var(--bg); box-shadow: var(--shadow-lg); font-size: 14px; animation: rise .2s;
}
.toast.err { background: var(--bad); color: #fff; }
.toast span { flex: 1; }
.toast button { background: transparent; border: 0; color: inherit; font-weight: 700; cursor: pointer; padding: 4px 8px; border-radius: 6px; opacity: .9; }
.toast button:hover { opacity: 1; background: rgba(127, 127, 127, .2); }
@keyframes rise { from { transform: translateY(8px); opacity: 0; } }

/* ------------------------------------------------------------ login */
.login-body { min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px; background: radial-gradient(900px 500px at 50% -10%, var(--accent-soft), transparent 70%), var(--bg); }
.login-card { width: 100%; max-width: 380px; background: var(--surface); border: 1px solid var(--line); border-radius: 20px; padding: 32px 28px; box-shadow: var(--shadow-lg); display: grid; gap: 16px; }
.login-card img { border-radius: 12px; }
.login-card h1 { font-size: 22px; letter-spacing: -.02em; margin-top: 4px; }
.login-card p { margin: -8px 0 4px; font-size: 14px; }
.login-err { margin: -6px 0 0; color: var(--bad); font-size: 13.5px; font-weight: 500; }

/* ------------------------------------------------------------ responsive */
@media (max-width: 1000px) {
  .grid-2 { grid-template-columns: minmax(0, 1fr); }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 760px) {
  :root { --top-h: 56px; }
  .tabs, .brand-text small, .search kbd { display: none; }
  .sync { padding: 0 10px; }
  main.wrap { padding-top: 18px; padding-bottom: calc(88px + env(safe-area-inset-bottom)); }
  .page-head h1 { font-size: 22px; }
  .kpi { padding: 12px 14px; }
  .kpi-value { font-size: 26px; }
  .search { max-width: none; flex-basis: 100%; }
  .filters { flex-wrap: nowrap; overflow-x: auto; margin: 0 -16px; padding: 0 16px 2px; scrollbar-width: none; }
  .filters::-webkit-scrollbar { display: none; }
  .filter { flex: none; }

  .bottom-nav {
    display: grid; grid-template-columns: repeat(4, 1fr); position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
    background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
    border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom);
  }
  .bottom-nav a {
    position: relative; display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 9px 0 8px;
    font-size: 11.5px; font-weight: 600; color: var(--ink-3); text-decoration: none;
  }
  .bottom-nav a[aria-current="page"] { color: var(--accent); }
  .bottom-nav .tab-count { position: absolute; top: 4px; left: calc(50% + 8px); min-width: 18px; height: 18px; font-size: 10px; }

  /* tables become cards */
  .table-wrap { background: transparent; border: 0; box-shadow: none; overflow: visible; }
  table.rows, .rows tbody { display: block; }
  .rows thead { display: none; }
  .rows tbody tr {
    display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 10px 12px; margin-bottom: 10px; padding: 14px;
    background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
  }
  .rows tbody tr:hover td { background: transparent; }
  .rows td { display: block; padding: 0; border: 0; }
  .rows td[data-label]::before { content: attr(data-label); display: block; font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-3); margin-bottom: 3px; }
  .rows td.cell-who, .rows td.cell-wide { grid-column: 1 / -1; }
  .rows .sub { white-space: normal; overflow-wrap: anywhere; }
  .rows .who { min-width: 0; }
  .rows .who small { max-width: 60vw; }
  .progress-cell { min-width: 0; }

  .drawer { width: 100%; border-left: 0; animation: up .22s cubic-bezier(.2, .8, .2, 1); }
  @keyframes up { from { transform: translateY(40px); opacity: 0; } }
  .d-head { padding: 14px 16px; }
  .d-body { padding: 14px 16px 40px; }
  .toasts { bottom: calc(76px + env(safe-area-inset-bottom)); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ------------------------------------------------------------ moments + texts */
.moment .moment-title { font-size: 14px; font-weight: 600; margin-top: 2px; }
.moment .moment-title .muted { font-weight: 400; }
.moment-actions { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.moment.is-open { background: var(--surface-2); cursor: default; }
.moment-icon { width: 44px; height: 44px; border-radius: 12px; flex: none; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); }
.moment-icon.bad { background: var(--bad-soft); color: var(--bad); }
.moment-icon.gold { background: var(--gold-soft); color: var(--gold); }

.composer { margin-top: 12px; border: 1px solid var(--line-2); border-radius: 12px; background: var(--surface); overflow: hidden; cursor: auto; }
.thread { max-height: 260px; overflow-y: auto; padding: 12px; display: flex; flex-direction: column; gap: 6px; background: var(--bg); border-bottom: 1px solid var(--line); }
.thread-empty, .thread-more { margin: 0; font-size: 13px; color: var(--ink-3); text-align: center; }
.bubble { max-width: 82%; padding: 7px 11px; border-radius: 14px; font-size: 14px; line-height: 1.4; white-space: pre-wrap; overflow-wrap: anywhere; }
.bubble small { display: block; font-size: 11px; opacity: .7; margin-top: 2px; }
.bubble.in { align-self: flex-start; background: var(--surface-3); color: var(--ink); border-bottom-left-radius: 4px; }
.bubble.out { align-self: flex-end; background: var(--accent); color: var(--accent-ink); border-bottom-right-radius: 4px; }
.bubble.out.auto { background: color-mix(in srgb, var(--accent) 55%, var(--surface-3)); }
.compose-text { display: block; width: 100%; border: 0; padding: 12px; resize: vertical; min-height: 96px; background: var(--surface); color: var(--ink); font: inherit; font-size: 14.5px; line-height: 1.45; }
.compose-text:focus { outline: none; box-shadow: inset 0 0 0 2px var(--accent); }
.compose-actions { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; padding: 10px 12px; border-top: 1px solid var(--line); }
.compose-reason { font-size: 12.5px; color: var(--ink-3); }
.compose-buttons { display: flex; gap: 6px; flex-wrap: wrap; margin-left: auto; }
.d-moment { cursor: default; }
.d-moment:hover { background: transparent; }
.d-moment.is-current .step-text { color: var(--accent); }
