/* Chhatraya web. Tokens follow docs/DESIGN.md; keep the two in step. */

@font-face {
  font-family: 'IBM Plex Sans';
  src: url('./fonts/ibm-plex-sans-var-latin.woff2') format('woff2');
  font-weight: 400 600;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'IBM Plex Sans';
  src: url('./fonts/ibm-plex-sans-var-latin-ext.woff2') format('woff2');
  font-weight: 400 600;
  font-display: swap;
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'Anek Latin';
  src: url('./fonts/anek-latin-600-87-latin.woff2') format('woff2');
  font-weight: 600;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Anek Latin';
  src: url('./fonts/anek-latin-600-87-latin-ext.woff2') format('woff2');
  font-weight: 600;
  font-display: swap;
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

:root {
  color-scheme: light;
  --canvas: #f4f6f5;
  --card: #ffffff;
  --outline: #dde3e0;
  --outline-strong: #b9c4bf;
  --ink: #14201c;
  --ink-muted: #4e5b56;
  --ink-faint: #66726d;
  --canopy-900: #123d33;
  --canopy-700: #1f6f54;
  --canopy-100: #e3f0ea;
  --haldi-500: #d99a1e;
  --haldi-100: #fbf0d9;
  --haldi-ink: #8a5a00;
  --principal: #1f6f54;
  --interest: #4c5a9a;
  --on-hero: #ffffff;
  --on-hero-muted: rgba(255, 255, 255, 0.72);
  --hero-track: rgba(255, 255, 255, 0.16);
  --hero-outline: transparent;
  --danger: #b3261e;
  --danger-bg: #fdecea;
  --warning: #8a5a00;
  --warning-bg: #fff0d4;
  --focus: #1f6f54;
  --button-primary: #1f6f54;
  --button-primary-ink: #ffffff;

  --font-body: 'IBM Plex Sans', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --font-display: 'Anek Latin', 'IBM Plex Sans', system-ui, sans-serif;

  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 24px; --s6: 32px; --s7: 48px;
  --r-card: 20px; --r-control: 14px; --r-chip: 10px;
  --gutter: 16px;
  --measure: 600px;
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --canvas: #0e1412;
    --card: #17201d;
    --outline: #2b3632;
    --outline-strong: #43514b;
    --ink: #e8eeeb;
    --ink-muted: #a9b5b0;
    --ink-faint: #8a9690;
    --canopy-900: #0f2f27;
    --canopy-700: #5cc09a;
    --canopy-100: #1c3a31;
    --haldi-500: #e8b04a;
    --haldi-100: #33280f;
    --haldi-ink: #e8b04a;
    --principal: #5cc09a;
    --interest: #9aa8e0;
    --hero-outline: #24453c;
    --danger: #f2b8b5;
    --danger-bg: #3a1a18;
    --warning: #f0c36b;
    --warning-bg: #3d2e0a;
    --focus: #5cc09a;
    --button-primary: #5cc09a;
    --button-primary-ink: #0e1412;
  }
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--canvas);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 22px;
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
}

