/* Renew — public screener.
   Theme-aware: OS setting via prefers-color-scheme, plus a data-theme override.
   Chart colors are the validated categorical palette (slots 1-5) and the fixed
   status palette; see the dataviz reference. */

:root {
  color-scheme: light;
  --surface-0: #f4f4f2;
  --surface-1: #fcfcfb;
  --surface-2: #eeeeeb;
  --border: #d8d8d3;
  --border-strong: #b9b9b2;
  --text-primary: #0b0b0b;
  --text-secondary: #52514e;
  --text-muted: #6e6d68;

  --series-1: #2a78d6;
  --series-2: #eb6834;
  --series-3: #1baf7a;
  --series-4: #eda100;
  --series-5: #e87ba4;

  --good: #0ca30c;
  --warning: #fab219;
  --serious: #ec835a;
  --critical: #d03b3b;

  --radius: 8px;
  --gap: 1rem;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --surface-0: #121211;
    --surface-1: #1a1a19;
    --surface-2: #242422;
    --border: #35352f;
    --border-strong: #4c4c44;
    --text-primary: #ffffff;
    --text-secondary: #c3c2b7;
    --text-muted: #94938a;

    --series-1: #3987e5;
    --series-2: #d95926;
    --series-3: #199e70;
    --series-4: #c98500;
    --series-5: #d55181;
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --surface-0: #121211;
  --surface-1: #1a1a19;
  --surface-2: #242422;
  --border: #35352f;
  --border-strong: #4c4c44;
  --text-primary: #ffffff;
  --text-secondary: #c3c2b7;
  --text-muted: #94938a;

  --series-1: #3987e5;
  --series-2: #d95926;
  --series-3: #199e70;
  --series-4: #c98500;
  --series-5: #d55181;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--surface-0);
  color: var(--text-primary);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
}

.wrap { max-width: 1180px; margin: 0 auto; padding: 0 1rem; }
.sr-only {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip-path: inset(50%); white-space: nowrap;
}

/* ---- Header / footer ---------------------------------------------------- */

.site-header { padding: 2rem 0 1rem; }
.site-header h1 { margin: 0; font-size: 1.9rem; letter-spacing: -0.02em; }
.tagline { margin: 0.4rem 0 0; color: var(--text-secondary); max-width: 62ch; }

.site-footer {
  margin-top: 3rem; padding: 1.5rem 0 3rem;
  border-top: 1px solid var(--border);
  color: var(--text-secondary); font-size: 0.85rem;
}
.site-footer p { margin: 0 0 0.5rem; max-width: 78ch; }
.muted { color: var(--text-muted); }

/* ---- Notices ------------------------------------------------------------ */

.notice {
  border: 1px solid var(--border-strong);
  border-left-width: 4px;
  border-radius: var(--radius);
  background: var(--surface-1);
  padding: 0.75rem 1rem;
  margin: 0 0 0.75rem;
  font-size: 0.9rem;
  color: var(--text-secondary);
}
.notice strong { color: var(--text-primary); display: block; margin-bottom: 0.15rem; }
.notice-blocker { border-left-color: var(--critical); }
.notice-disclaimer { border-left-color: var(--warning); }
.notice a { color: inherit; }

/* ---- Layout ------------------------------------------------------------- */

.layout {
  display: grid;
  grid-template-columns: minmax(0, 360px) minmax(0, 1fr);
  gap: var(--gap);
  align-items: start;
  margin-top: 1rem;
}
@media (max-width: 900px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
}

.panel {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
}
.panel-head {
  display: flex; flex-wrap: wrap; gap: 0.5rem;
  align-items: baseline; justify-content: space-between;
}
.panel h2 { margin: 0 0 0.5rem; font-size: 1.05rem; }
.placeholder { color: var(--text-muted); }

/* ---- Form --------------------------------------------------------------- */

fieldset {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem;
  margin: 0 0 0.75rem;
}
legend { padding: 0 0.35rem; font-weight: 600; font-size: 0.85rem; color: var(--text-secondary); }

.field { display: grid; grid-template-columns: 1fr auto; gap: 0.5rem; align-items: center; margin-bottom: 0.4rem; }
.field label { font-size: 0.85rem; color: var(--text-secondary); }
.field-hint { grid-column: 1 / -1; font-size: 0.75rem; color: var(--text-muted); margin: -0.2rem 0 0.3rem; }

input, select, button {
  font: inherit;
  color: var(--text-primary);
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  padding: 0.3rem 0.45rem;
}
input[type="number"] { width: 8.5rem; text-align: right; font-variant-numeric: tabular-nums; }
input[type="checkbox"] { width: auto; }
select { max-width: 11rem; }
input:focus-visible, select:focus-visible, button:focus-visible {
  outline: 2px solid var(--series-1); outline-offset: 1px;
}

button { cursor: pointer; }
button:hover { border-color: var(--text-secondary); }

.toolbar { display: flex; flex-wrap: wrap; gap: 0.35rem; }
.toolbar button { font-size: 0.8rem; padding: 0.25rem 0.5rem; }
.toolbar-status { min-height: 1.2rem; margin: 0.25rem 0 0.5rem; font-size: 0.8rem; color: var(--text-muted); }

.add-row { font-size: 0.8rem; margin-top: 0.35rem; }

/* ---- Tables ------------------------------------------------------------- */

table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
th, td { text-align: right; padding: 0.3rem 0.35rem; border-bottom: 1px solid var(--border); }
th:first-child, td:first-child { text-align: left; }
thead th { color: var(--text-secondary); font-weight: 600; font-size: 0.75rem; }
tbody tr:last-child td { border-bottom: none; }
td.numeric, th.numeric { font-variant-numeric: tabular-nums; }

