:root {
  --bg: #f6f7f9;
  --bg-2: #eceef2;
  --surface: #ffffff;
  --surface-2: #f2f4f7;
  --border: #e1e4ea;
  --text: #0f1722;
  --text-2: #4b5565;
  --text-3: #7c8595;
  --live: #f7931a;
  --live-soft: rgba(247, 147, 26, 0.12);
  --vault: #3a7bfd;
  --vault-soft: rgba(58, 123, 253, 0.12);
  --ln: #8b5cf6;
  --ln-soft: rgba(139, 92, 246, 0.12);
  --good: #16a34a;
  --bad: #dc2626;
  --bad-soft: rgba(220, 38, 38, 0.1);
  --warn: #b45309;
  --warn-soft: rgba(217, 119, 6, 0.12);
  --focus: rgba(58, 123, 253, 0.45);
  --shadow: 0 1px 2px rgba(15, 23, 34, 0.06), 0 8px 24px rgba(15, 23, 34, 0.06);
  --radius: 18px;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", "Cascadia Code", Menlo, Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0d1117; --bg-2: #111722; --surface: #161c27; --surface-2: #1c2431; --border: #263042;
    --text: #e8edf5; --text-2: #a9b3c4; --text-3: #758197;
    --live-soft: rgba(247, 147, 26, 0.14); --vault: #6ea0ff; --vault-soft: rgba(110, 160, 255, 0.14);
    --ln: #a78bfa; --ln-soft: rgba(167, 139, 250, 0.14); --good: #22c55e; --bad: #f87171; --bad-soft: rgba(248, 113, 113, 0.12);
    --warn: #fbbf24; --warn-soft: rgba(251, 191, 36, 0.12);
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 10px 30px rgba(0, 0, 0, 0.25);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0d1117; --bg-2: #111722; --surface: #161c27; --surface-2: #1c2431; --border: #263042;
  --text: #e8edf5; --text-2: #a9b3c4; --text-3: #758197;
  --live-soft: rgba(247, 147, 26, 0.14); --vault: #6ea0ff; --vault-soft: rgba(110, 160, 255, 0.14);
  --ln: #a78bfa; --ln-soft: rgba(167, 139, 250, 0.14); --good: #22c55e; --bad: #f87171; --bad-soft: rgba(248, 113, 113, 0.12);
  --warn: #fbbf24; --warn-soft: rgba(251, 191, 36, 0.12);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 10px 30px rgba(0, 0, 0, 0.25);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, Ubuntu, Cantarell, "Noto Sans", sans-serif;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--vault); }
.noscript { padding: 24px; text-align: center; }

#app { max-width: 520px; margin: 0 auto; padding: 16px 16px calc(32px + env(safe-area-inset-bottom)); }

/* ---------- header ---------- */
.top { display: flex; align-items: center; gap: 10px; padding: 4px 0 18px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 18px; letter-spacing: -0.01em; margin-right: auto; }
.brand img { width: 30px; height: 30px; border-radius: 8px; }
.badge { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; padding: 3px 8px; border-radius: 999px; background: var(--warn-soft); color: var(--warn); }
.icon-btn { width: 40px; height: 40px; display: inline-grid; place-items: center; border-radius: 12px; border: 1px solid var(--border); background: var(--surface); cursor: pointer; color: var(--text-2); }
.icon-btn:hover { color: var(--text); background: var(--surface-2); }
.icon-btn svg { width: 18px; height: 18px; }
.spin svg { animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

svg.i { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* ---------- cards ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); }
.stack > * + * { margin-top: 14px; }
.total { text-align: center; padding: 28px 20px 24px; }
.total .label { color: var(--text-3); font-size: 13px; font-weight: 500; }
.total .amount { font-size: 38px; font-weight: 700; letter-spacing: -0.03em; margin: 4px 0 2px; font-variant-numeric: tabular-nums; }
.total .sub { color: var(--text-3); font-size: 13px; }

.accounts { display: grid; gap: 12px; }
.acct { display: flex; align-items: center; gap: 14px; padding: 16px 18px; cursor: pointer; text-align: left; width: 100%; }
.acct:hover { border-color: var(--text-3); }
.acct .dot { width: 42px; height: 42px; border-radius: 13px; display: grid; place-items: center; flex: none; }
.acct.live .dot { background: var(--live-soft); color: var(--live); }
.acct.vault .dot { background: var(--vault-soft); color: var(--vault); }
.acct.ln .dot { background: var(--ln-soft); color: var(--ln); }
.acct .meta { flex: 1; min-width: 0; }
.acct .name { font-weight: 600; }
.acct .hint { color: var(--text-3); font-size: 13px; }
.acct .bal { font-weight: 600; font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.acct .bal small { display: block; color: var(--text-3); font-weight: 400; font-size: 12px; }

.actions { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.action { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 14px 6px; border-radius: 16px; border: 1px solid var(--border); background: var(--surface); cursor: pointer; font-weight: 600; font-size: 14px; box-shadow: var(--shadow); }
.action:hover { background: var(--surface-2); }
.action .i { width: 22px; height: 22px; }

/* ---------- activity ---------- */
.section-title { font-size: 13px; font-weight: 600; color: var(--text-3); text-transform: uppercase; letter-spacing: 0.06em; margin: 26px 4px 10px; }
.list { padding: 6px 0; }
.row { display: flex; align-items: center; gap: 12px; padding: 12px 18px; }
.row + .row { border-top: 1px solid var(--border); }
.row .ico { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; background: var(--surface-2); color: var(--text-2); flex: none; }
.row .ico .i { width: 17px; height: 17px; }
.row .main { flex: 1; min-width: 0; }
.row .title { font-weight: 500; }
.row .when { font-size: 12px; color: var(--text-3); }
.row .amt { font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.pos { color: var(--good); }
.empty { color: var(--text-3); text-align: center; padding: 26px 18px; font-size: 14px; }
.row a.tx { color: inherit; text-decoration: none; }

/* ---------- forms ---------- */
h1 { font-size: 26px; letter-spacing: -0.02em; margin: 0 0 6px; }
h2 { font-size: 20px; letter-spacing: -0.01em; margin: 0 0 4px; }
p { margin: 0; }
.muted { color: var(--text-2); }
.small { font-size: 13px; }
.field { display: block; }
.field > span { display: block; font-size: 13px; font-weight: 600; color: var(--text-2); margin-bottom: 6px; }
.input, select.input, textarea.input {
  width: 100%; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface-2);
  outline: none; transition: border-color 0.15s, box-shadow 0.15s;
}
textarea.input { resize: vertical; min-height: 84px; font-family: var(--mono); font-size: 13px; word-break: break-all; }
.input:focus { border-color: var(--vault); box-shadow: 0 0 0 3px var(--focus); }
.input.mono { font-family: var(--mono); font-size: 13px; }
.input-row { display: flex; gap: 8px; }
.input-row .input { flex: 1; min-width: 0; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 13px 18px; border-radius: 13px; border: 1px solid transparent; font-weight: 600; cursor: pointer; width: 100%; background: var(--text); color: var(--bg); transition: opacity 0.15s, transform 0.05s; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn.secondary { background: var(--surface-2); color: var(--text); border-color: var(--border); }
.btn.vault { background: var(--vault); color: #fff; }
.btn.live { background: var(--live); color: #fff; }
.btn.ln { background: var(--ln); color: #fff; }
.btn.danger { background: var(--bad); color: #fff; }
.btn.small { padding: 9px 12px; font-size: 13px; width: auto; border-radius: 10px; }
.btn.link { background: none; color: var(--text-2); padding: 8px; font-weight: 500; }
.btn.link:hover { color: var(--text); }
.btn-row { display: flex; gap: 10px; }
.btn-row > * { flex: 1; }

.seg { display: flex; padding: 4px; gap: 4px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 13px; }
.seg button { flex: 1; padding: 9px 8px; border-radius: 10px; border: none; background: none; cursor: pointer; font-weight: 600; font-size: 14px; color: var(--text-2); display: flex; align-items: center; justify-content: center; gap: 6px; }
.seg button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.seg button .i { width: 16px; height: 16px; }
.seg button:disabled { opacity: 0.4; cursor: not-allowed; }

.check { display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; border: 1px solid var(--border); border-radius: 12px; cursor: pointer; background: var(--surface-2); }
.check input { margin-top: 3px; width: 18px; height: 18px; accent-color: var(--vault); flex: none; }

.note { display: flex; gap: 10px; padding: 12px 14px; border-radius: 12px; font-size: 14px; background: var(--vault-soft); color: var(--text); }
.note .i { color: var(--vault); margin-top: 1px; }
.note.warn { background: var(--warn-soft); }
.note.warn .i { color: var(--warn); }
.note.bad { background: var(--bad-soft); }
.note.bad .i { color: var(--bad); }

.meter { height: 6px; border-radius: 3px; background: var(--surface-2); overflow: hidden; margin-top: 8px; }
.meter > div { height: 100%; width: 0; transition: width 0.2s, background 0.2s; }
.meter-label { font-size: 12px; color: var(--text-3); margin-top: 4px; }

.kv { display: flex; justify-content: space-between; gap: 12px; padding: 10px 0; font-size: 14px; }
.kv + .kv { border-top: 1px solid var(--border); }
.kv .k { color: var(--text-2); }
.kv .v { font-weight: 600; text-align: right; word-break: break-all; font-variant-numeric: tabular-nums; }
.kv .v.mono { font-family: var(--mono); font-size: 12px; font-weight: 500; }

.qr { background: #fff; border-radius: 16px; padding: 12px; width: min(280px, 100%); margin: 0 auto; display: block; border: 1px solid var(--border); }
.qr img { display: block; width: 100%; height: auto; image-rendering: pixelated; }
.addr { font-family: var(--mono); font-size: 14px; word-break: break-all; text-align: center; padding: 12px; background: var(--surface-2); border-radius: 12px; border: 1px solid var(--border); user-select: all; }

.chips { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.chip { flex: 1; padding: 10px 6px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface-2); cursor: pointer; text-align: center; }
.chip b { display: block; font-size: 14px; }
.chip small { color: var(--text-3); font-size: 12px; }
.chip.on { border-color: var(--vault); box-shadow: 0 0 0 2px var(--focus); background: var(--surface); }

/* ---------- sheet (modal) ---------- */
.overlay { position: fixed; inset: 0; background: rgba(5, 8, 13, 0.55); backdrop-filter: blur(4px); display: flex; align-items: flex-end; justify-content: center; z-index: 50; animation: fade 0.15s ease-out; }
.sheet { background: var(--bg); width: 100%; max-width: 520px; max-height: 92vh; overflow-y: auto; border-radius: 22px 22px 0 0; padding: 20px 18px calc(24px + env(safe-area-inset-bottom)); animation: up 0.2s ease-out; border: 1px solid var(--border); border-bottom: none; }
@media (min-width: 640px) { .overlay { align-items: center; } .sheet { border-radius: 22px; border-bottom: 1px solid var(--border); } }
.sheet-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
@keyframes fade { from { opacity: 0; } }
@keyframes up { from { transform: translateY(24px); opacity: 0.6; } }

/* ---------- welcome ---------- */
.hero { text-align: center; padding: 48px 8px 24px; }
.hero img { width: 84px; height: 84px; border-radius: 22px; box-shadow: var(--shadow); }
.hero h1 { font-size: 32px; margin-top: 18px; }
.hero p { color: var(--text-2); margin-top: 8px; font-size: 16px; }
.features { display: grid; gap: 10px; margin: 26px 0; }
.feature { display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px; }
.feature .i { color: var(--text-2); margin-top: 2px; }
.feature b { display: block; font-size: 14px; }
.feature span { color: var(--text-2); font-size: 13px; }
.steps { display: flex; gap: 6px; margin-bottom: 18px; }
.steps div { flex: 1; height: 4px; border-radius: 2px; background: var(--border); }
.steps div.on { background: var(--vault); }

#toast { position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translateX(-50%) translateY(20px); background: var(--text); color: var(--bg); padding: 11px 18px; border-radius: 12px; font-weight: 500; font-size: 14px; opacity: 0; pointer-events: none; transition: opacity 0.2s, transform 0.2s; z-index: 100; max-width: calc(100% - 32px); }
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
#toast.bad { background: var(--bad); color: #fff; }

.center { text-align: center; }
.spacer { height: 8px; }
.hidden { display: none !important; }
video.scan { width: 100%; border-radius: 16px; background: #000; }
.footer { text-align: center; color: var(--text-3); font-size: 12px; margin-top: 28px; }
.footer button { background: none; border: none; color: var(--text-3); cursor: pointer; text-decoration: underline; font-size: 12px; }