h1, h2, p, dl, dd, figure, fieldset { margin: 0; }
fieldset { border: 0; padding: 0; min-width: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
svg { display: block; }
:focus { outline: none; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
[tabindex='-1']:focus-visible { outline: none; }

.icon-sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.visually-hidden {
  position: absolute !important; 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: var(--s4); top: -64px; z-index: 20;
  padding: var(--s2) var(--s4); border-radius: var(--r-chip);
  background: var(--button-primary); color: var(--button-primary-ink); text-decoration: none;
}
.skip-link:focus-visible { top: var(--s2); }

/* App bar */
.app-bar { border-bottom: 1px solid var(--outline); background: var(--canvas); }
.app-bar-inner {
  max-width: calc(var(--measure) + 2 * var(--gutter));
  margin: 0 auto;
  padding: 0 var(--gutter);
  height: 56px;
  display: flex; align-items: center; justify-content: space-between;
}
.brand { color: inherit; text-decoration: none; display: inline-flex; align-items: center; gap: 10px; font-family: var(--font-display); font-weight: 600; font-size: 21px; letter-spacing: 0; }
.brand-mark { width: 30px; height: 20px; fill: none; stroke-linecap: round; }
.brand-arc { stroke: var(--canopy-700); stroke-width: 3.5; }
.brand-roof { stroke: var(--ink); stroke-width: 3; }
.start-over { min-height: 44px; padding: 0 var(--s2); margin-right: calc(-1 * var(--s2)); }

/* Page */
.page {
  flex: 1;
  width: 100%;
  max-width: calc(var(--measure) + 2 * var(--gutter));
  margin: 0 auto;
  padding: var(--s5) var(--gutter) var(--s7);
}
.step-panel { display: flex; flex-direction: column; gap: var(--s3); }
.step-panel > h1 {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 30px;
  line-height: 34px;
  letter-spacing: -0.2px;
  text-wrap: balance;
}
.lead { color: var(--ink-muted); margin-bottom: var(--s3); text-wrap: pretty; }

/* Steps */
.steps { list-style: none; margin: 0 0 var(--s5); padding: 0; display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.steps li { display: flex; flex-direction: column; gap: 6px; }
.steps-bar { height: 4px; border-radius: 2px; background: var(--outline); }
.steps-label { font-size: 12px; line-height: 16px; font-weight: 500; color: var(--ink-faint); }
.steps li.is-done .steps-bar, .steps li.is-current .steps-bar { background: var(--canopy-700); }
.steps li.is-current .steps-label { color: var(--ink); }

/* Cards */
.card {
  background: var(--card);
  border: 1px solid var(--outline);
  border-radius: var(--r-card);
  padding: var(--s4);
}
.card-head { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); margin-bottom: var(--s3); min-height: 24px; }
.card-head .button.small { margin: -10px -4px; }
.card-head h2 { font-size: 17px; line-height: 24px; font-weight: 600; white-space: nowrap; }
.card-meta { font-size: 13px; line-height: 18px; color: var(--ink-faint); text-align: right; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Choice list (step 0) */
.choice-list {
  position: relative;
  background: var(--card);
  border: 1px solid var(--outline);
  border-radius: var(--r-card);
  overflow: hidden;
}
.choice-row {
  width: 100%;
  display: flex; align-items: center; gap: var(--s3);
  min-height: 72px;
  padding: var(--s3) var(--s4);
  background: transparent;
  border: 0;
  border-top: 1px solid var(--outline);
  text-align: left;
  cursor: pointer;
}
.choice-list > .choice-row:first-child { border-top: 0; }
.choice-row:hover { background: color-mix(in srgb, var(--canopy-100) 45%, transparent); }
.choice-row:focus-visible { outline-offset: -2px; border-radius: var(--r-card); }
#choice-list:has(#file-input:focus-visible) #upload-choice { outline: 2px solid var(--focus); outline-offset: -2px; }
.choice-icon {
  flex: none; width: 40px; height: 40px; border-radius: 12px;
  display: grid; place-items: center;
  background: var(--canopy-100); color: var(--canopy-700);
}
.choice-icon svg, .chevron, .privacy-line svg, .file-icon, .button svg, .icon-button svg {
  width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round;
}
.choice-text { flex: 1; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.choice-text strong { font-weight: 600; }
.choice-text small, .radio-row small { font-size: 13px; line-height: 18px; color: var(--ink-muted); }
.chevron { color: var(--ink-faint); flex: none; }
.drop-hint {
  position: absolute; inset: 0; display: none; place-items: center;
  background: color-mix(in srgb, var(--card) 92%, transparent);
  border: 2px dashed var(--canopy-700); border-radius: var(--r-card);
  font-weight: 600; color: var(--canopy-700);
}
.choice-list.is-dragging .drop-hint { display: grid; }

.privacy-line { display: flex; gap: var(--s2); align-items: flex-start; color: var(--ink-muted); font-size: 13px; line-height: 18px; margin-top: var(--s1); }
.privacy-line svg { width: 16px; height: 16px; margin-top: 1px; flex: none; }
.start-links { display: flex; flex-wrap: wrap; gap: var(--s1) var(--s4); margin-top: var(--s2); }

/* File panel */
.file-panel { display: flex; flex-direction: column; gap: var(--s4); }
.file-head { display: flex; gap: var(--s3); align-items: flex-start; }
.file-icon { color: var(--ink-muted); margin-top: 1px; flex: none; }
.file-meta { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.file-meta strong { font-weight: 600; overflow-wrap: anywhere; }
.file-meta span { color: var(--ink-muted); font-size: 13px; line-height: 18px; }
.file-meta span.is-error { color: var(--danger); }
.file-section { display: flex; flex-direction: column; gap: var(--s2); padding-top: var(--s4); border-top: 1px solid var(--outline); }
.file-actions { margin-top: calc(-1 * var(--s2)); }
.inline-field { display: flex; gap: var(--s2); }
.inline-field .input { flex: 1; min-width: 0; }
.ocr-progress { display: flex; flex-direction: column; gap: var(--s2); }
.progress-track { height: 6px; border-radius: 3px; background: var(--outline); overflow: hidden; }
.progress-track span { display: block; height: 100%; width: 0; background: var(--canopy-700); transition: width 200ms ease-out; }

/* Fields */
.field-stack { display: flex; flex-direction: column; gap: var(--s5); }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field-pair { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s4); }
.field-label { font-weight: 500; font-size: 14px; line-height: 20px; color: var(--ink); }
.optional { font-weight: 400; color: var(--ink-faint); }
.field-hint { font-size: 13px; line-height: 18px; color: var(--ink-muted); }
.field-error { font-size: 13px; line-height: 18px; color: var(--danger); }
.amount-words { font-size: 13px; line-height: 18px; color: var(--ink-faint); min-height: 18px; }
.amount-words:empty { display: none; }

.input {
  width: 100%;
  min-height: 48px;
  padding: 0 14px;
  border: 1px solid var(--outline-strong);
  border-radius: var(--r-control);
  background: var(--card);
  color: var(--ink);
  font-size: 16px;
  font-variant-numeric: tabular-nums;
  transition: border-color 120ms ease-out;
}
.input:hover { border-color: var(--ink-faint); }
.input:focus-visible { outline: none; border-color: var(--focus); box-shadow: 0 0 0 1px var(--focus); }
.input[aria-invalid='true'] { border-color: var(--danger); }
.input[aria-invalid='true']:focus-visible { box-shadow: 0 0 0 1px var(--danger); }
select.input {
  appearance: none;
  padding-right: 40px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2366726d' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 18px;
}
.input-date { padding-right: 10px; }
.textarea { min-height: 200px; padding: 12px 14px; line-height: 22px; resize: vertical; }

.affix-input { position: relative; display: flex; align-items: center; }
.affix-input .input { flex: 1; }
.affix { position: absolute; color: var(--ink-faint); pointer-events: none; font-size: 16px; }
.affix:first-child { left: 14px; }
.affix:first-child + .input { padding-left: 32px; }
.affix-input .input:not(:last-child) { padding-right: 84px; }
.affix:last-child { right: 14px; font-size: 14px; }

.lender-match { color: var(--canopy-700); }
.lender-match:empty { display: none; }
.source {
  display: inline-flex; align-items: center; gap: 6px; align-self: flex-start;
  font-size: 12px; line-height: 16px; font-weight: 500; color: var(--ink-muted);
}
.source::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: var(--ink-faint); }
.source.is-found::before { background: var(--canopy-700); }
.source.is-check { color: var(--warning); }
.source.is-check::before { background: var(--haldi-500); }

/* Radio rows */
.segmented-card { padding: 0; overflow: hidden; }
.radio-row {
  display: flex; align-items: flex-start; gap: var(--s3);
  padding: 14px var(--s4); min-height: 64px; cursor: pointer;
}
.radio-row + .radio-row { border-top: 1px solid var(--outline); }
.radio-row span { display: flex; flex-direction: column; gap: 2px; }
.radio-row strong { font-weight: 600; }
.radio-row input {
  appearance: none; flex: none; margin: 1px 0 0;
  width: 20px; height: 20px; border-radius: 50%;
  border: 1.5px solid var(--outline-strong); background: var(--card);
  display: grid; place-items: center; cursor: pointer;
}
.radio-row input::after { content: ''; width: 10px; height: 10px; border-radius: 50%; background: var(--canopy-700); transform: scale(0); transition: transform 120ms ease-out; }
.radio-row input:checked { border-color: var(--canopy-700); }
.radio-row input:checked::after { transform: scale(1); }
.radio-row:has(input:checked) { background: color-mix(in srgb, var(--canopy-100) 50%, transparent); }

/* Payout ledger */
.ledger:not(:empty) { margin-bottom: var(--s4); border-bottom: 1px solid var(--outline); }
.ledger-row { display: grid; grid-template-columns: 1fr auto 44px; align-items: center; gap: var(--s3); padding: 10px 0; border-top: 1px solid var(--outline); }
.ledger-row:first-child { border-top: 0; padding-top: 0; }
.ledger-row div { display: flex; flex-direction: column; min-width: 0; }
.ledger-row div span { font-size: 13px; line-height: 18px; color: var(--ink-muted); overflow-wrap: anywhere; }
.ledger-row strong { font-weight: 600; }
.ledger-total { display: flex; justify-content: space-between; padding: 10px 0; border-top: 1px solid var(--outline); font-weight: 600; }
.add-row { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s4); }
.field-wide { grid-column: 1 / -1; }

/* Buttons */
.button {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s2);
  min-height: 48px; padding: 0 20px;
  border-radius: var(--r-control); border: 1px solid transparent;
  font-weight: 600; font-size: 15px; line-height: 20px;
  cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: background-color 120ms ease-out, border-color 120ms ease-out, opacity 120ms ease-out;
}
.button:disabled { opacity: 0.55; cursor: progress; }
.button.primary { background: var(--button-primary); color: var(--button-primary-ink); }
.button.primary:hover:not(:disabled) { opacity: 0.88; }
.button.secondary { background: var(--card); border-color: var(--outline-strong); color: var(--ink); }
.button.secondary:hover:not(:disabled) { border-color: var(--ink-faint); }
.button.danger { background: var(--danger); color: var(--card); }
/* A text button keeps a 44px target, and its label lines up with the text around it. */
.button.text { background: none; border: 0; padding: 0 var(--s1); margin-inline: calc(-1 * var(--s1)); min-height: 44px; color: var(--canopy-700); }
.button.text:hover { text-decoration: underline; text-underline-offset: 3px; }
.button.small { min-height: 44px; font-size: 14px; }
.button-row { display: flex; flex-wrap: wrap; gap: var(--s2); }
/* A control after content in a stacked card gets one step of space. A text button's
   label already sits 12px inside its 44px target, so it needs only 4px more.
   Zero specificity, so any card that spaces its own controls wins. */
:where(.card:not(.goal-card, .empty-card, .signin-card, .insight) > *) + :where(.button, .button-row) { margin-top: var(--s4); }
:where(.card:not(.goal-card, .empty-card, .signin-card, .insight) > *) + :where(.button.text) { margin-top: var(--s1); }
/* A text button that ends a card gives back the space under its label, so the
   card's bottom padding matches its top. */
:where(.card:not(.goal-card, .empty-card, .signin-card, .insight) > .button.text:last-child) { margin-bottom: calc(-1 * var(--s3)); }
.icon-button {
  width: 44px; height: 44px; display: grid; place-items: center;
  border: 0; border-radius: 12px; background: none; color: var(--ink-muted); cursor: pointer;
}
.icon-button:hover { background: var(--canvas); color: var(--ink); }
.remove-button { justify-self: end; }

.actions {
  display: grid; grid-template-columns: 1fr 2fr; gap: var(--s3);
  margin-top: var(--s4);
}
.actions > [hidden] + .button { grid-column: 1 / -1; }

/* Banners */
.banner { padding: var(--s3) var(--s4); border-radius: var(--r-control); background: var(--canopy-100); font-size: 14px; line-height: 20px; }
.banner-warning { background: var(--warning-bg); color: var(--warning); }
.banner-error { background: var(--danger-bg); color: var(--danger); }

/* Raw text */
.raw-text { padding: 0; }
.raw-text summary { padding: 14px var(--s4); min-height: 48px; cursor: pointer; font-weight: 500; color: var(--ink-muted); list-style-position: inside; }
.raw-text[open] summary { border-bottom: 1px solid var(--outline); }
#page-text { padding: var(--s4); display: flex; flex-direction: column; gap: var(--s4); max-height: 420px; overflow: auto; }
.page-block { font-size: 13px; line-height: 20px; white-space: pre-wrap; overflow-wrap: anywhere; color: var(--ink-muted); }
.page-block b { display: block; color: var(--ink); font-weight: 600; margin-bottom: var(--s1); }

/* Result: hero */
.hero {
  background: var(--canopy-900);
  color: var(--on-hero);
  border: 1px solid var(--hero-outline);
  border-radius: var(--r-card);
  padding: 20px;
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-areas: 'main arc' 'stats stats';
  gap: var(--s4) var(--s4);
  align-items: center;
}
.hero-main { grid-area: main; min-width: 0; }
.hero-label { color: var(--on-hero-muted); font-size: 13px; line-height: 18px; }
.hero-amount { font-family: var(--font-display); font-weight: 600; font-size: 40px; line-height: 44px; margin-top: var(--s1); white-space: nowrap; }
.canopy { grid-area: arc; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.canopy-dial { position: relative; width: 128px; }
.canopy-dial svg { width: 100%; height: auto; overflow: visible; fill: none; stroke-linecap: round; stroke-width: 10; }
.canopy-track { stroke: var(--hero-track); }
.canopy-fill { stroke: var(--haldi-500); stroke-dasharray: 100 100; stroke-dashoffset: 100; transition: stroke-dashoffset 600ms cubic-bezier(0.22, 1, 0.36, 1); }
.canopy-dial strong {
  position: absolute; left: 0; right: 0; bottom: -2px; text-align: center;
  font-family: var(--font-display); font-weight: 600; font-size: 24px; line-height: 28px;
}
.canopy figcaption { color: var(--on-hero-muted); font-size: 12px; line-height: 16px; white-space: nowrap; }
.hero-stats {
  grid-area: stats;
  display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--s3);
  padding-top: var(--s4);
  border-top: 1px solid rgba(255, 255, 255, 0.14);
}
.hero-stats dt { color: var(--on-hero-muted); font-size: 13px; line-height: 18px; }
.hero-stats dd { font-weight: 600; font-size: 16px; line-height: 22px; margin-top: 2px; }

/* Result: check and rows */
.status { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; line-height: 18px; font-weight: 500; color: var(--ink-muted); white-space: nowrap; }
.status::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: var(--ink-faint); }
.status.is-ok::before { background: var(--canopy-700); }
.status.is-warning { color: var(--warning); }
.status.is-warning::before { background: var(--haldi-500); }
.status.is-danger { color: var(--danger); }
.status.is-danger::before { background: var(--danger); }
.check-headline { font-family: var(--font-display); font-weight: 600; font-size: 22px; line-height: 27px; text-wrap: balance; }
.check-body { color: var(--ink-muted); margin-top: var(--s2); text-wrap: pretty; }
.check-card .rows { margin-top: var(--s4); }
.check-next { margin-top: var(--s4); padding-top: var(--s3); border-top: 1px solid var(--outline); font-size: 14px; line-height: 20px; }
.check-next:empty { display: none; }

