/* Daily Receipts – themes via CSS variables (light / dark + accent) */
:root, [data-theme="light"] {
  --bg: #f4f1ea; --card: #ffffff; --ink: #1f2937; --muted: #6b7280; --line: #e5e7eb;
  --paper: #fffdf7; --paper-ink: #1f2937; --paper-muted: #6b7280; --paper-line: #d6d3d1;
  --paper-hover: #f5f0e3; --paper-bar: #ede7da; --seg-bg: #e7e2d6; --seg-ink: #57534e;
  --chip-bg: #f9fafb; --input-bg: #ffffff; --topbar-bg: rgba(244,241,234,.92);
  --composer-bg: rgba(244,241,234,.96); --tabbar-bg: #ffffff;
  --auth-grad-from: var(--brand-soft); --bubble-bot: #ffffff; --icon-bg: #f3f4f6;
  --shadow: 0 6px 24px rgba(15, 23, 42, .08);
  --danger: #dc2626; --danger-border: #fecaca;
  --toast-bg: #111827; --toast-ink: #fff;
  --warn: #d97706; --warn-soft: #fef3c7; --warn-ink: #92400e; --warn-border: #fcd34d;
  --danger-soft: #fee2e2; --danger-ink: #991b1b; --danger-bar: #dc2626;
  color-scheme: light;
}
[data-theme="dark"] {
  --bg: #1c1917; --card: #292524; --ink: #f5f5f4; --muted: #a8a29e; --line: #44403c;
  --paper: #292524; --paper-ink: #f5f5f4; --paper-muted: #a8a29e; --paper-line: #57534e;
  --paper-hover: #3f3a36; --paper-bar: #44403c; --seg-bg: #292524; --seg-ink: #a8a29e;
  --chip-bg: #1c1917; --input-bg: #1c1917; --topbar-bg: rgba(28,25,23,.92);
  --composer-bg: rgba(28,25,23,.96); --tabbar-bg: #292524;
  --auth-grad-from: #292524; --bubble-bot: #292524; --icon-bg: #44403c;
  --shadow: 0 6px 24px rgba(0, 0, 0, .35);
  --danger: #f87171; --danger-border: #7f1d1d;
  --toast-bg: #f5f5f4; --toast-ink: #1c1917;
  --warn: #fbbf24; --warn-soft: #3b2a0a; --warn-ink: #fde68a; --warn-border: #92400e;
  --danger-soft: #3f1212; --danger-ink: #fecaca; --danger-bar: #f87171;
  color-scheme: dark;
}

