:root {
  --bg: #0b1120;
  --surface: #111827;
  --surface-2: #0f172a;
  --border: rgba(148, 163, 184, 0.16);
  --text: #f1f5f9;
  --muted: #94a3b8;
  --green: #10b981;
  --blue: #38bdf8;
  --amber: #f59e0b;
  --red: #ef4444;
  --radius: 14px;
}

* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0;
  background: var(--bg); color: var(--text);
  font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}
.hidden { display: none !important; }

/* Auth / Landing screen */
.auth-screen {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  background: radial-gradient(circle at top left, rgba(16,185,129,0.14), transparent 45%),
              radial-gradient(circle at bottom right, rgba(14,165,233,0.14), transparent 45%), var(--bg);
}
.auth-shell {
  width: 100%; max-width: 920px;
  display: grid; grid-template-columns: 1.05fr 1fr; gap: 22px;
  align-items: stretch;
}
.auth-hero, .auth-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 18px; padding: 28px;
}
.brand-row { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.brand-logo { width: 42px; height: 42px; border-radius: 11px; }
.brand-title { font-size: 1.35rem; font-weight: 800; letter-spacing: -0.02em; }
.brand-sub { font-size: 0.78rem; color: var(--muted); }
.hero-list { list-style: none; padding: 0; margin: 16px 0; display: grid; gap: 10px; font-size: 0.92rem; }
.hero-list li { display: flex; gap: 8px; color: #cbd5e1; }
.demo-box {
  margin-top: 18px; padding: 14px; border-radius: 12px;
  background: rgba(16, 185, 129, 0.08); border: 1px solid rgba(16, 185, 129, 0.25);
}
.auth-tabs { display: flex; gap: 8px; margin-bottom: 16px; }
.auth-tabs button { flex: 1; }

/* App shell */
.app-shell { display: grid; grid-template-columns: 230px 1fr; min-height: 100vh; }
.sidebar {
  background: #080d1a; border-right: 1px solid var(--border);
  padding: 18px 14px; display: flex; flex-direction: column; gap: 6px;
}
.nav-btn {
  display: flex; align-items: center; justify-content: space-between;
  width: 100%; padding: 10px 12px; border-radius: 10px;
  background: transparent; border: 1px solid transparent;
  color: #cbd5e1; font-size: 0.9rem; font-weight: 600; cursor: pointer; text-align: left;
}
.nav-btn:hover { background: rgba(148,163,184,0.08); color: #fff; }
.nav-btn.active { background: rgba(16,185,129,0.14); border-color: rgba(16,185,129,0.35); color: #34d399; }
.sidebar-footer { margin-top: auto; padding-top: 14px; border-top: 1px solid var(--border); display: flex; flex-direction: column; gap: 8px; }

.main-area { padding: 20px 24px; max-width: 1380px; width: 100%; margin: 0 auto; }
.topbar-mobile {
  display: none; align-items: center; justify-content: space-between;
  padding: 12px 16px; background: #080d1a; border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 40;
}

/* Cards & Grids */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px 18px;
}
.grid-2 { display: grid; grid-template-columns: 1.15fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.grid-4 { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 12px; }
.grid-dash { display: grid; grid-template-columns: 1fr 340px; gap: 16px; align-items: start; }

.big-num { font-size: 2rem; font-weight: 800; letter-spacing: -0.02em; margin: 4px 0; }
.med-num { font-size: 1.35rem; font-weight: 800; margin: 2px 0; }
.label { font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); font-weight: 700; }
.sub { font-size: 0.82rem; color: var(--muted); }
.between { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.mb-12 { margin-bottom: 12px; }
.mt-12 { margin-top: 12px; }

/* Inputs & Buttons */
input, select, textarea {
  width: 100%; padding: 9px 11px; border-radius: 9px;
  background: var(--surface-2); border: 1px solid var(--border);
  color: var(--text); font-size: 0.9rem; font-family: inherit;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--blue); }
.btn {
  padding: 9px 14px; border-radius: 9px; border: 1px solid var(--border);
  background: #1e293b; color: #f8fafc; font-weight: 600; font-size: 0.88rem;
  cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
}
.btn:hover { filter: brightness(1.12); }
.btn-primary { background: #0284c7; border-color: #38bdf8; }
.btn-green { background: #059669; border-color: #10b981; }
.btn-amber { background: #b45309; border-color: #f59e0b; }
.btn-danger { background: #991b1b; border-color: #ef4444; }
.btn-sm { padding: 6px 10px; font-size: 0.8rem; }

/* Pills & Progress */
.pill {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 9px; border-radius: 999px; font-size: 0.75rem; font-weight: 700;
  background: rgba(148,163,184,0.15); color: #e2e8f0;
}
.pill.green { background: rgba(16,185,129,0.16); color: #34d399; }
.pill.blue { background: rgba(56,189,248,0.16); color: #7dd3fc; }
.pill.amber { background: rgba(245,158,11,0.16); color: #fbbf24; }
.pill.red { background: rgba(239,68,68,0.18); color: #fca5a5; }

.progress { height: 7px; border-radius: 999px; background: #1e293b; overflow: hidden; margin-top: 6px; }
.progress-fill { height: 100%; background: var(--green); transition: width 0.25s; }
.progress-fill.warn { background: var(--amber); }
.progress-fill.high { background: var(--red); }

.list-row {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 9px 0; border-bottom: 1px solid rgba(148,163,184,0.1);
}
.list-row:last-child { border-bottom: none; }
.list-row.is-paid { opacity: 0.6; }

/* Alerts */
.alert-item { padding: 10px 12px; border-radius: 10px; margin-bottom: 8px; border: 1px solid var(--border); background: var(--surface-2); }
.alert-item.red { border-color: rgba(239,68,68,0.45); background: rgba(239,68,68,0.08); }
.alert-item.amber { border-color: rgba(245,158,11,0.45); background: rgba(245,158,11,0.08); }

/* Chat */
.chat-panel { position: sticky; top: 18px; display: flex; flex-direction: column; height: calc(100vh - 40px); max-height: 760px; }
.chat-msgs { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; padding: 6px 2px; margin: 8px 0; }
.msg { padding: 9px 12px; border-radius: 11px; font-size: 0.86rem; max-width: 92%; white-space: pre-wrap; word-break: break-word; }
.msg.user { align-self: flex-end; background: #0369a1; color: #fff; }
.msg.assistant { align-self: flex-start; background: #1e293b; border: 1px solid var(--border); }

/* Calendar */
.cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; }
.cal-head { text-align: center; font-size: 0.76rem; color: var(--muted); font-weight: 700; padding: 4px; }
.cal-cell { min-height: 74px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 9px; padding: 5px; cursor: pointer; font-size: 0.74rem; }
.cal-cell.today { border-color: var(--blue); }
.cal-cell.selected { border-color: var(--green); background: rgba(16,185,129,0.08); }
.cal-pill { padding: 2px 5px; border-radius: 5px; margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 0.69rem; font-weight: 600; }
.cal-pill.payday { background: rgba(16,185,129,0.2); color: #34d399; }
.cal-pill.obligation { background: rgba(245,158,11,0.2); color: #fbbf24; }
.cal-pill.card_due { background: rgba(239,68,68,0.2); color: #fca5a5; }
.cal-pill.card_paid { background: rgba(56,189,248,0.2); color: #7dd3fc; }

/* Modal onboarding */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(2,6,23,0.82); z-index: 100;
  display: flex; align-items: center; justify-content: center; padding: 16px;
}
.modal-card { width: 100%; max-width: 640px; max-height: 92vh; overflow-y: auto; background: var(--surface); border: 1px solid var(--border); border-radius: 18px; padding: 24px; }
.demo-banner {
  background: rgba(245,158,11,0.14); border: 1px solid rgba(245,158,11,0.4);
  color: #fde68a; padding: 10px 14px; border-radius: 10px; margin-bottom: 14px;
  display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; font-size: 0.86rem;
}

@media (max-width: 1020px) {
  .grid-dash { grid-template-columns: 1fr; }
  .chat-panel { position: static; height: min(65dvh, 460px); }
}
@media (max-width: 820px) {
  .auth-shell { grid-template-columns: 1fr; }
  .app-shell { grid-template-columns: 1fr; }
  .topbar-mobile { display: flex; }
  .sidebar { display: none; position: fixed; inset: 54px 0 0 0; z-index: 50; overflow-y: auto; padding-bottom: calc(18px + env(safe-area-inset-bottom)); }
  .sidebar.open { display: flex; }
  .main-area { padding: 14px 14px calc(18px + env(safe-area-inset-bottom)); }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  input, select, textarea { font-size: 16px; }
}
@media (max-width: 520px) {
  .cal-grid { gap: 3px; }
  .cal-cell { min-height: 52px; padding: 3px; font-size: 0.68rem; }
  .cal-pill { font-size: 0.6rem; padding: 1px 3px; }
}

.toast {
  position: fixed; right: 16px; bottom: 16px; z-index: 200;
  max-width: 380px; padding: 11px 15px; border-radius: 10px;
  font-size: 0.86rem; font-weight: 600; box-shadow: 0 8px 24px rgba(0,0,0,0.45);
  background: #065f46; border: 1px solid #10b981; color: #ecfdf5;
}
.toast.error { background: #7f1d1d; border-color: #ef4444; color: #fef2f2; }