.rows > div { display: flex; justify-content: space-between; align-items: baseline; gap: var(--s4); padding: 10px 0; border-top: 1px solid var(--outline); }
.rows > div:first-child { border-top: 0; padding-top: 0; }
.rows > div:last-child { padding-bottom: 0; }
.rows dt { color: var(--ink-muted); }
.rows dd { font-weight: 600; text-align: right; overflow-wrap: anywhere; }
.rows dd small { display: block; font-weight: 400; font-size: 12px; line-height: 16px; color: var(--ink-faint); }
.rows dd.is-missing { font-weight: 400; color: var(--ink-faint); }

.footnote { font-size: 13px; line-height: 18px; color: var(--ink-faint); margin-top: var(--s2); }

/* Footer */
.page-footer { padding: var(--s4) var(--gutter) calc(var(--s5) + env(safe-area-inset-bottom)); text-align: center; color: var(--ink-faint); font-size: 12px; line-height: 16px; }

/* Dialogs */
dialog {
  width: min(560px, calc(100vw - 2 * var(--gutter)));
  max-height: calc(100dvh - 2 * var(--gutter));
  padding: 0; border: 1px solid var(--outline); border-radius: var(--r-card);
  background: var(--card); color: var(--ink);
}
dialog::backdrop { background: rgba(14, 20, 18, 0.48); }
.dialog-card { padding: 20px; display: flex; flex-direction: column; gap: var(--s2); }
.dialog-card h2 { font-size: 18px; line-height: 24px; font-weight: 600; }
.dialog-head { display: flex; align-items: center; justify-content: space-between; margin: -6px -8px var(--s2) 0; }
.dialog-actions { display: flex; justify-content: flex-end; gap: var(--s2); margin-top: var(--s3); flex-wrap: wrap; }

