:root {
  --bg: #f6f7f5;
  --surface: #ffffff;
  --ink: #1b211d;
  --muted: #5b655e;
  --line: #d9ded9;
  --accent: #1f6b4a;
  --accent-ink: #ffffff;
  --danger: #a3261b;
  --danger-bg: #fbeceb;
  --key-bg: #eef3ef;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121614;
    --surface: #1a201c;
    --ink: #e6ebe7;
    --muted: #9aa69e;
    --line: #2d3530;
    --accent: #5fbf8f;
    --accent-ink: #0e1511;
    --danger: #f2a39b;
    --danger-bg: #3a1f1c;
    --key-bg: #202a24;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
.bar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 12px 16px; background: var(--surface); border-bottom: 1px solid var(--line);
}
.mark { font-weight: 650; letter-spacing: .01em; }
.mark .sub { color: var(--muted); font-weight: 500; }
.who { color: var(--muted); font-size: 14px; margin-right: 8px; }
main { margin: 40px auto; padding: 0 16px; }
main.narrow { max-width: 420px; }
main.wide { max-width: 960px; }
h1 { font-size: 24px; line-height: 1.25; margin: 0 0 16px; text-wrap: balance; }
p { margin: 0 0 16px; max-width: 65ch; }
.stack { display: grid; gap: 16px; margin: 0 0 20px; }
label { display: grid; gap: 6px; font-size: 14px; font-weight: 600; }
input {
  font: inherit; font-weight: 400; padding: 10px 12px; border-radius: 6px;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
}
input:focus-visible, button:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
input.code { font-variant-numeric: tabular-nums; letter-spacing: .3em; font-size: 22px; text-align: center; }
button {
  font: inherit; font-weight: 600; padding: 10px 16px; border-radius: 6px; border: 0;
  background: var(--accent); color: var(--accent-ink); cursor: pointer;
}
button.link { background: none; color: var(--accent); padding: 0; font-weight: 500; }
.inline { display: flex; align-items: center; margin: 0; }
.error { background: var(--danger-bg); color: var(--danger); padding: 10px 12px; border-radius: 6px; }
.note { color: var(--muted); font-size: 14px; }
.steps { padding-left: 20px; display: grid; gap: 12px; margin: 0 0 20px; }
.key {
  margin: 8px 0 0; padding: 12px; border-radius: 6px; background: var(--key-bg);
  font: 600 18px/1.4 ui-monospace, "SF Mono", Menlo, Consolas, monospace; letter-spacing: .06em;
  word-break: break-word; user-select: all;
}
.facts { display: grid; grid-template-columns: max-content 1fr; gap: 8px 24px; margin: 0 0 24px; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; }
@media (max-width: 480px) { .facts { grid-template-columns: 1fr; } .facts dt { margin-top: 8px; } }

