/* TA-Synth Engine UI -- one stylesheet, no build step, no CDN.
 *
 * The colour values are not chosen here; they are the validated house data-viz
 * palette, declared once as tokens so a chart and a badge in the same view
 * cannot drift apart. Both modes are SELECTED (the dark column is the same
 * eight hues re-stepped for the dark surface) rather than produced by flipping
 * the light values, because an automatic flip puts series colours outside the
 * dark lightness band and the CVD separation stops holding.
 *
 * Validated with the house validator at the surfaces actually used here:
 *   light #fcfcfb  -> all checks PASS (3 slots sub-3:1 contrast, so every
 *                     chart ships a table-view twin and direct labels: the
 *                     documented relief rule)
 *   dark  #1a1a19  -> all checks PASS
 *
 * This is a regulated-industry tool, so the chrome stays grey and quiet and
 * colour is spent only on data, status and one accent.
 */

/* ---------------------------------------------------------------- tokens */

:root {
  color-scheme: light;

  --surface-1: #fcfcfb;          /* cards, chart surface */
  --surface-2: #f3f3f0;          /* inset wells, table stripes */
  --plane: #f9f9f7;              /* page */
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --ink-3: #898781;
  --grid: #e1e0d9;
  --axis: #c3c2b7;
  --hairline: rgba(11, 11, 11, 0.10);
  --hairline-strong: rgba(11, 11, 11, 0.18);
  --shadow: 0 1px 2px rgba(11, 11, 11, 0.04), 0 8px 24px rgba(11, 11, 11, 0.05);
  --shadow-lift: 0 2px 6px rgba(11, 11, 11, 0.07), 0 16px 40px rgba(11, 11, 11, 0.09);

  --series-1: #2a78d6;
  --series-2: #eb6834;
  --series-3: #1baf7a;
  --series-4: #eda100;
  --series-5: #e87ba4;
  --series-6: #008300;
  --series-7: #4a3aa7;
  --series-8: #e34948;

  --accent: #2a78d6;
  --accent-ink: #ffffff;
  --accent-wash: rgba(42, 120, 214, 0.08);
  --accent-wash-2: rgba(42, 120, 214, 0.16);

  /* Status is reserved: good / warning / serious / critical. Never a series. */
  --good: #0ca30c;
  --good-text: #006300;
  --warning: #fab219;
  --serious: #ec835a;
  --critical: #d03b3b;
  --critical-text: #a62626;
  --good-wash: rgba(12, 163, 12, 0.10);
  --critical-wash: rgba(208, 59, 59, 0.10);
  --warning-wash: rgba(250, 178, 25, 0.14);

  --seal: #6b5b2e;
  --seal-wash: rgba(250, 178, 25, 0.10);
  --seal-rule: rgba(107, 91, 46, 0.35);

  --r-sm: 4px;
  --r-md: 8px;
  --r-lg: 12px;
  --sans: system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: ui-monospace, "Cascadia Mono", "Consolas", "SFMono-Regular", monospace;
  --header-h: 58px;
}

@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --surface-1: #1a1a19;
    --surface-2: #232321;
    --plane: #0d0d0d;
    --ink: #ffffff;
    --ink-2: #c3c2b7;
    --ink-3: #898781;
    --grid: #2c2c2a;
    --axis: #383835;
    --hairline: rgba(255, 255, 255, 0.10);
    --hairline-strong: rgba(255, 255, 255, 0.20);
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 8px 24px rgba(0, 0, 0, 0.4);
    --shadow-lift: 0 2px 6px rgba(0, 0, 0, 0.5), 0 16px 40px rgba(0, 0, 0, 0.55);
    --series-1: #3987e5;
    --series-2: #d95926;
    --series-3: #199e70;
    --series-4: #c98500;
    --series-5: #d55181;
    --series-6: #008300;
    --series-7: #9085e9;
    --series-8: #e66767;
    --accent: #3987e5;
    --accent-wash: rgba(57, 135, 229, 0.14);
    --accent-wash-2: rgba(57, 135, 229, 0.26);
    --good-text: #0ca30c;
    --critical-text: #e66767;
    --good-wash: rgba(12, 163, 12, 0.16);
    --critical-wash: rgba(208, 59, 59, 0.20);
    --warning-wash: rgba(250, 178, 25, 0.16);
    --seal: #e8cf8a;
    --seal-wash: rgba(250, 178, 25, 0.07);
    --seal-rule: rgba(232, 207, 138, 0.35);
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --surface-1: #1a1a19;
  --surface-2: #232321;
  --plane: #0d0d0d;
  --ink: #ffffff;
  --ink-2: #c3c2b7;
  --ink-3: #898781;
  --grid: #2c2c2a;
  --axis: #383835;
  --hairline: rgba(255, 255, 255, 0.10);
  --hairline-strong: rgba(255, 255, 255, 0.20);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 8px 24px rgba(0, 0, 0, 0.4);
  --shadow-lift: 0 2px 6px rgba(0, 0, 0, 0.5), 0 16px 40px rgba(0, 0, 0, 0.55);
  --series-1: #3987e5;
  --series-2: #d95926;
  --series-3: #199e70;
  --series-4: #c98500;
  --series-5: #d55181;
  --series-6: #008300;
  --series-7: #9085e9;
  --series-8: #e66767;
  --accent: #3987e5;
  --accent-wash: rgba(57, 135, 229, 0.14);
  --accent-wash-2: rgba(57, 135, 229, 0.26);
  --good-text: #0ca30c;
  --critical-text: #e66767;
  --good-wash: rgba(12, 163, 12, 0.16);
  --critical-wash: rgba(208, 59, 59, 0.20);
  --warning-wash: rgba(250, 178, 25, 0.16);
  --seal: #e8cf8a;
  --seal-wash: rgba(250, 178, 25, 0.07);
  --seal-rule: rgba(232, 207, 138, 0.35);
}