/* Small screens */
@media (max-width: 479px) {
  .page { padding-top: var(--s4); }
  .step-panel > h1, .view > h1 { font-size: 26px; line-height: 30px; }
  .toast { bottom: calc(96px + env(safe-area-inset-bottom)); }
  .field-pair, .add-row { grid-template-columns: 1fr; }
  .actions {
    position: sticky; bottom: 0; z-index: 5;
    margin: var(--s4) calc(-1 * var(--gutter)) 0;
    padding: var(--s3) var(--gutter) calc(var(--s3) + env(safe-area-inset-bottom));
    background: var(--canvas);
    border-top: 1px solid var(--outline);
  }
  .view:not(#view-add) .actions { position: static; border-top: 0; margin: var(--s2) 0 0; padding: 0; background: none; }
  .hero { grid-template-columns: 1fr; grid-template-areas: 'main' 'arc' 'stats'; }
  .canopy { flex-direction: row; justify-content: flex-start; gap: var(--s4); }
  .canopy-dial { width: 104px; }
  .canopy-dial strong { font-size: 21px; line-height: 24px; }
  .canopy figcaption { white-space: normal; font-size: 13px; line-height: 18px; }
  .hero-amount { font-size: 36px; line-height: 40px; }
  .page-footer { padding-bottom: var(--s4); }
  .session-name { display: none; }
  .nav-signin { min-height: 44px; padding: 0 var(--s2); }
.code-input { text-align: center; font-size: 24px; letter-spacing: 8px; font-variant-numeric: tabular-nums; }
.signin-links { display: flex; flex-wrap: wrap; justify-content: space-between; gap: var(--s2); }
.signin-card { display: flex; flex-direction: column; gap: var(--s3); }
.signin-card .button { align-self: flex-start; }
.session-chip { padding: 0 6px; }
}
@media (max-width: 359px) {
  .hero-amount { font-size: 32px; line-height: 36px; }
  .hero-stats { grid-template-columns: 1fr 1fr; }
}

/* Views */
.view { display: flex; flex-direction: column; gap: var(--s3); }
#view-add { display: block; }
.view > h1 {
  font-family: var(--font-display); font-weight: 600; font-size: 30px; line-height: 34px; letter-spacing: -0.2px; text-wrap: balance;
}
.loading { color: var(--ink-faint); padding: var(--s7) 0; text-align: center; }
.stack { display: flex; flex-direction: column; gap: var(--s3); }
.section-title { font-size: 17px; line-height: 24px; font-weight: 600; margin-top: var(--s4); }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); margin-top: var(--s4); scroll-margin-top: var(--s4); }
.section-head .section-title { margin-top: 0; }
.back-link { display: inline-flex; align-items: center; gap: 2px; align-self: flex-start; min-height: 44px; margin: calc(-1 * var(--s3)) 0 calc(-1 * var(--s2)) -6px; color: var(--canopy-700); font-weight: 500; text-decoration: none; }
.back-link svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* App nav */
.app-nav { display: flex; gap: var(--s1); margin-right: calc(-1 * var(--s2)); }
.nav-button { position: relative; color: var(--ink-muted); text-decoration: none; }
.nav-button[aria-current] { color: var(--canopy-700); background: var(--canopy-100); }
.session-chip {
  display: inline-flex; align-items: center; gap: var(--s2); min-height: 44px; padding: 0 var(--s2) 0 6px;
  border-radius: 22px; color: var(--ink); font-size: 14px; font-weight: 500; text-decoration: none;
}
.session-chip:hover { background: var(--canopy-100); }
.avatar {
  width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; flex: none;
  background: var(--canopy-700); color: var(--button-primary-ink); font-size: 12px; font-weight: 600; letter-spacing: 0.3px;
}
.avatar.is-empty::before { content: ''; width: 12px; height: 12px; border-radius: 50%; background: currentColor; box-shadow: 0 9px 0 -2px currentColor; transform: translateY(-3px); }
.session-name { max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.app-bar-inner { gap: var(--s2); }
.app-nav { align-items: center; margin-left: auto; }
.badge {
  position: absolute; top: 6px; right: 5px; min-width: 18px; height: 18px; padding: 0 5px;
  border-radius: 9px; background: var(--danger); color: var(--card);
  font-size: 11px; line-height: 18px; font-weight: 600; text-align: center;
}

/* Home */
.alert-banner {
  display: flex; align-items: center; justify-content: space-between; gap: var(--s3);
  min-height: 48px; padding: var(--s3) var(--s4); border-radius: var(--r-control);
  background: var(--warning-bg); color: var(--warning); font-weight: 500; text-decoration: none;
}
.alert-banner .chevron { color: currentColor; }
.hero-total { grid-template-columns: 1fr; grid-template-areas: 'main' 'stats'; }
.hero-total .hero-stats { grid-template-columns: repeat(2, 1fr); }
.loan-card { display: flex; flex-direction: column; gap: var(--s3); color: inherit; text-decoration: none; }
.loan-card:hover { border-color: var(--outline-strong); }
.loan-card-top, .loan-card-bottom { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--s3); }
.loan-card-bottom { align-items: flex-end; }
.loan-card-name { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.loan-card-name strong { font-size: 17px; line-height: 24px; font-weight: 600; overflow-wrap: anywhere; }
.loan-card-name span, .loan-card-label { font-size: 13px; line-height: 18px; color: var(--ink-muted); }
.loan-card-label { display: block; }
.loan-card-amount { font-family: var(--font-display); font-weight: 600; font-size: 24px; line-height: 28px; }
.chip { display: inline-flex; align-items: center; min-height: 28px; padding: 0 10px; border-radius: var(--r-chip); background: var(--canopy-100); color: var(--canopy-700); font-size: 12px; font-weight: 500; }
.add-another { align-self: flex-start; }
.canopy-mini { width: 40px; flex: none; }
.canopy-mini svg, .canopy-empty svg { width: 100%; height: auto; fill: none; stroke-linecap: round; stroke-width: 14; overflow: visible; }
.canopy-mini .canopy-track { stroke: var(--canopy-100); }
.canopy-mini .canopy-fill { stroke: var(--canopy-700); }
.canopy-empty { width: 56px; }
.canopy-empty .canopy-track { stroke: var(--outline-strong); stroke-width: 6; }
.canopy-empty .canopy-fill { display: none; }

/* Loan tabs */
.tabs { display: flex; gap: var(--s5); border-bottom: 1px solid var(--outline); margin: var(--s1) 0 var(--s2); overflow-x: auto; scrollbar-width: none; }
.tab {
  display: inline-flex; align-items: center; min-height: 44px; margin-bottom: -1px; padding: 0 2px;
  color: var(--ink-muted); font-weight: 500; text-decoration: none; white-space: nowrap;
  border-bottom: 2px solid transparent;
}
.tab:hover { color: var(--ink); }
.tab[aria-current='page'] { color: var(--ink); border-bottom-color: var(--canopy-700); }

/* Row cards: icon, text, actions on one line */
.file-row { display: grid; grid-template-columns: 20px 1fr auto; gap: var(--s3); align-items: center; }
.file-row .file-icon { align-self: start; margin-top: 2px; }
.file-actions { display: flex; align-items: center; gap: var(--s1); }
.file-actions .button.small { min-height: 44px; padding: 0 var(--s2); }
.button.quiet { color: var(--ink-muted); }
.button.quiet:hover { color: var(--danger); }
.goal-card { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); }
.goal-card .file-meta span { font-size: 13px; line-height: 18px; color: var(--ink-muted); }
.goal-card .file-meta strong { font-size: 16px; }
.danger-zone {
  display: flex; align-items: center; justify-content: space-between; gap: var(--s4);
  margin-top: var(--s4); padding: var(--s4) 0 0; border-top: 1px solid var(--outline);
}
.danger-zone .file-meta span { font-size: 13px; line-height: 18px; color: var(--ink-muted); }
.button.danger-outline { background: transparent; border-color: var(--outline-strong); color: var(--danger); min-height: 44px; }
.button.danger-outline:hover { border-color: var(--danger); }
.actions.single { grid-template-columns: 1fr; }

