:root {
  color-scheme: light;
  --page: #f9f9f7;
  --surface: #fcfcfb;
  --surface-2: #f3f2ee;
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --muted: #898781;
  --grid: #e1e0d9;
  --axis: #c3c2b7;
  --border: rgba(11, 11, 11, 0.10);
  --accent: #2a78d6;
  --brand: #4a638d;
  --accent-wash: rgba(42, 120, 214, 0.10);
  --good-text: #006300;
  --bad-text: #b42318;
  --s1: #2a78d6; --s2: #eb6834; --s3: #1baf7a; --s4: #eda100;
  --s5: #e87ba4; --s6: #008300; --s7: #6250d6; --s8: #e34948;
  --good: #0ca30c; --warning: #fab219; --serious: #ec835a; --critical: #d03b3b;
  --seq-0: #f0efec; --seq-1: #cde2fb; --seq-2: #9ec5f4; --seq-3: #6da7ec; --seq-4: #3987e5; --seq-5: #256abf; --seq-6: #184f95;
  --seq-ink-light: #0b0b0b; --seq-ink-dark: #ffffff;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 4px 16px rgba(0, 0, 0, 0.04);
  --radius: 12px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --page: #0d0d0d; --surface: #1a1a19; --surface-2: #232321;
    --ink: #f0efec; --ink-2: #c3c2b7; --muted: #898781; --grid: #2c2c2a; --axis: #383835;
    --border: rgba(255, 255, 255, 0.10); --accent: #3987e5; --brand: #f0efec; --accent-wash: rgba(57, 135, 229, 0.16);
    --good-text: #0ca30c; --bad-text: #f97066;
    --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500; --s5: #d55181; --s6: #008300; --s7: #9085e9; --s8: #e66767;
    --seq-0: #2a2a28; --seq-1: #0d366b; --seq-2: #104281; --seq-3: #184f95; --seq-4: #256abf; --seq-5: #3987e5; --seq-6: #6da7ec;
    --shadow: none;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0d0d0d; --surface: #1a1a19; --surface-2: #232321;
  --ink: #f0efec; --ink-2: #c3c2b7; --muted: #898781; --grid: #2c2c2a; --axis: #383835;
  --border: rgba(255, 255, 255, 0.10); --accent: #3987e5; --brand: #f0efec; --accent-wash: rgba(57, 135, 229, 0.16);
  --good-text: #0ca30c; --bad-text: #f97066;
  --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500; --s5: #d55181; --s6: #008300; --s7: #9085e9; --s8: #e66767;
  --seq-0: #2a2a28; --seq-1: #0d366b; --seq-2: #104281; --seq-3: #184f95; --seq-4: #256abf; --seq-5: #3987e5; --seq-6: #6da7ec;
  --shadow: none;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--page); color: var(--ink); font: 14px/1.45 var(--font);
  -webkit-font-smoothing: antialiased;
}
button, input, select { font: inherit; color: inherit; }
a { color: var(--accent); }
h1, h2, h3, h4 { margin: 0; font-weight: 600; letter-spacing: -0.01em; }
h1 { font-size: 18px; }
h2 { font-size: 16px; }
h3 { font-size: 14px; }
.muted { color: var(--muted); }
.ink2 { color: var(--ink-2); }
.num { font-variant-numeric: tabular-nums; }
.hidden { display: none !important; }

/* ---------------------------------------------------------------- shell */
.topbar {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 14px max(16px, calc((100vw - 1320px) / 2)); background: var(--surface); border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; margin-right: auto; }
.brand-mark { width: 34px; height: 34px; flex: none; color: var(--brand); }
.brand small { display: block; color: var(--muted); font-size: 12px; font-weight: 400; }
.status { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--ink-2); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--good); flex: none; }
.dot.loading { background: var(--warning); }
.dot.error { background: var(--critical); }
.icon-btn {
  border: 1px solid var(--border); background: var(--surface); border-radius: 8px; height: 32px; min-width: 32px;
  padding: 0 10px; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; color: var(--ink-2);
}
.icon-btn:hover { background: var(--surface-2); color: var(--ink); }
.icon-btn svg { width: 16px; height: 16px; }
.icon-btn[hidden] { display: none; }

