/* app.css -- ScaleArena arena UI. System fonts, CSS variables, dark/light from the OS. */

:root {
  --bg: #f7f7f5;
  --surface: #ffffff;
  --surface-2: #fbfbfa;
  --line: #e2e2dd;
  --line-strong: #cfcfc8;
  --ink: #1b1b19;
  --ink-2: #4a4a45;
  --ink-3: #78786f;
  --accent: #2f5d8a;
  --accent-soft: #e8eff6;
  --good: #1f7a4d;
  --good-soft: #e3f3ea;
  --bad: #a43030;
  --bad-soft: #fbe9e7;
  --warn: #8a5a12;
  --warn-soft: #fcf1de;
  --focus: #2f5d8a;

  --s-n: #3d5a9e;
  --s-nactive: #1f8a86;
  --s-queue: #b8791f;
  --s-arrivals: #5b6f8f;
  --s-served: #2f7d52;
  --s-att: #7a4aa8;
  --s-plain: #6a6a62;

  --d0: #eceae5;  --d1: #e7efe9;  --d2: #fbeed7;  --d3: #f8ddd8;
  --d0-ink: #55554e; --d1-ink: #256b46; --d2-ink: #8a5a12; --d3-ink: #a43030;

  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --radius: 8px;
  --shadow: 0 1px 2px rgba(0,0,0,.05), 0 6px 18px rgba(0,0,0,.04);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #131315;
    --surface: #1a1a1d;
    --surface-2: #202024;
    --line: #2d2d32;
    --line-strong: #3d3d44;
    --ink: #ecebe6;
    --ink-2: #b9b7b0;
    --ink-3: #85837c;
    --accent: #7aa8d8;
    --accent-soft: #1d2a38;
    --good: #57c088;
    --good-soft: #14291e;
    --bad: #e6807a;
    --bad-soft: #2e1a19;
    --warn: #d9a55a;
    --warn-soft: #2c2314;
    --focus: #7aa8d8;

    --s-n: #7f9be0;
    --s-nactive: #46c6c0;
    --s-queue: #e0a23f;
    --s-arrivals: #9aaec9;
    --s-served: #5fbc86;
    --s-att: #b489e0;
    --s-plain: #9c9a93;

    --d0: #26262a;  --d1: #17291f;  --d2: #2e2515;  --d3: #33201e;
    --d0-ink: #a6a49c; --d1-ink: #6fce9b; --d2-ink: #e0a23f; --d3-ink: #e6807a;
    --shadow: 0 1px 2px rgba(0,0,0,.4), 0 8px 24px rgba(0,0,0,.25);
  }
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 14px/1.5 var(--sans);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

a { color: var(--accent); }
code, .mono, pre { font-family: var(--mono); font-size: .92em; }

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

.skip {
  position: absolute; left: -999px; top: 0; z-index: 50;
  background: var(--surface); padding: 8px 12px; border: 1px solid var(--line);
}
.skip:focus { left: 8px; top: 8px; }

/* ------------------------------------------------------------- top bar */
.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; flex-wrap: wrap; gap: 12px 20px; align-items: center; justify-content: space-between;
  padding: 10px 20px;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: saturate(150%) blur(8px);
  border-bottom: 1px solid var(--line);
}
.topbar-left { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; min-width: 0; }
.brand {
  font-size: 16px; font-weight: 640; letter-spacing: -.01em;
  display: inline-flex; align-items: center; gap: 8px;
}
.brand-mark {
  width: 13px; height: 13px; border-radius: 50%;
  border: 3px solid var(--accent);
  box-shadow: inset 0 0 0 2px var(--surface);
}
.card-picker { display: inline-flex; align-items: center; gap: 7px; }
.card-picker-label, .picker label { color: var(--ink-3); font-size: 12px; text-transform: uppercase; letter-spacing: .05em; }
.card-meta { color: var(--ink-3); font-size: 12px; white-space: nowrap; }

select, input[type="text"], input[type="number"], textarea {
  font: inherit; color: var(--ink);
  background: var(--surface); border: 1px solid var(--line-strong);
  border-radius: 6px; padding: 5px 8px; max-width: 100%;
}
select { padding-right: 24px; }

.tabs { display: flex; gap: 2px; background: var(--surface-2); padding: 3px; border-radius: 9px; border: 1px solid var(--line); }
.tab {
  font: inherit; color: var(--ink-2); background: transparent;
  border: 0; border-radius: 7px; padding: 6px 13px; cursor: pointer; white-space: nowrap;
}
.tab:hover { color: var(--ink); background: color-mix(in srgb, var(--accent-soft) 60%, transparent); }
.tab.active { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); font-weight: 560; }