/* ---------------------------------------------------------------- reset */

*, *::before, *::after { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--plane);
  color: var(--ink);
  font: 400 14px/1.55 var(--sans);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, h4 { margin: 0; font-weight: 600; letter-spacing: -0.01em; }
h1 { font-size: 26px; line-height: 1.2; letter-spacing: -0.02em; }
h2 { font-size: 18px; line-height: 1.3; }
h3 { font-size: 15px; line-height: 1.35; }
h4 { font-size: 12px; line-height: 1.3; text-transform: uppercase;
     letter-spacing: 0.08em; color: var(--ink-3); font-weight: 600; }
p { margin: 0; }
a { color: var(--accent); }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--r-sm);
}

.skip-link {
  position: absolute; left: 12px; top: -48px; z-index: 100;
  padding: 8px 14px; background: var(--surface-1); color: var(--ink);
  border: 1px solid var(--hairline-strong); border-radius: var(--r-md);
  transition: top .12s ease;
}
.skip-link:focus { top: 10px; }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ---------------------------------------------------------------- shell */

.app {
  min-height: 100%;
  display: grid;
  grid-template-rows: var(--header-h) 1fr auto;
}

.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 24px;
  padding: 0 24px;
  background: color-mix(in srgb, var(--surface-1) 92%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--hairline);
}

.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-mark {
  width: 26px; height: 26px; flex: 0 0 auto; display: block;
}
.brand-text { display: flex; flex-direction: column; min-width: 0; }
.brand-name {
  font-size: 13px; font-weight: 650; letter-spacing: -0.01em;
  white-space: nowrap;
}
.brand-sub {
  font-size: 11px; color: var(--ink-3); white-space: nowrap;
  letter-spacing: 0.01em;
}

.tabs { display: flex; gap: 2px; margin-left: 8px; }
.tab {
  appearance: none; border: 0; background: none; cursor: pointer;
  font: inherit; font-size: 13px; font-weight: 500; color: var(--ink-2);
  padding: 7px 13px; border-radius: var(--r-md);
  display: inline-flex; align-items: center; gap: 7px;
  white-space: nowrap;
}
.tab:hover { background: var(--surface-2); color: var(--ink); }
.tab[aria-selected="true"] {
  background: var(--accent-wash); color: var(--accent); font-weight: 600;
}
.tab .tab-n {
  font-size: 10px; font-weight: 700; min-width: 16px; height: 16px;
  display: inline-grid; place-items: center; border-radius: 8px;
  background: var(--surface-2); color: var(--ink-3);
  font-variant-numeric: tabular-nums;
}
.tab[aria-selected="true"] .tab-n { background: var(--accent-wash-2); color: var(--accent); }
.tab[disabled] { opacity: .4; cursor: not-allowed; }

.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }

.chip {
  font-size: 11px; color: var(--ink-3); padding: 3px 9px;
  border: 1px solid var(--hairline); border-radius: 999px;
  white-space: nowrap; font-variant-numeric: tabular-nums;
}

.icon-btn {
  appearance: none; width: 32px; height: 32px; display: grid; place-items: center;
  border: 1px solid var(--hairline); border-radius: var(--r-md);
  background: var(--surface-1); color: var(--ink-2); cursor: pointer;
}
.icon-btn:hover { background: var(--surface-2); color: var(--ink); }

main { padding: 28px 24px 56px; }
.view { display: none; max-width: 1360px; margin: 0 auto; }
.view.is-active { display: block; }

.page-head { margin-bottom: 22px; max-width: 760px; }
.page-head .eyebrow {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.1em;
  color: var(--ink-3); font-weight: 600; margin-bottom: 8px;
}
.page-head .lede { margin-top: 9px; color: var(--ink-2); font-size: 14px; max-width: 70ch; }

.footer {
  border-top: 1px solid var(--hairline);
  background: var(--surface-1);
  padding: 16px 24px;
  font-size: 12px; color: var(--ink-3);
}
.footer-inner {
  max-width: 1360px; margin: 0 auto;
  display: flex; flex-wrap: wrap; gap: 8px 22px; align-items: baseline;
}
.footer strong { color: var(--ink-2); font-weight: 650; letter-spacing: 0.04em; }
.footer .footer-note { max-width: 72ch; }

/* ---------------------------------------------------------------- cards */

.card {
  background: var(--surface-1);
  border: 1px solid var(--hairline);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow);
}
.card-head {
  display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap;
  padding: 16px 18px; border-bottom: 1px solid var(--hairline);
}
.card-head .sub { font-size: 12px; color: var(--ink-3); }
.card-head .spacer { margin-left: auto; }
.card-body { padding: 18px; }
.card-body.tight { padding: 12px; }

.stat-row {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 1px; background: var(--hairline);
  border: 1px solid var(--hairline); border-radius: var(--r-lg);
  overflow: hidden; margin-bottom: 20px;
}
.stat {
  background: var(--surface-1); padding: 13px 16px;
}
.stat .k {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.07em;
  color: var(--ink-3); font-weight: 600;
}
.stat .v { font-size: 22px; font-weight: 600; letter-spacing: -0.02em; margin-top: 3px; }
.stat .n { font-size: 11px; color: var(--ink-3); margin-top: 1px; }

/* ---------------------------------------------------------------- controls */