.controls {
  position: sticky; top: 0; z-index: 20; background: color-mix(in srgb, var(--page) 92%, transparent);
  backdrop-filter: blur(8px); border-bottom: 1px solid var(--border);
  padding: 0 max(16px, calc((100vw - 1320px) / 2));
}
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; background: var(--surface); }
.seg button { border: 0; background: none; padding: 5px 10px; cursor: pointer; color: var(--ink-2); white-space: nowrap; }
.seg button + button { border-left: 1px solid var(--border); }
.seg button:hover { background: var(--surface-2); }
.seg button[aria-pressed="true"] { background: var(--ink); color: var(--surface); }
select, input[type="date"], input[type="number"], input[type="search"] {
  border: 1px solid var(--border); background: var(--surface); border-radius: 8px; padding: 5px 8px; height: 32px;
}
input[type="date"] { width: 140px; }

/* tabs: primary navigation, first row of the sticky block */
.tabs { display: flex; gap: 2px; overflow-x: auto; scrollbar-width: none; border-bottom: 1px solid var(--border); }
.tabs::-webkit-scrollbar { display: none; }
.tabs button {
  border: 0; background: none; padding: 12px 12px 10px; cursor: pointer; color: var(--ink-2); white-space: nowrap;
  border-bottom: 2px solid transparent; margin-bottom: -1px; font-weight: 500;
}
.tabs button:hover { color: var(--ink); }
.tabs button[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--ink); }

/* filter bar: one chip per filter that applies to the current tab */
.filterbar { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; padding: 10px 0; min-height: 56px; }
.filterbar[hidden] { display: none; }
.filter { position: relative; }
.filter[hidden] { display: none; }
.chip {
  display: inline-flex; align-items: baseline; gap: 6px; border: 1px solid var(--border); background: var(--surface);
  border-radius: 99px; padding: 6px 30px 6px 14px; cursor: pointer; white-space: nowrap; position: relative; line-height: 1.3;
}
.chip::after { content: ''; position: absolute; right: 13px; top: 50%; width: 6px; height: 6px; margin-top: -5px;
  border-right: 1.5px solid var(--muted); border-bottom: 1.5px solid var(--muted); transform: rotate(45deg); transition: transform 0.15s; }
