:root {
  --bg: #f2f4f7;
  --surface: #ffffff;
  --surface-2: #e8edf2;
  --fg: #141a21;
  --muted: #586472;
  --line: #d3dae2;
  --accent: #0b5d8a;
  --accent-fg: #ffffff;
  --accent-soft: #e2eef6;
  --good: #1e7a3e;
  --warn: #a35a0a;
  --bad: #b3261e;
  --warn-soft: #fbf1e3;
  --s1: #2a78d6;
  --s2: #eb6834;
  --s3: #1baf7a;
  --s4: #eda100;
  --font-body: 'IBM Plex Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-display: 'IBM Plex Sans Condensed', 'IBM Plex Sans', system-ui, sans-serif;
  --font-mono: 'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  --radius: 6px;
  --shadow: 0 1px 2px rgba(20, 26, 33, 0.06);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1419; --surface: #171e26; --surface-2: #202a34; --fg: #e8edf2; --muted: #9aa7b4; --line: #2b3843;
    --accent: #4aa3d8; --accent-fg: #0b1620; --accent-soft: #1b2f3d; --good: #4cc271; --warn: #e2a24a; --bad: #ef6b63; --warn-soft: #3a2c14;
    --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500; --shadow: none; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0f1419; --surface: #171e26; --surface-2: #202a34; --fg: #e8edf2; --muted: #9aa7b4; --line: #2b3843;
  --accent: #4aa3d8; --accent-fg: #0b1620; --accent-soft: #1b2f3d; --good: #4cc271; --warn: #e2a24a; --bad: #ef6b63; --warn-soft: #3a2c14;
  --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500; --shadow: none; color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--fg); font-family: var(--font-body); font-size: 15px; line-height: 1.5; }
h1, h2, h3, h4 { font-family: var(--font-display); text-wrap: balance; margin: 0; line-height: 1.15; }
h2 { font-size: 1.55rem; margin-bottom: 0.35rem; }
h3 { font-size: 1.1rem; margin: 1.4rem 0 0.5rem; }
p { margin: 0.4rem 0; }
.lede { color: var(--muted); max-width: 62ch; }
code, .mono { font-family: var(--font-mono); font-size: 0.92em; }
a { color: var(--accent); }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.top { background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: env(safe-area-inset-top, 0px); z-index: 5; }
.top-inner { max-width: 1320px; margin: 0 auto; padding: 0.7rem 16px; display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 0.8rem; }
.brand h1 { font-size: 1.25rem; letter-spacing: 0.01em; }
.brand p { margin: 0; color: var(--muted); font-size: 0.85rem; }
.mark { display: block; width: auto; height: 32px; border-radius: 4px; flex: none; }
.top-status { font-family: var(--font-mono); font-size: 0.8rem; color: var(--muted); }
.project { display: flex; align-items: center; gap: 0.4rem; flex-wrap: wrap; margin-left: auto; }
.project input[type="text"] { width: 15rem; max-width: 100%; padding: 0.35rem 0.55rem; font-size: 0.88rem; }
.project .pid { font-family: var(--font-mono); font-size: 0.75rem; color: var(--muted); }
.project .msg { font-size: 0.8rem; color: var(--muted); flex-basis: 100%; text-align: right; }
@media (max-width: 700px) { .project { margin-left: 0; width: 100%; } .project input[type="text"] { flex: 1; } .project .msg { text-align: left; } }

.shell { max-width: 1320px; margin: 0 auto; padding: 1.2rem 16px 2rem; display: grid; grid-template-columns: 148px minmax(0, 1fr) 300px; gap: 1.2rem; align-items: start; }
@media (max-width: 1000px) { .shell { grid-template-columns: minmax(0, 1fr); } }

.stepper { display: flex; flex-direction: column; gap: 2px; position: sticky; top: calc(env(safe-area-inset-top, 0px) + 72px); }
.stepper button { text-align: left; background: none; border: 0; border-left: 3px solid transparent; padding: 0.5rem 0.55rem; border-radius: 0 var(--radius) var(--radius) 0; cursor: pointer; color: var(--muted); display: grid; grid-template-columns: 1rem 1fr; gap: 0.4rem; align-items: baseline; white-space: nowrap; }
.stepper button .n { font-family: var(--font-mono); font-size: 0.78rem; }
.stepper button .l { font-weight: 500; }
.stepper button.done { color: var(--fg); }
.stepper button.active { color: var(--accent); border-left-color: var(--accent); background: var(--accent-soft); }
.stepper button:disabled { cursor: not-allowed; opacity: 0.55; }
@media (max-width: 1000px) {
  .stepper { position: static; flex-direction: row; overflow-x: auto; gap: 0.3rem; padding-bottom: 0.2rem; }
  .stepper button { border-left: 0; border-bottom: 3px solid transparent; border-radius: var(--radius) var(--radius) 0 0; white-space: nowrap; grid-template-columns: auto auto; }
  .stepper button.active { border-bottom-color: var(--accent); }
}