/* Fixed layout: the selects need room for their labels, and auto layout was
   collapsing them to unreadable stubs. */
.unit-mix { table-layout: fixed; }
.unit-mix th:nth-child(1), .unit-mix td:nth-child(1) { width: 22%; }
.unit-mix th:nth-child(2), .unit-mix td:nth-child(2) { width: 15%; }
.unit-mix th:nth-child(3), .unit-mix td:nth-child(3) { width: 17%; }
.unit-mix th:nth-child(4), .unit-mix td:nth-child(4) { width: 21%; }
.unit-mix th:nth-child(5), .unit-mix td:nth-child(5) { width: 17%; }
.unit-mix th:nth-child(6), .unit-mix td:nth-child(6) { width: 8%; }
/* Spinners cost ~16px per cell here, which is the difference between "900" and
   a clipped "90". The values are typed, not stepped. */
.unit-mix input[type="number"] {
  width: 100%; padding: 0.2rem 0.25rem;
  appearance: textfield; -moz-appearance: textfield;
}
.unit-mix input[type="number"]::-webkit-outer-spin-button,
.unit-mix input[type="number"]::-webkit-inner-spin-button { appearance: none; margin: 0; }
.unit-mix select { width: 100%; max-width: none; padding: 0.2rem 0.2rem; font-size: 0.78rem; }
.unit-mix td { padding: 0.2rem 0.15rem; }
.unit-mix select:disabled { opacity: 0.45; }
.remove-row {
  padding: 0.1rem 0.4rem; font-size: 0.9rem; line-height: 1.2;
  background: none; border-color: transparent; color: var(--text-muted);
}
.remove-row:hover { color: var(--critical); border-color: var(--border-strong); }

.table-scroll { overflow-x: auto; }

/* ---- Verdict + stats ---------------------------------------------------- */

.verdict {
  display: flex; align-items: center; gap: 0.6rem;
  border: 1px solid var(--border-strong); border-left-width: 4px;
  border-radius: var(--radius); padding: 0.7rem 0.9rem; margin-bottom: 0.9rem;
}
.verdict-icon { font-size: 1.2rem; line-height: 1; }
.verdict-text strong { display: block; }
.verdict-text span { font-size: 0.85rem; color: var(--text-secondary); }
.verdict-blocked { border-left-color: var(--critical); }
.verdict-strained { border-left-color: var(--serious); }
.verdict-ok { border-left-color: var(--good); }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 0.5rem; margin-bottom: 1rem; }
.stat { background: var(--surface-2); border-radius: var(--radius); padding: 0.6rem 0.7rem; }
.stat dt { font-size: 0.72rem; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.04em; margin: 0; }
.stat dd { margin: 0.2rem 0 0; font-size: 1.15rem; font-variant-numeric: tabular-nums; }
.stat dd.is-negative { color: var(--critical); }
.stat .stat-note { display: block; font-size: 0.72rem; color: var(--text-muted); font-variant-numeric: normal; }

/* ---- Chart -------------------------------------------------------------- */

.chart { margin: 0 0 1rem; }
.chart h3, .results h3 { font-size: 0.95rem; margin: 1.2rem 0 0.5rem; }
.chart figcaption { font-size: 0.78rem; color: var(--text-muted); margin-top: 0.35rem; }
.chart svg { display: block; width: 100%; height: auto; }
.chart-ref-line { stroke: var(--text-secondary); stroke-width: 2; stroke-dasharray: 4 3; }
.chart-ref-label { fill: var(--text-secondary); font-size: 11px; }
.chart-seg-label { fill: var(--text-primary); font-size: 11px; font-variant-numeric: tabular-nums; }

.legend { display: flex; flex-wrap: wrap; gap: 0.5rem 0.9rem; margin-top: 0.5rem; font-size: 0.8rem; }
.legend-item { display: inline-flex; align-items: center; gap: 0.35rem; color: var(--text-secondary); }
.legend-swatch { width: 12px; height: 12px; border-radius: 3px; flex: none; }

/* ---- Findings ----------------------------------------------------------- */

.findings { list-style: none; padding: 0; margin: 0; }
.finding {
  border: 1px solid var(--border); border-left-width: 4px;
  border-radius: var(--radius); padding: 0.6rem 0.8rem; margin-bottom: 0.5rem;
  background: var(--surface-2);
}
.finding-BLOCKER { border-left-color: var(--critical); }
.finding-CRITICAL { border-left-color: var(--serious); }
.finding-WARNING { border-left-color: var(--warning); }
.finding-INFO { border-left-color: var(--series-1); }

.finding-head { display: flex; align-items: baseline; gap: 0.4rem; flex-wrap: wrap; }
.finding-badge {
  font-size: 0.68rem; letter-spacing: 0.05em; text-transform: uppercase;
  border: 1px solid currentColor; border-radius: 4px; padding: 0 0.3rem;
}
.finding-BLOCKER .finding-badge { color: var(--critical); }
.finding-CRITICAL .finding-badge { color: var(--serious); }
.finding-WARNING .finding-badge { color: var(--text-secondary); }
.finding-INFO .finding-badge { color: var(--text-secondary); }
.finding-title { font-weight: 600; }
.finding-spec { font-size: 0.72rem; color: var(--text-muted); margin-left: auto; }
.finding p { margin: 0.3rem 0 0; font-size: 0.85rem; color: var(--text-secondary); }
.finding .finding-action { color: var(--text-primary); }