.toolbar {
  display: flex; flex-wrap: wrap; gap: 12px; align-items: center;
  margin-bottom: 18px;
}
.search {
  position: relative; flex: 1 1 260px; max-width: 380px;
}
.search svg {
  position: absolute; left: 10px; top: 50%; transform: translateY(-50%);
  color: var(--ink-3); pointer-events: none;
}
input[type="text"], input[type="number"], input[type="search"], select {
  appearance: none; font: inherit; font-size: 13px;
  color: var(--ink); background: var(--surface-1);
  border: 1px solid var(--hairline-strong); border-radius: var(--r-md);
  padding: 8px 11px; width: 100%;
}
select {
  padding-right: 30px; cursor: pointer;
  /* Caret drawn inline rather than fetched: no CDN, no extra request. */
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M4 6.5l4 4 4-4' fill='none' stroke='%23898781' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 9px center;
  background-size: 14px 14px;
}
.search input { padding-left: 32px; }
input:disabled, select:disabled { opacity: .55; }
input[aria-invalid="true"] { border-color: var(--critical); }

.seg {
  display: inline-flex; padding: 2px; gap: 2px;
  background: var(--surface-2); border-radius: var(--r-md);
  border: 1px solid var(--hairline);
}
.seg button {
  appearance: none; border: 0; background: none; cursor: pointer; font: inherit;
  font-size: 12px; font-weight: 500; color: var(--ink-2);
  padding: 5px 11px; border-radius: 6px; white-space: nowrap;
}
.seg button:hover { color: var(--ink); }
.seg button[aria-pressed="true"] {
  background: var(--surface-1); color: var(--ink); font-weight: 600;
  box-shadow: 0 1px 2px rgba(0, 0, 0, .08);
}
.seg .count { color: var(--ink-3); font-variant-numeric: tabular-nums; }

.btn {
  appearance: none; cursor: pointer; font: inherit; font-size: 13px;
  font-weight: 550; padding: 9px 16px; border-radius: var(--r-md);
  border: 1px solid var(--hairline-strong); background: var(--surface-1);
  color: var(--ink); display: inline-flex; align-items: center; gap: 8px;
  white-space: nowrap;
}
.btn:hover { background: var(--surface-2); }
.btn-primary {
  background: var(--accent); border-color: transparent; color: var(--accent-ink);
}
.btn-primary:hover { filter: brightness(1.06); background: var(--accent); }
.btn-ghost { border-color: transparent; background: none; color: var(--accent); }
.btn-ghost:hover { background: var(--accent-wash); }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.btn-sm { padding: 6px 11px; font-size: 12px; }
.btn-seal {
  border-color: var(--seal-rule); color: var(--seal); background: var(--seal-wash);
}
.btn-seal:hover { background: var(--warning-wash); }

.badge {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11px; font-weight: 600; letter-spacing: 0.02em;
  padding: 3px 8px; border-radius: 999px;
  border: 1px solid var(--hairline); color: var(--ink-2);
  background: var(--surface-2); white-space: nowrap;
}
.badge-engine { text-transform: none; }
.badge-good { color: var(--good-text); background: var(--good-wash); border-color: transparent; }
.badge-bad { color: var(--critical-text); background: var(--critical-wash); border-color: transparent; }
.badge-warn { color: var(--seal); background: var(--warning-wash); border-color: transparent; }
.badge-dot {
  width: 7px; height: 7px; border-radius: 4px; flex: 0 0 auto;
  background: currentColor;
}

.domain-chips { display: flex; flex-wrap: wrap; gap: 4px; }
.domain-chip {
  font: 500 10.5px/1 var(--mono); letter-spacing: 0.03em;
  padding: 4px 6px; border-radius: var(--r-sm);
  background: var(--surface-2); color: var(--ink-2);
}
.domain-chip.is-extra { background: var(--accent-wash); color: var(--accent); }

/* ---------------------------------------------------------------- catalogue */

.ta-grid {
  display: grid; gap: 14px;
  grid-template-columns: repeat(auto-fill, minmax(330px, 1fr));
}
.ta-card {
  display: flex; flex-direction: column; gap: 12px;
  padding: 16px 17px 14px;
  background: var(--surface-1); border: 1px solid var(--hairline);
  border-radius: var(--r-lg); box-shadow: var(--shadow);
  text-align: left; position: relative;
}
.ta-card:hover { box-shadow: var(--shadow-lift); border-color: var(--hairline-strong); }
.ta-card:focus-within { border-color: var(--accent); }
.ta-card-top { display: flex; align-items: flex-start; gap: 10px; }
.ta-card h3 { flex: 1 1 auto; }
.ta-card .indication {
  font-size: 12.5px; color: var(--ink-2); margin-top: 3px;
}
.ta-card .endpoint {
  font-size: 13px; color: var(--ink); padding: 10px 12px;
  background: var(--surface-2); border-radius: var(--r-md);
  border-left: 2px solid var(--series-1);
}
.ta-card .endpoint .k {
  display: block; font-size: 10px; text-transform: uppercase;
  letter-spacing: 0.08em; color: var(--ink-3); font-weight: 600;
  margin-bottom: 3px;
}
.ta-meta {
  display: grid; grid-template-columns: 1fr 1fr; gap: 10px 14px;
}
.ta-meta .k {
  font-size: 10px; text-transform: uppercase; letter-spacing: 0.07em;
  color: var(--ink-3); font-weight: 600;
}
.ta-meta .v {
  font-size: 13px; font-weight: 550; font-variant-numeric: tabular-nums;
  margin-top: 1px;
}
.ta-meta .u { font-size: 11px; color: var(--ink-3); font-weight: 400; }
.ta-card-foot {
  margin-top: auto; padding-top: 10px; border-top: 1px solid var(--hairline);
  display: flex; align-items: center; gap: 10px;
}
.ta-card-foot .btn { margin-left: auto; }

/* ---------------------------------------------------------------- configure */

.cfg-grid {
  display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(300px, 0.85fr);
  gap: 20px; align-items: start;
}
.cfg-aside { position: sticky; top: calc(var(--header-h) + 20px); }

fieldset {
  border: 0; margin: 0; padding: 0 0 20px;
}
fieldset + fieldset { border-top: 1px solid var(--hairline); padding-top: 18px; }
fieldset:last-of-type { padding-bottom: 0; }
legend { padding: 0; margin-bottom: 4px; }
.fieldset-note { font-size: 12px; color: var(--ink-3); margin-bottom: 14px; max-width: 64ch; }

