/* =========================================================================
   IGNITED OS — design tokens
   Every colour is declared on bare :root first, then redefined (tokens only)
   for the two dark states, so the un-stamped "system" viewer resolves too.
   ========================================================================= */
:root {
  /* --- surfaces & ink (neutrals carry a slight blue bias toward the accent) */
  --ground: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #f9fafb;
  --surface-sunken: #f1f3f7;
  --ink: #0f172a;
  --ink-2: #334155;
  --muted: #64748b;
  --faint: #94a3b8;
  --hairline: #e6e9ef;
  --hairline-strong: #d7dce6;

  /* --- accent: one soft blue, spent sparingly */
  --accent: #3b6fe0;
  --accent-ink: #1e4fb8;
  --accent-wash: #eef3fe;
  --accent-hairline: #cddcfa;

  /* --- semantic status: carried over from the legacy dashboards verbatim */
  --st-done: #16a34a;
  --st-done-wash: #e8f6ed;
  --st-active: #2563eb;
  --st-active-wash: #e8f0fe;
  --st-waiting: #db2777;
  --st-waiting-wash: #fdecf4;
  --st-open: #d97706;
  --st-open-wash: #fdf1e1;
  --st-idle: #64748b;
  --st-idle-wash: #eef1f5;

  /* --- chart series (accessible in both themes, distinct in hue and value) */
  --c1: #3b6fe0;
  --c2: #16a34a;
  --c3: #db2777;
  --c4: #d97706;
  --c5: #7c5cd6;
  --c6: #0e9aa7;

  /* --- elevation: hairline is the default, shadow is reserved */
  --shadow-raised: 0 1px 2px rgba(15, 23, 42, .04), 0 4px 12px rgba(15, 23, 42, .05);
  --shadow-float: 0 8px 28px rgba(15, 23, 42, .12), 0 2px 6px rgba(15, 23, 42, .06);
  --ring: 0 0 0 3px rgba(59, 111, 224, .28);

  /* --- radii */
  --r-sm: 6px;
  --r: 10px;
  --r-lg: 14px;
  --r-pill: 999px;

  /* --- type scale */
  --f-display: 'Google Sans', 'Segoe UI', system-ui, sans-serif;
  --f-ui: 'Google Sans', 'Segoe UI', system-ui, sans-serif;
  --t-page: 26px;
  --t-section: 17px;
  --t-card: 15px;
  --t-body: 14px;
  --t-meta: 12.5px;
  --t-label: 11px;
  --t-kpi: 30px;

  /* --- layout */
  --rail: 264px;
  --rail-collapsed: 68px;
  --gap: 16px;
  --pad: 20px;
  --header-h: 60px;
}

/* Dark, for the default "system" viewer (no data-theme stamp present). */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    --ground: #0c1119;
    --surface: #131a25;
    --surface-2: #171f2c;
    --surface-sunken: #0f1621;
    --ink: #eef2f8;
    --ink-2: #cbd5e1;
    --muted: #94a3b8;
    --faint: #64748b;
    --hairline: #243040;
    --hairline-strong: #33415a;

    --accent: #7ba3f5;
    --accent-ink: #a9c4fb;
    --accent-wash: #17233a;
    --accent-hairline: #2c3f63;

    --st-done: #4ade80;
    --st-done-wash: #10261a;
    --st-active: #7ba3f5;
    --st-active-wash: #15243d;
    --st-waiting: #f472b6;
    --st-waiting-wash: #2c1424;
    --st-open: #fbbf24;
    --st-open-wash: #2b2011;
    --st-idle: #94a3b8;
    --st-idle-wash: #1b2431;

    --c1: #7ba3f5;
    --c2: #4ade80;
    --c3: #f472b6;
    --c4: #fbbf24;
    --c5: #a58bf0;
    --c6: #2dd4bf;

    --shadow-raised: 0 1px 2px rgba(0, 0, 0, .4), 0 4px 12px rgba(0, 0, 0, .3);
    --shadow-float: 0 10px 32px rgba(0, 0, 0, .55), 0 2px 8px rgba(0, 0, 0, .4);
    --ring: 0 0 0 3px rgba(123, 163, 245, .35);
  }
}