/* ------------------------------------------------------------- layout */
main { max-width: 1400px; margin: 0 auto; padding: 20px; }
.view[hidden] { display: none; }
.block { margin: 28px 0; }
.block-h {
  font-size: 13px; font-weight: 640; text-transform: uppercase; letter-spacing: .07em;
  color: var(--ink-3); margin: 0 0 10px; display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap;
}
.block-sub { font-weight: 400; text-transform: none; letter-spacing: 0; color: var(--ink-3); font-size: 12px; }

.banner { padding: 9px 20px; font-size: 13px; border-bottom: 1px solid var(--line); }
.banner-ok { background: var(--good-soft); color: var(--good); }
.banner-error { background: var(--bad-soft); color: var(--bad); }
.banner-warn { background: var(--warn-soft); color: var(--warn); }
.banner-info { background: var(--accent-soft); color: var(--accent); }

.foot { max-width: 1400px; margin: 0 auto; padding: 20px; color: var(--ink-3); font-size: 12px; }

/* ------------------------------------------------------------- headline */
.headline { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 16px; align-items: stretch; }
@media (max-width: 900px) { .headline { grid-template-columns: 1fr; } }

.verdict {
  background: var(--surface); border: 1px solid var(--line); border-left: 4px solid var(--ink-3);
  border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); height: 100%;
}
.verdict-agree { border-left-color: var(--good); }
.verdict-disagree { border-left-color: var(--bad); }
.verdict-insufficient { border-left-color: var(--warn); }
.verdict-top { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.verdict-badge {
  font-weight: 700; font-size: 12px; letter-spacing: .08em; padding: 3px 9px; border-radius: 5px;
  background: var(--ink-3); color: var(--surface);
}
.verdict-agree .verdict-badge { background: var(--good); color: #fff; }
.verdict-disagree .verdict-badge { background: var(--bad); color: #fff; }
.verdict-insufficient .verdict-badge { background: var(--warn); color: #fff; }
.verdict-where { color: var(--ink-3); font-size: 12px; font-family: var(--mono); }
.verdict-line { margin: 10px 0 0; font-size: 15px; line-height: 1.45; }
.verdict-sub { margin: 8px 0 0; font-size: 12.5px; color: var(--ink-3); }
.verdict-chips { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }

.chip {
  font-size: 12px; padding: 3px 8px; border-radius: 999px; border: 1px solid var(--line-strong);
  background: var(--surface-2); color: var(--ink-2); display: inline-flex; gap: 6px; align-items: baseline;
}
.chip b { font-weight: 640; }
.chip-agree { background: var(--good-soft); border-color: color-mix(in srgb, var(--good) 35%, transparent); color: var(--good); }
.chip-disagree { background: var(--bad-soft); border-color: color-mix(in srgb, var(--bad) 35%, transparent); color: var(--bad); }
.chip-insufficient { background: var(--warn-soft); border-color: color-mix(in srgb, var(--warn) 35%, transparent); color: var(--warn); }
.chip-n { color: var(--ink-3); font-variant-numeric: tabular-nums; }

.headline-facts, .headline > * { min-width: 0; }
.headline-facts {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 12px 14px; display: grid; grid-template-columns: 1fr 1fr; gap: 8px 16px; box-shadow: var(--shadow);
}
.fact dt { color: var(--ink-3); font-size: 11px; text-transform: uppercase; letter-spacing: .05em; }
.fact dd { margin: 1px 0 0; font-family: var(--mono); font-size: 12px; overflow-wrap: anywhere; }

/* ------------------------------------------------------------- tables */
.table-scroll { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
table.grid { border-collapse: collapse; width: 100%; font-variant-numeric: tabular-nums; }
table.grid th, table.grid td { text-align: left; padding: 0; border-bottom: 1px solid var(--line); }
table.grid thead th { position: sticky; top: 0; background: var(--surface-2); z-index: 1; border-bottom: 1px solid var(--line-strong); }
.th-wrap { display: flex; align-items: center; gap: 2px; }
th.num .th-wrap { justify-content: flex-end; }
th.c-mid .th-wrap { justify-content: center; }
.th-btn { font: inherit; font-size: 11.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em;
  color: var(--ink-3); background: transparent; border: 0; cursor: pointer;
  padding: 8px 10px; display: flex; align-items: center; gap: 5px; white-space: nowrap;
}
.th-btn:hover { color: var(--ink); background: color-mix(in srgb, var(--accent-soft) 55%, transparent); }
.th-arrow { font-size: 9px; color: var(--accent); }
table.grid td { padding: 7px 10px; }
table.grid td.num { text-align: right; }
table.grid td.c-mid { text-align: center; }
table.grid tbody tr:hover { background: var(--surface-2); }
table.grid tbody tr:last-child td { border-bottom: 0; }
table.grid tbody tr.front { background: color-mix(in srgb, var(--accent-soft) 45%, transparent); }
table.grid tbody tr.front:hover { background: color-mix(in srgb, var(--accent-soft) 80%, transparent); }
table.grid tbody tr.hl { box-shadow: inset 3px 0 0 var(--accent); background: var(--accent-soft); }
table.grid tbody tr.misses .v { color: var(--ink-2); }
table.grid tbody tr.out-tol td.num .delta { font-weight: 640; }

.rowname { font-family: var(--mono); font-size: 12.5px; font-weight: 560; }
.rowlabel { display: block; color: var(--ink-3); font-size: 11.5px; }
.v { font-size: 13px; }
.v.dim { color: var(--ink-2); }
.v.up { color: var(--good); } .v.down { color: var(--bad); }
.ci { color: var(--ink-3); font-size: 11px; margin-left: 5px; }
.ci-few { font-style: italic; border-bottom: 1px dotted var(--ink-3); cursor: help; }
.dim { color: var(--ink-2); }
.slash { color: var(--ink-3); margin: 0 3px; }

.pill {
  display: inline-block; font-size: 11px; font-weight: 620; padding: 2px 8px; border-radius: 999px; white-space: nowrap;
}
.pill-yes { background: var(--good-soft); color: var(--good); }
.pill-no { background: transparent; color: var(--ink-3); border: 1px solid var(--line-strong); }
.pill-unknown { color: var(--ink-3); }
.badge { font-size: 11px; padding: 2px 7px; border-radius: 4px; font-variant-numeric: tabular-nums; }
.badge-front { background: var(--accent-soft); color: var(--accent); font-weight: 620; }
.badge-rank { color: var(--ink-3); border: 1px solid var(--line); }
.badge-cost-front { color: var(--ink-3); border: 1px dashed var(--line); font-style: italic; }
.tag { font-size: 10px; text-transform: uppercase; letter-spacing: .05em; padding: 1px 5px; border-radius: 3px; }
.tag-plugin { background: var(--warn-soft); color: var(--warn); }

.delta { font-size: 13px; padding: 2px 6px; border-radius: 4px; display: inline-block; min-width: 62px; text-align: right; }
.delta.d0 { background: var(--d0); color: var(--d0-ink); }
.delta.d1 { background: var(--d1); color: var(--d1-ink); }
.delta.d2 { background: var(--d2); color: var(--d2-ink); }
.delta.d3 { background: var(--d3); color: var(--d3-ink); }
.delta.d-na { color: var(--ink-3); }

.fam { margin-bottom: 20px; }
.fam-h { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; margin: 0 0 7px; font-size: 14px; }
.fam-name { font-weight: 620; }
.fam-key { font-family: var(--mono); font-size: 11.5px; color: var(--ink-3); }
.fam-count { margin-left: auto; font-size: 12px; color: var(--ink-3); }

/* ------------------------------------------------------- predicted vs measured */
.compare-grid { display: grid; grid-template-columns: minmax(0, 2.1fr) minmax(280px, 1fr); gap: 16px; align-items: start; }
.compare-grid > * { min-width: 0; }
@media (max-width: 1080px) { .compare-grid { grid-template-columns: minmax(0, 1fr); } }
.scatter-wrap { margin: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px; }
.scatter svg { width: 100%; height: auto; display: block; }
.figcap { color: var(--ink-3); font-size: 11.5px; margin-top: 6px; line-height: 1.45; }
.inline-pick { font-size: 12px; color: var(--ink-3); }
.inline-pick select { font-size: 12px; padding: 2px 6px; }

.details { margin-top: 14px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.details > summary {
  cursor: pointer; padding: 9px 13px; font-size: 12.5px; color: var(--ink-2); font-weight: 560; list-style: revert;
}
.details > summary:hover { color: var(--ink); }
.details[open] > summary { border-bottom: 1px solid var(--line); }
.details > div { padding: 14px; }
.kd-period { margin-bottom: 18px; }
.kd-period h3 { font-size: 13.5px; margin: 0 0 6px; display: flex; gap: 8px; align-items: center; }
.kd-req { margin: 0 0 10px; font-size: 12px; color: var(--ink-3); }
.kd-metric { border-top: 1px solid var(--line); padding-top: 10px; margin-top: 10px; }
.kd-metric h4 { margin: 0 0 4px; font-size: 13px; display: flex; gap: 8px; align-items: center; }
.kd-line { margin: 0 0 8px; color: var(--ink-2); }
.kd-nums { display: flex; flex-wrap: wrap; gap: 6px 22px; margin: 0 0 8px; }
.kd-nums dt { font-size: 11px; color: var(--ink-3); text-transform: uppercase; letter-spacing: .04em; }
.kd-nums dd { margin: 0; font-variant-numeric: tabular-nums; font-size: 13px; }
.kd-nums dd.bad, .bad { color: var(--bad); }
.kd-list { font-size: 12px; margin-top: 6px; }
.kd-list b { color: var(--ink-3); font-weight: 600; font-size: 11px; text-transform: uppercase; letter-spacing: .04em; }
.kd-list ul { margin: 4px 0 0; padding-left: 18px; color: var(--ink-2); }
.kd-list ul.cols { columns: 3 150px; }
.kd-rule { font-size: 12px; color: var(--ink-3); border-top: 1px solid var(--line); padding-top: 10px; }
.note { white-space: pre-wrap; word-break: break-word; font-size: 11.5px; line-height: 1.6; margin: 0; color: var(--ink-2); max-height: 420px; overflow: auto; }

/* ------------------------------------------------------------- add tab */
.add-grid { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(340px, .9fr); gap: 18px; align-items: start; }
.add-grid > * { min-width: 0; }
@media (max-width: 1080px) { .add-grid { grid-template-columns: minmax(0, 1fr); } }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); margin-bottom: 18px; }
.panel-sticky { position: sticky; top: 74px; }
.panel-h { margin: 0 0 6px; font-size: 14.5px; font-weight: 640; }
.panel-sh { margin: 0 0 6px; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-3); }
.panel-lead { margin: 0 0 14px; color: var(--ink-2); font-size: 13px; }
.field { margin-bottom: 13px; display: flex; flex-direction: column; gap: 4px; }
.field > label { font-size: 12px; font-weight: 600; color: var(--ink-2); }
.field-row { flex-direction: row; align-items: center; gap: 10px; }
.check { display: inline-flex; gap: 6px; align-items: center; font-size: 12.5px; color: var(--ink-2); }
.help { font-size: 11.5px; color: var(--ink-3); }
.validity { font-size: 11.5px; min-height: 16px; color: var(--ink-3); }
/* a field the source has taken over: still legible, visibly not yours to type in */
input.locked { background: var(--surface-2); color: var(--ink-2); border-style: dashed; cursor: not-allowed; }
#source-authority { padding: 0 0 10px; color: var(--ink-2); border-left: 3px solid var(--warn); padding-left: 9px; margin-bottom: 12px; }
.validity.ok { color: var(--good); }
.validity.bad { color: var(--bad); }
.validity.warn { color: var(--warn); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
@media (max-width: 640px) { .grid2 { grid-template-columns: 1fr; } }

textarea#plugin-source {
  font-family: var(--mono); font-size: 12px; line-height: 1.55; tab-size: 4;
  background: var(--surface-2); min-height: 420px; resize: vertical; white-space: pre; overflow: auto;
}

.actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 4px; }
.btn {
  font: inherit; font-size: 13px; font-weight: 560; padding: 7px 14px; border-radius: 7px; cursor: pointer;
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink);
}
.btn:hover:not(:disabled) { border-color: var(--ink-3); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover:not(:disabled) { filter: brightness(1.08); }
.btn-quiet { background: transparent; border-color: var(--line); color: var(--ink-2); }
.btn-sm { font-size: 12px; padding: 4px 10px; }
.btn-link { text-decoration: none; display: inline-block; margin-top: 10px; }

.errors { margin-bottom: 14px; }
.errors.good .ok-box { border-color: color-mix(in srgb, var(--good) 40%, transparent); }
.ok-box { background: var(--good-soft); color: var(--good); border: 1px solid transparent; border-radius: 6px; padding: 9px 12px; font-size: 13px; }
.ok-box .mono { color: inherit; }
.errbox { background: var(--bad-soft); border: 1px solid color-mix(in srgb, var(--bad) 30%, transparent); border-radius: 6px; padding: 11px 13px; }
.errbox-h { font-weight: 640; color: var(--bad); font-size: 13px; }
.errbox-msg { font-family: var(--mono); font-size: 12px; margin-top: 5px; color: var(--ink); overflow-wrap: anywhere; }
.errbox-hint { margin-top: 7px; font-size: 12px; color: var(--ink-2); }
.err-list { margin: 6px 0 0; padding-left: 18px; font-size: 12.5px; color: var(--ink); }
.err-one + .err-one { margin-top: 10px; border-top: 1px solid color-mix(in srgb, var(--bad) 20%, transparent); padding-top: 8px; }
.err-msg { font-size: 12.5px; margin-top: 6px; color: var(--ink); }
.err-where { color: var(--ink-3); font-family: var(--mono); font-size: 11px; }
.warn-txt { color: var(--warn); }
.trace {
  margin-top: 9px; background: var(--surface); border: 1px solid var(--line); border-radius: 6px;
  padding: 10px; font-size: 11.5px; line-height: 1.5; max-height: 280px; overflow: auto; white-space: pre;
}
.subblock { margin-top: 16px; }
.empty {
  border: 1px dashed var(--line-strong); border-radius: var(--radius); padding: 16px;
  color: var(--ink-2); font-size: 13px; display: flex; flex-direction: column; gap: 5px; background: var(--surface-2);
}
.empty-prose { display: block; }
[hidden] { display: none !important; }
.empty-prose code { white-space: nowrap; }
.empty b { color: var(--ink); }
.empty span { color: var(--ink-3); }

.progress { margin-bottom: 10px; }
.prog-head { display: flex; justify-content: space-between; align-items: baseline; font-size: 12px; margin-bottom: 5px; }
.prog-status { text-transform: uppercase; letter-spacing: .06em; font-weight: 640; font-size: 11px; }
.st-running { color: var(--accent); } .st-done { color: var(--good); } .st-failed { color: var(--bad); } .st-queued { color: var(--ink-3); }
.prog-count { color: var(--ink-3); font-variant-numeric: tabular-nums; }
.prog-track { height: 7px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 999px; overflow: hidden; }
.prog-fill { height: 100%; background: var(--accent); transition: width .4s ease; }
.prog-fill.failed { background: var(--bad); }
.log {
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 6px; padding: 9px 11px;
  font-size: 11.5px; line-height: 1.55; max-height: 220px; overflow: auto; white-space: pre-wrap; margin: 0;
}
.job-result { margin-top: 10px; }
.spec-result:not(:empty) { margin: 10px 0; }
.commands-head { display: flex; align-items: center; justify-content: space-between; margin-top: 16px; }
.commands {
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 6px; padding: 11px 13px;
  font-size: 11.5px; line-height: 1.65; overflow-x: auto; margin: 0; white-space: pre;
}

/* ------------------------------------------------------------- runs tab */
.runs-pickers { display: flex; gap: 14px; flex-wrap: wrap; align-items: flex-start; margin-bottom: 14px; }
.picker {
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface);
  padding: 9px 13px 11px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin: 0;
}
.picker legend { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-3); padding: 0 5px; }
.picker-sim { border-left: 3px solid var(--s-n); }
.picker-hw { border-left: 3px dashed var(--s-n); }
.picker select { max-width: 220px; }
.runs-legend { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; font-size: 12px; color: var(--ink-2); padding: 6px 0; }
.lg-item { display: inline-flex; gap: 6px; align-items: center; }
.lg-swatch { width: 26px; height: 10px; }
.lg-sep { width: 1px; height: 16px; background: var(--line-strong); }
.lg-tri { width: 0; height: 0; border-left: 4px solid transparent; border-right: 4px solid transparent; border-bottom: 7px solid var(--good); }

