:root {
  --void: #05060a;
  --ink: #f4f6f8;
  --muted: #9aa3b5;
  --line: rgba(255, 255, 255, 0.12);
  --glass: rgba(12, 16, 26, 0.62);
  --lime: #d6ff4a;
  --cyan: #7ee7ff;
  --coral: #ff5d73;
  --font: "Manrope", "Segoe UI", sans-serif;
  --sidebar: 252px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: var(--font);
  color: var(--ink);
  background: var(--void);
  color-scheme: dark;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; touch-action: manipulation; }
h1, h2, h3, .mega, .kpi strong, .person strong, .account-figure strong { font-family: var(--font); font-weight: 600; letter-spacing: -0.03em; margin: 0; font-variant-numeric: tabular-nums; }
.ico { width: 18px; height: 18px; flex: none; display: block; }
p { margin: 0; }

.orbit, .gridlines { position: fixed; inset: 0; pointer-events: none; }
.orbit {
  background:
    radial-gradient(ellipse 48% 36% at 12% 8%, rgba(214, 255, 74, 0.2), transparent 70%),
    radial-gradient(ellipse 42% 38% at 88% 0%, rgba(126, 231, 255, 0.22), transparent 68%),
    radial-gradient(ellipse 40% 34% at 72% 100%, rgba(110, 86, 255, 0.18), transparent 70%);
  animation: drift 22s ease-in-out infinite alternate;
}
@keyframes drift {
  to { transform: translate3d(-2%, 2%, 0) scale(1.06); }
}

.gate {
  position: relative; z-index: 2; min-height: 100vh;
  display: grid; place-items: center;
  padding: calc(24px + env(safe-area-inset-top)) 18px calc(24px + env(safe-area-inset-bottom));
}
.gate-card {
  width: min(420px, 100%);
  display: grid; gap: 12px;
  padding: 22px;
  border-radius: 24px;
  border: 1px solid var(--line);
  background: var(--glass);
  backdrop-filter: blur(18px);
}
.gate-card h1 { font-size: 2rem; }
.gate-card .btn, .google { min-height: 48px; width: 100%; }
.google { display: inline-flex; align-items: center; justify-content: center; text-decoration: none; }
.or { text-align: center; color: var(--muted); font-size: 0.85rem; }
.auth-error { color: var(--coral); font-size: 0.92rem; }
.app { position: relative; z-index: 1; display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar);
  flex: none;
  margin: 16px 0 16px 16px;
  padding: 22px 14px;
  display: flex;
  flex-direction: column;
  gap: 22px;
  position: sticky;
  top: 16px;
  height: calc(100vh - 32px);
  border: 1px solid var(--line);
  border-radius: 28px;
  background: var(--glass);
  backdrop-filter: blur(22px);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
}
.brand { display: flex; gap: 12px; align-items: center; padding: 0 8px; }
.brand strong { display: block; font-size: 1.2rem; letter-spacing: -0.03em; }
.brand small { display: block; color: var(--muted); line-height: 1.3; font-size: 0.78rem; }
.brand small:first-of-type { color: var(--lime); letter-spacing: 0.14em; text-transform: uppercase; font-size: 0.68rem; }
.mark {
  width: 36px; height: 36px; border-radius: 12px;
  display: grid; place-items: center;
  color: var(--void); background: var(--lime);
}
.mark svg { width: 18px; height: 18px; }
.nav, .tabbar { display: flex; flex-direction: column; gap: 4px; }
.nav-btn, .tab-btn {
  border: 0; background: transparent; text-align: left;
  padding: 10px 12px; border-radius: 14px; color: var(--muted);
  display: flex; align-items: center; gap: 10px;
}
.nav-btn.active, .tab-btn.active {
  color: var(--void);
  background: var(--lime);
}
.sidebar-cta { margin-top: auto; white-space: nowrap; }

