/* Fynlet – design tokens ------------------------------------------------- */
:root {
  --bg: #f6f7f6; --surface: #ffffff; --surface-2: #f0f2f1; --text: #141816; --muted: #667069; --border: #e3e7e5;
  --accent: #2f9e6b; --accent-strong: #248058; --accent-soft: #e4f4ec; --on-accent: #ffffff;
  --income: #1d8f57; --expense: #d23c3c; --warn: #b7791f; --focus: #2f9e6b66;
  --shadow: 0 1px 2px rgba(16,24,20,.06), 0 6px 20px rgba(16,24,20,.06); --shadow-lg: 0 20px 60px rgba(8,14,11,.28);
  --radius: 14px; --radius-sm: 10px; --nav-h: 64px; --top-h: 56px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --safe-b: env(safe-area-inset-bottom, 0px); --safe-t: env(safe-area-inset-top, 0px);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1211; --surface: #171b19; --surface-2: #1f2522; --text: #ecf0ee; --muted: #98a39d; --border: #28302c;
    --accent: #3dbb85; --accent-strong: #52cf98; --accent-soft: #17302400; --on-accent: #07140d;
    --income: #4cc38a; --expense: #f07171; --warn: #e0a64a; --focus: #3dbb8566;
    --shadow: 0 1px 2px rgba(0,0,0,.4), 0 8px 24px rgba(0,0,0,.35); --shadow-lg: 0 20px 60px rgba(0,0,0,.6);
    --accent-soft: #173024; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0f1211; --surface: #171b19; --surface-2: #1f2522; --text: #ecf0ee; --muted: #98a39d; --border: #28302c;
  --accent: #3dbb85; --accent-strong: #52cf98; --accent-soft: #173024; --on-accent: #07140d;
  --income: #4cc38a; --expense: #f07171; --warn: #e0a64a; --focus: #3dbb8566;
  --shadow: 0 1px 2px rgba(0,0,0,.4), 0 8px 24px rgba(0,0,0,.35); --shadow-lg: 0 20px 60px rgba(0,0,0,.6); color-scheme: dark;
}

[hidden] { display: none !important; }
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.45 var(--font); -webkit-font-smoothing: antialiased; overscroll-behavior-y: none; }
h1, h2, h3 { margin: 0; line-height: 1.2; letter-spacing: -.01em; }
h1 { font-size: 1.5rem; } h2 { font-size: 1.15rem; } h3 { font-size: 1rem; }
p { margin: 0 0 .75rem; }
a { color: var(--accent-strong); text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 8px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--muted); } .small { font-size: .85rem; } .center { text-align: center; }
.income { color: var(--income); } .expense { color: var(--expense); } .neg { color: var(--expense) !important; }
.num { font-variant-numeric: tabular-nums; }
.hide-balances .amt { filter: blur(7px); user-select: none; transition: filter .2s; }
.hide-balances .amt:hover { filter: blur(7px); }
svg.i { width: 1.25em; height: 1.25em; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; vertical-align: -.22em; }

.boot { min-height: 100vh; display: grid; place-content: center; justify-items: center; gap: .5rem; text-align: center; padding: 2rem; color: var(--muted); }
.boot img { animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 50% { transform: scale(.94); opacity: .8; } }