.charts { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 6px; }
.panel-row + .panel-row { border-top: 1px solid var(--line); }

/* Phone: an SVG panel scaled to 400 px turns its axis text into 3 px smudge. Keep the panels at a
   legible width and let the box scroll sideways instead -- the label/select pairs stack too. */
@media (max-width: 720px) {
  .charts { overflow-x: auto; }
  .panel-row { min-width: 620px; }
  .run-head { min-width: 0; }
  .picker { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 6px 10px; align-items: center; }
  .picker select { max-width: 100%; width: 100%; }
}
.chart-panel { width: 100%; height: auto; display: block; }
.run-head { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; padding: 4px 8px 12px; }
@media (max-width: 800px) { .run-head { grid-template-columns: 1fr; } }
.rh-card { border: 1px solid var(--line); border-radius: 6px; padding: 10px 12px; background: var(--surface-2); }
.rh-cluster { border-style: dashed; }
.rh-empty { color: var(--ink-3); font-size: 12.5px; }
.rh-title { font-family: var(--mono); font-size: 12px; margin-bottom: 7px; overflow-wrap: anywhere; }
.rh-kind { display: inline-block; font-family: var(--sans); font-size: 10px; text-transform: uppercase; letter-spacing: .06em;
  color: var(--ink-3); margin-right: 7px; }