.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.4rem 1.4rem 1.6rem; box-shadow: var(--shadow); min-width: 0; }
.rail { position: sticky; top: calc(env(safe-area-inset-top, 0px) + 72px); display: flex; flex-direction: column; gap: 0.8rem; min-width: 0; }
@media (max-width: 1000px) { .rail { position: static; } }
.rail .card { padding: 0.9rem 1rem; }
.rail h4 { font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); margin-bottom: 0.4rem; }
.rail dl { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: 0.15rem 0.7rem; font-size: 0.88rem; }
.rail dt { color: var(--muted); }
.rail dd { margin: 0; font-variant-numeric: tabular-nums; min-width: 0; overflow-wrap: anywhere; }
.rail .big { font-family: var(--font-display); font-size: 1.6rem; font-weight: 700; font-variant-numeric: tabular-nums; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1.1rem; }
.card.soft { background: var(--surface-2); border-color: transparent; }
.card.warn { background: var(--warn-soft); border-color: transparent; }
.note { color: var(--muted); font-size: 0.86rem; }
.flag { color: var(--warn); font-size: 0.86rem; }
.ok { color: var(--good); }
.bad { color: var(--bad); }

fieldset { border: 0; padding: 0; margin: 1rem 0 0; min-width: 0; }
legend, label.lab { font-weight: 600; font-size: 0.86rem; letter-spacing: 0.01em; display: block; margin-bottom: 0.35rem; }
.field { display: flex; flex-direction: column; gap: 0.25rem; min-width: 0; }
.field .help { color: var(--muted); font-size: 0.8rem; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 0.9rem 1rem; margin-top: 1rem; }
.grid3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 0.9rem 1rem; margin-top: 1rem; }
input[type="number"], input[type="text"], select { width: 100%; padding: 0.45rem 0.55rem; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); font-variant-numeric: tabular-nums; }
input[type="number"] { font-family: var(--font-mono); }
input[type="file"] { max-width: 100%; }
.unit { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 0.4rem; }
.unit span { color: var(--muted); font-size: 0.82rem; white-space: nowrap; }
.inline { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }
.check { display: flex; align-items: flex-start; gap: 0.5rem; padding: 0.45rem 0; }
.check input { margin-top: 0.3rem; }
.check .d { color: var(--muted); font-size: 0.82rem; display: block; }

.choices { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 0.6rem; margin-top: 0.3rem; }
.choice { position: relative; border: 1px solid var(--line); border-radius: var(--radius); padding: 0.7rem 0.8rem 0.7rem 2.2rem; cursor: pointer; background: var(--surface); }
.choice input { position: absolute; left: 0.8rem; top: 0.9rem; }
.choice b { display: block; font-weight: 600; }
.choice small { color: var(--muted); display: block; margin-top: 0.15rem; line-height: 1.35; }
.choice:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.choice.wide { grid-column: 1 / -1; }

details { margin-top: 1rem; border: 1px solid var(--line); border-radius: var(--radius); padding: 0.5rem 0.9rem; }
summary { cursor: pointer; font-weight: 600; font-size: 0.9rem; }

table { border-collapse: collapse; width: 100%; font-size: 0.88rem; }
.tablewrap { overflow-x: auto; margin-top: 0.6rem; }
th, td { text-align: left; padding: 0.4rem 0.55rem; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-weight: 600; color: var(--muted); font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.06em; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; font-family: var(--font-mono); font-size: 0.85rem; }
tr.total td { font-weight: 700; border-top: 2px solid var(--fg); }
tr.sub td { color: var(--muted); }
table.reqs { min-width: 42rem; font-size: 0.84rem; line-height: 1.4; table-layout: fixed; }
table.reqs th:first-child, table.reqs td:first-child { width: 6.2rem; padding-left: 0; padding-right: 0.4rem; font-size: 0.8rem; }
table.reqs th.sel, table.reqs td.sel { background: var(--accent-soft); }
table.reqs th.sel { color: var(--accent); }