.chip[aria-expanded="true"]::after { transform: rotate(-135deg); margin-top: -1px; }
.chip:hover { border-color: var(--axis); }
.chip[aria-expanded="true"] { border-color: var(--ink-2); }
.chip.changed { background: var(--accent-wash); border-color: color-mix(in srgb, var(--accent) 45%, transparent); }
.chip-k { font-size: 12px; color: var(--muted); }
.chip-v { font-weight: 600; color: var(--ink); }
.chip-sub { font-size: 12px; color: var(--ink-2); }
.chip-sub:not(:empty)::before { content: '·'; margin-right: 6px; color: var(--muted); }
.pop {
  position: absolute; z-index: 40; top: calc(100% + 6px); left: 0; width: 260px; max-width: calc(100vw - 32px);
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 6px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.14);
}
.pop.wide { width: 360px; }
.pop.period { width: 330px; }
.pop[hidden] { display: none; }
.opt-list { display: grid; }
.opt-list button {
  display: grid; grid-template-columns: 20px 1fr; align-items: start; text-align: left; gap: 2px 6px;
  border: 0; background: none; padding: 7px 8px; border-radius: 8px; cursor: pointer; color: var(--ink);
}
.opt-list button::before { content: ''; grid-row: span 2; }
.opt-list button[aria-checked="true"]::before { content: '✓'; font-weight: 700; }
.opt-list button:hover, .opt-list button:focus-visible { background: var(--surface-2); outline: none; }
.opt-list.described button b { font-weight: 600; }
.opt-list.described button span { grid-column: 2; font-size: 12px; color: var(--ink-2); }
.pop-foot { border-top: 1px solid var(--grid); margin-top: 6px; padding: 10px 8px 4px; display: grid; gap: 8px; }
.pop-title { font-size: 12px; font-weight: 600; color: var(--ink-2); }
.range-inputs { display: flex; align-items: center; gap: 6px; }
.range-inputs input[type="date"] { width: auto; flex: 1 1 0; min-width: 0; }
.btn.small { padding: 4px 12px; justify-self: end; }
.pop-note { margin: 6px 8px 6px; font-size: 11px; line-height: 1.45; color: var(--muted); }
.pop-quick { display: flex; gap: 6px; padding: 6px 8px 8px; border-bottom: 1px solid var(--grid); margin-bottom: 4px; }
.pop-quick button { border: 1px solid var(--border); background: var(--surface); border-radius: 99px; padding: 3px 10px; cursor: pointer; font-size: 12px; color: var(--ink-2); }
.pop-quick button:hover { background: var(--surface-2); color: var(--ink); }
.pop-quick button[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: var(--surface); }
.check-list label { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 8px; cursor: pointer; }
.check-list label:hover { background: var(--surface-2); }
.check-list .count { margin-left: auto; color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.filter-note { font-size: 12px; color: var(--muted); margin-left: 4px; }
.reset { margin-left: auto; border: 0; background: none; color: var(--accent); cursor: pointer; padding: 6px 4px; font-weight: 500; }
.reset:hover { text-decoration: underline; }
.reset[hidden] { display: none; }

main { padding: 20px max(16px, calc((100vw - 1320px) / 2)) 64px; }
main.refreshing { opacity: 0.55; transition: opacity 0.2s; }
.banner {
  margin: 0 0 16px; padding: 10px 14px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface);
  display: flex; gap: 10px; align-items: flex-start;
}
.banner.error { border-color: color-mix(in srgb, var(--critical) 40%, transparent); }
.banner.warn { border-color: color-mix(in srgb, var(--warning) 50%, transparent); }
.banner .dot { margin-top: 6px; }

/* ---------------------------------------------------------------- layout */
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin: 28px 0 12px; }
.section-head:first-child { margin-top: 0; }
.section-head p { margin: 4px 0 0; color: var(--ink-2); max-width: 820px; }
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.span2 { grid-column: span 2; }
@media (max-width: 1000px) { .g3, .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 720px) { .g2, .g3, .g4 { grid-template-columns: minmax(0, 1fr); } .span2 { grid-column: auto; } }

.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow);
  min-width: 0;
}
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
.card-head h3 { display: flex; align-items: center; gap: 6px; }
.card-head p { margin: 2px 0 0; font-size: 12px; color: var(--muted); }
.chart { position: relative; height: 260px; }
.chart.tall { height: 340px; }
.chart.short { height: 200px; }

