:root {
  --bg: #F5F7F6; --surface: #FFFFFF; --sunk: #E9EEEC; --line: #D7E0DD;
  --ink: #12303A; --ink-2: #4A626A; --ink-3: #7F9399;
  --teal: #0E9C9A; --amber: #B97F00; --amber-bg: #FFF3D6; --red: #C2413B;
  --h0: #E4EAE8; --h1: #C9D2F2; --h2: #9AA6E6; --h3: #6670CF; --h4: #3E44A6; --h5: #2A2C78;
  --display: 'Bricolage Grotesque', ui-sans-serif, system-ui, sans-serif;
  --ui: 'Instrument Sans', ui-sans-serif, system-ui, -apple-system, sans-serif;
  --r-s: 8px; --r-m: 14px; --r-l: 22px;
  --tabs-h: 64px; --safe-b: env(safe-area-inset-bottom, 0px);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0C1C21; --surface: #12262C; --sunk: #183139; --line: #22404A;
    --ink: #E3EEF0; --ink-2: #A5BBC0; --ink-3: #6E878D;
    --teal: #3CC7C2; --amber: #F2B83A; --amber-bg: #3A2F12; --red: #F07A73;
    --h0: #17303A; --h1: #263B6B; --h2: #3A4D9C; --h3: #5765C8; --h4: #8790E6; --h5: #C2C8FF;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0C1C21; --surface: #12262C; --sunk: #183139; --line: #22404A;
  --ink: #E3EEF0; --ink-2: #A5BBC0; --ink-3: #6E878D;
  --teal: #3CC7C2; --amber: #F2B83A; --amber-bg: #3A2F12; --red: #F07A73;
  --h0: #17303A; --h1: #263B6B; --h2: #3A4D9C; --h3: #5765C8; --h4: #8790E6; --h5: #C2C8FF;
  color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--ink); }
body { font: 16px/1.45 var(--ui); font-variant-numeric: tabular-nums; min-height: 100dvh; -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: inherit; }
:focus-visible { outline: 2px solid var(--teal); outline-offset: 2px; border-radius: 4px; }
svg { stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

main { max-width: 540px; margin: 0 auto; padding: calc(env(safe-area-inset-top, 0px) + 18px) 16px calc(var(--tabs-h) + var(--safe-b) + 28px); outline: none; }

/* type */
.fig { font-family: var(--display); font-variation-settings: 'wdth' 85; font-weight: 700; letter-spacing: -0.02em; line-height: 1; }
.fig-xl { font-size: clamp(44px, 13vw, 64px); }
.fig-l { font-size: 30px; }
.cur { font-family: var(--ui); font-size: 0.32em; font-weight: 600; letter-spacing: 0; color: var(--ink-3); margin-right: 0.3em; vertical-align: 0.9em; }
h1 { font: 600 15px/1.3 var(--ui); color: var(--ink-2); margin: 0 0 8px; }
h2 { font: 700 20px/1.2 var(--display); font-variation-settings: 'wdth' 90; margin: 34px 0 12px; letter-spacing: -0.01em; }
h2:first-child { margin-top: 0; }
.muted { color: var(--ink-2); }
.small { font-size: 13.5px; }
.pos { color: var(--teal); }
.neg { color: var(--ink); }

/* home */
.top { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.month-nav { display: flex; gap: 2px; }
.icon-btn { background: none; border: 0; width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; color: var(--ink-2); cursor: pointer; }
.icon-btn:active { background: var(--sunk); }
.icon-btn svg { width: 20px; height: 20px; }
.forecast { margin: 14px 0 0; font-size: 16.5px; max-width: 34ch; }
.forecast b { font-weight: 600; }
.pace { position: relative; height: 8px; background: var(--sunk); border-radius: 4px; margin: 16px 0 6px; overflow: visible; }
.pace .spent { position: absolute; inset: 0 auto 0 0; background: var(--ink); border-radius: 4px; }
.pace .proj { position: absolute; inset: 0 auto 0 0; background: repeating-linear-gradient(-45deg, var(--h2) 0 4px, transparent 4px 7px); border-radius: 4px; }
.pace .cap { position: absolute; top: -5px; bottom: -5px; width: 2px; background: var(--amber); }
.pace-legend { display: flex; justify-content: space-between; font-size: 12.5px; color: var(--ink-3); }

.review { display: flex; align-items: center; gap: 10px; width: 100%; margin-top: 18px; padding: 12px 14px; border-radius: var(--r-m); border: 1px dashed var(--h3); background: transparent; text-align: left; cursor: pointer; }
.review .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--h4); flex: none; }

