:root {
  --bg: #07080c;
  --surface: #10131a;
  --surface-2: #181c26;
  --line: rgba(255, 255, 255, .07);
  --text: #f3f5fa;
  --muted: #8b92a5;
  --accent: #2f7dff;
  --accent-2: #5b9dff;
  --accent-ink: #ffffff;
  --accent-soft: rgba(47, 125, 255, .14);
  --good: #2bd98f;
  --good-soft: rgba(43, 217, 143, .13);
  --bad: #ff5d6c;
  --bad-soft: rgba(255, 93, 108, .14);
  --warn: #ffb547;
  --warn-soft: rgba(255, 181, 71, .13);
  --bar: #3a4256;
  --shadow: 0 1px 0 rgba(255, 255, 255, .04) inset, 0 10px 30px rgba(0, 0, 0, .35);
  --radius: 16px;
  --tabs-h: 64px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  padding-bottom: calc(var(--tabs-h) + env(safe-area-inset-bottom));
}
body.no-tabs { padding-bottom: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: inherit; }
.num, .amt, .big { font-variant-numeric: tabular-nums; }

/* ---------- layout ---------- */
.top {
  position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 8px;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px; background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
}
.top h1 { font-size: 22px; line-height: 1.2; margin: 0; flex: 1; letter-spacing: -.01em; }
.top .icon-btn { width: 40px; height: 40px; }
main { max-width: 720px; margin: 0 auto; padding: 4px 16px 24px; }
.stack > * + * { margin-top: 12px; }

.card { background: var(--surface); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); border: 1px solid var(--line); }
.card h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 0 0 10px; font-weight: 600; display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.card h2 a, .card h2 button.link { text-transform: none; letter-spacing: 0; font-size: 14px; }
.card.flat { box-shadow: none; }
.card.accent { background: var(--accent-soft); border-color: transparent; }
.card.warn { background: var(--warn-soft); border-color: transparent; }
.big { font-size: 32px; font-weight: 700; letter-spacing: -.02em; line-height: 1.1; }
.mid { font-size: 22px; font-weight: 700; letter-spacing: -.01em; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.tiny { font-size: 12px; }
.good { color: var(--good); }
.bad { color: var(--bad); }
.warn-t { color: var(--warn); }
.row { display: flex; align-items: center; gap: 10px; }
.row.between { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.split { display: flex; gap: 16px; flex-wrap: wrap; margin-top: 10px; }
.split > div { min-width: 0; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.center { text-align: center; }
hr { border: 0; border-top: 1px solid var(--line); margin: 12px 0; }

/* ---------- buttons & inputs ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px; padding: 0 16px;
  border-radius: 12px; border: 1px solid var(--line); background: var(--surface); font-weight: 600; cursor: pointer;
  text-decoration: none; transition: transform .08s ease, background .15s ease;
}
.btn:active { transform: scale(.98); }
.btn svg { width: 18px; height: 18px; flex: none; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.danger { color: var(--bad); }
.btn.block { width: 100%; }
.btn.sm { min-height: 36px; padding: 0 12px; font-size: 14px; border-radius: 10px; }
.btn:disabled { opacity: .55; cursor: default; }
.link { background: none; border: 0; padding: 0; color: var(--text); text-decoration: underline; text-underline-offset: 3px; cursor: pointer; font-weight: 600; }
.icon-btn { display: inline-grid; place-items: center; width: 44px; height: 44px; border: 0; background: transparent; border-radius: 12px; cursor: pointer; color: var(--text); }
.icon-btn:active { background: var(--surface-2); }
.icon-btn:disabled { opacity: .3; cursor: default; }
.icon-btn svg, .tab svg { width: 24px; height: 24px; }
label.field { display: block; }
label.field > span { display: block; font-size: 14px; color: var(--muted); margin-bottom: 4px; font-weight: 600; }
.input, select.input, textarea.input {
  width: 100%; min-height: 46px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface);
  font-size: 16px; /* keeps iOS from zooming */
}
textarea.input { min-height: 96px; resize: vertical; }
.input:focus, .btn:focus-visible, .icon-btn:focus-visible, .tab:focus-visible, .tx:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.check { display: flex; gap: 10px; align-items: center; min-height: 44px; cursor: pointer; }
.check input { width: 20px; height: 20px; accent-color: var(--accent); }
.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; min-height: 36px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); font-size: 14px; font-weight: 600; cursor: pointer; }
.chip[aria-pressed="true"] { background: var(--text); color: var(--bg); border-color: var(--text); }
.filters { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 8px; }