/* Accent palettes (work in both modes) */
[data-accent="green"], :root {
  --brand: #0f766e; --brand-2: #14b8a6; --brand-soft: #ccfbf1; --brand-contrast: #fff;
}
[data-theme="dark"][data-accent="green"] { --brand: #2dd4bf; --brand-2: #14b8a6; --brand-soft: #134e4a; --brand-contrast: #042f2e; }
[data-accent="blue"] {
  --brand: #1d4ed8; --brand-2: #3b82f6; --brand-soft: #dbeafe; --brand-contrast: #fff;
}
[data-theme="dark"][data-accent="blue"] { --brand: #60a5fa; --brand-2: #3b82f6; --brand-soft: #1e3a5f; --brand-contrast: #0c1a2e; }
[data-accent="purple"] {
  --brand: #7c3aed; --brand-2: #a78bfa; --brand-soft: #ede9fe; --brand-contrast: #fff;
}
[data-theme="dark"][data-accent="purple"] { --brand: #c4b5fd; --brand-2: #a78bfa; --brand-soft: #3b0764; --brand-contrast: #1e0533; }
[data-accent="orange"] {
  --brand: #ea580c; --brand-2: #fb923c; --brand-soft: #ffedd5; --brand-contrast: #fff;
}
[data-theme="dark"][data-accent="orange"] { --brand: #fdba74; --brand-2: #fb923c; --brand-soft: #7c2d12; --brand-contrast: #431407; }
[data-accent="rose"] {
  --brand: #e11d48; --brand-2: #fb7185; --brand-soft: #ffe4e6; --brand-contrast: #fff;
}
[data-theme="dark"][data-accent="rose"] { --brand: #fda4af; --brand-2: #fb7185; --brand-soft: #881337; --brand-contrast: #4c0519; }

:root {
  --radius: 16px;
  --tabbar-h: 64px; --safe-b: env(safe-area-inset-bottom, 0px);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--ink); -webkit-text-size-adjust: 100%;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); min-height: 100%; color: var(--ink); }
[hidden] { display: none !important; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2 { margin: 0; }
.muted { color: var(--muted); } .small { font-size: .875rem; }

/* ---------- buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .4rem; padding: .7rem 1rem; border-radius: 12px; border: 1px solid var(--line); background: var(--card); text-decoration: none; font-weight: 600; min-height: 44px; color: var(--ink); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-contrast); }
.btn.danger { color: var(--danger); border-color: var(--danger-border); }
.btn.block { width: 100%; }
.btn:disabled { opacity: .55; }
.icon-btn { border: 0; background: transparent; font-size: 1.4rem; width: 44px; height: 44px; border-radius: 12px; display: inline-flex; align-items: center; justify-content: center; flex: none; color: var(--ink); }
.icon-btn.round { border-radius: 50%; background: var(--icon-bg); font-size: 1.2rem; }
.icon-btn.send { background: var(--brand); color: var(--brand-contrast); }
.icon-btn.listening { background: var(--danger); color: #fff; animation: pulse 1.2s infinite; }
.icon-btn.theme-toggle { font-size: 1.25rem; }
@keyframes pulse { 0%,100% { box-shadow: 0 0 0 0 rgba(220,38,38,.5); } 50% { box-shadow: 0 0 0 10px rgba(220,38,38,0); } }

/* ---------- auth ---------- */
.auth { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px 18px; background: linear-gradient(160deg, var(--auth-grad-from) 0%, var(--bg) 55%); }
.auth-card { width: 100%; max-width: 400px; background: var(--card); border-radius: 24px; padding: 28px 22px; box-shadow: var(--shadow); position: relative; }
.auth-theme { position: absolute; top: 12px; right: 12px; }
.brand-big { display: flex; flex-direction: column; align-items: center; gap: 10px; }
.brand-big h1 { font-size: 1.75rem; letter-spacing: -.02em; }
.tagline { text-align: center; color: var(--muted); margin: 10px 0 20px; line-height: 1.45; }
.tagline em { color: var(--ink); font-style: normal; font-weight: 600; }
.tabs { display: grid; grid-template-columns: 1fr 1fr; background: var(--icon-bg); border-radius: 12px; padding: 4px; margin-bottom: 16px; }
.tab { border: 0; background: transparent; padding: .6rem; border-radius: 9px; font-weight: 600; color: var(--muted); }
.tab.active { background: var(--card); color: var(--ink); box-shadow: 0 1px 3px rgba(0,0,0,.08); }
label { display: block; font-size: .85rem; font-weight: 600; color: var(--muted); margin-bottom: 12px; }
label input, label select { display: block; width: 100%; margin-top: 6px; }
input, select, textarea { border: 1px solid var(--line); border-radius: 12px; padding: .7rem .8rem; background: var(--input-bg); font-size: 16px; min-height: 44px; color: var(--ink); }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand-2); outline-offset: 0; border-color: transparent; }
.error { color: var(--danger); min-height: 1.2em; margin: 0 0 10px; font-size: .9rem; }
.privacy { text-align: center; font-size: .82rem; color: var(--muted); margin: 16px 0 0; }

/* ---------- app shell ---------- */
.app { max-width: 560px; margin: 0 auto; min-height: 100vh; padding-bottom: calc(var(--tabbar-h) + var(--safe-b)); }
.topbar { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 12px 16px; padding-top: max(12px, env(safe-area-inset-top)); background: var(--topbar-bg); backdrop-filter: blur(8px); }
.topbar-right { display: flex; align-items: center; gap: 4px; }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 800; font-size: 1.1rem; letter-spacing: -.01em; }
.today-pill { border: 0; background: var(--brand-soft); color: var(--brand); font-weight: 700; border-radius: 999px; padding: .45rem .8rem; }
.view { padding: 4px 16px 24px; }
.tabbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; height: calc(var(--tabbar-h) + var(--safe-b)); padding-bottom: var(--safe-b); display: grid; grid-template-columns: repeat(3, 1fr); background: var(--tabbar-bg); border-top: 1px solid var(--line); max-width: 560px; margin: 0 auto; }
.tabbar button { border: 0; background: transparent; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; font-size: .75rem; font-weight: 600; color: var(--muted); }
.tabbar button span { font-size: 1.3rem; filter: grayscale(1); opacity: .7; }
.tabbar button.active { color: var(--brand); }
.tabbar button.active span { filter: none; opacity: 1; }