.rh-nums { display: flex; gap: 6px 20px; flex-wrap: wrap; margin: 0; }
.rh-nums dt { font-size: 10.5px; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-3); }
.rh-nums dd { margin: 1px 0 0; font-variant-numeric: tabular-nums; font-size: 13.5px; }
.rh-req { margin-top: 8px; font-size: 11.5px; color: var(--ink-3); }
.note-line { font-size: 12px; color: var(--ink-3); padding: 0 10px 6px; }

/* ------------------------------------------------------------- charts */
.chart { overflow: visible; }
.ch-grid { stroke: var(--line); stroke-width: 1; }
.ch-grid-x { stroke-dasharray: 2 4; }
.ch-frame { fill: none; stroke: var(--line-strong); stroke-width: 1; }
.ch-tick { fill: var(--ink-3); font-size: 10px; font-family: var(--sans); font-variant-numeric: tabular-nums; }
.ch-axis { fill: var(--ink-3); font-size: 11px; font-family: var(--sans); }
.ch-title { fill: var(--ink-2); font-size: 11px; font-weight: 600; font-family: var(--sans); }
.ch-unit { fill: var(--ink-3); font-weight: 400; }
.ch-empty { fill: var(--ink-3); font-size: 12px; font-family: var(--sans); }
.ch-band { fill: color-mix(in srgb, var(--accent) 12%, transparent); stroke: none; }
.ch-diag { stroke: var(--ink-3); stroke-width: 1; stroke-dasharray: 4 3; }
.ch-ref { stroke: var(--ink-3); stroke-width: 1; stroke-dasharray: 3 3; opacity: .7; }
.ch-reflabel { fill: var(--ink-3); font-size: 9.5px; font-family: var(--sans); }
.ch-dot { fill: var(--surface); stroke-width: 2; }
.ch-dot.in-tol { stroke: var(--accent); fill: color-mix(in srgb, var(--accent) 65%, var(--surface)); }
.ch-dot.out-tol { stroke: var(--bad); fill: color-mix(in srgb, var(--bad) 55%, var(--surface)); }
.ch-dot.plugin { stroke-dasharray: 3 2; }
.ch-leader { stroke: var(--line-strong); stroke-width: 1; }
.ch-plabel { fill: var(--ink-2); font-size: 10.5px; font-family: var(--mono); }
.ch-plabel.plugin { fill: var(--warn); }
.ch-point:hover .ch-dot { r: 7; }
.ch-endlabel.is-cluster { font-style: italic; }
.ch-endlabel { font-size: 9.5px; font-family: var(--sans); font-variant-numeric: tabular-nums; }

