/* FinSync — native WebView UI. GPay / Material 3 look, light + dark. */
@font-face { font-family: 'DM Sans'; font-weight: 400; font-display: block; src: url(fonts/dm-sans-latin-400-normal.woff2) format('woff2'); }
@font-face { font-family: 'DM Sans'; font-weight: 500; font-display: block; src: url(fonts/dm-sans-latin-500-normal.woff2) format('woff2'); }
@font-face { font-family: 'DM Sans'; font-weight: 600; font-display: block; src: url(fonts/dm-sans-latin-600-normal.woff2) format('woff2'); }
@font-face { font-family: 'DM Sans'; font-weight: 700; font-display: block; src: url(fonts/dm-sans-latin-700-normal.woff2) format('woff2'); }
@font-face { font-family: 'Symbols'; font-weight: 100 700; font-display: block; src: url(fonts/symbols.woff2) format('woff2'); }

:root {
  --bg: #ffffff; --surface: #ffffff; --surface2: #f1f3f4; --border: #eceff1; --border-hi: #dadce0;
  --text: #202124; --text2: #5f6368; --text3: #80868b;
  --accent: #1a73e8; --accent-wash: #e8f0fe; --on-accent: #ffffff;
  --pos: #1e8e3e; --neg: #d93025; --pos-wash: #e6f4ea; --neg-wash: #fce8e6;
  --brand: #1a73e8; --brand-deep: #185abc;
  --shadow: 0 1px 2px rgba(60,64,67,.12), 0 2px 6px rgba(60,64,67,.08);
  --scrim: rgba(32,33,36,.38);
  /* category tones: fg / bg */
  --t0: #1a73e8; --t0b: #e8f0fe; --t1: #e8710a; --t1b: #feefe3; --t2: #1e8e3e; --t2b: #e6f4ea;
  --t3: #b06000; --t3b: #fef7e0; --t4: #9334e6; --t4b: #f3e8fd; --t5: #d93025; --t5b: #fce8e6;
  --t6: #12805c; --t6b: #e0f2ef; --t7: #d01884; --t7b: #fde7f3; --t8: #4355b9; --t8b: #e8eafd;
  --t9: #5f6368; --t9b: #f1f3f4;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #131314; --surface: #1e1f20; --surface2: #2d2f31; --border: #2a2b2d; --border-hi: #3c4043;
    --text: #e8eaed; --text2: #9aa0a6; --text3: #80868b;
    --accent: #8ab4f8; --accent-wash: rgba(138,180,248,.15); --on-accent: #131314;
    --pos: #81c995; --neg: #f28b82; --pos-wash: rgba(129,201,149,.14); --neg-wash: rgba(242,139,130,.14);
    --shadow: none; --scrim: rgba(0,0,0,.55);
    --t0: #8ab4f8; --t0b: rgba(138,180,248,.15); --t1: #fcad70; --t1b: rgba(252,173,112,.14);
    --t2: #81c995; --t2b: rgba(129,201,149,.14); --t3: #fdd663; --t3b: rgba(253,214,99,.13);
    --t4: #d7aefb; --t4b: rgba(215,174,251,.14); --t5: #f28b82; --t5b: rgba(242,139,130,.14);
    --t6: #78d9ec; --t6b: rgba(120,217,236,.14); --t7: #ff8bcb; --t7b: rgba(255,139,203,.14);
    --t8: #a8b1ff; --t8b: rgba(168,177,255,.14); --t9: #bdc1c6; --t9b: rgba(189,193,198,.14);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg); color: var(--text);
  font: 400 14px/1.4 'DM Sans', system-ui, sans-serif;
  -webkit-font-smoothing: antialiased; overscroll-behavior: none;
  user-select: none; -webkit-user-select: none;
}
input, textarea, select, button { font: inherit; color: inherit; }
input, textarea { user-select: text; -webkit-user-select: text; }
button { background: none; border: 0; padding: 0; cursor: pointer; }
.num { font-variant-numeric: tabular-nums; }
.i { font-family: 'Symbols'; font-weight: 400; font-style: normal; font-size: 22px; line-height: 1;
  letter-spacing: normal; text-transform: none; display: inline-block; white-space: nowrap;
  direction: ltr; font-feature-settings: 'liga'; -webkit-font-smoothing: antialiased;
  font-variation-settings: 'FILL' 0, 'wght' 400, 'opsz' 24; vertical-align: middle; }