/* Opportunities */
.opportunity h3, .empty-card h3 { font-size: 17px; line-height: 24px; font-weight: 600; }
.opportunity .rows { margin-top: var(--s4); }
.opportunity.insight { background: var(--haldi-100); border-color: transparent; }
.opportunity.insight .rows > div { border-color: color-mix(in srgb, var(--haldi-ink) 18%, transparent); }
.insight-link { align-self: flex-start; margin-block: var(--s2) -10px; }
.opportunity.insight { display: flex; flex-direction: column; }
.insight-amount { font-family: var(--font-display); font-weight: 600; font-size: 24px; line-height: 28px; color: var(--haldi-ink); margin-bottom: var(--s1); }
.opportunity .banner { margin-top: var(--s3); }
.goal-line { color: var(--ink-muted); font-size: 14px; line-height: 20px; }
.goal-line strong { color: var(--ink); font-weight: 600; }
.goal-date { color: var(--ink-faint); }
details.more { margin-top: var(--s3); }
details.more summary { cursor: pointer; color: var(--canopy-700); font-weight: 500; font-size: 14px; min-height: 44px; display: flex; align-items: center; }
details.more ul { margin: 0; padding-left: 18px; color: var(--ink-muted); font-size: 13px; line-height: 20px; display: flex; flex-direction: column; gap: 4px; }
details.more strong { color: var(--ink); font-weight: 500; }
.empty-card { display: flex; flex-direction: column; align-items: flex-start; gap: var(--s2); }
.empty-card .button { margin-top: var(--s2); }
.empty-card .button { align-self: flex-start; }