.field-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 14px 16px;
}
.field { min-width: 0; }
.field label {
  display: block; font-size: 12px; font-weight: 600; color: var(--ink-2);
  margin-bottom: 5px;
}
.field .hint { font-size: 11.5px; color: var(--ink-3); margin-top: 5px; }
.field .err { font-size: 11.5px; color: var(--critical-text); margin-top: 5px; display: none; }
.field.is-bad .err { display: block; }
.field.is-bad .hint { display: none; }
.field-wide { grid-column: 1 / -1; }

.input-unit { display: flex; align-items: stretch; }
.input-unit input { border-radius: var(--r-md) 0 0 var(--r-md); }
.input-unit .unit {
  display: grid; place-items: center; padding: 0 10px;
  font-size: 12px; color: var(--ink-2); background: var(--surface-2);
  border: 1px solid var(--hairline-strong); border-left: 0;
  border-radius: 0 var(--r-md) var(--r-md) 0; white-space: nowrap;
}
.input-row { display: flex; gap: 8px; align-items: center; }
.input-row input[type="range"] { flex: 1 1 auto; width: auto; accent-color: var(--accent); }
.input-row .num { width: 84px; flex: 0 0 auto; }

.radio-row { display: flex; gap: 10px; flex-wrap: wrap; }
.radio-card {
  flex: 1 1 200px; display: flex; gap: 10px; align-items: flex-start;
  padding: 11px 13px; border: 1px solid var(--hairline-strong);
  border-radius: var(--r-md); cursor: pointer; background: var(--surface-1);
}
.radio-card:hover { background: var(--surface-2); }
.radio-card input { margin: 2px 0 0; accent-color: var(--accent); }
.radio-card:has(input:checked) {
  border-color: var(--accent); background: var(--accent-wash);
}
.radio-card .t { font-size: 13px; font-weight: 600; }
.radio-card .d { font-size: 11.5px; color: var(--ink-2); margin-top: 2px; }

.defect-list { display: grid; gap: 8px; margin-top: 4px; }
.defect-group h4 { margin: 12px 0 7px; }
.defect {
  display: grid; grid-template-columns: auto 1fr auto; gap: 10px;
  align-items: start; padding: 9px 11px; border-radius: var(--r-md);
  border: 1px solid var(--hairline); background: var(--surface-1);
  cursor: pointer;
}
.defect:hover { background: var(--surface-2); }
.defect:has(input:checked) { border-color: var(--accent); background: var(--accent-wash); }
.defect input { margin: 2px 0 0; accent-color: var(--accent); }
.defect .t { font-size: 12.5px; font-weight: 600; }
.defect .d { font-size: 11.5px; color: var(--ink-2); margin-top: 2px; }
.defect .id { font: 500 10px/1.4 var(--mono); color: var(--ink-3); margin-top: 4px; }
.defect[aria-disabled="true"] { opacity: .5; }

.kv { display: grid; grid-template-columns: auto 1fr; gap: 7px 14px; font-size: 12.5px; }
.kv dt { color: var(--ink-3); }
.kv dd { margin: 0; font-weight: 550; font-variant-numeric: tabular-nums;
         overflow-wrap: anywhere; }

.power {
  display: grid; gap: 12px;
}
.power-figure {
  font-size: 30px; font-weight: 600; letter-spacing: -0.025em; line-height: 1;
}
.power-figure .pm { font-size: 18px; color: var(--ink-3); font-weight: 500; }
.power-note { font-size: 11.5px; color: var(--ink-3); }

.form-errors {
  display: none; margin-top: 14px; padding: 11px 13px;
  border-radius: var(--r-md); background: var(--critical-wash);
  color: var(--critical-text); font-size: 12.5px;
}
.form-errors.is-on { display: block; }
.form-errors ul { margin: 6px 0 0; padding-left: 18px; }

/* ---------------------------------------------------------------- verdict */

.verdict {
  border-radius: var(--r-lg); border: 1px solid var(--hairline);
  background: var(--surface-1); box-shadow: var(--shadow);
  overflow: hidden; margin-bottom: 20px;
}
.verdict-top {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  padding: 13px 20px; border-bottom: 1px solid var(--hairline);
  background: var(--surface-2);
}
.verdict-top .ttl { font-size: 12px; font-weight: 650; letter-spacing: 0.06em;
                    text-transform: uppercase; color: var(--ink-3); }
.verdict-top .spacer { margin-left: auto; }
.verdict-body {
  display: grid; grid-template-columns: minmax(280px, 0.9fr) minmax(320px, 1.1fr);
  gap: 0;
}
.verdict-numbers {
  padding: 22px 24px; display: grid; gap: 20px; align-content: start;
  border-right: 1px solid var(--hairline);
}
.verdict-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.vnum .k {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em;
  font-weight: 650; color: var(--ink-3); display: flex; align-items: center; gap: 6px;
}
.vnum .v {
  font-size: 40px; font-weight: 600; letter-spacing: -0.03em; line-height: 1.05;
  margin-top: 4px;
}
.vnum .ci {
  font-size: 12.5px; color: var(--ink-2); margin-top: 5px;
  font-variant-numeric: tabular-nums;
}
.verdict-call { padding: 22px 24px; display: grid; gap: 14px; align-content: start; }
.call-badge {
  display: inline-flex; align-items: center; gap: 9px;
  align-self: start; justify-self: start;
  font-size: 15px; font-weight: 700; letter-spacing: 0.01em;
  padding: 9px 15px; border-radius: 999px;
}
.call-badge.is-good { background: var(--good-wash); color: var(--good-text); }
.call-badge.is-bad { background: var(--critical-wash); color: var(--critical-text); }
.call-badge.is-warn { background: var(--warning-wash); color: var(--seal); }
.call-why { font-size: 12.5px; color: var(--ink-2); max-width: 54ch; }
.verdict-foot {
  padding: 11px 20px; border-top: 1px solid var(--hairline);
  font-size: 11.5px; color: var(--ink-3);
  display: flex; gap: 8px 20px; flex-wrap: wrap;
}

