/* Sunso Portal — one stylesheet, no framework.
   Fonts: braik brand (Figtree, Archivo Narrow), self-hosted, OFL.
   Colour: semantic tokens only; components never use raw hex.
   Chart series colours are the validated dataviz palette (slot 1 + neutral comparison). */

@font-face { font-family: "Figtree"; font-weight: 400; font-display: swap; src: url("/static/fonts/figtree-latin-400-normal.woff2") format("woff2"); }
@font-face { font-family: "Figtree"; font-weight: 500; font-display: swap; src: url("/static/fonts/figtree-latin-500-normal.woff2") format("woff2"); }
@font-face { font-family: "Figtree"; font-weight: 600; font-display: swap; src: url("/static/fonts/figtree-latin-600-normal.woff2") format("woff2"); }
@font-face { font-family: "Figtree"; font-weight: 700; font-display: swap; src: url("/static/fonts/figtree-latin-700-normal.woff2") format("woff2"); }
@font-face { font-family: "Archivo Narrow"; font-weight: 700; font-display: swap; src: url("/static/fonts/archivo-narrow-700.woff2") format("woff2"); }

/* ------------------------------------------------------------------ tokens */
:root {
  color-scheme: light;
  --bg: #f5f7fa;
  --surface: #ffffff;
  --surface-2: #f1f4f8;
  --surface-3: #e8edf3;
  --border: #e1e7ef;
  --border-strong: #c9d3df;
  --text: #0f1b2d;
  --text-2: #44536a;
  --text-3: #5f6e84;          /* 4.9:1 on --surface, still AA for small text */
  --accent: #1f5fbf;          /* links, primary buttons: 6.1:1 on white */
  --accent-hover: #184c9a;
  --accent-soft: #e6eefb;
  --on-accent: #ffffff;
  --brand: #6994c6;           /* braik brand blue: graphics only, never body text */
  --focus: #1f5fbf;

  --good: #166534;  --good-bg: #e3f6e8;  --good-line: #9fdcb0;
  --warn: #92400e;  --warn-bg: #fdf1d8;  --warn-line: #f2cf86;
  --bad:  #b42318;  --bad-bg:  #fde8e6;  --bad-line:  #f4b4ad;
  --info: #1e4f9c;  --info-bg: #e6eefb;  --info-line: #a9c4ee;
  --muted-tone: #4b5a70; --muted-bg: #eef1f5; --muted-line: #d5dce6;

  --series-1: #257de0;        /* dataviz slot 1 (validated, light) */
  --series-prev: #9aa6b6;     /* previous period: neutral comparison, dashed */
  --grid: #e9eef4;

  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(15, 27, 45, 0.05);
  --sp-1: 4px; --sp-2: 8px; --sp-3: 12px; --sp-4: 16px; --sp-5: 24px; --sp-6: 32px; --sp-7: 48px;
  --sidebar: 252px;
}

