:root {
  --surface-1:      #ffffff;
  --page-plane:     #f4f6f9;
  --text-primary:   #0b0e14;
  --text-secondary: #52586b;
  --text-muted:     #8a90a3;
  --gridline:       #e7e9f0;
  --baseline:       #c7cbdb;
  --border:         rgba(11,14,20,0.08);
  --card-shadow:    0 1px 2px rgba(16,24,40,0.04), 0 1px 3px rgba(16,24,40,0.06);

  --blue-100: #cde2fb;
  --blue-200: #9ec5f4;
  --blue-300: #6da7ec;
  --blue-400: #3987e5;
  --blue-500: #2a78d6;
  --blue-600: #1c5cab;
  --blue-700: #184f95;
  --blue-800: #104281;
  --accent:   #2a78d6;

  --warn-bg: #fdf3e0;
  --warn-text: #7a5300;
}
@media (prefers-color-scheme: dark) {
  :root {
    --surface-1:      #12141c;
    --page-plane:     #0a0b10;
    --text-primary:   #f4f5f8;
    --text-secondary: #b7bbcc;
    --text-muted:     #7d8296;
    --gridline:       #262a38;
    --baseline:       #363c50;
    --border:         rgba(255,255,255,0.08);
    --card-shadow:    0 1px 2px rgba(0,0,0,0.3);

    --blue-100: #16233a;
    --blue-200: #1c3357;
    --blue-300: #24487c;
    --blue-400: #2f62a8;
    --blue-500: #3987e5;
    --blue-600: #5b9eea;
    --blue-700: #86b6ef;
    --blue-800: #b7d3f6;
    --accent:   #5b9eea;

    --warn-bg: #332a10;
    --warn-text: #f0c96b;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--page-plane);
  color: var(--text-primary);
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}

/* ---- top bar ---- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.1rem 2rem;
  background: var(--surface-1);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 20;
}
.topbar .brand h1 { margin: 0; font-size: 1.15rem; font-weight: 700; letter-spacing: -0.01em; }
.topbar .brand p { margin: 0.1rem 0 0; font-size: 0.82rem; color: var(--text-secondary); }
.topbar nav { display: flex; gap: 0.4rem; }
.topbar nav a {
  text-decoration: none;
  color: var(--text-secondary);
  font-size: 0.9rem;
  font-weight: 600;
  padding: 0.45rem 0.9rem;
  border-radius: 8px;
}
.topbar nav a:hover { background: var(--page-plane); color: var(--text-primary); }
.topbar nav a.active { background: var(--accent); color: #fff; }

main { max-width: 1280px; margin: 0 auto; padding: 1.75rem 2rem 4rem; }

/* ---- KPI cards ---- */
.kpi-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  margin-bottom: 1.75rem;
}
.kpi-card {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--card-shadow);
  padding: 1.1rem 1.3rem;
}
.kpi-card .kpi-label { font-size: 0.8rem; color: var(--text-secondary); font-weight: 600; text-transform: uppercase; letter-spacing: 0.03em; }
.kpi-card .kpi-value { font-size: 1.9rem; font-weight: 700; letter-spacing: -0.02em; margin-top: 0.3rem; }
.kpi-card .kpi-sub { font-size: 0.78rem; color: var(--text-muted); margin-top: 0.2rem; }

/* ---- filter bar ---- */
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 1.25rem;
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--card-shadow);
  padding: 1rem 1.3rem;
  margin-bottom: 1.75rem;
}
.filter-field { display: flex; flex-direction: column; gap: 0.3rem; }
.filter-field label { font-size: 0.76rem; font-weight: 600; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.03em; }
.filter-field select,
.filter-field input {
  font: inherit;
  font-size: 0.9rem;
  padding: 0.45rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--page-plane);
  color: var(--text-primary);
  min-width: 9rem;
}

/* ---- panels / chart grid ---- */
.chart-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
  margin-bottom: 1.75rem;
}
@media (max-width: 900px) {
  .chart-grid { grid-template-columns: 1fr; }
}
.panel {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--card-shadow);
  padding: 1.3rem 1.5rem;
}
.panel h2 { margin: 0 0 0.2rem; font-size: 1rem; font-weight: 700; }
.panel .panel-sub { margin: 0 0 1rem; font-size: 0.8rem; color: var(--text-muted); }
.panel canvas { max-height: 320px; }

.warn-box {
  background: var(--warn-bg);
  color: var(--warn-text);
  border-radius: 10px;
  padding: 0.65rem 0.9rem;
  font-size: 0.83rem;
  margin-bottom: 1rem;
}

/* ---- table ---- */
table { width: 100%; border-collapse: collapse; font-size: 0.85rem; margin-top: 0.75rem; }
th, td { text-align: left; padding: 0.5rem 0.6rem; border-bottom: 1px solid var(--gridline); }
th { color: var(--text-secondary); font-weight: 600; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.02em; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
details summary { cursor: pointer; color: var(--accent); font-size: 0.87rem; font-weight: 600; margin-top: 0.75rem; }