/* ---------------------------------------------------------------- progress */

.steps { display: grid; gap: 2px; }
.step {
  display: grid; grid-template-columns: 20px 1fr auto; gap: 11px;
  align-items: center; padding: 8px 10px; border-radius: var(--r-md);
  font-size: 13px;
}
.step .dot {
  width: 16px; height: 16px; border-radius: 9px; display: grid; place-items: center;
  border: 1.5px solid var(--axis); color: var(--surface-1);
}
.step .nm { font-weight: 500; }
.step .nt { font-size: 11.5px; color: var(--ink-3); margin-top: 1px; }
.step .ms { font-size: 11.5px; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.step.is-active { background: var(--accent-wash); }
.step.is-active .dot { border-color: var(--accent); animation: pulse 1.1s ease-in-out infinite; }
.step.is-active .nm { color: var(--accent); font-weight: 600; }
.step.is-done .dot { background: var(--good); border-color: var(--good); }
.step.is-skipped { opacity: .55; }
.step.is-error .dot { background: var(--critical); border-color: var(--critical); }
.step.is-pending { opacity: .6; }
.step-bar {
  grid-column: 2 / -1; height: 3px; border-radius: 2px; background: var(--grid);
  overflow: hidden; margin-top: 6px;
}
.step-bar i { display: block; height: 100%; background: var(--accent); border-radius: 2px;
              transition: width .2s linear; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }

.progress-total {
  height: 4px; border-radius: 2px; background: var(--grid); overflow: hidden;
  margin-top: 14px;
}
.progress-total i { display: block; height: 100%; background: var(--accent);
                    transition: width .25s ease; }

/* ---------------------------------------------------------------- charts */

.chart-wrap { position: relative; }
.chart { display: block; width: 100%; height: auto; overflow: visible; }
.chart text { font-family: var(--sans); fill: var(--ink-3); }
.chart .tick-label { font-size: 11px; fill: var(--ink-3); }
.chart .axis-title { font-size: 11.5px; fill: var(--ink-2); font-weight: 500; }
.chart .grid-line { stroke: var(--grid); stroke-width: 1; }
.chart .axis-line { stroke: var(--axis); stroke-width: 1; }
.chart .ref-line { stroke: var(--ink); stroke-width: 1.5; }
.chart .null-line { stroke: var(--axis); stroke-width: 1; }
.chart .series-line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .marker { stroke: var(--surface-1); stroke-width: 2; }
.chart .value-label { font-size: 11px; fill: var(--ink); font-weight: 600;
                      font-variant-numeric: tabular-nums; }
/* A label that sits over a reference line gets a surface halo rather than being
   nudged off its mark -- same idea as the 2px surface ring on a marker. */
.chart .halo { paint-order: stroke; stroke: var(--surface-1); stroke-width: 3.5px;
               stroke-linejoin: round; }
.chart .mark-label { font-size: 11px; fill: var(--ink-2); }
.chart .crosshair { stroke: var(--ink-3); stroke-width: 1; pointer-events: none; }
.chart .hit { fill: transparent; cursor: crosshair; }
.chart .bar-hit { fill: transparent; cursor: pointer; }
.chart .bar:hover, .chart .bar.is-hot { filter: brightness(1.12); }

.legend {
  display: flex; flex-wrap: wrap; gap: 6px 18px; margin: 0 0 10px;
  font-size: 12px; color: var(--ink-2);
}
.legend-item { display: inline-flex; align-items: center; gap: 7px; }
.legend-key { width: 14px; height: 3px; border-radius: 2px; flex: 0 0 auto; }
.legend-key.is-rect { height: 10px; width: 10px; border-radius: 2px; }
.legend-item .n { color: var(--ink-3); font-variant-numeric: tabular-nums; }

.tooltip {
  position: absolute; z-index: 20; pointer-events: none; min-width: 150px;
  padding: 9px 11px; border-radius: var(--r-md);
  background: var(--surface-1); border: 1px solid var(--hairline-strong);
  box-shadow: var(--shadow-lift); font-size: 12px;
  opacity: 0; transition: opacity .1s ease;
}
.tooltip.is-on { opacity: 1; }
.tooltip .tt-head {
  font-size: 11px; color: var(--ink-3); font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 6px;
}
.tt-row { display: grid; grid-template-columns: 14px 1fr auto; gap: 8px;
          align-items: baseline; }
.tt-row + .tt-row { margin-top: 4px; }
.tt-key { width: 14px; height: 3px; border-radius: 2px; margin-top: 6px; }
.tt-name { color: var(--ink-2); }
.tt-val { font-weight: 650; color: var(--ink); font-variant-numeric: tabular-nums; }
.tt-note { font-size: 11px; color: var(--ink-3); margin-top: 6px;
           padding-top: 5px; border-top: 1px solid var(--hairline); }

/* Numbers at risk. Fixed layout with equal data columns so the counts spread
   under the axis they belong to instead of bunching at the right-hand edge --
   the figure's own time grid is evenly spaced, so equal columns track it. */
.risk-table { margin-top: 10px; font-size: 11.5px; }
.risk-table table { width: 100%; border-collapse: collapse; table-layout: fixed; }
.risk-table th, .risk-table td {
  text-align: center; padding: 3px 6px; font-variant-numeric: tabular-nums;
  color: var(--ink-2);
}
.risk-table th:first-child, .risk-table td:first-child {
  text-align: left; width: 34%; white-space: nowrap; overflow: hidden;
  text-overflow: ellipsis;
}
.risk-table thead th { color: var(--ink-3); font-weight: 600;
                       border-bottom: 1px solid var(--hairline); }
.risk-table caption { text-align: left; color: var(--ink-3); font-size: 11px;
                      padding-bottom: 4px; }

/* ---------------------------------------------------------------- tables */

.table-scroll {
  max-height: 440px; overflow: auto; border: 1px solid var(--hairline);
  border-radius: var(--r-md); background: var(--surface-1);
}
.grid-table {
  border-collapse: separate; border-spacing: 0; width: max-content; min-width: 100%;
  font-size: 12px;
}
.grid-table th, .grid-table td {
  padding: 6px 10px; text-align: left; white-space: nowrap;
  border-bottom: 1px solid var(--hairline);
}
.grid-table thead th {
  position: sticky; top: 0; z-index: 2;
  background: var(--surface-2); color: var(--ink-2);
  font: 600 10.5px/1.5 var(--mono); letter-spacing: 0.03em;
  text-transform: uppercase;
  border-bottom: 1px solid var(--hairline-strong);
}
.grid-table tbody tr:hover td { background: var(--surface-2); }
.grid-table td.num { text-align: right; font-variant-numeric: tabular-nums; }
.grid-table td.rownum {
  position: sticky; left: 0; background: var(--surface-1); color: var(--ink-3);
  font-variant-numeric: tabular-nums; text-align: right;
  border-right: 1px solid var(--hairline);
}
.grid-table thead th.rownum { left: 0; z-index: 3; background: var(--surface-2); }
.grid-table tbody tr:hover td.rownum { background: var(--surface-2); }

.data-table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.data-table th, .data-table td {
  text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--hairline);
  vertical-align: top;
}
.data-table thead th {
  font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.07em;
  color: var(--ink-3); font-weight: 650;
}
.data-table td.num { text-align: right; font-variant-numeric: tabular-nums; }
.data-table tbody tr:hover { background: var(--surface-2); }
.data-table code { font: 500 11px/1.4 var(--mono); color: var(--ink-2); }

