/* Layout: a sticky ledger-style top bar (project switcher + tab rail) over panels laid on a 12-column grid;
   numbers and codes set in tabular mono, headings in condensed Archivo like a mill's stencilled sack print. */
:root {
  --bg: #F2F3EE;
  --surface: #FFFFFF;
  --surface-2: #F7F8F4;
  --sunken: #EBEDE6;
  --ink: #16201B;
  --ink-2: #3B4640;
  --muted: #5F6A63;
  --line: #DADFD5;
  --line-2: #C3CABF;
  --accent: #1C5B7B;
  --accent-2: #164A64;
  --accent-soft: #E1EDF3;
  --on-accent: #FFFFFF;
  --good: #26734A;
  --good-soft: #DFF0E5;
  --warn: #93600A;
  --warn-soft: #FAEED5;
  --crit: #B4361F;
  --crit-soft: #F8E0D9;
  --review: #6A4C9C;
  --review-soft: #ECE5F6;
  --idle: #737E77;
  --idle-soft: #ECEEEA;
  --heat-1: #D6E6EE;
  --heat-2: #9DC2D4;
  --heat-3: #4F8DAD;
  --shadow: 0 1px 2px rgba(22, 32, 27, .06), 0 6px 20px rgba(22, 32, 27, .07);
  --f-display: "Archivo", "Arial Narrow", system-ui, sans-serif;
  --f-body: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --f-mono: "IBM Plex Mono", ui-monospace, "Cascadia Mono", Consolas, monospace;
  --r: 8px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0F1412; --surface: #161D1A; --surface-2: #1A2320; --sunken: #121916;
    --ink: #E4EAE5; --ink-2: #C2CBC5; --muted: #929E97; --line: #29332E; --line-2: #3A4640;
    --accent: #6FB3D6; --accent-2: #8CC4E0; --accent-soft: #17303D; --on-accent: #08161D;
    --good: #5EC28C; --good-soft: #14301F; --warn: #E2AA4C; --warn-soft: #33270F;
    --crit: #F07C66; --crit-soft: #3B1A14; --review: #AE90E3; --review-soft: #2A2140;
    --idle: #8D9891; --idle-soft: #212A26;
    --heat-1: #173543; --heat-2: #22566E; --heat-3: #3C86AA;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .35);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0F1412; --surface: #161D1A; --surface-2: #1A2320; --sunken: #121916;
  --ink: #E4EAE5; --ink-2: #C2CBC5; --muted: #929E97; --line: #29332E; --line-2: #3A4640;
  --accent: #6FB3D6; --accent-2: #8CC4E0; --accent-soft: #17303D; --on-accent: #08161D;
  --good: #5EC28C; --good-soft: #14301F; --warn: #E2AA4C; --warn-soft: #33270F;
  --crit: #F07C66; --crit-soft: #3B1A14; --review: #AE90E3; --review-soft: #2A2140;
  --idle: #8D9891; --idle-soft: #212A26;
  --heat-1: #173543; --heat-2: #22566E; --heat-3: #3C86AA;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .35);
  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: 400 14px/1.5 var(--f-body);
  padding-top: env(safe-area-inset-top, 0px);
}
[hidden] { display: none !important; }
img, svg { max-width: 100%; }
h1, h2, h3 { font-family: var(--f-display); font-stretch: 82%; letter-spacing: .005em; text-wrap: balance; margin: 0; }
h1 { font-size: 26px; font-weight: 700; line-height: 1.15; }
h2 { font-size: 17px; font-weight: 700; }
h3 { font-size: 14px; font-weight: 700; }
p { margin: 0; }
a { color: var(--accent); }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
.mono, code { font-family: var(--f-mono); font-size: 12.5px; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.eyebrow { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .09em; color: var(--muted); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.nowrap { white-space: nowrap; }
/* Number notes: a small numbered marker after a figure, a pop-up with its explanation, and the list at the page foot. */
sup.cite { font-size: 10px; line-height: 0; margin-left: 3px; vertical-align: super; }
sup.cite button { font: 600 10px/1 var(--f-mono); letter-spacing: 0; text-transform: none; color: var(--accent); background: var(--accent-soft); border: 0; border-radius: 4px; padding: 3px 5px; min-width: 18px; cursor: pointer; }
sup.cite button:hover, sup.cite button:focus-visible { background: var(--accent); color: var(--on-accent); }
.note-pop { position: fixed; z-index: 70; background: var(--surface); color: var(--ink); border: 1px solid var(--line-2); border-radius: 10px; box-shadow: var(--shadow); padding: 12px 14px; display: grid; gap: 8px; font-size: 13px; line-height: 1.45; max-height: 70vh; overflow: auto; }
.note-pop p { color: var(--ink-2); }
.note-pop-head { display: flex; align-items: center; gap: 8px; }
.note-pop-head b { flex: 1; }
.note-pop .btn { justify-self: start; }
.note-n { font: 600 11px/1 var(--f-mono); background: var(--accent); color: var(--on-accent); border-radius: 4px; padding: 4px 6px; flex: none; align-self: start; }
.note-how { margin: 0; padding-left: 18px; display: grid; gap: 4px; color: var(--ink-2); }
.note-src { font-size: 12px; color: var(--muted); margin-top: 4px; }
.notes .note-list { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 440px), 1fr)); column-gap: 28px; font-size: 13px; }
.notes .note-list > li { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 10px; padding: 10px 6px; border-top: 1px solid var(--line); scroll-margin-top: 150px; border-radius: 6px; transition: background .3s; }
.notes .note-list > li p { margin: 2px 0 4px; color: var(--ink-2); }
.notes .note-list > li.flash { background: var(--accent-soft); }
.admin-head { display: flex; align-items: center; justify-content: space-between; gap: 12px 20px; flex-wrap: wrap; padding-bottom: 14px; border-bottom: 1px solid var(--line); }
.admin-nav button { padding: 8px 16px; font-size: 14px; }
.restore-item { border: 1px solid var(--line); border-radius: var(--r); padding: 14px; background: var(--surface-2); }
.who { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--ink-2); min-width: 0; }
.who:empty { display: none; }
.who-email { max-width: 230px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.login-seg { display: flex; }
.login-seg button { flex: 1; padding: 9px 12px; font-size: 14px; }
.code-input { font-family: var(--f-mono); font-size: 22px; letter-spacing: .3em; }
body.signed-out .topbar .switch, body.signed-out #tabs, body.signed-out #syncState { display: none; }
.restore-item .notice ul { margin-top: 4px; }
/* The Stallion logo has a white background, so it sits on a white tile that also reads in dark mode. */
.brand-logo { height: 46px; width: auto; flex: none; background: #fff; border-radius: 6px; padding: 2px 4px; box-shadow: 0 0 0 1px var(--line); }
.sync.saving .dot { background: var(--warn); }
.sync.err { color: var(--crit); font-weight: 600; }
.modal .notice { margin: 0; }
.modal #discardBar { margin: 0 20px 14px; flex-wrap: wrap; justify-content: space-between; }
table.data.audit td { vertical-align: top; }
table.data.audit .audit-summary { min-width: 280px; max-width: 520px; }

/* ---------- top bar ---------- */
body::before { content: ""; position: fixed; inset: 0 0 auto; height: env(safe-area-inset-top, 0px); z-index: 30; background: var(--surface); }
.topbar { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 20; background: var(--surface); border-bottom: 1px solid var(--line); }
.gutter { padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
.topbar-inner { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 20px; padding-block: 10px; max-width: 1480px; margin: 0 auto; }
.brand { display: flex; align-items: center; gap: 10px; margin-right: auto; min-width: 0; }
.brand-mark { width: 30px; height: 30px; flex: none; border-radius: 7px; background: var(--accent); display: grid; place-items: center; }
.brand-mark svg { width: 20px; height: 20px; }
.brand-name { font-family: var(--f-display); font-stretch: 70%; font-weight: 800; font-size: 19px; letter-spacing: .06em; line-height: 1; }
.brand-sub { font-size: 11px; color: var(--muted); letter-spacing: .02em; margin-top: 3px; }
.switch { display: flex; align-items: center; gap: 8px; min-width: 0; }
.switch label { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.switch select { max-width: 280px; }
.sync { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.sync .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--good); }
.sync.err .dot { background: var(--crit); }
.icon-btn { border: 1px solid var(--line); background: var(--surface); border-radius: 7px; width: 32px; height: 32px; display: grid; place-items: center; cursor: pointer; color: var(--ink-2); }
.icon-btn:hover { background: var(--surface-2); }

.tabs { display: flex; gap: 2px; overflow-x: auto; scrollbar-width: none; max-width: 1480px; margin: 0 auto; }
.tabs::-webkit-scrollbar { display: none; }
.tab { flex: none; border: 0; background: none; padding: 10px 12px 11px; font-weight: 500; color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent; display: flex; align-items: center; gap: 6px; white-space: nowrap; }
.tab:hover { color: var(--ink); }
.tab[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--accent); font-weight: 600; }
.badge { min-width: 19px; height: 19px; padding: 0 5px; border-radius: 10px; font-size: 11px; font-weight: 600; display: inline-grid; place-items: center; background: var(--crit); color: #fff; font-variant-numeric: tabular-nums; }
.badge.warn { background: var(--warn); }
.badge.quiet { background: var(--sunken); color: var(--muted); }

/* ---------- page & panels ---------- */
main { max-width: 1480px; margin: 0 auto; padding-block: 20px 60px; }
.page { display: grid; gap: 16px; }
.grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 16px; }
.span-12 { grid-column: span 12; } .span-8 { grid-column: span 8; } .span-7 { grid-column: span 7; } .span-6 { grid-column: span 6; }
.span-5 { grid-column: span 5; } .span-4 { grid-column: span 4; }
@media (max-width: 1080px) { .span-8, .span-7, .span-6, .span-5, .span-4 { grid-column: span 12; } }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 16px; min-width: 0; }
.panel-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.panel-head .sub { font-size: 12.5px; color: var(--muted); }
.stack { display: grid; gap: 10px; }
.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.spacer { flex: 1; }
.divider { height: 1px; background: var(--line); margin: 4px 0; }

/* project header band */
.proj-band { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 16px 24px; align-items: start; }
@media (max-width: 860px) { .proj-band { grid-template-columns: 1fr; } }
.proj-title { display: grid; gap: 6px; min-width: 0; }
.proj-meta { display: flex; flex-wrap: wrap; gap: 6px 16px; color: var(--muted); font-size: 13px; }
.reasons { margin: 8px 0 0; padding: 0; list-style: none; display: grid; gap: 3px; font-size: 13px; color: var(--ink-2); }
.reasons li { display: flex; gap: 6px; }
.reasons li::before { content: "–"; color: var(--muted); }
.milestones { display: grid; grid-template-columns: repeat(4, minmax(0, auto)); gap: 0; border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; }
.milestones > div { padding: 9px 14px; border-left: 1px solid var(--line); background: var(--surface-2); min-width: 0; }
.milestones > div:first-child { border-left: 0; }
.milestones .v { font-family: var(--f-display); font-stretch: 80%; font-weight: 700; font-size: 17px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.milestones .v.bad { color: var(--crit); }
@media (max-width: 560px) { .milestones { grid-template-columns: 1fr 1fr; } .milestones > div:nth-child(3) { border-left: 0; } .milestones > div:nth-child(n+3) { border-top: 1px solid var(--line); } }

.notice { display: flex; gap: 10px; align-items: flex-start; padding: 10px 14px; border-radius: var(--r); background: var(--warn-soft); color: var(--ink); border: 1px solid color-mix(in oklab, var(--warn) 35%, transparent); font-size: 13.5px; }
.notice.crit { background: var(--crit-soft); border-color: color-mix(in oklab, var(--crit) 35%, transparent); }
.notice.info { background: var(--accent-soft); border-color: color-mix(in oklab, var(--accent) 30%, transparent); }
.notice .btn { margin-left: auto; flex: none; }
.notice > svg { width: 18px; height: 18px; flex: none; margin-top: 2px; color: var(--crit); }

/* KPI tiles */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(178px, 1fr)); gap: 12px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 13px 15px 14px; display: grid; gap: 4px; align-content: start; }
.kpi .label { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.kpi .value { font-family: var(--f-display); font-stretch: 75%; font-weight: 700; font-size: 34px; line-height: 1.05; font-variant-numeric: tabular-nums; }
.kpi .value small { font-size: 16px; font-weight: 600; color: var(--muted); margin-left: 3px; }
.kpi .value.bad { color: var(--crit); } .kpi .value.warn { color: var(--warn); } .kpi .value.good { color: var(--good); }
.kpi .sub { font-size: 12.5px; color: var(--muted); }
.meter { position: relative; height: 6px; border-radius: 3px; background: var(--sunken); margin-top: 6px; }
.meter .fill { position: absolute; inset: 0 auto 0 0; border-radius: 3px; background: var(--accent); }
.meter .mark { position: absolute; top: -3px; bottom: -3px; width: 2px; background: var(--ink); border-radius: 1px; }

/* pills, tags */
.pill { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px 2px 7px; border-radius: 999px; font-size: 12px; font-weight: 600; line-height: 1.6; white-space: nowrap; }
.pill svg { width: 12px; height: 12px; flex: none; }
.pill.good { background: var(--good-soft); color: var(--good); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.bad, .pill.crit { background: var(--crit-soft); color: var(--crit); }
.pill.info { background: var(--accent-soft); color: var(--accent); }
.pill.big { font-size: 13px; padding: 4px 12px 4px 9px; }
.st { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 500; white-space: nowrap; }
.st::before { content: ""; width: 8px; height: 8px; border-radius: 2px; background: var(--c, var(--idle)); flex: none; }
.st-ns { --c: var(--idle); } .st-ip { --c: var(--accent); } .st-rv { --c: var(--review); } .st-bl { --c: var(--crit); } .st-dn { --c: var(--good); }
.tag { display: inline-block; padding: 1px 7px; border-radius: 4px; font-size: 11.5px; font-weight: 500; background: var(--sunken); color: var(--ink-2); white-space: nowrap; }
.tag.risk { background: var(--warn-soft); color: var(--warn); }
.tag.issue { background: var(--crit-soft); color: var(--crit); }
.tag.challenge { background: var(--review-soft); color: var(--review); }
.tag.carry { background: var(--crit-soft); color: var(--crit); }
.code { font-family: var(--f-mono); font-size: 12px; font-weight: 500; color: var(--muted); white-space: nowrap; }
.person { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.avatar { width: 22px; height: 22px; border-radius: 50%; display: inline-grid; place-items: center; font-size: 10px; font-weight: 700; color: #fff; flex: none; letter-spacing: .02em; }
.avatar.team { background: var(--ink-2); }
.lvl { font-size: 12px; font-weight: 600; }
.lvl.High { color: var(--crit); } .lvl.Medium { color: var(--warn); } .lvl.Low { color: var(--muted); }

/* buttons & forms */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid var(--line-2); background: var(--surface); color: var(--ink); border-radius: 7px; padding: 7px 13px; font-weight: 500; font-size: 13.5px; cursor: pointer; white-space: nowrap; text-decoration: none; }
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn.primary:hover { background: var(--accent-2); }
.btn.danger { color: var(--crit); border-color: color-mix(in oklab, var(--crit) 45%, var(--line)); }
.btn.danger:hover { background: var(--crit-soft); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--sunken); }
.btn.sm { padding: 4px 9px; font-size: 12.5px; }
.btn[disabled] { opacity: .55; cursor: default; }
input[type="text"], input[type="email"], input[type="number"], input[type="date"], input[type="search"], input[type="password"], select, textarea {
  border: 1px solid var(--line-2); background: var(--surface); border-radius: 7px; padding: 7px 10px; min-height: 36px; max-width: 100%; min-width: 0;
}
textarea { resize: vertical; min-height: 64px; line-height: 1.45; }
select { padding-right: 28px; }
input:focus, select:focus, textarea:focus { outline: 2px solid color-mix(in oklab, var(--accent) 55%, transparent); outline-offset: 0; border-color: var(--accent); }
.form { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 12px 14px; }
.field { display: grid; gap: 5px; grid-column: span 3; min-width: 0; }
.field.full { grid-column: 1 / -1; } .field.third { grid-column: span 2; } .field.two-third { grid-column: span 4; }
.field > label, .field > .label { font-size: 12px; font-weight: 600; color: var(--ink-2); }
.field .hint { font-size: 12px; color: var(--muted); }
.field input, .field select, .field textarea { width: 100%; }
@media (max-width: 640px) { .field, .field.third, .field.two-third { grid-column: 1 / -1; } }
.checks { display: flex; flex-wrap: wrap; gap: 6px; }
.check { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); border-radius: 7px; padding: 5px 10px; font-size: 13px; cursor: pointer; background: var(--surface-2); }
.check input { margin: 0; }

.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.toolbar input[type="search"] { width: 220px; }
.seg { display: inline-flex; border: 1px solid var(--line-2); border-radius: 7px; overflow: hidden; }
.seg button { border: 0; background: var(--surface); padding: 6px 12px; font-size: 13px; cursor: pointer; color: var(--muted); }
.seg button + button { border-left: 1px solid var(--line-2); }
.seg button[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent); font-weight: 600; }