/* Top bar & navigation ---------------------------------------------------- */
.topbar { position: sticky; top: 0; z-index: 20; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border); padding-top: var(--safe-t); }
.topbar-in { max-width: 960px; margin: 0 auto; height: var(--top-h); display: flex; align-items: center; gap: .75rem; padding: 0 16px; }
.brand { display: inline-flex; align-items: center; gap: .55rem; color: var(--text); font-weight: 750; font-size: 1.2rem; letter-spacing: -.03em; }
.brand img { width: 30px; height: 30px; border-radius: 8px; }
.brand span b { color: var(--accent); font-weight: 750; }
.nav { display: flex; gap: .25rem; margin-left: auto; }
.nav a { display: inline-flex; align-items: center; gap: .4rem; padding: .55rem .85rem; border-radius: 999px; color: var(--muted); font-weight: 600; min-height: 44px; transition: background .15s, color .15s; }
.nav a:hover { background: var(--surface-2); color: var(--text); }
.nav a.active { color: var(--accent-strong); background: var(--accent-soft); }
.nav a svg { display: none; }
.top-actions { display: flex; align-items: center; gap: .25rem; }
.bottomnav { display: none; }
.icon-btn { display: inline-grid; place-items: center; width: 44px; height: 44px; border: 0; background: transparent; border-radius: 50%; color: var(--muted); transition: background .15s, color .15s, transform .1s; }
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn:active { transform: scale(.92); }
.icon-btn.on { color: var(--accent-strong); }
.offline-banner { background: var(--warn); color: #fff; text-align: center; font-weight: 600; padding: .4rem 1rem; font-size: .9rem; position: sticky; top: 0; z-index: 30; }
@media (max-width: 719px) {
  .nav { display: none; }
  .top-actions { margin-left: auto; }
  .bottomnav { display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; background: color-mix(in srgb, var(--surface) 94%, transparent); backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px); border-top: 1px solid var(--border); padding-bottom: var(--safe-b); }
  .bottomnav a { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; height: var(--nav-h); color: var(--muted); font-size: .72rem; font-weight: 600; }
  .bottomnav a svg { width: 1.5rem; height: 1.5rem; }
  .bottomnav a.active { color: var(--accent-strong); }
  .page { padding-bottom: calc(var(--nav-h) + var(--safe-b) + 24px) !important; }
  body.on-budget .bottomnav { display: none; }
  body.on-budget .page { padding-bottom: calc(96px + var(--safe-b)) !important; }
}

/* Layout ------------------------------------------------------------------- */
.page { max-width: 960px; margin: 0 auto; padding: 20px 16px 48px; animation: rise .22s ease-out; }
.page.narrow { max-width: 680px; }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } }
.page-head { display: flex; align-items: center; gap: .75rem; margin-bottom: 1rem; flex-wrap: wrap; }
.page-head h1 { flex: 1; min-width: 0; }
.stack > * + * { margin-top: 1rem; }
.row-flex { display: flex; align-items: center; gap: .75rem; }
.grow { flex: 1; min-width: 0; }
.section-title { font-size: .78rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 700; margin: 1.5rem 0 .5rem; display: flex; align-items: center; gap: .5rem; }
.section-title .count { background: var(--surface-2); border-radius: 999px; padding: 0 .5rem; font-size: .75rem; }

/* Buttons & forms --------------------------------------------------------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .45rem; min-height: 46px; padding: 0 1.1rem; border-radius: 12px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); font-weight: 650; transition: transform .1s, background .15s, border-color .15s, box-shadow .15s; }
.btn:hover { border-color: color-mix(in srgb, var(--border) 50%, var(--muted)); }
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn.primary:hover { background: var(--accent-strong); border-color: var(--accent-strong); }
.btn.income-btn { background: var(--income); border-color: var(--income); color: var(--on-accent); }
.btn.expense-btn { background: var(--expense); border-color: var(--expense); color: #fff; }
.btn.danger { color: var(--expense); border-color: color-mix(in srgb, var(--expense) 40%, var(--border)); }
.btn.danger.solid { background: var(--expense); color: #fff; border-color: var(--expense); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.ghost:hover { background: var(--surface-2); color: var(--text); }
.btn.sm { min-height: 38px; padding: 0 .8rem; font-size: .9rem; border-radius: 10px; }
.btn.block { width: 100%; }
.field { display: block; margin-bottom: .9rem; }
.field > span, .field > label { display: block; font-size: .85rem; font-weight: 650; margin-bottom: .3rem; color: var(--muted); }
.input, .select, .textarea { width: 100%; min-height: 46px; padding: .6rem .85rem; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; transition: border-color .15s, box-shadow .15s; }
.textarea { min-height: 80px; resize: vertical; }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--focus); }
.input.invalid { border-color: var(--expense); }
.field-error { color: var(--expense); font-size: .85rem; margin-top: .25rem; }
.form-error { background: color-mix(in srgb, var(--expense) 12%, transparent); color: var(--expense); padding: .6rem .85rem; border-radius: 10px; margin-bottom: .9rem; font-size: .92rem; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; }
@media (max-width: 480px) { .grid2.stack-sm { grid-template-columns: 1fr; } }
.check-line { display: flex; align-items: center; gap: .65rem; min-height: 44px; cursor: pointer; }
.check-line input { width: 22px; height: 22px; accent-color: var(--accent); flex: none; }
.amount-input { position: relative; }
.amount-input .input { font-size: 1.35rem; font-weight: 700; padding-left: 2rem; font-variant-numeric: tabular-nums; }
.amount-input::before { content: attr(data-sym); position: absolute; left: .85rem; top: 50%; transform: translateY(-50%); color: var(--muted); font-weight: 700; z-index: 1; }
.seg { display: inline-flex; background: var(--surface-2); border-radius: 12px; padding: 3px; gap: 2px; }
.seg button { border: 0; background: transparent; min-height: 40px; padding: 0 1rem; border-radius: 9px; font-weight: 650; color: var(--muted); }
.seg button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.switch { appearance: none; width: 50px; height: 30px; border-radius: 99px; background: var(--border); position: relative; transition: background .2s; flex: none; cursor: pointer; margin: 0; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; transition: transform .2s; box-shadow: 0 1px 3px rgba(0,0,0,.3); }
.switch:checked { background: var(--accent); } .switch:checked::after { transform: translateX(20px); }

/* Cards / panels ----------------------------------------------------------- */
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.panel-pad { padding: 1rem 1.1rem; }
.setting-row { display: flex; align-items: center; gap: 1rem; padding: .85rem 1.1rem; min-height: 58px; }
.setting-row + .setting-row { border-top: 1px solid var(--border); }
.setting-row .select { width: auto; min-width: 150px; }
.setting-row small { display: block; color: var(--muted); }
.empty { text-align: center; padding: 2.5rem 1rem; color: var(--muted); }
.empty svg { width: 2.2rem; height: 2.2rem; opacity: .5; margin-bottom: .5rem; }