.ch-line { stroke-width: 1.7; fill: none; stroke-linejoin: round; stroke-linecap: round; }
.ch-line.src-cluster { stroke-dasharray: 6 4; }
.s-n, .ch-line.s-n { stroke: var(--s-n); } text.s-n, .ch-endlabel.s-n { fill: var(--s-n); stroke: none; }
.s-nactive, .ch-line.s-nactive { stroke: var(--s-nactive); } .ch-endlabel.s-nactive { fill: var(--s-nactive); stroke: none; }
.s-queue, .ch-line.s-queue { stroke: var(--s-queue); } .ch-endlabel.s-queue { fill: var(--s-queue); stroke: none; }
.s-arrivals, .ch-line.s-arrivals { stroke: var(--s-arrivals); } .ch-endlabel.s-arrivals { fill: var(--s-arrivals); stroke: none; }
.s-served, .ch-line.s-served { stroke: var(--s-served); } .ch-endlabel.s-served { fill: var(--s-served); stroke: none; }
.s-att, .ch-line.s-att { stroke: var(--s-att); } .ch-endlabel.s-att { fill: var(--s-att); stroke: none; }
.s-plain, .ch-line.s-plain { stroke: var(--s-plain); }
.ch-mark { opacity: .85; }
.ch-mark.up { fill: var(--good); }
.ch-mark.down { fill: var(--bad); }
.ch-mark.src-cluster { opacity: .6; }