/* Dark mode is selected, not inverted: own steps, validated against its surface. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0d1219; --surface: #141b24; --surface-2: #1a222d; --surface-3: #222c39;
    --border: #253041; --border-strong: #33415a;
    --text: #e8edf4; --text-2: #b0bccc; --text-3: #94a1b3;
    --accent: #7eb0ff; --accent-hover: #a3c7ff; --accent-soft: #1b2b45; --on-accent: #0d1219;
    --focus: #7eb0ff;
    --good: #6ee08f; --good-bg: #12301d; --good-line: #23603a;
    --warn: #f7c35c; --warn-bg: #33270f; --warn-line: #6a5120;
    --bad: #ff8f84;  --bad-bg: #3a1714;  --bad-line: #74302a;
    --info: #8fb8ff; --info-bg: #17284a; --info-line: #2f4c80;
    --muted-tone: #aab6c6; --muted-bg: #1d2531; --muted-line: #313d4f;
    --series-1: #338ced; --series-prev: #66758a; --grid: #212b38;
    --shadow: none;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0d1219; --surface: #141b24; --surface-2: #1a222d; --surface-3: #222c39;
  --border: #253041; --border-strong: #33415a;
  --text: #e8edf4; --text-2: #b0bccc; --text-3: #94a1b3;
  --accent: #7eb0ff; --accent-hover: #a3c7ff; --accent-soft: #1b2b45; --on-accent: #0d1219;
  --focus: #7eb0ff;
  --good: #6ee08f; --good-bg: #12301d; --good-line: #23603a;
  --warn: #f7c35c; --warn-bg: #33270f; --warn-line: #6a5120;
  --bad: #ff8f84;  --bad-bg: #3a1714;  --bad-line: #74302a;
  --info: #8fb8ff; --info-bg: #17284a; --info-line: #2f4c80;
  --muted-tone: #aab6c6; --muted-bg: #1d2531; --muted-line: #313d4f;
  --series-1: #338ced; --series-prev: #66758a; --grid: #212b38;
  --shadow: none;
}

/* ------------------------------------------------------------------ base */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 400 16px/1.5 "Figtree", system-ui, -apple-system, "Segoe UI", sans-serif;
  font-feature-settings: "tnum" 1; /* tabular numbers: columns of figures line up */
}
h1, h2, h3 { margin: 0; line-height: 1.25; }
h1 { font: 700 1.9rem/1.15 "Archivo Narrow", "Figtree", sans-serif; letter-spacing: 0.005em; }
h2 { font-size: 1.05rem; font-weight: 600; }
h3 { font-size: 0.95rem; font-weight: 600; }
p { margin: 0; }
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); text-decoration: underline; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
.icon { width: 18px; height: 18px; flex: none; vertical-align: -3px; }
.icon-lg .icon, .icon.lg { width: 22px; height: 22px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--text-3); }
.small { font-size: 0.875rem; }
.mono { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: 0.85rem; }
.nowrap { white-space: nowrap; }
.stack > * + * { margin-top: var(--sp-4); }
.stack-sm > * + * { margin-top: var(--sp-2); }
.row { display: flex; align-items: center; gap: var(--sp-3); flex-wrap: wrap; }
.spacer { flex: 1; }