/* The defect ledger is a wide forensic record, not a summary: let it keep its
   natural column widths inside the scroller rather than squeezing the
   explanation column into a 40-line ribbon. */
.ledger { width: max-content; min-width: 100%; }
.ledger th, .ledger td { white-space: nowrap; }
.ledger td:first-child { white-space: normal; min-width: 260px; max-width: 340px; }
.ledger td:first-child div { white-space: normal; }

/* layer accordion */
.layer {
  border: 1px solid var(--hairline); border-radius: var(--r-md);
  background: var(--surface-1); overflow: hidden;
}
.layer + .layer { margin-top: 8px; }
.layer-head {
  width: 100%; appearance: none; border: 0; background: none; cursor: pointer;
  font: inherit; text-align: left; padding: 12px 14px;
  display: grid; grid-template-columns: 16px 1fr auto auto; gap: 12px;
  align-items: center; list-style: none;
}
.layer-head::-webkit-details-marker, .layer-head::marker { display: none; content: ''; }
details > summary { list-style: none; }
.layer-head:hover { background: var(--surface-2); }
.layer-head .caret { color: var(--ink-3); transition: transform .14s ease; }
.layer[open] .layer-head .caret { transform: rotate(90deg); }
.layer-head .nm { display: block; font-weight: 600; font-size: 13.5px; }
.layer-head .bl { display: block; font-size: 11.5px; color: var(--ink-3); margin-top: 2px; }
.layer-head .rows { font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums; }
.layer-head .ds { font-size: 11.5px; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.layer-body { padding: 0 14px 14px; }
.ds-pills { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.ds-pill {
  appearance: none; cursor: pointer; font: inherit; font-size: 11.5px;
  padding: 5px 9px; border-radius: var(--r-sm);
  border: 1px solid var(--hairline); background: var(--surface-1); color: var(--ink-2);
  display: inline-flex; gap: 7px; align-items: baseline;
}
.ds-pill:hover { background: var(--surface-2); color: var(--ink); }
.ds-pill[aria-pressed="true"] {
  border-color: var(--accent); background: var(--accent-wash); color: var(--accent);
  font-weight: 600;
}
.ds-pill .n { color: var(--ink-3); font-variant-numeric: tabular-nums; font-weight: 400; }
.ds-pill[aria-pressed="true"] .n { color: var(--accent); }

/* ---------------------------------------------------------------- sealed */

.downloads { display: grid; grid-template-columns: minmax(0,1fr) minmax(280px,0.8fr); gap: 16px; }
.download-item { display: grid; gap: 5px; justify-items: start; }
.seal-card {
  border: 1px dashed var(--seal-rule); background: var(--seal-wash);
  border-radius: var(--r-lg); padding: 16px 18px;
  display: grid; gap: 11px; align-content: start;
  position: relative;
}
.seal-card .seal-tag {
  display: inline-flex; align-items: center; gap: 7px;
  align-self: start; justify-self: start;
  font: 700 10px/1 var(--mono); letter-spacing: 0.14em;
  color: var(--seal); border: 1px solid var(--seal-rule);
  padding: 5px 8px; border-radius: var(--r-sm);
}
.seal-card h3 { color: var(--ink); }
.seal-card p { font-size: 12.5px; color: var(--ink-2); max-width: 46ch; }

/* ---------------------------------------------------------------- states */

.empty {
  text-align: center; padding: 56px 24px; color: var(--ink-3);
  border: 1px dashed var(--hairline-strong); border-radius: var(--r-lg);
}
.empty .ttl { font-size: 15px; font-weight: 600; color: var(--ink-2); margin-top: 12px; }
.empty .msg { font-size: 13px; margin-top: 6px; max-width: 46ch; margin-inline: auto; }
.empty .btn { margin-top: 18px; }

.error-box {
  padding: 14px 16px; border-radius: var(--r-md);
  background: var(--critical-wash); color: var(--critical-text);
  font-size: 13px; display: grid; gap: 6px;
}
.error-box .ttl { font-weight: 650; display: flex; align-items: center; gap: 8px; }
.error-box pre {
  margin: 4px 0 0; font: 500 11px/1.5 var(--mono); white-space: pre-wrap;
  color: var(--ink-2); max-height: 200px; overflow: auto;
}

.skeleton {
  background: linear-gradient(90deg, var(--surface-2) 25%,
              var(--grid) 37%, var(--surface-2) 63%);
  background-size: 400% 100%; animation: shimmer 1.4s ease infinite;
  border-radius: var(--r-sm);
}
@keyframes shimmer { 0% { background-position: 100% 0; } 100% { background-position: 0 0; } }

.is-stale { opacity: .45; transition: opacity .15s ease; }

.section { margin-top: 22px; }
.section-head {
  display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap;
  margin-bottom: 11px;
}
.section-head .sub { font-size: 12px; color: var(--ink-3); }
.section-head .spacer { margin-left: auto; }

.inline-note {
  font-size: 12px; color: var(--ink-3); margin-top: 10px;
  display: flex; gap: 7px; align-items: flex-start;
}
.inline-note svg { flex: 0 0 auto; margin-top: 2px; }

.mono { font-family: var(--mono); font-size: 11.5px; letter-spacing: 0.01em; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--ink-3); }

pre.doc {
  margin: 0; font: 500 11px/1.5 var(--mono); white-space: pre;
  overflow: auto; max-height: 420px; color: var(--ink-2);
  background: var(--surface-2); padding: 14px; border-radius: var(--r-md);
}

/* ------------------------------------------------- inline `?` hints */

/* A `?` next to a control. Shares the `.hint` class with the help TEXT under a
   field -- that is the house contract (any .hint with data-step is a jump) --
   so the selector carries the attribute AND the element name to win against
   `.field .hint` and against `.field.is-bad .hint { display:none }`, which
   would otherwise take the button away at the moment it is most wanted. */
button.hint[data-step] {
  appearance: none; cursor: help; font: 700 10px/1 var(--sans);
  width: 15px; height: 15px; padding: 0; margin-left: 5px;
  display: inline-grid; place-items: center; vertical-align: 1px;
  border: 1px solid var(--hairline-strong); border-radius: 999px;
  background: var(--surface-2); color: var(--ink-3);
  flex: 0 0 auto;
}
button.hint[data-step]:hover {
  background: var(--accent-wash); border-color: var(--accent); color: var(--accent);
}
.field.is-bad button.hint[data-step] { display: inline-grid; }
h2 > button.hint[data-step], h4 > button.hint[data-step] { vertical-align: 0; }

/* -------------------------------------------- guided tour + auto-demo */

/* The auto-demo's narration, and its stop button. Fixed to the foot of the
   viewport rather than the header, because the driver.js overlay covers the
   header whenever a header element is the thing being spotlighted. */
.caption {
  appearance: none;
  position: fixed; left: 50%; bottom: 18px; transform: translateX(-50%);
  z-index: 1000000001;                   /* driver's popover is 1000000000 */
  /* `width`, not `max-width`: a shrink-to-fit button wraps at its own
     preferred width and the banner ends up tall and narrow. */
  width: min(920px, calc(100vw - 32px));
  margin: 0; text-align: left; cursor: pointer;
  font: 400 13px/1.55 var(--sans); color: var(--ink);
  background: var(--surface-1); border: 1px solid var(--hairline-strong);
  border-left: 3px solid var(--accent);
  border-radius: var(--r-md); padding: 11px 15px;
  box-shadow: var(--shadow-lift);
}
.caption:hover { background: var(--surface-2); }
.caption[hidden] { display: none; }
/* driver.js kills pointer events on everything but its stage. The escape
   hatch has to survive that or the demo is a trap. */
.driver-active .caption, .driver-active .caption * { pointer-events: auto; }

/* driver.js ships a hard-coded white popover. Re-skin it with the same tokens
   as everything else so the tour does not look bolted on, and so dark mode is
   not a white card in a dark room. */
.driver-popover {
  background-color: var(--surface-1); color: var(--ink);
  border: 1px solid var(--hairline-strong); border-radius: var(--r-lg);
  box-shadow: var(--shadow-lift); padding: 16px 18px;
  min-width: 280px; max-width: 400px;
}
.driver-popover-title { font: 600 15px/1.35 var(--sans); color: var(--ink);
                        letter-spacing: -0.01em; }
.driver-popover-description { font: 400 13px/1.6 var(--sans); color: var(--ink-2); }
.driver-popover-progress-text { font: 500 11px/1 var(--mono); color: var(--ink-3); }
.driver-popover-close-btn { color: var(--ink-3); }
.driver-popover-close-btn:hover, .driver-popover-close-btn:focus { color: var(--ink); }
.driver-popover-footer button {
  font: 550 12px/1.3 var(--sans); text-shadow: none;
  background-color: var(--surface-1); color: var(--ink);
  border: 1px solid var(--hairline-strong); border-radius: var(--r-sm);
  padding: 5px 11px;
}
.driver-popover-footer button:hover, .driver-popover-footer button:focus {
  background-color: var(--surface-2);
}
.driver-popover-navigation-btns button:last-child {
  background-color: var(--accent); border-color: transparent; color: var(--accent-ink);
}
.driver-popover-arrow-side-left { border-left-color: var(--surface-1); }
.driver-popover-arrow-side-right { border-right-color: var(--surface-1); }
.driver-popover-arrow-side-top { border-top-color: var(--surface-1); }
.driver-popover-arrow-side-bottom { border-bottom-color: var(--surface-1); }

/* ---------------------------------------------------------------- help */

.help-launch {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 14px 20px; padding: 16px 18px; margin-bottom: 4px;
  background: var(--surface-1); border: 1px solid var(--hairline);
  border-radius: var(--r-lg); box-shadow: var(--shadow);
}
.help-launch-item { display: grid; gap: 6px; justify-items: start; }
.help-launch-item .muted { font-size: 11.5px; max-width: 44ch; }

.prose { display: grid; gap: 12px; }
.prose p { font-size: 13.5px; line-height: 1.65; color: var(--ink-2); max-width: 76ch; }
.prose strong { color: var(--ink); font-weight: 650; }
.prose em { font-style: italic; }
.prose code, .help-step-body code, .help-term code {
  font: 500 12px/1.4 var(--mono); color: var(--ink);
  background: var(--surface-2); padding: 1px 5px; border-radius: var(--r-sm);
}

/* Explainer beside its own table of contents. Prose is held to a readable
   measure, so without this the right half of a 1360px row is empty. */
.help-two {
  display: grid; grid-template-columns: minmax(0, 660px) minmax(280px, 1fr);
  gap: 16px; align-items: start;
}
.help-aside { position: sticky; top: calc(var(--header-h) + 20px); }
.help-toc { margin: 0; padding: 0 0 0 20px; display: grid; gap: 3px; }
.help-toc li { font-variant-numeric: tabular-nums; color: var(--ink-3); }
.help-toc button {
  appearance: none; border: 0; background: none; padding: 2px 0; margin: 0;
  font: inherit; font-size: 12.5px; color: var(--accent); cursor: pointer;
  text-align: left; line-height: 1.45;
}
.help-toc button:hover { text-decoration: underline; }

.help-step {
  display: grid; grid-template-columns: 34px minmax(0, 1fr) minmax(150px, 190px);
  gap: 14px; padding: 15px 17px; background: var(--surface-1);
  border: 1px solid var(--hairline); border-radius: var(--r-lg);
  box-shadow: var(--shadow);
}
.help-step + .help-step { margin-top: 10px; }
.help-step-meta {
  display: grid; gap: 5px; align-content: start; justify-items: start;
  padding-left: 16px; border-left: 1px solid var(--hairline);
}
.help-step-meta .k {
  font-size: 10px; text-transform: uppercase; letter-spacing: 0.07em;
  color: var(--ink-3); font-weight: 600;
}
.help-step-meta code { font: 500 11px/1.4 var(--mono); color: var(--ink-3);
                       overflow-wrap: anywhere; }
.help-step-meta .btn { margin-top: 10px; }
.help-step-n {
  width: 28px; height: 28px; display: grid; place-items: center;
  border-radius: 999px; background: var(--accent-wash); color: var(--accent);
  font: 650 13px/1 var(--sans); font-variant-numeric: tabular-nums;
}
.help-step-main { min-width: 0; display: grid; gap: 8px; }
.help-step-body { font-size: 13px; line-height: 1.65; color: var(--ink-2); max-width: 82ch; }
.help-step-body strong { color: var(--ink); font-weight: 650; }

/* Arriving from a `?` has to be unmistakable, or the reader lands in the
   middle of a long page with no idea which paragraph answered them. */
.help-step.is-flash { animation: help-flash 1.9s ease-out; }
@keyframes help-flash {
  0%, 22% { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-wash-2); }
  100% { border-color: var(--hairline); box-shadow: var(--shadow); }
}

