:root {
  --bg: #f7f7f5; --surface: #ffffff; --ink: #16202b; --muted: #4b5563; --line: #e3e5e2; --line-soft: #f0f1ef;
  --accent: #0f3d3e; --accent-ink: #ffffff; --accent-soft: #e7f2ec; --accent-soft-ink: #1f5f3f;
  --in: #1f7a4d; --out: #c7ccc9; --bar-track: #eceeeb; --chip: #eef1ef; --control: #d5d8d4;
  --warn: #b45309; --warn-ink: #92400e; --link: #1d4ed8; --link-hover: #1e3a8a; --balance-fill: #dce7e3;
  --excluded: #e0a526; --note-bg: #fbf6e9; --note-line: #ecd9a3;
  --font: Inter, system-ui, -apple-system, "Segoe UI", sans-serif; --head: "Space Grotesk", Inter, system-ui, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #111518; --surface: #1a2024; --ink: #e8ebe9; --muted: #a3aab2; --line: #2c3439; --line-soft: #242b30;
    --accent: #5fb3a6; --accent-ink: #0d1a1a; --accent-soft: #1d3a33; --accent-soft-ink: #8fd3c2;
    --in: #3fae76; --out: #4d565b; --bar-track: #262d31; --chip: #262d31; --control: #3a434a;
    --warn: #f0b429; --warn-ink: #f5c75a; --link: #8ab4ff; --link-hover: #b3ccff; --balance-fill: #233a35;
    --excluded: #f0b429; --note-bg: #2a2416; --note-line: #4a3f1f;
  }
}
:root[data-theme="dark"] {
  --bg: #111518; --surface: #1a2024; --ink: #e8ebe9; --muted: #a3aab2; --line: #2c3439; --line-soft: #242b30;
  --accent: #5fb3a6; --accent-ink: #0d1a1a; --accent-soft: #1d3a33; --accent-soft-ink: #8fd3c2;
  --in: #3fae76; --out: #4d565b; --bar-track: #262d31; --chip: #262d31; --control: #3a434a;
  --warn: #f0b429; --warn-ink: #f5c75a; --link: #8ab4ff; --link-hover: #b3ccff; --balance-fill: #233a35;
    --excluded: #f0b429; --note-bg: #2a2416; --note-line: #4a3f1f;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.5 var(--font); min-height: 100vh; display: flex; flex-direction: column; }
a { color: var(--link); }
a:hover { color: var(--link-hover); }
h1, h2, h3 { margin: 0; }
h1, .display { font-family: var(--head); font-weight: 700; letter-spacing: -0.01em; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
.hidden, [hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.wrap { max-width: 1200px; width: 100%; margin: 0 auto; padding-left: 40px; padding-right: 40px; }
.muted { color: var(--muted); }
.num { font-variant-numeric: tabular-nums; }

/* Header and footer */
.site-header { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 16px; padding: 16px 40px; border-bottom: 1px solid var(--line); background: var(--surface); }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); font-family: var(--head); font-weight: 700; font-size: 19px; }
.brand-mark { display: inline-flex; width: 30px; height: 30px; border-radius: 8px; background: var(--accent); color: var(--accent-ink); align-items: center; justify-content: center; font-size: 15px; }
.site-nav { display: flex; flex-wrap: wrap; gap: 24px; font-size: 15px; }
.site-nav a { text-decoration: none; color: var(--muted); }
.site-nav a:hover { color: var(--ink); }
.header-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; font-size: 14px; color: var(--muted); }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 999px; background: var(--accent-soft); color: var(--accent-soft-ink); font-weight: 500; }
.site-footer { margin-top: auto; padding: 24px 40px; border-top: 1px solid var(--line); display: flex; flex-wrap: wrap; justify-content: space-between; gap: 12px; font-size: 14px; color: var(--muted); background: var(--surface); }
.site-footer span:last-child { display: flex; gap: 18px; }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 40px; padding: 0 16px; border-radius: 10px; border: 1px solid var(--control); background: var(--surface); color: var(--ink); font-weight: 500; text-decoration: none; }
.btn:hover { border-color: var(--muted); }
.btn-primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
.btn-primary:hover { border-color: var(--accent); filter: brightness(1.08); }
.btn-round { border-radius: 999px; padding: 0 14px; }
.btn[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }

/* Home */
.hero { padding: 64px 40px 40px; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 48px; align-items: center; }
.hero-copy { display: flex; flex-direction: column; gap: 20px; min-width: 0; }
.eyebrow { margin: 0; font-size: 13px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--accent); }
.hero h1 { font-size: 46px; line-height: 1.1; }
.lede { margin: 0; font-size: 18px; color: var(--muted); max-width: 52ch; }
.checks { margin: 0; padding: 0; list-style: none; display: flex; flex-wrap: wrap; gap: 10px 22px; font-size: 15px; }
.checks li { display: flex; align-items: center; gap: 8px; }
.checks svg { stroke: var(--in); }
.drop-col { min-width: 0; display: flex; flex-direction: column; gap: 14px; }
.drop { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; min-height: 300px; border: 2px dashed var(--accent); border-radius: 16px; background: var(--surface); padding: 32px; text-align: center; cursor: pointer; }
.drop.over { background: var(--accent-soft); }
.drop svg { stroke: var(--accent); }
.drop-title { font-family: var(--head); font-weight: 700; font-size: 22px; }
.drop-note { color: var(--muted); font-size: 15px; }
.drop .btn-primary { border-radius: 999px; min-height: 44px; padding: 0 22px; font-size: 15px; }
.drop input { position: absolute; width: 1px; height: 1px; opacity: 0; overflow: hidden; }
.privacy-line { margin: 0; display: flex; align-items: flex-start; gap: 8px; font-size: 14px; color: var(--muted); }
.privacy-line svg { flex-shrink: 0; margin-top: 2px; stroke: var(--accent); }
.sample-line { margin: 0; font-size: 14px; color: var(--muted); }
.sample-line button { border: 0; padding: 0; background: none; color: var(--link); text-decoration: underline; }
.progress { display: flex; flex-direction: column; gap: 10px; min-height: 300px; border: 1px solid var(--line); border-radius: 16px; background: var(--surface); padding: 24px; }
.progress h2 { font-size: 17px; font-weight: 600; }
.progress ol { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 6px; font-size: 14px; }
.progress li { display: flex; justify-content: space-between; gap: 12px; }
.progress li span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.progress li span:last-child { color: var(--muted); white-space: nowrap; }
.progress li.bad span:last-child { color: var(--warn); }
.section { padding: 32px 40px 48px; display: flex; flex-direction: column; gap: 24px; }
.section h2 { font-family: var(--head); font-weight: 700; font-size: 28px; }
.cards { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 20px; }
.card { display: flex; flex-direction: column; gap: 10px; padding: 24px; border-radius: 14px; background: var(--surface); border: 1px solid var(--line); min-width: 0; }
.card svg { stroke: var(--accent); }
.card h3 { font-size: 18px; font-weight: 600; }
.card p { margin: 0; color: var(--muted); font-size: 15px; }
.pricing { padding: 8px 40px 64px; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
.pricing .card-accent { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.pricing .card-accent p { color: inherit; opacity: 0.85; }

/* Results */
.results { padding: 28px 40px 48px; display: flex; flex-direction: column; gap: 28px; font-size: 15px; }
.results-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-end; gap: 16px; }
.results-head h1 { font-size: 30px; }
.results-head p { margin: 0; color: var(--muted); }
.results-head nav { display: flex; flex-wrap: wrap; gap: 8px; }
.note-warn { color: var(--warn-ink); }
.tiles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.tile { display: flex; flex-direction: column; gap: 4px; padding: 18px 20px; border-radius: 14px; background: var(--surface); border: 1px solid var(--line); min-width: 0; }
.tile span { font-size: 13px; color: var(--muted); }
.tile strong { font-family: var(--head); font-size: 26px; font-weight: 700; font-variant-numeric: tabular-nums; }
.tile .good { color: var(--accent-soft-ink); }
.tile .warn { color: var(--warn); }
.panel { display: flex; flex-direction: column; gap: 14px; padding: 22px; border-radius: 14px; background: var(--surface); border: 1px solid var(--line); min-width: 0; }
.panel h2 { font-size: 17px; font-weight: 600; }
.panel-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 12px; }
.panel-head .legend { display: flex; gap: 14px; font-size: 13px; color: var(--muted); }
.legend i { width: 10px; height: 10px; border-radius: 2px; display: inline-block; margin-right: 6px; }
.panel .foot { margin: 0; font-size: 13px; color: var(--muted); }
.grid-5 { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 16px; }
.grid-5 > .span-3 { grid-column: span 3; }
.grid-5 > .span-2 { grid-column: span 2; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.chart { display: block; width: 100%; height: auto; }
.chart text { fill: var(--muted); font-size: 12px; font-family: var(--font); }
.chart .grid { stroke: var(--line); }
.chart .bar-in { fill: var(--in); }
.chart .bar-out { fill: var(--out); }
.chart .area { fill: var(--balance-fill); }
.chart .trace { fill: none; stroke: var(--accent); stroke-width: 2; }
.cats { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 10px; }
.cats li { display: grid; grid-template-columns: 130px minmax(0, 1fr) 80px; gap: 10px; align-items: center; font-size: 14px; }
.cats .track { height: 10px; border-radius: 999px; background: var(--bar-track); overflow: hidden; display: block; }
.cats .track span { display: block; height: 100%; background: var(--accent); }
.cats .amt { text-align: right; font-variant-numeric: tabular-nums; color: var(--muted); }
.table-box { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
thead tr { color: var(--muted); font-size: 12px; text-align: left; }
th { font-weight: 500; padding: 8px 6px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 9px 6px; border-bottom: 1px solid var(--line-soft); vertical-align: top; }
th.r, td.r { text-align: right; font-variant-numeric: tabular-nums; }
td.credit { color: var(--accent-soft-ink); }
td.date { white-space: nowrap; color: var(--muted); }
td.pg { color: var(--muted); white-space: nowrap; }
.rows-table { min-width: 760px; }
.rows-table td.desc { min-width: 260px; }
.subs-table td:first-child { font-weight: 500; }
.subs-table td:not(:first-child) { white-space: nowrap; }
.cat-select { max-width: 190px; padding: 2px 8px; border-radius: 999px; border: 1px solid transparent; background: var(--chip); font-size: 12px; color: var(--ink); }
.cat-select:hover, .cat-select:focus { border-color: var(--control); }
.rows-tools { display: flex; flex-wrap: wrap; gap: 8px; }
.rows-tools input[type="search"] { min-height: 40px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--control); background: var(--surface); width: 220px; }
.rating { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 22px; border-radius: 14px; background: var(--surface); border: 1px solid var(--line); font-size: 14px; }
.rating .choices { display: flex; flex-wrap: wrap; gap: 8px; }
.warn-line { margin: 0; display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--warn-ink); }
.warn-line svg { stroke: var(--warn); flex-shrink: 0; }
.empty { color: var(--muted); font-size: 14px; margin: 0; }