/* phase 1 screens */
:root { --ok: #1f6b4a; --ok-bg: #e3efe8; --warn: #8a5a00; --warn-bg: #fbf1dc; --bad: #a3261b; --bad-bg: #fbeceb; --sunk: #eef1ee; --soft: #e3efe8; }
@media (prefers-color-scheme: dark) {
  :root { --ok: #7fd3a8; --ok-bg: #1d2d24; --warn: #f0c56a; --warn-bg: #33291a; --bad: #f2a39b; --bad-bg: #3a1f1c; --sunk: #151a17; --soft: #1d2d24; }
}
.bar { flex-wrap: wrap; }
.tabs { display: flex; gap: 4px; flex-wrap: wrap; flex: 1; }
.tab { color: var(--muted); text-decoration: none; padding: 6px 10px; border-radius: 6px; font-size: 14px; display: inline-flex; gap: 6px; align-items: center; }
.tab.on { background: var(--soft); color: var(--ink); font-weight: 600; }
.tab:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.tab .n { background: var(--accent); color: var(--accent-ink); border-radius: 999px; font-size: 12px; padding: 0 7px; font-variant-numeric: tabular-nums; }
main.wide { display: grid; gap: 24px; }
.head { display: grid; gap: 6px; }
.head .sub { margin: 0; }
.sub { color: var(--muted); font-size: 14px; margin: 0; }
h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 0 0 8px; font-weight: 650; display: flex; align-items: center; gap: 8px; }
h2 .count { background: var(--sunk); color: var(--ink); border-radius: 999px; padding: 0 8px; font-variant-numeric: tabular-nums; letter-spacing: 0; }
.list { list-style: none; margin: 0; padding: 0; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; }
.item { display: grid; grid-template-columns: 4px minmax(0, 1fr) auto; gap: 0 14px; padding: 12px 14px 12px 0; border-top: 1px solid var(--line); align-items: center; }
.item:first-child { border-top: 0; }
.stripe { align-self: stretch; border-radius: 0 3px 3px 0; background: var(--line); }
.stripe.warn { background: var(--warn); } .stripe.bad { background: var(--bad); } .stripe.act { background: var(--accent); } .stripe.ok { background: var(--ok); }
.what { min-width: 0; display: grid; gap: 2px; }
.what b { font-weight: 600; }
.meta { color: var(--muted); font-size: 13px; }
.amt { font-variant-numeric: tabular-nums; font-weight: 650; white-space: nowrap; }
.empty { color: var(--muted); font-size: 14px; background: var(--surface); border: 1px dashed var(--line); border-radius: 8px; padding: 12px 14px; margin: 0; }
.problems { margin: 6px 0 0; padding-left: 18px; color: var(--bad); font-size: 13px; display: grid; gap: 2px; }
@media (max-width: 560px) { .item { grid-template-columns: 4px minmax(0, 1fr); } .amt { grid-column: 2; margin-top: 6px; } }
.tablewrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; }
table { width: 100%; border-collapse: collapse; font-size: 14px; min-width: 520px; }
th, td { text-align: left; padding: 10px 12px; border-top: 1px solid var(--line); vertical-align: top; }
thead th { border-top: 0; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 650; background: var(--sunk); }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.big { font-size: 17px; font-weight: 650; }
.muted { color: var(--muted); font-weight: 500; font-size: 14px; }
.badnum { color: var(--bad); }
.acct { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 12px; color: var(--muted); }
.chip { display: inline-flex; padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 650; letter-spacing: 0; text-transform: none; }
.chip.ok { background: var(--ok-bg); color: var(--ok); } .chip.bad { background: var(--bad-bg); color: var(--bad); }
.equation { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 16px; display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px 14px; margin-bottom: 8px; }
.term { display: grid; gap: 2px; }
.term .k { font-size: 12px; color: var(--muted); }
.term .v { font-size: 19px; font-weight: 650; font-variant-numeric: tabular-nums; }
.op { font-size: 19px; color: var(--muted); }
.term.result .v { color: var(--ok); } .term.result.short .v { color: var(--bad); }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 16px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 14px; display: grid; gap: 6px; align-content: start; }
.figure { font-size: 24px; font-weight: 650; font-variant-numeric: tabular-nums; margin: 0; }
.row { display: flex; justify-content: space-between; gap: 12px; font-size: 14px; }
.row span:last-child { font-variant-numeric: tabular-nums; font-weight: 600; white-space: nowrap; }

/* phase 2: decisions */
.what a, .back { color: inherit; text-decoration: underline; text-decoration-color: var(--line); text-underline-offset: 3px; }
.what a:hover, .back:hover { text-decoration-color: var(--accent); }
.what a:focus-visible, .back:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 2px; }
.back { color: var(--muted); }
.state { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px; }
.caution { background: var(--warn-bg); color: var(--warn); padding: 10px 12px; border-radius: 6px; }
.facts dd { overflow-wrap: anywhere; }
textarea {
  font: inherit; font-weight: 400; padding: 10px 12px; border-radius: 6px; resize: vertical;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
}
textarea:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.decide { max-width: 420px; }
.verdicts { display: flex; flex-wrap: wrap; gap: 12px; }
button.secondary { background: var(--surface); color: var(--ink); border: 1px solid var(--line); }
.lookup { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px; max-width: 520px; }
.lookup label { flex: 1 1 240px; }
.facts.match { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px; margin: 0; max-width: 520px; }
select {
  font: inherit; font-weight: 400; padding: 10px 12px; border-radius: 6px;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
}
select:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
fieldset.checks { border: 1px solid var(--line); border-radius: 6px; padding: 10px 12px; margin: 0; display: flex; flex-wrap: wrap; gap: 8px 16px; }
fieldset.checks legend { font-size: 14px; font-weight: 600; padding: 0 4px; }
label.check { display: inline-flex; flex-direction: row; align-items: center; gap: 6px; font-weight: 400; }
