/* Budget — shares the IFAIMA look: glass tab bar, draggable sheets, zoom-from-tap popups, auto light/dark. */
:root {
  --ink: #12243f; --muted: #5b6b82; --faint: #8a97aa; --heading: #0f1f38;
  --page: #edf1f6; --surface: #ffffff; --raised: rgba(255,255,255,.72); --line: rgba(18,36,63,.10);
  --action: #1f6feb; --on-action: #fff; --navy: #12243f;
  --good: #1e8e6e; --near: #c8901f; --over: #d64545;
  --good-tint: rgba(30,142,110,.12); --near-tint: rgba(200,144,31,.14); --over-tint: rgba(214,69,69,.12); --action-tint: rgba(31,111,235,.10);
  --glass: rgba(255,255,255,.62); --glass-edge: rgba(255,255,255,.7); --shadow: 0 10px 30px rgba(18,36,63,.14);
  --figures: ui-rounded, "SF Pro Rounded", "Nunito", system-ui, sans-serif;
  --text: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, system-ui, sans-serif;
  --r-lg: 22px; --r-md: 14px; --r-sm: 10px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --dark: 1; } }
:root[data-theme="dark"], :root.dark {
  --ink: #e6ecf5; --muted: #9aa8bd; --faint: #6f7d92; --heading: #f2f6fb;
  --page: #0e1a2e; --surface: #15243c; --raised: rgba(28,44,70,.72); --line: rgba(230,236,245,.10);
  --action: #4b8dff; --good: #3fbf95; --near: #e0ab45; --over: #f07171;
  --good-tint: rgba(63,191,149,.16); --near-tint: rgba(224,171,69,.16); --over-tint: rgba(240,113,113,.16); --action-tint: rgba(75,141,255,.16);
  --glass: rgba(24,38,62,.62); --glass-edge: rgba(255,255,255,.08); --shadow: 0 10px 30px rgba(0,0,0,.4);
  color-scheme: dark;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: env(safe-area-inset-top, 0px); }
body { margin: 0; background: var(--page); color: var(--ink); font: 16px/1.45 var(--text); min-height: 100vh;
  padding-top: env(safe-area-inset-top, 0px); -webkit-tap-highlight-color: transparent; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--action); text-decoration: none; }
:focus-visible { outline: 2px solid var(--action); outline-offset: 2px; border-radius: 6px; }
.num, .fig { font-family: var(--figures); font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); } .small { font-size: 13px; } .tiny { font-size: 12px; }
.good { color: var(--good); } .near { color: var(--near); } .over { color: var(--over); }
[hidden] { display: none !important; }