.i.fill { font-variation-settings: 'FILL' 1, 'wght' 400, 'opsz' 24; }

/* ── App shell ── */
#app { height: 100%; display: flex; flex-direction: column; }
#view { flex: 1; overflow-y: auto; overflow-x: hidden; padding-bottom: 96px; -webkit-overflow-scrolling: touch; }
nav.tabs { flex: none; display: grid; grid-template-columns: repeat(6, 1fr); background: var(--surface);
  border-top: 1px solid var(--border); height: 68px; }
nav.tabs button { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  color: var(--text2); font-size: 11.5px; font-weight: 500; }
nav.tabs .pill { width: 56px; height: 30px; border-radius: 15px; display: grid; place-items: center; transition: background .2s; }
nav.tabs button.on { color: var(--text); }
nav.tabs button.on .pill { background: var(--accent-wash); }
nav.tabs button.on .i { color: var(--accent); font-variation-settings: 'FILL' 1, 'wght' 500, 'opsz' 24; }

.fab { position: fixed; right: 18px; bottom: 86px; width: 58px; height: 58px; border-radius: 18px;
  background: var(--brand); color: #fff; display: grid; place-items: center; z-index: 5;
  box-shadow: 0 3px 8px rgba(26,115,232,.35); }
.fab .i { font-size: 28px; }
.fab:active { transform: scale(.96); }

/* ── Headers ── */
.hdr { padding: 20px 16px 8px; }
.eyebrow { font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--text2); font-weight: 500; }
.big { font-size: 34px; font-weight: 700; letter-spacing: -.5px; margin-top: 2px; }
.big .sym { font-size: 20px; font-weight: 500; color: var(--text2); margin-right: 2px; }
.sub { font-size: 12.5px; color: var(--text3); margin-top: 4px; }
.row { display: flex; align-items: center; gap: 8px; }
.spacer { flex: 1; }
.hello { display: flex; align-items: center; gap: 10px; padding: 12px 16px 0; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--accent-wash); color: var(--accent);
  display: grid; place-items: center; font-weight: 600; overflow: hidden; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.badge { font-size: 11px; font-weight: 600; padding: 3px 9px; border-radius: 10px; background: var(--surface2); color: var(--text2); }
.badge.red { background: var(--neg-wash); color: var(--neg); }
.badge.green { background: var(--pos-wash); color: var(--pos); }
.badge.blue { background: var(--accent-wash); color: var(--accent); }