/* ------------------------------------------------------------- tooltips */
.gl {
  display: inline-flex; align-items: center; justify-content: center;
  width: 14px; height: 14px; border-radius: 50%; margin-left: 4px; cursor: help;
  font-size: 9.5px; font-weight: 700; font-family: var(--sans);
  background: var(--surface-2); color: var(--ink-3); border: 1px solid var(--line-strong);
  vertical-align: middle; text-transform: none; letter-spacing: 0;
}
.gl-word { font-family: var(--mono); font-size: .95em; }
.gl:hover, .gl:focus { background: var(--accent); color: #fff; border-color: var(--accent); }
.tip {
  position: fixed; z-index: 60; background: var(--surface); color: var(--ink);
  border: 1px solid var(--line-strong); border-radius: 8px; box-shadow: var(--shadow);
  padding: 10px 12px; font-size: 12.5px; line-height: 1.5; pointer-events: auto;
}
.tip b { display: block; margin-bottom: 4px; font-size: 12px; }
.tip span { color: var(--ink-2); }

/* ------------------------------------------------------------- states */
.loading { display: flex; align-items: center; gap: 9px; color: var(--ink-3); font-size: 13px; padding: 14px 2px; }
.spinner {
  width: 13px; height: 13px; border-radius: 50%;
  border: 2px solid var(--line-strong); border-top-color: var(--accent);
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  .spinner { animation-duration: 3s; }
  .prog-fill { transition: none; }
  * { scroll-behavior: auto !important; }
}
.status:not(:empty) { margin-bottom: 14px; }

.rows-list { display: flex; flex-direction: column; gap: 8px; }
.row-item { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 12px;
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface-2); }
.row-item-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.row-item-main b { font-family: var(--mono); }
.btn-remove { flex: none; }

