/* TaxSane design system. One file shared by the app and the landing page.
   Themes are plain colour tokens: test/theme.test.js checks every pair for WCAG contrast. */

/* ---------- themes ---------- */
:root, [data-theme="paper"] {
  --bg:#f6f2ea; --surface:#fffdf8; --surface-2:#efe9dd; --ink:#1f2421; --ink-2:#555b55; --line:#ddd5c4; --edge:#8a8478;
  --accent:#0f5c45; --accent-ink:#ffffff; --accent-soft:#dcebe3; --accent-text:#0f5c45;
  --pos:#0b6b3a; --neg:#a3261b; --warn:#8a4b00; --warn-soft:#f6e6c8; --neg-soft:#f7ddd9; --focus:#1a4fd0;
  --chart-a:#0f5c45; --chart-b:#8a6a3b;
  color-scheme: light;
}
[data-theme="harbour"] {
  --bg:#eaf1f6; --surface:#fbfdff; --surface-2:#dde8f0; --ink:#12263a; --ink-2:#465a6e; --line:#c5d3df; --edge:#6f8397;
  --accent:#0b4f7a; --accent-ink:#ffffff; --accent-soft:#d3e5f2; --accent-text:#0b4f7a;
  --pos:#0a6a4a; --neg:#a8261f; --warn:#8a4b00; --warn-soft:#f6e6c8; --neg-soft:#f7ddd9; --focus:#b4470b;
  --chart-a:#0b4f7a; --chart-b:#a0601a;
  color-scheme: light;
}
[data-theme="bloom"] {
  --bg:#f6f0fb; --surface:#fffcff; --surface-2:#ebe0f5; --ink:#2a1838; --ink-2:#5d4b75; --line:#d9c9e8; --edge:#85709c;
  --accent:#6b2fb3; --accent-ink:#ffffff; --accent-soft:#e7d9f5; --accent-text:#6b2fb3;
  --pos:#0b6b3a; --neg:#b3261e; --warn:#8a4b00; --warn-soft:#f6e6c8; --neg-soft:#f7ddd9; --focus:#0057d9;
  --chart-a:#6b2fb3; --chart-b:#a3427b;
  color-scheme: light;
}
[data-theme="slate"] {
  --bg:#12161b; --surface:#1a2027; --surface-2:#232b34; --ink:#e8edf2; --ink-2:#a7b2bf; --line:#303a45; --edge:#7d8a99;
  --accent:#5ec59b; --accent-ink:#08150f; --accent-soft:#1d3a31; --accent-text:#7fd9b5;
  --pos:#62d49a; --neg:#ff9188; --warn:#f0b45a; --warn-soft:#3a2d14; --neg-soft:#3d1f1d; --focus:#8ab4ff;
  --chart-a:#5ec59b; --chart-b:#9aa8b8;
  color-scheme: dark;
}
[data-theme="ember"] {
  --bg:#1b1512; --surface:#251d19; --surface-2:#31261f; --ink:#f3e9df; --ink-2:#bfb0a2; --line:#44352b; --edge:#8f7d6c;
  --accent:#f2a444; --accent-ink:#231607; --accent-soft:#43301a; --accent-text:#f5b560;
  --pos:#8fd694; --neg:#ff9a8a; --warn:#ffc266; --warn-soft:#41301a; --neg-soft:#43221e; --focus:#ffd27a;
  --chart-a:#f2a444; --chart-b:#b59a85;
  color-scheme: dark;
}
[data-theme="contrast"] {
  --bg:#000000; --surface:#000000; --surface-2:#161616; --ink:#ffffff; --ink-2:#ebebeb; --line:#ffffff; --edge:#ffffff;
  --accent:#ffe600; --accent-ink:#000000; --accent-soft:#1c1a00; --accent-text:#ffe600;
  --pos:#7dff9b; --neg:#ff9a9a; --warn:#ffd166; --warn-soft:#2a2000; --neg-soft:#2b0000; --focus:#00e5ff;
  --chart-a:#ffe600; --chart-b:#ffffff;
  color-scheme: dark;
}

