/* ===== RESET & BASE ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #0f1117;
  --bg2: #161b27;
  --bg3: #1e2535;
  --border: #252d3d;
  --text: #e8eaf0;
  --text2: #8b93a8;
  --text3: #5a6278;
  --blue: #4f8ef7;
  --blue-dim: rgba(79,142,247,0.12);
  --green: #34d399;
  --green-dim: rgba(52,211,153,0.12);
  --orange: #fb923c;
  --orange-dim: rgba(251,146,60,0.12);
  --red: #f87171;
  --red-dim: rgba(248,113,113,0.12);
  --purple: #a78bfa;
  --purple-dim: rgba(167,139,250,0.12);
  --teal: #22d3ee;
  --teal-dim: rgba(34,211,238,0.12);
  --sidebar-w: 220px;
  --radius: 12px;
  --radius-sm: 8px;
}

html, body { height: 100%; }

body {
  font-family: 'Inter', sans-serif;
  background: var(--bg);
  color: var(--text);
  display: flex;
  overflow: hidden;
}

/* ===== SIDEBAR ===== */
.sidebar {
  width: var(--sidebar-w);
  min-height: 100vh;
  background: var(--bg2);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 24px 0;
  flex-shrink: 0;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 20px 28px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
}

.logo-icon {
  width: 36px; height: 36px;
  background: var(--blue-dim);
  border: 1px solid rgba(79,142,247,0.3);
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  color: var(--blue);
}

.logo-text {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.3px;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 0 12px;
  flex: 1;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: var(--text2);
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 500;
  transition: all 0.15s;
  cursor: pointer;
}

.nav-item:hover {
  background: var(--bg3);
  color: var(--text);
}

.nav-item.active {
  background: var(--blue-dim);
  color: var(--blue);
  border: 1px solid rgba(79,142,247,0.2);
}

.sidebar-footer {
  padding: 16px 20px 0;
  border-top: 1px solid var(--border);
  margin-top: 16px;
}

.data-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text3);
}

.badge-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 6px var(--green);
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* ===== MAIN ===== */
.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}

/* ===== TOPBAR ===== */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 28px;
  border-bottom: 1px solid var(--border);
  background: var(--bg2);
  flex-shrink: 0;
}

.topbar-left { display: flex; flex-direction: column; gap: 2px; }

.page-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.4px;
}

.page-subtitle {
  font-size: 12px;
  color: var(--text3);
}

.last-updated {
  font-size: 12px;
  color: var(--text3);
  background: var(--bg3);
  padding: 6px 12px;
  border-radius: 20px;
  border: 1px solid var(--border);
}

/* ===== CONTENT SECTIONS ===== */
.content-section {
  display: none;
  flex-direction: column;
  gap: 20px;
  padding: 24px 28px;
  overflow-y: auto;
  flex: 1;
}

.content-section.active {
  display: flex;
}

/* ===== KPI GRID ===== */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 14px;
}

.kpi-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: border-color 0.2s;
}

.kpi-card:hover { border-color: var(--blue); }

.kpi-icon {
  width: 38px; height: 38px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
}

.kpi-blue   { background: var(--blue-dim);   color: var(--blue);   }
.kpi-green  { background: var(--green-dim);  color: var(--green);  }
.kpi-orange { background: var(--orange-dim); color: var(--orange); }
.kpi-red    { background: var(--red-dim);    color: var(--red);    }
.kpi-purple { background: var(--purple-dim); color: var(--purple); }
.kpi-teal   { background: var(--teal-dim);   color: var(--teal);   }

.kpi-body { flex: 1; }

.kpi-value {
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.5px;
  line-height: 1.1;
}

.kpi-label {
  font-size: 11.5px;
  color: var(--text2);
  margin-top: 3px;
}

.kpi-trend {
  font-size: 11px;
  font-weight: 500;
  padding: 3px 8px;
  border-radius: 20px;
  width: fit-content;
}

.kpi-trend.up     { background: var(--green-dim);  color: var(--green);  }
.kpi-trend.down   { background: var(--red-dim);    color: var(--red);    }
.kpi-trend.neutral{ background: var(--bg3);        color: var(--text2);  }

/* ===== CHARTS ===== */
.charts-row {
  display: flex;
  gap: 16px;
  align-items: stretch;
}

.chart-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.chart-card.wide { flex: 2; }

.chart-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.chart-header h3 {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

.chart-badge {
  font-size: 11px;
  color: var(--text3);
  background: var(--bg3);
  padding: 3px 8px;
  border-radius: 20px;
  border: 1px solid var(--border);
}

.chart-wrap {
  position: relative;
  height: 200px;
}

.chart-wrap.tall { height: 280px; }
.chart-wrap.donut-wrap { height: 180px; }

/* ===== DONUT LEGEND ===== */
.donut-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 11.5px;
  color: var(--text2);
}

.legend-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* ===== TABLE ===== */
.table-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.table-wrap { overflow-x: auto; }

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.data-table th {
  text-align: left;
  padding: 10px 14px;
  color: var(--text3);
  font-weight: 500;
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid var(--border);
}

.data-table td {
  padding: 11px 14px;
  color: var(--text);
  border-bottom: 1px solid rgba(37,45,61,0.5);
  vertical-align: middle;
}

.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: var(--bg3); }

/* ===== PROGRESS BAR ===== */
.progress-bar {
  height: 6px;
  background: var(--bg3);
  border-radius: 3px;
  overflow: hidden;
  width: 100px;
}

.progress-fill {
  height: 100%;
  border-radius: 3px;
  background: var(--blue);
}

/* ===== HEALTH BADGE ===== */
.health-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 500;
}

.health-good   { background: var(--green-dim);  color: var(--green);  }
.health-warn   { background: var(--orange-dim); color: var(--orange); }
.health-bad    { background: var(--red-dim);    color: var(--red);    }

/* ===== INSIGHTS GRID ===== */
.insights-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
}

.insight-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  display: flex;
  align-items: flex-start;
  gap: 14px;
  transition: border-color 0.2s;
}

.insight-card:hover { border-color: var(--blue); }

.insight-icon {
  font-size: 26px;
  line-height: 1;
  flex-shrink: 0;
}

.insight-title {
  font-size: 11.5px;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 4px;
}

.insight-value {
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.4px;
  margin-bottom: 4px;
}

.insight-desc {
  font-size: 12px;
  color: var(--text2);
  line-height: 1.4;
}

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text3); }

/* ===== RESPONSIVE ===== */
@media (max-width: 1200px) {
  .kpi-grid { grid-template-columns: repeat(3, 1fr); }
  .insights-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 900px) {
  .sidebar { width: 60px; }
  .logo-text, .nav-item span, .data-badge span { display: none; }
  .charts-row { flex-direction: column; }
  .chart-card.wide { flex: 1; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
}