.fam-body { display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(300px, 1fr); gap: 16px; align-items: start; }
.fam-chart { margin: 0; display: flex; flex-direction: column; gap: 6px; }
.fam-chart .chart { width: 100%; height: auto; }
.fam-chart figcaption { font-size: 11.5px; color: var(--ink-3); }
.ch-ref { stroke: var(--good); stroke-width: 1.5; stroke-dasharray: 5 3; }
.ch-ref-label { fill: var(--good); font-size: 10px; font-family: var(--sans); }
.ch-front { fill: none; stroke: var(--accent); stroke-width: 1.2; opacity: .35; }
.ch-fdot { stroke-width: 2; fill: var(--surface); stroke: var(--ink-3); }
.ch-fdot.meets { stroke: var(--good); }
.ch-fdot.front { fill: color-mix(in srgb, var(--accent) 70%, var(--surface)); stroke: var(--accent); }
.ch-fdot.front.meets { stroke: var(--good); }
.ch-fdot.hl { stroke-width: 3; }
.ch-fdot.plugin { stroke-dasharray: 3 2; }
@media (max-width: 1100px) { .fam-body { grid-template-columns: 1fr; } }

.row-filter { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 4px 0 14px; }
.rf-label { font-size: 11.5px; color: var(--ink-3); text-transform: uppercase; letter-spacing: .06em; margin-right: 4px; }
.rf-sep { width: 1px; height: 18px; background: var(--line-strong); margin: 0 4px; }
.chip { font: inherit; font-size: 12.5px; font-family: var(--mono); padding: 3px 10px; border-radius: 999px;
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink-2); cursor: pointer; }
.chip:hover { border-color: var(--accent); color: var(--ink); }
.chip.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.chip.chip-plugin:not(.on) { border-style: dashed; }
.chip.chip-ghost { font-family: var(--sans); border-color: transparent; color: var(--accent); }
.chip.chip-ghost:disabled { color: var(--ink-3); cursor: default; }

.fam-legend { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 11.5px; color: var(--ink-3); }
.fam-legend span { display: inline-flex; align-items: center; gap: 5px; }
.lg { display: inline-block; width: 11px; height: 11px; border-radius: 50%; border: 2px solid var(--ink-3); background: var(--surface); }
.lg-front { background: color-mix(in srgb, var(--accent) 70%, var(--surface)); border-color: var(--accent); }
.lg-meets { border-color: var(--good); }
.lg-misses { border-color: var(--ink-3); }
.lg-plugin { border-style: dashed; }
.lg-note { flex-basis: 100%; }
.ch-fdot:not(.front) { opacity: .75; }

table.grid tbody tr.peer-hl { background: var(--accent-soft); box-shadow: inset 3px 0 0 var(--accent); }
.ch-point { cursor: pointer; outline: none; }
.ch-point.peer-hl .ch-fdot, .ch-point:focus .ch-fdot { stroke-width: 3.5; r: 8; opacity: 1; }
.ch-point.peer-hl .ch-plabel, .ch-point:focus .ch-plabel { font-weight: 700; fill: var(--ink); }