/* ---------- base ---------- */
:root {
  --font-ui: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-display: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Charter, Georgia, serif;
  --r: 0.9rem; --r-sm: 0.55rem; --gap: 1.25rem; --pad: 1.25rem; --tap: 2.75rem;
}
html[data-size="l"] { font-size: 112.5%; }
html[data-size="xl"] { font-size: 125%; }
html[data-density="compact"] { --gap: 0.8rem; --pad: 0.9rem; --tap: 2.5rem; }
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: 1rem; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 1rem/1.55 var(--font-ui); -webkit-font-smoothing: antialiased; }
h1, h2, h3 { margin: 0; line-height: 1.15; font-weight: 600; }
h1 { font: 600 clamp(1.7rem, 1.25rem + 1.8vw, 2.5rem)/1.1 var(--font-display); letter-spacing: -0.015em; }
h2 { font: 600 1.25rem/1.2 var(--font-display); }
h3 { font-size: 0.8rem; letter-spacing: 0.07em; text-transform: uppercase; color: var(--ink-2); font-weight: 650; }
p { margin: 0 0 0.75rem; }
a { color: var(--accent-text); text-underline-offset: 0.18em; }
a:hover { text-decoration-thickness: 2px; }
.num, .fig { font-variant-numeric: tabular-nums lining-nums; }
.muted { color: var(--ink-2); }
.small { font-size: 0.875rem; }
.sr-only { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
.skip { position: absolute; left: 0.5rem; top: -4rem; background: var(--accent); color: var(--accent-ink); padding: 0.7rem 1rem; border-radius: var(--r-sm); z-index: 100; font-weight: 600; }
.skip:focus { top: 0.5rem; }
[hidden] { display: none !important; }
svg.i { width: 1.4rem; height: 1.4rem; flex: none; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- controls ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem; min-height: var(--tap); padding: 0.55rem 1.1rem; border-radius: var(--r-sm); border: 1.5px solid var(--accent); background: var(--accent); color: var(--accent-ink); font: 600 0.95rem/1.2 var(--font-ui); cursor: pointer; text-decoration: none; }
.btn:hover { filter: brightness(1.08); }
.btn:active { transform: translateY(1px); }
.btn.quiet { background: transparent; color: var(--ink); border-color: var(--edge); }
.btn.quiet:hover { background: var(--surface-2); filter: none; }
.btn.small { min-height: 2.5rem; padding: 0.3rem 0.8rem; font-size: 0.85rem; }
.btn[disabled], .btn[aria-disabled="true"] { opacity: 0.55; cursor: not-allowed; }
input, select, textarea { font: inherit; color: var(--ink); background: var(--surface); border: 1.5px solid var(--edge); border-radius: var(--r-sm); min-height: var(--tap); padding: 0.5rem 0.75rem; max-width: 100%; }
input[type="checkbox"], input[type="radio"] { min-height: 0; width: 1.25rem; height: 1.25rem; accent-color: var(--accent); }
select { padding-right: 2rem; }
label, .label { display: block; font-size: 0.9rem; font-weight: 600; margin: 0 0 0.3rem; }
.hint { font-size: 0.85rem; color: var(--ink-2); margin: 0.3rem 0 0; }
.field { margin: 0 0 1rem; }
.field-row { display: grid; gap: 0 var(--gap); grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr)); }
fieldset { border: 0; padding: 0; margin: 0 0 1rem; min-inline-size: 0; }
legend { font-weight: 650; padding: 0; margin-bottom: 0.4rem; }