/* Dark, when the viewer explicitly chose it — wins over a light OS. */
:root[data-theme='dark'] {
  --ground: #0c1119;
  --surface: #131a25;
  --surface-2: #171f2c;
  --surface-sunken: #0f1621;
  --ink: #eef2f8;
  --ink-2: #cbd5e1;
  --muted: #94a3b8;
  --faint: #64748b;
  --hairline: #243040;
  --hairline-strong: #33415a;

  --accent: #7ba3f5;
  --accent-ink: #a9c4fb;
  --accent-wash: #17233a;
  --accent-hairline: #2c3f63;

  --st-done: #4ade80;
  --st-done-wash: #10261a;
  --st-active: #7ba3f5;
  --st-active-wash: #15243d;
  --st-waiting: #f472b6;
  --st-waiting-wash: #2c1424;
  --st-open: #fbbf24;
  --st-open-wash: #2b2011;
  --st-idle: #94a3b8;
  --st-idle-wash: #1b2431;

  --c1: #7ba3f5;
  --c2: #4ade80;
  --c3: #f472b6;
  --c4: #fbbf24;
  --c5: #a58bf0;
  --c6: #2dd4bf;

  --shadow-raised: 0 1px 2px rgba(0, 0, 0, .4), 0 4px 12px rgba(0, 0, 0, .3);
  --shadow-float: 0 10px 32px rgba(0, 0, 0, .55), 0 2px 8px rgba(0, 0, 0, .4);
  --ring: 0 0 0 3px rgba(123, 163, 245, .35);
}

/* ========================= reset + base ========================= */
*, *::before, *::after { box-sizing: border-box; }
html, body, #root { height: 100%; }
/* Keep this on html, not body: an overflow on body makes it a scrollport that
   never scrolls, and every position:sticky inside the app stops working. */