/* ------------------------------------------------------------------ shell */
.shell { display: grid; grid-template-columns: var(--sidebar) 1fr; min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
  background: var(--surface); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; padding: var(--sp-4) var(--sp-3);
}
.brand { display: flex; align-items: center; gap: var(--sp-3); padding: var(--sp-2) var(--sp-3) var(--sp-4); }
.brand-mark {
  width: 34px; height: 34px; border-radius: 9px; background: var(--brand); color: #0d1219;
  display: grid; place-items: center; font: 700 1.05rem "Archivo Narrow", sans-serif;
}
.brand-name { font-weight: 700; line-height: 1.1; }
.brand-area { font-size: 0.78rem; color: var(--text-3); }
.area-ops .brand-mark { background: var(--text); color: var(--surface); }
.nav-section { margin-top: var(--sp-4); }
.nav-title {
  padding: 0 var(--sp-3) var(--sp-2); font-size: 0.72rem; font-weight: 600; letter-spacing: 0.07em;
  text-transform: uppercase; color: var(--text-3);
}
.nav a {
  display: flex; align-items: center; gap: var(--sp-3); min-height: 40px; padding: 0 var(--sp-3);
  border-radius: var(--radius-sm); color: var(--text-2); font-weight: 500; position: relative;
  transition: background-color 150ms ease, color 150ms ease;
}
.nav a:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.nav a[aria-current="page"] { background: var(--accent-soft); color: var(--accent); }
.nav a[aria-current="page"]::before {
  content: ""; position: absolute; left: -12px; top: 8px; bottom: 8px; width: 3px; border-radius: 0 3px 3px 0; background: var(--accent);
}
.nav .count {
  margin-left: auto; min-width: 22px; padding: 0 7px; border-radius: 999px; font-size: 0.75rem; font-weight: 600;
  line-height: 20px; text-align: center;
}
.count.warn { background: var(--warn-bg); color: var(--warn); }
.count.muted { background: var(--muted-bg); color: var(--text-3); font-weight: 500; }
.sidebar-foot { margin-top: auto; padding-top: var(--sp-4); border-top: 1px solid var(--border); }
.user-chip { display: flex; align-items: center; gap: var(--sp-3); padding: var(--sp-2) var(--sp-3); }
.avatar {
  width: 32px; height: 32px; border-radius: 50%; background: var(--surface-3); color: var(--text-2);
  display: grid; place-items: center; font-weight: 600; font-size: 0.85rem; flex: none;
}
.user-meta { min-width: 0; }
.user-meta .name { font-weight: 600; font-size: 0.9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-meta .role { font-size: 0.78rem; color: var(--text-3); }
.foot-actions { display: flex; gap: var(--sp-1); padding: var(--sp-2) var(--sp-2) 0; }

.main { min-width: 0; padding: var(--sp-6) var(--sp-6) var(--sp-7); }
.container { max-width: 1240px; margin: 0 auto; }
.page-head { display: flex; align-items: flex-end; gap: var(--sp-4); flex-wrap: wrap; margin-bottom: var(--sp-5); }
.page-head .titles { flex: 1; min-width: 240px; }
.page-head .subtitle { margin-top: var(--sp-1); color: var(--text-3); }
.topbar { display: none; }

/* ------------------------------------------------------------------ surfaces */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: var(--sp-5);
}
.card-head { display: flex; align-items: center; gap: var(--sp-3); margin-bottom: var(--sp-4); }
.card-head h2 { display: flex; align-items: center; gap: var(--sp-2); }
.card-head .icon { color: var(--text-3); }
.card.flush { padding: 0; overflow: hidden; }
.card.flush .card-head { padding: var(--sp-4) var(--sp-5) 0; }
.section-title { display: flex; align-items: center; gap: var(--sp-2); margin: var(--sp-6) 0 var(--sp-3); color: var(--text-2); }
.section-title h2 { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.07em; }
.grid { display: grid; gap: var(--sp-4); }
.grid.kpis { grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(420px, 1fr)); }
.grid.tiles { grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); }
.split { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: var(--sp-5); align-items: start; }

/* ------------------------------------------------------------------ KPI */
.kpi { padding: var(--sp-4) var(--sp-5); display: flex; flex-direction: column; gap: var(--sp-1); }
.kpi-label { display: flex; align-items: center; gap: var(--sp-2); color: var(--text-3); font-size: 0.85rem; font-weight: 500; }
.kpi-value { white-space: nowrap; font-size: 1.75rem; font-weight: 700; letter-spacing: -0.01em; line-height: 1.2; }
.kpi-top { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--sp-2); }
.kpi-foot { display: flex; align-items: center; gap: var(--sp-2); min-height: 26px; flex-wrap: wrap; }
.delta { white-space: nowrap; display: inline-flex; align-items: center; gap: 2px; font-size: 0.82rem; font-weight: 600; padding: 1px 8px 1px 5px; border-radius: 999px; }
.delta .icon { width: 15px; height: 15px; }
.delta.good { color: var(--good); background: var(--good-bg); }
.delta.bad { color: var(--bad); background: var(--bad-bg); }
.delta.flat { color: var(--text-3); background: var(--muted-bg); }
.kpi-compare { font-size: 0.78rem; color: var(--text-3); white-space: nowrap; }
.spark { display: block; width: 100%; height: 28px; margin-top: var(--sp-2); }
.spark .line { stroke-width: 1.75; }