/* Inbox */
.inbox-list { list-style: none; margin: 0; padding: 0 var(--s4); }
.inbox-item { display: grid; grid-template-columns: 8px 1fr 44px; gap: var(--s3); padding: var(--s4) 0; border-top: 1px solid var(--outline); }
.inbox-item:first-child { border-top: 0; }
.inbox-list.compact .inbox-item { padding: var(--s3) 0; }
.dot { width: 8px; height: 8px; border-radius: 50%; margin-top: 7px; background: var(--ink-faint); }
.dot.is-danger { background: var(--danger); }
.dot.is-warning { background: var(--haldi-500); }
.dot.is-ok { background: var(--canopy-700); }
.inbox-text { min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.inbox-text strong { font-weight: 600; }
.inbox-item.is-new .inbox-text strong::after { content: 'New'; margin-left: var(--s2); padding: 1px 6px; border-radius: 6px; background: var(--canopy-100); color: var(--canopy-700); font-size: 11px; font-weight: 600; vertical-align: 2px; }
.inbox-text p { color: var(--ink-muted); font-size: 14px; line-height: 20px; }
.inbox-meta { font-size: 12px; line-height: 16px; color: var(--ink-faint); }
.inbox-actions { grid-column: 2 / -1; display: flex; flex-wrap: wrap; gap: 0 var(--s4); margin: calc(-1 * var(--s2)) 0 -10px; }
.inline-icon { width: 14px !important; height: 14px !important; margin-left: 4px; }
.inbox-item .icon-button { margin: -10px -12px 0 0; }

/* Check rows (checkbox) */
.check-row { display: flex; align-items: flex-start; gap: var(--s3); padding: 14px var(--s4); cursor: pointer; }
.check-row + .check-row { border-top: 1px solid var(--outline); }
.check-row span { display: flex; flex-direction: column; gap: 2px; }
.check-row strong { font-weight: 600; }
.check-row small { font-size: 13px; line-height: 18px; color: var(--ink-muted); }
.check-row input { width: 20px; height: 20px; margin: 1px 0 0; accent-color: var(--canopy-700); flex: none; }
.save-card { padding: 0; }
.save-card .check-row { padding: var(--s4); }
.save-card .privacy-line { margin: 0; padding: var(--s3) var(--s4) var(--s4); border-top: 1px solid var(--outline); }
.save-card #keep-letter-row[hidden] + .privacy-line { border-top: 0; padding-top: var(--s4); }
.calendar-note { padding: 0 var(--s4) var(--s4); }

/* What's moving your loan */
.factor-head { margin-bottom: var(--s1); }
.factor-scope { margin: 0 0 var(--s4); }
.factor-group + .factor-group { margin-top: var(--s4); padding-top: var(--s4); border-top: 1px solid var(--outline); }
.factor-group h3 { font-size: 13px; line-height: 18px; font-weight: 600; color: var(--ink-muted); margin: 0 0 var(--s1); }
.factor { border-top: 1px solid var(--outline); }
.factor-group h3 + .factor { border-top: 0; }
.factor summary { list-style: none; cursor: pointer; padding: var(--s3) 0; display: flex; flex-direction: column; gap: var(--s2); border-radius: 8px; }
.factor summary::-webkit-details-marker { display: none; }
.factor summary:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.factor summary:hover .factor-title { text-decoration: underline; text-underline-offset: 3px; }
.factor-line { display: flex; align-items: flex-start; gap: var(--s3); }
.factor-title { flex: 1; min-width: 0; font-weight: 500; line-height: 22px; }
.factor-amount { display: flex; flex-direction: column; align-items: flex-end; text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.factor-amount strong { font-weight: 600; line-height: 22px; }
.factor-amount small { font-size: 12px; line-height: 16px; color: var(--ink-faint); }
.factor-chevron { width: 20px; height: 20px; flex: none; margin-top: 1px; color: var(--ink-faint); transform: rotate(90deg); transition: transform 120ms ease-out; }
.factor[open] .factor-chevron { transform: rotate(-90deg); }
.factor-bar { display: block; height: 8px; margin-right: 32px; }
.factor-bar span { display: block; height: 100%; min-width: 4px; border-radius: 4px; }
.factor-bar.is-costs span { background: var(--interest); }
.factor-bar.is-saves span { background: var(--principal); }
.factor-body { padding: 0 0 var(--s4); display: flex; flex-direction: column; align-items: flex-start; gap: var(--s3); }
.factor-body .check-body { margin-top: 0; }
.factor-body .rows { align-self: stretch; }
.factor-sources { font-size: 13px; line-height: 20px; color: var(--ink-muted); }
.factor-sources-label { display: block; font-weight: 600; color: var(--ink); }
.factor-sources ul { margin: 0; padding-left: 18px; }
.factor-sources a { color: var(--canopy-700); }
.factor-missing .factor-line { align-items: center; padding: var(--s1) 0; }
.factor-missing .factor-title { color: var(--ink-muted); }
.factor-note { margin-top: var(--s3); }
@media (prefers-reduced-motion: reduce) { .factor-chevron { transition: none; } }

/* Your plan */
.plan-checks { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.plan-checks li { display: flex; flex-direction: column; gap: 2px; padding: var(--s3) 0; border-top: 1px solid var(--outline); }
.plan-checks li:first-child { border-top: 0; padding-top: 0; }
.plan-checks span { color: var(--ink-muted); font-size: 14px; line-height: 20px; }
/* Ways to save: result */
.savings-result .card-head { margin-bottom: var(--s2); }
.savings-figure { display: flex; flex-direction: column; gap: 2px; }
.savings-amount { font-family: var(--font-display); font-weight: 600; font-size: 24px; line-height: 28px; color: var(--haldi-ink); font-variant-numeric: tabular-nums; }
.savings-amount.is-empty { color: var(--ink); }
.savings-line { color: var(--ink-muted); font-size: 15px; line-height: 22px; text-wrap: pretty; }
.savings-stale { margin-top: var(--s2); font-size: 13px; line-height: 18px; color: var(--warning); }
.savings-result.is-stale :is(.savings-figure, .cost-chart, .balance-chart) { opacity: 0.5; }

/* Where your money goes */
.cost-chart { margin: var(--s4) 0 var(--s5); display: flex; flex-direction: column; gap: var(--s2); }
.cost-rows { display: flex; flex-direction: column; gap: var(--s3); }
.cost-head { display: flex; justify-content: space-between; gap: var(--s3); font-size: 14px; line-height: 20px; color: var(--ink-muted); }
.cost-head strong { color: var(--ink); font-weight: 600; font-variant-numeric: tabular-nums; }
.cost-bar { display: flex; gap: 2px; height: 12px; margin-top: var(--s1); border-radius: 6px; }
.cost-bar:focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; }
.cost-seg { flex: 0 1 auto; min-width: 4px; height: 100%; }
.cost-seg:first-child { border-radius: 6px 0 0 6px; }
.cost-seg:last-child { border-radius: 0 6px 6px 0; }
.cost-seg:only-child { border-radius: 6px; }
.is-principal { background: var(--principal); }
.is-interest { background: var(--interest); }
.is-fees { background: var(--ink-faint); }
.is-saved { background: var(--haldi-100); box-shadow: inset 0 0 0 1px var(--haldi-500); }
.cost-facts { margin-top: var(--s1); font-size: 13px; line-height: 18px; color: var(--ink-faint); font-variant-numeric: tabular-nums; }
.swatch-box { width: 10px; height: 10px; border-radius: 3px; }

/* Segmented control */
.segmented { border: 0; padding: 0; margin: 0 0 var(--s5); min-width: 0; }
.segmented-legend { padding: 0; margin-bottom: var(--s2); font-size: 14px; line-height: 20px; font-weight: 500; }
.segmented-options { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 4px; border: 1px solid var(--outline); border-radius: var(--r-control); background: var(--canvas); }
.segmented-option { position: relative; display: flex; align-items: center; justify-content: center; min-height: 44px; border-radius: 10px; font-size: 15px; font-weight: 500; color: var(--ink-muted); cursor: pointer; }
.segmented-option input { position: absolute; inset: 0; margin: 0; opacity: 0; cursor: pointer; }
.segmented-option:has(input:checked) { background: var(--card); color: var(--ink); box-shadow: inset 0 0 0 1px var(--outline-strong); }
.segmented-option:has(input:focus-visible) { outline: 2px solid var(--focus); outline-offset: 2px; }
.segmented.is-compact { margin: 0; }
.segmented.is-compact .segmented-options { padding: 2px; gap: 2px; }
.segmented.is-compact .segmented-option { min-height: 44px; padding: 0 var(--s3); font-size: 13px; border-radius: 8px; }
.chart-head { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); }

/* Balance chart */
.balance-chart { margin: 0; display: flex; flex-direction: column; gap: var(--s2); }
.chart-caption { font-size: 14px; line-height: 20px; font-weight: 500; }
.chart-legend { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: var(--s1) var(--s4); font-size: 13px; line-height: 18px; color: var(--ink-muted); }
.chart-legend li { display: inline-flex; align-items: center; gap: 6px; }
.swatch { width: 18px; border-top: 2px solid var(--principal); }
.swatch.is-today { border-top-style: dashed; border-top-color: var(--ink-faint); }
.chart-frame { position: relative; }
.chart-plot { border-radius: var(--r-chip); touch-action: pan-y; }
.chart-plot:focus-visible { outline: 2px solid var(--focus); outline-offset: 4px; }
.chart-svg { overflow: visible; }
.chart-grid { stroke: var(--outline); stroke-width: 1; }
.chart-axis { stroke: var(--outline-strong); stroke-width: 1; }
.chart-label { fill: var(--ink-faint); font-size: 12px; font-variant-numeric: tabular-nums; }
.chart-end { fill: var(--ink-muted); font-size: 12px; font-weight: 500; font-variant-numeric: tabular-nums; paint-order: stroke; stroke: var(--card); stroke-width: 4px; stroke-linejoin: round; }
.chart-line { fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.chart-line.is-today { stroke: var(--ink-faint); stroke-dasharray: 4 4; }
.chart-line.is-chosen { stroke: var(--principal); }
.chart-dot { stroke: var(--card); stroke-width: 2; }
.chart-dot.is-today { fill: var(--ink-faint); }
.chart-dot.is-chosen { fill: var(--principal); }
.chart-cross { stroke: var(--outline-strong); stroke-width: 1; }
.chart-tip {
  position: absolute; top: 0; left: 0; z-index: 2; pointer-events: none;
  display: flex; flex-direction: column; gap: 2px; padding: var(--s2) var(--s3);
  background: var(--card); border: 1px solid var(--outline-strong); border-radius: var(--r-chip);
  font-size: 13px; line-height: 18px; color: var(--ink-muted); white-space: nowrap; font-variant-numeric: tabular-nums;
}
.chart-tip strong { color: var(--ink); font-weight: 600; }
.chart-details summary { display: inline-flex; align-items: center; min-height: 44px; cursor: pointer; font-size: 14px; font-weight: 600; color: var(--canopy-700); }
.table-scroll { max-height: 288px; overflow: auto; border: 1px solid var(--outline); border-radius: var(--r-chip); }
.chart-table { width: 100%; border-collapse: collapse; font-size: 14px; line-height: 20px; font-variant-numeric: tabular-nums; }
.chart-table th, .chart-table td { padding: var(--s2) var(--s3); text-align: right; white-space: nowrap; border-top: 1px solid var(--outline); }
.chart-table thead th { position: sticky; top: 0; border-top: 0; background: var(--card); font-weight: 500; color: var(--ink-muted); }
.chart-table :is(th[scope='row'], thead th:first-child) { text-align: left; font-weight: 400; }

/* Levers */
.levers-lead { margin: calc(-1 * var(--s2)) 0 var(--s2); font-size: 14px; line-height: 20px; color: var(--ink-muted); text-wrap: pretty; }
.lever-list { list-style: none; margin: 0; padding: 0; }
.lever { display: flex; flex-direction: column; gap: var(--s1); padding: var(--s3) 0 var(--s4); border-top: 1px solid var(--outline); }
.lever:last-child { padding-bottom: 0; }
.lever-head { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); }
.lever-toggle { display: flex; align-items: center; gap: var(--s3); min-height: 48px; min-width: 0; cursor: pointer; }
.lever-title { font-size: 15px; line-height: 20px; font-weight: 600; }
.lever.is-unavailable .lever-toggle { cursor: default; }
.lever.is-unavailable .lever-title { color: var(--ink-faint); }
.lever-adds { flex: none; display: flex; flex-direction: column; align-items: flex-end; text-align: right; }
.lever-adds strong { font-size: 15px; line-height: 20px; font-weight: 600; color: var(--haldi-ink); font-variant-numeric: tabular-nums; }
.lever-adds span { font-size: 12px; line-height: 16px; color: var(--ink-faint); }
.lever-adds.is-potential strong { font-weight: 500; color: var(--ink-muted); }
.lever-hint, .lever-warn, .lever-body { margin-left: 56px; }
.lever-hint { font-size: 13px; line-height: 18px; color: var(--ink-muted); text-wrap: pretty; }
.lever-warn { display: flex; align-items: baseline; gap: 6px; font-size: 13px; line-height: 18px; font-weight: 500; color: var(--warning); }
.lever-warn::before { content: ''; flex: none; width: 8px; height: 8px; border-radius: 50%; background: var(--haldi-500); transform: translateY(-1px); }
.lever-warn[hidden] { display: none; }
.lever-body { display: flex; flex-direction: column; gap: var(--s3); margin-top: var(--s3); }
.lever-note { font-size: 13px; line-height: 18px; color: var(--ink-faint); text-wrap: pretty; }
.lever-note:empty { display: none; }

.switch {
  appearance: none; flex: none; position: relative; margin: 0; cursor: pointer;
  width: 44px; height: 26px; border-radius: 13px; background: var(--outline-strong);
  transition: background-color 120ms ease-out;
}
.switch::after {
  content: ''; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%;
  background: #ffffff; transition: transform 120ms ease-out;
}
.switch:checked { background: var(--canopy-700); }
.switch:checked::after { transform: translateX(18px); }
.switch:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.switch:disabled { opacity: 0.4; cursor: not-allowed; }
@media (forced-colors: active) {
  .switch { border: 1px solid CanvasText; }
  .switch::after { background: CanvasText; }
  .switch:checked::after { background: Highlight; }
}

.rate-options { border: 1px solid var(--outline); border-radius: var(--r-control); overflow: hidden; }
.rate-option { align-items: center; min-height: 60px; }
.rate-option > span:not(.rate-value) { flex: 1; min-width: 0; }
.rate-option small { font-size: 13px; line-height: 18px; color: var(--ink-muted); }
.rate-value { flex: none; font-weight: 600; font-variant-numeric: tabular-nums; }
.rate-source a { color: var(--canopy-700); font-weight: 500; }

.stepper { display: grid; grid-template-columns: 48px minmax(0, 1fr) 48px; gap: var(--s2); max-width: 300px; }
.stepper-button { padding: 0; font-size: 20px; font-weight: 500; }
.stepper-input { appearance: textfield; -moz-appearance: textfield; }
.stepper-input::-webkit-inner-spin-button, .stepper-input::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }

