/* Budget — Apple-style, mobile-first */
:root {
  /* iOS system colors (systemGroupedBackground, label, secondaryLabel, separator…) */
  --bg: #f2f2f7;
  --card: #ffffff;
  --fill: rgba(118, 118, 128, .12);
  --fill-2: rgba(118, 118, 128, .08);
  --text: #000;
  --muted: rgba(60, 60, 67, .6);
  --sep: rgba(60, 60, 67, .29);
  --blue: #007aff;
  --green: #248a3d;
  --red: #ff3b30;
  --shadow: none;
  --bar: rgba(249, 249, 249, .8);
  --radius: 12px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --tabbar: calc(56px + var(--safe-b));
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000; --card: #1c1c1e; --fill: rgba(118, 118, 128, .24); --fill-2: rgba(118, 118, 128, .16);
    --text: #fff; --muted: rgba(235, 235, 245, .6); --sep: rgba(84, 84, 88, .6); --blue: #0a84ff;
    --green: #30d158; --red: #ff453a; --shadow: none; --bar: rgba(22, 22, 23, .8);
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; background: var(--bg); }
/* Feel like an app, not a web page: no text selection, link previews or double-tap zoom on UI */
body { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
input, textarea, select { -webkit-user-select: text; user-select: text; }
a, button, label { touch-action: manipulation; }
@view-transition { navigation: auto; }
::view-transition-old(root), ::view-transition-new(root) { animation-duration: .18s; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 17px/1.3 -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "Helvetica Neue", Inter, system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  padding-bottom: calc(var(--tabbar) + 24px);
}
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
input, select { font: inherit; color: inherit; font-size: 17px; }
h1, h2, h3, p { margin: 0; }
h1 { font-size: 34px; font-weight: 700; line-height: 1.2; }
h2 { font-size: 20px; font-weight: 600; }
.card-head h2 { font-size: 17px; }
.muted { color: var(--muted); }
.neg { color: var(--red); }
.pos { color: var(--green); }
[hidden] { display: none !important; }

/* ---------- Top bar & tab bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  border-bottom: .5px solid var(--sep); padding-top: env(safe-area-inset-top, 0px);
}
/* blur lives on a pseudo-element so the fixed tab bar inside isn't trapped by backdrop-filter */
.topbar::before { content: ""; position: absolute; inset: 0; z-index: -1; background: var(--bar); -webkit-backdrop-filter: saturate(180%) blur(20px); backdrop-filter: saturate(180%) blur(20px); }
.topbar-inner { max-width: 1180px; margin: 0 auto; height: 48px; padding: 0 max(16px, env(safe-area-inset-left)); display: flex; align-items: center; gap: 16px; }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 17px; }
.brand .logo { width: 26px; height: 26px; border-radius: 7px; }
.avatar { flex: none; width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; font-size: 14px; font-weight: 600; color: #fff; background: linear-gradient(180deg, #a5a5aa, #85858b); }
.avatar.lg { width: 60px; height: 60px; font-size: 24px; }
.btn-add { margin-left: auto; width: 34px; height: 34px; border-radius: 50%; background: var(--blue); color: #fff; display: grid; place-items: center; }
.btn-add svg { width: 18px; height: 18px; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; fill: none; }
.btn-add span { display: none; }

.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; height: var(--tabbar); padding-bottom: var(--safe-b);
  display: flex; background: var(--bar); -webkit-backdrop-filter: saturate(180%) blur(20px); backdrop-filter: saturate(180%) blur(20px);
  border-top: .5px solid var(--sep);
}
.tabs a { flex: 1; font-weight: 500; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; font-size: 10px; color: var(--muted); }
.tabs a.on { color: var(--blue); }
.tabs svg { width: 25px; height: 25px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* Large title with its toolbar row (add + profile live here on phones; the desktop top bar has them) */
.toolbar { display: flex; align-items: center; justify-content: flex-end; gap: 6px; min-height: 0; }
.tool-btn { flex: none; width: 44px; height: 44px; margin-right: -6px; display: grid; place-items: center; color: var(--blue); }
.tool-btn svg { width: 22px; height: 22px; stroke: currentColor; stroke-width: 2; stroke-linecap: round; fill: none; }
.tool-btn:active, .avatar:active { opacity: .5; }
.large-title h1 { margin-top: 0; }
.nav-title { display: none; }

/* Phones: no web header. A compact title bar fades in only once the large title scrolls away, like UINavigationBar. */
@media (max-width: 759px) {
  body { padding-top: env(safe-area-inset-top, 0px); }
  .topbar { position: fixed; left: 0; right: 0; top: 0; pointer-events: none; border-bottom-color: transparent; transition: border-color .2s; }
  .topbar::before { opacity: 0; transition: opacity .2s; }
  .topbar-inner { height: 44px; justify-content: center; }
  .topbar .brand, .topbar .btn-add, .topbar > .topbar-inner > .avatar { display: none; }
  .nav-title { display: block; font-size: 17px; font-weight: 600; opacity: 0; transform: translateY(4px); transition: opacity .2s, transform .2s; max-width: 70%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .scrolled .topbar { pointer-events: auto; border-bottom-color: var(--sep); }
  .scrolled .topbar::before, .scrolled .nav-title { opacity: 1; transform: none; }
  .tabs { pointer-events: auto; view-transition-name: tabbar; }
  .tabs a:active { opacity: .6; }
  .toolbar { margin-right: -6px; }
  .page-head { padding-top: 4px; }
}

/* ---------- Page ---------- */
.wrap { max-width: 1180px; margin: 0 auto; padding: 0 max(16px, env(safe-area-inset-left)) 0 max(16px, env(safe-area-inset-right)); }
.page-head { display: flex; flex-direction: column; gap: 6px; padding: 18px 0 16px; }
.page-head > .btn-primary { align-self: flex-start; }

.card { background: var(--card); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); min-width: 0; }
.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.card-head .muted { font-size: 13px; }
.grid { display: grid; gap: 12px; margin-bottom: 12px; }
.stack { display: grid; gap: 12px; align-content: start; min-width: 0; }
section.card { margin-bottom: 12px; }
.label { font-size: 15px; color: var(--muted); }
.link { color: var(--blue); font-size: 15px; }
.link:active { opacity: .5; }
.link.strong { font-weight: 600; }
.empty { text-align: center; padding: 36px 20px; display: grid; gap: 8px; justify-items: center; margin-bottom: 12px; }
.empty p { color: var(--muted); }
.empty .btn-primary { margin-top: 8px; }
.empty-note { color: var(--muted); font-size: 15px; padding: 18px 0; text-align: center; }

/* ---------- Buttons ---------- */
.btn-primary { display: inline-flex; align-items: center; justify-content: center; background: var(--blue); color: #fff; border-radius: 980px; padding: 8px 18px; font-size: 15px; font-weight: 600; min-height: 36px; }
.btn-primary.sm { padding: 6px 14px; min-height: 32px; font-size: 14px; }
.btn-primary:active { opacity: .8; }
.block { display: flex; width: 100%; border-radius: var(--radius); min-height: 50px; font-size: 17px; font-weight: 600; margin-top: 18px; }
.btn-danger { color: var(--red); background: var(--fill-2); justify-content: center; align-items: center; }
.btn-danger.block { margin-top: 10px; font-weight: 400; }

/* ---------- Period menu (pop-up button; the real <select> sits on top, invisible, so iOS shows its native picker) ---------- */
.period { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; min-width: 0; }
.menu-btn { position: relative; display: inline-flex; align-items: center; gap: 2px; color: var(--blue); font-size: 17px; }
.menu-btn select { position: absolute; inset: 0; width: 100%; opacity: 0; font-size: 16px; cursor: pointer; }
.menu-btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.menu-btn:active { opacity: .5; }
.range { font-size: 15px; color: var(--muted); }
.custom-range { flex-basis: 100%; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 6px; }
.custom-range input { background: var(--card); border: 0; border-radius: 10px; padding: 7px 10px; font-size: 16px; min-width: 0; flex: 1 1 130px; }
.custom-range span { color: var(--muted); font-size: 15px; }

/* ---------- Hero / stats ---------- */
.hero { grid-template-columns: minmax(0, 1fr); }
.card.balance { position: relative; overflow: hidden; padding-bottom: 60px; }
.big { font-size: 34px; font-weight: 700; line-height: 1.2; margin: 2px 0; font-variant-numeric: tabular-nums; }
.balance .muted { font-size: 15px; }
.spark { position: absolute; left: 16px; right: 16px; bottom: 14px; width: calc(100% - 32px); height: 36px; color: var(--green); }
.spark.down { color: var(--red); }
.stats .row { padding-top: 11px; padding-bottom: 11px; }
.stats small { display: block; font-size: 13px; color: var(--muted); }
.stats .val, .tx-amt, .summary-row strong { font-variant-numeric: tabular-nums; white-space: nowrap; }
.delta.good { color: var(--green); }
.delta.bad { color: var(--red); }
.narrow { max-width: 640px; }
.narrow .card.balance { padding-bottom: 16px; margin-bottom: 24px; }

/* ---------- Donut + legend ---------- */
.two { grid-template-columns: minmax(0, 1fr); }
.donut-wrap { position: relative; width: min(180px, 55vw); margin: 4px auto 16px; }
.donut { width: 100%; display: block; }
.donut circle { transition: opacity .2s, stroke-width .2s; cursor: pointer; }
.donut.focus circle:not(.hl) { opacity: .25; }
.donut-center { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; pointer-events: none; }
.donut-center span { font-size: 15px; max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.donut-center strong { font-size: 20px; font-weight: 600; font-variant-numeric: tabular-nums; }
.legend { list-style: none; margin: 0; padding: 0; }
.legend a { display: flex; align-items: center; gap: 12px; padding: 8px 4px; border-radius: 12px; transition: background .15s; }
.legend a:hover, .legend a.hl { background: var(--fill-2); }
.lg-main { flex: 1; min-width: 0; display: grid; gap: 5px; }
.lg-top, .lg-sub { display: flex; justify-content: space-between; gap: 8px; }
.lg-top { font-size: 17px; }
.lg-top span:last-child { font-variant-numeric: tabular-nums; }
.lg-sub { font-size: 12px; color: var(--muted); }
.meter { height: 4px; background: var(--fill-2); border-radius: 3px; overflow: hidden; }
.meter i { display: block; height: 100%; border-radius: 3px; }

/* ---------- Icon tiles ---------- */
.ic {
  --c: #8E8E93; flex: none; width: 32px; height: 32px; border-radius: 8px; display: grid; place-items: center; font-size: 17px; font-weight: 600; color: var(--c);
  background: color-mix(in srgb, var(--c) 16%, transparent);
}
.ic.sm { width: 30px; height: 30px; border-radius: 7px; font-size: 15px; }
.acct .ic, .ic.solid { background: var(--c); color: #fff; }

/* ---------- Bar chart ---------- */
.bars-wrap { position: relative; height: 200px; margin: 6px 0 4px; }
.bars-grid { position: absolute; inset: 0 0 22px 0; pointer-events: none; }
.gl { position: absolute; left: 0; right: 0; border-top: .5px solid var(--sep); }
.gl span { position: absolute; right: 0; top: -8px; transform: translateY(-50%); font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
.gl:first-child span { top: 8px; }
.avg { position: absolute; left: 0; right: 34px; border-top: 1px dashed var(--muted); }
.avg span { position: absolute; left: 0; top: -15px; background: var(--card); padding: 0 3px 0 0; line-height: 1; font-size: 11px; color: var(--muted); }
.bars { position: absolute; inset: 0 34px 0 0; display: flex; gap: 2px; }
.bar-col { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; padding-bottom: 22px; position: relative; cursor: pointer; }
.bar { width: min(78%, 26px); display: flex; flex-direction: column-reverse; border-radius: 4px 4px 1.5px 1.5px; overflow: hidden; transition: opacity .15s, filter .15s; min-height: 0; }
.bar i { display: block; min-height: 1px; }
.bar-col.on .bar, .bar-col:hover .bar { filter: brightness(1.08) saturate(1.1); }
.bars:hover .bar-col:not(:hover) .bar { opacity: .55; }
.xl { position: absolute; bottom: 0; font-size: 11px; color: var(--muted); white-space: nowrap; height: 16px; }

.tip {
  position: fixed; z-index: 50; pointer-events: none; min-width: 170px; max-width: 240px;
  background: var(--card); border-radius: 12px; padding: 10px 12px; font-size: 13px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, .18), 0 0 0 .5px var(--sep);
}
.tip b { display: block; font-size: 12px; color: var(--muted); font-weight: 400; }
.tip strong { display: block; font-size: 17px; margin-bottom: 4px; }
.tip div { display: flex; align-items: center; gap: 6px; padding: 1px 0; }
.tip div i { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.tip div span:last-child { margin-left: auto; font-variant-numeric: tabular-nums; }

/* ---------- Lists ---------- */
.list { display: grid; }
.tx, .acct { display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; padding: 8px 0; min-height: 52px; border-radius: 10px; }
.tx:active, .acct:active { background: var(--fill-2); }
.tx-main { flex: 1; min-width: 0; display: grid; }
.tx-title { font-size: 17px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tx-sub { font-size: 15px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tx-amt { font-size: 17px; }
.tx-amt.income { color: var(--green); }
.tx-amt.transfer { color: var(--muted); }
.list.flush { padding: 0 16px; }
.list.flush > * + *, .list.rows > * + * { border-top: .5px solid var(--sep); border-radius: 0; }

.day { margin-bottom: 18px; }
.day h3 { display: flex; justify-content: space-between; font-size: 13px; font-weight: 400; color: var(--muted); text-transform: uppercase; padding: 0 16px 6px; }
.day h3 span:last-child { text-transform: none; font-variant-numeric: tabular-nums; }

.filters { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; margin-bottom: 14px; align-items: center; }
.filters .search { grid-column: 1 / -1; display: flex; align-items: center; gap: 6px; background: var(--fill); border-radius: 10px; padding: 0 8px; height: 36px; }
.filters .search svg { width: 17px; height: 17px; flex: none; fill: none; stroke: var(--muted); stroke-width: 2; stroke-linecap: round; }
.filters .search input { border: 0; background: none; outline: 0; flex: 1; min-width: 0; font-size: 17px; }
.filters select { appearance: none; -webkit-appearance: none; border: 0; background: var(--fill); border-radius: 10px; height: 32px; padding: 0 10px; font-size: 15px; min-width: 0; text-overflow: ellipsis; }
.filters .link { grid-column: 1 / -1; text-align: center; }

.summary-row { display: grid; grid-template-columns: repeat(3, 1fr); background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 12px 0; margin-bottom: 20px; }
.summary-row div { display: grid; text-align: center; padding: 0 6px; min-width: 0; }
.summary-row div + div { border-left: .5px solid var(--sep); }
.summary-row .label { font-size: 13px; }
.summary-row strong { font-size: 17px; font-weight: 400; font-variant-numeric: tabular-nums; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- Accounts ---------- */
.row.acct-row { min-height: 60px; padding-top: 8px; padding-bottom: 8px; }
.group .acct-row + .row::before { left: 58px; }
.acct-row .tx-amt { margin-left: auto; }
.group.archived { opacity: .6; }

/* ---------- Grouped form rows (iOS Settings style) ---------- */
.group { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.group + .group { margin-top: 18px; }
.group-title { font-size: 13px; font-weight: 400; color: var(--muted); text-transform: uppercase; padding: 22px 16px 7px; }
.row { display: flex; align-items: center; gap: 12px; min-height: 44px; padding: 0 16px; width: 100%; text-align: left; position: relative; }
.row + .row::before { content: ""; position: absolute; top: 0; left: 16px; right: 0; border-top: .5px solid var(--sep); }
.row > span:first-child { flex: none; }
.row input:not([type=checkbox]):not([type=radio]), .row select {
  flex: 1; min-width: 0; border: 0; background: none; outline: 0; text-align: right; color: var(--muted); padding: 12px 0;
  font-size: 17px; appearance: none; -webkit-appearance: none;
}
.row input:focus { color: var(--text); }
.row input[type=date] { display: flex; justify-content: flex-end; min-height: 44px; }
.row input[type=date]::-webkit-date-and-time-value { text-align: right; }
.row select { text-align-last: right; direction: rtl; padding-right: 0; }
.row select option { direction: ltr; }
.row .grow, .row > span.grow { flex: 1; }
.chev { color: var(--muted); font-size: 22px; line-height: 1; opacity: .6; }
.add-row { color: var(--blue); }
.cat-row:active, a.row:active { background: var(--fill-2); }
.hint { font-size: 13px; color: var(--muted); padding: 7px 16px 0; }

.switch { appearance: none; -webkit-appearance: none; margin-left: auto; width: 51px; height: 31px; border-radius: 99px; background: var(--fill); position: relative; transition: background .25s; cursor: pointer; flex: none; }
.switch::after { content: ""; position: absolute; top: 2px; left: 2px; width: 27px; height: 27px; border-radius: 50%; background: #fff; box-shadow: 0 3px 8px rgba(0, 0, 0, .15), 0 1px 1px rgba(0, 0, 0, .16); transition: transform .25s; }
.switch:checked { background: #34c759; }
.switch:checked::after { transform: translateX(20px); }

.settings { max-width: 640px; margin: 0 auto; }
.settings form > .btn-primary.block { margin-top: 12px; min-height: 44px; background: var(--card); color: var(--blue); font-weight: 400; }
.settings form > .btn-primary.block:active { background: var(--fill); }

.swatches { display: flex; flex-wrap: wrap; gap: 12px; justify-content: center; padding: 18px 4px 6px; }
.swatches label { --c: #888; cursor: pointer; }
.swatches input { position: absolute; opacity: 0; pointer-events: none; }
.swatches i { display: block; width: 30px; height: 30px; border-radius: 50%; background: var(--c); transition: box-shadow .15s; }
.swatches input:checked + i { box-shadow: 0 0 0 3px var(--card), 0 0 0 5px var(--c); }

/* ---------- Sheets ---------- */
dialog.sheet {
  border: 0; padding: 0; margin: auto auto 0; width: 100%; max-width: 100%; max-height: 94dvh;
  background: var(--bg); color: var(--text); border-radius: 14px 14px 0 0; overflow: hidden;
}
dialog.sheet[open] { animation: up .38s cubic-bezier(.32, .72, 0, 1); display: flex; }
dialog.sheet::backdrop { background: rgba(0, 0, 0, .35); animation: fade .3s; }
.sheet-body { overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; padding: 0 16px calc(24px + var(--safe-b)); width: 100%; }
.sheet-head { position: sticky; top: 0; z-index: 2; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; height: 56px; margin: 0 -16px 8px; padding: 0 16px; background: var(--bg); }
.sheet-head::before { content: ""; position: absolute; top: 6px; left: 50%; width: 36px; height: 5px; border-radius: 3px; background: var(--fill); transform: translateX(-50%); }
.sheet-head strong { font-size: 17px; font-weight: 600; }
.sheet-head .link { font-size: 17px; justify-self: start; min-height: 44px; }
.sheet-head .link:last-child { justify-self: end; }
@keyframes up { from { transform: translateY(100%); } }
@keyframes fade { from { opacity: 0; } }

.segmented { display: grid; grid-template-columns: repeat(3, 1fr); background: var(--fill); border-radius: 9px; padding: 2px; }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented span { display: block; text-align: center; padding: 6px 0; border-radius: 7px; font-size: 13px; font-weight: 400; cursor: pointer; transition: background .2s; }
.segmented input:checked + span { background: var(--card); box-shadow: 0 1px 3px rgba(0, 0, 0, .12); font-weight: 600; }

.amount-field { display: flex; align-items: baseline; justify-content: center; gap: 4px; padding: 26px 0 10px; font-size: 48px; font-weight: 600; cursor: text; }
.amount-field .cur { font-size: 34px; font-weight: 400; color: var(--muted); }
/* The input sizes to its text: an invisible copy of the value sits in the same grid cell */
.amount-size { position: relative; max-width: 85%; overflow: hidden; }
.amount-size::after { content: attr(data-value); visibility: hidden; white-space: pre; }
.amount-size::after, .amount-field input { font: inherit; font-variant-numeric: tabular-nums; padding: 0 2px; }
.amount-field input { position: absolute; inset: 0; width: 100%; border: 0; background: none; outline: 0; text-align: center; caret-color: var(--blue); }
.amount-field input::placeholder { color: var(--muted); }

.chips { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px 4px; padding: 16px 8px 14px; background: var(--card); border-radius: var(--radius); }
.chip { --c: #888; display: grid; justify-items: center; gap: 6px; cursor: pointer; text-align: center; min-width: 0; }
.chip input { position: absolute; opacity: 0; pointer-events: none; }
.chip-icon { font-size: 22px; width: 46px; height: 46px; display: grid; place-items: center; border-radius: 50%; background: color-mix(in srgb, var(--c) 16%, transparent); transition: box-shadow .15s; }
.chip-name { font-size: 11px; line-height: 1.2; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding: 0 2px; color: var(--muted); }
.chip:has(input:checked) .chip-icon { box-shadow: 0 0 0 2px var(--card), 0 0 0 4px var(--c); }
.chip:has(input:checked) .chip-name { color: var(--text); font-weight: 600; }
.chip:active .chip-icon { opacity: .6; }

.date-row { justify-content: space-between; }
.date-pills { display: flex; gap: 6px; min-width: 0; }
.date-pills > * { position: relative; flex: none; height: 32px; padding: 0 11px; border-radius: 8px; background: var(--fill); font-size: 15px; display: grid; place-items: center; cursor: pointer; }
.date-pills .on { background: color-mix(in srgb, var(--blue) 15%, transparent); color: var(--blue); font-weight: 600; }
.row .date-pills input[type=date] { position: absolute; inset: 0; width: 100%; height: 100%; min-height: 0; padding: 0; opacity: 0; cursor: pointer; }
.sheet-head .link:disabled { color: var(--muted); opacity: .6; }
#txForm .segmented { margin-top: 4px; }
.segmented input:disabled + span { opacity: .35; cursor: default; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; top: calc(env(safe-area-inset-top, 0px) + 12px); transform: translateX(-50%); z-index: 60;
  background: var(--text); color: var(--bg); padding: 10px 18px; border-radius: 99px; font-size: 15px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, .2); animation: toast 3.2s forwards; white-space: nowrap; max-width: 92vw; overflow: hidden; text-overflow: ellipsis;
}
@keyframes toast { 0% { opacity: 0; transform: translate(-50%, -12px); } 8%, 85% { opacity: 1; transform: translate(-50%, 0); } 100% { opacity: 0; transform: translate(-50%, -12px); visibility: hidden; } }

/* ---------- Splash (first open per session) ---------- */
.splash { display: none; }
.show-splash .splash {
  position: fixed; inset: 0; z-index: 100; background: var(--bg); display: grid; place-content: center; justify-items: center; gap: 16px;
  animation: splash-out .5s ease 1.25s forwards;
}
.splash-logo { width: 104px; height: 104px; border-radius: 23px; box-shadow: 0 16px 40px rgba(0, 0, 0, .18); animation: pop-in .7s cubic-bezier(.34, 1.56, .64, 1) both; }
.splash-name { font-size: 28px; font-weight: 700; animation: rise .6s ease .35s both; }
.splash-logo circle, .hero-logo circle { animation: draw 1s cubic-bezier(.3, .7, 0, 1) .2s both; }
.splash-logo .r2, .hero-logo .r2 { animation-delay: .4s; }
.splash-logo .r3, .hero-logo .r3 { animation-delay: .55s; }
@keyframes splash-out { to { opacity: 0; visibility: hidden; transform: scale(1.04); } }
@keyframes pop-in { from { opacity: 0; transform: scale(.6); } }
@keyframes draw { from { stroke-dasharray: 0 300; } }
@keyframes rise { from { opacity: 0; transform: translateY(12px); } }

/* ---------- Landing ---------- */
.landing { width: 100%; max-width: 420px; text-align: center; display: flex; flex-direction: column; align-items: center; min-height: calc(100dvh - 48px); justify-content: center; }
.landing > * { animation: rise .7s cubic-bezier(.2, .8, .2, 1) both; }
.landing > :nth-child(2) { animation-delay: .1s; }
.landing > :nth-child(3) { animation-delay: .18s; }
.landing > :nth-child(4) { animation-delay: .3s; }
.landing > :nth-child(5) { animation-delay: .42s; }
.show-splash .landing > * { animation-delay: 1.45s; }
.show-splash .landing > :nth-child(4) { animation-delay: 1.6s; }
.show-splash .landing > :nth-child(5) { animation-delay: 1.75s; }
.show-splash .hero-logo circle { animation-delay: 1.5s; }
.hero-logo { width: 96px; height: 96px; border-radius: 22px; box-shadow: 0 14px 36px rgba(0, 0, 0, .16); margin-bottom: 20px; }
.landing h1 { font-size: 34px; }
.tagline { font-size: 20px; color: var(--muted); margin-top: 4px; }
.features { list-style: none; padding: 0; margin: 40px 0 36px; display: grid; gap: 22px; text-align: left; width: 100%; }
.features li { display: flex; gap: 14px; align-items: flex-start; }
.features strong { display: block; font-size: 17px; font-weight: 600; color: var(--text); margin-bottom: 1px; }
.features li > span:last-child { color: var(--muted); font-size: 15px; line-height: 1.35; }
.cta { width: 100%; }
.btn-plain { color: var(--blue); justify-content: center; align-items: center; font-weight: 400; margin-top: 6px; }
.btn-plain:active { opacity: .6; }

/* ---------- Sign in / sign up / onboarding ---------- */
body.center { display: grid; place-items: center; min-height: 100dvh; padding: calc(24px + env(safe-area-inset-top, 0px)) 16px calc(24px + var(--safe-b)); }
.onboard { width: 100%; max-width: 440px; text-align: center; }
.onboard .app-icon { width: 76px; height: 76px; border-radius: 17px; box-shadow: 0 10px 30px rgba(0, 0, 0, .15); margin-bottom: 18px; }
.app-icon-link { display: inline-block; }
.onboard h1 { font-size: 28px; margin-bottom: 6px; }
.onboard .group, .onboard .group-title, .onboard .hint { text-align: left; }
.auth .group { margin-top: 28px; }
.auth .row > span { min-width: 84px; }
.form-error { color: var(--red); font-size: 15px; margin-top: 12px; }
.note { margin-top: 16px; font-size: 15px; background: var(--fill-2); border-radius: 12px; padding: 10px 14px; }
.switch-auth { margin-top: 22px; font-size: 15px; color: var(--muted); }
.switch-auth a { color: var(--blue); font-weight: 400; }
.wave { display: inline-block; font-size: 56px; line-height: 1; margin-bottom: 14px; transform-origin: 70% 70%; animation: wave 1.6s ease .3s both; }
@keyframes wave { 0%, 60%, 100% { transform: rotate(0); } 10%, 30% { transform: rotate(14deg); } 20% { transform: rotate(-8deg); } 40% { transform: rotate(-4deg); } 50% { transform: rotate(10deg); } }
.shake { animation: shake .4s; }
@keyframes shake { 20%, 60% { transform: translateX(-10px); } 40%, 80% { transform: translateX(10px); } }

/* ---------- Friendly bits ---------- */
.empty-emoji { font-size: 40px; line-height: 1; margin-bottom: 4px; }
.profile { display: flex; align-items: center; gap: 14px; background: var(--card); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); margin-top: 4px; }
.profile strong { display: block; font-size: 22px; font-weight: 400; }
.profile .muted { font-size: 15px; }
.profile > div { min-width: 0; }
.profile > div > * { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.link-blue { color: var(--blue); }
.btn-danger.solid { background: var(--red); color: #fff; font-weight: 600; }
.sheet-note { color: var(--muted); font-size: 15px; padding: 4px 4px 14px; }


/* Phones: categories are a swipeable two-row strip; column width leaves the next one peeking */
@media (max-width: 759px) {
  .chips { grid-template-columns: none; grid-template-rows: repeat(2, auto); grid-auto-flow: column; grid-auto-columns: 78px; gap: 14px 0; overflow-x: auto; scrollbar-width: none; padding: 16px 8px 14px; scroll-padding-inline: 8px; scroll-snap-type: x proximity; }
  .chips::-webkit-scrollbar { display: none; }
  .chip { scroll-snap-align: start; }
}

/* ---------- Small iPhones (SE / mini) ---------- */
@media (max-width: 374px) {
  h1 { font-size: 30px; }
  .amount-field { font-size: 44px; }
}

/* ---------- iPad / desktop ---------- */
@media (min-width: 760px) {
  body { padding-bottom: 48px; }
  .topbar-inner { height: 56px; }
  .topbar { view-transition-name: topbar; }
  .large-title .toolbar { display: none; }
  .tabs { position: static; height: auto; padding: 3px; background: var(--fill); border: 0; border-radius: 11px; -webkit-backdrop-filter: none; backdrop-filter: none; margin: 0 auto; gap: 2px; }
  .tabs a { flex-direction: row; gap: 6px; padding: 6px 14px; border-radius: 8px; font-size: 14px; color: var(--text); }
  .tabs a.on { background: var(--card); color: var(--text); box-shadow: 0 1px 3px rgba(0, 0, 0, .1); font-weight: 600; }
  .tabs svg { width: 17px; height: 17px; }
  .btn-add { margin-left: 0; width: auto; height: 34px; padding: 0 16px 0 12px; border-radius: 99px; gap: 4px; display: inline-flex; align-items: center; font-size: 15px; font-weight: 400; }
  .btn-add span { display: inline; }
  .wrap { padding: 0 28px; }
  .page-head { flex-direction: row; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; padding: 36px 0 22px; }
  .page-head h1 { white-space: nowrap; }
  .page-head > .period { justify-content: flex-end; }
  .page-head > .btn-primary { align-self: flex-end; }
  .grid { gap: 16px; margin-bottom: 16px; }
  .stack { gap: 16px; }
  section.card { margin-bottom: 16px; }
  .card { padding: 20px; }
  .hero { grid-template-columns: 1fr 1fr; align-items: start; }
  .two { grid-template-columns: minmax(0, 1fr) minmax(0, 1.35fr); }
  .bars-wrap { height: 240px; }
  .filters { grid-template-columns: 2fr 1fr 1fr 1fr auto; }
  .filters .search, .filters .link { grid-column: auto; }
  dialog.sheet { margin: auto; width: 460px; border-radius: 16px; max-height: 88vh; box-shadow: 0 30px 80px rgba(0, 0, 0, .3); }
  dialog.sheet[open] { animation: pop .3s cubic-bezier(.32, .72, 0, 1); }
  .sheet-head::before { display: none; }
  .toast { top: 70px; }
  @keyframes pop { from { transform: scale(.94); opacity: 0; } }
}
@media (min-width: 760px) and (max-width: 1020px) {
  .two { grid-template-columns: minmax(0, 1fr); }
}
@media (hover: hover) {
  .tx:hover, .acct:hover { background: var(--fill-2); }
}
@media (prefers-reduced-motion: reduce) { *, ::before, ::after { animation: none !important; transition: none !important; } }