/* ---------- bottom tabs ---------- */
#tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; display: grid; grid-template-columns: repeat(5, 1fr);
  height: calc(var(--tabs-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
  background: var(--surface); border-top: 1px solid var(--line);
}
#tabs[hidden] { display: none; }
.tab { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; text-decoration: none; color: var(--muted); font-size: 11px; font-weight: 600; }
.tab[aria-current="page"] { color: var(--text); }
.tab[aria-current="page"] svg { color: var(--accent); }

/* ---------- lists ---------- */
.list { list-style: none; margin: 0; padding: 0; }
.list > li { border-top: 1px solid var(--line); }
.list > li:first-child { border-top: 0; }
.tx { display: flex; align-items: center; gap: 12px; width: 100%; padding: 10px 0; background: none; border: 0; text-align: left; cursor: pointer; min-height: 56px; }
.tx .avatar { flex: none; width: 36px; height: 36px; border-radius: 10px; background: var(--surface-2); display: grid; place-items: center; font-weight: 700; font-size: 15px; overflow: hidden; color: var(--muted); }
.tx .avatar img { width: 100%; height: 100%; object-fit: cover; }
.tx .name { font-weight: 600; }
.tx .meta { font-size: 13px; color: var(--muted); }
.tx .amt { font-weight: 600; white-space: nowrap; }
.tx .amt.in { color: var(--good); }
.tx.excluded { opacity: .5; }
.day { font-size: 13px; color: var(--muted); font-weight: 600; padding: 14px 0 4px; display: flex; justify-content: space-between; }
.pill { display: inline-block; font-size: 12px; font-weight: 600; padding: 1px 8px; border-radius: 999px; background: var(--surface-2); color: var(--muted); }
.pill.pending { background: var(--warn-soft); color: var(--warn); }
.pill.good { background: var(--good-soft); color: var(--good); }
.pill.bad { background: var(--bad-soft); color: var(--bad); }

/* ---------- bars ---------- */
.bar { height: 8px; border-radius: 999px; background: var(--surface-2); overflow: hidden; position: relative; }
.bar > i { display: block; height: 100%; border-radius: 999px; background: var(--bar); }
.bar > i.ok { background: var(--good); }
.bar > i.ahead { background: var(--warn); }
.bar > i.over { background: var(--bad); }
.bar > i.accent { background: var(--accent); }
.bar .pace { position: absolute; top: -3px; bottom: -3px; width: 2px; background: var(--text); opacity: .35; }
.cat-row { padding: 8px 0; }
.cat-row .row { margin-bottom: 6px; }
button.cat-row { display: block; width: 100%; background: none; border: 0; text-align: left; cursor: pointer; padding: 10px 0; }
.legend { display: flex; gap: 14px; font-size: 13px; color: var(--muted); margin-top: 6px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }
.chart svg { width: 100%; height: auto; display: block; }
.chart text { fill: var(--muted); font-size: 11px; }

/* ---------- sheet (bottom drawer) ---------- */
#sheet { position: fixed; inset: 0; z-index: 20; display: none; }
#sheet.open { display: block; }
#sheet .scrim { position: absolute; inset: 0; background: rgba(0, 0, 0, .45); animation: fade .15s ease; }
#sheet .panel {
  position: absolute; left: 0; right: 0; bottom: 0; max-height: 88vh; overflow: auto; background: var(--surface);
  border-radius: 18px 18px 0 0; padding: 8px 16px calc(20px + env(safe-area-inset-bottom)); animation: up .2s cubic-bezier(.2, .8, .2, 1);
  max-width: 720px; margin: 0 auto;
}
#sheet .grab { width: 40px; height: 5px; border-radius: 3px; background: var(--line); margin: 4px auto 12px; }
#sheet h3 { margin: 0 0 12px; font-size: 19px; }
@keyframes up { from { transform: translateY(24px); opacity: 0; } }
@keyframes fade { from { opacity: 0; } }
@media (prefers-reduced-motion: reduce) { #sheet .panel, #sheet .scrim { animation: none; } .btn { transition: none; } }

#toast {
  position: fixed; left: 50%; bottom: calc(var(--tabs-h) + 16px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 12px; font-size: 14px; font-weight: 600;
  z-index: 30; opacity: 0; pointer-events: none; transition: opacity .2s; max-width: calc(100vw - 32px);
}
#toast.show { opacity: 1; }

/* ---------- misc ---------- */
.empty { text-align: center; padding: 28px 12px; color: var(--muted); }
.empty .big-icon { font-size: 34px; margin-bottom: 6px; }
pre.export { white-space: pre-wrap; word-break: break-word; font: 12px/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; background: var(--surface-2); padding: 12px; border-radius: 10px; max-height: 50vh; overflow: auto; margin: 0; }
.login { max-width: 380px; margin: 0 auto; padding: 12vh 20px 40px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 26px; letter-spacing: -.02em; }
.brand svg { width: 38px; height: 38px; }
.spinner { width: 18px; height: 18px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }
.month-nav { display: flex; align-items: center; justify-content: space-between; }
.month-nav strong { font-size: 17px; }
.kv { display: flex; justify-content: space-between; gap: 12px; padding: 6px 0; }
.kv + .kv { border-top: 1px solid var(--line); }
details > summary { cursor: pointer; font-weight: 600; min-height: 44px; display: flex; align-items: center; }
code { font: 13px ui-monospace, Menlo, Consolas, monospace; background: var(--surface-2); padding: 2px 6px; border-radius: 6px; word-break: break-all; }
@media (min-width: 700px) {
  .top h1 { font-size: 26px; }
  .wide-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
  .wide-grid > * + * { margin-top: 0; }
}

/* ---------- fintech dark skin ---------- */
body { font-family: Inter, "SF Pro Display", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; letter-spacing: -.005em;
  background: radial-gradient(1200px 500px at 50% -200px, rgba(47, 125, 255, .16), transparent 70%), var(--bg); background-attachment: fixed; }
.num, .amt, .big, .mid { font-feature-settings: "tnum" 1, "ss01" 1; }
.big { font-size: 36px; font-weight: 650; letter-spacing: -.035em; }
.mid { font-weight: 650; letter-spacing: -.025em; }
.card { background: linear-gradient(180deg, #121620 0%, #0e1118 100%); border: 1px solid var(--line); }
.card h2 { font-size: 11.5px; letter-spacing: .1em; font-weight: 600; }
.card h2 a, .card h2 button.link { color: var(--accent-2); text-decoration: none; font-weight: 600; }
.card.accent { background: linear-gradient(135deg, rgba(47, 125, 255, .22), rgba(47, 125, 255, .06)); border: 1px solid rgba(91, 157, 255, .28); }
.card.warn { background: linear-gradient(135deg, rgba(255, 93, 108, .18), rgba(255, 93, 108, .05)); border: 1px solid rgba(255, 93, 108, .28); }
.card.hero { position: relative; overflow: hidden; background: linear-gradient(160deg, #15203a 0%, #0f1424 55%, #0c0f18 100%); border: 1px solid rgba(91, 157, 255, .22); }
.card.hero::after { content: ""; position: absolute; right: -60px; top: -60px; width: 220px; height: 220px; border-radius: 50%; background: radial-gradient(circle, rgba(47, 125, 255, .35), transparent 65%); pointer-events: none; }
.card.hero .big { font-size: 40px; }
.delta { display: inline-flex; align-items: center; gap: 4px; font-size: 13px; font-weight: 600; padding: 2px 8px; border-radius: 999px; }
.delta.up { color: var(--good); background: var(--good-soft); }
.delta.down { color: var(--bad); background: var(--bad-soft); }
.spark { display: block; width: 100%; height: 56px; margin-top: 12px; }
.top { background: rgba(7, 8, 12, .72); border-bottom: 1px solid transparent; }
.top h1 { font-weight: 700; letter-spacing: -.03em; }
.btn { background: var(--surface-2); border-color: var(--line); }
.btn.primary { background: linear-gradient(180deg, #4a8fff, #2563eb); border-color: transparent; color: #fff; box-shadow: 0 6px 18px rgba(47, 125, 255, .35); }
.btn.danger { color: var(--bad); }
.link { color: var(--accent-2); text-decoration: none; }
.input, select.input, textarea.input { background: #0c0f16; border-color: rgba(255, 255, 255, .09); }
.input:focus { border-color: var(--accent); outline: 2px solid rgba(47, 125, 255, .35); outline-offset: 0; }
.chip { background: var(--surface); border-color: var(--line); color: var(--muted); }
.chip[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent-2); border-color: rgba(91, 157, 255, .4); }
#tabs { background: rgba(10, 12, 18, .82); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); border-top: 1px solid var(--line); }
.tab[aria-current="page"] { color: var(--text); }
.tab[aria-current="page"] svg { color: var(--accent-2); filter: drop-shadow(0 0 6px rgba(47, 125, 255, .6)); }
.bar { background: rgba(255, 255, 255, .06); height: 6px; }
.bar > i { background: linear-gradient(90deg, #3a4256, #4b556c); }
.bar > i.accent { background: linear-gradient(90deg, #2563eb, #5b9dff); }
.bar > i.ok { background: linear-gradient(90deg, #18b977, #2bd98f); }
.bar > i.over { background: linear-gradient(90deg, #e2394b, #ff5d6c); }
.bar > i.ahead { background: linear-gradient(90deg, #e09a2c, #ffb547); }
.bar .pace { background: #fff; opacity: .5; }
.tx .avatar { background: linear-gradient(160deg, #1d2333, #151a26); color: var(--accent-2); border: 1px solid var(--line); }
.pill { background: rgba(255, 255, 255, .06); }
#sheet .panel { background: #10131a; border-top: 1px solid var(--line); }
#toast { background: #1d2333; color: var(--text); border: 1px solid rgba(91, 157, 255, .3); }
pre.export { background: #0a0d13; border: 1px solid var(--line); }
.chart text { fill: var(--muted); }
.chart-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