.main { flex: 1; min-width: 0; padding: 28px 32px 96px; }
.topbar { display: flex; justify-content: space-between; gap: 16px; align-items: flex-end; margin-bottom: 22px; }
.eyebrow { color: var(--cyan); font-size: 0.72rem; letter-spacing: 0.18em; text-transform: uppercase; font-weight: 600; }
.topbar h1 { font-size: clamp(1.7rem, 2.4vw, 2.15rem); font-weight: 650; }
.month-switch {
  display: flex; align-items: center; gap: 8px;
  background: var(--glass); border: 1px solid var(--line); border-radius: 999px; padding: 6px;
  backdrop-filter: blur(16px);
}
.month-switch span { min-width: 168px; text-align: center; font-weight: 600; }
.month-switch button, .icon-btn {
  width: 36px; height: 36px; border-radius: 50%; border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.04); color: var(--ink);
  display: grid; place-items: center; padding: 0;
}

.banner {
  display: flex; justify-content: space-between; gap: 12px; align-items: center;
  margin-bottom: 16px; padding: 14px 16px; border-radius: 18px;
  border: 1px solid rgba(214, 255, 74, 0.35);
  background: rgba(214, 255, 74, 0.08);
}
.banner button { background: transparent; color: var(--lime); border: 1px solid rgba(214, 255, 74, 0.45); border-radius: 999px; padding: 6px 12px; }

