/* Regional Solid Waste Management Planning
   Type: Bahnschrift (DIN, the lettering of European road and infrastructure signs) for
   headings and figures; Segoe UI for running text.
   Colour: black by default (a light theme is one click away). Facility colours (--f1..--f5)
   follow the waste hierarchy and are validated for colour-vision deficiency in both themes. */
:root {
  color-scheme: dark;
  --page: #000000;
  --surface: #0b0d0f;
  --surface-2: #13171a;
  --surface-3: #1a1f23;
  --ink: #eceff1;
  --ink-2: #b3bdc3;
  --muted: #828d94;
  --hair: #1e2428;
  --base: #353d43;
  --accent: #5fb0d8;
  --accent-ink: #000000;
  --accent-soft: #0e2733;
  --focus: #7cc3e6;
  --changed: #e6a23c; --good: #2fb35a; --good-text: #4cc471;
  --warning: #e0a000; --critical: #ec6a5e;
  /* facility types: EMAK, MAA, MEVA, WtE, landfill */
  --f1: #3d82cf; --f2: #1ea67b; --f3: #9a7ae0; --f4: #bd8500; --f5: #e5576e;
  /* categorical slots for streams and cost items (validated reference palette) */
  --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500;
  --s5: #d55181; --s6: #008300; --s7: #9085e9; --s8: #e66767;
  /* sequential blue, dark to light on black */
  --q1: #104281; --q2: #184f95; --q3: #256abf; --q4: #3987e5; --q5: #6da7ec; --q6: #9ec5f4; --q7: #cde2fb;
  --null: #171c20;
  --shadow: 0 1px 0 rgba(255, 255, 255, .03) inset;
  --radius: 8px; --radius-sm: 5px;
  --topbar-h: 60px;
  --font: "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, sans-serif;
  --font-display: "Bahnschrift", "DIN Alternate", "Segoe UI Variable Display", "Segoe UI", sans-serif;
}
:root[data-theme="light"] {
  color-scheme: light;
  --page: #eceff0; --surface: #ffffff; --surface-2: #f4f6f6; --surface-3: #eaeeef;
  --ink: #15232b; --ink-2: #475861; --muted: #64737b; --hair: #d8dee0; --base: #b6c1c4;
  --accent: #0f5470; --accent-ink: #ffffff; --accent-soft: #e0ecf1; --focus: #1f7fb0;
  --changed: #b36b00; --good: #1a8a3a; --good-text: #17702f; --critical: #c23b2e;
  --f1: #2f6fb5; --f2: #1f9d78; --f3: #7a5bc7; --f4: #e09a12; --f5: #b8472f;
  --s1: #2a78d6; --s2: #eb6834; --s3: #1baf7a; --s4: #eda100;
  --s5: #e87ba4; --s6: #008300; --s7: #6250d6; --s8: #e34948;
  --q1: #cde2fb; --q2: #9ec5f4; --q3: #6da7ec; --q4: #3987e5; --q5: #256abf; --q6: #184f95; --q7: #0d366b;
  --null: #e7ebec;
  --shadow: 0 1px 2px rgba(20, 32, 43, .06);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
  background: var(--page); color: var(--ink); font-family: var(--font);
  font-size: 14px; line-height: 1.45; -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { margin: 0; font-family: var(--font-display); font-weight: 600; }
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
a { color: var(--accent); }
abbr[title] { text-decoration: underline dotted var(--base); text-underline-offset: 3px; cursor: help; }
kbd { font: inherit; font-size: 11px; padding: 1px 5px; border-radius: 3px; border: 1px solid currentColor; opacity: .7; }
.skip { position: absolute; left: -999px; top: 8px; z-index: 100; background: var(--surface); padding: 8px 12px; }
.skip:focus { left: 8px; }

/* ---------- top bar ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  height: var(--topbar-h); padding: 0 24px; background: var(--surface); border-bottom: 1px solid var(--hair);
  position: sticky; top: 0; z-index: 20;
}
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand-mark { width: 32px; height: 32px; color: var(--accent); flex: none; }
.brand h1 { font-size: 19px; letter-spacing: .005em; line-height: 1.15; }
.brand .sub { margin: 0; color: var(--ink-2); font-size: 12.5px; }
.topbar-actions { display: flex; align-items: center; gap: 8px; }
.status-pill {
  display: inline-flex; align-items: center; gap: 7px; padding: 5px 11px; border-radius: 999px;
  font-size: 12.5px; background: var(--surface-2); color: var(--ink-2); white-space: nowrap;
  font-variant-numeric: tabular-nums; margin-right: 6px;
}
.status-pill::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.status-pill.ok::before { background: var(--good); }
.status-pill.bad::before { background: var(--critical); }
.status-pill.busy::before { background: var(--warning); animation: pulse 1s infinite alternate; }
@keyframes pulse { to { opacity: .3; } }

/* ---------- layout ---------- */
.layout { display: grid; grid-template-columns: 340px minmax(0, 1fr); align-items: start; }
.inputs {
  background: var(--surface); border-right: 1px solid var(--hair);
  display: flex; flex-direction: column; position: sticky; top: var(--topbar-h); height: calc(100vh - var(--topbar-h));
}
.inputs-head { padding: 16px 20px 12px; border-bottom: 1px solid var(--hair); }
.inputs-title { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.inputs-title h2 { font-size: 17px; }
.inputs-title select { max-width: 190px; }
.baseline-line { margin: 8px 0 0; font-size: 12.5px; color: var(--ink-2); display: flex; align-items: center; gap: 6px; flex-wrap: wrap; min-height: 20px; }
.baseline-line .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--changed); }
.baseline-line .dot.same { background: var(--good); }
.linkish { background: none; border: 0; padding: 0; color: var(--accent); text-decoration: underline; cursor: pointer; font-size: inherit; }

