/* Bonker Banker: theme layer.
   Loaded AFTER styles.css so that file stays untouched. It re-points the tokens (adds dark mode) and
   restyles components.

   House rules (from the anti-"AI slop" guidance we reviewed):
   - one accent colour, solid. No gradients, glow, glass, or gradient text.
   - flat surfaces: a border OR a shadow, never both. Small radii. No nested cards.
   - one typeface (Public Sans); hierarchy comes from size and weight. Numbers are tabular.
   - sentence-case labels, 13px minimum, body 16px, measure capped near 65 characters.
   - no emoji, no icon tiles, no repeated identical card grids.
   - motion only where it explains something, never hides content, and respects reduced motion. */

/* ============================================================ tokens */
:root {
  color-scheme: light dark;

  --font: "Public Sans", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;

  --brand: #c2410c;              /* the single accent. White text on it is 5.2:1 */
  --brand-hover: #9a3412;
  --brand-strong: #c2410c;       /* accent used as text/links on the page background */
  --brand-tint: rgb(194 65 12 / 0.09);

  --ink: #14181f;
  --muted: #566070;
  --page: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #eff1f4;
  --border: #dde1e7;

  --good: #0b7a4f;
  --warn: #9a5b00;
  --bad: #b3261e;
  --good-bg: rgb(11 122 79 / 0.09);
  --warn-bg: rgb(154 91 0 / 0.10);
  --bad-bg: rgb(179 38 30 / 0.08);
  --guess-bg: #fdf3cf;

  --radius: 0.75rem;
  --ring: 0 0 0 3px rgb(194 65 12 / 0.30);

  /* chart/category ramp: the accent fading to neutrals, always paired with a text label */
  --c1: #c2410c; --c2: #14181f; --c3: #e0764a; --c4: #566070;
  --c5: #eaa88a; --c6: #8b94a3; --c7: #f2cdbb; --c8: #bcc3ce;
}

@media (prefers-color-scheme: dark) {
  :root {
    --brand-strong: #ff8a4c;     /* lighter accent for text on dark surfaces */
    --brand-tint: rgb(255 138 76 / 0.12);

    --ink: #eceff4;
    --muted: #a0a9b8;
    --page: #0e1013;
    --surface: #16191e;
    --surface-2: #1e2229;
    --border: #2b313a;

    --good: #4bd08f;
    --warn: #e8b04a;
    --bad: #ff8078;
    --good-bg: rgb(75 208 143 / 0.12);
    --warn-bg: rgb(232 176 74 / 0.12);
    --bad-bg: rgb(255 128 120 / 0.12);
    --guess-bg: rgb(232 176 74 / 0.14);

    --ring: 0 0 0 3px rgb(255 138 76 / 0.40);

    --c1: #ff8a4c; --c2: #eceff4; --c3: #c8693a; --c4: #a0a9b8;
    --c5: #8f4a28; --c6: #6d7686; --c7: #5e3320; --c8: #454c58;
  }
}

/* ============================================================ base */
html { accent-color: var(--brand); }

body {
  font-family: var(--font);
  font-size: 1rem;
  line-height: 1.55;
  font-variant-numeric: lining-nums;
  -webkit-font-smoothing: antialiased;
  background: var(--page);
  color: var(--ink);
}

::selection { background: var(--brand-tint); }
:focus-visible { outline: 2px solid var(--brand-strong); outline-offset: 2px; }

h1, h2, h3 { letter-spacing: -0.015em; text-wrap: balance; }
p, li { text-wrap: pretty; }

main a:not([class]) {
  color: var(--brand-strong);
  text-decoration-line: underline;
  text-underline-offset: 3px;
  text-decoration-thickness: 1px;
}
main a:not([class]):hover { text-decoration-thickness: 2px; }

/* ============================================================ nav */
.nav { position: sticky; top: 0; z-index: 40; background: var(--surface); border-bottom: 1px solid var(--border); view-transition-name: site-nav; }
.nav > div { flex-wrap: wrap; gap: 0.25rem 1.25rem; }
.nav .flex.gap-6 { gap: 0.1rem; flex-wrap: wrap; }

.nav-brand { display: inline-flex; align-items: center; gap: 0.55rem; font-weight: 700; letter-spacing: -0.02em; color: var(--ink); }
.nav-brand::before { content: ""; inline-size: 0.9rem; block-size: 0.9rem; border-radius: 0.2rem; background: var(--brand); }
.nav-link { padding: 0.4rem 0.7rem; border-radius: 0.4rem; color: var(--muted); font-size: 0.9375rem; transition: color 0.12s, background-color 0.12s; }
.nav-link:hover { color: var(--ink); background: var(--surface-2); }
.nav-link.active { color: var(--ink); font-weight: 600; box-shadow: inset 0 -2px 0 var(--brand); border-radius: 0; background: transparent; }