/* ------------------------------------------------------------------ home */
:root { --brand: #1e3a8a; --brand-2: #2563eb; --gold: #fbbf24; --hero-ink: #ffffff; }
@media (prefers-color-scheme: dark) { :root { --brand: #16264f; --brand-2: #1d3f94; } }

.topbar:has(#tab-home.active) .card-picker, .topbar:has(#tab-home.active) .card-meta { display: none; }
main.is-home { max-width: none; padding: 0; }

.hero { background: var(--brand-2); color: var(--hero-ink); padding: 56px 20px; }
.hero-inner {
  max-width: 1200px; margin: 0 auto; display: grid; gap: 40px; align-items: center;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr);
}
.hero h1 { font-size: clamp(28px, 4vw, 44px); line-height: 1.15; margin: 0 0 16px; font-weight: 700; letter-spacing: -0.01em; }
.hero-sub { font-size: 18px; line-height: 1.55; margin: 0 0 24px; color: rgba(255,255,255,.9); max-width: 34em; }
.hero-actions { display: flex; gap: 12px; flex-wrap: wrap; }
.btn {
  display: inline-flex; align-items: center; padding: 11px 20px; border-radius: 8px; font-weight: 600;
  text-decoration: none; font-size: 15px; border: 2px solid transparent;
}
.btn-primary { background: var(--gold); color: #1f2937; }
.btn-primary:hover { background: #f59e0b; }
.btn-ghost { color: #fff; border-color: rgba(255,255,255,.55); }
.btn-ghost:hover { background: rgba(255,255,255,.12); }
.btn:focus-visible { outline: 3px solid #fff; outline-offset: 2px; }

.hero-card { background: var(--surface); color: var(--ink); border-radius: 12px; padding: 22px 24px; box-shadow: 0 12px 36px rgba(0,0,0,.22); }
.hero-card h2 { margin: 0 0 12px; font-size: 15px; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-3); }
.podium { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.podium-row { display: grid; grid-template-columns: 34px minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 10px 12px; border-radius: 8px; background: var(--surface-2); border: 1px solid var(--line); }
.podium-name { font-family: var(--mono); font-weight: 600; font-size: 15px; }
.podium-num { color: var(--ink-2); font-size: 13px; font-variant-numeric: tabular-nums; }
.medal { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: 14px; color: #1f2937; }
.medal-gold { background: var(--gold); }
.medal-silver { background: #cbd5e1; }
.medal-bronze { background: #d99a5b; }
.hero-card-note { margin: 12px 0 0; color: var(--ink-3); font-size: 13px; }
.hero-verdict { margin: 12px 0 0; padding-top: 12px; border-top: 1px solid var(--line); font-size: 14px; }
.verdict-agree { color: var(--good); } .verdict-insufficient { color: var(--warn); } .verdict-disagree { color: var(--bad); }
.muted { color: var(--ink-3); }

.home-section { max-width: 1200px; margin: 0 auto; padding: 48px 20px 8px; }
.home-section h2 { font-size: 26px; margin: 0 0 8px; letter-spacing: -0.01em; }
.lede { color: var(--ink-2); font-size: 16px; line-height: 1.6; max-width: 46em; margin: 0 0 24px; }

.loop-steps { list-style: none; margin: 0 0 28px; padding: 0; display: grid; gap: 12px; align-items: stretch; grid-template-columns: minmax(0,1fr) auto minmax(0,1fr) auto minmax(0,1fr) auto; }
.loop-step { background: var(--surface); border: 1px solid var(--line); border-top: 4px solid var(--brand-2); border-radius: 10px; padding: 16px 18px; box-shadow: var(--shadow); }
.loop-fix { border-top-color: var(--good); } .loop-falsification { border-top-color: var(--gold); }
.loop-step h3 { margin: 6px 0; font-size: 17px; }
.loop-step p { margin: 0; color: var(--ink-2); font-size: 14px; line-height: 1.55; }
.loop-n { font-family: var(--mono); color: var(--ink-3); font-size: 12px; }
.loop-arrow { align-self: center; font-size: 22px; color: var(--ink-3); }

.cycles { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); }
.cycle { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 16px 18px; }
.cycle-head { display: grid; grid-template-columns: minmax(0,1fr) auto; gap: 4px 10px; align-items: start; margin-bottom: 10px; }
.cycle-head time { grid-column: 1 / -1; font-family: var(--mono); font-size: 12px; color: var(--ink-3); }
.cycle-head h3 { margin: 0; font-size: 16px; line-height: 1.3; }
.cycle-body { margin: 0; display: grid; gap: 8px; }
.cycle-body dt { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-3); }
.cycle-body dd { margin: 2px 0 0; font-size: 14px; line-height: 1.5; color: var(--ink-2); }
.cycle-result dd { color: var(--ink); }
.pill { font-size: 12px; font-weight: 600; padding: 3px 9px; border-radius: 999px; white-space: nowrap; }
.pill-ok { background: var(--good-soft); color: var(--good); }
.pill-warn { background: var(--warn-soft); color: var(--warn); }
.pill-bad { background: var(--bad-soft); color: var(--bad); }

.cost-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.cost-card { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 18px 20px; }
.cost-card h3 { margin: 0; font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-3); }
.cost-big { margin: 8px 0 0; font-size: 34px; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }
.cost-unit { margin: 0 0 10px; color: var(--ink-2); font-size: 14px; }
.cost-detail { margin: 0; color: var(--ink-3); font-size: 13px; line-height: 1.5; }
.cost-ratio { border-color: var(--brand-2); } .cost-ratio .cost-big { color: var(--accent); }

.limits { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); padding-bottom: 48px; }
.limit-group { background: var(--surface); border: 1px solid var(--line); border-left: 4px solid var(--warn); border-radius: 10px; padding: 16px 18px; }
.limit-group h3 { margin: 0 0 8px; font-size: 16px; }
.limit-group ul { margin: 0; padding-left: 18px; display: grid; gap: 8px; }
.limit-group li { font-size: 14px; line-height: 1.5; color: var(--ink-2); }

@media (max-width: 860px) {
  .hero-inner { grid-template-columns: 1fr; }
  .loop-steps { grid-template-columns: 1fr; }
  .loop-arrow { display: none; }
  .podium-row { grid-template-columns: 34px minmax(0, 1fr); }
  .podium-num { grid-column: 2; }
}

/* the header band, as on the home page */
.topbar { background: var(--brand); border-bottom: 0; backdrop-filter: none; color: #fff; }
.topbar .brand { color: #fff; font-size: 18px; }
.topbar .brand-mark { border-color: var(--gold); box-shadow: inset 0 0 0 2px var(--brand); }
.topbar .card-picker-label, .topbar .card-meta { color: rgba(255,255,255,.75); }
.topbar .tabs { background: transparent; border: 0; gap: 4px; }
.topbar .tab { color: rgba(255,255,255,.85); }
.topbar .tab:hover { color: #fff; background: rgba(255,255,255,.12); }
.topbar .tab.active { background: rgba(255,255,255,.18); color: #fff; box-shadow: none; }