.year { margin-top: 30px; }
.year-head { display: flex; align-items: baseline; justify-content: space-between; }
.year-head h2 { margin: 0; }
.grid { display: grid; grid-template-columns: 16px repeat(31, minmax(0, 1fr)); gap: 2px; margin-top: 12px; }
.grid .ml { font-size: 10.5px; color: var(--ink-3); align-self: center; font-weight: 600; }
.grid .d { aspect-ratio: 1; min-width: 0; width: 100%; border-radius: 2px; background: var(--h0); border: 0; padding: 0; cursor: pointer; }
.grid .d.x { background: transparent; cursor: default; }
.grid .d.f { background: transparent; box-shadow: inset 0 0 0 1px var(--h0); cursor: default; }
.grid .d.t { box-shadow: 0 0 0 1.5px var(--teal); }
.grid .d.l1 { background: var(--h1); } .grid .d.l2 { background: var(--h2); } .grid .d.l3 { background: var(--h3); }
.grid .d.l4 { background: var(--h4); } .grid .d.l5 { background: var(--h5); }
.scale { display: flex; align-items: center; gap: 3px; justify-content: flex-end; margin-top: 10px; font-size: 12px; color: var(--ink-3); }
.scale i { width: 10px; height: 10px; border-radius: 2px; display: inline-block; }
.peek { min-height: 22px; margin-top: 8px; font-size: 14px; color: var(--ink-2); }

/* budgets */
.budget { padding: 12px 0; border-bottom: 1px solid var(--line); }
.budget:last-child { border-bottom: 0; }
.budget .row { display: flex; justify-content: space-between; gap: 10px; font-size: 15px; }
.bar { height: 6px; border-radius: 3px; background: var(--sunk); margin-top: 8px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--ink-2); border-radius: 3px; }
.bar.near > i { background: var(--amber); } .bar.over > i { background: var(--red); }