.help-terms {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(330px, 1fr));
  gap: 2px 26px;
}
.help-term { padding: 12px 0; border-top: 1px solid var(--hairline); }
.help-term:first-child { border-top: 0; }
.help-term h3 { font-size: 13.5px; margin-bottom: 4px; }
.help-term p { font-size: 12.5px; line-height: 1.6; color: var(--ink-2); }
.help-term strong { color: var(--ink); font-weight: 650; }

/* ---------------------------------------------------------------- responsive */

@media (max-width: 1100px) {
  .verdict-body { grid-template-columns: 1fr; }
  .verdict-numbers { border-right: 0; border-bottom: 1px solid var(--hairline); }
  .cfg-grid { grid-template-columns: 1fr; }
  .cfg-aside { position: static; }
  .downloads { grid-template-columns: 1fr; }
}
@media (max-width: 1100px) {
  .help-terms { grid-template-columns: 1fr; }
  .help-two { grid-template-columns: 1fr; }
  .help-aside { position: static; }
  /* The meta column has nowhere to go: put it back under the body. */
  .help-step { grid-template-columns: 34px minmax(0, 1fr); }
  .help-step-meta {
    grid-column: 2; display: flex; align-items: center; flex-wrap: wrap;
    gap: 8px; padding: 9px 0 0; border-left: 0;
    border-top: 1px solid var(--hairline);
  }
  .help-step-meta .btn { margin: 0 0 0 auto; }
}
@media (max-width: 820px) {
  main { padding: 20px 14px 44px; }
  .topbar { padding: 0 14px; gap: 12px; }
  .brand-sub { display: none; }
  .tabs .tab-label { display: none; }
  .vnum .v { font-size: 32px; }
  .verdict-pair { grid-template-columns: 1fr; }
  /* The two launch buttons keep their labels; the header pair drops to icons. */
  #tour-btn span:not(.sr-only), #demo-btn span:not(.sr-only) { display: none; }
  #tour-btn, #demo-btn { padding: 6px 8px; }
  .caption { left: 8px; right: 8px; bottom: 8px; transform: none;
             max-width: none; font-size: 12px; }
}

@media print {
  .topbar, .toolbar, .tabs, .icon-btn, .caption, .help-launch { display: none; }
  .view { display: block !important; }
  .help-step, .card { box-shadow: none; break-inside: avoid; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important;
                           transition-duration: .001ms !important; }
}
