:root{
  --bg:#0f172a; --card:#1e293b; --card2:#273449; --line:#334155;
  --text:#e2e8f0; --muted:#94a3b8; --green:#22c55e; --red:#f87171;
  --accent:#38bdf8; --chip:#334155; --warn:#f59e0b;
}
*{box-sizing:border-box}
html,body{margin:0}
body{
  font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Arial,sans-serif;
  background:var(--bg); color:var(--text);
  padding:0 16px calc(96px + env(safe-area-inset-bottom));
  max-width:760px; margin:0 auto; -webkit-tap-highlight-color:transparent;
}
header{padding:18px 0 6px; position:sticky; top:0; background:var(--bg); z-index:5}
h1{font-size:19px; margin:0; display:flex; align-items:center; gap:8px}
.sub{color:var(--muted); font-size:13px; margin-top:2px}
.row-between{display:flex; justify-content:space-between; align-items:center; gap:10px}
.green{color:var(--green)} .red{color:var(--red)} .warn{color:var(--warn)} .muted{color:var(--muted)}

/* balance + cards */
.balance{background:linear-gradient(135deg,#1e293b,#0b2436); border:1px solid var(--line); border-radius:18px; padding:20px; margin:14px 0}
.balance .label{color:var(--muted); font-size:13px}
.balance .amt{font-size:32px; font-weight:700; margin-top:4px}
.cards{display:grid; grid-template-columns:1fr 1fr; gap:12px}
.card{background:var(--card); border:1px solid var(--line); border-radius:16px; padding:14px}
.card .t{color:var(--muted); font-size:12px; text-transform:uppercase; letter-spacing:.04em}
.card .v{font-size:21px; font-weight:700; margin-top:6px}

section{margin:20px 0}
.h2{font-size:15px; font-weight:600; margin:0 0 10px; display:flex; justify-content:space-between; align-items:center; gap:8px}
.h2 .muted{font-weight:400; font-size:12px}

/* bars */
.bar-row{display:flex; align-items:center; gap:10px; margin:9px 0; cursor:pointer}
.bar-row .ic{width:30px;height:30px;border-radius:9px;display:grid;place-items:center;font-size:15px;flex:0 0 auto}
.bar-row .nm{flex:0 0 108px; font-size:13px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap}
.track{flex:1; height:8px; background:var(--card2); border-radius:6px; overflow:hidden}
.fill{height:100%; border-radius:6px}
.bar-row .amt{flex:0 0 auto; font-size:13px; font-variant-numeric:tabular-nums; color:var(--muted)}

/* budgets */
.budget{background:var(--card); border:1px solid var(--line); border-radius:14px; padding:12px 14px; margin:10px 0}
.budget .top{display:flex; justify-content:space-between; font-size:13px; margin-bottom:8px}
.budget .trackB{height:10px; background:var(--card2); border-radius:6px; overflow:hidden}
.budget .fillB{height:100%; border-radius:6px}

/* controls */
.controls{display:flex; gap:8px; margin-bottom:10px; flex-wrap:wrap}
input,select,textarea{
  background:var(--card); border:1px solid var(--line); color:var(--text);
  border-radius:12px; padding:11px 13px; font-size:14px; outline:none; font-family:inherit; width:100%
}
input[type=search]{flex:1}
label.fld{display:block; margin:12px 0 0}
label.fld .lab{font-size:12px; color:var(--muted); margin-bottom:5px; display:block}
.chips{display:flex; gap:8px; overflow-x:auto; padding-bottom:6px; margin-bottom:6px; scrollbar-width:none}
.chips::-webkit-scrollbar{display:none}
.chip{white-space:nowrap; background:var(--chip); color:var(--text); border:1px solid var(--line); padding:7px 12px; border-radius:999px; font-size:13px; cursor:pointer}
.chip.on{background:var(--accent); color:#06283d; border-color:var(--accent); font-weight:600}

/* txn list */
.datehdr{margin:16px 0 4px; color:var(--muted); font-weight:600; font-size:13px}
.txn{display:flex; align-items:center; gap:12px; padding:12px 0; border-bottom:1px solid var(--line); cursor:pointer}
.txn .ic{width:40px;height:40px;border-radius:12px;display:grid;place-items:center;font-size:18px;flex:0 0 auto}
.txn .mid{flex:1; min-width:0}
.txn .nm{font-size:14px; font-weight:600; white-space:nowrap; overflow:hidden; text-overflow:ellipsis}
.txn .meta{font-size:12px; color:var(--muted); margin-top:2px}
.txn .val{font-size:15px; font-weight:700; font-variant-numeric:tabular-nums; flex:0 0 auto}

/* trend */
.trend{display:flex; align-items:flex-end; gap:8px; height:130px; padding-top:6px}
.trend .col{flex:1; display:flex; flex-direction:column; align-items:center; gap:6px; height:100%}
.trend .stack{flex:1; width:100%; display:flex; flex-direction:column; justify-content:flex-end; gap:3px}
.trend .seg{width:100%; border-radius:4px}
.trend .lbl{font-size:11px; color:var(--muted)}
.legend{display:flex; gap:16px; font-size:12px; color:var(--muted); margin-top:8px}
.dot{display:inline-block;width:9px;height:9px;border-radius:3px;margin-right:5px;vertical-align:middle}

/* buttons */
.btn{display:inline-flex; align-items:center; justify-content:center; gap:7px; background:var(--accent); color:#06283d; border:none; border-radius:12px; padding:12px 16px; font-weight:600; font-size:14px; cursor:pointer; width:100%}
.btn.sec{background:var(--card); color:var(--text); border:1px solid var(--line)}
.btn.danger{background:#7f1d1d; color:#fecaca}
.btn.sm{padding:8px 12px; font-size:13px; width:auto}
.btn-row{display:flex; gap:10px; margin-top:16px}

/* fab */
.fab{position:fixed; right:calc(50% - 356px); bottom:calc(84px + env(safe-area-inset-bottom)); width:56px; height:56px; border-radius:18px; background:var(--accent); color:#06283d; border:none; font-size:28px; box-shadow:0 8px 24px rgba(0,0,0,.4); cursor:pointer; z-index:8}
@media (max-width:792px){ .fab{right:20px} }

/* nav */
.nav{position:fixed; left:0; right:0; bottom:0; display:flex; justify-content:center; gap:4px; background:rgba(15,23,42,.94); backdrop-filter:blur(8px); border-top:1px solid var(--line); padding:8px 8px calc(8px + env(safe-area-inset-bottom))}
.nav button{flex:1; max-width:150px; background:none; border:none; color:var(--muted); font-size:11px; display:flex; flex-direction:column; align-items:center; gap:3px; padding:6px; cursor:pointer}
.nav button .i{font-size:19px}
.nav button.on{color:var(--accent)}

.view{display:none} .view.on{display:block}
.empty{color:var(--muted); text-align:center; padding:30px 0; font-size:14px}

/* modal / sheet */
.sheet-bg{position:fixed; inset:0; background:rgba(0,0,0,.55); z-index:20; display:none}
.sheet-bg.on{display:block}
.sheet{position:fixed; left:0; right:0; bottom:0; max-width:760px; margin:0 auto; background:var(--bg); border-top-left-radius:20px; border-top-right-radius:20px; border:1px solid var(--line); z-index:21; max-height:92vh; overflow-y:auto; padding:16px 16px calc(24px + env(safe-area-inset-bottom)); transform:translateY(100%); transition:transform .22s ease}
.sheet.on{transform:translateY(0)}
.sheet .grab{width:40px;height:4px;background:var(--line);border-radius:3px;margin:2px auto 12px}
.sheet h3{margin:4px 0 8px; font-size:17px}

/* lock screen */
.lock{position:fixed; inset:0; background:var(--bg); z-index:50; display:flex; flex-direction:column; align-items:center; justify-content:center; gap:18px; padding:24px}
.lock .logo{font-size:40px}
.pindots{display:flex; gap:14px}
.pindots span{width:14px;height:14px;border-radius:50%; border:2px solid var(--muted)}
.pindots span.f{background:var(--accent); border-color:var(--accent)}
.keypad{display:grid; grid-template-columns:repeat(3,72px); gap:14px}
.keypad button{height:72px; border-radius:50%; border:1px solid var(--line); background:var(--card); color:var(--text); font-size:24px; cursor:pointer}
.keypad button.blank{background:none; border:none; cursor:default}
.lockmsg{color:var(--muted); font-size:13px; min-height:18px}

/* segmented */
.seg2{display:flex; background:var(--card2); border-radius:12px; padding:4px; gap:4px}
.seg2 button{flex:1; border:none; background:none; color:var(--muted); padding:9px; border-radius:9px; font-size:14px; font-weight:600; cursor:pointer}
.seg2 button.on{background:var(--accent); color:#06283d}
.seg2.income button.on{background:var(--green)}
.seg2.expense button.on{background:var(--red); color:#fff}

/* import table */
.imp-row{display:grid; grid-template-columns:70px 1fr 90px 36px; gap:8px; align-items:center; padding:8px 0; border-bottom:1px solid var(--line); font-size:12px}
.imp-row input{padding:7px 9px; font-size:12px}
.imp-row .x{background:none;border:none;color:var(--red);font-size:18px;cursor:pointer}
.imp-head{display:grid; grid-template-columns:70px 1fr 90px 36px; gap:8px; font-size:11px; color:var(--muted); padding-bottom:6px; border-bottom:1px solid var(--line)}

.pill{display:inline-block; font-size:11px; padding:2px 8px; border-radius:999px; background:var(--card2); color:var(--muted); margin-left:6px}
.listitem{display:flex; align-items:center; gap:10px; padding:12px 0; border-bottom:1px solid var(--line)}
.listitem .ic{width:34px;height:34px;border-radius:10px;display:grid;place-items:center;font-size:16px}
.toast{position:fixed; left:50%; transform:translateX(-50%); bottom:calc(120px + env(safe-area-inset-bottom)); background:#111827; color:#fff; padding:10px 16px; border-radius:12px; font-size:13px; z-index:60; opacity:0; transition:opacity .2s; border:1px solid var(--line)}
.toast.on{opacity:1}
.thumb{width:100%; max-height:200px; object-fit:contain; border-radius:12px; margin-top:8px; background:var(--card2)}
.note-sm{font-size:12px; color:var(--muted); margin-top:6px; line-height:1.5}
