:root,
[data-theme="dark"] {
  --bg: #070708;
  --bg-elev: #101012;
  --surface: #17171a;
  --surface-2: #1f1f24;
  --text: #f5f5f7;
  --muted: #9a9aa3;
  --faint: #6e6e78;
  --line: rgba(255, 255, 255, 0.08);
  --accent: #ff6a45;
  --accent-2: #c4452e;
  --income: #3dd68c;
  --expense: #ff6b7a;
  --shadow: 0 18px 40px rgba(0, 0, 0, 0.35);
  --nav: rgba(18, 18, 20, 0.92);
  --field: #121214;
  color-scheme: dark;
}

[data-theme="light"] {
  --bg: #f3f1ef;
  --bg-elev: #ffffff;
  --surface: #ffffff;
  --surface-2: #f7f4f1;
  --text: #1c1c21;
  --muted: #6b6b75;
  --faint: #8a8a94;
  --line: rgba(20, 16, 16, 0.08);
  --accent: #e24a2b;
  --accent-2: #c4452e;
  --income: #0f9d58;
  --expense: #e23d4d;
  --shadow: 0 12px 30px rgba(40, 20, 16, 0.08);
  --nav: rgba(255, 255, 255, 0.92);
  --field: #f4f2f0;
  color-scheme: light;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: Manrope, system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; }
img { max-width: 100%; }

.app-shell {
  max-width: 430px;
  margin: 0 auto;
  min-height: 100dvh;
  padding: calc(18px + env(safe-area-inset-top)) 18px calc(108px + env(safe-area-inset-bottom));
  position: relative;
}

.topbar {
  display: grid;
  grid-template-columns: 40px 1fr 40px;
  align-items: center;
  margin-bottom: 18px;
}
.topbar-title { text-align: center; font-weight: 800; font-size: 18px; }
.brand-kicker { color: var(--accent); font-size: 13px; font-weight: 700; }
.brand-hello { color: var(--muted); font-size: 13px; margin-top: 2px; }
.icon-btn {
  width: 40px; height: 40px; border-radius: 50%;
  background: var(--surface); color: var(--text);
  display: grid; place-items: center;
}

.balance-block { margin: 8px 0 18px; }
.balance-label { color: var(--accent); font-size: 14px; }
.balance-value {
  font-size: 42px; font-weight: 800; letter-spacing: -1.2px;
  color: var(--accent); line-height: 1.1; margin: 4px 0 14px;
}
.totals-row { display: flex; gap: 28px; color: var(--muted); font-size: 13px; }
.totals-row b { display: block; font-size: 15px; margin-top: 2px; }
.totals-row .in b { color: var(--income); }
.totals-row .out b { color: var(--expense); }