/* Dashboard ------------------------------------------------------------------ */
.hero { padding: 1.4rem 1.25rem; text-align: center; }
.hero .label { color: var(--muted); font-size: .85rem; font-weight: 650; }
.hero .big { font-size: clamp(2.2rem, 8vw, 3.2rem); font-weight: 780; letter-spacing: -.03em; line-height: 1.1; font-variant-numeric: tabular-nums; margin: .15rem 0 .6rem; }
.stat-row { display: flex; justify-content: center; gap: 1.75rem; flex-wrap: wrap; }
.stat b { display: block; font-size: 1.05rem; font-variant-numeric: tabular-nums; } .stat span { font-size: .78rem; color: var(--muted); font-weight: 650; }
.toolbar { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; }
.search { position: relative; flex: 1; min-width: 160px; }
.search svg { position: absolute; left: .8rem; top: 50%; transform: translateY(-50%); color: var(--muted); }
.search .input { padding-left: 2.4rem; }
.budget-list { display: grid; gap: .6rem; }
@media (min-width: 720px) { .budget-list.cols { grid-template-columns: 1fr 1fr; } }
.budget-card { display: flex; align-items: center; gap: .85rem; padding: .85rem .9rem; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  transition: transform .12s, box-shadow .15s, border-color .15s; position: relative; color: var(--text); touch-action: pan-y; }
.budget-card:hover { box-shadow: var(--shadow); border-color: color-mix(in srgb, var(--border) 60%, var(--accent)); }
.budget-card:active { transform: scale(.992); }
.b-icon { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; color: #fff; flex: none; }
.b-icon svg { width: 22px; height: 22px; }
.b-main { flex: 1; min-width: 0; }
.b-name { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.b-meta { font-size: .8rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.b-right { text-align: right; }
.b-rem { font-weight: 750; font-variant-numeric: tabular-nums; }
.b-actions { display: flex; align-items: center; }
.b-actions .icon-btn { width: 40px; height: 40px; }
.handle { cursor: grab; touch-action: none; color: var(--muted); opacity: .6; }
.handle:active { cursor: grabbing; }
.dragging { position: relative; z-index: 5; box-shadow: var(--shadow-lg) !important; transition: none !important; opacity: .96; }
.placeholder { border: 2px dashed var(--border); border-radius: var(--radius); background: transparent; }
.upcoming { display: grid; }
.upcoming a { display: flex; align-items: center; gap: .75rem; padding: .7rem 1rem; color: var(--text); min-height: 52px; }
.upcoming a + a { border-top: 1px solid var(--border); }
.upcoming .dot { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.due-badge { font-size: .76rem; font-weight: 700; padding: .12rem .5rem; border-radius: 99px; background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.due-badge.late { background: color-mix(in srgb, var(--expense) 15%, transparent); color: var(--expense); }
.due-badge.soon { background: color-mix(in srgb, var(--warn) 18%, transparent); color: var(--warn); }
.recent { display: flex; gap: .5rem; overflow-x: auto; padding-bottom: .25rem; scrollbar-width: none; }
.chip { display: inline-flex; align-items: center; gap: .4rem; padding: .4rem .8rem; border-radius: 99px; background: var(--surface); border: 1px solid var(--border); white-space: nowrap; font-weight: 600; font-size: .9rem; color: var(--text); min-height: 38px; }
button.chip:hover, a.chip:hover { border-color: var(--accent); }
.chip.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-strong); }
.chip .dot { width: 9px; height: 9px; border-radius: 50%; }
.fab-row { display: flex; gap: .6rem; }

/* Budget screen ----------------------------------------------------------- */
.budget-head { display: flex; align-items: center; gap: .5rem; margin-bottom: .5rem; }
.budget-head h1 { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 1.3rem; }
.summary { padding: 1.1rem 1.2rem; margin-bottom: 1rem; }
.summary .remaining { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; }
.summary .remaining .big { font-size: clamp(2rem, 8vw, 2.7rem); font-weight: 780; letter-spacing: -.03em; font-variant-numeric: tabular-nums; }
.summary .mini { display: grid; grid-template-columns: repeat(3, 1fr); gap: .5rem; margin-top: .75rem; padding-top: .75rem; border-top: 1px solid var(--border); }
.summary .mini b { display: block; font-variant-numeric: tabular-nums; }
.summary .mini span { font-size: .75rem; color: var(--muted); font-weight: 650; }
.meter { height: 6px; background: var(--surface-2); border-radius: 99px; overflow: hidden; margin-top: .75rem; }
.meter i { display: block; height: 100%; background: var(--accent); border-radius: 99px; transition: width .35s ease; }
.filters { display: flex; gap: .5rem; align-items: center; margin-bottom: .75rem; overflow-x: auto; scrollbar-width: none; }
.entries { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.entry { display: flex; align-items: center; gap: .6rem; padding: .35rem .6rem .35rem .4rem; min-height: 60px; background: var(--surface); transition: background .15s, opacity .2s; position: relative; }
.entry + .entry { border-top: 1px solid var(--border); }
.entry:hover { background: color-mix(in srgb, var(--surface) 94%, var(--accent)); }
.entry .handle { display: grid; place-items: center; width: 30px; height: 44px; }
.check { width: 44px; height: 44px; display: grid; place-items: center; border: 0; background: transparent; flex: none; }
.check i { width: 26px; height: 26px; border-radius: 50%; border: 2px solid var(--muted); display: grid; place-items: center; color: transparent; transition: all .18s; }
.check i svg { width: 15px; height: 15px; stroke-width: 3.2; transform: scale(.4); transition: transform .18s; }
.entry.income-e .check i { border-color: color-mix(in srgb, var(--income) 60%, var(--muted)); }
.entry.expense-e .check i { border-color: color-mix(in srgb, var(--expense) 55%, var(--muted)); }
.entry.done .check i { background: var(--accent); border-color: var(--accent); color: #fff; }
.entry.done .check i svg { transform: scale(1); }
.entry-main { flex: 1; min-width: 0; text-align: left; border: 0; background: none; padding: .35rem 0; }
.entry-name { font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: flex; align-items: center; gap: .35rem; }
.entry-name svg { width: .9em; height: .9em; color: var(--muted); }
.entry-meta { font-size: .78rem; color: var(--muted); display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.entry.done .entry-name { color: var(--muted); font-weight: 500; text-decoration: line-through; text-decoration-color: color-mix(in srgb, var(--muted) 60%, transparent); }
.entry.done .entry-amt { opacity: .6; }
.entry:not(.done).expense-e .entry-name { font-weight: 700; }
.entry-amt { font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; padding-right: .25rem; }
.star { color: var(--muted); } .star.on { color: #e5a50a; } .star.on svg { fill: currentColor; }
.cat-dot { display: inline-flex; align-items: center; gap: .3rem; } .cat-dot i { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.overdue { color: var(--expense); font-weight: 700; }
.total-row { display: flex; justify-content: space-between; padding: .95rem 1.1rem; font-weight: 750; font-size: 1.05rem; background: var(--surface-2); border-top: 1px solid var(--border); }
.actionbar { display: flex; gap: .6rem; margin-top: 1rem; }
.actionbar .btn { flex: 1; min-height: 52px; font-size: 1rem; }
@media (max-width: 719px) {
  .actionbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 15; margin: 0; padding: .65rem 16px calc(.65rem + var(--safe-b));
    background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); border-top: 1px solid var(--border); }
}
.suggest { display: flex; gap: .4rem; flex-wrap: wrap; margin-bottom: .9rem; }
.suggest .chip { min-height: 34px; font-size: .85rem; padding: .25rem .65rem; }

/* Modal / sheet / toast ---------------------------------------------------- */
.backdrop { position: fixed; inset: 0; background: rgba(8,12,10,.5); z-index: 50; display: grid; place-items: center; padding: 16px; animation: fade .15s; overflow-y: auto; }
@keyframes fade { from { opacity: 0; } }
.modal { background: var(--surface); width: min(520px, 100%); border-radius: 20px; box-shadow: var(--shadow-lg); animation: pop .2s cubic-bezier(.2,.9,.3,1.2); max-height: calc(100dvh - 32px); display: flex; flex-direction: column; }
.modal.wide { width: min(680px, 100%); }
@keyframes pop { from { opacity: 0; transform: translateY(14px) scale(.98); } }
.modal-head { display: flex; align-items: center; gap: .5rem; padding: 1rem 1rem .5rem 1.25rem; }
.modal-head h2 { flex: 1; }
.modal-body { padding: .5rem 1.25rem 1rem; overflow-y: auto; overscroll-behavior: contain; }
.modal-foot { display: flex; gap: .6rem; padding: .75rem 1.25rem calc(1rem + var(--safe-b)); border-top: 1px solid var(--border); flex-wrap: wrap; }
.modal-foot .btn.primary { flex: 1; }
@media (max-width: 560px) {
  .backdrop { align-items: end; padding: 0; }
  .modal { border-radius: 22px 22px 0 0; width: 100%; max-height: 92dvh; animation: sheet .24s cubic-bezier(.2,.9,.3,1); }
  @keyframes sheet { from { transform: translateY(40%); opacity: 0; } }
}
.more-toggle { background: none; border: 0; color: var(--accent-strong); font-weight: 650; padding: .5rem 0; min-height: 44px; display: inline-flex; align-items: center; gap: .3rem; }
.toasts { position: fixed; left: 0; right: 0; bottom: calc(var(--nav-h) + var(--safe-b) + 14px); display: grid; justify-items: center; gap: .5rem; z-index: 80; pointer-events: none; padding: 0 16px; }
body.on-budget .toasts { bottom: calc(96px + var(--safe-b)); }
@media (min-width: 720px) { .toasts, body.on-budget .toasts { bottom: 24px; } }
.toast { pointer-events: auto; background: #1b211e; color: #f1f5f3; padding: .7rem 1rem; border-radius: 12px; box-shadow: var(--shadow-lg); display: flex; align-items: center; gap: .9rem; animation: pop .2s; max-width: 460px; font-size: .95rem; }
.toast.error { background: #8c2222; } .toast button { background: none; border: 0; color: #7fe0b0; font-weight: 750; padding: .4rem .2rem; min-height: 36px; }
.menu { position: fixed; z-index: 60; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow-lg); padding: .35rem; min-width: 210px; animation: pop .14s; }
.menu button { display: flex; align-items: center; gap: .65rem; width: 100%; text-align: left; border: 0; background: none; padding: .65rem .8rem; border-radius: 9px; min-height: 44px; font-weight: 550; }
.menu button:hover { background: var(--surface-2); } .menu button.danger { color: var(--expense); }
.menu hr { border: 0; border-top: 1px solid var(--border); margin: .3rem 0; }
.swatches { display: flex; gap: .5rem; flex-wrap: wrap; }
.swatch { width: 34px; height: 34px; border-radius: 50%; border: 3px solid transparent; box-shadow: 0 0 0 1px var(--border) inset; padding: 0; }
.swatch.on { border-color: var(--surface); box-shadow: 0 0 0 2px var(--text); }
.icon-pick { display: flex; gap: .4rem; flex-wrap: wrap; }
.icon-pick button { width: 42px; height: 42px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface); display: grid; place-items: center; color: var(--muted); }
.icon-pick button.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-strong); }
details.adv { border-top: 1px solid var(--border); padding-top: .5rem; margin-top: .25rem; }
details.adv summary { cursor: pointer; font-weight: 650; min-height: 44px; display: flex; align-items: center; color: var(--accent-strong); list-style: none; }
details.adv summary::-webkit-details-marker { display: none; }

/* Auth ----------------------------------------------------------------------- */
.auth { min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px; }
.auth-card { width: min(420px, 100%); }
.auth-brand { text-align: center; margin-bottom: 1.5rem; }
.auth-brand img { width: 72px; height: 72px; border-radius: 20px; box-shadow: var(--shadow); }
.auth-brand h1 { font-size: 2rem; margin-top: .75rem; letter-spacing: -.04em; } .auth-brand h1 b { color: var(--accent); }
.auth-brand p { color: var(--muted); margin-top: .25rem; }
.auth-card .panel { padding: 1.4rem; box-shadow: var(--shadow); }

/* Reports -------------------------------------------------------------------- */
.chart { width: 100%; height: auto; display: block; }
.chart text { fill: var(--muted); font-size: 13px; font-family: var(--font); }
.chart .grid { stroke: var(--border); stroke-width: 1; }
.chart .bar-inc { fill: var(--income); } .chart .bar-exp { fill: var(--expense); }
.legend { display: flex; gap: 1rem; font-size: .82rem; color: var(--muted); flex-wrap: wrap; margin-top: .5rem; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: .35rem; }
.hbar { display: grid; grid-template-columns: 110px 1fr auto; gap: .6rem; align-items: center; padding: .35rem 0; font-size: .9rem; }
.hbar .track { height: 12px; background: var(--surface-2); border-radius: 99px; overflow: hidden; } .hbar .track i { display: block; height: 100%; border-radius: 99px; }
.hbar .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.table { width: 100%; border-collapse: collapse; font-size: .92rem; } .table th { text-align: left; color: var(--muted); font-size: .78rem; text-transform: uppercase; letter-spacing: .05em; }
.table th, .table td { padding: .55rem .5rem; border-bottom: 1px solid var(--border); } .table td.r, .table th.r { text-align: right; font-variant-numeric: tabular-nums; }
.table-wrap { overflow-x: auto; }
.report-grid { display: grid; gap: 1rem; } @media (min-width: 820px) { .report-grid.two { grid-template-columns: 1fr 1fr; } }
.stack-bar { display: flex; height: 16px; border-radius: 99px; overflow: hidden; background: var(--surface-2); margin: .5rem 0; } .stack-bar i { display: block; height: 100%; transition: width .3s; }

/* Template editor ------------------------------------------------------------ */
.tpl-row { display: grid; grid-template-columns: 28px 106px 1fr 104px 34px; gap: .4rem; align-items: center; margin-bottom: .4rem; }
.tpl-row .select, .tpl-row .input { min-height: 42px; padding: .4rem .55rem; font-size: .92rem; }
@media (max-width: 560px) { .tpl-row { grid-template-columns: 28px 1fr 100px 34px; } .tpl-row .select.type { grid-column: 2 / 5; } }
.tpl-card { display: flex; align-items: center; gap: .8rem; padding: .9rem 1rem; }
.tpl-card + .tpl-card { border-top: 1px solid var(--border); }

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; } }

/* Template editor rows */
.tpl-item { margin-bottom: .7rem; padding-bottom: .7rem; border-bottom: 1px dashed var(--border); }
.tpl-sub { display: flex; gap: .4rem; padding-left: 32px; margin-top: .3rem; }
.tpl-sub .select { min-height: 38px; font-size: .85rem; padding: .25rem .5rem; }
.tpl-row .handle { display: grid; place-items: center; height: 42px; }
.tpl-row .icon-btn { width: 34px; height: 42px; }