/* ---------- receipts ---------- */
.segmented { display: grid; grid-template-columns: repeat(4, 1fr); background: var(--seg-bg); border-radius: 12px; padding: 4px; }
.segmented button { border: 0; background: transparent; padding: .55rem 0; border-radius: 9px; font-weight: 600; color: var(--seg-ink); }
.segmented button.active { background: var(--card); color: var(--ink); box-shadow: 0 1px 3px rgba(0,0,0,.08); }
.period-nav { display: flex; align-items: center; justify-content: space-between; margin: 10px 0; }
.period-label { font-weight: 700; text-align: center; }
.custom-range { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 10px 0; }
.receipt { position: relative; background: var(--paper); color: var(--paper-ink); padding: 22px 18px 28px; box-shadow: var(--shadow); font-family: ui-monospace, "SF Mono", Menlo, Consolas, "Courier New", monospace; font-size: .92rem; margin-bottom: 18px;
  -webkit-mask: radial-gradient(circle 7px at 50% 100%, transparent 98%, #000) 50% 100% / 18px 100% repeat-x; mask: radial-gradient(circle 7px at 50% 100%, transparent 98%, #000) 50% 100% / 18px 100% repeat-x; }
.receipt h2 { text-align: center; font-size: 1.05rem; letter-spacing: .15em; }
.receipt .sub { text-align: center; color: var(--paper-muted); margin: 4px 0 0; font-size: .82rem; }
.receipt hr { border: 0; border-top: 2px dashed var(--paper-line); margin: 14px 0; }
.receipt .day { font-weight: 700; margin: 12px 0 4px; font-size: .82rem; color: var(--paper-muted); text-transform: uppercase; }
.receipt .row { display: flex; justify-content: space-between; gap: 12px; padding: 6px 4px; border-radius: 8px; align-items: baseline; }
.receipt .row.item { cursor: pointer; }
.receipt .row.item:active, .receipt .row.item:hover { background: var(--paper-hover); }
.receipt .row .desc { min-width: 0; overflow-wrap: anywhere; }
.receipt .row small { display: block; color: var(--paper-muted); font-size: .75rem; }
.receipt .row .amt { white-space: nowrap; font-weight: 600; }
.receipt .grand { font-size: 1.1rem; font-weight: 800; }
.receipt .empty { text-align: center; color: var(--paper-muted); padding: 16px 0; font-family: inherit; }
.receipt .bar { height: 6px; background: var(--paper-bar); border-radius: 3px; margin: 2px 4px 6px; overflow: hidden; }
.receipt .bar i { display: block; height: 100%; background: var(--brand-2); }
.receipt-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.fab { position: fixed; right: max(16px, calc(50% - 264px)); bottom: calc(var(--tabbar-h) + var(--safe-b) + 16px); z-index: 9; border: 0; background: var(--brand); color: var(--brand-contrast); font-weight: 700; padding: .9rem 1.2rem; border-radius: 999px; box-shadow: 0 10px 24px rgba(15,118,110,.35); }

/* ---------- chat ---------- */
.log-view { display: flex; flex-direction: column; padding-bottom: 0; min-height: calc(100vh - 60px - var(--tabbar-h)); }
.chat { flex: 1; display: flex; flex-direction: column; gap: 10px; padding: 6px 0 96px; }
.bubble { max-width: 88%; padding: .7rem .9rem; border-radius: 18px; line-height: 1.4; overflow-wrap: anywhere; }
.bubble.bot { background: var(--bubble-bot); border-bottom-left-radius: 6px; align-self: flex-start; box-shadow: 0 1px 2px rgba(0,0,0,.05); }
.bubble.me { background: var(--brand); color: var(--brand-contrast); border-bottom-right-radius: 6px; align-self: flex-end; }
.bubble.me img { display: block; max-width: 180px; max-height: 220px; border-radius: 12px; }
.bubble.wide { max-width: 100%; width: 100%; }
.bubble a { color: var(--brand); font-weight: 600; }
.bubble .hint { color: var(--muted); font-size: .85rem; }
.bubble details { margin-top: 8px; font-size: .8rem; color: var(--muted); }
.bubble pre { white-space: pre-wrap; font-size: .75rem; max-height: 160px; overflow: auto; background: var(--chip-bg); padding: 8px; border-radius: 8px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.chip { border: 1px solid var(--line); background: var(--chip-bg); border-radius: 999px; padding: .35rem .7rem; font-size: .82rem; color: var(--ink); }
.preview-row { display: grid; grid-template-columns: 96px 1fr 36px; gap: 6px; padding: 10px 0; border-bottom: 1px dashed var(--line); }
.preview-row:last-of-type { border-bottom: 0; }
.preview-row input, .preview-row select { min-height: 40px; padding: .45rem .55rem; font-size: 16px; width: 100%; }
.preview-row .amt-wrap { position: relative; }
.preview-row .amt-wrap::before { content: "$"; position: absolute; left: 9px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.preview-row .amt-wrap input { padding-left: 20px; font-weight: 700; }
.preview-row .full { grid-column: 1 / 3; display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.preview-row .rm { grid-row: 1; grid-column: 3; width: 36px; height: 40px; border: 0; background: transparent; color: var(--muted); font-size: 1.1rem; }
.preview-total { display: flex; justify-content: space-between; font-weight: 800; padding: 8px 0; }
.preview-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 6px; }
.preview-actions .btn { flex: 1; }
.link-btn { border: 0; background: none; color: var(--brand); font-weight: 600; padding: 6px 0; }
.progress { height: 6px; background: var(--line); border-radius: 3px; overflow: hidden; margin-top: 8px; }
.progress i { display: block; height: 100%; width: 0; background: var(--brand-2); transition: width .2s; }
.composer { position: fixed; left: 0; right: 0; bottom: calc(var(--tabbar-h) + var(--safe-b)); z-index: 8; max-width: 560px; margin: 0 auto; display: flex; align-items: flex-end; gap: 6px; padding: 8px 10px; background: var(--composer-bg); backdrop-filter: blur(8px); border-top: 1px solid var(--line); }
.composer textarea { flex: 1; resize: none; border-radius: 22px; padding: .65rem 1rem; max-height: 120px; line-height: 1.35; }

/* ---------- settings ---------- */
.card { background: var(--card); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); margin-bottom: 14px; }
.card h2 { font-size: 1.05rem; margin-bottom: 8px; }
.cat-list { list-style: none; padding: 0; margin: 0 0 10px; }
.cat-list li { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.cat-list li:last-child { border-bottom: 0; }
.cat-list .kw { display: block; color: var(--muted); font-size: .78rem; }
.cat-form { display: grid; grid-template-columns: 1fr; gap: 8px; }

.theme-mode-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 10px 0 14px; }
.theme-mode-row button { border: 1px solid var(--line); background: var(--input-bg); border-radius: 12px; padding: .7rem .4rem; font-weight: 600; min-height: 44px; color: var(--ink); }
.theme-mode-row button.active { border-color: var(--brand); background: var(--brand-soft); color: var(--brand); }
.accent-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; margin-top: 8px; }
.accent-swatch { border: 2px solid transparent; border-radius: 12px; padding: 8px 4px; background: var(--input-bg); display: flex; flex-direction: column; align-items: center; gap: 6px; font-size: .7rem; font-weight: 600; color: var(--muted); min-height: 64px; }
.accent-swatch i { width: 28px; height: 28px; border-radius: 50%; display: block; }
.accent-swatch[data-accent="blue"] i { background: #1d4ed8; }
.accent-swatch[data-accent="green"] i { background: #0f766e; }
.accent-swatch[data-accent="purple"] i { background: #7c3aed; }
.accent-swatch[data-accent="orange"] i { background: #ea580c; }
.accent-swatch[data-accent="rose"] i { background: #e11d48; }
.accent-swatch.active { border-color: var(--brand); color: var(--ink); box-shadow: 0 0 0 2px var(--brand-soft); }

.toggle-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 10px 0; }
.toggle-row span { font-weight: 600; }
.switch { position: relative; width: 48px; height: 28px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .slider { position: absolute; inset: 0; background: var(--line); border-radius: 999px; transition: .2s; }
.switch .slider::before { content: ""; position: absolute; width: 22px; height: 22px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: .2s; }
.switch input:checked + .slider { background: var(--brand); }
.switch input:checked + .slider::before { transform: translateX(20px); }
.field-hint { font-size: .78rem; color: var(--muted); margin: -6px 0 10px; font-weight: 400; }
.provider-note { background: var(--brand-soft); color: var(--ink); border-radius: 10px; padding: 10px 12px; font-size: .85rem; margin: 8px 0; line-height: 1.4; }
.provider-note.warn { background: #fef3c7; color: #92400e; }
[data-theme="dark"] .provider-note.warn { background: #78350f; color: #fde68a; }
.eod-preview { background: var(--input-bg); border: 1px solid var(--line); border-radius: 12px; padding: 12px; font-size: .82rem; white-space: pre-wrap; font-family: ui-monospace, Menlo, Consolas, monospace; max-height: 240px; overflow: auto; margin-top: 10px; }
.settings-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }

/* ---------- dialog / toast ---------- */
.sheet { border: 0; border-radius: 20px 20px 0 0; padding: 20px 18px calc(20px + var(--safe-b)); width: 100%; max-width: 560px; margin: auto auto 0; box-shadow: var(--shadow); background: var(--card); color: var(--ink); }
.sheet::backdrop { background: rgba(15,23,42,.4); }
.sheet h2 { margin-bottom: 14px; font-size: 1.15rem; }
.sheet-actions { display: flex; gap: 8px; align-items: center; margin-top: 6px; }
.spacer { flex: 1; }
.toast { position: fixed; left: 50%; bottom: calc(var(--tabbar-h) + 90px); transform: translateX(-50%) translateY(20px); background: var(--toast-bg); color: var(--toast-ink); padding: .7rem 1rem; border-radius: 12px; font-size: .9rem; opacity: 0; pointer-events: none; transition: all .25s; z-index: 50; max-width: 90vw; text-align: center; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- budget ---------- */
.budget-banner { display: flex; gap: 10px; align-items: flex-start; border-radius: 14px; padding: 12px 14px; margin: 0 0 10px; font-weight: 600; line-height: 1.35; border: 1px solid transparent; }
.budget-banner small { display: block; font-weight: 500; opacity: .85; margin-top: 2px; }
.budget-banner.warning { background: var(--warn-soft); color: var(--warn-ink); border-color: var(--warn-border); }
.budget-banner.over { background: var(--danger-soft); color: var(--danger-ink); border-color: var(--danger-border); }
.budget-card { --bc-fill: var(--brand); background: var(--card); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); margin: 0 0 12px; border: 1px solid var(--line); }
.budget-card.warning { --bc-fill: var(--warn); border-color: var(--warn-border); }
.budget-card.over { --bc-fill: var(--danger-bar); border-color: var(--danger-border); }
.budget-card.empty { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: .9rem; color: var(--muted); padding: 10px 14px; }
.bc-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.bc-title { font-weight: 800; }
.bc-chip { font-size: .72rem; font-weight: 700; border-radius: 999px; padding: .2rem .6rem; background: var(--brand-soft); color: var(--brand); white-space: nowrap; }
.budget-card.warning .bc-chip { background: var(--warn-soft); color: var(--warn-ink); }
.budget-card.over .bc-chip { background: var(--danger-soft); color: var(--danger-ink); }
.bc-range { color: var(--muted); font-size: .8rem; margin-top: 2px; }
.bc-stats { display: grid; grid-template-columns: 1.1fr 1.3fr .8fr; gap: 8px; margin: 12px 0 10px; }
.bc-stats b { display: block; font-size: 1.15rem; letter-spacing: -.01em; font-variant-numeric: tabular-nums; }
.bc-stats small { color: var(--muted); font-size: .74rem; }
.budget-card.warning .bc-left { color: var(--warn); }
.budget-card.over .bc-left { color: var(--danger); }
.bc-bar { position: relative; height: 10px; border-radius: 999px; background: var(--paper-bar); overflow: visible; }
.bc-bar i { display: block; height: 100%; border-radius: 999px; background: var(--bc-fill); transition: width .3s; max-width: 100%; }
.bc-bar.small { height: 6px; }
.bc-mark { position: absolute; top: -3px; bottom: -3px; width: 2px; background: var(--ink); opacity: .35; border-radius: 1px; }
.bc-foot { display: flex; justify-content: space-between; align-items: center; font-size: .8rem; color: var(--muted); margin-top: 4px; }
.bc-foot .link-btn { font-size: .85rem; }
.bc-cats { border-top: 1px dashed var(--line); margin-top: 6px; padding-top: 8px; display: grid; gap: 8px; }
.bc-cat { --bc-fill: var(--brand-2); }
.bc-cat.warning { --bc-fill: var(--warn); }
.bc-cat.over { --bc-fill: var(--danger-bar); }
.bc-cat-row { display: flex; justify-content: space-between; gap: 8px; font-size: .85rem; margin-bottom: 4px; }
.bc-cat-row small { color: var(--muted); }
.bc-cat.over .bc-cat-row b { color: var(--danger); }
.budget-inline { margin-top: 8px; padding: 8px 10px; border-radius: 10px; font-size: .88rem; font-weight: 600; }
.budget-inline.warning { background: var(--warn-soft); color: var(--warn-ink); }
.budget-inline.over { background: var(--danger-soft); color: var(--danger-ink); }
.budget-alert { position: fixed; z-index: 60; left: 50%; top: max(12px, env(safe-area-inset-top)); width: min(520px, calc(100vw - 24px)); transform: translate(-50%, -16px); opacity: 0; transition: all .25s; display: flex; gap: 10px; align-items: flex-start; padding: 14px 12px 14px 14px; border-radius: 16px; box-shadow: 0 12px 32px rgba(0,0,0,.25); border: 1px solid var(--warn-border); background: var(--warn-soft); color: var(--warn-ink); }
.budget-alert.show { opacity: 1; transform: translate(-50%, 0); }
.budget-alert.over { background: var(--danger-soft); color: var(--danger-ink); border-color: var(--danger-border); }
.budget-alert .ba-icon { font-size: 1.4rem; line-height: 1; }
.budget-alert .ba-body { flex: 1; min-width: 0; }
.budget-alert .ba-body p { margin: 2px 0 0; line-height: 1.35; font-size: .92rem; }
.budget-alert .ba-close { border: 0; background: transparent; color: inherit; font-size: 1rem; width: 32px; height: 32px; border-radius: 8px; opacity: .7; }
.money-input { position: relative; display: block; margin-top: 6px; }
.money-input::before { content: "$"; position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); font-weight: 600; pointer-events: none; }
.money-input input { margin-top: 0; padding-left: 26px; width: 100%; }
.money-input.pct::before { content: "%"; left: auto; right: 14px; }
.money-input.pct input { padding-left: .8rem; padding-right: 32px; }
#bud-warn-label > span:first-child { display: block; }
.subhead { font-size: .95rem; margin: 14px 0 6px; }
.bud-cats { display: grid; gap: 8px; margin-bottom: 4px; }
.bud-cat-row { display: grid; grid-template-columns: minmax(0, 1fr) 104px 32px; gap: 6px; align-items: center; }
.bud-cat-row select { min-height: 44px; width: 100%; }
.bud-cat-row .money-input { margin-top: 0; }
.bud-cat-row .rm { width: 32px; height: 44px; border: 0; background: transparent; color: var(--muted); font-size: 1.1rem; }
.bud-cat-row .bud-cat-period { grid-column: 1 / -1; }
.bud-cat-row .bud-cat-period select { font-size: .9rem; }
.bc-cat-meta { display: block; font-size: .72rem; font-weight: 600; color: var(--muted); margin-top: 2px; }
#bud-fields.dimmed { opacity: .55; }

/* ---------- quick-start tour ---------- */
:root { --tour-dim: rgba(15, 23, 42, .62); }
[data-theme="dark"] { --tour-dim: rgba(0, 0, 0, .74); }
.help-btn { width: 36px; height: 36px; border-radius: 50%; font-size: 1rem; font-weight: 800; background: var(--icon-bg); color: var(--ink); }
.tour-welcome { position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center; padding: 20px 16px calc(20px + var(--safe-b)); background: var(--tour-dim); animation: tour-fade .2s ease-out; }
.tour-welcome-card { width: 100%; max-width: 380px; background: var(--card); color: var(--ink); border: 1px solid var(--line); border-radius: 24px; padding: 26px 20px 18px; text-align: center; box-shadow: 0 20px 50px rgba(0,0,0,.35); }
.tour-welcome-icon { width: 64px; height: 64px; margin: 0 auto 12px; border-radius: 50%; background: var(--brand-soft); display: flex; align-items: center; justify-content: center; font-size: 2rem; }
.tour-welcome-card h2 { font-size: 1.3rem; letter-spacing: -.01em; }
.tour-welcome-card > p { margin: 8px 0 18px; line-height: 1.4; }
.tour-welcome-card > p.small { margin: 12px 0 0; }
.tour-welcome-actions { display: grid; gap: 10px; }
.tour { position: fixed; inset: 0; z-index: 100; }
.tour-blocker { position: absolute; inset: 0; touch-action: none; }
.tour.centered .tour-blocker { background: var(--tour-dim); }
.tour-spot { position: fixed; border-radius: 14px; box-shadow: 0 0 0 3px var(--brand), 0 0 0 9999px var(--tour-dim); pointer-events: none; transition: top .25s, left .25s, width .25s, height .25s; }
.tour.centered .tour-spot { display: none; }
.tour-card { position: fixed; left: 12px; width: min(380px, calc(100vw - 24px)); max-height: calc(100vh - 24px); overflow: auto; background: var(--card); color: var(--ink); border: 1px solid var(--line); border-radius: 18px; padding: 14px 16px 14px; box-shadow: 0 16px 40px rgba(0,0,0,.35); animation: tour-fade .2s ease-out; }
.tour-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.tour-count { font-size: .78rem; font-weight: 700; color: var(--brand); background: var(--brand-soft); border-radius: 999px; padding: .2rem .6rem; }
.tour-skip { border: 0; background: transparent; color: var(--muted); font-weight: 600; min-height: 40px; padding: 0 6px; }
.tour-card h3 { margin: 6px 0 4px; font-size: 1.08rem; }
.tour-card p { margin: 0; line-height: 1.45; color: var(--ink); }
.tour-card p b { color: var(--brand); }
.tour-dots { display: flex; gap: 5px; margin: 12px 0 10px; }
.tour-dots i { width: 7px; height: 7px; border-radius: 50%; background: var(--line); }
.tour-dots i.on { background: var(--brand); width: 18px; border-radius: 4px; }
.tour-actions { display: flex; gap: 8px; }
.tour-actions .btn { flex: 1; }
.tour-actions .btn[disabled] { visibility: hidden; }
@keyframes tour-fade { from { opacity: 0; } to { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .tour-spot { transition: none; } .tour-card, .tour-welcome { animation: none; } }
/* keep the header on one line now that it also holds the ? button */
.topbar .brand { min-width: 0; }
.topbar .brand span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .brand img { flex: none; }
.topbar-right { flex: none; gap: 2px; }
.today-pill { white-space: nowrap; }
@media (max-width: 420px) {
  .topbar { padding-left: 12px; padding-right: 12px; }
  .topbar .brand { font-size: 1rem; gap: 6px; }
  .topbar .icon-btn.theme-toggle { width: 38px; }
  .today-pill { padding: .45rem .65rem; font-size: .92rem; }
}

/* ---------- bulk delete ---------- */
.clear-receipt-btn { grid-column: 1 / -1; background: transparent; }
.btn.danger-solid { background: var(--danger); border-color: var(--danger); color: #fff; }
[data-theme="dark"] .btn.danger-solid { background: #dc2626; border-color: #dc2626; color: #fff; }
.btn.danger-solid:disabled { opacity: .45; }
.confirm-sheet { text-align: left; }
.confirm-sheet .confirm-icon { width: 48px; height: 48px; border-radius: 50%; background: var(--danger-soft); display: flex; align-items: center; justify-content: center; font-size: 1.4rem; margin-bottom: 10px; }
.confirm-sheet h2 { margin-bottom: 8px; }
.confirm-sheet p { margin: 0 0 16px; line-height: 1.45; }
.confirm-sheet p b { color: var(--danger); }
.confirm-sheet .sheet-actions .btn { min-width: 110px; }
.confirm-sheet::backdrop { background: var(--tour-dim); }
.danger-zone { border: 1px solid var(--danger-border); }
.danger-zone h2 { color: var(--danger); }
.receipt-actions { margin-bottom: 84px; } /* keep the clear button clear of the floating Log button */

/* ---------- logo ---------- */
.logo-mark { display: block; flex: none; border-radius: 22%; }
.topbar .logo-mark { width: 30px; height: 30px; box-shadow: 0 1px 3px rgba(15, 23, 42, .25); }
[data-theme="dark"] .topbar .logo-mark { box-shadow: 0 0 0 1px rgba(139, 92, 246, .35), 0 0 10px rgba(139, 92, 246, .25); }
.logo-mark-lg { width: 96px; height: 96px; box-shadow: 0 10px 28px rgba(76, 29, 149, .28), 0 0 0 1px rgba(76, 29, 149, .08); }
[data-theme="dark"] .logo-mark-lg { box-shadow: 0 0 36px rgba(139, 92, 246, .45), 0 0 0 1px rgba(139, 92, 246, .3); }
.brand-big { gap: 14px; margin-top: 4px; }
.brand-big .wordmark { font-size: 1.9rem; font-weight: 700; letter-spacing: -.025em; }

/* ---------- no-spend days ---------- */
.no-spend-card { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; text-align: center; background: var(--brand-soft); color: var(--ink); border: 1px solid color-mix(in srgb, var(--brand) 35%, transparent); border-radius: 16px; padding: 18px 14px 14px; margin: 4px 0; }
.no-spend-card .ns-emoji { font-size: 2.2rem; line-height: 1; margin-bottom: 6px; }
.no-spend-card h3 { margin: 0 0 4px; font-size: 1.2rem; color: var(--brand); letter-spacing: -.01em; }
[data-theme="dark"] .no-spend-card h3 { color: var(--ink); }
.no-spend-card .ns-cheer { margin: 0 0 10px; line-height: 1.4; }
.ns-chips { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; margin-bottom: 10px; }
.ns-chip { background: var(--card); color: var(--ink); border: 1px solid var(--line); border-radius: 999px; padding: .25rem .65rem; font-size: .8rem; font-weight: 700; }
.no-spend-card .ns-budget { margin: 0 0 8px; font-weight: 700; font-size: .92rem; }
.no-spend-card .ns-forgot { margin: 0; font-size: .82rem; color: var(--muted); line-height: 1.4; }
.no-spend-card .ns-forgot .link-btn { font-size: .82rem; }
.streak-badge { display: inline-flex; align-items: center; gap: 4px; border: 1px solid color-mix(in srgb, var(--brand) 40%, transparent); background: var(--brand-soft); color: var(--brand); font-weight: 700; font-size: .85rem; border-radius: 999px; padding: .35rem .8rem; margin: 0 0 10px; }
[data-theme="dark"] .streak-badge { color: var(--ink); }
.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 70; overflow: hidden; }
.confetti span { position: absolute; top: -40px; animation: confetti-fall 1.9s ease-in forwards; }
@keyframes confetti-fall { 0% { transform: translate(0, 0) rotate(0); opacity: 1; } 100% { transform: translate(var(--drift, 0), 105vh) rotate(300deg); opacity: .2; } }
.ns-preview { margin-top: 12px; border: 1px solid var(--line); border-radius: 14px; padding: 12px; background: var(--input-bg); }
.ns-preview-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 6px; }
.ns-preview-label { margin: 10px 0 4px; font-size: .75rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.ns-email { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; }
.ns-email-subject { font-weight: 700; font-size: .9rem; margin-bottom: 6px; }
.ns-email pre { margin: 0; white-space: pre-wrap; font-family: inherit; font-size: .85rem; line-height: 1.45; }
.ns-sms { display: flex; }
.ns-sms-bubble { max-width: 88%; background: var(--icon-bg); color: var(--ink); border-radius: 18px 18px 18px 4px; padding: 10px 12px; white-space: pre-wrap; font-size: .88rem; line-height: 1.4; }

/* ---------- password reset ---------- */
.forgot-link { display: block; margin: 10px auto 0; font-size: .9rem; }
.auth-h { font-size: 1.15rem; margin: 4px 0 6px; text-align: center; }
.ok-note { background: var(--brand-soft); color: var(--ink); border-radius: 12px; padding: 10px 12px; font-size: .9rem; line-height: 1.35; }

/* ---------- undo toast ---------- */
.undo-toast { position: fixed; left: 50%; bottom: calc(var(--tabbar-h) + var(--safe-b) + 84px); transform: translateX(-50%); z-index: 55; width: min(420px, calc(100vw - 24px)); display: flex; align-items: center; gap: 10px; background: var(--toast-bg); color: var(--toast-ink); border-radius: 14px; padding: 10px 10px 12px 14px; box-shadow: 0 10px 28px rgba(0,0,0,.3); overflow: hidden; font-size: .92rem; animation: tour-fade .2s ease-out; }
.undo-toast span { flex: 1; min-width: 0; }
.undo-btn { border: 0; background: var(--brand); color: var(--brand-contrast, #fff); font-weight: 800; font-size: .9rem; padding: 8px 16px; border-radius: 999px; min-height: 40px; flex: none; }
.undo-timer { position: absolute; left: 0; bottom: 0; height: 3px; width: 100%; background: var(--brand); transform-origin: left; animation: undo-shrink var(--undo-ms, 8000ms) linear forwards; }
@keyframes undo-shrink { from { transform: scaleX(1); } to { transform: scaleX(0); } }

/* ---------- recurring ---------- */
.rec-list { list-style: none; padding: 0; margin: 8px 0; display: grid; gap: 8px; }
.rec-list li { display: grid; grid-template-columns: minmax(0,1fr) auto; gap: 4px 8px; align-items: center; border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; background: var(--input-bg); }
.rec-list li.paused { opacity: .6; }
.rec-list .rec-main b { display: block; }
.rec-list .rec-main small { color: var(--muted); font-size: .8rem; }
.rec-list .rec-amt { font-weight: 800; text-align: right; }
.rec-list .rec-actions { grid-column: 1 / -1; display: flex; gap: 8px; justify-content: flex-end; }
.rec-list .rec-actions .btn { min-height: 36px; padding: .35rem .8rem; font-size: .85rem; }
.rec-empty { color: var(--muted); font-size: .9rem; }
.rec-add summary { cursor: pointer; color: var(--brand); font-weight: 700; padding: 8px 0; list-style: none; }
.rec-add summary::-webkit-details-marker { display: none; }
.rec-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 10px; margin-bottom: 10px; }
.rec-grid label:nth-child(2) { grid-column: 1 / -1; order: -1; }
.rec-grid select, .rec-grid input { width: 100%; }

/* ---------- spending chart ---------- */
.chart { display: grid; grid-template-columns: 132px minmax(0,1fr); gap: 14px; align-items: center; margin: 4px 0 10px; }
.chart svg { width: 132px; height: 132px; display: block; }
.chart .donut-total { font: 800 15px ui-monospace, Menlo, Consolas, monospace; fill: currentColor; }
.chart .donut-sub { font: 600 9px -apple-system, system-ui, sans-serif; fill: var(--paper-muted, #888); letter-spacing: .08em; }
.chart-legend { list-style: none; margin: 0; padding: 0; display: grid; gap: 5px; font-size: .82rem; }
.chart-legend li { display: grid; grid-template-columns: 10px minmax(0,1fr) auto; gap: 6px; align-items: center; }
.chart-legend i { width: 10px; height: 10px; border-radius: 3px; }
.chart-legend span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chart-legend b { font-variant-numeric: tabular-nums; }
@media (max-width: 340px) { .chart { grid-template-columns: 1fr; justify-items: center; } }

/* Legal links + sign-up agreement */
.agree-note { font-size: .8rem; color: var(--muted); margin: 4px 0 10px; text-align: center; line-height: 1.4; }
.agree-note a, .legal-links a { color: inherit; text-decoration: underline; text-underline-offset: 2px; }
.legal-links { text-align: center; font-size: .8rem; color: var(--muted); margin: 10px 0 0; }
.legal-links.left { text-align: left; }
