:root {
  --bg: #0a0e17;
  --bg-soft: #0f1524;
  --panel: #121a2b;
  --panel-2: #16203a;
  --border: #1f2a45;
  --text: #e8edf7;
  --muted: #8b96b0;
  --accent: #6c5ce7;
  --accent-2: #00d4ff;
  --good: #2dd4a7;
  --warn: #f5b23e;
  --bad: #ff5c7a;
  --radius: 14px;
  --shadow: 0 8px 30px rgba(0, 0, 0, 0.35);
  --chart-grid: rgba(31, 42, 69, 0.6);
}

:root[data-theme='light'] {
  --bg: #f4f6fb;
  --bg-soft: #ffffff;
  --panel: #ffffff;
  --panel-2: #eef1f8;
  --border: #dfe5f0;
  --text: #182033;
  --muted: #5a6a85;
  --accent: #6c5ce7;
  --accent-2: #0aa2c0;
  --shadow: 0 8px 24px rgba(20, 30, 60, 0.08);
  --chart-grid: rgba(20, 30, 60, 0.08);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  background-image:
    radial-gradient(900px 500px at 10% -10%, rgba(108, 92, 231, 0.18), transparent 60%),
    radial-gradient(800px 500px at 100% 0%, rgba(0, 212, 255, 0.12), transparent 55%);
}

.app { display: flex; min-height: 100vh; }

/* Sidebar */
.sidebar {
  width: 232px;
  flex-shrink: 0;
  background: rgba(15, 21, 36, 0.85);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 22px 16px;
  position: sticky;
  top: 0;
  height: 100vh;
}
.brand { display: flex; align-items: center; gap: 12px; margin-bottom: 30px; }
.brand-logo {
  width: 40px; height: 40px; border-radius: 11px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  display: grid; place-items: center;
  font-weight: 800; font-size: 20px; color: #fff;
}
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-name { font-weight: 800; font-size: 16px; letter-spacing: 0.5px; }
.brand-sub { font-size: 11px; color: var(--muted); letter-spacing: 1px; text-transform: uppercase; }

.nav { display: flex; flex-direction: column; gap: 4px; }
.nav-item {
  padding: 10px 12px; border-radius: 9px; color: var(--muted);
  text-decoration: none; font-size: 14px; font-weight: 500;
  transition: all 0.15s ease;
}
.nav-item:hover { color: var(--text); background: var(--panel); }
.nav-item.active { color: #fff; background: linear-gradient(135deg, rgba(108,92,231,0.25), rgba(0,212,255,0.12)); border: 1px solid rgba(108,92,231,0.35); }

.sidebar-foot {
  margin-top: auto; display: flex; align-items: center; gap: 8px;
  font-size: 12px; color: var(--muted);
}
.live-dot {
  width: 8px; height: 8px; border-radius: 50%; background: var(--good);
  box-shadow: 0 0 0 0 rgba(45, 212, 167, 0.6);
  animation: pulse 2s infinite;
}
.live-dot.off { background: var(--warn); animation: none; box-shadow: none; }
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(45,212,167,0.5); }
  70% { box-shadow: 0 0 0 8px rgba(45,212,167,0); }
  100% { box-shadow: 0 0 0 0 rgba(45,212,167,0); }
}

/* Main */
.main { flex: 1; padding: 28px 32px 40px; max-width: 1320px; }
.topbar {
  display: flex; justify-content: space-between; align-items: flex-start;
  margin-bottom: 24px; flex-wrap: wrap; gap: 12px;
}
.topbar h1 { font-size: 26px; font-weight: 800; letter-spacing: -0.5px; }
.subtitle { color: var(--muted); font-size: 14px; margin-top: 4px; }
.topbar-right { text-align: right; }
.clock {
  font-family: 'JetBrains Mono', monospace; font-size: 22px; font-weight: 600;
  color: var(--accent-2);
}
.updated { font-size: 12px; color: var(--muted); }

/* toolbar */
.toolbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 18px; gap: 12px; flex-wrap: wrap; }
.data-source {
  font-size: 12px; padding: 5px 12px; border-radius: 20px; font-weight: 600;
  background: var(--panel); border: 1px solid var(--border); color: var(--muted);
}
.data-source.ok { color: var(--good); border-color: rgba(45,212,167,0.35); background: rgba(45,212,167,0.08); }
.data-source.warn { color: var(--warn); border-color: rgba(245,178,62,0.35); background: rgba(245,178,62,0.08); }
.theme-toggle {
  width: 40px; height: 40px; border-radius: 11px; border: 1px solid var(--border);
  background: var(--panel); color: var(--text); font-size: 18px; cursor: pointer;
  display: grid; place-items: center; transition: transform 0.15s ease;
}
.theme-toggle:hover { transform: scale(1.06); }

/* KPI cards */
.kpi-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px; margin-bottom: 24px;
}
.kpi {
  background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px 20px;
  box-shadow: var(--shadow); position: relative; overflow: hidden;
}
.kpi::after {
  content: ''; position: absolute; inset: 0 0 auto 0; height: 3px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
}
.kpi-label { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.8px; }
.kpi-value { font-size: 30px; font-weight: 800; margin: 6px 0 2px; letter-spacing: -0.5px; }
.kpi-sub { font-size: 12px; color: var(--muted); }
.kpi-sub.good { color: var(--good); }
.kpi-sub.bad { color: var(--bad); }