/* ---------------------------------------------------------------- KPI tiles */
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
@media (max-width: 1000px) { .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); min-width: 0; }
.kpi .label { font-size: 12px; color: var(--ink-2); display: flex; align-items: center; gap: 4px; }
.kpi .value { font-size: 26px; font-weight: 600; letter-spacing: -0.02em; margin-top: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi .delta { font-size: 12px; margin-top: 2px; color: var(--muted); }
.delta.up { color: var(--good-text); }
.delta.down { color: var(--bad-text); }

/* ---------------------------------------------------------------- insights */
.insights { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.insight { border: 1px solid var(--border); background: var(--surface); border-radius: 10px; padding: 12px 14px; display: flex; gap: 10px; }
.insight .tag { flex: none; font-size: 11px; font-weight: 600; letter-spacing: 0.02em; text-transform: uppercase; color: var(--muted); width: 74px; padding-top: 2px; }
.insight p { margin: 0; color: var(--ink); }
.insight b { font-weight: 600; }

/* ---------------------------------------------------------------- tables */
.table-wrap { overflow-x: auto; margin: 0 -16px; padding: 0 16px; }
.table-wrap.can-drag { cursor: grab; }
body.drag-scrolling, body.drag-scrolling * { cursor: grabbing !important; user-select: none; }
table { border-collapse: collapse; width: 100%; font-size: 13px; }
th, td { padding: 7px 10px; text-align: right; white-space: nowrap; border-bottom: 1px solid var(--grid); }
th:first-child, td:first-child { text-align: left; position: sticky; left: 0; background: var(--surface); z-index: 1; }
/* only while a table is scrolled sideways, behind the sticky cell's content: cover the wrap's 16px gutter so
   scrolled cells don't peek out on the left, and fade a short shadow onto the cells passing underneath.
   Skipped where the first column isn't sticky (.heat, grouped sub-header), or it would size against the page. */
.table-wrap.scrolled table:not(.heat) :is(th, td):first-child::before {
  content: ''; position: absolute; top: 0; bottom: 0; left: -16px; right: -10px; z-index: -1; pointer-events: none;
  background: linear-gradient(to right, var(--surface) 16px, transparent 16px, transparent calc(100% - 10px),
    var(--border) calc(100% - 10px), var(--border) calc(100% - 9px), rgba(0, 0, 0, 0.12) calc(100% - 9px), transparent);
}
th { font-weight: 500; color: var(--ink-2); font-size: 12px; vertical-align: bottom; }
th.sortable { cursor: pointer; user-select: none; }
th.sortable:hover { color: var(--ink); }
th.sorted::after { content: ' ↓'; }
th.sorted.asc::after { content: ' ↑'; }
td { font-variant-numeric: tabular-nums; }
td.text, th.text { text-align: left; }
tbody tr:hover td { background: var(--surface-2); }
tbody tr.clickable { cursor: pointer; }
/* the wash is translucent; layer it over the surface so cells scrolling under the sticky column stay hidden */
tbody tr.selected td { background: linear-gradient(var(--accent-wash), var(--accent-wash)), var(--surface); }
tr.team td { font-weight: 600; border-top: 1px solid var(--axis); }
.low { color: var(--muted); }
.low::after { content: '*'; }
/* grouped tables: topic row above short column names */
table.grouped tr.groups th.group {
  text-align: center; font-size: 11px; font-weight: 600; letter-spacing: 0.03em; text-transform: uppercase; color: var(--muted);
  border-bottom: 1px solid var(--axis); padding: 8px 10px 4px; position: static;
}
table.grouped tr.groups th[rowspan] { vertical-align: bottom; }
table.grouped tr.sub th:first-child { position: static; text-align: right; background: none; z-index: auto; }
table.grouped tr.sub th:first-child::before { content: none !important; }
table.grouped th, table.grouped td { padding-left: 8px; padding-right: 8px; }
table.grouped th.gstart, table.grouped td.gstart { border-left: 1px solid var(--grid); }
table.grouped .th-label { border-bottom: 1px dotted var(--axis); padding-bottom: 1px; }
table.grouped th:hover .th-label { border-bottom-color: var(--ink-2); }
.table-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 8px 16px; flex-wrap: wrap; margin-bottom: 8px; }
.table-tools { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }

/* column chooser */
.colpick { position: relative; }
.colpick-btn { gap: 6px; }
.colpick-btn[aria-expanded="true"] { border-color: var(--ink-2); color: var(--ink); }
.colpick-count { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.colpick-pop { left: auto; right: 0; width: 360px; padding: 0; overflow: hidden; display: flex; flex-direction: column; max-height: min(70vh, 640px); }
.colpick-pop[hidden] { display: none; }
.colpick-head { display: flex; align-items: baseline; justify-content: space-between; padding: 12px 14px 4px; }
.colpick-head .muted { font-size: 12px; }
.pop-quick.wrap { flex-wrap: wrap; padding: 6px 14px 10px; margin: 0; }
.colpick-groups { overflow-y: auto; padding: 4px 6px 10px; }
.colpick fieldset { border: 0; margin: 0; padding: 6px 0 2px; }
.colpick legend { display: flex; width: 100%; justify-content: space-between; align-items: baseline; padding: 4px 8px;
  font-size: 11px; font-weight: 600; letter-spacing: 0.03em; text-transform: uppercase; color: var(--muted); }
.colpick label { display: flex; align-items: center; gap: 8px; padding: 5px 8px; border-radius: 8px; cursor: pointer; }
.colpick label:hover { background: var(--surface-2); }
.colpick-name { flex: 1; }
.colpick-short { font-size: 11px; color: var(--muted); border: 1px solid var(--border); border-radius: 4px; padding: 0 5px; white-space: nowrap; }
.link { border: 0; background: none; padding: 0; color: var(--accent); cursor: pointer; font-size: 12px; text-transform: none; letter-spacing: 0; font-weight: 500; }
.link:hover { text-decoration: underline; }

.pill { display: inline-block; padding: 1px 7px; border-radius: 99px; font-size: 11px; background: var(--surface-2); color: var(--ink-2); border: 1px solid var(--border); }
.idx { display: inline-flex; align-items: center; gap: 4px; }
.idx::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: var(--muted); }
.idx.hi::before { background: var(--good); }
.idx.lo::before { background: var(--critical); }
.bar-cell { display: flex; align-items: center; gap: 8px; justify-content: flex-end; }
.bar-cell .track { width: 64px; height: 6px; border-radius: 3px; background: var(--surface-2); overflow: hidden; flex: none; }
.bar-cell .fill { height: 100%; background: var(--s1); border-radius: 3px; }

/* ---------------------------------------------------------------- heatmap */
.heat { border-collapse: separate; border-spacing: 2px; width: 100%; font-size: 12px; }
.heat th, .heat td { border: 0; padding: 0; text-align: center; position: static; background: none; }
.heat th { color: var(--muted); font-weight: 500; padding: 2px 4px; }
.heat td.cell { height: 28px; min-width: 44px; border-radius: 4px; font-variant-numeric: tabular-nums; cursor: default; }
.heat td.cell.empty { background: transparent; }
.heat th.row { text-align: right; padding-right: 8px; white-space: nowrap; }
.legend-scale { display: flex; align-items: center; gap: 6px; font-size: 11px; color: var(--muted); margin-top: 8px; }
.legend-scale .ramp { display: flex; height: 8px; width: 160px; border-radius: 4px; overflow: hidden; }
.legend-scale .ramp span { flex: 1; }

/* ---------------------------------------------------------------- funnel */
.funnel-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px; }
.funnel-card h3 { margin-bottom: 2px; }
.step { margin-top: 10px; }
.step-top { display: flex; justify-content: space-between; font-size: 12px; color: var(--ink-2); }
.step-top b { color: var(--ink); font-weight: 600; font-variant-numeric: tabular-nums; }
.step-track { height: 8px; border-radius: 4px; background: var(--surface-2); margin-top: 4px; overflow: hidden; }
.step-fill { height: 100%; border-radius: 4px; background: var(--s1); }