/* ============================================================ surfaces */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: none; padding: 1.5rem; }
@media (max-width: 640px) { .card { padding: 1.1rem; } }
.card-title { font-size: 1.125rem; font-weight: 700; letter-spacing: -0.01em; }

.metric-label { font-size: 0.8125rem; font-weight: 500; letter-spacing: 0; text-transform: none; color: var(--muted); }
.metric-value { font-weight: 700; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }

.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr)); border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); overflow: clip; }
.tile { padding: 1rem 1.15rem; border-inline-start: 1px solid var(--border); border-block-end: 1px solid var(--border); margin: 0 -1px -1px 0; }
.tile-value { font-size: 1.5rem; font-weight: 700; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; line-height: 1.25; margin-top: 0.15rem; }
.tile-sub { color: var(--muted); font-size: 0.8125rem; margin-top: 0.1rem; }

.stat { background: var(--surface-2); border: 0; }

/* ============================================================ buttons & inputs */
.btn-primary, .btn-secondary {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem;
  text-decoration: none; line-height: 1.25; font-weight: 600; border-radius: 0.5rem; padding: 0.6rem 1.1rem;
  transition: background-color 0.12s, border-color 0.12s, color 0.12s;
}
.btn-primary { background: var(--brand); color: #fff; box-shadow: none; }
.btn-primary:hover { background: var(--brand-hover); }
.btn-secondary { background: var(--surface); color: var(--ink); border: 1px solid var(--border); box-shadow: none; }
.btn-secondary:hover { border-color: var(--ink); color: var(--ink); }
.btn-primary:focus-visible, .btn-secondary:focus-visible { box-shadow: var(--ring); outline: none; }

input:not([type="range"], [type="checkbox"], [type="radio"], [type="file"], [type="hidden"]), textarea, select {
  background: var(--surface); color: var(--ink); border: 1px solid var(--border); border-radius: 0.5rem; padding: 0.55rem 0.8rem;
  transition: border-color 0.12s, box-shadow 0.12s;
}
input::placeholder, textarea::placeholder { color: var(--muted); opacity: 1; }
input:focus-visible, textarea:focus-visible, select:focus-visible { outline: none; border-color: var(--brand); box-shadow: var(--ring); }

.preset-btn, .lab-group, .twist-form { border-color: var(--border); }
.preset-btn { background: var(--surface); border-radius: 0.4rem; }
.preset-btn.active { color: #fff; background: var(--brand); border-color: var(--brand); }
.toggle-track { background: var(--surface-2); border: 1px solid var(--border); }
.slider-value { color: var(--brand-strong); }
.empty-icon { display: none; }       /* teammate's emoji placeholder: text-only empty state */

/* ============================================================ status */
.verdict { border: 0; border-radius: 0.5rem; }
.verdict.good { background: var(--good-bg); }
.verdict.warn { background: var(--warn-bg); }
.verdict.bad  { background: var(--bad-bg); }
.runway-big { letter-spacing: -0.03em; }

.chips { display: flex; flex-wrap: wrap; gap: 0.4rem 1.1rem; margin-top: 0.5rem; }
.chip { display: inline-flex; gap: 0.35rem; font-size: 0.875rem; font-weight: 600; background: none; border: 0; padding: 0; color: var(--ink); }
.chip .chip-k { color: var(--muted); font-weight: 400; }

.badge { display: inline-flex; align-items: center; padding: 0.1rem 0.5rem; border-radius: 0.3rem; font-size: 0.75rem; font-weight: 700; white-space: nowrap; }
.badge-high   { color: var(--bad);  background: var(--bad-bg); }
.badge-medium { color: var(--warn); background: var(--warn-bg); }
.badge-low    { color: var(--muted); background: var(--surface-2); }
.badge-ok     { color: var(--good); background: var(--good-bg); }

/* ============================================================ tables */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); }
.data-table { inline-size: 100%; border-collapse: collapse; font-size: 0.9375rem; }
.data-table th { position: sticky; inset-block-start: 0; background: var(--surface-2); color: var(--muted); font-size: 0.8125rem; font-weight: 600; text-align: start; padding: 0.6rem 0.9rem; white-space: nowrap; }
.data-table td { padding: 0.55rem 0.9rem; border-top: 1px solid var(--border); vertical-align: top; }
.data-table tbody tr:hover { background: var(--surface-2); }
.data-table .num { text-align: end; white-space: nowrap; font-variant-numeric: tabular-nums; }
.data-table tr.row-guess td { background: var(--guess-bg); }
.data-table tr.row-flagged td:first-child { box-shadow: inset 3px 0 0 var(--warn); }
.amt-neg { color: var(--bad); }
.amt-pos { color: var(--good); }
.scroll-y { max-block-size: 32rem; overflow-y: auto; scrollbar-gutter: stable; overscroll-behavior: contain; }