/* ---------- layout ---------- */
#app { max-width: 760px; margin: 0 auto; padding: 8px 16px calc(110px + env(safe-area-inset-bottom, 0px)); }
.top { display: flex; align-items: center; gap: 10px; padding: 10px 0 14px; }
.top h1 { font: 700 28px/1.1 var(--figures); color: var(--heading); margin: 0; flex: 1; letter-spacing: -.01em; }
.avatar { width: 38px; height: 38px; border-radius: 50%; border: 0; background: var(--navy); color: #fff; font-weight: 600; cursor: pointer; }
.section { margin: 22px 0 8px; display: flex; align-items: baseline; justify-content: space-between; }
.section h2 { font-size: 17px; margin: 0; color: var(--heading); }
.card { background: var(--surface); border-radius: var(--r-lg); padding: 16px; box-shadow: 0 1px 0 var(--line); }
.card + .card { margin-top: 12px; }
.list { background: var(--surface); border-radius: var(--r-lg); overflow: hidden; }
.row { display: flex; align-items: center; gap: 12px; padding: 13px 16px; border-top: 1px solid var(--line); min-height: 56px; width: 100%;
  background: none; border-left: 0; border-right: 0; border-bottom: 0; text-align: left; cursor: pointer; }
.row:first-child { border-top: 0; }
.row .grow { flex: 1; min-width: 0; }
.row .title { font-weight: 550; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .sub { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .amt { font-family: var(--figures); font-variant-numeric: tabular-nums; font-weight: 600; text-align: right; white-space: nowrap; }
.empty { text-align: center; color: var(--muted); padding: 28px 16px; }

/* ---------- controls ---------- */
.btn { border: 0; border-radius: 999px; padding: 11px 18px; font-weight: 600; cursor: pointer; background: var(--action); color: var(--on-action); min-height: 44px; }
.btn.ghost { background: var(--action-tint); color: var(--action); }
.btn.plain { background: transparent; color: var(--action); padding: 8px 10px; min-height: 0; }
.btn.danger { background: var(--over-tint); color: var(--over); }
.btn.block { width: 100%; }
.btn:disabled { opacity: .5; }
.btns { display: flex; gap: 10px; margin-top: 14px; flex-wrap: wrap; }
.btns .btn { flex: 1; }
label.f { display: block; margin: 12px 0 0; font-size: 13px; color: var(--muted); }
label.f > span { display: block; margin-bottom: 5px; }
.in, select.in, textarea.in { width: 100%; border: 1px solid var(--line); background: var(--page); border-radius: var(--r-md); padding: 12px 14px; font-size: 16px; color: var(--ink); }
textarea.in { min-height: 110px; resize: vertical; }
.in:focus { outline: 2px solid var(--action); outline-offset: 0; }
.pair { display: flex; gap: 10px; } .pair > * { flex: 1; min-width: 0; }
.amount-in { font: 700 40px/1 var(--figures); text-align: center; border: 0; background: transparent; width: 100%; padding: 6px 0; color: var(--heading); }
.amount-in:focus { outline: 0; }
.switch { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 0; }
.switch input { width: 46px; height: 28px; appearance: none; background: var(--line); border-radius: 999px; position: relative; cursor: pointer; transition: background .2s; flex: none; }
.switch input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: transform .2s; }
.switch input:checked { background: var(--good); } .switch input:checked::after { transform: translateX(18px); }
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 2px 0 6px; scrollbar-width: none; }
.chip { border: 0; background: var(--surface); color: var(--muted); border-radius: 999px; padding: 8px 14px; font-weight: 550; white-space: nowrap; cursor: pointer; }
.chip.on { background: var(--navy); color: #fff; }
.tag { display: inline-block; font-size: 12px; padding: 2px 8px; border-radius: 999px; background: var(--action-tint); color: var(--action); font-weight: 600; }
.tag.good { background: var(--good-tint); color: var(--good); } .tag.near { background: var(--near-tint); color: var(--near); } .tag.over { background: var(--over-tint); color: var(--over); }

/* ---------- the ring (home) ---------- */
.hero { display: grid; grid-template-columns: 168px 1fr; gap: 18px; align-items: center; }
.ring { position: relative; width: 168px; height: 168px; }
.ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring .track { stroke: var(--line); } .ring .fill { transition: stroke-dashoffset .9s cubic-bezier(.2,.8,.2,1); }
.ring .mid { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; }
.ring .mid b { font: 700 25px/1 var(--figures); color: var(--heading); font-variant-numeric: tabular-nums; }
.ring .mid span { font-size: 12px; color: var(--muted); margin-top: 4px; }
.stats { display: grid; gap: 10px; }
.stat b { display: block; font: 650 19px/1.2 var(--figures); font-variant-numeric: tabular-nums; color: var(--heading); }
.stat span { font-size: 13px; color: var(--muted); }
@media (max-width: 380px) { .hero { grid-template-columns: 1fr; justify-items: center; text-align: center; } }

/* ---------- budget bars ---------- */
.bar { height: 6px; border-radius: 99px; background: var(--line); overflow: hidden; margin-top: 7px; position: relative; }
.bar i { display: block; height: 100%; border-radius: 99px; background: var(--good); }
.bar i.near { background: var(--near); } .bar i.over { background: var(--over); }
.bar .pace { position: absolute; top: -2px; bottom: -2px; width: 2px; background: var(--ink); opacity: .35; }
.group-h { display: flex; justify-content: space-between; align-items: baseline; margin: 22px 4px 8px; }
.group-h h3 { margin: 0; font-size: 13px; color: var(--muted); font-weight: 650; letter-spacing: .02em; }
.monthbar { display: flex; align-items: center; gap: 6px; }
.monthbar button { border: 0; background: var(--surface); width: 38px; height: 38px; border-radius: 50%; cursor: pointer; font-size: 18px; color: var(--ink); }
.monthbar strong { min-width: 112px; text-align: center; font-weight: 600; }

/* ---------- glass tab bar ---------- */
.tabbar { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(14px + env(safe-area-inset-bottom, 0px)); z-index: 30;
  display: flex; gap: 2px; padding: 6px; border-radius: 999px; background: var(--glass); border: 1px solid var(--glass-edge);
  backdrop-filter: blur(22px) saturate(1.6); -webkit-backdrop-filter: blur(22px) saturate(1.6); box-shadow: var(--shadow); touch-action: none; }
.tabbar a { position: relative; z-index: 1; display: grid; justify-items: center; gap: 2px; width: 64px; padding: 7px 0 5px; border-radius: 999px; color: var(--muted); font-size: 11px; font-weight: 600; }
.tabbar a svg { width: 23px; height: 23px; }
.tabbar a.on { color: var(--action); }
.tabbar a.add { color: #fff; }
.tabbar a.add span.plus { width: 44px; height: 44px; border-radius: 50%; background: var(--action); display: grid; place-items: center; margin-top: -2px; box-shadow: 0 6px 16px rgba(31,111,235,.35); }
.tabbar .bubble { position: absolute; z-index: 0; top: 6px; bottom: 6px; width: 64px; border-radius: 999px; background: var(--action-tint);
  transition: transform .35s cubic-bezier(.2,.9,.25,1.15); pointer-events: none; }
.tabbar.dragging .bubble { transition: none; }
.badge { position: absolute; top: 2px; right: 12px; min-width: 17px; height: 17px; border-radius: 99px; background: var(--over); color: #fff; font-size: 11px; display: grid; place-items: center; padding: 0 4px; }

/* desktop: side rail */
@media (min-width: 960px) {
  #app { padding-left: 120px; max-width: 900px; }
  .tabbar { left: 24px; top: 50%; bottom: auto; transform: translateY(-50%); flex-direction: column; border-radius: 30px; }
  .tabbar .bubble { left: 6px; right: 6px; top: 0; bottom: auto; height: 58px; width: auto; }
}

/* ---------- sheets ---------- */
.scrim { position: fixed; inset: 0; background: rgba(8,16,30,.38); z-index: 40; opacity: 0; transition: opacity .25s; }
.scrim.show { opacity: 1; }
.sheet { position: fixed; left: 0; right: 0; bottom: 0; z-index: 41; max-height: 92vh; overflow: auto; overscroll-behavior: contain;
  background: var(--surface); border-radius: 26px 26px 0 0; padding: 8px 18px calc(22px + env(safe-area-inset-bottom, 0px));
  transform: translateY(100%); transition: transform .34s cubic-bezier(.2,.9,.25,1); box-shadow: 0 -10px 40px rgba(0,0,0,.2); }
.sheet.show { transform: translateY(0); }
.sheet.dragging { transition: none; }
.sheet .grab { width: 40px; height: 5px; border-radius: 99px; background: var(--line); margin: 4px auto 10px; cursor: grab; touch-action: none; }
.sheet .grabzone { touch-action: none; padding-bottom: 2px; }
.sheet h2 { margin: 0 0 4px; font: 700 21px/1.2 var(--figures); color: var(--heading); }
.sheet .head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
@media (min-width: 700px) { .sheet { left: 50%; right: auto; width: 560px; bottom: 50%; border-radius: 26px; transform: translate(-50%, 60%) scale(.96); opacity: 0; transition: transform .3s, opacity .2s; }
  .sheet.show { transform: translate(-50%, 50%); opacity: 1; } .sheet .grab { display: none; } }

/* zoom-from-tap popup */
.pop { position: fixed; z-index: 50; left: 50%; top: 50%; width: min(360px, calc(100vw - 40px)); background: var(--surface); border-radius: 24px; padding: 20px;
  box-shadow: var(--shadow); transform: translate(-50%,-50%); transition: transform .32s cubic-bezier(.2,.9,.25,1.1), opacity .2s; }
.pop p { margin: 0 0 6px; }

.toast { position: fixed; left: 50%; bottom: calc(96px + env(safe-area-inset-bottom, 0px)); transform: translate(-50%, 20px); z-index: 60; opacity: 0;
  background: var(--navy); color: #fff; padding: 11px 18px; border-radius: 999px; font-weight: 550; transition: .25s; pointer-events: none; max-width: 90vw; text-align: center; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- inbox ---------- */
.alert-card .raw { font-size: 13px; color: var(--muted); background: var(--page); border-radius: var(--r-sm); padding: 10px 12px; margin-top: 10px; white-space: pre-wrap; word-break: break-word; }
.alert-card .big { font: 700 26px/1.1 var(--figures); color: var(--heading); font-variant-numeric: tabular-nums; }
.split-row { display: flex; gap: 8px; margin-top: 8px; } .split-row select { flex: 2; } .split-row input { flex: 1; }

/* ---------- auth ---------- */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px; margin: -8px -16px; background: linear-gradient(160deg, #12243f 0%, #1b3a66 55%, #1e8e6e 140%); }
.auth .card { width: min(400px, 100%); padding: 26px 22px; }
.auth h1 { font: 700 28px/1.15 var(--figures); margin: 0 0 4px; color: var(--heading); }
.err { color: var(--over); font-size: 14px; margin-top: 10px; min-height: 1em; }

/* ---------- charts ---------- */
.chart svg { width: 100%; height: auto; display: block; }
.chart text { fill: var(--muted); font-size: 10px; font-family: var(--text); }
.legend { display: flex; gap: 14px; font-size: 13px; color: var(--muted); margin-top: 8px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }
.hbar { margin: 10px 0; } .hbar .lab { display: flex; justify-content: space-between; font-size: 14px; }

.copy { display: flex; gap: 8px; align-items: center; } .copy code { flex: 1; font-size: 12px; background: var(--page); padding: 10px; border-radius: var(--r-sm); word-break: break-all; }
ol.steps { padding-left: 20px; margin: 8px 0; } ol.steps li { margin: 6px 0; }

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition: none !important; animation: none !important; } }
.row .grow, .row .title, .row .sub, .row .bar { display: block; }
.row > span:last-child:not(.grow) { flex: none; }
.top h1 { font-size: 26px; }
.btns .btn { flex: 1 1 auto; white-space: nowrap; }

/* ---------- set up this device ---------- */
.steps-dots { display: flex; gap: 6px; justify-content: center; margin: 4px 0 12px; }
.steps-dots i { width: 8px; height: 8px; border-radius: 50%; background: var(--line); }
.steps-dots i.on { background: var(--action); width: 22px; border-radius: 99px; }
.steps-dots i.done { background: var(--good); }
.setup-art { width: 64px; height: 64px; border-radius: 18px; display: grid; place-items: center; background: var(--action-tint); color: var(--action); margin: 4px 0 10px; }
.setup-art svg { width: 32px; height: 32px; }
.setup-done { display: flex; gap: 10px; align-items: center; background: var(--good-tint); color: var(--good); border-radius: var(--r-md); padding: 12px 14px; font-weight: 600; margin-top: 10px; }
.qr { display: grid; place-items: center; background: #fff; border-radius: var(--r-md); padding: 14px; margin-top: 10px; }
.qr svg { width: 180px; height: 180px; }
.kbd { display: inline-block; border: 1px solid var(--line); border-radius: 6px; padding: 0 6px; font-weight: 600; background: var(--page); }
