:root {
  --bg: #F3F7FE;
  --card: #FFFFFF;
  --ink: #0E1220;
  --muted: #8A90A2;
  --line: #ECEFF5;
  --blue: #3B82F6;
  --blue-soft: #DCE8FF;
  --needs: #A3A1F7;
  --wants: #8FD9C8;
  --savings: #F28B9B;
  --up: #16A34A;
  --up-bg: #E3F8EA;
  --down: #DC2626;
  --down-bg: #FDE8E8;
  --serif: "DM Serif Display", Georgia, serif;
  --sans: "Plus Jakarta Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--ink); font-family: var(--sans); font-size: 15px; }
body { overscroll-behavior: none; }
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; }
input, select, textarea { font: inherit; color: inherit; }
#app { max-width: 480px; margin: 0 auto; min-height: 100%; position: relative; }

/* ---------- onboarding ---------- */
.onboard { min-height: 100vh; display: flex; flex-direction: column; background: #fff; padding: calc(var(--safe-top) + 12px) 24px calc(var(--safe-bottom) + 28px); text-align: center; overflow: hidden; }
.onboard .rings { position: relative; overflow: hidden; height: 46vh; min-height: 300px; margin: 0 -24px; display: flex; align-items: flex-end; justify-content: center; }
.onboard .rings span { position: absolute; bottom: 0; left: 50%; transform: translate(-50%, 50%); border-radius: 50%; background: radial-gradient(circle at 50% 100%, rgba(59,130,246,.0) 40%, rgba(59,130,246,.10) 100%); border: 1px solid rgba(59,130,246,.08); }
.onboard .rings span:nth-child(1) { width: 640px; height: 640px; }
.onboard .rings span:nth-child(2) { width: 470px; height: 470px; }
.onboard .rings span:nth-child(3) { width: 310px; height: 310px; }
.onboard .rings span:nth-child(4) { width: 170px; height: 170px; background: radial-gradient(circle, #fff 20%, rgba(59,130,246,.18) 100%); }
.onboard .logo { position: relative; z-index: 1; width: 52px; height: 52px; margin-bottom: 4px; }
.onboard h1 { font-weight: 600; font-size: 32px; line-height: 1.15; margin: 26px 0 12px; letter-spacing: -.5px; }
.onboard h1 em { font-style: normal; color: var(--blue); display: block; }
.onboard p { color: #555B6E; line-height: 1.5; margin: 0 auto; max-width: 300px; }
.dots { display: flex; gap: 6px; justify-content: center; margin: 22px 0 auto; }
.dots i { width: 6px; height: 6px; border-radius: 3px; background: #D5D9E2; }
.dots i.on { width: 20px; background: var(--blue); }
.btn { display: block; width: 100%; padding: 16px; border-radius: 999px; background: var(--ink); color: #fff; font-weight: 600; margin-top: 28px; }
.btn.blue { background: var(--blue); }
.btn.ghost { background: var(--card); color: var(--ink); border: 1px solid var(--line); margin-top: 10px; }
.onboard input { width: 100%; padding: 15px 18px; border-radius: 16px; border: 1px solid var(--line); background: var(--bg); text-align: center; margin-top: 20px; outline: none; }

/* ---------- layout ---------- */
.screen { padding: calc(var(--safe-top) + 16px) 16px calc(var(--safe-bottom) + 110px); }
.topbar { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.avatar { width: 44px; height: 44px; border-radius: 50%; background: linear-gradient(135deg, #3B82F6, #A3A1F7); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 17px; flex: none; }
.topbar .hello small { display: block; color: var(--muted); font-size: 12.5px; }
.topbar .hello b { font-size: 18px; font-weight: 600; }
.topbar h2 { font-size: 24px; font-weight: 600; margin: 0; }
.icon-btn { margin-left: auto; width: 40px; height: 40px; border-radius: 50%; background: var(--card); border: 1px solid var(--line); display: grid; place-items: center; position: relative; flex: none; }
.icon-btn svg { width: 18px; height: 18px; }
.icon-btn .badge { position: absolute; top: 6px; right: 8px; width: 8px; height: 8px; border-radius: 50%; background: var(--savings); border: 2px solid #fff; }
.card { background: var(--card); border-radius: 22px; padding: 16px; margin-bottom: 12px; box-shadow: 0 1px 2px rgba(16,24,40,.03); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid2 .card { margin-bottom: 12px; }
.card-head { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 14px; }
.card-head .chip-ico { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; font-size: 13px; flex: none; }
.card-head .info { margin-left: auto; width: 20px; height: 20px; border: 1.5px solid #B8BDC9; color: #8A90A2; border-radius: 50%; font-size: 11px; display: grid; place-items: center; font-weight: 700; }
.card-head .sel { margin-left: auto; font-size: 12px; font-weight: 500; border: 1px solid var(--line); border-radius: 999px; padding: 5px 10px; background: #fff; }
.big { font-family: var(--serif); font-size: 30px; margin: 12px 0 6px; letter-spacing: .2px; line-height: 1; }
.big.lg { font-size: 34px; }
.sub { color: var(--muted); font-size: 11.5px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.sub b { color: var(--ink); font-weight: 600; }
.pill { font-size: 10.5px; font-weight: 600; padding: 3px 7px; border-radius: 999px; background: var(--up-bg); color: var(--up); white-space: nowrap; }
.pill.down { background: var(--down-bg); color: var(--down); }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.legend { display: flex; justify-content: center; gap: 16px; font-size: 12px; color: #555B6E; margin-top: 10px; flex-wrap: wrap; }
.legend i { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 6px; vertical-align: 0; }
.bars { display: flex; align-items: flex-end; gap: 3px; height: 54px; margin-top: 14px; }
.bars i { flex: 1; border-radius: 3px; min-height: 6px; }
.gauge { position: relative; margin: 10px auto 0; max-width: 300px; }
.gauge svg { display: block; width: 100%; height: auto; }
.gauge .center { position: absolute; left: 0; right: 0; bottom: 6px; text-align: center; }
.gauge .center b { font-family: var(--serif); font-size: 32px; font-weight: 400; display: block; }
.gauge .center span { font-size: 12.5px; color: #555B6E; }
.note { text-align: center; color: var(--muted); font-size: 11.5px; margin-top: 8px; }
.arrow-btn { margin-left: auto; width: 32px; height: 32px; border-radius: 50%; border: 1px solid var(--line); display: grid; place-items: center; }

/* ---------- donut ---------- */
.donut-wrap { display: flex; align-items: center; gap: 12px; margin-top: 10px; }
.donut { position: relative; width: 170px; flex: none; }
.donut svg { width: 100%; height: auto; display: block; transform: rotate(-90deg); }
.donut .center { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; }
.donut .center b { font-family: var(--serif); font-size: 28px; font-weight: 400; }
.donut .center span { font-size: 11.5px; color: #555B6E; }
.dlist { flex: 1; display: flex; flex-direction: column; gap: 14px; }
.dlist div { font-size: 11.5px; color: #555B6E; }
.dlist div i { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 6px; }
.dlist div b { display: block; font-size: 15px; color: var(--ink); margin: 3px 0 0 15px; }

/* ---------- area chart ---------- */
.area { margin-top: 10px; position: relative; }
.area svg { width: 100%; height: auto; display: block; overflow: visible; }
.area text { font-size: 9px; fill: #8A90A2; font-family: var(--sans); }

/* ---------- lists ---------- */
.seg { display: flex; background: var(--card); border-radius: 999px; padding: 4px; margin-bottom: 12px; gap: 4px; }
.seg button { flex: 1; padding: 9px 4px; border-radius: 999px; font-size: 13px; font-weight: 600; color: var(--muted); }
.seg button.on { background: var(--ink); color: #fff; }
.day-label { font-size: 12px; color: var(--muted); font-weight: 600; margin: 16px 4px 8px; text-transform: uppercase; letter-spacing: .5px; }
.txn { display: flex; align-items: center; gap: 12px; padding: 12px 4px; border-bottom: 1px solid var(--line); }
.txn:last-child { border-bottom: 0; }
.txn .ico { width: 40px; height: 40px; border-radius: 14px; display: grid; place-items: center; font-size: 18px; flex: none; }
.txn .mid { flex: 1; min-width: 0; }
.txn .mid b { display: block; font-weight: 600; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.txn .mid small { color: var(--muted); font-size: 12px; }
.txn .amt { font-weight: 700; font-size: 14px; white-space: nowrap; }
.txn .amt.in { color: var(--up); }
.empty { text-align: center; color: var(--muted); padding: 28px 12px; font-size: 13.5px; line-height: 1.5; }
.empty .e-ico { font-size: 34px; display: block; margin-bottom: 6px; }
.actions { display: flex; gap: 8px; margin-bottom: 12px; }
.actions button { flex: 1; background: var(--card); border-radius: 16px; padding: 12px 6px; font-size: 12.5px; font-weight: 600; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.actions button span { font-size: 18px; }

/* budget rows */
.grp-title { display: flex; justify-content: space-between; align-items: baseline; margin: 6px 2px 10px; }
.grp-title b { font-size: 15px; }
.grp-title small { color: var(--muted); font-size: 12px; }
.brow { padding: 10px 0; border-bottom: 1px solid var(--line); }
.brow:last-child { border-bottom: 0; }
.brow .top { display: flex; justify-content: space-between; font-size: 13.5px; gap: 10px; }
.brow .top span:first-child { font-weight: 600; }
.brow .top span:last-child { color: var(--muted); white-space: nowrap; }
.track { height: 8px; background: var(--bg); border-radius: 99px; margin-top: 8px; overflow: hidden; }
.track i { display: block; height: 100%; border-radius: 99px; }
.ratio { display: flex; height: 12px; border-radius: 99px; overflow: hidden; margin: 12px 0 8px; }
.kv { display: flex; justify-content: space-between; padding: 9px 0; font-size: 13.5px; border-bottom: 1px solid var(--line); }
.kv:last-child { border-bottom: 0; }
.kv span:first-child { color: #555B6E; }
.kv b { font-weight: 600; }
.kv.total { font-size: 15px; }
.kv.total span:first-child { color: var(--ink); font-weight: 600; }
.link { color: var(--blue); font-weight: 600; font-size: 13px; }

/* ---------- nav ---------- */
.nav { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--safe-bottom) + 14px); width: min(440px, calc(100% - 32px)); background: rgba(255,255,255,.92); backdrop-filter: blur(12px); border-radius: 999px; padding: 8px; display: flex; justify-content: space-between; box-shadow: 0 8px 30px rgba(16,24,40,.10); z-index: 10; }
.nav button { width: 52px; height: 52px; border-radius: 50%; background: var(--bg); display: grid; place-items: center; color: #8A90A2; }
.nav button svg { width: 21px; height: 21px; }
.nav button.on { background: var(--ink); color: #fff; }

/* ---------- sheet ---------- */
.overlay { position: fixed; inset: 0; background: rgba(14,18,32,.35); z-index: 20; display: flex; align-items: flex-end; justify-content: center; animation: fade .15s; }
.sheet { background: #fff; width: 100%; max-width: 480px; border-radius: 26px 26px 0 0; padding: 10px 20px calc(var(--safe-bottom) + 22px); max-height: 92vh; overflow-y: auto; animation: up .2s ease-out; }
.sheet .grab { width: 40px; height: 5px; border-radius: 3px; background: #DDE1E8; margin: 0 auto 14px; }
.sheet h3 { margin: 0 0 4px; font-size: 19px; }
.sheet p.hint { margin: 0 0 14px; color: var(--muted); font-size: 13px; line-height: 1.45; }
.field { margin-bottom: 12px; }
.field label { display: block; font-size: 12px; color: var(--muted); font-weight: 600; margin-bottom: 6px; }
.field input, .field select, .field textarea { width: 100%; padding: 13px 14px; border-radius: 14px; border: 1px solid var(--line); background: var(--bg); outline: none; }
.field textarea { min-height: 110px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--blue); }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.toggle { display: flex; background: var(--bg); border-radius: 14px; padding: 4px; }
.toggle button { flex: 1; padding: 10px; border-radius: 11px; font-weight: 600; font-size: 13px; color: var(--muted); }
.toggle button.on { background: #fff; color: var(--ink); box-shadow: 0 1px 3px rgba(0,0,0,.08); }
.danger { color: var(--down); }
@keyframes up { from { transform: translateY(40px); opacity: .5 } }
@keyframes fade { from { opacity: 0 } }

#toast { position: fixed; left: 50%; bottom: calc(var(--safe-bottom) + 96px); transform: translateX(-50%); background: var(--ink); color: #fff; padding: 11px 18px; border-radius: 999px; font-size: 13px; opacity: 0; pointer-events: none; transition: opacity .2s; z-index: 30; max-width: 90%; text-align: center; }
#toast.on { opacity: 1; }
.banner { display: flex; gap: 12px; align-items: center; background: linear-gradient(135deg, #3B82F6, #6D8DF8); color: #fff; border-radius: 22px; padding: 16px; margin-bottom: 12px; }
.banner b { display: block; font-size: 14px; }
.banner small { opacity: .85; font-size: 12px; }
.banner button { margin-left: auto; background: #fff; color: var(--blue); font-weight: 700; padding: 9px 14px; border-radius: 999px; font-size: 12.5px; white-space: nowrap; }

/* ---------- tour ---------- */
#tour { position: fixed; inset: 0; z-index: 40; background: rgba(14,18,32,.45); display: flex; align-items: flex-end; justify-content: center; padding: 0 16px calc(var(--safe-bottom) + 20px); animation: fade .2s; }
.tour-card { background: #fff; border-radius: 24px; padding: 18px; width: 100%; max-width: 440px; animation: up .25s ease-out; }
.tour-card small { color: var(--blue); font-weight: 700; font-size: 11.5px; text-transform: uppercase; letter-spacing: .6px; }
.tour-card b { display: block; font-size: 18px; margin: 6px 0; }
.tour-card p { color: #555B6E; font-size: 14px; line-height: 1.5; margin: 0 0 14px; }
.tour-hl { position: relative; z-index: 41; box-shadow: 0 0 0 4px #fff, 0 0 0 7px var(--blue); border-radius: 22px; }