/* Lender view */
.lender-intro { max-width: 80ch; }
.lender-tiles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.lender-tiles .tile { gap: 6px; padding: 20px 22px; }
.lender-tiles .tile strong { font-size: 34px; }
.lender-tiles .tile strong small { font-size: 16px; font-weight: 500; color: var(--muted); }
.tile-accent { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.tile-accent span, .tile-accent strong small { color: inherit; opacity: 0.85; }
.tile-accent a { color: inherit; }
.tile-controls { gap: 10px; }
.tile-controls label { font-size: 13px; color: var(--muted); }
.slider-row { display: flex; align-items: center; gap: 12px; }
.slider-row input { flex: 1; min-width: 0; accent-color: var(--accent); }
.lender-tiles .tile .slider-row strong { min-width: 44px; text-align: right; font: 600 16px var(--font); }
.tile-controls select { min-height: 40px; padding: 0 10px; border-radius: 10px; border: 1px solid var(--control); background: var(--surface); max-width: 100%; }
.chart .bar-ok { fill: var(--in); }
.chart .bar-ex { fill: var(--excluded); }
.chart g[data-month] { cursor: pointer; }
.chart g[data-month]:hover rect { opacity: 0.85; }
.arith { margin: 0; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px 16px; font-size: 14px; }
.arith dt { color: var(--muted); }
.arith dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; }
.arith .total { font-weight: 600; color: var(--ink); padding-top: 6px; border-top: 1px solid var(--line); }
.flags { margin: 0; padding: 0; list-style: none; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.flag { display: grid; grid-template-columns: 10px minmax(0, 1fr); gap: 12px; padding: 14px 16px; border-radius: 12px; border: 1px solid var(--line); background: var(--bg); }
.flag i { display: block; border-radius: 999px; background: var(--in); }
.flag.warn i { background: var(--excluded); }
.flag div { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.flag .flag-head { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.flag strong { font-size: 15px; font-weight: 600; }
.flag .level { font-size: 12px; color: var(--muted); white-space: nowrap; }
.flag p { margin: 0; font-size: 14px; color: var(--muted); }
.panel-text { margin: 0; font-size: 14px; color: var(--muted); }
.panel .btn { align-self: flex-start; min-height: 44px; padding: 0 18px; }
.panel-note { background: var(--note-bg); border-color: var(--note-line); }
.panel-note .btn { background: transparent; border-color: var(--note-line); }
.rules { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 6px; font-size: 14px; color: var(--muted); }
.rules strong { color: var(--ink); font-weight: 600; }
.disclaimer { margin: 0; font-size: 13px; color: var(--muted); }

/* Simple pages */
.page { padding: 48px 40px 64px; max-width: 760px; display: flex; flex-direction: column; gap: 16px; }
.page h2 { font-size: 22px; font-family: var(--head); margin-top: 12px; }
.page ul { margin: 0; padding-left: 22px; }
.page h1 { font-size: 34px; }
.page p { margin: 0; }
.draft { display: inline-block; padding: 2px 10px; border-radius: 999px; background: var(--chip); font-size: 13px; color: var(--muted); }

@media (max-width: 1024px) {
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .lender-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-5 > .span-3, .grid-5 > .span-2 { grid-column: span 5; }
}
@media (max-width: 760px) {
  .wrap, .site-header, .site-footer, .hero, .section, .pricing, .results, .page { padding-left: 16px; padding-right: 16px; }
  .hero { grid-template-columns: minmax(0, 1fr); gap: 28px; padding-top: 32px; }
  .hero h1 { font-size: 34px; }
  .cards, .pricing, .grid-2, .tiles, .lender-tiles, .flags { grid-template-columns: minmax(0, 1fr); }
  .lender-tiles .tile strong { font-size: 28px; }
  .results-head h1 { font-size: 24px; }
  .cats li { grid-template-columns: 100px minmax(0, 1fr) 72px; }
  .rows-tools input[type="search"] { width: 100%; }
  .site-nav { gap: 14px; font-size: 14px; }
}