.month-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 8px 0 22px; }
.stat-card {
  border-radius: 22px;
  padding: 16px;
  min-height: 92px;
  color: #fff;
  position: relative;
  overflow: hidden;
}
.stat-card.income { background: linear-gradient(160deg, #1f6b4a, #2f9d6b 60%, #54d08e); }
.stat-card.expense { background: linear-gradient(160deg, #7a2433, #c4452e 55%, #e85d3a); }
.stat-card span { font-size: 13px; opacity: 0.9; }
.stat-card strong { display: block; font-size: 20px; margin-top: 18px; }

.section-head {
  display: flex; align-items: center; justify-content: space-between;
  margin: 8px 0 12px;
}
.section-head h2 { font-size: 18px; font-weight: 700; }
.linkish { color: var(--accent); font-size: 13px; font-weight: 700; }

.carousel {
  display: flex; gap: 14px;
  overflow-x: auto; scroll-snap-type: x mandatory;
  scroll-snap-stop: always;
  padding: 4px 2px 16px;
  margin: 0 -18px; padding-left: 18px; padding-right: 42px;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-x;
}
.carousel::-webkit-scrollbar { display: none; }
.pay-card {
  min-width: min(82%, 320px);
  flex: 0 0 min(82%, 320px);
  scroll-snap-align: start;
  user-select: none;
  border-radius: 24px;
  padding: 18px 18px 16px;
  color: #fff;
  min-height: 188px;
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow);
  display: flex; flex-direction: column; justify-content: space-between;
}
.pay-card::after {
  content: "";
  position: absolute; right: -40px; top: -50px;
  width: 160px; height: 160px; border-radius: 50%;
  background: rgba(255,255,255,0.12);
}
.pay-card-top, .pay-card-mid, .pay-card-bot { position: relative; z-index: 1; }
.pay-card-top { display: flex; justify-content: space-between; align-items: flex-start; }
.pay-card-top .bank { font-size: 13px; opacity: 0.9; }
.pay-card-top .name { font-size: 20px; font-weight: 800; }
.brand-pill {
  background: rgba(255,255,255,0.16);
  border-radius: 999px; padding: 4px 8px; font-size: 11px; text-transform: uppercase;
}
.chip {
  width: 38px; height: 28px; border-radius: 6px;
  background: linear-gradient(135deg, #e8d5a3, #c9a35a 45%, #f3e6c0);
  margin: 10px 0 6px;
  box-shadow: inset 0 0 0 1px rgba(0,0,0,0.12);
}
.digits { letter-spacing: 1.5px; font-size: 14px; margin: 4px 0 10px; opacity: 0.95; font-variant-numeric: tabular-nums; }
.usage-bar { height: 6px; background: rgba(255,255,255,0.22); border-radius: 99px; overflow: hidden; margin: 8px 0; }
.usage-bar i { display: block; height: 100%; background: #fff; }
.pay-card-bot { display: flex; justify-content: space-between; font-size: 12px; opacity: 0.95; }
.pay-card-bot b { display: block; font-size: 14px; margin-top: 2px; }
.dots { display: flex; justify-content: center; gap: 6px; margin-top: -6px; margin-bottom: 18px; }
.dots i { width: 6px; height: 6px; border-radius: 50%; background: var(--line); }
.dots i.on { background: var(--accent); width: 16px; border-radius: 99px; }

.tx-list { display: grid; gap: 10px; }
.tx {
  background: var(--surface);
  border-radius: 18px;
  padding: 12px 14px;
  display: flex; align-items: center; gap: 12px;
}
.tx-ico {
  width: 42px; height: 42px; border-radius: 14px;
  display: grid; place-items: center; font-weight: 800;
}
.tx-ico.in { background: rgba(61, 214, 140, 0.15); color: var(--income); }
.tx-ico.out { background: rgba(255, 107, 122, 0.15); color: var(--expense); }
.tx-body { flex: 1; min-width: 0; }
.tx-body b { display: block; font-size: 14px; }
.tx-body span { color: var(--muted); font-size: 12px; }
.tx-val { font-weight: 800; }
.tx-val.in { color: var(--income); }
.tx-val.out { color: var(--expense); }

.empty {
  background: var(--surface);
  border-radius: 22px;
  padding: 28px 18px;
  text-align: center;
  color: var(--muted);
}
.empty .glyph { font-size: 34px; margin-bottom: 8px; }
.empty p { font-size: 13px; margin-top: 6px; }

.fab {
  position: fixed;
  right: max(18px, calc(50% - 197px));
  bottom: calc(86px + env(safe-area-inset-bottom));
  width: 58px; height: 58px; border-radius: 50%;
  background: var(--accent); color: #fff;
  font-size: 32px; font-weight: 500; line-height: 1;
  box-shadow: 0 10px 24px rgba(196, 69, 46, 0.45);
  z-index: 20;
}

.nav {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: 0; width: min(430px, 100%);
  background: var(--nav);
  backdrop-filter: blur(16px);
  border-top: 1px solid var(--line);
  display: grid; grid-template-columns: repeat(4, 1fr);
  padding: 8px 8px calc(10px + env(safe-area-inset-bottom));
  z-index: 15;
}
.nav button {
  color: var(--faint); font-size: 11px; font-weight: 600;
  display: grid; gap: 4px; place-items: center;
}
.nav button svg { width: 22px; height: 22px; }
.nav button.active { color: var(--accent); }

.auth {
  min-height: 100dvh;
  max-width: 430px; margin: 0 auto;
  padding: 48px 22px 32px;
  display: flex; flex-direction: column; justify-content: center;
}
.auth h1 { font-size: 28px; margin: 8px 0 6px; }
.auth p { color: var(--muted); margin-bottom: 22px; }
.field { display: grid; gap: 6px; margin-bottom: 12px; }
.field label { font-size: 12px; color: var(--muted); font-weight: 700; }
.field input, .field select, .field textarea {
  background: var(--field);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 13px 14px;
  outline: none;
}
.field input:focus, .field select:focus { border-color: var(--accent); }
.btn {
  width: 100%;
  border-radius: 16px;
  padding: 14px;
  background: var(--accent);
  color: #fff;
  font-weight: 800;
  margin-top: 8px;
}
.btn.ghost { background: var(--surface); color: var(--text); }
.btn.danger { background: var(--expense); }
.error { color: var(--expense); font-size: 13px; margin: 8px 0; }
.muted { color: var(--muted); font-size: 13px; }

.overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.55);
  z-index: 40;
  display: flex; align-items: flex-end; justify-content: center;
}
.sheet {
  width: min(430px, 100%);
  background: var(--bg-elev);
  border-radius: 24px 24px 0 0;
  padding: 12px 18px calc(22px + env(safe-area-inset-bottom));
  max-height: 92dvh;
  overflow: auto;
}
.grab { width: 42px; height: 4px; border-radius: 99px; background: var(--line); margin: 4px auto 14px; }
.sheet h3 { margin-bottom: 14px; }
.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.seg { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 12px; }
.seg button {
  padding: 10px; border-radius: 12px; background: var(--surface); color: var(--muted); font-weight: 700;
}
.seg button.on.income { background: rgba(61,214,140,0.18); color: var(--income); }
.seg button.on.expense { background: rgba(255,107,122,0.18); color: var(--expense); }

.alert {
  background: linear-gradient(160deg, #7a2433, #c4452e);
  color: #fff;
  border-radius: 18px;
  padding: 12px 14px;
  margin-bottom: 14px;
  font-size: 13px;
}

.page-title { font-size: 24px; font-weight: 800; margin-bottom: 16px; }
.card-list { display: grid; gap: 12px; }
.mini-card {
  border-radius: 18px; padding: 14px; color: #fff;
}
.colors { display: flex; gap: 8px; flex-wrap: wrap; }
.swatch {
  width: 28px; height: 28px; border-radius: 50%;
  border: 2px solid transparent;
}
.swatch.on { border-color: #fff; box-shadow: 0 0 0 2px var(--accent); }

.bars { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; align-items: end; height: 140px; margin-top: 12px; }
.bar-col { display: grid; align-items: end; height: 100%; gap: 4px; }
.bar { border-radius: 8px 8px 4px 4px; min-height: 4px; }
.bar.in { background: var(--income); }
.bar.out { background: var(--expense); }
.bar-col span { font-size: 10px; color: var(--muted); text-align: center; text-transform: capitalize; }

.install-banner {
  background: var(--surface);
  border-radius: 16px;
  padding: 12px 14px;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  margin-bottom: 16px;
  font-size: 13px;
}

.settings-block { background: var(--surface); border-radius: 18px; padding: 14px; margin-bottom: 12px; }
.toggle-row { display: flex; align-items: center; justify-content: space-between; }
.hint { font-size: 12px; color: var(--faint); margin: -4px 0 10px; }
.stat-card::after {
  content: "";
  position: absolute; left: 14px; bottom: 10px;
  width: 46px; height: 3px; border-radius: 99px;
  background: rgba(255,255,255,0.35);
}