/* ── Cards ── */
.pad { padding: 0 16px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 18px; margin: 12px 16px 0; overflow: hidden; }
.card.p { padding: 14px; }
.card-h { display: flex; align-items: center; padding: 14px 14px 6px; }
.card-h .t { font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--text3); font-weight: 600; }
.link { color: var(--accent); font-size: 12.5px; font-weight: 600; padding: 6px 0 6px 12px; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 14px 16px 0; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 11px 12px; }
.stat .l { font-size: 11px; color: var(--text3); font-weight: 500; }
.stat .v { font-size: 15px; font-weight: 700; margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.minis { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; padding: 4px 14px 14px; }
.mini .l { font-size: 11px; color: var(--text3); }
.mini .v { font-size: 14px; font-weight: 700; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar { height: 6px; border-radius: 3px; background: var(--surface2); overflow: hidden; }
.bar > i { display: block; height: 100%; border-radius: 3px; background: var(--accent); transition: width .6s cubic-bezier(.2,.8,.2,1); }
.sect { display: flex; align-items: center; justify-content: space-between; padding: 22px 16px 6px; }
.sect .t { font-size: 15px; font-weight: 600; }
.pos { color: var(--pos); } .neg { color: var(--neg); } .muted { color: var(--text3); } .acc { color: var(--accent); }

/* ── List rows ── */
.list { background: var(--surface); }
.card .list { background: transparent; }
.item { display: flex; align-items: center; gap: 14px; padding: 11px 16px; min-height: 64px; position: relative; }
.item:active { background: var(--surface2); }
.disc { width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; flex: none; }
.disc .i { font-size: 21px; }
.item .mid { flex: 1; min-width: 0; }
.item .t1 { font-size: 14.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item .t2 { font-size: 12.5px; color: var(--text2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 1px; }
.item .amt { font-size: 14.5px; font-weight: 500; text-align: right; white-space: nowrap; }
.item .amt small { display: block; font-size: 11.5px; font-weight: 400; color: var(--text3); }
.day { display: flex; justify-content: space-between; padding: 14px 16px 4px; font-size: 12px; color: var(--text3); font-weight: 500; }
.empty { padding: 28px 16px; text-align: center; color: var(--text3); font-size: 13px; }
.empty .i { font-size: 34px; display: block; margin: 0 auto 8px; color: var(--border-hi); }

/* ── Chips / segmented ── */
.chips { display: flex; gap: 6px; overflow-x: auto; padding: 2px 16px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; padding: 7px 14px; border-radius: 18px; background: var(--surface2); color: var(--text2);
  font-size: 12.5px; font-weight: 600; display: inline-flex; align-items: center; gap: 4px; }
.chip.on { background: var(--text); color: var(--bg); }
.chip .i { font-size: 15px; }
.seg { display: inline-flex; background: var(--surface2); border-radius: 20px; padding: 3px; }
.seg button { padding: 6px 13px; border-radius: 16px; font-size: 12.5px; color: var(--text2); }
.seg button.on { background: var(--surface); color: var(--text); font-weight: 600; box-shadow: 0 1px 3px rgba(0,0,0,.12); }
.tabsline { display: flex; gap: 2px; padding: 0 8px; border-bottom: 1px solid var(--border); overflow-x: auto; scrollbar-width: none; }
.tabsline button { padding: 12px 10px 10px; font-size: 13px; font-weight: 500; color: var(--text3); border-bottom: 2px solid transparent; flex: none; }
.tabsline button.on { color: var(--accent); border-color: var(--accent); }
.legend { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; padding: 14px 4px 2px; }
.lchip { display: inline-flex; align-items: center; gap: 6px; padding: 6px 10px; border-radius: 18px; border: 1px solid var(--border-hi);
  font-size: 12px; background: var(--surface); }
.lchip .dot { width: 8px; height: 8px; border-radius: 50%; }
.lchip .a { color: var(--text2); font-variant-numeric: tabular-nums; }
.lchip.on { font-weight: 600; }
.mstep { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px 0; font-weight: 600; font-size: 13.5px; }
.rbtn { width: 34px; height: 34px; border-radius: 17px; border: 1px solid var(--border); display: grid; place-items: center; color: var(--text2); }
.search { display: flex; align-items: center; gap: 8px; margin: 10px 16px 4px; padding: 0 14px; height: 42px; border-radius: 21px; background: var(--surface2); }
.search input { flex: 1; border: 0; outline: 0; background: transparent; font-size: 14px; }
.search .i { font-size: 20px; color: var(--text3); }

/* ── Donut ── */
.donut { position: relative; margin: 0 auto; }
.donut svg { display: block; overflow: visible; }
.donut .seg-arc { transition: opacity .2s, stroke-width .2s; }
.donut .c { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; pointer-events: none; }
.donut .c .l { font-size: 10.5px; letter-spacing: .08em; text-transform: uppercase; color: var(--text3); font-weight: 600; }
.donut .c .v { font-weight: 700; font-variant-numeric: tabular-nums; }
.donut .c .s { font-size: 11px; color: var(--text2); }
.where { display: flex; align-items: center; gap: 16px; padding: 4px 14px 14px; }
.where .lg { flex: 1; min-width: 0; }
.lline { padding: 4px 0; }
.lline .r { display: flex; align-items: center; gap: 6px; font-size: 12.5px; }
.lline .r .n { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lline .r b { font-weight: 600; font-variant-numeric: tabular-nums; }
.lline .bar { height: 3px; margin-top: 4px; }

/* ── Banner ── */
.banner { display: flex; align-items: center; gap: 12px; margin: 12px 16px 0; padding: 12px 14px; border-radius: 16px; background: var(--accent-wash); }
.banner .ic { width: 36px; height: 36px; border-radius: 50%; background: var(--accent); color: var(--on-accent); display: grid; place-items: center; flex: none; }
.banner .ic .i { font-size: 19px; }
.banner .t1 { font-weight: 600; font-size: 14px; }
.banner .t2 { font-size: 12px; color: var(--text2); }
.banner.warn { background: var(--neg-wash); }
.banner.warn .ic { background: var(--neg); }

/* ── Loan / goal cards ── */
.lcard { padding: 14px; border-top: 1px solid var(--border); }
.lcard:first-child { border-top: 0; }
.lcard .top { display: flex; align-items: center; gap: 12px; }
.lcard .meta { display: flex; justify-content: space-between; font-size: 12px; color: var(--text2); margin-top: 8px; }
.lcard .bar { margin-top: 10px; }
.btnrow { display: flex; gap: 8px; margin-top: 12px; }

/* ── Buttons ── */
.btn { height: 44px; padding: 0 20px; border-radius: 22px; font-weight: 600; font-size: 14px; display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.btn.primary { background: var(--brand); color: #fff; }
.btn.tonal { background: var(--accent-wash); color: var(--accent); }
.btn.outline { border: 1px solid var(--border-hi); color: var(--text); }
.btn.danger { background: var(--neg-wash); color: var(--neg); }
.btn.sm { height: 36px; padding: 0 14px; font-size: 13px; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .45; }
.btn:active { filter: brightness(.95); }

/* ── Settings ── */
.slabel { padding: 22px 16px 6px; font-size: 12px; font-weight: 600; color: var(--accent); letter-spacing: .02em; }
.srow { display: flex; align-items: center; gap: 14px; padding: 13px 16px; min-height: 56px; background: var(--surface); }
.srow:active { background: var(--surface2); }
.srow .i.lead { color: var(--text2); }
.srow .mid { flex: 1; min-width: 0; }
.srow .t1 { font-size: 15px; }
.srow .t2 { font-size: 12.5px; color: var(--text2); margin-top: 1px; }
.srow select { border: 0; background: var(--surface2); border-radius: 10px; padding: 8px 10px; font-size: 13.5px; outline: 0; }
.toggle { width: 52px; height: 32px; border-radius: 16px; background: var(--surface2); border: 2px solid var(--border-hi); position: relative; flex: none; transition: all .2s; }
.toggle::after { content: ''; position: absolute; width: 16px; height: 16px; left: 6px; top: 6px; border-radius: 50%; background: var(--text3); transition: all .2s; }
.toggle.on { background: var(--accent); border-color: var(--accent); }
.toggle.on::after { width: 24px; height: 24px; left: 22px; top: 2px; background: var(--on-accent); }

/* ── Sheets ── */
#scrim { position: fixed; inset: 0; background: var(--scrim); opacity: 0; pointer-events: none; transition: opacity .22s; z-index: 20; }
#scrim.on { opacity: 1; pointer-events: auto; }
.sheet { position: fixed; left: 0; right: 0; bottom: 0; max-height: 92%; background: var(--surface); z-index: 21;
  border-radius: 28px 28px 0 0; transform: translateY(105%); transition: transform .28s cubic-bezier(.2,.8,.2,1);
  display: flex; flex-direction: column; }
.sheet.on { transform: none; }
.sheet .grab { width: 36px; height: 4px; border-radius: 2px; background: var(--border-hi); margin: 10px auto 2px; flex: none; }
.sheet .sh { display: flex; align-items: center; padding: 8px 12px 6px 20px; flex: none; }
.sheet .sh h2 { margin: 0; font-size: 18px; font-weight: 600; flex: 1; }
.sheet .body { overflow-y: auto; padding: 4px 20px 24px; }
.field { margin-top: 14px; }
.field > label { display: block; font-size: 12px; font-weight: 600; color: var(--text2); margin-bottom: 6px; }
.inp { width: 100%; height: 48px; border: 1.5px solid transparent; border-radius: 14px; background: var(--surface2); padding: 0 14px; outline: 0; font-size: 15px; }
.inp:focus { border-color: var(--accent); }
textarea.inp { height: 140px; padding: 12px 14px; font: 12px/1.4 ui-monospace, monospace; resize: none; }
.amount { display: flex; align-items: baseline; gap: 8px; padding: 14px 0 10px; border-bottom: 1px solid var(--border); }
.amount .s { font-size: 22px; color: var(--text3); }
.amount input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; font-size: 40px; font-weight: 700; font-variant-numeric: tabular-nums; }
.typeseg { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 8px; }
.typeseg button { height: 42px; border-radius: 21px; border: 1px solid var(--border-hi); font-weight: 600; font-size: 13.5px; color: var(--text2); }
.typeseg button.on.exp { background: var(--neg-wash); border-color: var(--neg); color: var(--neg); }
.typeseg button.on.inc { background: var(--pos-wash); border-color: var(--pos); color: var(--pos); }
.typeseg button.on.any { background: var(--accent-wash); border-color: var(--accent); color: var(--accent); }
.cats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.cat { border: 1px solid var(--border); border-radius: 16px; padding: 10px 2px 8px; display: flex; flex-direction: column; align-items: center; gap: 4px; font-size: 11.5px; color: var(--text2); }
.cat .i { font-size: 22px; }
.cat.on { border-color: currentColor; font-weight: 600; }
.srcs { display: flex; flex-wrap: wrap; gap: 6px; }
.src { padding: 8px 12px; border-radius: 18px; border: 1px solid var(--border-hi); font-size: 12.5px; color: var(--text2); }
.src.on { background: var(--accent-wash); border-color: var(--accent); color: var(--accent); font-weight: 600; }
.actions { display: flex; gap: 8px; margin-top: 22px; }
.actions .btn { flex: 1; }
.raw { font-size: 11.5px; color: var(--text3); line-height: 1.35; margin-top: 4px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.warnline { font-size: 11.5px; color: var(--neg); margin-top: 3px; }
.iconbtn { width: 40px; height: 40px; border-radius: 20px; display: grid; place-items: center; color: var(--text2); flex: none; }
.iconbtn:active { background: var(--surface2); }
.note { font-size: 13px; color: var(--text2); line-height: 1.5; }
.note ul { padding-left: 18px; margin: 8px 0; }

/* ── Toast ── */
#toast { position: fixed; left: 16px; right: 16px; bottom: 84px; background: #303134; color: #e8eaed; padding: 12px 16px;
  border-radius: 12px; font-size: 13.5px; transform: translateY(20px); opacity: 0; transition: all .2s; z-index: 40; pointer-events: none; }
#toast.on { transform: none; opacity: 1; }

/* ── Auth / splash ── */
.auth { height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 32px; text-align: center; }
.logo { width: 76px; height: 76px; border-radius: 24px; background: linear-gradient(135deg, #1a73e8, #185abc); display: grid; place-items: center;
  box-shadow: 0 10px 24px rgba(26,115,232,.35); }
.logo .i { color: #fff; font-size: 38px; }
.auth h1 { font-size: 28px; font-weight: 600; margin: 22px 0 6px; letter-spacing: -.3px; }
.auth p { color: var(--text2); margin: 0 0 32px; font-size: 14.5px; line-height: 1.5; }
.gbtn { display: inline-flex; align-items: center; gap: 12px; height: 50px; padding: 0 22px; border-radius: 25px; border: 1px solid var(--border-hi);
  background: var(--surface); font-weight: 600; font-size: 15px; box-shadow: var(--shadow); }
.gbtn svg { width: 20px; height: 20px; }
.err { color: var(--neg); font-size: 13px; margin-top: 18px; min-height: 18px; }
.spin { width: 24px; height: 24px; border-radius: 50%; border: 2.5px solid var(--accent-wash); border-top-color: var(--accent); animation: spin .8s linear infinite; margin-top: 28px; }
@keyframes spin { to { transform: rotate(360deg); } }
.fade { animation: fade .25s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
.iconbtn.acc { color: var(--accent); }
