:root {
  --primary: #2e1c85;
  --primary-mid: #4738b8;
  --primary-light: #7361eb;
  --coral: #ff6b61;
  --magenta: #e84794;
  --violet: #8c52f2;
  --teal: #1fb8ad;
  --gold: #fab838;
  --success: #29c785;
  --danger: #f04752;
  --bg: #f3f4fb;
  --surface: #ffffff;
  --text: #1a1d2e;
  --muted: #6b7280;
  --border: #e5e7f0;
  --radius: 14px;
  --shadow: 0 12px 40px rgba(46, 28, 133, 0.12);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: "Inter", system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

.hidden { display: none !important; }

/* Auth */
.auth-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 2rem 1rem;
  background: linear-gradient(135deg, var(--primary), var(--primary-mid), var(--violet));
}
.auth-card {
  width: min(440px, 100%);
  background: var(--surface);
  border-radius: 20px;
  padding: 2rem;
  box-shadow: var(--shadow);
}
.brand-mark {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}
.brand-icon {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--coral), var(--magenta));
  display: grid;
  place-items: center;
  color: white;
  font-weight: 800;
  font-size: 1.25rem;
}
.brand-mark h1 { margin: 0; font-size: 1.6rem; }
.brand-mark p { margin: 0.15rem 0 0; color: var(--muted); font-size: 0.9rem; }

.tabs { display: flex; gap: 0.5rem; margin-bottom: 1.25rem; }
.tab {
  flex: 1;
  border: 0;
  background: var(--bg);
  padding: 0.65rem;
  border-radius: 10px;
  font-weight: 600;
  cursor: pointer;
  color: var(--muted);
}
.tab.active { background: var(--primary-mid); color: white; }

label { display: block; font-size: 0.85rem; font-weight: 600; margin: 0.65rem 0 0.35rem; }
input, select, textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.7rem 0.8rem;
  font: inherit;
}
textarea { min-height: 80px; resize: vertical; }

.btn {
  border: 0;
  border-radius: 10px;
  padding: 0.75rem 1rem;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
}
.btn-primary {
  background: linear-gradient(90deg, var(--coral), var(--magenta));
  color: white;
  width: 100%;
  margin-top: 1rem;
}
.btn-secondary { background: var(--bg); color: var(--text); border: 1px solid var(--border); }
.btn-ghost { background: transparent; color: var(--muted); }
.btn-danger { background: var(--danger); color: white; }

.alert {
  padding: 0.75rem 0.9rem;
  border-radius: 10px;
  margin: 0.75rem 0;
  font-size: 0.9rem;
}
.alert-error { background: #fde8ea; color: #9f1239; }
.alert-ok { background: #e8faf1; color: #166534; }
.alert-info { background: #eef2ff; color: #3730a3; }

.pwd-rules { font-size: 0.8rem; color: var(--muted); margin-top: 0.5rem; }
.pwd-rules li { margin: 0.2rem 0; }
.pwd-rules li.ok { color: var(--success); }

/* App shell */
.app-shell { display: grid; grid-template-columns: 260px 1fr; min-height: 100vh; }
.sidebar {
  background: linear-gradient(180deg, var(--primary), var(--primary-mid));
  color: white;
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
.sidebar .brand-mark h1 { color: white; font-size: 1.25rem; }
.sidebar .brand-mark p { color: rgba(255,255,255,0.75); }
.nav { display: flex; flex-direction: column; gap: 0.35rem; flex: 1; }
.nav button {
  border: 0;
  background: transparent;
  color: rgba(255,255,255,0.85);
  text-align: left;
  padding: 0.7rem 0.85rem;
  border-radius: 10px;
  font-weight: 600;
  cursor: pointer;
}
.nav button.active, .nav button:hover { background: rgba(255,255,255,0.15); color: white; }
.sidebar-footer { margin-top: auto; font-size: 0.85rem; opacity: 0.85; }

.main { padding: 1.5rem 2rem 2rem; }
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
}
.page-header h2 { margin: 0; font-size: 1.6rem; }

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
  margin-bottom: 1.25rem;
}
.stat-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 1rem;
  border: 1px solid var(--border);
  box-shadow: 0 4px 20px rgba(0,0,0,0.04);
}
.stat-card span { display: block; color: var(--muted); font-size: 0.85rem; }
.stat-card strong { font-size: 1.5rem; margin-top: 0.25rem; display: block; }

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  margin-bottom: 1rem;
  box-shadow: 0 4px 20px rgba(0,0,0,0.04);
}
.panel h3 { margin: 0 0 0.75rem; font-size: 1.05rem; }

.list-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
}
.list-row:last-child { border-bottom: 0; }
.list-row:hover { background: var(--bg); margin: 0 -0.5rem; padding-left: 0.5rem; padding-right: 0.5rem; border-radius: 8px; }

.badge {
  display: inline-block;
  padding: 0.2rem 0.5rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
}
.badge-income { background: #e8faf1; color: #166534; }
.badge-expense { background: #fde8ea; color: #9f1239; }
.badge-soon { background: #eef2ff; color: #4338ca; }

.chip-row { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.chip {
  border: 1px solid var(--border);
  background: var(--bg);
  padding: 0.35rem 0.65rem;
  border-radius: 999px;
  font-size: 0.8rem;
}

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
@media (max-width: 900px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { flex-direction: row; flex-wrap: wrap; align-items: center; }
  .nav { flex-direction: row; flex-wrap: wrap; }
  .main { padding: 1rem; }
  .grid-2 { grid-template-columns: 1fr; }
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  display: grid;
  place-items: center;
  padding: 1rem;
  z-index: 50;
}
.modal {
  background: var(--surface);
  border-radius: 16px;
  width: min(520px, 100%);
  max-height: 90vh;
  overflow: auto;
  padding: 1.25rem;
  box-shadow: var(--shadow);
}
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1rem; }
.modal-header h3 { margin: 0; }

.empty { text-align: center; color: var(--muted); padding: 2rem 1rem; }

.hero-banner {
  background: linear-gradient(135deg, var(--primary-mid), var(--violet));
  color: white;
  border-radius: var(--radius);
  padding: 1.25rem;
  margin-bottom: 1rem;
}

.roadmap-item {
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--border);
}
.roadmap-item:last-child { border-bottom: 0; }
.roadmap-item strong { display: block; }
.roadmap-item span { color: var(--muted); font-size: 0.85rem; }

.settlement-row {
  padding: 0.5rem 0;
  font-size: 0.95rem;
}