.inputs-scroll { flex: 1; overflow-y: auto; overscroll-behavior: contain; }
.group + .group { border-top: 1px solid var(--hair); }
.group-head {
  width: 100%; text-align: left; background: none; border: 0; padding: 13px 20px; cursor: pointer;
  font-weight: 600; display: flex; align-items: center; gap: 8px;
}
.group-head > span:first-child { flex: 1; }
.group-head:hover { background: var(--surface-2); }
.group-head::after {
  content: ""; width: 7px; height: 7px; border-right: 1.5px solid var(--muted); border-bottom: 1.5px solid var(--muted);
  transform: rotate(45deg) translate(-2px, -2px); transition: transform .15s; flex: none;
}
.group.open .group-head::after { transform: rotate(-135deg); }
.badge { font-size: 11.5px; font-weight: 600; color: var(--changed); background: color-mix(in srgb, var(--changed) 13%, transparent); padding: 1px 7px; border-radius: 999px; }
.group-body { padding: 2px 20px 18px; display: none; }
.group.open .group-body { display: block; }

.field { margin: 6px 0 18px; }
.field:last-child { margin-bottom: 4px; }
.field label { font-weight: 500; }
.field-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.field.num { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 10px 0; }
.num-unit { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 12.5px; white-space: nowrap; }
.num-unit input { width: 84px; text-align: right; color: var(--ink); font-size: 14px; }
.num-unit > span { min-width: 44px; }
.hint { color: var(--muted); font-size: 12.5px; margin: 6px 0 0; }
input[type="number"], input[type="text"], select {
  background: var(--surface); border: 1px solid var(--base); border-radius: var(--radius-sm);
  padding: 5px 8px; min-height: 32px; font-variant-numeric: tabular-nums;
}
input[type="number"]:hover, input[type="text"]:hover, select:hover { border-color: var(--ink-2); }
input.changed { border-color: var(--changed); box-shadow: inset 3px 0 0 var(--changed); }
input:invalid { border-color: var(--critical); }
select { padding-right: 24px; cursor: pointer; }
input[type="range"] { width: 100%; accent-color: var(--accent); margin: 10px 0 0; }
.scale { display: flex; justify-content: space-between; font-size: 11.5px; color: var(--muted); margin-top: -2px; }

.policy-list { display: grid; gap: 6px; }
.policy {
  display: grid; grid-template-columns: 16px 1fr; gap: 2px 10px; align-items: start; text-align: left;
  border: 1px solid var(--hair); border-radius: var(--radius); padding: 9px 12px; background: var(--surface); cursor: pointer;
}
.policy:hover { border-color: var(--base); background: var(--surface-2); }
.policy::before {
  content: ""; width: 14px; height: 14px; border-radius: 50%; border: 1.5px solid var(--base); margin-top: 2px; grid-row: span 2;
}
.policy[aria-checked="true"] { border-color: var(--accent); background: var(--accent-soft); }
.policy[aria-checked="true"]::before { border: 4.5px solid var(--accent); }
.policy b { font-weight: 600; }
.policy small { color: var(--ink-2); font-size: 12.5px; }

.segmented { display: inline-grid; grid-auto-flow: column; background: var(--surface-2);
  border: 1px solid var(--hair); border-radius: var(--radius); padding: 3px; gap: 3px; }