.stage {
  display: grid;
  grid-template-columns: 1.4fr 0.8fr;
  gap: 18px;
  margin-bottom: 16px;
  align-items: end;
}
.balance-row { display: flex; align-items: center; gap: 18px; margin: 8px 0 12px; }
.mega {
  font-size: clamp(2.4rem, 4vw, 3.4rem);
  font-weight: 650;
  line-height: 1;
  letter-spacing: -0.045em;
  color: #fff;
}
.ring {
  width: 84px; height: 84px; border-radius: 50%; flex: none;
  background: conic-gradient(var(--lime) calc(var(--p) * 1%), rgba(255, 255, 255, 0.08) 0);
  display: grid; place-items: center; position: relative;
}
.ring::before {
  content: ""; position: absolute; inset: 8px; border-radius: 50%;
  background: #0b0e16;
}
.ring span { position: relative; font-weight: 700; font-size: 0.95rem; }
.reading { max-width: 38rem; color: #d5dbe6; font-size: 1.08rem; line-height: 1.45; }
.satellites { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.grid { display: grid; gap: 14px; }
.kpis { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.kpi, .card {
  background: var(--glass);
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 16px 18px;
  backdrop-filter: blur(18px);
}
.kpi span, .muted { color: var(--muted); font-size: 0.86rem; }
.kpi { display: grid; gap: 4px; }
.badge {
  width: 32px; height: 32px; border-radius: 10px;
  display: grid; place-items: center; margin-bottom: 6px;
  background: rgba(255, 255, 255, 0.06); color: var(--ink);
}
.kpi.good .badge { color: var(--lime); background: rgba(214, 255, 74, 0.12); }
.kpi.bad .badge { color: var(--coral); background: rgba(255, 93, 115, 0.12); }
.kpi.pulse .badge { color: var(--cyan); background: rgba(126, 231, 255, 0.12); }
.kpi strong { display: block; margin-top: 2px; font-size: 1.2rem; }
.kpi.good strong { color: var(--lime); }
.kpi.bad strong { color: var(--coral); }
.kpi.pulse strong { color: var(--cyan); }
.split { grid-template-columns: 1.25fr 0.75fr; margin-bottom: 14px; }
.card h2 { font-size: 1.05rem; margin-bottom: 14px; display: flex; align-items: center; gap: 8px; font-weight: 600; }
.subhead { margin-top: 22px; }

.bars { display: flex; flex-direction: column; gap: 12px; }
.bar-row { display: grid; grid-template-columns: 148px 1fr auto; gap: 10px; align-items: center; font-size: 0.92rem; }
.bar-name { display: flex; align-items: center; gap: 8px; min-width: 0; }
.bar-name em { font-style: normal; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-name .ico { color: var(--cyan); }
.track { height: 7px; background: rgba(255, 255, 255, 0.08); border-radius: 99px; overflow: hidden; }
.track > span { display: block; height: 100%; background: linear-gradient(90deg, var(--cyan), var(--lime)); border-radius: 99px; box-shadow: 0 0 12px rgba(214, 255, 74, 0.45); }
.track.warn > span { background: #ffe08a; box-shadow: none; }
.track.over > span { background: var(--coral); box-shadow: none; }
.legend-note { margin-top: 10px; }

.list { display: flex; flex-direction: column; }
.row {
  display: grid; grid-template-columns: auto 1fr auto auto; gap: 12px; align-items: center;
  padding: 12px 0; border-top: 1px solid var(--line);
}
.glyph {
  width: 38px; height: 38px; border-radius: 12px;
  display: grid; place-items: center;
  background: rgba(255, 255, 255, 0.05); color: var(--cyan);
}
.row:first-child { border-top: 0; }
.row small { color: var(--muted); display: block; margin-top: 2px; }
.amount.income { color: var(--lime); }
.amount.expense { color: var(--coral); }
.row-actions { display: flex; gap: 6px; }
.ghost, .btn {
  border-radius: 999px; border: 1px solid var(--line); background: rgba(255, 255, 255, 0.04); padding: 8px 14px;
}
.btn.primary { background: var(--lime); color: var(--void); border-color: transparent; font-weight: 650; display: inline-flex; align-items: center; justify-content: center; gap: 8px; }
.btn.danger { color: var(--coral); }

.toolbar { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.toolbar input, .field input, .field select {
  border: 1px solid var(--line); background: rgba(5, 6, 10, 0.55); border-radius: 14px; padding: 11px 12px; width: 100%;
}
.toolbar input { min-width: 220px; flex: 1; }
.toolbar input:focus, .field input:focus, .field select:focus { outline: 2px solid rgba(214, 255, 74, 0.7); border-color: transparent; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { border-radius: 999px; border: 1px solid var(--line); background: transparent; padding: 8px 12px; }
.chip.active { background: var(--lime); color: var(--void); border-color: transparent; font-weight: 600; }

.people { display: flex; gap: 8px; flex-wrap: wrap; }
.person {
  border: 1px solid var(--line); border-radius: 16px; padding: 10px 12px; min-width: 140px;
  display: flex; align-items: center; gap: 10px;
  background: rgba(255, 255, 255, 0.03);
}
.avatar {
  width: 36px; height: 36px; border-radius: 50%; flex: none;
  display: grid; place-items: center; font-weight: 700;
  background: rgba(214, 255, 74, 0.16); color: var(--lime);
}
.person strong { display: block; margin-top: 2px; }

.accounts { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.account-card {
  min-height: 190px; display: flex; flex-direction: column; justify-content: space-between;
  position: relative; overflow: hidden;
  background:
    linear-gradient(145deg, rgba(214, 255, 74, 0.18), transparent 46%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0.02));
}
.account-card::after {
  content: "";
  position: absolute; width: 160px; height: 160px; border-radius: 50%;
  right: -40px; top: -50px;
  background: radial-gradient(circle, rgba(126, 231, 255, 0.45), transparent 68%);
  pointer-events: none;
}
.holo-credit {
  background:
    linear-gradient(160deg, rgba(255, 93, 115, 0.28), transparent 40%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.08), rgba(8, 10, 16, 0.4));
}
.account-card .kind { font-size: 0.72rem; letter-spacing: 0.16em; text-transform: uppercase; color: var(--cyan); }
.account-figure { position: relative; z-index: 1; }
.account-figure strong { font-size: 1.45rem; }

.cats { grid-template-columns: 1fr 1fr; }
.cat-list { display: flex; flex-wrap: wrap; gap: 8px; }
.pill { border: 1px solid var(--line); border-radius: 999px; padding: 8px 12px; background: rgba(255, 255, 255, 0.04); display: inline-flex; align-items: center; gap: 8px; }
.pill .ico { color: var(--lime); }

.modal {
  position: fixed; inset: 0; background: rgba(2, 3, 8, 0.62);
  backdrop-filter: blur(10px);
  display: grid; place-items: center; padding: 18px; z-index: 20;
}
.modal[hidden] { display: none; }
.modal-card {
  width: min(520px, 100%);
  background: rgba(10, 13, 20, 0.92);
  border: 1px solid var(--line);
  border-radius: 28px;
  padding: 18px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.45);
}
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.fields { display: grid; gap: 10px; }
.field { display: grid; gap: 4px; font-size: 0.92rem; color: var(--muted); }
.field.two { grid-template-columns: 1fr 1fr; gap: 10px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px; }
.empty { color: var(--muted); padding: 18px 0; }

.tabbar {
  display: none; position: fixed; left: 0; right: 0; bottom: 0; z-index: 5;
  flex-direction: row; justify-content: space-between; gap: 2px;
  padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
  border-radius: 18px 18px 0 0;
  background: rgba(8, 10, 16, 0.92); border: 1px solid var(--line); border-bottom: 0;
  backdrop-filter: blur(18px);
}
.tab-btn { flex: 1; min-width: 0; min-height: 52px; font-size: 0.62rem; padding: 6px 2px; text-align: center; flex-direction: column; gap: 3px; justify-content: center; }
.tab-btn span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fab {
  display: none;
  position: fixed; z-index: 6;
  right: 16px; bottom: calc(74px + env(safe-area-inset-bottom));
  width: 56px; height: 56px; border: 0; border-radius: 50%;
  background: var(--lime); color: var(--void);
  place-items: center;
  box-shadow: 0 10px 30px rgba(214, 255, 74, 0.28);
}
.fab .ico { width: 24px; height: 24px; }

@media (max-width: 900px) {
  .sidebar { display: none; }
  .tabbar, .fab { display: flex; }
  .fab { display: grid; }
  .main { padding: calc(14px + env(safe-area-inset-top)) 14px calc(108px + env(safe-area-inset-bottom)); }
  .topbar { align-items: stretch; flex-direction: column; gap: 12px; margin-bottom: 14px; }
  .topbar h1 { font-size: 1.65rem; }
  .month-switch { width: 100%; justify-content: space-between; }
  .month-switch span { min-width: 0; flex: 1; font-size: 0.95rem; }
  .month-switch button, .icon-btn, .chip, .ghost, .btn { min-height: 44px; }
  .month-switch button { width: 44px; height: 44px; }
  .stage, .split, .cats, .accounts, .kpis { grid-template-columns: 1fr; }
  .satellites { grid-template-columns: 1fr 1fr; }
  .balance-row { justify-content: space-between; gap: 12px; }
  .mega { font-size: clamp(1.85rem, 9vw, 2.5rem); min-width: 0; }
  .reading { font-size: 0.98rem; }
  .kpi, .card { padding: 14px; border-radius: 18px; }
  .kpi strong, .account-figure strong { font-size: clamp(1.05rem, 4.6vw, 1.3rem); overflow-wrap: anywhere; }
  .bar-row { grid-template-columns: minmax(0, 1fr) auto; gap: 8px 10px; }
  .bar-row .track { grid-column: 1 / -1; }
  .toolbar { flex-direction: column; align-items: stretch; }
  .toolbar input { min-width: 0; width: 100%; }
  .chips { width: 100%; }
  .chip { flex: 1; text-align: center; }
  #new-tx-inline, .modal-actions .btn, .toolbar .btn { width: 100%; }
  input, select { font-size: 16px; }
  .row { grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; }
  .amount { font-size: 0.92rem; white-space: nowrap; }
  .row-actions { grid-column: 1 / -1; }
  .row-actions .ghost { flex: 1; }
  .row small { overflow-wrap: anywhere; }
  .field.two { grid-template-columns: 1fr; }
  .modal { padding: 0; align-items: end; }
  .modal-card {
    width: 100%; max-height: min(92dvh, 100%); overflow: auto;
    border-radius: 22px 22px 0 0;
    padding: 16px 16px calc(16px + env(safe-area-inset-bottom));
  }
  .banner { flex-direction: column; align-items: stretch; }
  .banner button { min-height: 44px; }
  .account-card { min-height: 150px; }
}
@media (max-width: 380px) {
  .satellites { grid-template-columns: 1fr; }
  .tab-btn span { display: none; }
  .ring { width: 68px; height: 68px; }
  .ring::before { inset: 7px; }
  .main { padding-left: 12px; padding-right: 12px; }
}
@media (prefers-reduced-motion: reduce) {
  .orbit { animation: none; }
}