/* Close by */
.close-result { margin-top: var(--s3); font-size: 15px; line-height: 22px; text-wrap: pretty; }
.close-result:empty { display: none; }
.close-card .card-head .button.text { margin: -10px 0; }

/* Save bar */
.save-bar {
  display: flex; align-items: center; justify-content: space-between; gap: var(--s3);
  padding: var(--s3) var(--s4); background: var(--card);
  border: 1px solid var(--outline); border-radius: var(--r-card);
}
.save-bar.is-dirty {
  position: sticky; bottom: calc(var(--s3) + env(safe-area-inset-bottom)); z-index: 5;
  border-color: var(--outline-strong);
}
.save-bar-text { min-width: 0; font-size: 14px; line-height: 20px; color: var(--ink-muted); }
.save-bar-actions { display: flex; gap: var(--s2); flex: none; }
.savings-foot { display: flex; flex-direction: column; align-items: flex-start; gap: var(--s1); padding: 0 var(--s1); }
.savings-method { margin-top: var(--s2); color: var(--ink-faint); }

@media (max-width: 479px) {
  .lever-hint, .lever-warn, .lever-body { margin-left: 0; }
  .save-bar { flex-direction: column; align-items: stretch; }
  .save-bar-actions { display: grid; grid-template-columns: 1fr 1fr; }
  .save-bar-actions:has(> [hidden]) { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) {
  .switch, .switch::after { transition: none; }
}

/* Settings, unlock, misc */
.settings-note { margin: var(--s3) 0; }
.danger-text { color: var(--danger) !important; }
.file-input { padding: 10px 14px; }
.unlock { max-width: 360px; margin: var(--s7) auto 0; display: flex; flex-direction: column; gap: var(--s3); text-align: center; }
.unlock h1 { font-family: var(--font-display); font-weight: 600; font-size: 28px; line-height: 32px; }
.unlock .lead { margin: 0; }
.unlock-mark { width: 48px; height: 32px; margin: 0 auto var(--s2); fill: none; stroke-linecap: round; }
.unlock .input { text-align: center; font-size: 20px; letter-spacing: 4px; }
.toast {
  position: fixed; left: 50%; bottom: calc(var(--s5) + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 30;
  max-width: min(520px, calc(100vw - 2 * var(--gutter))); padding: var(--s3) var(--s4); border-radius: var(--r-control);
  background: var(--ink); color: var(--canvas); font-size: 14px; line-height: 20px; text-align: center;
}
.view .card-head h3 { white-space: normal; }

@media (max-width: 479px) {
  .file-row { grid-template-columns: 20px 1fr; }
  .file-actions { grid-column: 2; margin-left: -4px; }
  .reminder-card .file-actions { margin-bottom: calc(-1 * var(--s3)); }
  .danger-zone { flex-direction: column; align-items: stretch; }
  .tabs { gap: var(--s4); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
}

@media print {
  :root { --canvas: #fff; }
  .app-bar, .steps, .actions, .page-footer, .skip-link, .save-bar, .chart-details, .segmented, .savings-foot .button, .card-head .button, .start-links, .save-card, .toast, .danger-zone, .reminder-card, .tabs, .section-head .button, .inbox-list, .back-link { display: none !important; }
  .page { padding: 0; max-width: none; }
  .card, .hero { break-inside: avoid; }
  .hero { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