.segmented button { border: 0; background: none; padding: 6px 12px; border-radius: var(--radius-sm); cursor: pointer; color: var(--ink-2); font-weight: 500; }
.segmented button[aria-checked="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 0 0 1px var(--hair); }

table.traj { width: 100%; border-collapse: collapse; font-size: 13px; margin-top: 10px; }
table.traj th { text-align: right; color: var(--muted); font-weight: 500; padding: 4px; font-size: 12px; }
table.traj th:first-child { text-align: left; }
table.traj td { padding: 2px 4px; }
table.traj td:first-child { font-variant-numeric: tabular-nums; color: var(--ink-2); }
table.traj input { width: 100%; min-height: 28px; padding: 3px 6px; text-align: right; }

button.primary {
  background: var(--accent); color: var(--accent-ink); border: 1px solid var(--accent); border-radius: var(--radius-sm);
  padding: 8px 16px; font-weight: 600; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 10px;
}
button.primary:hover { filter: brightness(1.1); }
button.primary:disabled { opacity: .55; cursor: progress; filter: none; }
button.primary.small { padding: 5px 12px; font-size: 13px; }
button.ghost {
  background: var(--surface); border: 1px solid var(--base); border-radius: var(--radius-sm);
  padding: 7px 14px; cursor: pointer; color: var(--ink);
}
button.ghost:hover { background: var(--surface-2); border-color: var(--ink-2); }
button.ghost:disabled { opacity: .5; cursor: not-allowed; }
.icon-btn { padding: 6px 8px; display: inline-flex; }
.inputs-foot {
  padding: 14px 20px; border-top: 1px solid var(--hair); display: flex; gap: 8px; background: var(--surface);
}
.inputs-foot .primary { flex: 1; min-height: 40px; }
.inputs-foot .primary.pending { box-shadow: 0 0 0 3px color-mix(in srgb, var(--changed) 45%, transparent); }

/* ---------- results ---------- */
.results { padding: 0 28px 48px; min-width: 0; }
.tabs {
  display: flex; gap: 4px; border-bottom: 1px solid var(--hair); position: sticky; top: var(--topbar-h); z-index: 10;
  background: var(--page); padding-top: 10px; overflow-x: auto; scrollbar-width: thin;
}
.tabs button {
  border: 0; background: none; padding: 10px 12px; cursor: pointer; color: var(--ink-2); font-weight: 500;
  border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap;
}
.tabs button[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--accent); font-weight: 600; }
.tabs button:hover { color: var(--ink); }
.busy-line { position: sticky; top: calc(var(--topbar-h) + 52px); z-index: 10; height: 2px; overflow: hidden; background: var(--accent-soft); }
.busy-line::after { content: ""; position: absolute; inset: 0; width: 30%; background: var(--accent); animation: slide 1.1s ease-in-out infinite; }
@keyframes slide { from { transform: translateX(-100%); } to { transform: translateX(340%); } }
.results[aria-busy="true"] .tab-panel { opacity: .5; transition: opacity .2s; pointer-events: none; }
.tab-panel { padding-top: 20px; }

.stale {
  margin-top: 16px; display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap;
  padding: 10px 14px; border-radius: var(--radius); background: color-mix(in srgb, var(--changed) 11%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--changed) 45%, transparent); font-size: 13.5px;
}
.stale + .tab-panel { padding-top: 14px; }

.run-summary { margin-bottom: 16px; }
.run-summary .lede { font-family: var(--font-display); font-size: 20px; line-height: 1.3; margin: 0; max-width: 64ch; }
.run-summary .meta { color: var(--muted); font-size: 12.5px; margin: 4px 0 0; }
.notice {
  border: 1px solid var(--hair); border-left: 4px solid var(--critical); background: var(--surface); padding: 16px 18px;
  border-radius: var(--radius);
}
.notice h3 { font-size: 17px; margin-bottom: 4px; }
.notice p { margin: 0 0 12px; max-width: 75ch; color: var(--ink-2); }
.notice .actions { display: flex; flex-wrap: wrap; gap: 8px; }
.notice .solver-msg { color: var(--muted); font-size: 12px; margin: 12px 0 0; }

.kpis { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); background: var(--surface);
  border: 1px solid var(--hair); border-top: 3px solid var(--accent); border-radius: var(--radius); margin-bottom: 20px; }
