:root {
  --bg: #f1f5f9;
  --surface: #ffffff;
  --surface-alt: #f8fafc;
  --text: #0f172a;
  --muted: #64748b;
  --border: #e2e8f0;
  --primary: #004f90;
  --primary-2: #0284c7;
  --gold: #fab818;
  --green: #10b981;
  --amber: #f59e0b;
  --red: #ef4444;
  --shadow: 0 10px 30px rgba(15, 23, 42, 0.06);
  --radius: 18px;
}

html.dark {
  --bg: #070d19;
  --surface: #0f172a;
  --surface-alt: #162238;
  --text: #f8fafc;
  --muted: #94a3b8;
  --border: #1e293b;
  --shadow: 0 12px 32px rgba(0, 0, 0, 0.35);
}

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

/* ============ AUTH SCREEN ============ */
.auth-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem 1.25rem;
  background: radial-gradient(circle at 12% 15%, rgba(2, 132, 199, 0.16), transparent 45%),
              radial-gradient(circle at 88% 85%, rgba(250, 184, 24, 0.14), transparent 45%),
              #070d19;
  color: #f8fafc;
}
.auth-shell {
  width: 100%;
  max-width: 1080px;
  display: grid;
  grid-template-columns: 1.2fr 0.9fr;
  gap: 2.5rem;
  align-items: center;
}
.brand-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.45rem 0.95rem;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.14);
  font-size: 1rem;
  color: #ffffff;
}
.brand-pill-sm { font-size: 0.92rem; padding: 0.38rem 0.8rem; }
.brand-dot {
  width: 12px; height: 12px; border-radius: 50%;
  background: var(--gold);
  box-shadow: 0 0 0 3px rgba(250, 184, 24, 0.25);
}
.brand-accent { color: #38bdf8; font-weight: 600; }
.free-badge {
  display: inline-block;
  margin-top: 1.1rem;
  background: rgba(250, 184, 24, 0.16);
  color: #fde68a;
  border: 1px solid rgba(250, 184, 24, 0.45);
  padding: 0.35rem 0.85rem;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 700;
}
.auth-hero h1 {
  font-size: clamp(1.9rem, 3.2vw, 2.75rem);
  font-weight: 900;
  line-height: 1.14;
  margin-top: 0.9rem;
}
.auth-hero h1 span { color: var(--gold); }
.auth-lead {
  color: #cbd5e1;
  font-size: 1.02rem;
  margin-top: 0.9rem;
  max-width: 540px;
}
.auth-features {
  margin-top: 1.5rem;
  display: grid;
  gap: 0.85rem;
}
.feat-item {
  display: flex;
  gap: 0.85rem;
  align-items: flex-start;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  padding: 0.8rem 1rem;
  border-radius: 14px;
}
.feat-icon { font-size: 1.35rem; line-height: 1; }
.feat-item strong { display: block; font-size: 0.92rem; color: #fff; }
.feat-item span { font-size: 0.82rem; color: #94a3b8; }

.auth-card {
  background: #0f172a;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 22px;
  padding: 2rem;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
}
.auth-card h2 { font-size: 1.35rem; font-weight: 800; }
.auth-sub { color: #94a3b8; font-size: 0.88rem; margin: 0.35rem 0 1.25rem; }
.field { display: block; margin-bottom: 0.95rem; }
.field span { display: block; font-size: 0.8rem; font-weight: 600; color: #cbd5e1; margin-bottom: 0.35rem; }
.field input {
  width: 100%;
  padding: 0.78rem 0.95rem;
  border-radius: 12px;
  border: 1px solid #334155;
  background: #070d19;
  color: #ffffff;
  font-size: 0.95rem;
}
.field input:focus { outline: none; border-color: #38bdf8; box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.2); }
.alert-error {
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.5);
  color: #fecaca;
  padding: 0.75rem 0.9rem;
  border-radius: 12px;
  font-size: 0.84rem;
  margin-bottom: 0.9rem;
}
.auth-divider {
  display: flex; align-items: center; gap: 0.75rem;
  margin: 1.15rem 0; color: #64748b; font-size: 0.78rem;
}
.auth-divider::before, .auth-divider::after {
  content: ''; flex: 1; height: 1px; background: #1e293b;
}
.auth-footer-note {
  margin-top: 1.15rem; text-align: center; font-size: 0.82rem; color: #94a3b8;
}
.auth-footer-note a { color: var(--gold); font-weight: 700; text-decoration: none; }

/* ============ BUTTONS ============ */
.btn-primary, .btn-primary-sm {
  background: linear-gradient(135deg, #004f90, #0284c7);
  color: #ffffff; border: none; border-radius: 12px;
  font-weight: 700; cursor: pointer; transition: transform 0.12s, opacity 0.15s;
}
.btn-primary { padding: 0.85rem 1.2rem; font-size: 0.95rem; }
.btn-primary-sm { padding: 0.45rem 0.9rem; font-size: 0.82rem; border-radius: 10px; }
.btn-primary:hover, .btn-primary-sm:hover { opacity: 0.93; transform: translateY(-1px); }
.btn-secondary {
  background: rgba(250, 184, 24, 0.14);
  color: #fde68a; border: 1px solid rgba(250, 184, 24, 0.45);
  border-radius: 12px; padding: 0.8rem 1.1rem; font-weight: 700; font-size: 0.92rem; cursor: pointer;
}
.btn-secondary:hover { background: rgba(250, 184, 24, 0.22); }
.btn-full { width: 100%; }
.btn-ghost, .btn-ghost-sm {
  background: var(--surface-alt); color: var(--text);
  border: 1px solid var(--border); border-radius: 10px;
  font-weight: 600; cursor: pointer;
}
.btn-ghost { padding: 0.48rem 0.85rem; font-size: 0.84rem; }
.btn-ghost-sm { padding: 0.38rem 0.72rem; font-size: 0.78rem; }
.btn-danger-soft {
  background: rgba(239, 68, 68, 0.12); color: #ef4444;
  border: 1px solid rgba(239, 68, 68, 0.28); border-radius: 10px;
  padding: 0.48rem 0.85rem; font-weight: 700; font-size: 0.84rem; cursor: pointer;
}
.btn-gold-sm {
  background: var(--gold); color: #070d19; border-radius: 10px;
  padding: 0.4rem 0.85rem; font-weight: 800; font-size: 0.8rem; text-decoration: none;
}
.icon-btn {
  background: var(--surface-alt); color: var(--text);
  border: 1px solid var(--border); border-radius: 10px;
  width: 36px; height: 36px; display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer; font-weight: 700;
}

/* ============ TOPBAR ============ */
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0.75rem 1.5rem;
  display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap;
}
.topbar-left { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }
.tenant-meta strong { display: block; font-size: 0.96rem; }
.tenant-meta .muted { font-size: 0.76rem; color: var(--muted); }
.topbar-controls { display: flex; align-items: center; gap: 0.55rem; flex-wrap: wrap; }
.month-picker {
  display: inline-flex; align-items: center; gap: 0.4rem;
  background: var(--surface-alt); border: 1px solid var(--border);
  border-radius: 12px; padding: 0.2rem 0.35rem;
}
.period-label { font-weight: 800; font-size: 0.88rem; min-width: 128px; text-align: center; }

.demo-banner {
  background: linear-gradient(90deg, #004f90, #0369a1);
  color: #ffffff; padding: 0.65rem 1.5rem;
  display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap;
  font-size: 0.86rem;
}
.demo-banner-actions { display: flex; gap: 0.5rem; align-items: center; }

/* ============ MAIN CONTAINER ============ */
.container { max-width: 1280px; margin: 1.5rem auto; padding: 0 1.25rem; display: grid; gap: 1.35rem; }

/* ============ HERO GAUGE CARD ============ */
.hero-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 1.75rem;
  box-shadow: var(--shadow);
  display: grid;
  grid-template-columns: 310px 1fr;
  gap: 2rem;
  align-items: center;
  position: relative;
  overflow: hidden;
}
.hero-card::before {
  content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 7px;
  background: var(--amber);
}
.hero-card.status-ok::before { background: var(--green); }
.hero-card.status-danger::before { background: var(--red); }

.hero-gauge-col { text-align: center; }
.gauge-wrap { position: relative; width: 260px; height: 155px; margin: 0 auto; }
.gauge-center {
  position: absolute; left: 0; right: 0; bottom: 10px; text-align: center;
}
.gauge-pct { font-size: 2.35rem; font-weight: 900; line-height: 1; }
.gauge-sub { font-size: 0.76rem; color: var(--muted); font-weight: 600; margin-top: 4px; }

.progress-rail {
  height: 12px; background: var(--surface-alt); border: 1px solid var(--border);
  border-radius: 999px; overflow: hidden; margin-top: 0.75rem;
}
.progress-fill {
  height: 100%; border-radius: 999px;
  background: linear-gradient(90deg, var(--amber), var(--green));
  transition: width 0.5s ease;
}
.progress-scale {
  display: flex; justify-content: space-between;
  font-size: 0.72rem; color: var(--muted); font-weight: 600; margin-top: 0.35rem;
}

.status-badge {
  display: inline-block;
  padding: 0.32rem 0.8rem; border-radius: 999px;
  font-size: 0.76rem; font-weight: 800; letter-spacing: 0.3px;
  background: rgba(245, 158, 11, 0.16); color: #b45309;
}
html.dark .status-badge { color: #fde68a; }
.hero-card.status-ok .status-badge { background: rgba(16, 185, 129, 0.16); color: #059669; }
html.dark .hero-card.status-ok .status-badge { color: #6ee7b7; }
.hero-card.status-danger .status-badge { background: rgba(239, 68, 68, 0.16); color: #dc2626; }
html.dark .hero-card.status-danger .status-badge { color: #fca5a5; }

.hero-headline { font-size: clamp(1.4rem, 2.4vw, 2rem); font-weight: 900; margin-top: 0.65rem; line-height: 1.2; }
.hero-subtext { color: var(--muted); font-size: 0.96rem; margin-top: 0.45rem; }
.hero-pills {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.85rem; margin-top: 1.2rem;
}
.hero-pill {
  background: var(--surface-alt); border: 1px solid var(--border);
  border-radius: 14px; padding: 0.8rem 0.95rem;
}
.pill-lbl { display: block; font-size: 0.73rem; color: var(--muted); font-weight: 600; }
.hero-pill strong { display: block; font-size: 1.05rem; font-weight: 800; margin-top: 0.2rem; }

/* ============ KPI GRID ============ */
.kpi-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; }
.kpi-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1.2rem 1.3rem; box-shadow: var(--shadow);
}
.kpi-top { display: flex; justify-content: space-between; align-items: center; gap: 0.5rem; }
.kpi-label { font-size: 0.82rem; font-weight: 700; color: var(--muted); }
.kpi-tag {
  font-size: 0.7rem; font-weight: 700; padding: 0.18rem 0.55rem;
  border-radius: 999px; background: var(--surface-alt); border: 1px solid var(--border); color: var(--muted);
}
.kpi-value { font-size: 1.65rem; font-weight: 900; margin: 0.45rem 0 0.25rem; }
.kpi-sub { font-size: 0.78rem; color: var(--muted); }

/* ============ PANELS & CHARTS ============ */
.charts-grid { display: grid; grid-template-columns: 1.15fr 1fr; gap: 1.2rem; }
.bottom-grid { display: grid; grid-template-columns: 1.25fr 0.9fr; gap: 1.2rem; }
.panel {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1.35rem 1.45rem; box-shadow: var(--shadow);
}
.panel-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; margin-bottom: 1rem; }
.panel-head h3 { font-size: 1.04rem; font-weight: 800; }
.panel-head p { font-size: 0.82rem; color: var(--muted); margin-top: 0.2rem; }
.panel-actions { display: flex; gap: 0.45rem; flex-shrink: 0; }
.chart-box { position: relative; height: 300px; }

/* ============ SIMULATOR ============ */
.sim-controls { display: grid; gap: 1.15rem; }
.sim-row {
  background: var(--surface-alt); border: 1px solid var(--border);
  border-radius: 14px; padding: 0.95rem 1.05rem;
}
.sim-label-line { display: flex; justify-content: space-between; align-items: center; gap: 0.5rem; flex-wrap: wrap; margin-bottom: 0.55rem; }
.sim-label-line label { font-size: 0.85rem; font-weight: 700; }
.sim-hint { font-size: 0.76rem; color: var(--muted); }
.sim-badge {
  background: rgba(2, 132, 199, 0.14); color: var(--primary-2);
  padding: 0.2rem 0.6rem; border-radius: 999px; font-size: 0.8rem;
}
.sim-badge-green { background: rgba(16, 185, 129, 0.15); color: #059669; }
html.dark .sim-badge-green { color: #6ee7b7; }
.sim-input-pair { display: grid; grid-template-columns: 165px 1fr; gap: 0.85rem; align-items: center; }
.sim-input-pair input[type="number"] {
  padding: 0.55rem 0.75rem; border-radius: 10px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  font-size: 0.95rem; font-weight: 700;
}
.sim-input-pair input[type="range"] { width: 100%; accent-color: var(--primary-2); cursor: pointer; }
.sim-sub-hint { font-size: 0.78rem; color: var(--muted); margin-top: 0.5rem; }
.save-feedback {
  margin-top: 0.85rem; padding: 0.6rem 0.9rem; border-radius: 10px;
  background: rgba(16, 185, 129, 0.14); color: #059669; font-size: 0.84rem; font-weight: 700;
}

/* ============ EXPENSES DONUT & LIST ============ */
.donut-wrap { position: relative; height: 220px; max-width: 280px; margin: 0 auto 0.85rem; }
.expenses-list { display: grid; gap: 0.45rem; max-height: 220px; overflow-y: auto; }
.exp-row {
  display: flex; justify-content: space-between; align-items: center; gap: 0.5rem;
  padding: 0.5rem 0.7rem; border-radius: 10px; background: var(--surface-alt);
  font-size: 0.82rem;
}
.exp-row strong { font-weight: 700; }

.app-footer {
  text-align: center; padding: 1.5rem 1rem 2rem;
  color: var(--muted); font-size: 0.8rem;
}
.app-footer a { color: var(--primary-2); font-weight: 700; text-decoration: none; }

/* ============ RESPONSIVE ============ */
@media (max-width: 980px) {
  .auth-shell, .hero-card, .charts-grid, .bottom-grid { grid-template-columns: 1fr; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .hero-pills { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
  .kpi-grid { grid-template-columns: 1fr; }
  .sim-input-pair { grid-template-columns: 1fr; }
}
@media print {
  .topbar-controls, .demo-banner, .panel-actions, .sim-input-pair input[type="range"] { display: none !important; }
  body { background: #ffffff; color: #000000; }
}