/* tables */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); }
.panel .table-wrap { border-radius: 6px; }
table.data { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.data th { text-align: left; font-size: 11px; font-weight: 600; letter-spacing: .07em; text-transform: uppercase; color: var(--muted); background: var(--surface-2); padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; position: sticky; top: 0; }
table.data td { padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.data tr:last-child td { border-bottom: 0; }
table.data tbody tr.clickable { cursor: pointer; }
table.data tbody tr.clickable:hover td { background: var(--surface-2); }
table.data td.n, table.data th.n { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
table.data .title { font-weight: 500; }
table.data .details { color: var(--muted); font-size: 12.5px; margin-top: 2px; max-width: 520px; }
table.data select.inline { min-height: 30px; padding: 3px 26px 3px 8px; font-size: 12.5px; }
.prog { display: flex; align-items: center; gap: 8px; min-width: 110px; }
.prog .bar { flex: 1; height: 6px; border-radius: 3px; background: var(--sunken); position: relative; overflow: hidden; min-width: 50px; }
.prog .bar i { position: absolute; inset: 0 auto 0 0; background: var(--accent); border-radius: 3px; }
.prog .bar i.done { background: var(--good); }
.prog .bar b { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--ink); opacity: .55; }
.prog span { font-size: 12px; font-variant-numeric: tabular-nums; color: var(--ink-2); width: 34px; text-align: right; }
.flags { display: flex; flex-wrap: wrap; gap: 4px; }

/* lists */
.list { list-style: none; margin: 0; padding: 0; display: grid; }
.list > li { padding: 9px 0; border-top: 1px solid var(--line); display: grid; gap: 3px; }
.list > li:first-child { border-top: 0; padding-top: 2px; }
.li-top { display: flex; gap: 8px; align-items: baseline; justify-content: space-between; }
.li-title { font-weight: 500; min-width: 0; }
.li-sub { font-size: 12.5px; color: var(--muted); display: flex; flex-wrap: wrap; gap: 4px 12px; }
.plan-cols { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
@media (max-width: 1080px) { .plan-cols { grid-template-columns: 1fr; } }
.plan-col h3 { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; padding-bottom: 8px; border-bottom: 2px solid var(--ink); margin-bottom: 4px; }
.plan-col h3 .sub { font-family: var(--f-body); font-weight: 500; font-size: 12px; color: var(--muted); font-stretch: 100%; }
.week-group { margin-top: 10px; }
.week-group .wk { font-size: 11.5px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); display: flex; justify-content: space-between; }
ol.measures { margin: 0; padding: 0; list-style: none; counter-reset: m; display: grid; gap: 0; }
ol.measures li { counter-increment: m; display: grid; grid-template-columns: 26px minmax(0, 1fr); gap: 2px 10px; padding: 10px 0; border-top: 1px solid var(--line); }
ol.measures li:first-child { border-top: 0; padding-top: 2px; }
ol.measures li::before { content: counter(m); font-family: var(--f-display); font-stretch: 75%; font-weight: 700; font-size: 18px; color: var(--muted); line-height: 1.2; grid-row: span 2; text-align: right; }
ol.measures .what { font-weight: 500; }
ol.measures .why { font-size: 12.5px; color: var(--muted); grid-column: 2; }
ol.measures li.crit::before { color: var(--crit); } ol.measures li.warn::before { color: var(--warn); }

/* charts */
.chart { width: 100%; height: auto; display: block; overflow: visible; }
.chart text { fill: var(--muted); font: 500 11px var(--f-body); font-variant-numeric: tabular-nums; }
.chart .grid-l { stroke: var(--line); stroke-width: 1; }
.chart .axis-l { stroke: var(--line-2); stroke-width: 1; }
.chart .planned { stroke: var(--idle); stroke-width: 2; fill: none; stroke-dasharray: 5 4; }
.chart .earned { stroke: var(--accent); stroke-width: 2.5; fill: none; }
.chart .earned-area { fill: var(--accent); opacity: .1; }
.chart .today-l { stroke: var(--ink-2); stroke-width: 1; stroke-dasharray: 2 3; }
.chart .gap-l { stroke: var(--crit); stroke-width: 1.5; }
.chart text.lbl-strong { fill: var(--ink); font-weight: 600; }
.chart text.lbl-crit { fill: var(--crit); font-weight: 600; }
.chart .hit { fill: transparent; cursor: crosshair; }
.chart .hover-l { stroke: var(--ink-2); stroke-width: 1; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 12.5px; color: var(--ink-2); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 16px; height: 0; border-top: 2.5px solid var(--accent); display: inline-block; }
.legend i.planned { border-top: 2px dashed var(--idle); }
.legend i.sq { width: 10px; height: 10px; border: 0; border-radius: 2px; }
.chart-wrap { position: relative; }
.tip { position: absolute; pointer-events: none; background: var(--ink); color: var(--bg); border-radius: 6px; padding: 7px 10px; font-size: 12px; line-height: 1.45; white-space: nowrap; transform: translate(-50%, calc(-100% - 10px)); box-shadow: var(--shadow); z-index: 5; }
.tip b { font-weight: 600; }
.stackbar { display: flex; height: 14px; border-radius: 4px; overflow: hidden; gap: 2px; background: var(--surface); }
.stackbar span { display: block; min-width: 4px; }
.status-legend { display: grid; grid-template-columns: 1fr auto auto; gap: 4px 12px; font-size: 13px; margin-top: 12px; }
.status-legend .n { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }
.status-legend .md { text-align: right; font-variant-numeric: tabular-nums; color: var(--muted); }
.epics { display: grid; gap: 10px; }
.epic-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 10px; font-size: 13px; }
.epic-row .prog { grid-column: 1 / -1; }

/* board */
.board { display: grid; grid-template-columns: repeat(5, minmax(230px, 1fr)); gap: 12px; overflow-x: auto; padding-bottom: 6px; }
.col { background: var(--sunken); border-radius: var(--r); padding: 10px; display: flex; flex-direction: column; gap: 8px; min-height: 240px; border: 2px dashed transparent; }
.col.drop { border-color: var(--accent); background: var(--accent-soft); }
.col-head { display: flex; justify-content: space-between; align-items: center; padding: 0 2px 4px; }
.col-head .st { font-weight: 600; font-size: 13px; }
.col-empty { margin: 0; padding: 18px 12px; border: 1px dashed var(--line-2); border-radius: 7px; font-size: 12.5px; line-height: 1.45; color: var(--muted); text-align: center; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 7px; padding: 10px 11px; display: grid; gap: 6px; cursor: grab; box-shadow: 0 1px 1px rgba(0, 0, 0, .03); }
.card:hover { border-color: var(--line-2); }
.card.dragging { opacity: .5; }
.card .c-top { display: flex; justify-content: space-between; gap: 6px; align-items: center; }
.card .c-name { font-weight: 500; font-size: 13.5px; line-height: 1.35; }
.card .c-meta { display: flex; justify-content: space-between; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); flex-wrap: wrap; }
.card .late { color: var(--crit); font-weight: 600; }
.sprint-head { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 12px 20px; align-items: end; }
@media (max-width: 860px) { .sprint-head { grid-template-columns: 1fr; } }
.sprint-stats { display: flex; gap: 22px; flex-wrap: wrap; }
.sprint-stats div { display: grid; }
.sprint-stats .v { font-family: var(--f-display); font-stretch: 78%; font-weight: 700; font-size: 22px; font-variant-numeric: tabular-nums; line-height: 1.1; }
.goal-input { width: 100%; font-size: 15px; }