.stat-strip { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.stat-strip > div { padding: var(--sp-4) var(--sp-5); border-left: 1px solid var(--border); }
.stat-strip > div:first-child { border-left: 0; }
.stat-strip .v { font-size: 1.5rem; font-weight: 700; }
.stat-strip .l { display: flex; align-items: center; gap: var(--sp-2); color: var(--text-3); font-size: 0.85rem; }

/* ------------------------------------------------------------------ source tiles */
.tile-head { display: flex; align-items: center; gap: var(--sp-3); }
.platform {
  width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; flex: none;
  background: var(--surface-2); color: var(--text-2); border: 1px solid var(--border);
}
.tile-kpis { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--sp-3); margin-top: var(--sp-4); }
.tile-kpis .l { font-size: 0.78rem; color: var(--text-3); }
.tile-kpis .v { font-size: 1.15rem; font-weight: 700; }

/* ------------------------------------------------------------------ badges */
.badge {
  display: inline-flex; align-items: center; gap: 5px; padding: 2px 10px 2px 7px; border-radius: 999px;
  font-size: 0.8rem; font-weight: 600; line-height: 1.5; white-space: nowrap; border: 1px solid transparent;
}
.badge .icon { width: 14px; height: 14px; }
.badge.good { color: var(--good); background: var(--good-bg); border-color: var(--good-line); }
.badge.warn { color: var(--warn); background: var(--warn-bg); border-color: var(--warn-line); }
.badge.bad { color: var(--bad); background: var(--bad-bg); border-color: var(--bad-line); }
.badge.info { color: var(--info); background: var(--info-bg); border-color: var(--info-line); }
.badge.muted { color: var(--muted-tone); background: var(--muted-bg); border-color: var(--muted-line); }
.tag { display: inline-flex; align-items: center; gap: 4px; padding: 1px 8px; border-radius: 6px; background: var(--surface-2); color: var(--text-2); font-size: 0.78rem; border: 1px solid var(--border); }

/* ------------------------------------------------------------------ buttons & forms */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--sp-2);
  min-height: 40px; padding: 0 var(--sp-4); border-radius: var(--radius-sm); border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--text); font: 600 0.92rem "Figtree", sans-serif; cursor: pointer;
  transition: background-color 150ms ease, border-color 150ms ease, color 150ms ease;
}
.btn:hover { background: var(--surface-2); text-decoration: none; color: var(--text); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn.good { background: var(--good); border-color: var(--good); color: var(--surface); }
.btn.good:hover { filter: brightness(1.08); }
.btn.danger { color: var(--bad); border-color: var(--bad-line); }
.btn.danger:hover { background: var(--bad-bg); }
.btn.ghost { border-color: transparent; background: transparent; color: var(--text-2); }
.btn.ghost:hover { background: var(--surface-2); }
.btn.icon-only { width: 40px; padding: 0; }
.btn.sm { min-height: 32px; padding: 0 var(--sp-3); font-size: 0.85rem; }
.btn.block { width: 100%; }
.btn:disabled, .btn[aria-disabled="true"] { opacity: 0.55; cursor: not-allowed; }
.seg { display: inline-flex; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); overflow: hidden; background: var(--surface); }
.seg a { padding: 7px 14px; color: var(--text-2); font-weight: 600; font-size: 0.85rem; border-left: 1px solid var(--border); }
.seg a:first-child { border-left: 0; }
.seg a:hover { background: var(--surface-2); text-decoration: none; }
.seg a[aria-current="true"] { background: var(--accent-soft); color: var(--accent); }

.field { display: flex; flex-direction: column; gap: 6px; }
.field label, .label { font-weight: 600; font-size: 0.9rem; }
.field .help { font-size: 0.82rem; color: var(--text-3); }
input[type=text], input[type=email], input[type=password], input[type=search], select, textarea {
  width: 100%; min-height: 42px; padding: 9px 12px; border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
  font: 400 1rem/1.4 "Figtree", sans-serif;
}
textarea { min-height: 96px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--focus); outline-offset: 0; border-color: var(--focus); }
.check { display: flex; align-items: flex-start; gap: var(--sp-2); font-size: 0.92rem; }
.check input { width: 18px; height: 18px; margin-top: 2px; accent-color: var(--accent); }
.code-input { font: 600 1.5rem/1 ui-monospace, Consolas, monospace !important; letter-spacing: 0.3em; text-align: center; }