/* ---------- shell ---------- */
.shell { display: grid; grid-template-columns: 15.5rem minmax(0, 1fr); min-height: 100vh; min-height: 100dvh; }
.side { position: sticky; top: 0; align-self: start; height: 100vh; height: 100dvh; display: flex; flex-direction: column; gap: 0.5rem; padding: 1.25rem 0.9rem; border-right: 1px solid var(--line); background: var(--surface); overflow-y: auto; }
.brand { display: flex; align-items: center; gap: 0.6rem; min-height: var(--tap); font: 700 1.35rem/1 var(--font-display); letter-spacing: -0.02em; color: var(--ink); text-decoration: none; padding: 0.25rem 0.4rem 1rem; }
.brand svg { width: 2rem; height: 2rem; }
.nav { display: flex; flex-direction: column; gap: 0.2rem; }
.nav a { position: relative; display: flex; align-items: center; gap: 0.8rem; min-height: var(--tap); padding: 0.5rem 0.8rem; border-radius: var(--r-sm); color: var(--ink-2); text-decoration: none; font-weight: 600; }
.nav a:hover { background: var(--surface-2); color: var(--ink); }
.nav a[aria-current="page"] { background: var(--accent-soft); color: var(--accent-text); }
.badge { margin-left: auto; min-width: 1.4rem; padding: 0 0.4rem; border-radius: 99px; background: var(--warn); color: var(--bg); font-size: 0.75rem; font-weight: 700; text-align: center; line-height: 1.4rem; }
.side-foot { margin-top: auto; display: flex; flex-direction: column; gap: 0.5rem; }
.who { font-size: 0.85rem; color: var(--ink-2); padding: 0 0.4rem; }
.topbar { display: none; }
main { min-width: 0; padding: clamp(1rem, 3vw, 2.25rem) clamp(1rem, 4vw, 3rem) 4rem; }
.page { max-width: 68rem; margin: 0 auto; }
.page-head { margin-bottom: 1.5rem; }
.page-head p { margin: 0.35rem 0 0; color: var(--ink-2); }
.demo-banner { background: var(--warn-soft); color: var(--ink); border-bottom: 1px solid var(--edge); padding: 0.6rem clamp(1rem, 4vw, 3rem); font-size: 0.9rem; display: flex; flex-wrap: wrap; gap: 0.5rem 1rem; align-items: center; }
.demo-banner select { min-height: var(--tap); }

/* ---------- panels ---------- */
.grid { display: grid; gap: var(--gap); }
.cols-2 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 20rem), 1fr)); }
.cols-3 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 14rem), 1fr)); }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: var(--pad); min-width: 0; }
.panel > h2, .panel > h3 { margin-bottom: 0.75rem; }
.stack { display: grid; gap: var(--gap); }
.stack > * { margin: 0; min-width: 0; }
.hero { display: grid; gap: var(--gap); grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); align-items: end; border-color: var(--accent); border-width: 2px; background: var(--surface); }
.hero .fig { font: 600 clamp(2.6rem, 1.7rem + 4.5vw, 4.8rem)/1 var(--font-display); letter-spacing: -0.03em; color: var(--accent-text); margin: 0.35rem 0 0.6rem; }
.hero .keep { border-left: 1px solid var(--line); padding-left: var(--gap); }
.hero .keep .fig { font-size: clamp(1.8rem, 1.2rem + 2vw, 2.6rem); color: var(--ink); }
.stats { display: grid; gap: var(--gap); grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr)); margin: 0; }
.stats div { border-top: 2px solid var(--line); padding-top: 0.6rem; }
.stats dt { font-size: 0.8rem; letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-2); font-weight: 650; }
.stats dd { margin: 0.2rem 0 0; font: 600 1.7rem/1.2 var(--font-display); font-variant-numeric: tabular-nums lining-nums; }
.notice { display: flex; gap: 0.75rem; align-items: flex-start; padding: 0.9rem 1rem; border-radius: var(--r-sm); border: 1.5px solid var(--edge); background: var(--surface); }
.notice.warn { background: var(--warn-soft); border-color: var(--warn); }
.notice.bad { background: var(--neg-soft); border-color: var(--neg); }
.notice svg { margin-top: 0.1rem; }
.notice p { margin: 0; }
.pill { display: inline-block; padding: 0.1rem 0.6rem; border-radius: 99px; font-size: 0.8rem; font-weight: 700; border: 1.5px solid currentColor; }
.pill.ok { color: var(--pos); } .pill.bad { color: var(--neg); } .pill.warn { color: var(--warn); }
.pos { color: var(--pos); } .neg { color: var(--neg); }

/* meter */
.meter { height: 0.8rem; background: var(--surface-2); border: 1.5px solid var(--edge); border-radius: 99px; overflow: hidden; margin: 0.5rem 0; }
.meter > i { display: block; height: 100%; background: var(--accent); }
.meter.bad > i { background: var(--neg); }
.meter.warn > i { background: var(--warn); }

