/* Statement Raccoon — "ledger paper" design.
   Tokens → font → base → layout → header/footer → controls → upload → footing → table → pages → motion. */

/* ---------- Tokens ---------- */
:root {
  --paper: #f4f8f2;
  --surface: #ffffff;
  --ink: #1c2b2a;
  --ink-soft: #4a5b58;
  --muted: #6b7b77;
  --ledger: #1e5b45;
  --ledger-deep: #143f30;
  --ledger-tint: #e6f0e8;
  --rule: #d5e4d8;
  --rule-strong: #9dbfa8;
  --tick: #2f8f5b;
  --tick-tint: #e5f3e9;
  --pencil-red: #c8372d;
  --red-tint: #fbecea;
  --amber: #b7791f;
  --amber-tint: #fff6e3;
  --amber-rule: #ecd29b;

  --r-input: 4px;
  --r-control: 6px;
  --r-panel: 10px;
  --shadow-lift: 0 1px 2px rgba(20, 63, 48, 0.06), 0 12px 32px -12px rgba(20, 63, 48, 0.22);
  --focus: 0 0 0 3px rgba(30, 91, 69, 0.35);
  --ledger-line: 40px;

  --step--1: 0.8125rem;
  --step-0: 1rem;
  --step-1: 1.25rem;
  --step-2: 1.5625rem;
  --step-3: 1.953rem;
  --step-4: 2.441rem;
  --step-5: 3.052rem;
}

