/* Layout idea: one narrow column, inputs on top, verdict + tiles, chart, then the year-by-year ledger. */
:root {
  --bg: #f4f6f4;
  --surface: #ffffff;
  --ink: #17231f;
  --muted: #5d6b65;
  --line: #dbe2de;
  --accent: #0e6b58;
  --accent-soft: #e0f0eb;
  --warn: #b45309;
  --warn-soft: #fdf1df;
  --bad: #b3261e;
  --bad-soft: #fbe7e5;
  --good: #1b7a3d;
  --font-body: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-num: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #101816;
    --surface: #17211e;
    --ink: #e7efeb;
    --muted: #9bada5;
    --line: #2a3a35;
    --accent: #4fc3a4;
    --accent-soft: #1b3730;
    --warn: #f0a84b;
    --warn-soft: #3a2c14;
    --bad: #ff8a80;
    --bad-soft: #3d1f1d;
    --good: #6fd391;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #101816;
  --surface: #17211e;
  --ink: #e7efeb;
  --muted: #9bada5;
  --line: #2a3a35;
  --accent: #4fc3a4;
  --accent-soft: #1b3730;
  --warn: #f0a84b;
  --warn-soft: #3a2c14;
  --bad: #ff8a80;
  --bad-soft: #3d1f1d;
  --good: #6fd391;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
}
main { max-width: 900px; margin: 0 auto; padding: 24px 16px 56px; display: flex; flex-direction: column; gap: 20px; }
h1 { font-size: 1.6rem; line-height: 1.2; margin: 0; font-weight: 600; text-wrap: balance; }
h2 { font-size: 1.05rem; margin: 0 0 12px; font-weight: 600; text-wrap: balance; }
.sub { color: var(--muted); margin: 6px 0 0; max-width: 62ch; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 16px; min-width: 0; }

/* inputs */
.grid-in { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field label { font-size: 0.85rem; font-weight: 500; color: var(--muted); }
.field .hint { font-size: 0.78rem; color: var(--muted); }
select, input[type="number"] {
  width: 100%;
  font: inherit;
  font-family: var(--font-num);
  font-weight: 500;
  color: var(--ink);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  min-height: 44px;
}
select:focus-visible, input:focus-visible, button:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 1px;
}
.rate-line { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 0.82rem; color: var(--muted); }
.rate-line strong { color: var(--ink); font-family: var(--font-num); }

.presets { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.presets span { font-size: 0.82rem; color: var(--muted); align-self: center; }
button.chip {
  font: inherit; font-size: 0.85rem; font-weight: 500;
  color: var(--ink); background: var(--bg);
  border: 1px solid var(--line); border-radius: 999px;
  padding: 8px 14px; min-height: 40px; cursor: pointer;
}
button.chip:hover { border-color: var(--accent); }
button.chip[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }

/* verdict */
.notes { display: flex; flex-direction: column; gap: 8px; }
.note { border-radius: 8px; padding: 10px 14px; font-size: 0.92rem; border-left: 4px solid var(--accent); background: var(--accent-soft); }
.note.warn { border-left-color: var(--warn); background: var(--warn-soft); }
.note.bad { border-left-color: var(--bad); background: var(--bad-soft); }

/* tiles */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 14px; min-width: 0; }
.tile .k { font-size: 0.78rem; color: var(--muted); }
.tile .v { font-family: var(--font-num); font-weight: 600; font-size: 1.25rem; margin-top: 2px; overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }
.tile .s { font-size: 0.76rem; color: var(--muted); margin-top: 2px; }
.tile.hero { background: var(--accent-soft); border-color: var(--accent); }
.tile.hero .v { color: var(--accent); }
.neg { color: var(--bad) !important; }

/* chart */
.legend { display: flex; flex-wrap: wrap; gap: 14px; font-size: 0.82rem; color: var(--muted); margin-bottom: 8px; }
.legend i { display: inline-block; width: 18px; height: 3px; border-radius: 2px; vertical-align: middle; margin-right: 6px; }
svg.chart { width: 100%; height: auto; display: block; }
svg.chart text { fill: var(--muted); font-family: var(--font-num); font-size: 11px; }
svg.chart .grid { stroke: var(--line); stroke-width: 1; }
svg.chart .l-asb { stroke: var(--accent); fill: none; stroke-width: 2.5; stroke-linejoin: round; }
svg.chart .l-loan { stroke: var(--warn); fill: none; stroke-width: 2.5; stroke-linejoin: round; }
svg.chart .a-asb { fill: var(--accent); opacity: 0.1; }
svg.chart .dot-asb { fill: var(--accent); }
svg.chart .dot-loan { fill: var(--warn); }
svg.chart text.end-asb { fill: var(--accent); font-weight: 600; }

/* tables */
.scroll { overflow-x: auto; border: 1px solid var(--line); border-radius: 8px; }
table { border-collapse: collapse; width: 100%; font-size: 0.86rem; font-variant-numeric: tabular-nums; }
th, td { padding: 8px 12px; text-align: right; white-space: nowrap; border-bottom: 1px solid var(--line); }
th { font-weight: 500; color: var(--muted); font-size: 0.76rem; background: var(--bg); position: sticky; top: 0; }
th:first-child, td:first-child { text-align: left; position: sticky; left: 0; background: var(--surface); }
th:first-child { background: var(--bg); }
td { font-family: var(--font-num); }
tr:last-child td { border-bottom: 0; }
tr.sel td { background: var(--accent-soft); }
tr.sel td:first-child { background: var(--accent-soft); }
tr.cross td { box-shadow: inset 0 0 0 0 transparent; }
td.pos { color: var(--good); }
td.neg { color: var(--bad); }
.table-cap { font-size: 0.8rem; color: var(--muted); margin: 8px 0 0; }
.ledger { max-height: 520px; overflow-y: auto; }

.fine { font-size: 0.8rem; color: var(--muted); }
.fine ul { margin: 6px 0 0; padding-left: 18px; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* tabs */
.tabs { display: flex; gap: 4px; padding: 4px; background: var(--surface); border: 1px solid var(--line); border-radius: 999px; width: fit-content; max-width: 100%; }
.tab {
  font: inherit; font-size: 0.92rem; font-weight: 500;
  color: var(--muted); background: transparent;
  border: 0; border-radius: 999px;
  padding: 8px 18px; min-height: 40px; cursor: pointer;
}
.tab:hover { color: var(--ink); }
.tab[aria-selected="true"] { background: var(--accent-soft); color: var(--accent); }
.tab:focus-visible { outline: 3px solid var(--accent); outline-offset: 1px; }
.panel { display: flex; flex-direction: column; gap: 20px; min-width: 0; }
.panel[hidden] { display: none; }
.sub-tight { margin: -4px 0 14px; }
svg.chart .l-dep { stroke: var(--muted); fill: none; stroke-width: 2; stroke-dasharray: 5 4; stroke-linejoin: round; }
