:root {
  --bg: #0b0f14; --surface: #141a22; --surface-2: #1b232d; --line: #263140;
  --text: #eef2f6; --muted: #8a97a6; --accent: #7cffb2; --on-accent: #06210f;
  --warn: #ffc857; --danger: #ff6b6b; --ok: #7cffb2;
  --radius: 18px; --tab-h: 64px;
}
@media (prefers-color-scheme: light) {
  :root {
    --bg: #f3f5f8; --surface: #ffffff; --surface-2: #eaeef3; --line: #d9e0e8;
    --text: #0f1720; --muted: #5d6b7a; --accent: #0fa968; --on-accent: #ffffff;
    --warn: #b7791f; --danger: #d63b3b; --ok: #0a7d4d;
  }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font: 16px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased; min-height: 100dvh;
}
#app { max-width: 480px; margin: 0 auto; min-height: 100dvh; display: flex; flex-direction: column; }
.page { padding: calc(env(safe-area-inset-top) + 18px) 18px calc(var(--tab-h) + env(safe-area-inset-bottom) + 28px); flex: 1; }
.page.no-tabs { padding-bottom: calc(env(safe-area-inset-bottom) + 28px); }
h1 { font-size: 28px; letter-spacing: -.02em; margin: 6px 0 4px; }
h2 { font-size: 13px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin: 26px 0 10px; font-weight: 600; }
.sub { color: var(--muted); margin: 0 0 18px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; letter-spacing: .02em; }
.brand i { width: 30px; height: 22px; border-radius: 6px; background: var(--accent); display: inline-block; position: relative; }
.brand i::after { content: ""; position: absolute; left: 4px; top: 5px; width: 8px; height: 6px; border-radius: 2px; background: var(--on-accent); opacity: .45; }
.demo { background: var(--warn); color: #231a00; text-align: center; font-weight: 700; font-size: 13px; padding: 6px 10px; }

/* surfaces */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.panel + .panel { margin-top: 12px; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.stack > * + * { margin-top: 12px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.num { font-variant-numeric: tabular-nums; }

/* weekly meter */
.meter .big { font-size: 38px; font-weight: 800; letter-spacing: -.03em; line-height: 1.05; }
.meter .big small { font-size: 15px; font-weight: 600; color: var(--muted); letter-spacing: 0; }
.bar { height: 10px; border-radius: 99px; background: var(--surface-2); overflow: hidden; margin: 14px 0 8px; }
.bar > i { display: block; height: 100%; width: calc(var(--p, 0) * 1%); background: var(--accent); border-radius: 99px; transition: width .4s ease; }
.bar.low > i { background: var(--warn); }
.bar.out > i { background: var(--danger); }

/* card visual */
.cards { display: grid; gap: 14px; }
.vcard {
  position: relative; display: block; width: 100%; text-align: left; color: #fff; border: 0; cursor: pointer;
  aspect-ratio: 1.586; border-radius: 20px; padding: 18px 20px; overflow: hidden;
  background: linear-gradient(135deg, var(--g1), var(--g2));
  box-shadow: 0 10px 30px rgba(0,0,0,.28);
  text-decoration: none; font: inherit;
}
.vcard::after { content: ""; position: absolute; right: -40px; top: -60px; width: 220px; height: 220px; border-radius: 50%; background: rgba(255,255,255,.10); }
.vcard .top { display: flex; justify-content: space-between; align-items: center; position: relative; z-index: 1; }
.vcard .wm { font-weight: 800; letter-spacing: .1em; font-size: 12px; opacity: .9; }
.vcard .chip { width: 38px; height: 28px; border-radius: 6px; background: linear-gradient(135deg,#f3dd9a,#c9a447); opacity: .9; position: relative; z-index: 1; margin-top: 16px; }
.vcard .label { position: absolute; left: 20px; bottom: 44px; font-weight: 700; font-size: 17px; z-index: 1; max-width: 70%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vcard .dots { position: absolute; left: 20px; bottom: 18px; font-size: 15px; letter-spacing: .12em; opacity: .9; z-index: 1; font-variant-numeric: tabular-nums; }
.vcard .bal { position: absolute; right: 20px; bottom: 16px; font-size: 22px; font-weight: 800; z-index: 1; font-variant-numeric: tabular-nums; }
.g0 { --g1: #1d4ed8; --g2: #7c3aed; } .g1 { --g1: #0f766e; --g2: #16a34a; }
.g2 { --g1: #be123c; --g2: #ea580c; } .g3 { --g1: #0e7490; --g2: #2563eb; }
.g4 { --g1: #334155; --g2: #0f172a; } .g5 { --g1: #a21caf; --g2: #db2777; }
.vcard.static { cursor: default; margin-bottom: 4px; }

/* forms */
label { display: block; font-size: 13px; color: var(--muted); font-weight: 600; margin: 14px 0 6px; }
input[type=text], input[type=email], input[type=password], input[type=number], input[inputmode=decimal] {
  width: 100%; font: inherit; font-size: 16px; color: var(--text); background: var(--surface-2);
  border: 1.5px solid var(--line); border-radius: 14px; padding: 14px; min-height: 50px; outline: none;
}
input:focus { border-color: var(--accent); }
.amount { position: relative; }
.amount b { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--muted); font-size: 22px; font-weight: 700; }
.amount input { padding-left: 34px; font-size: 26px; font-weight: 800; letter-spacing: -.02em; min-height: 62px; }
.chips { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.chip-btn { flex: 1 1 0; min-width: 64px; border: 1.5px solid var(--line); background: transparent; color: var(--text); font: inherit; font-weight: 700; border-radius: 99px; padding: 10px 0; min-height: 44px; cursor: pointer; }
.chip-btn:active { background: var(--surface-2); }
.btn { display: block; width: 100%; font: inherit; font-weight: 800; font-size: 17px; min-height: 54px; border-radius: 16px; border: 0; cursor: pointer; background: var(--accent); color: var(--on-accent); margin-top: 18px; }
.btn:active { transform: scale(.985); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.ghost { background: var(--surface-2); color: var(--text); }
.btn.danger { background: transparent; color: var(--danger); border: 1.5px solid var(--danger); }
.btn.small { min-height: 44px; font-size: 15px; margin-top: 0; width: auto; padding: 0 16px; border-radius: 12px; }
.link { background: none; border: 0; color: var(--accent); font: inherit; font-weight: 700; cursor: pointer; padding: 8px 0; min-height: 44px; }
.seg { display: flex; background: var(--surface-2); border-radius: 14px; padding: 4px; gap: 4px; margin: 6px 0 4px; }
.seg button { flex: 1; border: 0; border-radius: 11px; min-height: 44px; font: inherit; font-weight: 700; color: var(--muted); background: transparent; cursor: pointer; }
.seg button[aria-pressed=true] { background: var(--surface); color: var(--text); box-shadow: 0 1px 4px rgba(0,0,0,.2); }
.err { color: var(--danger); font-size: 14px; min-height: 20px; margin-top: 10px; }

/* lists */
.item { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 13px 0; border-top: 1px solid var(--line); }
.item:first-child { border-top: 0; }
.item .t { font-weight: 600; } .item .d { color: var(--muted); font-size: 13px; }
.pill { display: inline-block; font-size: 12px; font-weight: 700; padding: 3px 9px; border-radius: 99px; background: var(--surface-2); color: var(--muted); }
.pill.ok { color: var(--ok); } .pill.warn { color: var(--warn); } .pill.bad { color: var(--danger); }
.pos { color: var(--ok); font-weight: 700; } .neg { font-weight: 700; }
.badge { background: var(--danger); color: #fff; border-radius: 99px; font-size: 11px; font-weight: 800; padding: 1px 6px; margin-left: 4px; }

/* reveal */
.reveal:empty { display: none; }
.reveal .field { display: flex; justify-content: space-between; align-items: center; padding: 12px 0; border-top: 1px solid var(--line); gap: 10px; }
.reveal .field:first-child { border-top: 0; }
.reveal .v { font-size: 18px; font-weight: 700; letter-spacing: .04em; font-variant-numeric: tabular-nums; word-break: break-all; }
.reveal .k { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; }

/* tab bar */
.tabs { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
.tabs nav { max-width: 480px; margin: 0 auto; display: flex; height: var(--tab-h); }
.tabs a { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; color: var(--muted); text-decoration: none; font-size: 11px; font-weight: 700; }
.tabs a[aria-current=page] { color: var(--accent); }
.tabs svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* sheet + toast */
.scrim { position: fixed; inset: 0; background: rgba(0,0,0,.55); z-index: 40; display: flex; align-items: flex-end; justify-content: center; animation: fade .15s ease; }
.sheet { width: 100%; max-width: 480px; background: var(--surface); border-radius: 24px 24px 0 0; padding: 22px 20px calc(env(safe-area-inset-bottom) + 20px); animation: up .2s ease; }
.sheet h3 { margin: 0 0 6px; font-size: 20px; }
@keyframes up { from { transform: translateY(30px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
#toasts { position: fixed; left: 0; right: 0; top: calc(env(safe-area-inset-top) + 10px); z-index: 60; display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; padding: 0 14px; }
.toast { background: var(--text); color: var(--bg); font-weight: 700; padding: 12px 16px; border-radius: 14px; max-width: 440px; box-shadow: 0 8px 24px rgba(0,0,0,.3); animation: up .2s ease; }
.toast.bad { background: var(--danger); color: #fff; }
.center { text-align: center; padding-top: 12vh; }
.empty { text-align: center; color: var(--muted); padding: 34px 10px; }
.spin { width: 26px; height: 26px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--accent); animation: r .8s linear infinite; margin: 40px auto; }
@keyframes r { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