.kpi { padding: 14px 16px 13px; min-width: 0; }
.kpi + .kpi { border-left: 1px solid var(--hair); }
.kpi .k-label { color: var(--ink-2); font-size: 12.5px; }
.kpi .k-value { font-family: var(--font-display); font-size: 30px; font-weight: 600; line-height: 1.15; margin-top: 3px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.kpi .k-value small { font-size: 13px; font-weight: 400; color: var(--ink-2); margin-left: 4px; }
.kpi .k-note { color: var(--muted); font-size: 12px; margin-top: 3px; }
.kpi .k-note.good { color: var(--good-text); }
.kpi .k-note.bad { color: var(--critical); }
.kpi .k-delta { font-size: 12px; margin-top: 4px; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.kpi .k-delta b { font-weight: 600; }

.grid { display: grid; gap: 20px; margin-bottom: 20px; }
.grid.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.card {
  margin: 0; background: var(--surface); border: 1px solid var(--hair); border-radius: var(--radius);
  padding: 16px 18px 10px; min-width: 0; position: relative;
}
.card.wide { margin-bottom: 20px; }
figcaption h3 { font-size: 16px; }
figcaption p { margin: 2px 0 0; color: var(--muted); font-size: 12.5px; }
figcaption { padding-right: 34px; }
figcaption.cap-row { padding-right: 34px; }
.cap-row { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; }
.save-png {
  position: absolute; top: 12px; right: 12px; border: 1px solid transparent; background: none; border-radius: var(--radius-sm);
  padding: 5px; color: var(--muted); cursor: pointer; display: inline-flex;
}
.save-png:hover { color: var(--ink); border-color: var(--hair); background: var(--surface-2); }
.chart { height: 300px; width: 100%; margin-top: 8px; }
.chart.tall { height: 520px; }
.year-pick { display: flex; align-items: center; gap: 10px; }
.year-pick input { width: 180px; margin: 0; }
.year-pick output { font-variant-numeric: tabular-nums; font-weight: 600; min-width: 96px; }

.controls-card { margin-bottom: 20px; padding-bottom: 14px; }
.controls { display: flex; gap: 16px; align-items: flex-end; flex-wrap: wrap; }
.controls .field { margin: 0; display: flex; flex-direction: column; gap: 4px; flex: 1; min-width: 220px; }
.controls .grow { flex: 1; margin: 0; min-width: 260px; font-size: 13.5px; color: var(--ink-2); max-width: 80ch; }
.inline-select { display: inline-flex; align-items: center; gap: 8px; color: var(--ink-2); }
.ctrl-btns { display: flex; gap: 8px; }
.progress { margin-top: 12px; display: flex; align-items: center; gap: 12px; }
.progress .bar { flex: 1; height: 6px; border-radius: 3px; background: var(--null); overflow: hidden; position: relative; }
.progress .bar::after { content: ""; position: absolute; inset: 0; width: var(--p, 0%); background: var(--accent); transition: width .3s; }
.progress span { font-variant-numeric: tabular-nums; color: var(--ink-2); font-size: 13px; min-width: 160px; text-align: right; }

.empty {
  border: 1px dashed var(--base); border-radius: var(--radius); padding: 28px 32px; color: var(--ink-2); background: var(--surface);
}
.empty p { margin: 0 0 6px; max-width: 72ch; }
.empty p:last-child { margin: 0; }
.empty b { color: var(--ink); }

.scen-cards { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 20px; margin-bottom: 20px; }
.scen-card { background: var(--surface); border: 1px solid var(--hair); border-radius: var(--radius); padding: 16px 18px; }
.scen-card h3 { font-size: 17px; display: flex; align-items: center; gap: 8px; }
.scen-card .swatch { width: 10px; height: 10px; border-radius: 3px; }
.scen-card p.desc { color: var(--muted); font-size: 12.5px; margin: 2px 0 12px; }
.scen-card dl { display: grid; grid-template-columns: 1fr auto; gap: 5px 12px; margin: 0; }
.scen-card dt { color: var(--ink-2); }
.scen-card dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }
.scen-card .infeas { color: var(--ink); border-left: 3px solid var(--critical); padding-left: 10px; font-size: 13px; }
.tag { display: inline-flex; gap: 4px; align-items: center; font-family: var(--font); font-size: 12px; padding: 1px 8px; border-radius: 999px; border: 1px solid var(--hair); color: var(--ink-2); font-weight: 500; margin-left: auto; }
.tag.bad::before { content: "✕"; color: var(--critical); font-weight: 700; }
.tag.ok::before { content: "✓"; color: var(--good-text); font-weight: 700; }

.table-wrap { overflow-x: auto; margin: 10px 0 6px; }
table.data { border-collapse: collapse; width: 100%; font-size: 13px; font-variant-numeric: tabular-nums; }
table.data th, table.data td { padding: 7px 10px; border-bottom: 1px solid var(--hair); text-align: right; white-space: nowrap; }
table.data th { color: var(--ink-2); font-weight: 600; background: var(--surface-2); position: sticky; top: 0; }
table.data th:first-child, table.data td:first-child { text-align: left; }
table.data tr:hover td { background: var(--surface-2); }

.glossary {
  border: 1px solid var(--hair); border-radius: var(--radius); padding: 0; width: min(560px, calc(100vw - 32px));
  max-height: min(720px, calc(100vh - 64px)); background: var(--surface); color: var(--ink);
}
.glossary::backdrop { background: rgba(10, 18, 22, .38); }
.glossary-head { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--hair); position: sticky; top: 0; background: var(--surface); }
.glossary-head h2 { font-size: 19px; }
.glossary dl { margin: 0; padding: 8px 20px 20px; display: grid; grid-template-columns: 110px 1fr; gap: 10px 16px; }
.glossary dt { font-family: var(--font-display); font-weight: 600; }
.glossary dd { margin: 0; color: var(--ink-2); }