/* ---------------------------------------------------------------- legend, tooltip, info */
.legend { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 12px; color: var(--ink-2); margin-bottom: 8px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.legend i.line { height: 2px; border-radius: 1px; width: 14px; }
.info {
  border: 0; background: none; padding: 0; width: 16px; height: 16px; border-radius: 50%; cursor: help; color: var(--muted);
  display: inline-grid; place-items: center; font-size: 11px; font-weight: 600; line-height: 1;
  box-shadow: inset 0 0 0 1px var(--axis); flex: none;
}
.info:hover, .info:focus-visible { color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink-2); }
#tip {
  position: fixed; z-index: 100; max-width: 320px; padding: 8px 10px; border-radius: 8px; font-size: 12px; line-height: 1.45;
  background: var(--ink); color: var(--surface); pointer-events: none; opacity: 0; transition: opacity 0.1s;
}
#tip.show { opacity: 1; }

/* ---------------------------------------------------------------- drawer, dialog, toast */
.detail { margin-top: 16px; }
.detail-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; margin-bottom: 16px; }
.stat { border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; }
.stat .label { font-size: 11px; color: var(--muted); }
.stat .value { font-size: 18px; font-weight: 600; }
.stat .sub { font-size: 11px; color: var(--ink-2); }
dialog { border: 1px solid var(--border); border-radius: 14px; background: var(--surface); color: var(--ink); padding: 20px; width: min(520px, calc(100vw - 32px)); }
dialog::backdrop { background: rgba(0, 0, 0, 0.35); }
.form-row { display: grid; grid-template-columns: 1fr 120px; gap: 4px 12px; align-items: center; margin: 12px 0; }
.form-row small { grid-column: 1 / -1; color: var(--muted); }
.btn { border: 1px solid var(--border); background: var(--surface); border-radius: 8px; padding: 6px 14px; cursor: pointer; }
.btn.primary { background: var(--ink); color: var(--surface); border-color: var(--ink); }
.btn:hover { filter: brightness(0.97); }
.toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%) translateY(20px); opacity: 0; transition: all 0.25s;
  background: var(--ink); color: var(--surface); padding: 10px 16px; border-radius: 10px; z-index: 200; font-size: 13px;
}
.toast.show { opacity: 1; transform: translateX(-50%); }
.empty-state { padding: 40px 16px; text-align: center; color: var(--muted); }
.sub-tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.sub-tabs button { border: 1px solid var(--border); background: var(--surface); border-radius: 99px; padding: 4px 12px; cursor: pointer; color: var(--ink-2); }
.sub-tabs button[aria-pressed="true"] { background: var(--ink); color: var(--surface); border-color: var(--ink); }
.sub-tabs .count { color: var(--muted); margin-left: 4px; }
.sub-tabs button[aria-pressed="true"] .count { color: inherit; opacity: 0.7; }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.note { font-size: 12px; color: var(--muted); margin-top: 8px; }
.callout { border-left: 3px solid var(--accent); background: var(--accent-wash); padding: 10px 14px; border-radius: 0 8px 8px 0; margin-bottom: 16px; color: var(--ink); }
.callout p { margin: 0; }
.glossary dt { font-weight: 600; margin-top: 12px; }
.glossary dd { margin: 2px 0 0; color: var(--ink-2); }
.check { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--ink-2); cursor: pointer; }
@media (max-width: 720px) {
  .controls { position: relative; }  /* not sticky on phones, but keep panels above the page */
  .chip { padding: 5px 26px 5px 12px; }
  .chip-sub { display: none; }
  .filter { position: static; }
  .filterbar { position: relative; }
  .pop, .pop.wide, .pop.period { left: 0; right: 0; width: auto; }
  .reset { margin-left: 0; }
  .colpick { position: static; }
  .table-toolbar { position: relative; }
  .colpick-pop { left: 0; right: 0; width: auto; }
  .kpi .value { font-size: 22px; }
  input[type="date"] { width: 128px; }
  .chart { height: 220px; }
}
@media print {
  .controls, .topbar .icon-btn { display: none; }
  .card, .kpi { break-inside: avoid; box-shadow: none; }
}

/* ---------------------------------------------------------------- sign-in */
.login-page { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.login-card {
  width: min(360px, 100%); background: var(--surface); border: 1px solid var(--border); border-radius: 14px;
  box-shadow: var(--shadow); padding: 24px; display: grid; gap: 20px;
}
.login-card .brand { margin: 0; }
.login-card form { display: grid; gap: 8px; }
.login-card label { font-weight: 600; font-size: 13px; }
.login-card input[type="password"] {
  border: 1px solid var(--border); background: var(--page); border-radius: 8px; padding: 0 10px; height: 38px; width: 100%;
}
.login-card input[type="password"]:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.login-card .btn { height: 38px; }
.login-card .btn:disabled { opacity: 0.6; cursor: progress; }
.login-error { margin: 0; min-height: 1.45em; color: var(--bad-text); font-size: 13px; }
.login-note { margin: 0; font-size: 12px; }