/* lists */
.rows { list-style: none; margin: 0; padding: 0; }
.rows li { display: flex; justify-content: space-between; gap: 1rem; padding: 0.55rem 0; border-bottom: 1px solid var(--line); }
.rows li:last-child { border-bottom: 0; }
.bars { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.7rem; }
.bars li { display: grid; gap: 0.25rem; }
.bars .t { display: flex; justify-content: space-between; gap: 1rem; font-size: 0.95rem; }
.bars .b { height: 0.5rem; background: var(--surface-2); border-radius: 99px; }
.bars .b i { display: block; height: 100%; border-radius: 99px; background: var(--chart-a); }

/* chart */
.chart { width: 100%; height: auto; display: block; }
.chart .axis { stroke: var(--edge); stroke-width: 1; }
.chart .a { fill: var(--chart-a); } .chart .b { fill: var(--chart-b); }
.chart text { fill: var(--ink-2); font: 11px var(--font-ui); }
.legend { display: flex; gap: 1.25rem; flex-wrap: wrap; font-size: 0.875rem; margin-top: 0.5rem; }
.legend span::before { content: ""; display: inline-block; width: 0.8rem; height: 0.8rem; border-radius: 3px; margin-right: 0.4rem; vertical-align: -0.1rem; }
.legend .a::before { background: var(--chart-a); } .legend .b::before { background: var(--chart-b); }
details.tablewrap summary { cursor: pointer; font-weight: 600; margin-top: 0.75rem; min-height: var(--tap); display: flex; align-items: center; }

/* tables (become cards on small screens) */
.tablewrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 0.65rem 0.75rem; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 0.78rem; letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-2); font-weight: 650; }
td.n, th.n { text-align: right; font-variant-numeric: tabular-nums lining-nums; white-space: nowrap; }
caption { text-align: left; padding: 0 0 0.6rem; color: var(--ink-2); font-size: 0.9rem; }