html { overflow-x: hidden; }
body {
  margin: 0;
  background: var(--ground);
  color: var(--ink);
  font-family: var(--f-ui);
  font-size: var(--t-body);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
h1, h2, h3, h4 { margin: 0; font-family: var(--f-display); font-weight: 700; text-wrap: balance; }
p { margin: 0; }
a { color: var(--accent-ink); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; height: auto; }
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }
:focus-visible { outline: none; box-shadow: var(--ring); border-radius: var(--r-sm); }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--hairline-strong); border-radius: var(--r-pill); border: 3px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-track { background: transparent; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* Mixed-direction content: English titles, URLs and filenames must not flip. */
.bidi { unicode-bidi: plaintext; }
.ltr { direction: ltr; text-align: start; unicode-bidi: isolate; }
.num { font-variant-numeric: tabular-nums; font-feature-settings: "tnum" 1; }

/* ========================= app shell ========================= */
.app { display: flex; min-height: 100vh; min-height: 100dvh; }

.rail {
  position: sticky; top: 0; align-self: flex-start;
  width: var(--rail); flex: 0 0 var(--rail);
  height: 100vh; height: 100dvh;
  background: var(--surface);
  border-inline-end: 1px solid var(--hairline);
  display: flex; flex-direction: column;
  transition: width .18s ease, flex-basis .18s ease;
  z-index: 40;
}
.rail.collapsed { width: var(--rail-collapsed); flex-basis: var(--rail-collapsed); }

.rail-top {
  display: flex; align-items: center; gap: 10px;
  padding: 16px var(--pad) 14px;
  min-height: var(--header-h);
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; flex: 1; }
.brand-mark {
  width: 30px; height: 30px; flex: 0 0 30px; border-radius: 9px;
  background: linear-gradient(150deg, var(--accent), var(--accent-ink));
  display: grid; place-items: center; color: #fff;
}
/* The two brand lines stack; without this they sit inline and the name clips. */
.brand-text { display: flex; flex-direction: column; min-width: 0; gap: 1px; }
.brand-name {
  font-family: var(--f-display); font-weight: 800; font-size: 14px;
  letter-spacing: .01em; line-height: 1.15; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis;
}
.brand-sub {
  font-size: 11px; line-height: 1.2; color: var(--muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.topbar-brand .brand-name { font-size: 13px; }
.rail.collapsed .brand-text,
.rail.collapsed .nav-label,
.rail.collapsed .nav-item span,
.rail.collapsed .rail-foot-text { display: none; }
.rail.collapsed .rail-top { justify-content: center; padding-inline: 0; }

.rail-toggle {
  width: 28px; height: 28px; flex: 0 0 28px; display: grid; place-items: center;
  border: 1px solid var(--hairline); background: var(--surface); color: var(--muted);
  border-radius: var(--r-sm); cursor: pointer;
}
.rail-toggle:hover { background: var(--surface-sunken); color: var(--ink); }
.rail.collapsed .rail-toggle .material-symbols-rounded { transform: rotate(180deg); }

.nav { flex: 1; overflow-y: auto; padding: 4px 12px 12px; }
.rail.collapsed .nav { padding-inline: 10px; }
.nav-group + .nav-group { margin-top: 14px; }
.nav-label {
  font-size: var(--t-label); font-weight: 700; letter-spacing: .1em;
  text-transform: uppercase; color: var(--faint);
  padding: 0 10px 6px;
}
.nav-item {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 8px 10px; margin-bottom: 2px;
  border: 0; background: none; color: var(--ink-2);
  border-radius: var(--r); cursor: pointer; text-align: start;
  font-size: var(--t-body); font-weight: 500;
  position: relative; white-space: nowrap;
}
.nav-item .material-symbols-rounded { flex: 0 0 18px; color: var(--faint); }
.nav-item:hover { background: var(--surface-sunken); color: var(--ink); }
.nav-item:hover .material-symbols-rounded { color: var(--ink-2); }
.nav-item.active { background: var(--accent-wash); color: var(--accent-ink); font-weight: 600; }
.nav-item.active .material-symbols-rounded { color: var(--accent); }
.rail.collapsed .nav-item { justify-content: center; padding-inline: 0; }
.nav-count {
  margin-inline-start: auto; font-size: 11px; font-weight: 700;
  background: var(--surface-sunken); color: var(--muted);
  border-radius: var(--r-pill); padding: 1px 7px; min-width: 20px; text-align: center;
}
.nav-item.active .nav-count { background: var(--surface); color: var(--accent-ink); }

.rail-foot { border-top: 1px solid var(--hairline); padding: 10px 12px; }
.rail-foot .nav-item { font-size: 13px; }

/* collapsed-rail tooltips */
.rail.collapsed .nav-item::after {
  content: attr(data-tip);
  position: absolute; inset-inline-start: calc(100% + 8px); top: 50%; transform: translateY(-50%);
  background: var(--ink); color: var(--ground);
  padding: 5px 9px; border-radius: var(--r-sm); font-size: 12px; font-weight: 600;
  white-space: nowrap; opacity: 0; pointer-events: none; transition: opacity .12s; z-index: 60;
}
.rail.collapsed .nav-item:hover::after { opacity: 1; }

/* ========================= main column ========================= */
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 12px;
  min-height: var(--header-h); padding: 10px clamp(16px, 3vw, 32px);
  background: var(--ground);
  border-bottom: 1px solid var(--hairline);
}
.btn.hamburger { display: none; }
.topbar-brand { display: none; align-items: center; gap: 8px; min-width: 0; }
.topbar-spacer { flex: 1; }
.topbar-date { font-size: var(--t-meta); color: var(--muted); white-space: nowrap; }
.page { padding: clamp(16px, 3vw, 28px) clamp(16px, 3vw, 32px) 56px; }

.page-head { display: flex; align-items: flex-start; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.page-head-text { min-width: 0; flex: 1 1 320px; }
.page-title { font-size: var(--t-page); line-height: 1.2; letter-spacing: -.015em; }
.page-sub { color: var(--muted); font-size: var(--t-body); margin-top: 4px; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ========================= grid ========================= */
.grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: var(--gap); }
.col-3 { grid-column: span 3; }
.col-4 { grid-column: span 4; }
.col-5 { grid-column: span 5; }
.col-6 { grid-column: span 6; }
.col-7 { grid-column: span 7; }
.col-8 { grid-column: span 8; }
.col-9 { grid-column: span 9; }
.col-12 { grid-column: span 12; }
.stack { display: flex; flex-direction: column; gap: var(--gap); }
.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* ========================= card ========================= */
.card {
  background: var(--surface); border: 1px solid var(--hairline);
  border-radius: var(--r-lg); overflow: hidden;
  display: flex; flex-direction: column;
}
.card-head {
  display: flex; align-items: center; gap: 10px;
  padding: 14px var(--pad); border-bottom: 1px solid var(--hairline);
}
.card-title { font-size: var(--t-card); font-weight: 700; font-family: var(--f-display); letter-spacing: -.01em; }
.card-head .spacer { flex: 1; }
.card-body { padding: var(--pad); flex: 1; }
.card-body.flush { padding: 0; }
.card-foot { padding: 12px var(--pad); border-top: 1px solid var(--hairline); background: var(--surface-2); }

/* KPI tile — deliberately flatter than a card: it is a figure, not an object */
.kpi { background: var(--surface); border: 1px solid var(--hairline); border-radius: var(--r-lg); padding: 16px 18px; display: flex; align-items: flex-start; gap: 12px; }
.kpi-body { min-width: 0; flex: 1; }
.kpi-value { font-family: var(--f-display); font-size: var(--t-kpi); font-weight: 800; line-height: 1.1; letter-spacing: -.02em; }
.kpi-label { font-size: var(--t-meta); color: var(--muted); margin-top: 2px; }
.kpi-icon { width: 34px; height: 34px; flex: 0 0 34px; border-radius: 10px; display: grid; place-items: center; background: var(--surface-sunken); color: var(--muted); }
.kpi-delta { font-size: var(--t-meta); font-weight: 700; margin-top: 4px; display: inline-flex; align-items: center; gap: 3px; }
.kpi-delta.up { color: var(--st-done); }
.kpi-delta.down { color: var(--st-waiting); }

/* ========================= pills, chips, badges ========================= */
.pill {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: var(--t-meta); font-weight: 600; line-height: 1.4;
  padding: 2px 9px; border-radius: var(--r-pill);
  background: var(--st-idle-wash); color: var(--st-idle);
  white-space: nowrap;
}
.pill .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex: 0 0 6px; }
.pill.done { background: var(--st-done-wash); color: var(--st-done); }
.pill.active { background: var(--st-active-wash); color: var(--st-active); }
.pill.waiting { background: var(--st-waiting-wash); color: var(--st-waiting); }
.pill.open { background: var(--st-open-wash); color: var(--st-open); }
.pill.idle { background: var(--st-idle-wash); color: var(--st-idle); }
.pill.accent { background: var(--accent-wash); color: var(--accent-ink); }
.pill.plain { background: var(--surface-sunken); color: var(--muted); font-weight: 500; }

.chip {
  display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid var(--hairline); background: var(--surface);
  color: var(--ink-2); border-radius: var(--r-pill);
  padding: 5px 12px; font-size: var(--t-meta); font-weight: 600;
  cursor: pointer; white-space: nowrap;
}
.chip:hover { border-color: var(--hairline-strong); background: var(--surface-2); }
.chip.on { background: var(--ink); border-color: var(--ink); color: var(--ground); }
.chip .n { opacity: .65; font-weight: 500; }

.chips { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.chips-scroll { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: thin; }
.chips-scroll > * { flex: 0 0 auto; }

/* ========================= tabs ========================= */
.tabs { display: flex; gap: 2px; overflow-x: auto; border-bottom: 1px solid var(--hairline); scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab {
  flex: 0 0 auto; border: 0; background: none; cursor: pointer;
  padding: 9px 13px; font-size: var(--t-body); font-weight: 600; color: var(--muted);
  border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap;
}
.tab:hover { color: var(--ink); }
.tab.on { color: var(--ink); border-bottom-color: var(--accent); }

/* ========================= buttons ========================= */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border-radius: var(--r); border: 1px solid var(--hairline);
  background: var(--surface); color: var(--ink-2);
  padding: 8px 14px; font-size: var(--t-body); font-weight: 600;
  cursor: pointer; min-height: 38px; white-space: nowrap;
}
.btn:hover { background: var(--surface-2); border-color: var(--hairline-strong); color: var(--ink); }
.btn.primary { background: var(--ink); border-color: var(--ink); color: var(--ground); }
.btn.primary:hover { background: var(--ink-2); border-color: var(--ink-2); }
.btn.accent { background: var(--accent); border-color: var(--accent); color: var(--surface); }
.btn.accent:hover { filter: brightness(1.06); }
.btn.sm { padding: 5px 10px; min-height: 30px; font-size: var(--t-meta); }
.btn.icon { padding: 0; width: 34px; min-height: 34px; flex: 0 0 34px; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.danger { color: var(--st-waiting); border-color: var(--st-waiting-wash); }
.btn.danger:hover { background: var(--st-waiting-wash); }

/* ========================= inputs ========================= */
.field {
  display: flex; align-items: center; gap: 8px;
  border: 1px solid var(--hairline); background: var(--surface);
  border-radius: var(--r); padding: 0 10px; min-height: 38px;
  color: var(--muted); min-width: 0;
}
.field:focus-within { border-color: var(--accent-hairline); box-shadow: var(--ring); }
.field input, .field select, .field textarea {
  flex: 1; min-width: 0; border: 0; background: none; outline: none;
  padding: 8px 0; color: var(--ink); font-size: var(--t-body);
}
.field textarea { resize: vertical; min-height: 60px; line-height: 1.5; }
select.bare {
  border: 1px solid var(--hairline); background: var(--surface); color: var(--ink);
  border-radius: var(--r-sm); padding: 5px 8px; font-size: var(--t-meta); font-weight: 600; cursor: pointer;
  min-height: 30px; max-width: 100%;
}
select.bare:focus-visible { box-shadow: var(--ring); }
.label { display: block; font-size: var(--t-label); font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--faint); margin-bottom: 6px; }

/* checkbox */
.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; user-select: none; }
.check input { position: absolute; opacity: 0; width: 0; height: 0; }
.check .box {
  width: 18px; height: 18px; flex: 0 0 18px; border-radius: 5px;
  border: 1.5px solid var(--hairline-strong); background: var(--surface);
  display: grid; place-items: center; color: transparent; transition: all .12s;
}
.check input:checked + .box { background: var(--st-done); border-color: var(--st-done); color: var(--surface); }
.check input:focus-visible + .box { box-shadow: var(--ring); }
.check:hover .box { border-color: var(--accent); }

/* The labelled variant: a list you work through, where the box is the point. */
.check.lg {
  gap: 9px; padding: 5px 10px 5px 12px; border-radius: var(--r-pill);
  border: 1px solid var(--hairline); background: var(--surface);
  font-size: var(--t-meta); font-weight: 600; color: var(--muted);
}
.check.lg .box { width: 22px; height: 22px; flex-basis: 22px; border-radius: 6px; border-width: 2px; }
.check.lg:hover { border-color: var(--hairline-strong); background: var(--surface-2); }
.check.lg:has(input:checked) { border-color: var(--st-done); color: var(--st-done); background: var(--st-done-wash); }

/* ========================= progress ========================= */
.bar { height: 6px; border-radius: var(--r-pill); background: var(--surface-sunken); overflow: hidden; }
.bar > i { display: block; height: 100%; border-radius: var(--r-pill); background: var(--accent); transition: width .3s ease; }
.bar.done > i { background: var(--st-done); }
.bar.thin { height: 4px; }

/* ========================= list rows ========================= */
.rows { display: flex; flex-direction: column; }
.list-row {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 11px var(--pad); border-bottom: 1px solid var(--hairline);
  min-width: 0;
}
.rows > .list-row:last-child { border-bottom: 0; }
.list-row:hover { background: var(--surface-2); }
.list-row .grow { flex: 1; min-width: 0; }
.row-title { font-size: var(--t-body); font-weight: 600; color: var(--ink); overflow-wrap: anywhere; }
.row-title.is-done { color: var(--muted); text-decoration: line-through; text-decoration-color: var(--faint); }
.row-meta { font-size: var(--t-meta); color: var(--muted); margin-top: 2px; overflow-wrap: anywhere; }
.row-side { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }

/* ========================= table ========================= */
.table-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-size: var(--t-body); }
table.tbl th {
  text-align: start; font-size: var(--t-label); font-weight: 700; letter-spacing: .07em;
  text-transform: uppercase; color: var(--faint); padding: 10px var(--pad);
  border-bottom: 1px solid var(--hairline); white-space: nowrap; background: var(--surface-2);
}
table.tbl td { padding: 11px var(--pad); border-bottom: 1px solid var(--hairline); vertical-align: top; }
table.tbl tr:last-child td { border-bottom: 0; }
table.tbl tbody tr:hover { background: var(--surface-2); }
/* A denser variant for tables with many columns, so less horizontal scroll is needed. */
table.tbl.compact th { padding: 7px 10px; }
table.tbl.compact td { padding: 7px 10px; }

/* ========================= misc ========================= */
.empty { text-align: center; padding: 44px 20px; color: var(--muted); }
.empty .ico { width: 44px; height: 44px; border-radius: 12px; background: var(--surface-sunken); color: var(--faint); display: grid; place-items: center; margin: 0 auto 12px; }
.empty h4 { font-size: var(--t-card); color: var(--ink); margin-bottom: 4px; }
.empty p { font-size: var(--t-meta); max-width: 44ch; margin: 0 auto; }

.note {
  font-size: var(--t-meta); color: var(--muted);
  background: var(--surface-sunken); border-radius: var(--r);
  padding: 10px 12px; border-inline-start: 3px solid var(--hairline-strong);
}
.note.warn { background: var(--st-open-wash); color: var(--st-open); border-inline-start-color: var(--st-open); }

.section-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.section-head h3 { font-size: var(--t-section); letter-spacing: -.01em; }
.section-head .spacer { flex: 1; }

.prose { font-size: var(--t-body); line-height: 1.75; color: var(--ink-2); white-space: pre-wrap; overflow-wrap: anywhere; }
.prose h3 { font-size: var(--t-card); margin: 16px 0 6px; color: var(--ink); }

/* modal + drawer */
/* The modal centers itself as a flex child of .scrim rather than via its own
   position:fixed + transform - an ancestor transform (e.g. a scaled preview
   frame) turns position:fixed into "relative to that ancestor", which pinned
   the modal to one edge and clipped it. Flex-centering inside .scrim (which
   already covers the available box, transformed ancestor or not) is immune
   to that. */
.scrim {
  position: fixed; inset: 0; background: rgba(9, 14, 23, .45); z-index: 90; border: 0; padding: 16px;
  display: flex; align-items: center; justify-content: center; overflow: auto;
}
.modal {
  width: min(640px, calc(100vw - 32px));
  max-height: calc(100vh - 64px); overflow: auto;
  background: var(--surface); border: 1px solid var(--hairline);
  border-radius: var(--r-lg); box-shadow: var(--shadow-float);
  flex: 0 0 auto;
}
.drawer {
  position: fixed; inset-block: 0; inset-inline-start: 0; z-index: 91;
  width: min(292px, 84vw); background: var(--surface);
  border-inline-end: 1px solid var(--hairline); box-shadow: var(--shadow-float);
  display: flex; flex-direction: column;
}

/* ========================= responsive ========================= */
@media (max-width: 1279px) {
  .col-3 { grid-column: span 6; }
  .col-4 { grid-column: span 6; }
  .col-5, .col-7, .col-8, .col-9 { grid-column: span 12; }
}
@media (max-width: 1023px) {
  /* The rail still obeys the user's open/closed switch at this width - it no
     longer forces icon-only, since that made the switch look broken. */
  .col-6 { grid-column: span 12; }
}
@media (max-width: 767px) {
  :root { --pad: 15px; --gap: 12px; --t-page: 21px; --t-kpi: 25px; }
  .rail { display: none; }
  .btn.hamburger { display: inline-flex; }
  .topbar-brand { display: inline-flex; }
  .topbar-date { display: none; }
  .grid > * { grid-column: span 12; }
  /* KPI figures stay two-up: they are short, and stacking four wastes the fold */
  .grid.kpis > * { grid-column: span 6; }
  .kpi { padding: 13px 14px; flex-direction: column; gap: 8px; }
  .kpi-icon { order: -1; }
  .page { padding-bottom: 40px; }
  .page-head { margin-bottom: 16px; }
  .btn { min-height: 40px; }
  .list-row { flex-wrap: wrap; }
  .row-side { width: 100%; justify-content: flex-start; }

  /* tables reflow into stacked cards rather than scrolling sideways */
  table.tbl, table.tbl tbody, table.tbl tr, table.tbl td { display: block; width: 100%; }
  table.tbl thead { display: none; }
  table.tbl tr { border-bottom: 1px solid var(--hairline); padding: 12px var(--pad); }
  table.tbl tr:last-child { border-bottom: 0; }
  table.tbl td { border: 0; padding: 3px 0; display: flex; gap: 10px; align-items: flex-start; }
  table.tbl td::before {
    content: attr(data-th); flex: 0 0 34%; font-size: var(--t-label); font-weight: 700;
    letter-spacing: .06em; text-transform: uppercase; color: var(--faint); padding-top: 2px;
  }
  table.tbl td[data-th=""]::before { display: none; }
}

/* ========================= task boards ========================= */
.boards {
  display: flex; gap: var(--gap); align-items: flex-start;
  overflow-x: auto; padding-bottom: 10px;
}
.board-col { flex: 0 0 300px; max-width: 300px; }
.board {
  background: var(--surface-sunken); border: 1px solid var(--hairline);
  border-radius: var(--r-lg); display: flex; flex-direction: column;
}
.board-head {
  display: flex; align-items: center; gap: 6px;
  padding: 10px 12px; border-bottom: 1px solid var(--hairline);
  background: var(--hairline-strong); border-radius: var(--r-lg) var(--r-lg) 0 0;
}
.board-name {
  flex: 1; min-width: 0; border: 0; background: none; cursor: text;
  font-family: var(--f-display); font-weight: 700; font-size: var(--t-card);
  color: var(--ink); text-align: start; padding: 2px 4px; border-radius: var(--r-sm);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.board-name:hover { background: var(--surface); }
.board-head .btn.icon { width: 26px; min-height: 26px; flex: 0 0 26px; }
.board-cards { position: relative; padding: 10px; display: flex; flex-direction: column; gap: 8px; }
.board-card {
  display: flex; align-items: flex-start; gap: 8px;
  background: var(--surface); border: 1px solid var(--hairline);
  border-radius: var(--r); padding: 10px 11px;
}
.board-card .grow { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.board-card .btn.icon { width: 24px; min-height: 24px; flex: 0 0 24px; opacity: 0; }
.board-card:hover .btn.icon, .board-card:focus-within .btn.icon { opacity: 1; }
.board-card-add, .board-add {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  width: 100%; border: 1px dashed var(--hairline-strong); background: none;
  color: var(--muted); border-radius: var(--r); padding: 9px 12px;
  cursor: pointer; font-size: var(--t-meta); font-weight: 600;
}
.board-card-add:hover, .board-add:hover { background: var(--surface); color: var(--ink); border-color: var(--accent); }
.board-add { padding: 14px 12px; border-radius: var(--r-lg); }

/* a completed day or reply recedes without disappearing */
.card.is-muted { opacity: .62; }
.card.is-muted:hover { opacity: 1; }

/* a row of move targets in the move dialog */
.move-target {
  border: 0; background: none; width: 100%; text-align: start;
  font: inherit; color: inherit; cursor: pointer;
  align-items: center;
}
.move-target:disabled { cursor: default; opacity: .65; }
.move-target:not(:disabled):hover { background: var(--surface-2); }
.move-target .material-symbols-rounded { color: var(--faint); }

/* --- board drag and drop --- */
.board-head { cursor: grab; }
.board-head:active { cursor: grabbing; }
.board-grip { color: var(--faint); display: inline-flex; flex: 0 0 auto; }
.board-head:hover .board-grip { color: var(--muted); }
.board-col.is-dragging { opacity: .4; }
.board-col.is-over .board { outline: 2px dashed var(--accent); outline-offset: 2px; }
/* keep the pointer on the columns while a drag is in flight */
/* Only a BOARD drag locks the cards out; a card drag needs them droppable. */
.boards.dragging-board .board-cards,
.boards.dragging-board .board-name,
.boards.dragging-board .board-head .btn { pointer-events: none; }

/* --- board totals, card meta, card drag --- */
.board-total {
  display: flex; align-items: center; gap: 6px;
  padding: 7px 12px; border-bottom: 1px solid var(--hairline);
  font-size: var(--t-meta); font-weight: 700; color: var(--ink-2);
}
.board-total .material-symbols-rounded { color: var(--muted); flex: 0 0 auto; }
.board-total-sub { font-weight: 500; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.board-card { flex-direction: column; gap: 7px; }
.board-card-top { display: flex; align-items: flex-start; gap: 8px; width: 100%; }
.board-card-detail {
  border-top: 1px dashed var(--hairline);
  padding-top: 7px;
  display: flex; flex-direction: column; gap: 6px; width: 100%;
}
.board-card-meta { display: flex; align-items: center; gap: 6px; width: 100%; }
.board-card-meta select.bare {
  flex: 1; min-width: 0; min-height: 26px; padding: 2px 6px;
  font-size: 11.5px; font-weight: 500; color: var(--muted);
  border-color: transparent; background: transparent;
}
.board-card:hover .board-card-meta select.bare { border-color: var(--hairline); background: var(--surface); }
.cat-dot { width: 9px; height: 9px; border-radius: 3px; flex: 0 0 9px; }

.est {
  display: inline-flex; align-items: center; gap: 3px; flex: 0 0 auto;
  border: 1px solid transparent; border-radius: var(--r-sm);
  padding: 2px 5px; color: var(--muted); font-size: 11.5px;
}
.board-card:hover .est, .est:focus-within { border-color: var(--hairline); background: var(--surface); }
.est input {
  width: 42px; border: 0; background: none; outline: none; padding: 0;
  font-size: 11.5px; font-weight: 700; color: var(--ink);
  font-variant-numeric: tabular-nums; text-align: center;
}
.est input::-webkit-outer-spin-button, .est input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.est input[type=number] { -moz-appearance: textfield; appearance: textfield; }
.est-unit { color: var(--faint); }

.board-card[draggable="true"] { cursor: grab; }
.board-card[draggable="true"]:active { cursor: grabbing; }
.board-card.is-dragging {
  opacity: 0;
  pointer-events: none;
}
.boards.dragging-card .board-card,
.boards.dragging-card .board-card-add {
  transition: transform 180ms cubic-bezier(0.2, 0, 0, 1);
}
.boards.dragging-card .board-cards {
  transition: padding-bottom 180ms cubic-bezier(0.2, 0, 0, 1), margin-bottom 180ms cubic-bezier(0.2, 0, 0, 1);
}

.swatch {
  width: 16px; height: 16px; border-radius: 5px; cursor: pointer;
  border: 2px solid transparent; padding: 0;
}
.swatch.on { border-color: var(--ink); }

/* --- the boards scroll from a sticky rail, since the columns are page-tall --- */
.boards-rail {
  position: sticky;
  top: calc(var(--header-h) + 4px);
  z-index: 20;
  overflow-x: auto;
  overflow-y: hidden;
  height: 14px;
  margin-bottom: 4px;
  background: var(--ground);
  border-radius: var(--r-pill);
}
.boards-rail.is-idle { display: none; }
.boards-rail::-webkit-scrollbar { height: 10px; }
.boards-rail::-webkit-scrollbar-thumb {
  background: var(--hairline-strong); border-radius: var(--r-pill);
  border: 2px solid transparent; background-clip: content-box;
}
.boards-rail:hover::-webkit-scrollbar-thumb { background: var(--muted); background-clip: content-box; }
.boards-rail::-webkit-scrollbar-track { background: transparent; }
/* the container still scrolls, it just no longer shows its own bar at the bottom */
.boards { scrollbar-width: none; padding-bottom: 0; }
.boards::-webkit-scrollbar { display: none; }

@media (max-width: 767px) {
  /* One board fills most of the screen, with the next peeking so the swipe
     affordance is obvious. */
  .board-col { flex-basis: 86vw; max-width: 86vw; }

  /* The rail is a 10px scrollbar: fine for a cursor, not for a thumb. On touch
     the columns are swiped directly, and snapping lands them square. */
  .boards-rail { display: none; }
  .boards {
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: auto;
    padding-bottom: 6px;
  }
  .boards::-webkit-scrollbar { display: block; height: 4px; }
  .board-col { scroll-snap-align: center; }

  /* Hover can never fire, so nothing may depend on it to become visible. */
  .board-card .btn.icon,
  .board-card .board-card-meta select.bare,
  .board-card .est { opacity: 1; }
  .board-card .board-card-meta select.bare { border-color: var(--hairline); background: var(--surface); }
  .board-card .est { border-color: var(--hairline); background: var(--surface); }

  /* Touch targets: 26px icons are too small to hit reliably. */
  .board-head { gap: 4px; padding: 8px 10px; }
  .board-head .btn.icon { width: 34px; min-height: 34px; flex: 0 0 34px; }
  .board-card .btn.icon { width: 32px; min-height: 32px; flex: 0 0 32px; }
  .board-card { padding: 12px; gap: 9px; }
  .board-card-meta select.bare { min-height: 34px; font-size: 12.5px; }
  .est { padding: 4px 7px; }
  .est input { width: 46px; font-size: 12.5px; }
  .board-card-add, .board-add { padding: 12px; }
  .board-name { font-size: var(--t-card); }
}

/* ========================= toast ========================= */
.toast-stack {
  position: fixed;
  bottom: 24px;
  inset-inline-end: 24px;
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: calc(100vw - 32px);
  pointer-events: none;
}
.toast {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: var(--r-lg);
  background: var(--ink);
  color: var(--ground);
  box-shadow: var(--shadow-float);
  font-size: var(--t-body);
  animation: toast-in .18s ease-out;
}
.toast-msg {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 280px;
}
.toast-undo {
  border: 0;
  background: none;
  padding: 2px 4px;
  color: inherit;
  font: inherit;
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
  flex: 0 0 auto;
}
.toast-undo:hover { opacity: .85; }
.toast-undo:focus-visible { outline: none; box-shadow: var(--ring); border-radius: var(--r-sm); }
.toast-close {
  border: 0;
  background: none;
  padding: 0 4px;
  color: var(--faint);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  flex: 0 0 auto;
}
.toast-close:hover { color: var(--ground); }
@keyframes toast-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
@media (max-width: 767px) {
  .toast-stack {
    bottom: 16px;
    inset-inline: 16px;
    align-items: stretch;
  }
  .toast-msg { max-width: none; flex: 1; }
}

.material-symbols-rounded {
  font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 20;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  user-select: none;
}

/* ========================= auth gate & card images ========================= */
.auth-screen {
  min-height: 100vh; min-height: 100dvh;
  display: grid; place-items: center; padding: 32px 24px;
  background: var(--ground);
}
.auth-editorial {
  width: 100%; max-width: 680px;
  display: flex; flex-direction: column; align-items: center; text-align: center;
}
.auth-quote {
  margin: 0;
  font-family: 'Playfair Display', Georgia, 'Times New Roman', serif;
  font-size: clamp(28px, 4.4vw, 44px);
  font-weight: 400;
  line-height: 1.26;
  letter-spacing: -0.015em;
  color: var(--ink);
  text-wrap: balance;
}
.auth-author {
  margin: 18px 0 0;
  font-family: var(--f-ui);
  font-size: 14px;
  font-weight: 500;
  letter-spacing: 0.04em;
  color: var(--muted);
}
.auth-actions {
  margin-top: 32px;
  display: flex; flex-direction: column; align-items: center; gap: 12px;
}
.auth-google-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  min-height: 44px; padding: 10px 22px;
  border-radius: var(--r-pill);
  border: 1px solid var(--hairline-strong);
  background: var(--surface);
  color: var(--ink);
  font-family: var(--f-ui);
  font-size: 14.5px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: var(--shadow-raised);
  transition: background-color 150ms ease, border-color 150ms ease, transform 150ms ease, box-shadow 150ms ease;
}
.auth-google-btn:hover:not(:disabled) {
  background: var(--surface-2);
  border-color: var(--ink-2);
  box-shadow: var(--shadow-float);
}
.auth-google-btn:active:not(:disabled) {
  transform: translateY(1px);
}
.auth-google-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}
.auth-error {
  margin: 0;
  font-size: var(--t-meta);
  color: var(--st-waiting);
  max-width: 420px;
}

.card-thumbs {
  display: flex; flex-wrap: wrap; gap: 6px; width: 100%;
}
.card-thumb {
  border: 1px solid var(--hairline); background: var(--surface-sunken);
  border-radius: var(--r-sm); padding: 0; overflow: hidden; cursor: zoom-in;
  width: 64px; height: 48px; flex: 0 0 auto;
}
.card-thumb img {
  width: 100%; height: 100%; object-fit: cover; display: block;
}
.card-thumb:hover { border-color: var(--accent); }

.card-img-bar {
  display: flex; flex-direction: column; gap: 6px; width: 100%;
}
.card-thumbs-edit {
  display: flex; flex-wrap: wrap; gap: 6px;
}
.card-thumb-wrap {
  position: relative; width: 64px; height: 48px;
  border-radius: var(--r-sm); overflow: hidden;
  border: 1px solid var(--hairline); background: var(--surface-sunken);
}
.card-thumb-wrap img {
  width: 100%; height: 100%; object-fit: cover; display: block;
}
.card-thumb-del {
  position: absolute; top: 2px; right: 2px;
  width: 18px; height: 18px; border-radius: 999px;
  border: 0; background: rgba(15, 23, 42, .75); color: #fff;
  font-size: 13px; line-height: 1; cursor: pointer;
  display: grid; place-items: center;
}
.card-thumb-del:hover { background: var(--st-waiting); }

.lightbox-img {
  display: block; max-width: 100%; max-height: 75vh;
  margin: 0 auto; border-radius: var(--r);
}