/* timeline / gantt */
table.gantt { border-collapse: separate; border-spacing: 0; font-size: 12.5px; min-width: 100%; }
table.gantt th, table.gantt td { border-bottom: 1px solid var(--line); padding: 0; height: 34px; }
table.gantt thead th { position: sticky; top: 0; background: var(--surface-2); z-index: 2; font-weight: 600; font-size: 11px; color: var(--muted); text-align: center; padding: 6px 4px; height: auto; line-height: 1.3; }
table.gantt .tcol { position: sticky; left: 0; background: var(--surface); z-index: 1; text-align: left; padding: 6px 10px; min-width: 260px; max-width: 320px; border-right: 1px solid var(--line); }
table.gantt thead .tcol { z-index: 3; background: var(--surface-2); }
table.gantt .tcol .nm { display: block; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 290px; }
table.gantt .tcol .ow { font-size: 11.5px; color: var(--muted); }
table.gantt td.wk { min-width: 50px; text-align: center; border-left: 1px solid var(--line); position: relative; font-variant-numeric: tabular-nums; font-weight: 600; }
table.gantt th.now, table.gantt td.now { box-shadow: inset 2px 0 0 var(--ink-2), inset -2px 0 0 var(--ink-2); }
table.gantt td.wk span.cell { position: absolute; inset: 6px 1px; display: grid; place-items: center; border-radius: 3px; background: var(--cbg, var(--sunken)); color: var(--cfg, var(--ink)); }
table.gantt td.wk span.carry { background: repeating-linear-gradient(135deg, var(--crit-soft) 0 5px, transparent 5px 9px); color: var(--crit); outline: 1px solid color-mix(in oklab, var(--crit) 50%, transparent); outline-offset: -1px; }
table.gantt tr.grp td { background: var(--surface-2); font-size: 11px; letter-spacing: .08em; text-transform: uppercase; font-weight: 600; color: var(--muted); height: 28px; }
table.gantt tr.grp td.tcol { background: var(--surface-2); }
table.gantt tr.tot td { font-weight: 700; background: var(--surface-2); }
table.gantt tr.tot td.tcol { background: var(--surface-2); }
table.gantt tbody tr.task:hover td { background: var(--surface-2); cursor: pointer; }
table.gantt tbody tr.task:hover td.tcol { background: var(--surface-2); }