/* Cards */
.card {
  background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow);
  margin-bottom: 22px;
}
.card-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; flex-wrap: wrap; gap: 10px; }
.card-head h3 { font-size: 16px; font-weight: 700; }
.badge {
  font-size: 11px; padding: 3px 9px; border-radius: 20px;
  background: var(--panel-2); color: var(--muted); font-weight: 600;
}
.badge.danger { background: rgba(255, 92, 122, 0.14); color: var(--bad); }
.badge.good { background: rgba(45, 212, 167, 0.14); color: var(--good); }

.charts-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 22px; margin-bottom: 22px;
}
.charts-grid .card { margin-bottom: 0; }
.chart-wrap { position: relative; height: 280px; }
.radar-wrap { height: 380px; }

/* Radar controls */
.radar-controls { display: flex; flex-wrap: wrap; gap: 8px; }
.pick {
  padding: 6px 12px; border-radius: 20px; font-size: 12px; font-weight: 600;
  background: var(--panel-2); color: var(--muted); cursor: pointer;
  border: 1px solid var(--border); transition: all 0.15s ease;
}
.pick:hover { color: var(--text); }
.pick.on { background: var(--accent); color: #fff; border-color: var(--accent); }

/* Filter */
.filter { display: flex; flex-wrap: wrap; gap: 6px; }

/* Table */
.table-scroll { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table th, .table td { padding: 11px 12px; text-align: left; border-bottom: 1px solid var(--border); }
.table th {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.7px;
  color: var(--muted); cursor: pointer; user-select: none; white-space: nowrap;
}
.table th:hover { color: var(--text); }
.table tbody tr:hover { background: var(--panel-2); }
.rank { font-weight: 700; color: var(--muted); width: 40px; }
.rank.top { color: var(--accent-2); }
.model-cell { display: flex; align-items: center; gap: 10px; }
.dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.vendor-tag { font-size: 11px; color: var(--muted); }
.quality-bar { width: 90px; height: 6px; background: var(--panel-2); border-radius: 4px; overflow: hidden; display: inline-block; vertical-align: middle; }
.quality-bar > span { display: block; height: 100%; border-radius: 4px; background: linear-gradient(90deg, var(--accent), var(--accent-2)); }
.num { font-family: 'JetBrains Mono', monospace; font-weight: 600; }
.good-text { color: var(--good); }
.bad-text { color: var(--bad); }

/* Model cards */
.section-title { font-size: 18px; font-weight: 700; margin: 6px 0 16px; }
.models-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 18px; }
.model-card {
  background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow);
  transition: transform 0.15s ease, border-color 0.15s ease;
}
.model-card:hover { transform: translateY(-3px); border-color: var(--accent); }
.mc-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.mc-name { font-size: 16px; font-weight: 700; }
.mc-vendor { font-size: 12px; color: var(--muted); }
.mc-score { font-size: 22px; font-weight: 800; color: var(--accent-2); }
.mc-score span { font-size: 12px; color: var(--muted); font-weight: 500; }
.mc-rows { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 14px; }
.mc-row .k { font-size: 11px; color: var(--muted); }
.mc-row .v { font-size: 13px; font-weight: 600; }

.section-hint { color: var(--muted); font-size: 12.5px; margin: -8px 0 14px; }
.live-tag {
  font-size: 9px; font-weight: 800; letter-spacing: 0.5px; color: #fff;
  background: var(--good); padding: 2px 6px; border-radius: 4px; text-transform: uppercase;
}
.seed-tag {
  font-size: 9px; font-weight: 800; letter-spacing: 0.5px; color: #fff;
  background: var(--warn); padding: 2px 6px; border-radius: 4px; text-transform: uppercase;
}
.clickable-row { cursor: pointer; }

/* modal */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(4, 8, 18, 0.7); backdrop-filter: blur(4px);
  display: none; align-items: center; justify-content: center; z-index: 100; padding: 20px;
}
.modal-overlay.open { display: flex; }
.modal {
  background: var(--panel); border: 1px solid var(--border); border-radius: 18px;
  width: min(720px, 100%); max-height: 90vh; overflow-y: auto; padding: 28px;
  box-shadow: 0 24px 80px rgba(0,0,0,0.5); position: relative;
}
.modal-close {
  position: absolute; top: 14px; right: 14px; width: 34px; height: 34px; border-radius: 9px;
  border: 1px solid var(--border); background: var(--panel-2); color: var(--muted);
  cursor: pointer; font-size: 15px; transition: all 0.15s ease;
}
.modal-close:hover { color: var(--text); }
.modal-head { display: flex; align-items: center; gap: 14px; margin-bottom: 22px; }
.modal-head .dot { width: 16px; height: 16px; }
.modal-head h2 { font-size: 22px; font-weight: 800; letter-spacing: -0.5px; }
.modal-score { margin-left: auto; font-size: 28px; font-weight: 800; color: var(--accent-2); }
.modal-score span { font-size: 13px; color: var(--muted); font-weight: 500; }
.modal-stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; margin-bottom: 22px; }
.stat {
  background: var(--panel-2); border: 1px solid var(--border); border-radius: 12px;
  padding: 14px;
}
.stat.good { border-color: rgba(45,212,167,0.4); }
.stat.warn { border-color: rgba(245,178,62,0.4); }
.stat.bad { border-color: rgba(255,92,122,0.4); }
.stat-label { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.6px; }
.stat-value { font-size: 20px; font-weight: 700; margin: 5px 0 2px; }
.stat-hint { font-size: 11px; color: var(--muted); }
.modal-radar-wrap { height: 300px; }

.footer { margin-top: 30px; text-align: center; font-size: 12px; color: var(--muted); opacity: 0.75; }

@media (max-width: 820px) {
  .sidebar { display: none; }
  .main { padding: 20px 16px; }
}