/* ============================================================ spending breakdown */
.split { display: grid; gap: 2rem; grid-template-columns: repeat(auto-fit, minmax(min(100%, 22rem), 1fr)); }
.split h3 { font-size: 0.9375rem; font-weight: 700; color: var(--ink); }

.segbar { display: flex; block-size: 0.75rem; border-radius: 0.2rem; overflow: hidden; background: var(--surface-2); margin: 0.75rem 0 1.25rem; gap: 2px; }
.segbar > span { block-size: 100%; min-inline-size: 4px; background: var(--c, var(--c8)); }

.legend { display: grid; margin-top: 0.5rem; }
.legend-row { display: grid; grid-template-columns: auto 1fr auto auto; align-items: center; gap: 0.6rem; padding: 0.45rem 0; }
.legend-row + .legend-row { border-top: 1px solid var(--border); }
.dot { inline-size: 0.65rem; block-size: 0.65rem; border-radius: 0.15rem; background: var(--c, var(--c8)); }
.legend-pct { color: var(--muted); font-size: 0.875rem; min-inline-size: 3rem; text-align: end; font-variant-numeric: tabular-nums; }
.legend-amt { font-weight: 600; font-variant-numeric: tabular-nums; }

.c1 { --c: var(--c1); } .c2 { --c: var(--c2); } .c3 { --c: var(--c3); } .c4 { --c: var(--c4); }
.c5 { --c: var(--c5); } .c6 { --c: var(--c6); } .c7 { --c: var(--c7); } .c8 { --c: var(--c8); }

.bar-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 0.25rem 0.75rem; padding: 0.5rem 0; }
.bar-row .bar-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.bar-row .bar-name small { color: var(--muted); font-weight: 400; margin-inline-start: 0.4rem; }
.bar-track { grid-column: 1 / -1; block-size: 0.4rem; border-radius: 0.15rem; background: var(--surface-2); overflow: hidden; }
.bar-fill { block-size: 100%; background: var(--brand); }

/* ============================================================ flagged purchases */
.flag-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 0.5rem; }
.flag-note { color: var(--muted); max-inline-size: 65ch; }
.flag-list { margin-top: 0.75rem; }
.flag-item { display: grid; grid-template-columns: 5.2rem minmax(0, 1fr) auto; gap: 0.2rem 0.9rem; align-items: start; padding: 0.85rem 0; border-top: 1px solid var(--border); }
.flag-item .flag-title { font-weight: 600; overflow-wrap: anywhere; }
.flag-item .flag-meta { color: var(--muted); font-size: 0.875rem; }
.flag-item .flag-reasons { margin: 0.25rem 0 0; padding-inline-start: 1.1rem; list-style: disc; font-size: 0.9375rem; }
.flag-item .flag-amt { font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.flag-clear { color: var(--good); font-weight: 600; }

/* ============================================================ upload */
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 0.75rem 1rem; margin-bottom: 0.9rem; }
.toolbar input[type="search"] { flex: 1 1 14rem; max-inline-size: 22rem; }
.check { display: inline-flex; align-items: center; gap: 0.45rem; cursor: pointer; user-select: none; }

.dropzone { display: grid; place-items: center; gap: 0.3rem; text-align: center; padding: 2.25rem 1.25rem; border: 1.5px dashed var(--muted); border-radius: var(--radius); background: var(--surface); cursor: pointer; transition: border-color 0.12s, background-color 0.12s; }
.dropzone:hover, .dropzone.is-over { border-color: var(--brand); background: var(--brand-tint); }
.dropzone:focus-within { border-color: var(--brand); box-shadow: var(--ring); }
.dropzone-icon { display: none; }
.dropzone-title { font-weight: 700; font-size: 1.0625rem; }
.dropzone input[type="file"] { position: absolute; opacity: 0; inline-size: 1px; block-size: 1px; }

.picked-files { list-style: none; margin: 0.75rem 0 0; padding: 0; display: grid; gap: 0.35rem; }
.picked-files:empty { display: none; }
.picked-files li { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; align-items: center; gap: 0.75rem; padding: 0.4rem 0.4rem 0.4rem 0.8rem; border: 1px solid var(--border); border-radius: 0.5rem; background: var(--surface); }
.picked-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.picked-remove { inline-size: 1.75rem; block-size: 1.75rem; border: 0; border-radius: 0.3rem; background: transparent; color: var(--muted); font-size: 1.15rem; line-height: 1; cursor: pointer; }
.picked-remove:hover { background: var(--bad-bg); color: var(--bad); }