.toast { position: fixed; bottom: 20px; right: 20px; background: var(--ink); color: var(--surface); padding: 10px 16px; border-radius: var(--radius-sm); z-index: 60; max-width: 420px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
@media (max-width: 1400px) {
  .kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .kpi:nth-child(4) { border-left: 0; }
  .kpi:nth-child(n+4) { border-top: 1px solid var(--hair); }
}
@media (max-width: 1000px) {
  .layout { grid-template-columns: 1fr; }
  .inputs { position: static; height: auto; border-right: 0; border-bottom: 1px solid var(--hair); }
  .inputs-scroll { overflow: visible; }
  .inputs-foot { position: sticky; bottom: 0; z-index: 15; }
  .grid.g2, .scen-cards { grid-template-columns: 1fr; }
  .tabs { top: 0; }
  .busy-line { top: 52px; }
  .topbar { position: static; }
}
@media (max-width: 600px) {
  .results { padding: 0 16px 32px; }
  .topbar { padding: 0 16px; }
  .brand .sub, #solverStatus { display: none; }
  .inputs-head, .group-head, .group-body, .inputs-foot { padding-left: 16px; padding-right: 16px; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi:nth-child(n) { border-left: 0; border-top: 1px solid var(--hair); }
  .kpi:nth-child(even) { border-left: 1px solid var(--hair); }
  .kpi:nth-child(-n+2) { border-top: 0; }
  .kpi .k-value { font-size: 24px; }
  .year-pick { flex-wrap: wrap; }
  .run-summary .lede { font-size: 17px; }
}
.kpi .k-delta b.good { color: var(--good-text); }
.kpi .k-delta b.bad { color: var(--critical); }
.kpis:empty { display: none; }
@media (max-width: 600px) { .inputs-foot kbd { display: none; } }

/* ---------- model switcher ---------- */
.model-switch { display: inline-flex; gap: 4px; padding: 3px; border: 1px solid var(--hair); border-radius: var(--radius); background: var(--surface-2); }
.model-switch button {
  border: 0; background: none; border-radius: var(--radius-sm); padding: 4px 14px; cursor: pointer; text-align: left;
  display: grid; line-height: 1.2; color: var(--ink-2);
}
.model-switch button b { font-family: var(--font-display); font-weight: 600; font-size: 14px; }
.model-switch button small { font-size: 11.5px; color: var(--muted); }
.model-switch button:hover { color: var(--ink); }
.model-switch button[aria-checked="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 0 0 1px var(--hair); }
.model-switch button[aria-checked="true"] b { color: var(--accent); }

/* ---------- policy model view ---------- */
.sview { padding: 0 28px 48px; max-width: 1680px; }
.readonly-note {
  margin: 14px 0 0; padding: 9px 14px; border-radius: var(--radius); font-size: 13px; color: var(--ink-2);
  background: var(--accent-soft); border: 1px solid color-mix(in srgb, var(--accent) 25%, transparent);
}
.swatch-dot { display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin-right: 8px; vertical-align: 1px; }
table.data.wrap td, table.data.wrap th { white-space: normal; vertical-align: top; }
table.data.wrap td, table.data.wrap th { text-align: left; }
.side-box { overflow-wrap: anywhere; }
table.data tr.total td { font-weight: 600; border-top: 2px solid var(--hair); }
table.data code, .about code { font-family: "Cascadia Mono", Consolas, monospace; font-size: 12px; color: var(--ink); white-space: nowrap; }
.kpi .k-value.k-text { font-size: 19px; white-space: normal; line-height: 1.25; margin-top: 6px; }

/* ---------- model description ---------- */
.about { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 28px; align-items: start; }
.about-main { min-width: 0; }
.about-main > section { background: var(--surface); border: 1px solid var(--hair); border-radius: var(--radius); padding: 16px 20px; margin-top: 16px; }
.about-main h2 { font-size: 26px; margin: 2px 0 8px; }
.about-main h3 { font-size: 17px; margin-bottom: 6px; }
.about-main p, .about-main li { max-width: 78ch; }
.about-main .lede { font-size: 15.5px; color: var(--ink-2); margin: 0; }
.about-kind { margin: 0; color: var(--accent); font-weight: 600; font-size: 13px; }
.about-main .question { border-left: 4px solid var(--accent); }
.about-main .question p { font-family: var(--font-display); font-size: 17px; margin: 0; }
.about-main ul, .about-main ol { margin: 6px 0 0; padding-left: 20px; }
.about-main li { margin: 4px 0; }
.steps li::marker { color: var(--accent); font-weight: 700; }
.about-side { display: grid; gap: 12px; min-width: 0; }
.side-box { background: var(--surface); border: 1px solid var(--hair); border-radius: var(--radius); padding: 13px 16px; font-size: 13px; }
.side-box h3 { font-size: 14.5px; margin-bottom: 4px; }
.side-box p { margin: 4px 0; color: var(--ink-2); }
.side-box ul { margin: 4px 0 0; padding-left: 18px; color: var(--ink-2); }
.side-box li { margin: 3px 0; }
.side-box.paper { border-top: 3px solid var(--accent); }
.side-box .ptitle { color: var(--ink); font-weight: 600; }
.side-box .tag { margin-left: 0; margin-top: 4px; }

/* ---------- guide ---------- */
.glossary.guide { width: min(880px, calc(100vw - 32px)); max-height: min(820px, calc(100vh - 48px)); }
.guide-nav { display: flex; gap: 4px; flex-wrap: wrap; padding: 10px 20px; border-bottom: 1px solid var(--hair); position: sticky; top: 59px; background: var(--surface); z-index: 1; }
.guide-nav a { text-decoration: none; color: var(--ink-2); padding: 4px 10px; border-radius: 999px; font-size: 13px; border: 1px solid var(--hair); }
.guide-nav a:hover { color: var(--ink); border-color: var(--base); }
.guide-body section { padding: 6px 20px 14px; }
.guide-body h3 { font-size: 18px; margin: 10px 0 6px; }
.guide-body h4 { font-size: 14.5px; margin: 12px 0 4px; font-family: var(--font-display); }
.guide-body ol { margin: 0; padding-left: 20px; color: var(--ink-2); }
.guide-body ol li { margin: 5px 0; }
.guide-body dl { padding: 4px 0 0; }
.glossary.guide dl { margin: 0; display: grid; grid-template-columns: 150px 1fr; gap: 8px 16px; }

@media (max-width: 1280px) {
  .model-switch button small { display: none; }
}
@media (max-width: 1100px) {
  .about { grid-template-columns: 1fr; }
  .about-side { position: static; max-height: none; }
}
@media (max-width: 1000px) {
  .topbar { flex-wrap: wrap; height: auto; padding-top: 8px; padding-bottom: 8px; }
  .model-switch { order: 3; width: 100%; }
  .model-switch button { flex: 1; }
  .sview { padding: 0 16px 32px; }
}
@media (max-width: 600px) {
  .glossary.guide dl { grid-template-columns: 1fr; gap: 2px; }
  .glossary.guide dd { margin-bottom: 8px; }
}

/* ================= pages, navigation ================= */
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.brand { text-decoration: none; color: inherit; }
.brand h1 { font-size: 18px; }
.mainnav { display: flex; gap: 2px; align-self: stretch; }
.mainnav a {
  display: flex; align-items: center; padding: 0 14px; color: var(--ink-2); text-decoration: none; font-weight: 500;
  border-bottom: 3px solid transparent; margin-bottom: -1px;
}
.mainnav a:hover { color: var(--ink); }
.mainnav a[aria-current="page"] { color: var(--ink); border-bottom-color: var(--accent); font-weight: 600; }
.page { max-width: 1440px; margin: 0 auto; padding: 28px 28px 56px; }
a.button { display: inline-flex; align-items: center; justify-content: center; text-decoration: none; border-radius: var(--radius-sm); padding: 9px 18px; font-weight: 600; }
a.button.primary { background: var(--accent); color: var(--accent-ink); border: 1px solid var(--accent); }
a.button.primary:hover { filter: brightness(1.1); }
a.button.ghost { background: var(--surface); border: 1px solid var(--base); color: var(--ink); font-weight: 500; }
a.button.ghost:hover { background: var(--surface-2); }
.textlink { display: inline-block; margin-top: 10px; font-weight: 500; }
.muted { color: var(--muted); }
.warn { color: var(--critical); }
button.small, .button.small { padding: 5px 12px; font-size: 13px; }

/* ================= home ================= */
.hero { max-width: 900px; padding: 18px 0 26px; }
.hero h2 { font-size: 34px; line-height: 1.15; letter-spacing: -0.005em; max-width: 26ch; }
.hero p { font-size: 16.5px; color: var(--ink-2); margin: 14px 0 0; max-width: 70ch; }
.steps-home { list-style: none; counter-reset: step; padding: 0; margin: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.step-card { counter-increment: step; background: var(--surface); border: 1px solid var(--hair); border-radius: var(--radius); padding: 18px 20px 20px; position: relative; }
.step-card.wide { grid-column: 1 / -1; }
.step-card h3 { font-size: 18px; display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.step-card h3::before {
  content: counter(step); width: 26px; height: 26px; border-radius: 50%; display: inline-grid; place-items: center;
  background: var(--accent); color: var(--accent-ink); font-size: 14px;
}
.step-card select { min-width: 240px; font-size: 15px; min-height: 38px; }
.period-pick { display: flex; align-items: center; gap: 10px; font-size: 15px; }
.period-pick select { min-width: 110px; }
.model-pick { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.model-option {
  text-align: left; border: 1px solid var(--hair); background: var(--surface); border-radius: var(--radius);
  padding: 14px 16px 14px 44px; cursor: pointer; display: grid; gap: 4px; position: relative;
}
.model-option::before { content: ""; position: absolute; left: 16px; top: 18px; width: 16px; height: 16px; border-radius: 50%; border: 1.5px solid var(--base); }
.model-option:hover { border-color: var(--base); background: var(--surface-2); }
.model-option[aria-checked="true"] { border-color: var(--accent); background: var(--accent-soft); }
.model-option[aria-checked="true"]::before { border: 5px solid var(--accent); }
.model-option b { font-family: var(--font-display); font-size: 18px; font-weight: 600; }
.mo-kind { color: var(--accent); font-weight: 600; font-size: 12.5px; }
.mo-q { color: var(--ink-2); font-size: 13.5px; }
.mo-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.mo-tags .tag { margin-left: 0; }
.home-actions { display: flex; gap: 10px; margin-top: 22px; flex-wrap: wrap; }

/* ================= region ================= */
.region-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; margin-bottom: 18px; }
.region-head h2 { font-size: 30px; margin: 2px 0 6px; }
.region-head .lede { color: var(--ink-2); font-size: 15px; max-width: 95ch; margin: 0; }
.kpis.facts .k-value { font-size: 26px; }
.region-grid { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 20px; margin-bottom: 20px; align-items: start; }
.map-card { margin: 0; }
.map { height: 560px; margin-top: 10px; border-radius: var(--radius-sm); border: 1px solid var(--hair); background: var(--surface-2); z-index: 0; }
.legend-card { margin: 0; padding: 16px 18px; }
.legend-card h3 { font-size: 15px; margin-bottom: 8px; }
.legend-card h3.mt { margin-top: 18px; }
.map-legend { list-style: none; margin: 0; padding: 0; display: grid; gap: 7px; font-size: 13px; color: var(--ink-2); }
.map-legend li { display: flex; align-items: center; gap: 10px; }
.lg.zone { width: 16px; height: 16px; border-radius: 50%; border: 1.5px solid var(--accent); background: color-mix(in srgb, var(--accent) 18%, transparent); }
.lg.route { width: 18px; border-top: 1.5px dashed var(--ink-2); }
.pin { display: inline-block; flex: none; }
.pin.sma { width: 14px; height: 14px; background: var(--ink); border: 2px solid var(--surface); border-radius: 3px; box-shadow: 0 0 0 1px var(--ink); }
.pin.sma.ind { background: var(--surface); border-style: dashed; }
.pin.fac { width: 16px; height: 16px; border-radius: 50%; background: var(--c); border: 2px solid var(--surface); box-shadow: 0 0 0 1.5px var(--c); }
.pin.fac.planned { background: var(--surface); border: 3px solid var(--c); box-shadow: none; }
table.data.compact th, table.data.compact td { padding: 5px 8px; font-size: 12.5px; }
.subtabs { position: static; margin-bottom: 16px; }
.rtab { margin-top: 0; }
.sources { margin-top: 16px; }
.leaflet-popup-content { font: 13px/1.45 var(--font); }
.leaflet-container a { color: var(--accent); }

/* ================= model pages ================= */
.model-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; padding-top: 16px; }
.model-head .mh-text { margin: 2px 0 0; color: var(--ink-2); max-width: 95ch; font-size: 13.5px; }
.src-chip { display: inline-block; font-size: 12px; font-weight: 600; padding: 1px 9px; border-radius: 999px; margin-right: 6px; }
.src-chip.pre { background: var(--accent-soft); color: var(--accent); }
.src-chip.run { background: color-mix(in srgb, var(--good) 14%, transparent); color: var(--good-text); }
.stale { align-items: flex-start; }
.stale ul.changes { margin: 6px 0 0; padding-left: 18px; }
.stale ul.changes li { margin: 2px 0; }
.stale ul.changes span { color: var(--ink-2); }
.stale-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.stale-block { display: flex; justify-content: space-between; gap: 14px; align-items: flex-start; flex: 1 1 100%; }
.stale-block + .stale-block { border-top: 1px solid color-mix(in srgb, var(--changed) 35%, transparent); padding-top: 10px; }
.stale .undo { margin-left: auto; }
.inputs-foot.two .primary { flex: 1.2; }
.inputs-foot.two .ghost { flex: 1; }
table.traj tr.off td { opacity: .45; }
.num-unit select { min-width: 84px; }
.progress .ghost.small { padding: 3px 10px; }

@media (max-width: 1280px) {
  .mainnav a { padding: 0 9px; }
  .brand .sub { display: none; }
}
@media (max-width: 1100px) {
  .region-grid { grid-template-columns: 1fr; }
  .model-pick, .steps-home { grid-template-columns: 1fr; }
  .step-card.wide { grid-column: auto; }
}
@media (max-width: 1000px) {
  .mainnav { order: 3; width: 100%; overflow-x: auto; }
  .mainnav a { padding: 8px 10px; }
  .page { padding: 20px 16px 40px; }
  .hero h2 { font-size: 26px; }
  .region-head { flex-direction: column; }
  .map { height: 420px; }
}
.inputs-title h2 { white-space: nowrap; }
.inputs-title select { max-width: 150px; }
.baseline-line { align-items: center; gap: 8px; }
.baseline-line > span:not(.dot) { flex: 1 1 160px; }
.baseline-line .ghost.small { padding: 3px 10px; font-size: 12.5px; }

/* ================= sign-in page ================= */
.auth-page { min-height: 100vh; display: grid; place-items: center; background: var(--page); }
.auth-wrap { width: min(1080px, 100%); display: grid; grid-template-columns: 1.1fr 1fr; gap: 48px; padding: 40px 28px; align-items: center; }
.auth-intro .brand { margin-bottom: 30px; }
.auth-intro .brand h1 { font-size: 18px; }
.auth-intro h2 { font-size: 32px; line-height: 1.15; max-width: 22ch; }
.auth-intro p { color: var(--ink-2); font-size: 15.5px; max-width: 58ch; margin: 14px 0 0; }
.auth-points { margin: 18px 0 0; padding-left: 20px; color: var(--ink-2); }
.auth-points li { margin: 6px 0; }
.auth-points li::marker { color: var(--accent); }
.auth-card { background: var(--surface); border: 1px solid var(--hair); border-top: 3px solid var(--accent); border-radius: var(--radius); padding: 22px 24px 24px; }
.auth-tabs { display: grid; width: 100%; margin-bottom: 18px; }
.auth-form { display: grid; gap: 6px; }
.auth-form.pad { padding: 16px 20px 20px; }
.auth-form label { font-weight: 500; margin-top: 8px; }
.auth-form input, .auth-form textarea {
  font: inherit; color: var(--ink); background: var(--surface); border: 1px solid var(--base); border-radius: var(--radius-sm);
  padding: 8px 10px; min-height: 38px;
}
.auth-form textarea { resize: vertical; }
.auth-form input:focus, .auth-form textarea:focus { outline: 2px solid var(--focus); outline-offset: 0; border-color: transparent; }
.auth-form .primary { margin-top: 14px; min-height: 40px; }
.auth-form .hint { margin: 2px 0 0; }
.auth-form .opt { color: var(--muted); font-weight: 400; }
.auth-msg { margin: 8px 0 0; padding: 8px 12px; border-radius: var(--radius-sm); font-size: 13.5px;
  background: color-mix(in srgb, var(--critical) 10%, var(--surface)); border: 1px solid color-mix(in srgb, var(--critical) 40%, transparent); }
.auth-done h3 { font-size: 20px; margin-bottom: 6px; }
.auth-done p { color: var(--ink-2); margin: 0 0 16px; }

/* ================= account menu ================= */
.user-menu { position: relative; }
.user-menu summary { list-style: none; cursor: pointer; border: 1px solid var(--base); border-radius: var(--radius-sm); padding: 7px 12px; background: var(--surface); }
.user-menu summary::-webkit-details-marker { display: none; }
.user-menu summary::after { content: " ▾"; color: var(--muted); }
.user-menu .menu { position: absolute; right: 0; top: calc(100% + 6px); z-index: 30; min-width: 230px; background: var(--surface);
  border: 1px solid var(--hair); border-radius: var(--radius); box-shadow: 0 8px 24px rgba(0,0,0,.12); padding: 6px; display: grid; }
.user-menu .menu-who { margin: 4px 8px 8px; font-size: 13px; color: var(--ink-2); overflow-wrap: anywhere; }
.user-menu .menu button { text-align: left; background: none; border: 0; padding: 8px 10px; border-radius: var(--radius-sm); cursor: pointer; }
.user-menu .menu button:hover { background: var(--surface-2); }

/* ================= admin ================= */
.status { font-size: 12px; font-weight: 600; padding: 2px 9px; border-radius: 999px; white-space: nowrap; }
.status.st-pending { background: color-mix(in srgb, var(--changed) 16%, transparent); color: var(--changed); }
.status.st-active { background: color-mix(in srgb, var(--good) 14%, transparent); color: var(--good-text); }
.status.st-rejected, .status.st-disabled { background: var(--surface-2); color: var(--muted); }
#adminTable td.actions { white-space: nowrap; }
#adminTable tr.st-pending td { background: color-mix(in srgb, var(--changed) 5%, transparent); }

@media (max-width: 900px) {
  .auth-wrap { grid-template-columns: 1fr; gap: 24px; padding: 24px 16px; }
  .auth-intro h2 { font-size: 24px; }
  .auth-points { display: none; }
}

/* ================= headline ================= */
.title-xl { font-family: var(--font-display); font-weight: 600; font-size: clamp(32px, 3.9vw, 54px); line-height: 1.05;
  letter-spacing: -0.01em; max-width: 21ch; margin: 0; }
.tagline { font-size: 18px; color: var(--ink-2); margin: 18px 0 0; }
.brand-mark.big { width: 52px; height: 52px; color: var(--accent); margin-bottom: 26px; }
.hero { padding: 26px 0 34px; }
.hero .title-xl { max-width: none; }

/* ================= map in the black theme ================= */
:root:not([data-theme="light"]) .leaflet-tile { filter: invert(1) hue-rotate(180deg) brightness(.85) contrast(.92) saturate(.45); }
:root:not([data-theme="light"]) .map { background: #0d1114; }
:root:not([data-theme="light"]) .leaflet-bar a, :root:not([data-theme="light"]) .leaflet-control-layers {
  background: var(--surface-2); color: var(--ink); border-color: var(--hair); }
:root:not([data-theme="light"]) .leaflet-bar a:hover { background: var(--surface-3); }
:root:not([data-theme="light"]) .leaflet-control-layers-toggle { filter: invert(1); }
:root:not([data-theme="light"]) .leaflet-control-attribution { background: rgba(0, 0, 0, .65); color: var(--muted); }
:root:not([data-theme="light"]) .leaflet-popup-content-wrapper, :root:not([data-theme="light"]) .leaflet-popup-tip {
  background: var(--surface-2); color: var(--ink); box-shadow: 0 6px 20px rgba(0, 0, 0, .6); }
.leaflet-container { font-family: var(--font); }

/* ================= frame ================= */
.topbar { background: #000; }
:root[data-theme="light"] .topbar { background: var(--surface); }
.brand h1 { font-size: 20px; letter-spacing: 0; }
.card, .kpis, .side-box, .about-main > section, .scen-card { box-shadow: var(--shadow); }
.auth-wrap { grid-template-columns: 1.25fr 1fr; }
.mo-q { font-size: 14px; }
.step-card .hint { font-size: 13.5px; }