/* resources */
table.heat { border-collapse: separate; border-spacing: 3px; font-size: 12.5px; }
table.heat th { font-size: 11px; font-weight: 600; color: var(--muted); padding: 4px; text-align: center; line-height: 1.3; white-space: nowrap; }
table.heat th.now { color: var(--ink); }
table.heat th.who { text-align: left; position: sticky; left: 0; background: var(--surface); z-index: 1; padding-right: 12px; min-width: 190px; }
table.heat td.who { position: sticky; left: 0; background: var(--surface); z-index: 1; padding: 4px 12px 4px 0; white-space: nowrap; }
table.heat td.cell { width: 54px; min-width: 54px; height: 38px; border-radius: 5px; text-align: center; font-weight: 600; font-variant-numeric: tabular-nums; cursor: pointer; background: var(--surface-2); color: var(--ink); border: 1px solid transparent; }
table.heat td.cell.l0 { color: var(--muted); font-weight: 400; background: var(--surface-2); }
table.heat td.cell.l1 { background: var(--heat-1); }
table.heat td.cell.l2 { background: var(--heat-2); }
table.heat td.cell.l3 { background: var(--heat-3); color: #fff; }
table.heat td.cell.over { background: var(--crit); color: #fff; }
table.heat td.cell.sel { outline: 2px solid var(--ink); outline-offset: 1px; }
table.heat td.cell.now { border-color: var(--ink-2); }
table.heat td.cell small { display: block; font-size: 10px; font-weight: 500; opacity: .85; line-height: 1; }
table.heat tr.team-row td.who { color: var(--muted); }
.heat-legend { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 12px; color: var(--ink-2); align-items: center; }
.heat-legend i { width: 16px; height: 12px; border-radius: 3px; display: inline-block; vertical-align: -2px; margin-right: 4px; }
.people-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; }
.pcard { border: 1px solid var(--line); border-radius: var(--r); padding: 12px 14px; display: grid; gap: 8px; background: var(--surface); }
.pcard.conf { border-color: color-mix(in oklab, var(--crit) 55%, var(--line)); }
.pcard .util { display: flex; gap: 16px; }
.pcard .util div { display: grid; }
.pcard .util .v { font-family: var(--f-display); font-stretch: 78%; font-weight: 700; font-size: 21px; font-variant-numeric: tabular-nums; line-height: 1.1; }
.pcard .util .v.over { color: var(--crit); }
.conflict { border: 1px solid var(--line); border-radius: var(--r); padding: 12px 14px; display: grid; gap: 8px; }
.conflict.critical { border-left: 4px solid var(--crit); }
.conflict.warning { border-left: 4px solid var(--warn); }
.conflict table.data td { padding: 5px 8px; }

/* alerts */
.alert { display: grid; grid-template-columns: 28px minmax(0, 1fr) auto; gap: 4px 12px; padding: 12px 0; border-top: 1px solid var(--line); align-items: start; }
.alert:first-child { border-top: 0; }
.alert .ico { width: 26px; height: 26px; border-radius: 6px; display: grid; place-items: center; }
.alert .ico svg { width: 15px; height: 15px; }
.alert.critical .ico { background: var(--crit-soft); color: var(--crit); }
.alert.warning .ico { background: var(--warn-soft); color: var(--warn); }
.alert.info .ico { background: var(--accent-soft); color: var(--accent); }
.alert .a-title { font-weight: 600; }
.alert .a-detail { font-size: 13px; color: var(--ink-2); }
.alert .a-to { font-size: 12px; color: var(--muted); display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.sev-count { display: flex; gap: 8px; flex-wrap: wrap; }
.digest { width: 100%; min-height: 220px; font-family: var(--f-mono); font-size: 12px; }

/* modal, toast */
.modal-back { position: fixed; inset: 0; background: rgba(10, 16, 13, .45); z-index: 50; display: grid; place-items: start center; overflow-y: auto; padding: max(24px, env(safe-area-inset-top, 0px)) max(12px, env(safe-area-inset-right, 0px)) 24px max(12px, env(safe-area-inset-left, 0px)); }
.modal { width: min(820px, 100%); background: var(--surface); border-radius: 10px; box-shadow: var(--shadow); border: 1px solid var(--line); display: grid; }
.modal.narrow { width: min(480px, 100%); }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.modal-body { padding: 18px 20px; display: grid; gap: 16px; }
.modal-foot { display: flex; gap: 8px; padding: 14px 20px; border-top: 1px solid var(--line); background: var(--surface-2); border-radius: 0 0 10px 10px; flex-wrap: wrap; }
.log { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; max-height: 220px; overflow: auto; }
.log li { font-size: 12.5px; border-left: 2px solid var(--line-2); padding-left: 10px; }
.log li .when { color: var(--muted); }
.alloc-chips { display: flex; flex-wrap: wrap; gap: 4px; }
.alloc-chips span { font-family: var(--f-mono); font-size: 11.5px; padding: 2px 6px; border-radius: 4px; background: var(--sunken); }
.toasts { position: fixed; z-index: 60; right: max(16px, env(safe-area-inset-right, 0px)); bottom: max(16px, env(safe-area-inset-bottom, 0px)); display: grid; gap: 8px; }
.toast { background: var(--ink); color: var(--bg); padding: 10px 14px; border-radius: 8px; box-shadow: var(--shadow); font-size: 13.5px; max-width: 360px; }
.toast.err { background: var(--crit); color: #fff; }

/* empty & gate */
.empty { text-align: center; padding: 40px 20px; display: grid; gap: 10px; justify-items: center; color: var(--muted); }
.empty h2 { color: var(--ink); font-size: 20px; }
.gate { max-width: 460px; margin: 60px auto; }
.matrix { display: grid; grid-template-columns: auto repeat(3, minmax(0, 1fr)); gap: 4px; font-size: 12px; }
.matrix .h { color: var(--muted); font-weight: 600; text-align: center; padding: 2px; font-size: 11px; }
.matrix .rh { color: var(--muted); font-weight: 600; padding-right: 6px; display: grid; align-items: center; font-size: 11px; }
.matrix .c { border-radius: 5px; height: 40px; display: grid; place-items: center; font-weight: 700; font-size: 15px; font-variant-numeric: tabular-nums; }
.matrix .c.s3 { background: var(--crit-soft); color: var(--crit); } .matrix .c.s2 { background: var(--warn-soft); color: var(--warn); } .matrix .c.s1 { background: var(--sunken); color: var(--muted); }

@media (prefers-reduced-motion: no-preference) {
  .toast { animation: rise .18s ease-out; }
  @keyframes rise { from { transform: translateY(6px); opacity: .4; } to { transform: none; opacity: 1; } }
}
@media (max-width: 640px) {
  /* On phones the full header is too tall to pin; it scrolls away with the page. */
  .topbar { position: static; }
  h1 { font-size: 22px; }
  .switch select { max-width: 190px; }
  .toolbar input[type="search"] { width: 100%; }
  .kpi .value { font-size: 28px; }
}

/* Dashboards tab: grouped page menu, chart marks (light blue = plan or reference, dark blue = actual), print layout */
.dash-nav { display: flex; flex-wrap: wrap; gap: 10px 18px; align-items: flex-end; padding-bottom: 14px; border-bottom: 1px solid var(--line); }
.dash-group { display: grid; gap: 5px; }
.dash-group .seg { flex-wrap: wrap; }
.dash-title { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 10px 16px; }
.dash-title p { margin-top: 2px; }
.chart .bar-ref { fill: var(--heat-2); }
.chart .bar-act { fill: var(--accent); }
.chart .bar-crit { fill: var(--crit); }
.chart .ref-line { stroke: var(--heat-2); stroke-width: 2; fill: none; stroke-dasharray: 6 4; }
.chart .act-line { stroke: var(--accent); stroke-width: 2; fill: none; }
.chart .dot { fill: var(--accent); stroke: var(--surface); stroke-width: 2; }
.chart .avg-l { stroke: var(--ink-2); stroke-width: 1; stroke-dasharray: 2 3; }
.chart .link-l { stroke: var(--line-2); stroke-width: 2; }
.chart .dia-ref { fill: var(--surface); stroke: var(--heat-3); stroke-width: 2; }
.chart .dia-act { fill: var(--accent); stroke: var(--surface); stroke-width: 2; }
.chart .dia-crit { fill: var(--crit); stroke: var(--surface); stroke-width: 2; }
.legend i.sq.ref { background: var(--heat-2); }
.legend i.sq.act { background: var(--accent); }
.legend i.sq.crit { background: var(--crit); }
.legend i.ref-dash { border-top: 2px dashed var(--heat-2); }
.legend i.avg { border-top: 2px dotted var(--ink-2); }
.age-bars { display: grid; gap: 8px; }
.age-row { display: grid; grid-template-columns: minmax(90px, 160px) minmax(0, 1fr) 32px; gap: 10px; align-items: center; font-size: 13px; }
.age-row span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.age-track { height: 10px; border-radius: 3px; background: var(--sunken); overflow: hidden; }
.age-track i { display: block; height: 100%; min-width: 2px; background: var(--accent); border-radius: 0 3px 3px 0; }
.age-row b { text-align: right; font-weight: 600; }
.checks.deps { max-height: 170px; overflow-y: auto; padding: 2px; }
.checks.deps .check { font-size: 12.5px; padding: 4px 8px; }
.num-input { width: 78px; text-align: right; font-variant-numeric: tabular-nums; min-height: 30px; padding: 3px 8px; }
ol.chain { list-style: none; margin: 0; padding: 0 0 0 14px; display: grid; gap: 0; border-left: 2px solid var(--line-2); }
ol.chain li { position: relative; padding: 8px 0 10px 12px; display: grid; gap: 3px; cursor: pointer; }
ol.chain li::before { content: ""; position: absolute; left: -21px; top: 13px; width: 10px; height: 10px; border-radius: 50%; background: var(--surface); border: 2px solid var(--heat-3); }
ol.chain li.crit::before { border-color: var(--crit); background: var(--crit); }
ol.chain li:hover .li-title { text-decoration: underline; }
@media (max-width: 640px) { .dash-title .toolbar { width: 100%; } .age-row { grid-template-columns: 90px minmax(0, 1fr) 28px; } }
@media print {
  :root:not(#print) {
    --bg: #FFFFFF; --surface: #FFFFFF; --surface-2: #F7F8F4; --sunken: #EBEDE6; --ink: #16201B; --ink-2: #3B4640; --muted: #5F6A63;
    --line: #DADFD5; --line-2: #C3CABF; --accent: #1C5B7B; --accent-soft: #E1EDF3; --good: #26734A; --good-soft: #DFF0E5;
    --warn: #93600A; --warn-soft: #FAEED5; --crit: #B4361F; --crit-soft: #F8E0D9; --heat-2: #9DC2D4; --heat-3: #4F8DAD; color-scheme: light;
  }
  body { background: #fff; }
  .topbar, .dash-nav, .no-print, #numberNotes, .toasts, .note-pop, .dash-title .toolbar, .cite { display: none !important; }
  .panel { box-shadow: none; break-inside: avoid; }
  .grid { gap: 10px; }
}
