:root {
  color-scheme: dark;
  --bg: #0b0c10;
  --surface: #15171d;          /* cards; chart palette validated against this */
  --surface-2: #1c1f27;
  --surface-3: #252934;
  --line: rgba(255, 255, 255, 0.08);
  --line-2: rgba(255, 255, 255, 0.14);
  --fg: #f4f5f7;
  --fg-2: #c3c6ce;
  --muted: #8b8f99;
  --faint: #5d616b;
  --accent: #34d399;           /* primary actions */
  --accent-2: #22b8cf;
  --accent-ink: #04130d;
  --good: #0ca30c;
  --warning: #fab219;
  --serious: #ec835a;
  --critical: #d03b3b;
  --critical-ink: #ff8a8a;
  --warning-ink: #ffd27a;
  /* categorical (dark steps) */
  --s1: #3987e5;
  --s2: #d95926;
  --s3: #199e70;
  --s4: #c98500;
  /* sequential blue, low -> high on the dark surface */
  --seq0: #1d2027;
  --seq1: #0d366b;
  --seq2: #184f95;
  --seq3: #256abf;
  --seq4: #3987e5;
  --seq5: #86b6ef;
  --grid: #262932;
  --axis: #383b45;
  --radius: 20px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-display: -apple-system, BlinkMacSystemFont, "SF Pro Display", system-ui, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; overflow: hidden; overscroll-behavior: none; background: var(--bg); color: var(--fg); }
:where(*) { touch-action: manipulation; } /* no double-tap zoom */
/* App frame: the page never scrolls or zooms; each view scrolls inside itself. */
/* Height comes from the real window (JS sets --app-h): iOS Home Screen apps with a translucent status bar report a
   "full screen" that's one status bar short, which left the tab bar floating above the bottom edge. */
#appView { position: fixed; top: 0; left: 0; right: 0; height: var(--app-h, 100%); display: flex; flex-direction: column; }
#appView > #page { flex: 1; min-height: 0; width: 100%; overflow-y: auto; overflow-x: hidden; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; }
/* Everything else on the bottom edge is placed from the TOP of the same frame (top + --frame-h), never with
   `bottom:`. In the iPhone Home Screen app the window iOS reports can be shorter than the screen, so anything
   anchored to the window's bottom floated one status bar up (sheets, the + button), while the frame is right. */
