:root {
  --bg: #0b1120;
  --card: #111827;
  --border: #1f2937;
  --text: #f3f4f6;
  --muted: #9ca3af;
  --primary: #3b82f6;
  --primary-hover: #2563eb;
  --green: #10b981;
  --red: #ef4444;
  --amber: #f59e0b;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: Inter, system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.45;
}
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.pos { color: var(--green); }
.neg { color: var(--red); }

.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1rem;
}
.login-card { width: 100%; max-width: 380px; }
.badge {
  display: inline-block;
  font-size: 0.75rem;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  background: rgba(59, 130, 246, 0.15);
  color: #93c5fd;
  margin-bottom: 0.5rem;
}

.topbar {
  background: rgba(17, 24, 39, 0.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 20;
}
.topbar-inner, .tabs, .container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0.75rem 1rem;
}
.topbar-inner {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
  justify-content: space-between;
}
.brand { display: flex; align-items: center; gap: 0.5rem; font-size: 1.05rem; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--green); }
.topbar-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; }

.tabs {
  display: flex;
  gap: 0.4rem;
  overflow-x: auto;
  padding-top: 0;
  padding-bottom: 0.6rem;
}
.tab {
  background: transparent;
  color: var(--muted);
  border: 1px solid transparent;
  padding: 0.45rem 0.85rem;
  border-radius: 8px;
  cursor: pointer;
  white-space: nowrap;
  font-weight: 500;
}
.tab.active {
  background: rgba(59, 130, 246, 0.15);
  color: #93c5fd;
  border-color: rgba(59, 130, 246, 0.35);
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.1rem;
  margin-bottom: 1rem;
}
.card-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}
h1, h3 { margin: 0 0 0.6rem; }

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 0.85rem;
  margin-bottom: 0.25rem;
}
.kpi { display: flex; flex-direction: column; gap: 0.25rem; margin-bottom: 0; }
.kpi strong { font-size: 1.5rem; }

.charts-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
  margin-top: 1rem;
}
.chart-card { margin-bottom: 0; }
.chart-card.span-2 { grid-column: span 2; }
.chart-box { position: relative; height: 260px; }
.chart-box.tall { height: 290px; }

.two-col {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
}
.span-2 { grid-column: span 2; }
label {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-size: 0.85rem;
  color: var(--muted);
}
.checkbox-row {
  flex-direction: row;
  align-items: center;
  gap: 0.5rem;
  align-self: end;
  padding-bottom: 0.5rem;
}
input, select {
  background: #0f172a;
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.55rem 0.7rem;
  border-radius: 8px;
  font-size: 0.92rem;
}
input[type="color"] { padding: 0.2rem; height: 38px; width: 56px; }
input[type="checkbox"] { width: 16px; height: 16px; }

.btn {
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 0.5rem 0.9rem;
  cursor: pointer;
  font-weight: 500;
  font-size: 0.88rem;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-secondary { background: #1f2937; color: var(--text); border-color: #374151; }
.btn-ghost { background: transparent; color: var(--muted); border-color: var(--border); }
.btn-danger { background: rgba(239, 68, 68, 0.15); color: #fca5a5; padding: 0.3rem 0.55rem; }
.full { width: 100%; }
.form-actions { display: flex; gap: 0.5rem; align-items: center; }
.inline-form { display: flex; gap: 0.5rem; margin-bottom: 0.75rem; }
.inline-form input[type="text"], .inline-form input:not([type="color"]) { flex: 1; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
th, td {
  text-align: left;
  padding: 0.6rem 0.5rem;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
th { color: var(--muted); font-weight: 500; font-size: 0.8rem; }

.pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  font-size: 0.78rem;
  background: rgba(255, 255, 255, 0.06);
}
.swatch { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }

.budget-list { display: flex; flex-direction: column; gap: 0.7rem; }
.budget-item { font-size: 0.85rem; }
.budget-head { display: flex; justify-content: space-between; margin-bottom: 0.25rem; }
.bar-bg { background: #1f2937; height: 8px; border-radius: 999px; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 999px; transition: width 0.25s; }

.simple-list { list-style: none; padding: 0; margin: 0.75rem 0 0; }
.simple-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  padding: 0.45rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
}

.toast {
  position: fixed;
  bottom: 1rem;
  right: 1rem;
  background: #1f2937;
  border: 1px solid #374151;
  padding: 0.7rem 1rem;
  border-radius: 10px;
  z-index: 50;
  max-width: 340px;
}
.error-text { color: #fca5a5; font-size: 0.85rem; min-height: 1.2rem; }

@media (max-width: 800px) {
  .charts-grid, .two-col, .form-grid { grid-template-columns: 1fr; }
  .chart-card.span-2, .span-2 { grid-column: span 1; }
}