/* transaction list */
.day-h { display: flex; justify-content: space-between; font-size: 13px; color: var(--ink-3); font-weight: 600; margin: 22px 0 4px; }
.tx { display: flex; align-items: center; gap: 12px; width: 100%; padding: 10px 0; background: none; border: 0; border-bottom: 1px solid var(--line); text-align: left; cursor: pointer; }
.tx:last-child { border-bottom: 0; }
.tx .ic { width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; font-size: 19px; flex: none; background: var(--sunk); }
.tx .mid { flex: 1; min-width: 0; }
.tx .t1 { font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tx .t2 { font-size: 13px; color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tx .amt { font-weight: 600; text-align: right; white-space: nowrap; }
.tx .amt small { display: block; font-weight: 400; font-size: 12px; color: var(--ink-3); }
.tx.pending .ic { box-shadow: inset 0 0 0 1.5px var(--h3); background: transparent; }
.empty { padding: 36px 8px; text-align: center; color: var(--ink-2); }
.empty button { margin-top: 12px; }

/* filters */
.filters { display: flex; gap: 8px; overflow-x: auto; padding: 4px 0 6px; scrollbar-width: none; margin: 0 -16px; padding-left: 16px; padding-right: 16px; }
.filters::-webkit-scrollbar { display: none; }
.chip { flex: none; border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 7px 13px; font-size: 14px; cursor: pointer; white-space: nowrap; }
.chip.on { background: var(--ink); color: var(--bg); border-color: var(--ink); }
select.chip { appearance: none; padding-right: 13px; }
.search { width: 100%; border: 1px solid var(--line); background: var(--surface); border-radius: var(--r-m); padding: 11px 14px; margin-bottom: 8px; }
.daterow { display: flex; gap: 8px; margin-top: 4px; }
.daterow input { flex: 1; min-width: 0; border: 1px solid var(--line); background: var(--surface); border-radius: var(--r-s); padding: 8px 10px; font-size: 14px; }

/* segmented */
.seg { display: inline-flex; background: var(--sunk); border-radius: 999px; padding: 3px; }
.seg button { border: 0; background: none; border-radius: 999px; padding: 7px 15px; font-size: 14.5px; font-weight: 500; color: var(--ink-2); cursor: pointer; }
.seg button.on { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(18, 48, 58, .14); }

/* charts */
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 18px 16px; margin: 20px 0 6px; }
.stats div span { display: block; font-size: 13px; color: var(--ink-3); margin-bottom: 4px; }
.stats div b { font: 700 22px/1.1 var(--display); font-variation-settings: 'wdth' 85; letter-spacing: -0.01em; }
.chart { width: 100%; height: auto; display: block; margin-top: 8px; }
.chart rect { stroke: none; }
.chart text { fill: var(--ink-3); stroke: none; font: 10.5px var(--ui); }
.cat-row { display: grid; grid-template-columns: 26px 1fr auto; gap: 4px 10px; align-items: center; padding: 9px 0; border: 0; background: none; width: 100%; text-align: left; cursor: pointer; }
.cat-row .e { font-size: 18px; }
.cat-row .n { font-size: 15px; }
.cat-row .v { font-weight: 600; }
.cat-row .bar { grid-column: 2 / 4; margin-top: 2px; height: 5px; }

/* more */
.list-row { display: flex; align-items: center; gap: 12px; width: 100%; padding: 13px 0; border: 0; border-bottom: 1px solid var(--line); background: none; text-align: left; cursor: pointer; }
.list-row:last-child { border-bottom: 0; }
.list-row .e { font-size: 20px; width: 30px; text-align: center; }
.list-row .grow { flex: 1; min-width: 0; }
.list-row .sub { font-size: 13px; color: var(--ink-3); }
.total-line { display: flex; justify-content: space-between; align-items: baseline; margin: 6px 0 2px; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.btn { border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 10px 16px; font-weight: 500; cursor: pointer; text-decoration: none; font-size: 15px; display: inline-flex; align-items: center; gap: 6px; }
.btn.primary { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.btn.danger { color: var(--red); }
.btn.block { width: 100%; justify-content: center; padding: 14px; font-size: 16px; }
code, .code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; background: var(--sunk); padding: 2px 6px; border-radius: 5px; overflow-wrap: anywhere; }
ol.steps { padding-left: 20px; margin: 8px 0; } ol.steps li { margin: 6px 0; }

/* tabs */
.tabs { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; height: calc(var(--tabs-h) + var(--safe-b)); padding-bottom: var(--safe-b);
  display: flex; justify-content: space-around; align-items: center; background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); border-top: 1px solid var(--line); }
.tabs a { display: flex; flex-direction: column; align-items: center; gap: 3px; font-size: 11px; font-weight: 500; color: var(--ink-3); text-decoration: none; width: 64px; padding: 6px 0; }
.tabs a svg { width: 22px; height: 22px; }
.tabs a.on { color: var(--ink); }
.add-btn { width: 54px; height: 54px; border-radius: 50%; border: 0; background: var(--ink); color: var(--bg); display: grid; place-items: center; cursor: pointer; transform: translateY(-6px); box-shadow: 0 6px 16px -6px rgba(18, 48, 58, .5); }
.add-btn svg { width: 26px; height: 26px; stroke-width: 2.4; }
.add-btn:active { transform: translateY(-6px) scale(.94); }

/* sheet */
.scrim { position: fixed; inset: 0; z-index: 40; background: rgba(8, 20, 24, .42); opacity: 0; transition: opacity .2s; }
.sheet { position: fixed; left: 0; right: 0; bottom: 0; z-index: 41; max-width: 560px; margin: 0 auto; max-height: 92dvh; overflow-y: auto; overscroll-behavior: contain;
  background: var(--surface); border-radius: var(--r-l) var(--r-l) 0 0; padding: 10px 18px calc(var(--safe-b) + 20px); transform: translateY(100%); transition: transform .26s cubic-bezier(.2, .8, .2, 1); }
.sheet.open { transform: none; } .scrim.open { opacity: 1; }
.grab { width: 38px; height: 5px; border-radius: 3px; background: var(--line); margin: 0 auto 12px; }
.sheet-h { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.sheet-h h3 { font: 700 19px var(--display); margin: 0; font-variation-settings: 'wdth' 90; }
@media (prefers-reduced-motion: reduce) { .sheet, .scrim { transition: none; } }

.amount-wrap { display: flex; align-items: baseline; gap: 8px; margin: 14px 0 6px; border-bottom: 2px solid var(--ink); padding-bottom: 4px; }
.amount-wrap .cc { font-weight: 600; color: var(--ink-3); font-size: 17px; }
.amount-in { border: 0; background: none; outline: none; width: 100%; font-family: var(--display); font-variation-settings: 'wdth' 85; font-weight: 700; font-size: 46px; letter-spacing: -0.02em; padding: 0; min-width: 0; }
.amount-in::placeholder { color: var(--line); }
.label { font-size: 13px; color: var(--ink-3); font-weight: 600; margin: 16px 0 7px; display: block; }
.acct-chips { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
.acct-chips::-webkit-scrollbar { display: none; }
.cats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.cat { border: 1px solid transparent; background: var(--sunk); border-radius: var(--r-m); padding: 9px 4px 7px; display: flex; flex-direction: column; align-items: center; gap: 3px; cursor: pointer; min-width: 0; }
.cat .e { font-size: 21px; line-height: 1.1; }
.cat .n { font-size: 11.5px; color: var(--ink-2); max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cat.on { border-color: var(--ink); background: var(--surface); }
.cat.on .n { color: var(--ink); }
.subcats { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.field { width: 100%; border: 1px solid var(--line); background: var(--bg); border-radius: var(--r-s); padding: 11px 12px; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.warn { margin-top: 14px; padding: 11px 13px; border-radius: var(--r-s); background: var(--amber-bg); color: var(--ink); font-size: 14.5px; border-left: 3px solid var(--amber); }
.warn.over { border-left-color: var(--red); }
.rate-note { font-size: 13px; color: var(--ink-3); margin-top: 6px; }
.sheet-actions { display: flex; gap: 10px; margin-top: 22px; }
.sheet-actions .btn.primary { flex: 1; justify-content: center; padding: 14px; font-size: 16px; }

#toast { position: fixed; left: 50%; bottom: calc(var(--tabs-h) + var(--safe-b) + 14px); transform: translate(-50%, 20px); opacity: 0; z-index: 60;
  background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 999px; font-size: 14.5px; pointer-events: none; transition: .2s; max-width: calc(100% - 32px); }
#toast.show { opacity: 1; transform: translate(-50%, 0); }

/* login */
.login { min-height: 80dvh; display: flex; flex-direction: column; justify-content: center; gap: 14px; max-width: 340px; margin: 0 auto; }
.login .mark { width: 56px; height: 56px; }
.err { color: var(--red); font-size: 14px; min-height: 20px; }

/* service icons */
.ic.svc { position: relative; overflow: hidden; background: hsl(var(--h) 55% 90%); color: hsl(var(--h) 50% 28%); }
.ic.svc b { font: 700 17px/1 var(--display); font-variation-settings: 'wdth' 90; }
.ic.svc img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; background: #fff; padding: 5px; border-radius: inherit; box-shadow: inset 0 0 0 1px rgba(18, 48, 58, .08); }
.ic.svc.sm { width: 32px; height: 32px; border-radius: 10px; flex: none; display: grid; place-items: center; }
.ic.svc.sm b { font-size: 15px; }
.tx.pending .ic.svc { box-shadow: inset 0 0 0 1.5px var(--h3); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .ic.svc { background: hsl(var(--h) 35% 22%); color: hsl(var(--h) 70% 82%); } }
:root[data-theme="dark"] .ic.svc { background: hsl(var(--h) 35% 22%); color: hsl(var(--h) 70% 82%); }

/* ---------- layout pieces shared by both modes ---------- */
.tabs .brand, .add-btn span, .add-btn kbd { display: none; }
.col-b > h2:first-child { margin-top: 34px; }

/* ---------- desktop: side panel + two columns ---------- */
@media (min-width: 900px) {
  :root { --side: 232px; }
  body { padding-left: var(--side); }

  .tabs {
    top: 0; bottom: 0; left: 0; right: auto; width: var(--side); height: auto;
    flex-direction: column; justify-content: flex-start; align-items: stretch; gap: 2px;
    padding: 22px 14px; border-top: 0; border-right: 1px solid var(--line);
    background: var(--bg); backdrop-filter: none; -webkit-backdrop-filter: none;
  }
  .tabs .brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 22px; width: auto; flex-direction: row;
    font: 700 21px/1 var(--display); font-variation-settings: 'wdth' 85; letter-spacing: -0.01em; color: var(--ink); }
  .tabs .brand img { width: 30px; height: 30px; border-radius: 8px; }
  .tabs a:not(.brand) { flex-direction: row; justify-content: flex-start; gap: 12px; width: auto; padding: 10px 12px;
    border-radius: 10px; font-size: 15px; font-weight: 500; color: var(--ink-2); }
  .tabs a:not(.brand):hover { background: var(--sunk); color: var(--ink); }
  .tabs a.on { background: var(--surface); color: var(--ink); box-shadow: inset 0 0 0 1px var(--line); }
  .tabs a svg { width: 20px; height: 20px; }

  /* the add button leads the panel */
  .add-btn { order: -1; transform: none; width: 100%; height: 44px; border-radius: 12px; margin: 0 0 18px;
    display: flex; align-items: center; gap: 10px; padding: 0 12px 0 14px; box-shadow: none; font-weight: 600; font-size: 15px; }
  .tabs .brand { order: -2; }
  .add-btn:active { transform: scale(.98); }
  .add-btn svg { width: 18px; height: 18px; }
  .add-btn span { display: inline; flex: 1; text-align: left; }
  .add-btn kbd { display: inline-block; font: 600 11.5px var(--ui); padding: 2px 7px; border-radius: 6px;
    background: color-mix(in srgb, var(--bg) 18%, transparent); color: var(--bg); }

  main { max-width: 1180px; margin: 0; padding: 40px 48px 64px; }
  .cols { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 0 64px; align-items: start; }
  .col-b > h2:first-child { margin-top: 0; }
  .narrow { max-width: 760px; }

  .fig-xl { font-size: 72px; }
  .forecast { font-size: 17.5px; max-width: 44ch; }
  .grid { gap: 3px; }
  .grid .ml { font-size: 11.5px; }
  .filters { margin: 0; padding-left: 0; padding-right: 0; flex-wrap: wrap; overflow: visible; }

  /* rows react to the pointer on desktop */
  .tx, .list-row, .cat-row { border-radius: 10px; transition: background .12s; }
  /* dividers drawn as straight inset lines so rounded hover corners don't bend them */
  .tx, .list-row { border-bottom: 0; box-shadow: inset 0 -1px 0 var(--line); }
  .tx:last-child, .list-row:last-child { box-shadow: none; }
  .tx:hover, .list-row[data-acct]:hover, .list-row[data-budget]:hover { box-shadow: none; }
  .tx:hover, .list-row[data-acct]:hover, .list-row[data-budget]:hover, .cat-row:hover { background: var(--sunk); }
  .tx, .list-row[data-acct], .list-row[data-budget] { padding-left: 8px; padding-right: 8px; margin: 0 -8px; width: calc(100% + 16px); }
  .grid .d:hover:not(.f):not(.x) { outline: 1.5px solid var(--ink-2); outline-offset: 1px; }

  /* sheets become centred dialogs */
  .sheet { top: 50%; bottom: auto; left: 50%; right: auto; width: min(560px, calc(100vw - 64px)); max-height: 86vh;
    border-radius: var(--r-l); padding: 22px 26px 24px; transform: translate(-50%, calc(-50% + 16px)) ; opacity: 0;
    transition: transform .2s cubic-bezier(.2,.8,.2,1), opacity .2s; box-shadow: 0 24px 60px -20px rgba(8, 20, 24, .45); }
  .sheet.open { transform: translate(-50%, -50%); opacity: 1; }
  .sheet .grab { display: none; }
  .sheet { padding-bottom: 0; }
  .sheet-actions { position: sticky; bottom: 0; background: var(--surface); margin: 22px -26px 0; padding: 14px 26px 22px;
    box-shadow: 0 -1px 0 var(--line); }

  #toast { bottom: 28px; left: calc(50% + var(--side) / 2); }
}

@media (min-width: 1400px) {
  main { padding-left: 64px; padding-right: 64px; }
}

/* =========================================================
   v2 screens: dashboard, month, categories, history, entry
   ========================================================= */
:root { --tile: var(--surface); --r-t: 18px; --e-bar: var(--h4); --i-bar: var(--teal); }
.round-btn { width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center; border: 1px solid var(--line);
  background: var(--surface); color: var(--ink); cursor: pointer; text-decoration: none; flex: none; padding: 0; }
.round-btn svg { width: 20px; height: 20px; }
.round-btn.on { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.round-btn.off { opacity: .3; pointer-events: none; }
.text-btn { background: none; border: 0; color: var(--ink-2); font-weight: 500; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; padding: 6px 2px; }
.text-btn svg { width: 16px; height: 16px; }
.soft-btn { display: inline-flex; align-items: center; gap: 8px; border: 0; background: var(--sunk); border-radius: 16px; padding: 14px 18px; font-weight: 600; font-size: 15.5px; cursor: pointer; margin-top: 12px; }
.soft-btn svg { width: 18px; height: 18px; }
.panel { background: var(--tile); border-radius: var(--r-t); padding: 16px; border: 1px solid var(--line); }
.mono-sub { margin: 2px 0 0; color: var(--ink-3); font-size: 13.5px; font-variant-numeric: tabular-nums; }
.h-ic { display: flex; align-items: center; gap: 6px; margin: 0; }
.h-ic svg { width: 19px; height: 19px; stroke-width: 2; }
.sec-h { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 10px; }
.sec-h h2 { margin: 0; }
.page-top { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 14px; }
.page-title { font: 700 clamp(34px, 9vw, 44px)/1.05 var(--display); font-variation-settings: 'wdth' 88; letter-spacing: -0.025em; color: var(--ink); margin: 6px 0 4px; }
.page-sub { margin: 0 0 6px; }
.month-nav { display: flex; gap: 6px; align-items: center; }
.icon-btn:disabled { opacity: .3; }

/* stat tiles */
.tiles { display: grid; gap: 10px; margin: 16px 0 6px; }
.tiles.quad { grid-template-columns: 1fr 1fr; }
.tiles.strip { grid-auto-flow: column; grid-auto-columns: minmax(132px, 1fr); overflow-x: auto; scrollbar-width: none; margin-left: -16px; margin-right: -16px; padding: 0 16px 4px; }
.tiles.strip::-webkit-scrollbar { display: none; }
.tile { background: var(--tile); border: 1px solid var(--line); border-radius: var(--r-t); padding: 13px 15px 14px; display: flex; flex-direction: column; gap: 6px; text-decoration: none; color: inherit; min-width: 0; }
.t-label { font-size: 13.5px; color: var(--ink-3); }
.t-val { font: 700 clamp(19px, 5.6vw, 24px)/1.05 var(--display); font-variation-settings: 'wdth' 85; letter-spacing: -0.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.t-val small { font: 600 11px var(--ui); color: var(--ink-3); margin-right: 4px; vertical-align: 0.5em; letter-spacing: 0; }
.t-val.pos { color: var(--teal); }
a.tile:active { transform: scale(.98); }

/* dashboard */
.dash-top { display: flex; justify-content: space-between; align-items: center; }
.acct-pill { display: inline-flex; align-items: center; gap: 8px; border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 8px 12px 8px 9px; font-weight: 500; font-size: 15px; cursor: pointer; }
.acct-pill .pill-ic { width: 26px; height: 26px; border-radius: 50%; background: var(--sunk); display: grid; place-items: center; font-size: 15px; }
.acct-pill > svg { width: 16px; height: 16px; color: var(--ink-3); }
.balance { font: 700 clamp(42px, 12.5vw, 60px)/1 var(--display); font-variation-settings: 'wdth' 82; letter-spacing: -0.03em; margin: 18px 0 8px; white-space: nowrap; }
.balance .cur { font: 600 15px var(--ui); color: var(--ink-3); margin-right: 8px; vertical-align: 0.95em; letter-spacing: 0; }
.bal-date { display: flex; align-items: center; gap: 7px; color: var(--ink-3); font-size: 14px; }
.bal-date svg { width: 16px; height: 16px; }
.review { justify-content: flex-start; }
.review > svg { width: 18px; height: 18px; margin-left: auto; color: var(--ink-3); }
.week-panel { margin-top: 20px; }
.week-read, .day-read { text-align: right; display: flex; flex-direction: column; align-items: flex-end; min-height: 40px; }
.week-read b, .day-read b { font: 700 20px/1.1 var(--display); font-variation-settings: 'wdth' 85; color: var(--e-bar); }
.week-read b small, .day-read b small { font: 600 11px var(--ui); color: var(--ink-3); }
.week-read span, .day-read span { font-size: 12.5px; color: var(--ink-3); }
.wk { display: flex; gap: 8px; height: 190px; }
.wk-bars { flex: 1; display: grid; grid-template-columns: repeat(7, 1fr); gap: 8px; }
.wk-slot { display: flex; flex-direction: column; align-items: center; gap: 6px; border: 0; background: none; padding: 0; cursor: pointer; min-width: 0; }
.wk-col { position: relative; flex: 1; width: 100%; max-width: 46px; }
.wk-col i { position: absolute; left: 0; right: 0; bottom: 0; border-radius: 9px; min-height: 0; transition: height .35s cubic-bezier(.2, .8, .2, 1); }
.wk-prev { background: var(--line); }
.wk-cur { background: var(--h2); left: 18% !important; right: 18% !important; }
.wk-slot.today .wk-cur, .wk-slot.sel .wk-cur { background: var(--e-bar); }
.wk-slot.sel .wk-lab { color: var(--ink); font-weight: 700; }
.wk-lab { font-size: 12.5px; color: var(--ink-3); }
.wk-slot.future .wk-lab { opacity: .5; }
.wk-axis { display: flex; flex-direction: column; justify-content: space-between; font-size: 11px; color: var(--ink-3); padding-bottom: 24px; text-align: right; min-width: 30px; }
.legend { display: flex; gap: 18px; margin-top: 12px; font-size: 13px; color: var(--ink-3); }
.legend i { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 6px; }
.lg-prev { background: var(--line); } .lg-cur { background: var(--e-bar); }
.row-h { margin: 28px 0 0; }
.row-h a { text-decoration: none; }
.duo { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 20px; }
.nav-card { display: flex; flex-direction: column; gap: 4px; text-decoration: none; color: inherit; min-height: 150px; overflow: hidden; position: relative; }
.nc-h { display: flex; justify-content: space-between; align-items: center; color: var(--ink-2); font-weight: 600; margin-bottom: 6px; }
.nc-h svg { width: 18px; height: 18px; }
.nc-big { font: 700 34px/1 var(--display); font-variation-settings: 'wdth' 85; }
.nc-sub { font-size: 13.5px; color: var(--ink-3); }
.nc-cat { display: flex; gap: 9px; align-items: center; margin-top: 4px; min-width: 0; }
.nc-cat .e { font-size: 22px; width: 28px; text-align: center; flex: none; }
.nc-cat b { display: block; font-weight: 600; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nc-cat small { font-size: 12.5px; color: var(--ink-3); }
.nc-cat > span:last-child { min-width: 0; }
.spark { position: absolute; left: 0; right: 0; bottom: 0; width: 100%; height: 46px; }
.sp-fill { fill: color-mix(in srgb, var(--e-bar) 16%, transparent); stroke: none; }
.sp-line { fill: none; stroke: var(--e-bar); stroke-width: 1.6; vector-effect: non-scaling-stroke; }
.year-sec { margin-top: 30px; }
.grid-panel .grid { margin-top: 0; }
.months { margin-top: 14px; background: var(--tile); border: 1px solid var(--line); border-radius: var(--r-t); overflow: hidden; }
.month-row { display: flex; align-items: center; gap: 10px; padding: 15px 16px; text-decoration: none; color: inherit; border-bottom: 1px solid var(--line); font-weight: 500; }
.month-row:last-child { border-bottom: 0; }
.month-row > span:first-child { flex: 1; }
.mr-val { font: 600 16px var(--ui); font-variant-numeric: tabular-nums; }
.mr-val small { font-size: 11px; color: var(--ink-3); margin-left: 4px; font-weight: 500; }
.month-row > svg { width: 16px; height: 16px; color: var(--ink-3); }

/* month page: day bars */
.two-charts { display: grid; gap: 14px; margin-top: 18px; }
.db { display: flex; gap: 8px; position: relative; }
.db-main { flex: 1; min-width: 0; }
.db-bars { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 3px; height: 150px; }
.db-slot { border: 0; background: none; padding: 0; cursor: pointer; display: flex; min-width: 0; }
.db-track { flex: 1; background: var(--sunk); border-radius: 6px; position: relative; overflow: hidden; }
.db-track i { position: absolute; left: 0; right: 0; bottom: 0; border-radius: 6px; background: var(--e-bar); }
.db-i .db-track i { background: var(--i-bar); }
.db-slot.future .db-track { opacity: .45; }
.db-slot.today .db-track { box-shadow: inset 0 0 0 1.5px var(--ink-3); }
.db-slot.sel .db-track { box-shadow: inset 0 0 0 2px var(--ink); }
.db-labs { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 3px; margin-top: 8px; font-size: 11px; color: var(--ink-3); text-align: center; }
.db-axis { display: flex; flex-direction: column; justify-content: space-between; font-size: 11px; color: var(--ink-3); height: 150px; min-width: 32px; text-align: right; }
.db.empty .db-main, .db.empty .db-axis { filter: blur(2px); opacity: .5; }
.db-empty { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; }
.db-empty b { font-weight: 600; }
.month-budget { margin-top: 30px; }
.month-budget .panel { margin-top: 12px; padding-top: 4px; padding-bottom: 4px; }
.link-row { display: flex; align-items: center; gap: 12px; margin-top: 18px; text-decoration: none; color: inherit; }
.link-row > svg { width: 20px; height: 20px; color: var(--ink-3); flex: none; }
.link-row b { display: block; font-weight: 600; } .link-row small { color: var(--ink-3); font-size: 13.5px; }

/* categories */
.period-pill { position: relative; display: inline-flex; align-items: center; border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 0 12px 0 0; }
.period-pill select { appearance: none; border: 0; background: none; padding: 10px 6px 10px 16px; font-weight: 500; font-size: 15px; cursor: pointer; }
.period-pill svg { width: 16px; height: 16px; pointer-events: none; color: var(--ink-3); }
.donut-wrap { display: flex; flex-direction: column; align-items: center; margin: 18px 0 8px; }
.donut { width: min(280px, 78vw); height: auto; }
.donut circle { transition: stroke-dasharray .4s; }
.dn-total { font: 700 21px var(--display); font-variation-settings: 'wdth' 85; fill: var(--ink); }
.dn-label { font: 500 11px var(--ui); fill: var(--ink-3); }
.dn-note { color: var(--ink-2); font-size: 14.5px; margin: 10px 0 0; text-align: center; }
.seg.small button { padding: 6px 12px; font-size: 13.5px; }
.cat-list { display: flex; flex-direction: column; gap: 8px; }
.cat-item { display: flex; align-items: center; gap: 12px; border: 1px solid var(--line); background: var(--tile); border-radius: 16px; padding: 12px 16px; text-align: left; cursor: pointer; width: 100%; }
.cat-item .dot { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.cat-item .e { font-size: 22px; width: 28px; text-align: center; }
.cat-item .grow { flex: 1; font-weight: 500; }
.cat-item small { display: block; font-size: 12.5px; color: var(--ink-3); font-weight: 400; }
.cat-item b { font-variant-numeric: tabular-nums; }

/* history */
.filter-box { margin: 10px 0 6px; }
.day-group { margin-top: 20px; }
.day-group .day-h { font-size: 15px; color: var(--ink-2); font-weight: 500; margin: 0 4px 8px; }
.day-group .day-h span:last-child { font-variant-numeric: tabular-nums; color: var(--ink-3); }
.tx-card { display: flex; align-items: center; gap: 13px; width: 100%; padding: 13px 16px; background: var(--tile); border: 1px solid var(--line); border-radius: 16px; text-align: left; cursor: pointer; margin-bottom: 8px; }
.tx-card .ic { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; font-size: 22px; flex: none; background: var(--sunk); }
.tx-card .mid { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.amt-line { font-weight: 600; font-size: 16px; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.amt-line small { font-weight: 400; color: var(--ink-3); font-size: 12.5px; }
.amt-line.pos { color: var(--teal); }
.sub-line { font-size: 13.5px; color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tx-card .time { font-size: 13px; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.tx-card.pending { border-style: dashed; border-color: var(--h3); }
.tx-card.pending .ic { background: transparent; box-shadow: inset 0 0 0 1.5px var(--h3); }

/* pickers shared */
.sheet-h.center { display: grid; grid-template-columns: 42px 1fr 42px; text-align: center; }
.pick-list { display: flex; flex-direction: column; gap: 8px; }
.pick-row { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 16px; border: 1px solid var(--line); background: var(--bg); text-align: left; cursor: pointer; width: 100%; }
.pick-row.on { background: var(--sunk); border-color: transparent; }
.pick-row .pk-check { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; flex: none; box-shadow: inset 0 0 0 1.5px var(--line); }
.pick-row.on .pk-check { background: var(--ink); color: var(--bg); box-shadow: none; }
.pick-row .pk-check svg { width: 16px; height: 16px; stroke-width: 2.4; }
.pick-row .e { font-size: 22px; width: 30px; text-align: center; }
.pick-row b { display: block; font-weight: 600; } .pick-row small { color: var(--ink-3); font-variant-numeric: tabular-nums; }
.pick-list + .text-btn { margin-top: 14px; font-size: 16px; color: var(--ink); }

/* entry sheet */
.sheet .sheet-h { margin-bottom: 4px; }
.pager { display: inline-flex; gap: 6px; background: var(--sunk); padding: 8px 10px; border-radius: 999px; }
.pager button { width: 9px; height: 9px; padding: 0; border-radius: 50%; border: 0; background: var(--ink-3); opacity: .45; cursor: pointer; }
.pager button.on { opacity: 1; background: var(--ink); }
.amount-line { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.amount-line.big { margin: 16px 0 14px; }
.amount-line .amount-in { width: auto; min-width: 1ch; field-sizing: content; max-width: 100%; font-size: 52px; }
.amount-line.big .amount-in { font-size: 60px; }
.amount-line .cc { font: 600 20px var(--ui); color: var(--ink-3); }
.chips-row { display: flex; gap: 8px; flex-wrap: wrap; margin: 4px 0 10px; }
.chip-btn { display: inline-flex; align-items: center; gap: 7px; border: 0; background: var(--sunk); border-radius: 999px; padding: 9px 14px; font-weight: 500; font-size: 15px; cursor: pointer; }
.chip-btn svg { width: 17px; height: 17px; }
.chip-btn.type-expense svg { color: var(--red); } .chip-btn.type-income svg { color: var(--teal); }
.chip-btn.ghost { background: none; box-shadow: inset 0 0 0 1px var(--line); color: var(--ink-2); }
.sr-date { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.note-add { color: var(--ink-3); }
.note-in { width: 100%; border: 0; border-bottom: 1px solid var(--line); background: none; padding: 10px 2px; font-size: 16px; outline: none; }
.cat-pick { display: flex; align-items: center; gap: 14px; width: 100%; margin-top: 16px; padding: 14px 16px; border-radius: 18px; border: 0; background: var(--sunk); text-align: left; cursor: pointer; }
.cat-pick .cp-ic { width: 40px; height: 40px; display: grid; place-items: center; font-size: 24px; }
.cat-pick .cp-ic svg { width: 28px; height: 28px; color: var(--ink-2); }
.cat-pick b { display: block; font-weight: 600; font-size: 16px; } .cat-pick small { color: var(--ink-3); }
.cat-pick > svg { width: 18px; height: 18px; color: var(--ink-3); }
.picker { margin-top: 12px; padding: 14px; border-radius: 18px; background: var(--bg); border: 1px solid var(--line); }
.pk-h { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.xfer { margin-top: 8px; }
.xf-row { display: flex; justify-content: space-between; color: var(--ink-3); font-size: 14.5px; margin-top: 8px; }
.xf-bal { font-variant-numeric: tabular-nums; }
.xf-line { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 6px 0 10px; }
.xf-line .amount-in { font-size: 44px; }
.acct-chip { display: inline-flex; align-items: center; gap: 7px; border: 0; background: var(--sunk); border-radius: 999px; padding: 10px 14px; font-weight: 500; font-size: 15px; cursor: pointer; white-space: nowrap; flex: none; }
.acct-chip svg { width: 15px; height: 15px; color: var(--ink-3); }
.xf-sep { position: relative; height: 1px; background: var(--line); margin: 10px -18px; }
.swap { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--line); background: var(--surface); display: grid; place-items: center; cursor: pointer; }
.swap svg { width: 18px; height: 18px; }
.amount-in.recv:disabled { opacity: .4; }

/* desktop refinements for v2 */
@media (min-width: 900px) {
  .tiles.strip { grid-auto-flow: row; grid-template-columns: repeat(4, 1fr); overflow: visible; margin-left: 0; margin-right: 0; padding: 0; }
  .tiles.quad { grid-template-columns: repeat(4, 1fr); }
  .page { max-width: 1040px; }
  .hist-page { max-width: 760px; }
  .two-charts { grid-template-columns: 1fr 1fr; }
  .cat-layout { display: grid; grid-template-columns: 340px 1fr; gap: 48px; align-items: start; }
  .donut { width: 300px; }
  .dash .col-b .duo { margin-top: 0; }
  .wk { height: 220px; }
  .tx-card:hover, .cat-item:hover, .month-row:hover, .pick-row:hover { background: var(--sunk); }
  a.tile:hover, .nav-card:hover, .link-row:hover { border-color: var(--ink-3); }
}
.donut text { stroke: none; }
.donut circle { stroke-linecap: butt; }
@media (min-width: 900px) {
  .dash .tiles.strip { grid-template-columns: 1fr 1fr; }
}