.alert { display: flex; gap: var(--sp-3); align-items: flex-start; padding: var(--sp-3) var(--sp-4); border-radius: var(--radius-sm); border: 1px solid; }
.alert .icon { margin-top: 2px; }
.alert.ok { color: var(--good); background: var(--good-bg); border-color: var(--good-line); }
.alert.error { color: var(--bad); background: var(--bad-bg); border-color: var(--bad-line); }
.alert.warn { color: var(--warn); background: var(--warn-bg); border-color: var(--warn-line); }
.alert.info { color: var(--info); background: var(--info-bg); border-color: var(--info-line); }
.alert p { color: var(--text); }
.flash { margin-bottom: var(--sp-5); }

/* ------------------------------------------------------------------ tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
th { text-align: left; font-weight: 600; color: var(--text-3); font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.05em; padding: var(--sp-3) var(--sp-4); border-bottom: 1px solid var(--border); background: var(--surface-2); }
td { padding: var(--sp-3) var(--sp-4); border-bottom: 1px solid var(--border); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; }
tbody tr:hover { background: var(--surface-2); }

/* ------------------------------------------------------------------ empty / state */
.empty { text-align: center; padding: var(--sp-7) var(--sp-5); }
.empty-icon { width: 56px; height: 56px; border-radius: 16px; margin: 0 auto var(--sp-4); display: grid; place-items: center; background: var(--surface-2); color: var(--text-3); border: 1px solid var(--border); }
.empty-icon .icon { width: 26px; height: 26px; }
.empty h2 { margin-bottom: var(--sp-2); }
.empty p { color: var(--text-3); max-width: 520px; margin: 0 auto; }
.steps { text-align: left; max-width: 520px; margin: var(--sp-5) auto 0; padding: 0; list-style: none; counter-reset: s; }
.steps li { position: relative; padding: 0 0 var(--sp-3) 36px; color: var(--text-2); counter-increment: s; }
.steps li::before { content: counter(s); position: absolute; left: 0; top: 0; width: 24px; height: 24px; border-radius: 50%; background: var(--surface-3); color: var(--text-2); font-size: 0.8rem; font-weight: 700; display: grid; place-items: center; }

/* ------------------------------------------------------------------ content */
.week { margin-top: var(--sp-5); }
.week-head { display: flex; align-items: center; gap: var(--sp-2); margin-bottom: var(--sp-3); color: var(--text-2); font-weight: 600; }
.post-list { display: grid; gap: var(--sp-3); }
.post-row {
  display: grid; grid-template-columns: 64px minmax(0, 1fr) auto; gap: var(--sp-4); align-items: center;
  padding: var(--sp-3) var(--sp-4); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  color: var(--text); transition: border-color 150ms ease, background-color 150ms ease;
}
.post-row:hover { border-color: var(--border-strong); background: var(--surface-2); text-decoration: none; color: var(--text); }
.thumb { width: 64px; height: 64px; border-radius: 10px; object-fit: cover; background: var(--surface-3); display: grid; place-items: center; color: var(--text-3); }
.post-title { font-weight: 600; }
.post-meta { display: flex; gap: var(--sp-3); flex-wrap: wrap; color: var(--text-3); font-size: 0.85rem; margin-top: 2px; }
.post-meta span { display: inline-flex; align-items: center; gap: 4px; }
.post-meta .icon { width: 15px; height: 15px; }
.filters { display: flex; gap: var(--sp-2); flex-wrap: wrap; }
.chip { display: inline-flex; align-items: center; gap: 6px; min-height: 34px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--border-strong); color: var(--text-2); font-size: 0.85rem; font-weight: 600; background: var(--surface); }
.chip:hover { background: var(--surface-2); text-decoration: none; }
.chip[aria-current="true"] { background: var(--accent-soft); color: var(--accent); border-color: var(--info-line); }
.chip .n { color: var(--text-3); font-weight: 500; }