.actions { display: flex; gap: 0.6rem; justify-content: space-between; align-items: center; margin-top: 1.6rem; flex-wrap: wrap; }
.btn { border: 1px solid var(--line); background: var(--surface); padding: 0.55rem 1rem; border-radius: var(--radius); cursor: pointer; font-weight: 600; }
.btn.primary { background: var(--accent); color: var(--accent-fg); border-color: var(--accent); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn.small { padding: 0.3rem 0.6rem; font-size: 0.82rem; font-weight: 500; }

.tabs { display: flex; gap: 0.2rem; border-bottom: 1px solid var(--line); margin-top: 1rem; }
.tabs button { background: none; border: 0; border-bottom: 3px solid transparent; padding: 0.5rem 0.8rem; cursor: pointer; color: var(--muted); font-weight: 600; }
.tabs button.active { color: var(--accent); border-bottom-color: var(--accent); }
.tabpane { padding-top: 1rem; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.seg button { background: var(--surface); border: 0; padding: 0.4rem 0.8rem; cursor: pointer; color: var(--muted); font-weight: 600; }
.seg button + button { border-left: 1px solid var(--line); }
.seg button.active { background: var(--accent-soft); color: var(--accent); }
input[type="range"] { width: 100%; margin: 0.35rem 0 0; accent-color: var(--accent); }
.figure { font-family: var(--font-mono); font-size: 1.15rem; padding: 0.35rem 0; }
.billgrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(300px, 100%), 1fr)); gap: 0.45rem 1.4rem; margin-top: 1rem; }
.billrow { display: grid; grid-template-columns: 2.4rem minmax(6.5rem, 8rem) minmax(0, 1fr); align-items: center; gap: 0.5rem; }
.billrow > span { color: var(--muted); font-size: 0.85rem; }
.billrow input[type="range"] { margin: 0; }

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 0.7rem; margin-top: 1rem; }
.kpi { background: var(--surface-2); border-radius: var(--radius); padding: 0.7rem 0.9rem; min-width: 0; }
.kpi .k { color: var(--muted); font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.06em; }
.kpi .v { font-family: var(--font-display); font-size: 1.45rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.kpi .s { color: var(--muted); font-size: 0.8rem; }
.hero { background: var(--accent-soft); border-radius: var(--radius); padding: 1.1rem 1.3rem; margin-top: 1rem; display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 0.8rem; }
.hero .k { color: var(--muted); font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.06em; }
.hero .v { font-family: var(--font-display); font-size: 2.1rem; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.1; }
.hero .s { color: var(--muted); font-size: 0.85rem; }

.chart { position: relative; margin-top: 0.6rem; }
.chart svg { width: 100%; height: auto; display: block; max-width: 100%; }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart .axis { stroke: var(--muted); stroke-width: 1; }
.chart .cross { stroke: var(--muted); stroke-width: 1; stroke-dasharray: 3 3; }
.chart .tick { fill: var(--muted); font-size: 11px; font-family: var(--font-mono); }
.chart .tip { position: absolute; pointer-events: none; background: var(--surface); border: 1px solid var(--line); border-radius: 4px; padding: 0.35rem 0.55rem; font-size: 0.8rem; box-shadow: var(--shadow); font-variant-numeric: tabular-nums; z-index: 2; white-space: nowrap; }
.chart .tip i, .legend i { display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin-right: 0.35rem; }
.legend { display: flex; gap: 1rem; flex-wrap: wrap; font-size: 0.8rem; color: var(--muted); margin-top: 0.3rem; }
.legend span { display: inline-flex; align-items: center; }

.progress { margin-top: 1rem; padding: 1rem; border: 1px dashed var(--line); border-radius: var(--radius); font-family: var(--font-mono); font-size: 0.85rem; }
.progress .bar { height: 6px; background: var(--surface-2); border-radius: 3px; overflow: hidden; margin-top: 0.5rem; }
.progress .bar i { display: block; height: 100%; width: 30%; background: var(--accent); animation: slide 1.2s infinite ease-in-out; }
@keyframes slide { 0% { margin-left: -30%; } 100% { margin-left: 100%; } }
@media (prefers-reduced-motion: reduce) { .progress .bar i { animation: none; width: 100%; } }

.foot { max-width: 1320px; margin: 0 auto; padding: 0 16px 2rem; color: var(--muted); font-size: 0.8rem; }
ul.tight { margin: 0.3rem 0; padding-left: 1.2rem; }
ul.tight li { margin: 0.2rem 0; }
.pill { display: inline-block; padding: 0.1rem 0.5rem; border-radius: 999px; background: var(--surface-2); font-size: 0.75rem; font-family: var(--font-mono); }