.spinner { display: inline-flex; align-items: center; gap: 0.5rem; color: var(--muted); }
.spinner::before { content: ""; inline-size: 1rem; block-size: 1rem; border-radius: 50%; border: 2px solid var(--border); border-top-color: var(--brand); animation: spin 0.7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.form-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 0.9rem; margin-top: 1rem; }

.file-list { margin-top: 0.5rem; }
.file-row { display: grid; grid-template-columns: 5.2rem minmax(0, 1fr); gap: 0.2rem 0.9rem; align-items: start; padding: 0.85rem 0; border-top: 1px solid var(--border); }
.file-row .badge { justify-self: start; }
.file-name { font-weight: 700; overflow-wrap: anywhere; }
.file-error { color: var(--bad); margin-top: 0.15rem; }
.warn-details { margin-top: 0.5rem; color: var(--warn); }
.warn-details summary { cursor: pointer; font-weight: 600; }
.warn-details ul { margin: 0.4rem 0 0; padding-inline-start: 1.1rem; list-style: disc; color: var(--ink); }
.combined-note { color: var(--muted); margin: 0; max-inline-size: 65ch; }

.reveal { display: grid; gap: 1.25rem; }
.reveal > *, .reveal > .card + .card { margin-block: 0; }

/* ============================================================ home */
.hero { max-inline-size: 44rem; padding: clamp(1.5rem, 5vw, 3rem) 0 1.75rem; }
.hero h1 { font-size: clamp(2rem, 4.6vw, 3rem); line-height: 1.1; font-weight: 700; letter-spacing: -0.025em; max-inline-size: 18ch; }
.hero p { margin-top: 1rem; color: var(--muted); max-inline-size: 60ch; font-size: 1.0625rem; }
.hero-form { display: flex; flex-wrap: wrap; gap: 0.6rem; margin-top: 1.5rem; }
.hero-form input { min-inline-size: 15rem; font-size: 1rem; padding: 0.65rem 0.9rem; }

.home-grid { display: grid; gap: 1rem 4rem; align-items: center; }
@media (min-width: 960px) { .home-grid { grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); min-block-size: 60vh; } }
.home-links { border-top: 1px solid var(--border); }
.home-link { display: grid; grid-template-columns: 7rem minmax(0, 1fr); gap: 0.25rem 1.25rem; padding: 1rem 0.25rem; border-bottom: 1px solid var(--border); text-decoration: none; color: inherit; transition: background-color 0.12s; }
.home-link:hover { background: var(--surface); }
.home-link:focus-visible { outline-offset: -2px; }
.home-link-name { font-weight: 700; color: var(--brand-strong); }
.home-link-desc { color: var(--muted); }
@media (max-width: 560px) { .home-link { grid-template-columns: 1fr; } }
.status-pill { color: var(--muted); font-size: 0.875rem; }
.footer-note { margin-top: 2rem; }

/* ============================================================ motion
   Content is always visible. The only motion: a short cross-fade between full page loads. */
@media (prefers-reduced-motion: no-preference) {
  @view-transition { navigation: auto; }
  ::view-transition-old(root) { animation: 0.12s ease-in both vt-out; }
  ::view-transition-new(root) { animation: 0.16s ease-out both vt-in; }
  @keyframes vt-out { to { opacity: 0; } }
  @keyframes vt-in { from { opacity: 0; } }
  ::view-transition-group(site-nav) { animation-duration: 0s; }
}

/* ============================================================ accessibility fallbacks */
@media (forced-colors: active) {
  .badge, .segbar > span, .dot { border: 1px solid CanvasText; }
  .btn-primary { border: 1px solid ButtonText; }
  .data-table tr.row-flagged td:first-child { box-shadow: inset 3px 0 0 Highlight; }
}

/* ============================================================ landing: demos + steps */
.hero-demos { margin-top: 1rem; font-size: 0.9rem; color: var(--muted); }
.hero-demos a { color: var(--brand-strong); font-weight: 600; text-decoration: none; }
.hero-demos a:hover { text-decoration: underline; }
.steps { display: grid; grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr)); gap: 1rem; margin-top: 2rem; }
.step { padding: 1rem 0 0; border-top: 1px solid var(--border); }
.step h3 { font-weight: 700; margin-block: 0.25rem 0.2rem; }
.step p { color: var(--muted); }
.step-num { color: var(--brand-strong); font-weight: 700; font-variant-numeric: tabular-nums; }

/* ============================================================ footer */
.site-footer { border-top: 1px solid var(--border); margin-top: 3rem; padding: 1.25rem 0 2rem; color: var(--muted); font-size: 0.875rem; }
.site-footer a { color: var(--brand-strong); text-decoration: underline; text-underline-offset: 3px; }