.preview { border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; background: var(--surface); }
.preview-head { display: flex; align-items: center; gap: var(--sp-2); padding: var(--sp-3) var(--sp-4); border-bottom: 1px solid var(--border); font-weight: 600; }
.preview-media { display: flex; gap: var(--sp-2); overflow-x: auto; padding: var(--sp-3); background: var(--surface-2); border-bottom: 1px solid var(--border); scroll-snap-type: x mandatory; }
.preview-media img, .preview-media video { flex: none; width: min(100%, 340px); aspect-ratio: 4 / 5; object-fit: cover; display: block; border-radius: var(--radius-sm); background: var(--surface-3); scroll-snap-align: start; }
.media-missing { aspect-ratio: 4 / 5; display: grid; place-items: center; text-align: center; padding: var(--sp-3); background: var(--surface-2); color: var(--text-3); font-size: 0.82rem; }
.caption { padding: var(--sp-4); white-space: pre-wrap; overflow-wrap: anywhere; }
.decision-card .btn { width: 100%; }
.decision-card form + form { margin-top: var(--sp-3); }
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { display: grid; grid-template-columns: 32px 1fr; gap: var(--sp-3); padding: var(--sp-3) 0; border-top: 1px solid var(--border); }
.timeline li:first-child { border-top: 0; }
.tl-icon { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-2); color: var(--text-2); border: 1px solid var(--border); }
.tl-icon.good { color: var(--good); background: var(--good-bg); border-color: var(--good-line); }
.tl-icon.warn { color: var(--warn); background: var(--warn-bg); border-color: var(--warn-line); }
.tl-icon.bad { color: var(--bad); background: var(--bad-bg); border-color: var(--bad-line); }
.tl-icon .icon { width: 16px; height: 16px; }
.tl-head { font-size: 0.9rem; }
.tl-head b { font-weight: 600; }
.tl-body { margin-top: var(--sp-1); white-space: pre-wrap; overflow-wrap: anywhere; color: var(--text); }
.tl-internal { border-left: 3px solid var(--warn-line); padding-left: var(--sp-3); }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: var(--sp-2) var(--sp-4); font-size: 0.9rem; }
.kv dt { color: var(--text-3); }
.kv dd { margin: 0; overflow-wrap: anywhere; }
.internal-panel { border-color: var(--warn-line); }
.internal-panel .card-head h2 .icon { color: var(--warn); }

/* ------------------------------------------------------------------ kanban */
.kanban { display: grid; grid-template-columns: repeat(6, minmax(220px, 1fr)); gap: var(--sp-3); overflow-x: auto; padding-bottom: var(--sp-2); }
.col { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); padding: var(--sp-3); min-height: 200px; }
.col-head { display: flex; align-items: center; gap: var(--sp-2); padding: var(--sp-1) var(--sp-1) var(--sp-3); font-weight: 600; font-size: 0.9rem; }
.col-head .n { margin-left: auto; color: var(--text-3); font-weight: 500; }
.kcard { display: block; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: var(--sp-3); color: var(--text); margin-bottom: var(--sp-2); }
.kcard:hover { border-color: var(--border-strong); text-decoration: none; color: var(--text); }
.kcard.overdue { border-left: 3px solid var(--warn); }
.kcard .t { font-weight: 600; font-size: 0.9rem; }
.kcard .m { display: flex; gap: var(--sp-2); align-items: center; font-size: 0.78rem; color: var(--text-3); margin-top: var(--sp-1); flex-wrap: wrap; }