/* review queue */
.queue { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.9rem; }
.item { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 1rem 1.1rem; display: grid; gap: 0.6rem; }
.item .top { display: flex; justify-content: space-between; gap: 1rem; align-items: baseline; }
.item .desc { font-weight: 650; overflow-wrap: anywhere; }
.item .amt { font: 600 1.25rem/1 var(--font-display); font-variant-numeric: tabular-nums lining-nums; white-space: nowrap; }
.item .meta { font-size: 0.85rem; color: var(--ink-2); }
.item .guess { font-size: 0.9rem; background: var(--accent-soft); color: var(--ink); padding: 0.4rem 0.7rem; border-radius: var(--r-sm); }
.actions { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.item details summary { cursor: pointer; font-weight: 600; min-height: var(--tap); display: flex; align-items: center; color: var(--accent-text); }

/* dropzone + steps */
.drop { border: 2px dashed var(--edge); border-radius: var(--r); padding: 2rem 1.25rem; text-align: center; background: var(--surface); }
.drop.on { border-color: var(--accent); background: var(--accent-soft); }
.steps { counter-reset: s; list-style: none; padding: 0; margin: 0; display: grid; gap: 0.5rem; }
.steps li { counter-increment: s; display: flex; gap: 0.75rem; align-items: baseline; }
.steps li::before { content: counter(s); flex: none; width: 1.7rem; height: 1.7rem; border-radius: 50%; background: var(--accent); color: var(--accent-ink); font-weight: 700; display: grid; place-items: center; font-size: 0.85rem; }

/* theme picker */
.themes { display: grid; gap: 0.75rem; grid-template-columns: repeat(auto-fill, minmax(9.5rem, 1fr)); }
.themes label { position: relative; display: block; margin: 0; cursor: pointer; }
.themes input { position: absolute; opacity: 0; inset: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.themes .card { display: grid; gap: 0.5rem; padding: 0.6rem; border: 2px solid var(--line); border-radius: var(--r-sm); background: var(--surface); }
.themes input:checked + .card { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.themes input:focus-visible + .card { outline: 3px solid var(--focus); outline-offset: 2px; }
.swatch { display: grid; grid-template-columns: 1.4fr 1fr 1fr; height: 2.4rem; border-radius: 6px; overflow: hidden; border: 1px solid rgba(128,128,128,.4); }
.themes .name { font-weight: 650; font-size: 0.92rem; }
.themes .desc { font-size: 0.8rem; color: var(--ink-2); }
.seg { display: inline-flex; border: 1.5px solid var(--edge); border-radius: var(--r-sm); overflow: hidden; }
.seg label { margin: 0; }
.seg input { position: absolute; opacity: 0; }
.seg span { display: block; padding: 0.55rem 1rem; min-height: var(--tap); line-height: 1.6; cursor: pointer; font-weight: 600; }
.seg input:checked + span { background: var(--accent); color: var(--accent-ink); }
.seg input:focus-visible + span { outline: 3px solid var(--focus); outline-offset: -3px; }
dialog { max-width: min(42rem, calc(100vw - 1.5rem)); width: 100%; border: 1px solid var(--edge); border-radius: var(--r); background: var(--bg); color: var(--ink); padding: 1.25rem; }
dialog::backdrop { background: rgba(0,0,0,.55); }
dialog .head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1rem; gap: 1rem; }

/* ---------- tablet: icon rail ---------- */
@media (max-width: 1099px) {
  .shell { grid-template-columns: 5.5rem minmax(0, 1fr); }
  .side { padding: 1rem 0.5rem; align-items: stretch; }
  .brand { justify-content: center; padding-bottom: 0.75rem; } .brand span { display: none; }
  .nav a { flex-direction: column; justify-content: center; gap: 0.2rem; padding: 0.55rem 0.25rem; font-size: 0.72rem; text-align: center; min-height: 3.6rem; }
  .badge { position: absolute; top: 0.25rem; right: 0.35rem; margin: 0; }
  .who { display: none; }
  .side-foot .btn span { display: none; }
}
/* ---------- phone: bottom tab bar ---------- */
@media (max-width: 719px) {
  .shell { display: block; }
  .side { position: fixed; inset: auto 0 0 0; height: auto; z-index: 20; flex-direction: row; padding: 0.25rem 0.25rem calc(0.25rem + env(safe-area-inset-bottom)); border-right: 0; border-top: 1px solid var(--line); gap: 0; }
  .side .brand, .side-foot { display: none; }
  .nav { flex-direction: row; width: 100%; justify-content: space-around; }
  .nav a { flex: 1; min-width: 0; min-height: 3.5rem; font-size: 0.7rem; padding: 0.4rem 0.1rem; }
  .topbar { display: flex; align-items: center; justify-content: space-between; padding: 0.6rem 1rem; background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10; }
  .topbar .brand { padding: 0; font-size: 1.2rem; } .topbar .brand span { display: inline; }
  main { padding-bottom: 6rem; }
  .hero { grid-template-columns: 1fr; } .hero .keep { border-left: 0; padding-left: 0; border-top: 1px solid var(--line); padding-top: var(--gap); }
  /* tables turn into stacked cards */
  table.stack-sm thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  table.stack-sm, table.stack-sm tbody, table.stack-sm tr, table.stack-sm td { display: block; width: 100%; }
  table.stack-sm tr { border: 1px solid var(--line); border-radius: var(--r-sm); padding: 0.5rem 0.75rem; margin-bottom: 0.75rem; background: var(--surface); }
  table.stack-sm td { border: 0; padding: 0.25rem 0; display: flex; justify-content: space-between; gap: 1rem; text-align: right; }
  table.stack-sm td::before { content: attr(data-label); font-weight: 650; color: var(--ink-2); text-align: left; font-size: 0.8rem; }
  table.stack-sm td.n { white-space: normal; }
  .item .top { flex-direction: column; gap: 0.2rem; }
}
@media (min-width: 720px) { .only-phone { display: none !important; } }
@media (prefers-reduced-motion: no-preference) {
  .btn, .nav a { transition: background-color .15s, color .15s, filter .15s; }
  .meter > i { transition: width .5s ease; }
}
@media (forced-colors: active) {
  .btn, .nav a[aria-current="page"], .badge { border: 2px solid ButtonText; }
  .meter > i, .bars .b i { background: Highlight; forced-color-adjust: none; }
}
@media print { .side, .topbar, .demo-banner { display: none; } .shell { display: block; } body { background: #fff; color: #000; } }