/* ---------- Font (self-hosted, OFL; see static/fonts/OFL.txt) ---------- */
@font-face {
  font-family: "Schibsted Grotesk";
  src: url("/static/fonts/schibsted-grotesk-latin-wght-normal.woff2") format("woff2");
  font-weight: 400 900;
  font-style: normal;
  font-display: swap;
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: "Schibsted Grotesk", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: var(--step-0);
  line-height: 1.55;
  color: var(--ink);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
h1, h2, h3 { line-height: 1.15; margin: 0 0 0.5em; letter-spacing: -0.015em; }
h1 { font-size: var(--step-4); font-weight: 800; }
h2 { font-size: var(--step-3); font-weight: 750; }
h3 { font-size: var(--step-1); font-weight: 700; }
p { margin: 0 0 1em; }
a { color: var(--ledger); text-underline-offset: 0.18em; text-decoration-thickness: 1px; }
a:hover { color: var(--ledger-deep); text-decoration-thickness: 2px; }
code { font-size: 0.92em; background: rgba(28, 43, 42, 0.06); padding: 0.1em 0.35em; border-radius: var(--r-input); }
:focus-visible { outline: none; box-shadow: var(--focus); border-radius: var(--r-input); }
::selection { background: #cfe6d6; }
.icon { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.muted { color: var(--muted); }
.lede { font-size: var(--step-1); color: var(--ink-soft); line-height: 1.5; }
.error { color: var(--pencil-red); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
.skip-link { position: absolute; left: 16px; top: -48px; z-index: 10; padding: 8px 14px; background: var(--surface); border-radius: var(--r-control); }
.skip-link:focus { top: 12px; }

/* Tabular figures only where numbers must line up (this font also widens punctuation under tnum). */
.footing-value, .txn-table td, .txn-table input, .plan-price, .offer-price, .step::before { font-variant-numeric: tabular-nums; }

/* ---------- Layout ---------- */
.container { max-width: 1160px; margin: 0 auto; padding: 40px 24px 72px; }
.narrow { max-width: 680px; margin-left: auto; margin-right: auto; }

/* ---------- Header: the ledger pad's binding strip ---------- */
.site-header { background: var(--ledger); color: #fff; border-bottom: 3px solid var(--ledger-deep); }
.site-header-inner { max-width: 1160px; margin: 0 auto; padding: 14px 24px; display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.logo { display: inline-flex; align-items: center; gap: 10px; color: #fff; text-decoration: none; font-weight: 750; font-size: 1.125rem; letter-spacing: -0.01em; }
.logo:hover { color: #fff; }
.logo-mark { width: 32px; height: 32px; color: var(--ledger-deep); }
.site-nav { display: flex; gap: 4px; margin-left: auto; }
.site-nav a { color: rgba(255, 255, 255, 0.86); text-decoration: none; padding: 6px 12px; border-radius: var(--r-control); font-weight: 500; }
.site-nav a:hover { color: #fff; background: rgba(255, 255, 255, 0.1); }
.install-app { border: 1px solid rgba(255, 255, 255, 0.5); background: none; color: #fff; font: inherit; font-weight: 500; padding: 5px 12px; border-radius: var(--r-control); cursor: pointer; white-space: nowrap; }
.install-app:hover { background: rgba(255, 255, 255, 0.12); }
.install-app:focus-visible { outline: none; box-shadow: var(--focus); }
.install-app[hidden], .install-hint[hidden] { display: none; }
.install-hint { max-width: 1160px; margin: 0 auto; padding: 0 24px 12px; color: rgba(255, 255, 255, 0.92); text-align: right; }

/* ---------- Footer ---------- */
.site-footer { border-top: 1px solid var(--rule); color: var(--muted); font-size: 0.9rem; }
.site-footer-inner { max-width: 1160px; margin: 0 auto; padding: 28px 24px 40px; display: flex; flex-wrap: wrap; justify-content: space-between; gap: 12px 32px; }
.site-footer p { margin: 0; }
.privacy-note { display: flex; gap: 10px; align-items: flex-start; max-width: 60ch; color: var(--ink-soft); }
.privacy-note .icon { margin-top: 2px; color: var(--ledger); }
.footer-meta { max-width: 44ch; flex: 1 1 100%; }
.footer-nav { display: flex; flex-wrap: wrap; gap: 20px 40px; flex: 1 1 100%; }
.footer-nav-heading { margin: 0 0 8px; font-size: 0.75rem; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink); }
.footer-nav-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.footer-nav-list a { color: var(--muted); text-decoration: none; }
.footer-nav-list a:hover { color: var(--ink); text-decoration: underline; }
.landing-upload { margin: 24px 0 32px; }
.landing-benefits, .landing-faq, .landing-related { margin: 36px 0; max-width: 40rem; }
.landing-bullets { margin: 0; padding-left: 1.25rem; display: grid; gap: 8px; color: var(--ink-soft); }
.landing-links { margin: 16px 0 0; font-size: 0.95rem; }
.landing-disclaimer { font-size: 0.85rem; color: var(--muted); max-width: 40rem; margin: 32px 0 0; }
.faq-list { margin: 0; display: grid; gap: 16px; }
.faq-list dt { font-weight: 600; color: var(--ink); margin: 0; }
.faq-list dd { margin: 4px 0 0; color: var(--ink-soft); line-height: 1.5; }
.landing-related ul { list-style: none; margin: 8px 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px 16px; }

/* ---------- Controls ---------- */
button, input, select { font: inherit; color: inherit; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 18px; border-radius: var(--r-control);
  border: 1px solid transparent; font-weight: 650; font-size: 0.975rem; line-height: 1;
  text-decoration: none; cursor: pointer; white-space: nowrap;
  transition: background-color 120ms ease, border-color 120ms ease, color 120ms ease;
}
.btn-primary { background: var(--ledger); color: #fff; }
.btn-primary:hover { background: var(--ledger-deep); color: #fff; }
.btn-quiet { background: var(--surface); color: var(--ink); border-color: var(--rule-strong); }
.btn-quiet:hover { border-color: var(--ledger); color: var(--ledger-deep); }
.btn[aria-busy="true"] { opacity: 0.85; cursor: progress; }
.spinner { width: 16px; height: 16px; border-radius: 50%; border: 2px solid rgba(255,255,255,0.4); border-top-color: #fff; animation: spin 700ms linear infinite; }

.field { display: flex; flex-direction: column; gap: 6px; font-size: var(--step--1); font-weight: 600; color: var(--ink-soft); }
.field input, .field select, .inline-field input {
  min-height: 44px; padding: 0 12px; border: 1px solid var(--rule-strong); border-radius: var(--r-input);
  background: var(--surface); font-size: var(--step-0); font-weight: 400; color: var(--ink);
}
.field input:focus, .field select:focus, .inline-field input:focus { outline: none; border-color: var(--ledger); box-shadow: var(--focus); }
.field-grow { flex: 1 1 16rem; }
.inline-field { display: flex; gap: 8px; flex-wrap: wrap; }
.inline-field input { flex: 1 1 14rem; min-width: 0; }

.callout { border-radius: var(--r-panel); padding: 18px 20px; background: var(--surface); border: 1px solid var(--rule); }
.callout-pending { background: var(--amber-tint); border-color: var(--amber-rule); }

/* ---------- Landing: hero ---------- */
.hero { display: grid; grid-template-columns: minmax(0, 1.08fr) minmax(0, 0.92fr); gap: 56px; align-items: center; padding: 24px 0 8px; }
.hero-eyebrow { font-size: var(--step--1); font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ledger); margin-bottom: 12px; }
.hero-title { font-size: clamp(2.4rem, 5vw, 3.6rem); font-weight: 850; letter-spacing: -0.03em; line-height: 1.02; max-width: 13ch; margin-bottom: 20px; }
.hero-lede { font-size: 1.1875rem; color: var(--ink-soft); max-width: 52ch; margin-bottom: 28px; }
.hero-lede strong { color: var(--ink); }

/* Upload zone: a blank ledger sheet waiting for a statement */
.upload-zone {
  position: relative; border: 2px dashed var(--rule-strong); border-radius: var(--r-panel);
  background:
    repeating-linear-gradient(to bottom, transparent 0 31px, rgba(157, 191, 168, 0.16) 31px 32px),
    var(--surface);
  transition: border-color 150ms ease, background-color 150ms ease;
}
.upload-zone.dragover { border-color: var(--ledger); border-style: solid; background-color: var(--ledger-tint); box-shadow: inset 0 0 0 4px rgba(30, 91, 69, 0.08); }
.upload-form { display: grid; justify-items: center; text-align: center; gap: 6px; padding: 28px 24px 24px; }
.upload-icon { width: 34px; height: 40px; fill: var(--surface); stroke: var(--ledger); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; margin-bottom: 6px; }
.upload-zone.dragover .upload-icon { transform: translateY(-3px); transition: transform 150ms ease; }
.upload-title { font-weight: 700; font-size: 1.125rem; margin: 0; }
.upload-hint { color: var(--muted); font-size: 0.9rem; margin: 0 0 10px; }

/* In-browser OCR: scan card, steps, live text (static/ocr.js) */
.upload-form[hidden], .scan-card[hidden], .ocr-steps[hidden], .ocr-live[hidden], .ocr-progress[hidden], .scan-note[hidden] { display: none; }
.scan-card { display: grid; gap: 16px; padding: 24px; text-align: left; }
.scan-file { display: grid; grid-template-columns: auto 1fr; gap: 18px; align-items: start; }
.scan-thumb { position: relative; width: 120px; border-radius: 4px; overflow: hidden; background: var(--surface); box-shadow: 0 1px 2px rgba(20, 63, 48, 0.12), 0 8px 20px -10px rgba(20, 63, 48, 0.35); border: 1px solid var(--rule); }
.scan-thumb canvas { display: block; width: 100%; height: auto; }
.scan-pages:not(:empty) { position: absolute; right: 6px; bottom: 6px; padding: 1px 7px; border-radius: 999px; background: var(--ink); color: var(--paper); font-size: 0.72rem; }
.scan-line { position: absolute; left: 0; right: 0; top: 0; height: 18%; background: linear-gradient(to bottom, rgba(47, 143, 91, 0), rgba(47, 143, 91, 0.28), rgba(47, 143, 91, 0)); border-bottom: 2px solid var(--tick); opacity: 0; pointer-events: none; }
.scan-thumb.scanning .scan-line { opacity: 1; animation: scan-line 2.2s ease-in-out infinite alternate; }
@keyframes scan-line { from { transform: translateY(-20%); } to { transform: translateY(470%); } }
.scan-meta { display: grid; gap: 4px; min-width: 0; }
.scan-kind { margin: 0; font-weight: 650; font-size: var(--step-1); color: var(--ink); }
.scan-name { margin: 0; color: var(--muted); font-size: var(--step--1); overflow-wrap: anywhere; }
.scan-lede { margin: 6px 0 0; color: var(--ink-soft); }
.scan-note { margin: 2px 0 0; color: var(--muted); font-size: var(--step--1); }
.scan-card.ocr-error .scan-lede { color: var(--pencil-red); }

.ocr-steps { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; border-top: 1px solid var(--rule); padding-top: 12px; }
.ocr-step { display: grid; grid-template-columns: 22px 1fr auto; gap: 10px; align-items: start; padding: 6px 0; color: var(--muted); }
.step-title { margin: 0; font-weight: 600; }
.step-detail { margin: 1px 0 0; font-size: var(--step--1); color: var(--muted); }
.step-detail:empty { display: none; }
.step-time { font-size: var(--step--1); font-variant-numeric: tabular-nums; color: var(--muted); padding-top: 2px; }
.step-mark { width: 18px; height: 18px; margin-top: 2px; border-radius: 50%; border: 2px solid var(--rule-strong); box-sizing: border-box; }
.ocr-step[data-state="active"] { color: var(--ink); }
.ocr-step[data-state="active"] .step-detail { color: var(--ink-soft); }
.ocr-step[data-state="active"] .step-mark { border-color: var(--ledger-tint); border-top-color: var(--ledger); animation: step-spin 0.9s linear infinite; }
.ocr-step[data-state="done"] { color: var(--ink); }
.ocr-step[data-state="done"] .step-mark { border: 0; background: var(--tick) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 18 18'%3E%3Cpath d='M5 9.5l2.6 2.5L13 6.5' fill='none' stroke='white' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / 18px no-repeat; }
.ocr-step[data-state="failed"] .step-mark { border-color: var(--pencil-red); background: var(--red-tint); }
@keyframes step-spin { to { transform: rotate(360deg); } }

.ocr-progress { width: 100%; height: 6px; accent-color: var(--ledger); }
.ocr-live { margin: 0; padding: 10px 12px; min-height: 8.4em; max-height: 16em; overflow-y: auto; overscroll-behavior: contain; white-space: pre-wrap; word-break: break-word; border-radius: var(--r-input); background: var(--paper); border: 1px solid var(--rule); color: var(--ink-soft); font: 0.78rem/1.25 ui-monospace, SFMono-Regular, Menlo, monospace; }
.ocr-live:focus-visible { outline: none; box-shadow: var(--focus); }
.ocr-countdown { margin: 0; color: var(--ink-soft); font-weight: 600; }
.ocr-actions { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.ocr-actions [hidden] { display: none; }
.ocr-actions .btn-upload { margin: 0; }
.btn-link { border: 0; background: none; padding: 6px 2px; color: var(--ledger-deep); font: inherit; text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }
.btn-link:hover { color: var(--ledger); }
.btn-link-small { padding: 0; font-size: inherit; }
.btn-link[hidden] { display: none; }
.btn-link:focus-visible { outline: none; box-shadow: var(--focus); border-radius: 2px; }
@media (max-width: 520px) {
  .scan-card { padding: 18px 16px; }
  .scan-file { grid-template-columns: 1fr; justify-items: center; text-align: center; }
  .scan-thumb { width: 140px; }
  .ocr-actions { justify-content: center; }
  .ocr-actions .btn-upload { width: 100%; }
}
@media (prefers-reduced-motion: reduce) {
  .scan-thumb.scanning .scan-line, .ocr-step[data-state="active"] .step-mark { animation: none; }
}
.ocr-note { margin: 6px 0 0; padding: 6px 10px; border-radius: var(--r-input); background: var(--amber-tint); border: 1px solid var(--amber-rule); color: var(--ink); font-size: var(--step--1); max-width: 60ch; }
.file-input { position: absolute; width: 1px; height: 1px; opacity: 0; overflow: hidden; clip: rect(0,0,0,0); }
.upload-actions { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; justify-content: center; max-width: 100%; }
.upload-actions .btn { min-height: 40px; }
.file-input:focus-visible ~ .upload-actions .btn { box-shadow: var(--focus); border-color: var(--ledger); }
.file-name { color: var(--muted); font-size: 0.9rem; max-width: 28ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-name.has-file { color: var(--ink); font-weight: 600; }
.btn-upload { margin-top: 12px; width: 100%; max-width: 320px; min-height: 48px; font-size: 1.0625rem; }

/* Proof card: the sample statement footed on a ledger sheet */
.proof-card { position: relative; background: var(--surface); border-radius: var(--r-panel); box-shadow: var(--shadow-lift); padding: 22px 24px 18px 44px; overflow: hidden; }
.proof-card::before { content: ""; position: absolute; top: 0; bottom: 0; left: 22px; width: 4px; border-left: 1px solid rgba(200, 55, 45, 0.55); border-right: 1px solid rgba(200, 55, 45, 0.55); }
.proof-caption { font-size: 0.9rem; color: var(--muted); margin: 0 0 6px; }
.proof-card .footing { grid-template-columns: 1fr; gap: 16px; background: none; border: 0; padding: 0; }
.proof-card .footing-lines { padding: 0; }
.proof-card .recon-banner { padding: 14px 0 0; background: none; border-top: 1px solid var(--rule); border-radius: 0; }
.proof-link { display: inline-block; margin-top: 14px; font-weight: 600; font-size: 0.95rem; }

/* ---------- Footing (the reconciliation proof) ---------- */
.footing {
  display: grid; grid-template-columns: minmax(0, 27rem) minmax(0, 1fr); gap: 0;
  background: var(--surface); border: 1px solid var(--rule); border-radius: var(--r-panel); overflow: hidden;
}
.footing-lines {
  margin: 0; padding: 8px 24px 16px;
}
.footing-line { display: flex; align-items: center; justify-content: space-between; gap: 16px; height: var(--ledger-line); border-bottom: 1px solid var(--rule); }
.footing-line:last-child { border-bottom: 0; }
.footing-line dt { color: var(--ink-soft); display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.footing-line dd { margin: 0; font-size: 1.0625rem; font-weight: 600; white-space: nowrap; }
.footing-op { display: inline-block; width: 1ch; font-weight: 700; color: var(--ink); }
.footing-count { font-size: var(--step--1); color: var(--muted); }
.footing-credit { color: var(--tick); }
.footing-total { border-top: 1.5px solid var(--ink); border-bottom: 0; height: calc(var(--ledger-line) + 8px); }
.footing-total dt { color: var(--ink); font-weight: 700; }
.footing-total dd { font-size: 1.25rem; font-weight: 800; line-height: 1.2; }
.footing-total .footing-value { display: inline-block; padding-bottom: 2px; border-bottom: 4px double var(--ink); }
.footing-statement dt, .footing-statement dd { color: var(--muted); font-weight: 500; }
.footing-blank { color: var(--muted); font-weight: 400; }
.footing-off { position: relative; color: var(--pencil-red); }
.footing-off::after {
  content: ""; position: absolute; inset: -6px -10px; border: 2px solid var(--pencil-red);
  border-radius: 50% 46% 52% 44% / 58% 50% 54% 46%; transform: rotate(-3deg); opacity: 0.85;
}
.footing-card .footing-line dd { display: flex; align-items: baseline; gap: 12px; }
.card-section-total { font-size: var(--step--1); font-weight: 600; color: var(--muted); }
.card-section-total.footing-off { color: var(--pencil-red); }

/* Status beside the footing */
.recon-banner { display: flex; align-items: center; gap: 16px; padding: 22px 28px; font-size: var(--step-0); }
.recon-text { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.recon-message { font-size: var(--step-2); font-weight: 800; letter-spacing: -0.015em; line-height: 1.15; }
.recon-detail { color: var(--ink-soft); }
.recon-ok { background: var(--tick-tint); }
.recon-ok .recon-message { color: #1f6b43; }
.recon-mismatch { background: var(--red-tint); }
.recon-mismatch .recon-message { color: var(--pencil-red); }
.recon-pending { background: var(--amber-tint); }
.recon-pending .recon-message { color: #7a5113; font-size: var(--step-1); font-weight: 700; }
.recon-jump { font-weight: 650; color: var(--pencil-red); }
.recon-jump:hover { color: #9e271f; }
.recon-tick, .recon-flag, .recon-wait { width: 56px; height: 48px; flex: none; fill: none; stroke-linecap: round; stroke-linejoin: round; }
.recon-tick { stroke: var(--tick); stroke-width: 5; }
.recon-flag { stroke: var(--pencil-red); stroke-width: 3.5; }
.recon-wait { stroke: var(--amber); stroke-width: 3; }
.recon-tick path, .recon-flag path { stroke-dasharray: 1; stroke-dashoffset: 1; animation: draw 650ms cubic-bezier(0.65, 0, 0.35, 1) 150ms forwards; }
.recon-flag path + path { animation-delay: 650ms; animation-duration: 250ms; }
.proof-card .recon-message { font-size: var(--step-1); }
.proof-card .recon-tick { width: 44px; height: 38px; }

/* ---------- Job page ---------- */
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 16px 24px; margin-bottom: 24px; }
.page-head h1 { font-size: var(--step-3); margin-bottom: 4px; }
.page-meta { color: var(--muted); margin: 0; }
.export-toolbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 8px 10px; }
.btn-compact { min-height: 36px; padding: 0 12px; gap: 6px; font-size: 0.875rem; }
.btn-compact .icon, .export-label .icon { width: 16px; height: 16px; }
.export-label { display: inline-flex; align-items: center; gap: 4px; font-size: var(--step--1); color: var(--muted); margin-left: 4px; }
/* Format buttons: one joined group */
.exports { display: inline-flex; flex-wrap: nowrap; }
.exports .btn-export { min-height: 36px; padding: 0 12px; font-size: 0.875rem; border-radius: 0; margin-left: -1px; position: relative; }
.exports .btn-export:first-child { margin-left: 0; border-top-left-radius: var(--r-control); border-bottom-left-radius: var(--r-control); }
.exports .btn-export:last-child { border-top-right-radius: var(--r-control); border-bottom-right-radius: var(--r-control); }
.exports .btn-export:hover, .exports .btn-export:focus-visible { z-index: 1; }
.exports .btn-primary { border-color: var(--ledger); z-index: 1; }
/* Options popover (CSV date format, amount columns) */
.export-settings { position: relative; }
.export-settings > summary { list-style: none; }
.export-settings > summary::-webkit-details-marker { display: none; }
.export-settings > summary::after { content: ""; width: 6px; height: 6px; border-right: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor; transform: translateY(-2px) rotate(45deg); margin-left: 2px; }
.export-settings[open] > summary { border-color: var(--ledger); color: var(--ledger-deep); }
.export-settings[open] > summary::after { transform: translateY(1px) rotate(-135deg); }
.export-options { position: absolute; left: 0; top: calc(100% + 6px); z-index: 20; display: grid; gap: 10px; width: max-content; min-width: 220px; padding: 12px 14px; background: var(--surface); border: 1px solid var(--rule-strong); border-radius: var(--r-panel); box-shadow: var(--shadow-lift); }
.export-options .field-inline { display: grid; gap: 4px; font-size: var(--step--1); margin: 0; }
.export-options select { font: inherit; font-size: var(--step-0); padding: 6px 8px; border: 1px solid var(--rule); border-radius: var(--r-input); background: var(--surface); color: inherit; }
.export-options-note { margin: 0; font-size: var(--step--1); color: var(--muted); }
.balances-form { display: flex; flex-wrap: wrap; gap: 12px 16px; align-items: flex-end; margin: 0 0 20px; }
.balances-form p { flex-basis: 100%; margin: 0; font-weight: 600; color: #7a5113; }
.summary-panel { border: 1px solid var(--rule); border-radius: var(--r-panel); background: var(--surface); padding: 0 16px 12px; }
.summary-panel > summary { cursor: pointer; font-weight: 650; padding: 14px 0; list-style: none; }
.summary-panel > summary::-webkit-details-marker { display: none; }
.summary-panel[open] > summary { border-bottom: 1px solid var(--rule); margin-bottom: 12px; color: var(--ledger-deep); }
.summary-panel-body { display: grid; gap: 16px; }
.summary-table-scroll { max-height: min(40vh, 280px); }
.summary-table { min-width: 480px; font-size: var(--step--1); }
.summary-payees { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.summary-subhead { font-size: var(--step--1); margin: 0 0 6px; font-weight: 650; }
.summary-payee-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; font-size: var(--step--1); }
.summary-payee-list li { display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: baseline; }
.summary-payee-name { flex: 1 1 auto; min-width: 0; }
.summary-payee-amt { font-variant-numeric: tabular-nums; white-space: nowrap; }
.swap-root { display: grid; grid-template-columns: minmax(0, 1fr); gap: 20px; }
.container > .footing + .table-scroll { margin-top: 20px; }
.add-row { margin-top: 40px; }
.add-row h2 { font-size: var(--step-1); margin-bottom: 4px; }
.section-hint { color: var(--muted); margin-bottom: 12px; }
.add-row form { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; background: var(--surface); border: 1px solid var(--rule); border-radius: var(--r-panel); padding: 16px; }

/* ---------- Transactions table: a ledger page ---------- */
.table-scroll {
  position: relative; max-height: min(70vh, 640px); overflow: auto; border: 1px solid var(--rule); border-radius: var(--r-panel);
  background: var(--surface);
  overscroll-behavior: contain;
}
.txn-table { width: 100%; border-collapse: separate; border-spacing: 0; min-width: 640px; font-size: 0.9375rem; }
.txn-table-editable { min-width: 920px; }
.txn-table th, .txn-table td { padding: 9px 12px; text-align: left; vertical-align: middle; border-bottom: 1px solid var(--rule); }
.txn-table th:first-child, .txn-table td:first-child { padding-left: 20px; }
.txn-table thead th {
  position: sticky; top: 0; z-index: 1; background: #f7faf6; color: var(--ink-soft);
  font-size: var(--step--1); font-weight: 650; white-space: nowrap; border-bottom: 1px solid var(--rule-strong);
}
.txn-table tbody tr:last-child td { border-bottom: 0; }
.txn-table tbody tr:hover td { background: rgba(230, 240, 232, 0.45); }
.txn-table .col-num { text-align: right; white-space: nowrap; }
.txn-table .col-ref { text-align: center; color: var(--muted); font-size: var(--step--1); width: 3.5rem; }
.txn-table .col-date { white-space: nowrap; color: var(--ink-soft); }
.txn-table .col-desc { width: 40%; }
.txn-table .col-actions, .txn-table .actions-cell { width: 1%; white-space: nowrap; text-align: right; }
.txn-table .account-cell { color: var(--muted); font-size: var(--step--1); white-space: nowrap; }
.amount { font-weight: 600; }
.txn-credit .amount, .txn-credit .amount-cell input { color: #1f6b43; }

/* Cell inputs look like ledger text until you touch them */
.txn-table input, .txn-table .kind-select { max-width: 100%; font-size: inherit; }
.txn-table input {
  width: 100%; padding: 6px 8px; margin: -6px 0; border: 1px solid transparent; border-radius: var(--r-input);
  background: transparent;
}
.txn-table input[size="10"] { min-width: 7rem; }
.txn-table .col-num input { text-align: right; font-weight: 600; }
.txn-table .desc-input { min-width: 14rem; }
.txn-table tr:hover input { border-color: var(--rule); background: var(--surface); }
.txn-table input:focus { outline: none; border-color: var(--ledger); background: var(--surface); box-shadow: var(--focus); }

.kind-select, .kind-pill {
  display: inline-block; border-radius: 999px; padding: 3px 12px; font-size: var(--step--1); font-weight: 650;
  border: 1px solid transparent; text-transform: capitalize; line-height: 1.5;
}
.kind-select {
  appearance: none; -webkit-appearance: none; cursor: pointer; padding-right: 26px;
  background: #eef1ef url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%234a5b58' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E") no-repeat right 10px center / 9px 6px;
}
.txn-credit .kind-select, .kind-credit { background-color: var(--tick-tint); color: #1f6b43; }
.kind-debit { background: #eef1ef; color: var(--ink-soft); }
.kind-select:focus { outline: none; box-shadow: var(--focus); }

.row-actions { display: inline; }
.btn-save, .btn-delete {
  display: inline-flex; align-items: center; justify-content: center; height: 32px; border-radius: var(--r-control);
  border: 1px solid transparent; background: transparent; cursor: pointer; vertical-align: middle;
}
.btn-save { padding: 0 12px; font-size: var(--step--1); font-weight: 650; color: var(--ledger); border-color: var(--rule); }
.btn-save:hover { background: var(--ledger); border-color: var(--ledger); color: #fff; }
.btn-delete { width: 32px; margin-left: 4px; color: var(--muted); }
.btn-delete:hover { color: var(--pencil-red); background: var(--red-tint); }
.btn-delete .icon { width: 17px; height: 17px; }
@media (hover: hover) {
  .btn-save, .btn-delete { opacity: 0.45; transition: opacity 120ms ease; }
  .txn-row:hover .btn-save, .txn-row:hover .btn-delete, .txn-row:focus-within .btn-save, .txn-row:focus-within .btn-delete { opacity: 1; }
}

.txn-row { scroll-margin-top: 48px; }
.txn-row.row-mismatch td { background: var(--red-tint); }
.txn-row.row-mismatch td:first-child { box-shadow: inset 4px 0 0 var(--pencil-red); }
.txn-row.row-mismatch .btn-save, .txn-row.row-mismatch .btn-delete { opacity: 1; }
.txn-row:target td { animation: flash 1.4s ease-out; }

/* ---------- Landing sections ---------- */
.how, .benefits, .comparison, .pricing { margin-top: 96px; }
.how h2, .benefits h2, .comparison h2, .pricing h2 { margin-bottom: 28px; }
.offer-heading { font-size: 1.0625rem; font-weight: 650; margin: 0 0 6px; color: var(--ink); }
.prose { max-width: 40rem; display: grid; gap: 28px; color: var(--ink-soft); }
.prose h2 { font-size: var(--step-2); margin: 0 0 8px; color: var(--ink); }
.prose p { margin: 0; line-height: 1.55; }
.steps { list-style: none; counter-reset: step; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 32px; }
.step { counter-increment: step; border-top: 2px solid var(--ink); padding-top: 18px; }
.step::before { content: counter(step); display: block; font-size: var(--step-4); font-weight: 800; line-height: 1; color: var(--ledger); margin-bottom: 14px; letter-spacing: -0.03em; }
.step h3 { margin-bottom: 8px; }
.step p { color: var(--ink-soft); margin: 0; max-width: 38ch; }

.table-wrap { overflow-x: auto; border: 1px solid var(--rule); border-radius: var(--r-panel); background: var(--surface); }
.compare-table { width: 100%; min-width: 640px; border-collapse: collapse; }
.compare-table th, .compare-table td { padding: 14px 18px; text-align: left; border-bottom: 1px solid var(--rule); vertical-align: top; }
.compare-table tbody tr:last-child > * { border-bottom: 0; }
.compare-table thead th { font-size: 0.9375rem; font-weight: 700; border-bottom: 1px solid var(--rule-strong); }
.compare-table tbody th { font-weight: 500; color: var(--ink); width: 32%; }
.compare-table td { color: var(--ink-soft); }
.compare-table .col-us { background: var(--ledger-tint); color: var(--ink); font-weight: 650; }
.compare-table thead .col-us { color: var(--ledger-deep); }
.mark { display: inline-block; width: 16px; height: 16px; margin: 0 8px -3px 0; background: no-repeat center / contain; }
.mark-yes { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M2.5 8.5l3.5 3.5 7.5-8' fill='none' stroke='%232f8f5b' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E"); }
.mark-no { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M4 4l8 8M12 4l-8 8' fill='none' stroke='%23c8372d' stroke-width='2' stroke-linecap='round'/%3E%3C/svg%3E"); }
.mark-some { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M4 8h8' fill='none' stroke='%23b7791f' stroke-width='2.2' stroke-linecap='round'/%3E%3C/svg%3E"); }

.plans { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 20px; align-items: stretch; }
.plan { display: flex; flex-direction: column; gap: 10px; background: var(--surface); border: 1px solid var(--rule); border-radius: var(--r-panel); padding: 24px; }
.plan-featured { border: 2px solid var(--ledger); padding: 23px; }
.plan-name { font-size: 1.0625rem; color: var(--ink-soft); margin: 0; font-weight: 650; }
.plan-price { font-size: var(--step-4); font-weight: 800; letter-spacing: -0.03em; line-height: 1; margin: 0; }
.plan-unit { font-size: var(--step-0); font-weight: 500; color: var(--muted); letter-spacing: 0; }
.plan-points { list-style: none; padding: 0; margin: 4px 0 8px; color: var(--ink-soft); flex: 1; }
.plan-points li { padding: 6px 0; border-top: 1px solid var(--rule); }
.plan form .btn { width: 100%; }
.plan-single { max-width: 420px; }
.plan-single p:last-child { margin: 0; color: var(--ink-soft); }
.auth-form { margin-top: 24px; max-width: 520px; }
.auth-form label { display: block; font-weight: 600; margin-bottom: 8px; }

/* ---------- Pay screen ---------- */
.nudge-head { display: flex; gap: 20px; align-items: flex-start; margin-bottom: 28px; }
.nudge-head h1 { font-size: var(--step-3); }
.nudge-tick { width: 56px; height: 48px; flex: none; fill: none; stroke: var(--tick); stroke-width: 5; stroke-linecap: round; stroke-linejoin: round; margin-top: 2px; }
.nudge-tick path { stroke-dasharray: 1; stroke-dashoffset: 1; animation: draw 650ms cubic-bezier(0.65, 0, 0.35, 1) 150ms forwards; }
.offers { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; margin: 0 0 24px; }
.offer { background: var(--surface); border: 1px solid var(--rule); border-radius: var(--r-panel); padding: 22px; display: flex; flex-direction: column; gap: 6px; }
.offer-featured { border: 2px solid var(--ledger); padding: 21px; }
.offer-price { font-size: var(--step-4); font-weight: 800; letter-spacing: -0.03em; margin: 0; line-height: 1; }
.offer-unit { margin-left: 4px; font-size: var(--step-0); font-weight: 500; color: var(--muted); letter-spacing: 0; }
.offer-terms { color: var(--ink-soft); margin: 0 0 8px; }
.offer form { margin-top: auto; }
.offer form .btn { width: 100%; }
.nudge .auth-form { margin-top: 0; }
.continue-free { margin-top: 28px; padding-top: 20px; border-top: 1px solid var(--rule); }
.continue-link { position: relative; display: inline-block; font-weight: 650; padding-bottom: 4px; }
.continue-link.waiting { color: var(--muted); cursor: default; text-decoration: none; }
.continue-link.waiting::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 2px; background: var(--rule-strong); transform-origin: left; animation: countdown 5s linear forwards; }

/* ---------- Notices: magic link, errors, fake checkout ---------- */
.notice { text-align: center; padding: 48px 0 24px; }
.notice .lede { margin-bottom: 12px; }
.notice-icon { width: 64px; height: 54px; fill: none; stroke: var(--ledger); stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; margin-bottom: 16px; }
.notice-error .notice-icon { stroke: var(--pencil-red); }
.notice-error .error { font-size: var(--step-1); margin-bottom: 24px; }
.test-banner {
  display: inline-block; padding: 8px 14px; border: 1px solid var(--amber-rule); border-radius: var(--r-control); color: #6f4a10;
  background: repeating-linear-gradient(-45deg, #fff6e3 0 10px, #fdedc6 10px 20px); font-weight: 600; font-size: 0.9rem; margin-bottom: 24px;
}
.fake-checkout form { margin: 8px 0 16px; }

/* ---------- Motion ---------- */
@keyframes draw { to { stroke-dashoffset: 0; } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes countdown { from { transform: scaleX(0); } to { transform: scaleX(1); } }
@keyframes flash { from { background-color: #fde3a7; } }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: 1ms !important; animation-delay: 0ms !important; transition-duration: 1ms !important; }
}

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .hero { grid-template-columns: minmax(0, 1fr); gap: 40px; }
  .footing { grid-template-columns: minmax(0, 1fr); }
  .steps, .plans { grid-template-columns: minmax(0, 1fr); gap: 24px; }
}
@media (max-width: 600px) {
  .container { padding: 24px 16px 56px; }
  .site-header-inner, .site-footer-inner { padding-left: 16px; padding-right: 16px; }
  .site-nav a { padding: 6px 8px; font-size: 0.9375rem; }
  .site-nav a[href="/#how"] { display: none; }
  /* Phones: the install button gets its own small row, so the main row still fits. */
  .site-header-inner { flex-wrap: wrap; row-gap: 6px; }
  .install-app { order: 3; margin-left: auto; padding: 3px 10px; font-size: 0.875rem; }
  .install-hint { padding-left: 16px; padding-right: 16px; }
  .logo span { font-size: 1rem; }
  .how, .benefits, .comparison, .pricing { margin-top: 64px; }
  .proof-card { padding: 18px 16px 16px 34px; }
  .proof-card::before { left: 16px; }
  .footing-lines { padding: 10px 16px 14px; }
  .recon-banner { padding: 18px 16px; gap: 12px; }
  .recon-message { font-size: var(--step-1); }
  .offers { grid-template-columns: minmax(0, 1fr); }
  .export-toolbar { justify-content: flex-start; width: 100%; }
  .export-label { display: none; }
  .page-head .exports { order: 3; width: 100%; flex-wrap: wrap; }
  .page-head .exports .btn-export { flex: 1 1 auto; padding: 0 10px; }
}
@media (max-width: 440px) {
  .page-head .exports { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
  .page-head .exports .btn-export { margin-left: 0; border-radius: var(--r-control); padding: 0 6px; }
}

/* Row order: toolbar, drag handle, drop marks, date-order chip (static/app.js) */
.table-toolbar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin: 0 0 10px; }
.table-toolbar .btn { min-height: 36px; gap: 6px; }
.btn-attention { border-color: var(--amber); background: var(--amber-tint); }
.toolbar-note { margin: 0; font-size: var(--step--1); color: var(--ink); }
.toolbar-hint { color: var(--muted); }
.txn-table th.col-handle, .txn-table td.col-handle { width: 28px; padding-left: 10px; padding-right: 0; }
.drag-handle { display: inline-grid; place-items: center; width: 24px; height: 30px; border: 0; border-radius: var(--r-input); background: transparent; color: var(--muted); cursor: grab; padding: 0; }
.drag-handle svg { width: 10px; height: 16px; fill: currentColor; }
.drag-handle:hover { background: var(--ledger-tint); color: var(--ledger-deep); }
.drag-handle:focus-visible { outline: none; box-shadow: var(--focus); color: var(--ledger-deep); }
.drag-handle:active { cursor: grabbing; }
tr.dragging td { opacity: 0.45; }
tr.drop-before td { box-shadow: inset 0 2px 0 var(--ledger); }
tr.drop-after td { box-shadow: inset 0 -2px 0 var(--ledger); }
tr.row-moved td { animation: row-moved 1.2s ease-out; }
@keyframes row-moved { from { background: var(--ledger-tint); } to { background: transparent; } }
/* Sits under the date input (the date cell is nowrap and the input fills it). */
.date-order-chip { display: table; margin: 8px 0 -2px 8px; padding: 1px 7px 1px 6px; border-radius: 999px; background: var(--amber-tint); border: 1px solid var(--amber-rule); color: var(--ink); font-size: 0.72rem; line-height: 1.4; white-space: nowrap; }
.date-order-chip::before { content: "↕"; margin-right: 4px; color: var(--amber); }
@media (prefers-reduced-motion: reduce) { tr.row-moved td { animation: none; } }

/* ---------- Batch review ---------- */
.headline-needs-balances { color: var(--amber); }
.headline-subline { margin: 4px 0 0; color: var(--muted); font-size: var(--step-0); }
.export-toolbar .export-note { flex-basis: 100%; margin: 0 0 6px; font-size: var(--step--1); color: var(--muted); }
.batch-tablist { display: flex; gap: 8px; margin: 0 0 16px; border-bottom: 1px solid var(--rule); }
.batch-tablist [role="tab"] { border: 0; border-bottom: 2px solid transparent; background: transparent; padding: 8px 12px; font: inherit; cursor: pointer; color: var(--muted); margin-bottom: -1px; }
.batch-tablist [role="tab"][aria-selected="true"] { color: var(--ledger-deep); border-bottom-color: var(--ledger); font-weight: 600; }
.batch-files-table td { font-variant-numeric: normal; }
.batch-files-table .batch-rows-col { font-variant-numeric: tabular-nums; }
.batch-status-detail { display: grid; gap: 8px; max-width: 28rem; font-size: var(--step--1); }
.batch-balances-form { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: flex-end; }
.batch-balances-form label { display: grid; gap: 2px; font-size: var(--step--1); }
.batch-balances-form input { min-height: 36px; width: 9rem; padding: 0 10px; border: 1px solid var(--rule-strong); border-radius: var(--r-input); background: var(--surface); font: inherit; font-size: var(--step-0); font-variant-numeric: tabular-nums; color: var(--ink); }
.batch-balances-form input:focus { outline: none; border-color: var(--ledger); box-shadow: var(--focus); }
.batch-balances-form .btn { min-height: 36px; padding: 0 14px; }
.batch-files-table td { vertical-align: top; }
.batch-files-table .batch-rows-col { text-align: right; }
.batch-status-detail strong { font-size: var(--step-0); }
.batch-txn-group-head { color: var(--ink-soft); }
.batch-txn-group-head strong { color: var(--ink); }
.batch-txn-group-head a { margin-left: 8px; }
.batch-balances-form .form-error { margin: 0; color: var(--pencil-red); font-size: var(--step--1); }
.batch-txn-group { margin-bottom: 24px; }
.batch-txn-group-muted { opacity: 0.72; }
.batch-txn-group-head { margin: 0 0 8px; font-size: var(--step--1); }
.batch-muted-label { color: var(--muted); margin-left: 6px; }