/* ------------------------------------------------------------------ charts */
.chart-card .legend { display: flex; gap: var(--sp-4); font-size: 0.82rem; color: var(--text-2); margin-bottom: var(--sp-2); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.swatch { width: 16px; height: 0; border-top: 2px solid var(--series-1); display: inline-block; }
.swatch.prev { border-top: 2px dashed var(--series-prev); }
.chart-wrap { position: relative; }
svg.chart { width: 100%; height: auto; display: block; overflow: visible; }
.chart .gridline { stroke: var(--grid); stroke-width: 1; }
.chart .axis { fill: var(--text-3); font-size: 11px; font-family: "Figtree", sans-serif; }
.line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.line.series-1 { stroke: var(--series-1); }
.line.series-prev { stroke: var(--series-prev); stroke-dasharray: 5 4; }
.marker.series-1 { fill: var(--series-1); stroke: var(--surface); stroke-width: 2; }
.chart .crosshair { stroke: var(--border-strong); stroke-width: 1; }
.chart-tip {
  position: absolute; pointer-events: none; z-index: 5; background: var(--surface); border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm); padding: 8px 10px; font-size: 0.82rem; box-shadow: 0 4px 16px rgba(0,0,0,.12); min-width: 140px;
}
.chart-tip .d { color: var(--text-3); margin-bottom: 2px; }
.chart-tip .r { display: flex; justify-content: space-between; gap: var(--sp-3); }
details.data-table { margin-top: var(--sp-3); }
details.data-table summary { cursor: pointer; color: var(--accent); font-size: 0.85rem; font-weight: 600; }
details.data-table .table-wrap { max-height: 280px; overflow-y: auto; margin-top: var(--sp-2); border: 1px solid var(--border); border-radius: var(--radius-sm); }

/* ------------------------------------------------------------------ auth pages */
.auth { min-height: 100vh; display: grid; place-items: center; padding: var(--sp-5); }
.auth-card { width: 100%; max-width: 420px; }
.auth-card .brand { justify-content: center; padding-bottom: var(--sp-5); }
.auth-card h1 { font-size: 1.6rem; text-align: center; }
.auth-card .lead { text-align: center; color: var(--text-3); margin: var(--sp-2) 0 var(--sp-5); }
.qr { display: block; margin: 0 auto; width: 200px; height: 200px; border-radius: var(--radius-sm); background: #fff; padding: 8px; image-rendering: pixelated; }
.secret { text-align: center; font: 600 0.95rem ui-monospace, Consolas, monospace; letter-spacing: 0.08em; padding: var(--sp-3); background: var(--surface-2); border-radius: var(--radius-sm); overflow-wrap: anywhere; }
.codes { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-2); padding: var(--sp-4); background: var(--surface-2); border-radius: var(--radius-sm); font: 600 1rem ui-monospace, Consolas, monospace; text-align: center; }
.auth-foot { text-align: center; margin-top: var(--sp-5); font-size: 0.82rem; color: var(--text-3); }

/* ------------------------------------------------------------------ responsive */
@media (max-width: 1100px) {
  .split { grid-template-columns: 1fr; }
}
@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: min(86vw, 300px); z-index: 20; transform: translateX(-100%); transition: transform 200ms ease; box-shadow: 0 0 40px rgba(0,0,0,.25); }
  .nav-open .sidebar { transform: none; }
  .topbar { display: flex; align-items: center; gap: var(--sp-3); position: sticky; top: 0; z-index: 10; padding: var(--sp-2) var(--sp-4); background: var(--surface); border-bottom: 1px solid var(--border); }
  .main { padding: var(--sp-5) var(--sp-4) var(--sp-7); }
  .grid.two, .grid.tiles { grid-template-columns: 1fr; }
  .post-row { grid-template-columns: 48px minmax(0, 1fr); }
  .post-row .badge { grid-column: 2; justify-self: start; }
  .thumb { width: 48px; height: 48px; }
  h1 { font-size: 1.6rem; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}
@media (forced-colors: active) {
  .line.series-prev { stroke-dasharray: 2 4; }
  .badge, .delta { border: 1px solid CanvasText; }
}
.row.center { justify-content: center; }
.mt { margin-top: var(--sp-4); }
.mt-sm { margin-top: var(--sp-2); }
.right { text-align: right; }
.center { text-align: center; }
.tile-link { display: block; color: var(--text); transition: border-color 150ms ease; }
.tile-link:hover { border-color: var(--border-strong); text-decoration: none; color: var(--text); }