:root { --frame-h: var(--app-h, 100vh); }
#setupView, #authView, #lockView:not(.lock-overlay), #splash { position: fixed; top: 0; left: 0; right: 0; height: var(--app-h, 100%); overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
body {
  font: 16px/1.45 var(--font);
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior-y: none;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; }
a { color: var(--accent); text-decoration: none; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 8px; }
h1, h2, h3, h4 { margin: 0; font-family: var(--font-display); letter-spacing: -0.015em; }
p { margin: 0; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.num { font-variant-numeric: tabular-nums; }
.ico { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.emoji { font-size: 1.15em; line-height: 1; }

.bg {
  position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background:
    radial-gradient(70% 45% at 0% 0%, rgba(52, 211, 153, 0.13), transparent 70%),
    radial-gradient(60% 40% at 100% 10%, rgba(57, 135, 229, 0.12), transparent 70%),
    var(--bg);
}

/* ---------- Layout ---------- */
.page {
  max-width: 680px; margin: 0 auto;
  padding: calc(14px + var(--safe-top)) 16px 96px;
}
#setupView.page { padding-bottom: calc(32px + var(--safe-bottom)); }
.center-view {
  min-height: 100%; display: grid; place-items: center;
  padding: calc(24px + var(--safe-top)) 20px calc(24px + var(--safe-bottom));
}
.stack-v { display: grid; gap: 12px; }
.row { display: flex; align-items: center; gap: 10px; }
.row.between { justify-content: space-between; }
.row.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.section { margin-top: 22px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; margin: 0 4px 10px; }
.section-head h2 { font-size: 20px; }
.section-head .link-btn { font-size: 15px; }

.topbar { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; min-height: 44px; }
.topbar h1 { font-size: 30px; font-weight: 800; }
.topbar .sub { color: var(--muted); font-size: 14px; margin-top: 2px; }

/* ---------- Cards ---------- */
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px;
}
.card.flush { padding: 0; overflow: hidden; }
.card + .card { margin-top: 12px; }
.card-title { font-size: 13px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 8px; }
.glass {
  background: linear-gradient(160deg, rgba(52, 211, 153, 0.16), rgba(57, 135, 229, 0.10) 55%, rgba(21, 23, 29, 0.9));
  border: 1px solid rgba(255, 255, 255, 0.10);
}

/* Hero */
.hero { display: flex; align-items: center; gap: 16px; padding: 20px; }
.hero-label { font-size: 14px; color: var(--fg-2); font-weight: 600; }
.hero-value { font: 800 44px/1.05 var(--font-display); letter-spacing: -0.03em; margin: 4px 0 6px; }
.hero-sub { font-size: 14px; color: var(--fg-2); }
.ring { width: 76px; height: 76px; flex: none; }
.ring-track { fill: none; stroke: rgba(255, 255, 255, 0.10); stroke-width: 7; }
.ring-fill { fill: none; stroke: var(--accent); stroke-width: 7; stroke-linecap: round; }
.ring-wrap { position: relative; }
.ring-text { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; font-size: 12px; color: var(--fg-2); line-height: 1.1; }
.ring-text b { display: block; font-size: 18px; color: var(--fg); }

.tiles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin-top: 12px; }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 12px; min-width: 0; }
.tile-label { font-size: 12px; color: var(--muted); font-weight: 600; }
.tile-value { font: 700 18px/1.2 var(--font-display); margin-top: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile.alert { border-color: rgba(250, 178, 25, 0.45); }
.tile.alert .tile-value { color: var(--warning-ink); }
.tiles.four { grid-template-columns: 1fr 1fr; }
@media (max-width: 380px) { .tiles { grid-template-columns: 1fr 1fr; } .tiles:not(.four) .tile:last-child { grid-column: 1 / -1; } .hero-value { font-size: 38px; } }

/* Home shortcuts: Plan · Income · Move · Bills · Goals */
.quick { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 4px; margin-top: 12px; padding: 12px 6px 10px; }
.quick button { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 4px 0; border-radius: 14px; font-size: 12px; font-weight: 600; color: var(--fg-2); min-width: 0; }
.quick button:active { background: var(--surface-2); }
.quick .q-ico { position: relative; width: 44px; height: 44px; border-radius: 15px; display: grid; place-items: center; color: var(--accent); background: rgba(52, 211, 153, 0.12); border: 1px solid rgba(52, 211, 153, 0.18); }
.quick .q-dot { position: absolute; top: -3px; right: -3px; width: 11px; height: 11px; border-radius: 50%; background: var(--warning); border: 2px solid var(--surface); }

.banner {
  display: flex; align-items: center; gap: 12px; padding: 14px 16px; border-radius: 16px;
  background: var(--surface-2); border: 1px solid var(--line); margin-top: 12px; width: 100%; text-align: left;
}
.banner .ico { width: 24px; height: 24px; }
.banner.warn { border-color: rgba(250, 178, 25, 0.45); background: rgba(250, 178, 25, 0.08); }
.banner.warn .ico { color: var(--warning); }
.banner.info .ico { color: var(--accent); }
.banner.danger { border-color: rgba(208, 59, 59, 0.5); background: rgba(208, 59, 59, 0.08); }
.banner.danger .ico { color: var(--critical-ink); }
.banner-title { font-weight: 650; }
.banner-sub { font-size: 14px; color: var(--fg-2); }

/* ---------- Buttons & inputs ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 13px 18px; border-radius: 14px; font-weight: 650; font-size: 16px;
  background: var(--surface-3); border: 1px solid var(--line); transition: transform 0.12s ease, opacity 0.2s;
}
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.5; }
.btn.primary { background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: var(--accent-ink); border-color: transparent; }
.btn.danger { color: var(--critical-ink); }
.btn.armed { background: rgba(208, 59, 59, 0.25); color: #fff; }
.btn.wide { width: 100%; }
.btn.small { padding: 8px 12px; font-size: 14px; border-radius: 11px; }
.btn.loading { position: relative; color: transparent !important; }
.btn.loading::after {
  content: ""; position: absolute; width: 18px; height: 18px; border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.35); border-top-color: #fff; animation: spin 0.8s linear infinite;
}
.btn.primary.loading::after { border-color: rgba(0, 0, 0, 0.25); border-top-color: var(--accent-ink); }
@keyframes spin { to { transform: rotate(360deg); } }
.icon-btn { width: 40px; height: 40px; display: grid; place-items: center; border-radius: 50%; color: var(--fg-2); }
.icon-btn:active { background: var(--surface-3); }
.link-btn { color: var(--accent); font-weight: 600; }
.link-btn.small { font-size: 13px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 6px 11px; border-radius: 999px;
  background: var(--surface-2); border: 1px solid var(--line); font-size: 14px; color: var(--fg-2); white-space: nowrap;
}
.chip.on { background: rgba(52, 211, 153, 0.16); border-color: rgba(52, 211, 153, 0.5); color: var(--fg); }
.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }

label.field, div.field { display: block; font-size: 13px; font-weight: 600; color: var(--fg-2); margin-bottom: 12px; }
label.field > span, div.field > span { display: block; margin-bottom: 6px; }
input:not([type=checkbox]):not([type=radio]):not([type=file]), select, textarea {
  display: block; width: 100%; font-size: 17px; padding: 12px 14px;
  background: var(--surface-2); border: 1px solid var(--line-2); border-radius: 12px; -webkit-appearance: none; appearance: none;
}
textarea { min-height: 84px; resize: vertical; line-height: 1.4; }
select { background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 20px) 50%, calc(100% - 14px) 50%; background-size: 6px 6px; background-repeat: no-repeat; padding-right: 34px; }
input::placeholder, textarea::placeholder { color: var(--faint); }
.money-input { font-variant-numeric: tabular-nums; }
.money-wrap { position: relative; }
.money-wrap::before { content: "Rp"; position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--muted); font-size: 17px; pointer-events: none; }
.money-wrap input { padding-left: 42px !important; } /* beats the generic input padding */
.hint { font-size: 13px; color: var(--muted); margin-top: 6px; }
.form-msg { min-height: 1.2em; font-size: 14px; color: var(--critical-ink); margin: 4px 0 10px; }
.form-msg.ok { color: var(--accent); }
.toggle { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 0; }
.switch { position: relative; width: 50px; height: 30px; flex: none; }
.switch input { opacity: 0; width: 100%; height: 100%; position: absolute; margin: 0; }
.switch span { position: absolute; inset: 0; background: var(--surface-3); border-radius: 999px; transition: background 0.2s; pointer-events: none; }
.switch span::after { content: ""; position: absolute; left: 3px; top: 3px; width: 24px; height: 24px; background: #fff; border-radius: 50%; transition: transform 0.2s; }
.switch input:checked + span { background: var(--accent); }
.switch input:checked + span::after { transform: translateX(20px); }
.segmented { display: flex; background: var(--surface-2); border-radius: 12px; padding: 3px; gap: 2px; border: 1px solid var(--line); }
.segmented button { flex: 1; padding: 8px 10px; border-radius: 9px; font-size: 14px; font-weight: 600; color: var(--muted); white-space: nowrap; }
.segmented button[aria-pressed="true"] { background: var(--surface-3); color: var(--fg); }

/* ---------- Lists ---------- */
.list { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.list-item { display: flex; align-items: center; gap: 12px; padding: 13px 14px; width: 100%; text-align: left; border-bottom: 1px solid var(--line); background: none; }
.list-item:last-child { border-bottom: 0; }
.list-item:active { background: var(--surface-2); }
.li-icon { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; background: var(--surface-3); flex: none; font-size: 20px; }
.li-main { flex: 1; min-width: 0; }
.li-title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.li-sub { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: flex; gap: 6px; align-items: center; }
.li-right { text-align: right; flex: none; }
.li-pills { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 5px; }
.li-note { font-size: 13px; color: var(--fg-2); font-style: italic; margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.banner.demo { border-color: rgba(144, 133, 233, 0.5); background: rgba(144, 133, 233, 0.10); margin-bottom: 12px; }
.banner.demo .ico { color: #b3aaf2; }
.li-amount { font-weight: 650; font-variant-numeric: tabular-nums; }
.li-amount.transfer { color: var(--muted); }
/* Inbox select mode */
.sel-check { width: 26px; height: 26px; border-radius: 50%; border: 2px solid var(--line-2); flex: none; display: grid; place-items: center; color: transparent; }
.sel-check .ico { width: 16px; height: 16px; stroke-width: 3; }
.list-item.picked { background: rgba(52, 211, 153, 0.07); }
.list-item.picked .sel-check { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.list-item.no-pick { opacity: 0.45; }
.list-item.no-pick .sel-check { border-style: dashed; }
.select-bar { position: sticky; bottom: 10px; z-index: 6; margin-top: 14px; display: flex; align-items: center; gap: 12px; padding: 10px 10px 10px 16px; border-radius: 18px;
  background: rgba(28, 31, 39, 0.96); border: 1px solid var(--line-2); box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45); -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px); }
.select-bar .btn { flex: none; }
.day-head { font-size: 13px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; margin: 18px 6px 8px; }
.empty-state { text-align: center; padding: 36px 20px; color: var(--muted); }
.empty-state .big { font-size: 40px; margin-bottom: 8px; }
.empty-state h3 { color: var(--fg); font-size: 18px; margin-bottom: 4px; }
.pill { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 650; padding: 2px 8px; border-radius: 999px; background: var(--surface-3); color: var(--fg-2); }
.pill.ok { background: rgba(12, 163, 12, 0.18); color: #6ee26e; }
.pill.warn { background: rgba(250, 178, 25, 0.16); color: var(--warning-ink); }
.pill.bad { background: rgba(208, 59, 59, 0.18); color: var(--critical-ink); }
.pill.ai { background: rgba(57, 135, 229, 0.18); color: #9ec5f4; }
.pill .ico { width: 13px; height: 13px; }

/* ---------- Wallets ---------- */
.wallet { padding: 13px 14px; border-bottom: 1px solid var(--line); display: block; width: 100%; text-align: left; }
.wallet:last-child { border-bottom: 0; }
.wallet-top { display: flex; align-items: center; gap: 10px; }
.wallet-name { flex: 1; min-width: 0; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wallet-left { font-weight: 700; font-variant-numeric: tabular-nums; }
.wallet-left.neg { color: var(--critical-ink); }
.wallet-sub { display: flex; justify-content: space-between; font-size: 13px; color: var(--muted); margin-top: 7px; }
.meter { position: relative; height: 8px; border-radius: 999px; background: rgba(57, 135, 229, 0.18); margin-top: 9px; overflow: visible; }
.meter-fill { height: 100%; border-radius: 999px; background: var(--s1); }
.meter.warning { background: rgba(250, 178, 25, 0.16); }
.meter-fill.warning { background: var(--warning); }
.meter.critical { background: rgba(208, 59, 59, 0.2); }
.meter-fill.critical { background: var(--critical); }
.meter-pace { position: absolute; top: -3px; bottom: -3px; width: 2px; background: var(--fg-2); border-radius: 2px; opacity: 0.7; }
.group-head { display: flex; justify-content: space-between; align-items: baseline; padding: 12px 14px 4px; font-size: 13px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; }
.alloc-row { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-bottom: 1px solid var(--line); }
.alloc-row:last-child { border-bottom: 0; }
.alloc-row .money-wrap { width: 150px; flex: none; }
.alloc-row input { padding-top: 9px; padding-bottom: 9px; font-size: 16px; text-align: right; }
/* Sticks just under the sheet's title row (never over the close button), on a solid backing so rows don't show through. */
.assign-bar { position: sticky; top: 50px; z-index: 2; margin-bottom: 12px; isolation: isolate; }
.assign-bar::before { content: ""; position: absolute; inset: 0; z-index: -1; border-radius: inherit; background: var(--surface); }

/* ---------- Transaction sheet ---------- */
.tx-amount { font: 800 38px/1.1 var(--font-display); letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; font-size: 15px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; text-align: right; overflow-wrap: anywhere; }
.flag { margin-top: 10px; }
.receipt-thumb { width: 100%; max-height: 260px; object-fit: contain; border-radius: 14px; background: #000; display: block; }
.match { display: grid; grid-template-columns: 1fr auto auto; gap: 6px 10px; font-size: 14px; align-items: center; margin-top: 10px; }
.match .h { color: var(--muted); font-size: 12px; font-weight: 700; text-transform: uppercase; }
.split-row { display: grid; grid-template-columns: minmax(0, 1fr) 132px 36px; gap: 8px; align-items: center; margin-bottom: 8px; }
.split-row select, .split-row input { padding-top: 10px; padding-bottom: 10px; font-size: 15px; }
.split-left { font-size: 14px; margin: 2px 0 8px; }
.split-left.bad { color: var(--critical-ink); }
.split-left.ok { color: var(--accent); }
.reason-chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0; }
.email-text { white-space: pre-wrap; font-size: 13px; color: var(--fg-2); background: var(--surface-2); border-radius: 12px; padding: 12px; max-height: 260px; overflow: auto; }
.sticky-actions { position: sticky; bottom: calc(-18px - var(--safe-bottom)); padding: 12px 0 calc(6px + var(--safe-bottom)); background: linear-gradient(180deg, transparent, var(--surface) 30%); margin-top: 16px; display: grid; gap: 8px; }

/* ---------- Sheets ---------- */
/* The sheet layer covers exactly the app frame (top 0, height --frame-h: the box that puts the tab bar on the bottom
   edge) and the panel sits at its bottom, its top always below the status bar / Dynamic Island so the close button
   can be tapped. Tapping the empty layer above the panel closes the sheet. */
dialog.sheet {
  position: fixed; inset: 0 0 auto 0; height: var(--frame-h); max-height: none; width: 100%; max-width: none;
  margin: 0; padding: 0; border: 0; background: transparent; color: var(--fg); overflow: hidden;
}
dialog.sheet[open] { display: flex; flex-direction: column; justify-content: flex-end; }
.sheet-panel {
  width: 100%; max-width: 680px; margin: 0 auto; max-height: calc(var(--frame-h) - var(--safe-top) - 12px);
  border-radius: 24px 24px 0 0; padding: 0 16px calc(18px + var(--safe-bottom));
  background: var(--surface); overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain;
  box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.5); animation: sheet-up 0.28s cubic-bezier(0.2, 0.9, 0.3, 1) both;
}
dialog.sheet.tall .sheet-panel { height: calc(var(--frame-h) - var(--safe-top) - 12px); }
dialog::backdrop { bottom: -25vh; background: rgba(0, 0, 0, 0.55); backdrop-filter: blur(2px); } /* also covers the frame below a short window */
@keyframes sheet-up { from { transform: translateY(40px); opacity: 0; } to { transform: none; opacity: 1; } }
.sheet-grab { width: 38px; height: 5px; border-radius: 3px; background: var(--line-2); margin: 8px auto 0; }
.sheet-head { position: sticky; top: 0; z-index: 3; display: flex; align-items: center; justify-content: space-between; padding: 8px 0 10px; background: var(--surface); }
.sheet-head h2 { font-size: 21px; }
.sheet-body { padding-bottom: 8px; }

/* ---------- Tab bar ---------- */
.tabbar {
  position: relative; flex: none; z-index: 20;
  display: grid; grid-template-columns: repeat(5, 1fr);
  padding: 6px 8px calc(6px + var(--safe-bottom));
  background: rgba(11, 12, 16, 0.82); -webkit-backdrop-filter: blur(20px) saturate(1.4); backdrop-filter: blur(20px) saturate(1.4);
  border-top: 1px solid var(--line);
}
.tabbar a { position: relative; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 0; color: var(--faint); font-size: 11px; font-weight: 600; }
.tabbar a.on { color: var(--accent); }
.tabbar .ico { width: 25px; height: 25px; }
.tabbar .badge { position: absolute; top: 2px; left: calc(50% + 6px); min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--critical); color: #fff; font-size: 11px; display: grid; place-items: center; }
.fab {
  position: fixed; right: max(16px, calc(50% - 324px)); top: calc(var(--frame-h) - 142px - var(--safe-bottom)); z-index: 15; /* 84px above the frame bottom */
  width: 58px; height: 58px; border-radius: 50%; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: var(--accent-ink);
  box-shadow: 0 10px 30px rgba(52, 211, 153, 0.35);
}
.fab .ico { width: 28px; height: 28px; stroke-width: 2.4; }

/* ---------- Splash, auth, lock ---------- */
.splash-icon { border-radius: 18px; animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: 0.55; transform: scale(0.96); } }
.auth-card { width: 100%; max-width: 380px; padding: 28px 22px 22px; }
.brand { text-align: center; margin-bottom: 22px; }
.brand img { border-radius: 16px; margin: 0 auto 12px; display: block; }
.brand h1 { font-size: 26px; font-weight: 800; }
.brand p { color: var(--muted); margin-top: 6px; }
.lock-card { text-align: center; max-width: 340px; }
.lock-card .ico.big { width: 64px; height: 64px; color: var(--accent); margin: 0 auto 14px; display: block; stroke-width: 1.5; }

/* ---------- Setup wizard ---------- */
.steps { display: flex; gap: 6px; margin: 4px 0 18px; }
.steps span { flex: 1; height: 4px; border-radius: 2px; background: var(--surface-3); }
.steps span.done { background: var(--accent); }
.setup-title { font-size: 28px; font-weight: 800; margin-bottom: 6px; }
.setup-lead { color: var(--fg-2); margin-bottom: 18px; }
.cat-edit { display: grid; grid-template-columns: 48px 1fr 110px 36px; gap: 8px; align-items: center; margin-bottom: 8px; }
.cat-edit input, .cat-edit select { padding: 10px; font-size: 15px; }
.cat-edit .emoji-input { text-align: center; font-size: 20px; padding: 8px 4px; }

/* ---------- Charts ---------- */
.chart-card { margin: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.chart-card + .chart-card, .card + .chart-card, .chart-card + .card { margin-top: 12px; }
.chart-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; margin-bottom: 12px; }
.chart-head h3 { font-size: 17px; }
.chart-head p { font-size: 13px; margin-top: 2px; }
svg.chart { width: 100%; height: auto; display: block; overflow: visible; }
svg.chart .grid { stroke: var(--grid); stroke-width: 1; }
svg.chart .baseline { stroke: var(--axis); stroke-width: 1; }
svg.chart .axis { fill: var(--muted); font-size: 10.5px; font-variant-numeric: tabular-nums; }
svg.chart .axis.strong { fill: var(--fg); font-weight: 700; }
svg.chart .mark { transition: opacity 0.15s; }
svg.chart .mark.dim { opacity: 0.45; }
svg.chart .col-group.hot .mark, svg.chart .col-group:focus .mark { filter: brightness(1.25); }
svg.chart .hit { fill: transparent; }
svg.chart .line { fill: none; stroke: var(--s1); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
svg.chart .area { fill: var(--s1); opacity: 0.1; }
svg.chart .end-dot { fill: var(--s1); stroke: var(--surface); stroke-width: 2; }
svg.chart .pace-line { stroke: var(--muted); stroke-width: 1.5; stroke-dasharray: 2 4; }
svg.chart .proj-line { stroke: var(--s1); stroke-width: 2; stroke-dasharray: 5 5; opacity: 0.8; }
svg.chart .proj-dot { fill: var(--surface); stroke: var(--s1); stroke-width: 2; }
svg.chart .band { fill: var(--s1); opacity: 0.12; }
svg.chart .crosshair { stroke: var(--fg-2); stroke-width: 1; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; margin: -2px 0 12px; font-size: 13px; color: var(--fg-2); }
.legend-item { display: inline-flex; align-items: center; gap: 6px; }
.swatch { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.swatch.line { height: 2px; width: 14px; border-radius: 1px; }
.chart-tip {
  position: fixed; left: 0; top: 0; z-index: 100; pointer-events: none; min-width: 120px; max-width: 240px;
  background: rgba(28, 31, 39, 0.97); border: 1px solid var(--line-2); border-radius: 12px; padding: 8px 10px;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.45); font-size: 13px;
}
.tip-title { color: var(--muted); font-size: 12px; margin-bottom: 4px; }
.tip-row { display: flex; align-items: center; gap: 8px; white-space: nowrap; }
.tip-row strong { font-variant-numeric: tabular-nums; }
.tip-label { color: var(--fg-2); }
.tip-key { width: 12px; height: 3px; border-radius: 2px; flex: none; }
.hbars { display: grid; gap: 10px; }
.hbar-row { display: grid; grid-template-columns: minmax(90px, 36%) 1fr auto; gap: 10px; align-items: center; font-size: 14px; border-radius: 8px; }
.hbar-row.hot { background: var(--surface-2); }
.hbar-label { display: flex; gap: 6px; align-items: center; min-width: 0; color: var(--fg-2); }
.hbar-label span:last-child { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hbar-track { height: 10px; }
.hbar { height: 100%; border-radius: 0 4px 4px 0; }
.hbar-value { font-variant-numeric: tabular-nums; font-weight: 600; text-align: right; min-width: 70px; }
.stack-chart { display: grid; gap: 10px; }
.stack-line { display: grid; grid-template-columns: 70px 1fr; gap: 10px; align-items: center; font-size: 13px; color: var(--fg-2); }
.stack { display: flex; height: 26px; gap: 2px; border-radius: 6px; overflow: hidden; }
.stack-seg { position: relative; display: grid; place-items: center; min-width: 2px; }
.stack-seg.rest { background: var(--surface-3); }
.stack-seg.hot { filter: brightness(1.2); }
.stack-label { font-size: 12px; font-weight: 700; color: #fff; }
.heat { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.heat-head { text-align: center; font-size: 11px; color: var(--muted); padding-bottom: 2px; }
.heat-cell { aspect-ratio: 1; border-radius: 6px; position: relative; }
.heat-cell.empty { background: transparent; }
.heat-cell.hot { outline: 2px solid var(--fg); outline-offset: 1px; }
.heat-day { position: absolute; left: 5px; top: 3px; font-size: 10px; color: rgba(255, 255, 255, 0.72); }
.heat-scale { display: flex; align-items: center; gap: 4px; justify-content: flex-end; margin-top: 10px; font-size: 12px; }
.heat-swatch { width: 14px; height: 14px; border-radius: 4px; }
.table-view { margin-top: 4px; }
.tbl-wrap { overflow-x: auto; }
.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
.tbl th, .tbl td { padding: 8px 6px; border-bottom: 1px solid var(--line); text-align: left; }
.tbl th { color: var(--muted); font-weight: 600; font-size: 12px; }
.tbl .num { text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- Reports ---------- */
.bva { margin-bottom: 14px; }
.bva-top { display: flex; justify-content: space-between; gap: 10px; font-size: 14px; }
.bva-name { min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--fg-2); }
.bva-amt { flex: none; font-variant-numeric: tabular-nums; }
.bva-over { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; color: var(--critical-ink); margin-top: 5px; }
.bva-over .ico { width: 13px; height: 13px; }
.report-hero { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.big-stat { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 14px; min-width: 0; }
.big-stat .v { font: 800 clamp(16px, 4.6vw, 22px)/1.2 var(--font-display); margin-top: 4px; letter-spacing: -0.02em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.big-stat .d { font-size: 13px; color: var(--muted); margin-top: 3px; }
.big-stat .d.up-bad { color: var(--critical-ink); }
.big-stat .d.down-good { color: #6ee26e; }
.ai-card { background: linear-gradient(160deg, rgba(57, 135, 229, 0.14), rgba(21, 23, 29, 0.95) 60%); border: 1px solid rgba(57, 135, 229, 0.3); }
.ai-card .ai-head { display: flex; align-items: center; gap: 8px; color: #9ec5f4; font-weight: 700; font-size: 14px; margin-bottom: 8px; }
.md h3 { font-size: 17px; margin: 14px 0 6px; }
.md h4 { font-size: 15px; margin: 12px 0 4px; }
.md p { margin: 6px 0; color: var(--fg-2); }
.md ul { margin: 6px 0; padding-left: 20px; color: var(--fg-2); }
.md li { margin: 4px 0; }
.md strong { color: var(--fg); }
.md-table { overflow-x: auto; margin: 8px 0; }
.md-table table { border-collapse: collapse; font-size: 13px; }
.md-table th, .md-table td { border-bottom: 1px solid var(--line); padding: 6px 8px; text-align: left; }
.skeleton { background: linear-gradient(90deg, var(--surface-2), var(--surface-3), var(--surface-2)); background-size: 200% 100%; animation: shimmer 1.4s infinite; border-radius: 12px; }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }

/* ---------- Advisor ---------- */
.chat { display: flex; flex-direction: column; gap: 10px; padding-bottom: 8px; }
.msg { max-width: 88%; padding: 11px 14px; border-radius: 18px; font-size: 15px; }
.msg.user { align-self: flex-end; background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: var(--accent-ink); border-bottom-right-radius: 6px; white-space: pre-wrap; }
.msg.assistant { align-self: flex-start; background: var(--surface); border: 1px solid var(--line); border-bottom-left-radius: 6px; }
.msg.assistant .md p:first-child { margin-top: 0; }
.chat-input {
  position: relative; flex: none; z-index: 12;
  padding: 8px 16px; background: var(--bg); border-top: 1px solid var(--line);
}
.chat-input form { max-width: 648px; margin: 0 auto; display: flex; gap: 8px; }
.chat-input input { border-radius: 22px; }
.chat-input .btn { border-radius: 50%; width: 48px; height: 48px; padding: 0; flex: none; }
.suggestions { display: flex; flex-wrap: wrap; gap: 8px; margin: 6px 0 14px; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; top: calc(var(--frame-h) - 96px - var(--safe-bottom)); transform: translate(-50%, -100%); z-index: 200;
  max-width: calc(100% - 32px); padding: 11px 16px; border-radius: 14px; font-size: 15px;
  background: rgba(37, 41, 52, 0.97); border: 1px solid var(--line-2); box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
  animation: toast-in 0.25s ease both;
}
.toast.good { border-color: rgba(52, 211, 153, 0.5); }
.toast.bad { border-color: rgba(208, 59, 59, 0.6); }
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, calc(-100% + 8px)); } to { opacity: 1; transform: translate(-50%, -100%); } }

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

/* Face ID lock on top of the open app (keeps whatever was being typed) */
#lockView.lock-overlay { position: fixed; inset: 0 0 auto 0; height: var(--frame-h); z-index: 90; background: color-mix(in srgb, var(--bg) 82%, transparent); -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px); }

/* ---- Bank details card (Inbox) ---- */
.bank-card .bank-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.bank-badge { font-weight: 800; font-size: 12px; padding: 3px 9px; border-radius: 8px; background: var(--surface-2, #2a2f3a); color: #fff; letter-spacing: .02em; }
.bank-badge.bca { background: #0060af; }
.bank-badge.mandiri { background: #003d79; color: #ffcf00; }
.bank-card .mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px; word-break: break-all; }
.bank-card dl.small { margin-top: 8px; font-size: 13px; }
.bank-card dd.full { grid-column: 1 / -1; color: var(--muted); margin: 0; }
.owner-pick { display: inline-flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-left: 6px; }
.chip.small { padding: 3px 10px; font-size: 13px; }

/* Savings page */
.li-icon.accent { color: var(--accent); }
.goal-ico { display: inline-grid; place-items: center; color: var(--accent); }
.goal-ico .ico { width: 20px; height: 20px; }
.hold-row { grid-column: 1 / -1; margin-top: -2px; }
.hold-row select { font-size: 14px; padding-top: 8px; padding-bottom: 8px; color: var(--accent); }

/* Plan wallets: last month under each wallet; warning when the plan is below what it really cost */
.alloc-hint { font-size: 12px; color: var(--muted); margin-top: 2px; line-height: 1.3; }
.alloc-hint.warn { color: var(--warning-ink); }
.assign-bar + .row .btn { flex: 1; min-width: 0; }

/* Briefing + next month */
.brief-headline { font: 650 17px/1.35 var(--font-display); margin: 0 0 10px; }
.brief-h { font-size: 13px; font-weight: 700; color: var(--fg-2); margin: 12px 0 4px; }
.brief-list { margin: 0; padding-left: 18px; display: grid; gap: 6px; font-size: 14px; line-height: 1.4; }
.li-amount.ok { color: var(--good); }
.li-amount.bad { color: var(--critical-ink); }
.li-amount.warn { color: var(--warning-ink); }
.next-month { border-color: rgba(57, 135, 229, 0.35); }
.next-month .chips { margin: 0; }
.nm-title { font: 700 16px/1.3 var(--font-display); }
.next-month .pill { flex: none; }
.segmented .seg-sub { font-size: 11px; font-weight: 500; opacity: 0.8; margin-top: 1px; }
.li-title.wrap { white-space: normal; overflow: visible; }
.li-sub.wrap { white-space: normal; display: block; }

/* Monthly meeting (rapat bulanan) */
.agree-list { display: grid; gap: 8px; margin-top: 4px; }
.agree { padding: 10px 12px; border-radius: 12px; background: var(--surface-2); display: grid; gap: 3px; }
.agree .row { gap: 10px; align-items: flex-start; }
.agree-text { font-weight: 600; font-size: 14px; line-height: 1.35; }
.agree .pill { flex: none; }
.suggest { padding: 12px 0; border-top: 1px solid var(--line); display: grid; gap: 4px; }
.suggest:first-of-type { border-top: 0; padding-top: 4px; }

.suggest .pill { justify-self: start; }
.card.fold > summary { font-weight: 650; cursor: pointer; list-style: none; display: flex; justify-content: space-between; align-items: center; gap: 10px; min-height: 28px; }
.card.fold > summary::-webkit-details-marker { display: none; }
.card.fold > summary::after { content: ""; flex: none; width: 8px; height: 8px; border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted); transform: rotate(45deg); transition: transform 0.2s; margin-right: 4px; }
.card.fold[open] > summary::after { transform: rotate(-135deg); }
.card.fold[open] > summary { margin-bottom: 10px; }
.result-card { border: 1px solid rgba(52, 211, 153, 0.4); background: linear-gradient(160deg, rgba(52, 211, 153, 0.12), rgba(21, 23, 29, 0.95) 60%); }
.result-card .ai-head { display: flex; align-items: center; gap: 8px; color: #6ee7b7; font-weight: 700; font-size: 14px; margin-bottom: 8px; }
.meeting-input textarea { border-radius: 22px; resize: none; min-height: 48px; max-height: 120px; padding: 12px 16px; line-height: 1.35; }
.note-chips { margin: 0 0 8px; }
.suggest-action { margin-top: 6px; }
.list .day-sub { padding: 10px 14px 4px; font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 0.03em; border-bottom: 1px solid var(--line); }
.emoji-input { text-align: center; font-size: 20px; padding: 8px 4px; }
.plan-card .group-head { margin-top: 12px; }
.plan-name { font-weight: 600; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.alloc-row.is-new { background: rgba(57, 135, 229, 0.08); }
.alloc-row.is-archived { opacity: 0.7; }
.alloc-row .icon-btn.small, .alloc-row .btn.small { flex: none; }
.icon-btn.small { width: 36px; height: 36px; }
.icon-btn.small .ico { width: 18px; height: 18px; }
.plan-totals { margin: 4px 0 2px; }
.msg-changes { margin-top: 10px; padding-top: 8px; border-top: 1px solid var(--line); font-size: 13px; color: var(--fg-2); }
.msg-changes-head { display: flex; align-items: center; gap: 6px; font-weight: 700; color: #9ec5f4; margin-bottom: 4px; }
.msg-changes-head .ico { width: 14px; height: 14px; }
.msg-changes ul { margin: 0; padding-left: 18px; display: grid; gap: 2px; }
/* Plan card rows: name on the first line, amount (+ bin) on the second, so long wallet names stay readable */
.plan-card .alloc-row { flex-wrap: wrap; row-gap: 8px; }
.plan-card .alloc-row > .grow { flex: 1 1 calc(100% - 44px); min-width: 0; }
.plan-card .alloc-row .money-wrap { flex: 1 1 0; min-width: 0; width: auto; margin-left: 34px; }
.plan-card .alloc-row.is-archived > .grow { flex-basis: calc(100% - 140px); }
