/* ============================================================
   TOKENS
   ============================================================ */
#theme-toggle {
  position: fixed;
  top: 75px;
  right: 16px;
  z-index: 1000;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.15);
  color: inherit;
  font-size: 18px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s ease, transform 0.2s ease;
}

#theme-toggle:hover {
  background: rgba(255,255,255,0.16);
  transform: scale(1.05);
}
/* Light mode overrides */
body.light-mode {
  background: #f5f6f8 !important;
  color: #1a1a2e !important;
}

/* Primary headings and strong text — near-black */
body.light-mode h1,
body.light-mode h2,
body.light-mode h3,
body.light-mode .stat-value,
body.light-mode strong {
  color: #12131a !important;
}

/* Body/paragraph text — dark gray, not black (easier to read) */
body.light-mode p,
body.light-mode li,
body.light-mode td {
  color: #2e2f3a !important;
}

/* Muted/secondary labels — the ones that were disappearing.
   This is the important fix: was probably something like #6b7280 or lighter,
   which is too light against #f5f6f8. Bump it darker. */
body.light-mode .label,
body.light-mode .muted,
body.light-mode small,
body.light-mode [class*="subtitle"],
body.light-mode [class*="caption"] {
  color: #4b4d5c !important;
}

body.light-mode .card,
body.light-mode [class*="panel"] {
  background: #ffffff !important;
  border-color: rgba(0,0,0,0.1) !important;
  color: #1a1a2e !important;
}

:root {
  --bg: #0A0E12;
  --bg-panel: #121922;
  --bg-panel-alt: #0D1319;
  --grid-line: #1E2A36;
  --border: #223140;

  --text-primary: #E8EDF2;
  --text-muted: #7C8B99;
  --text-dim: #4C5C6B;

  --amber: #FFB000;
  --amber-dim: #7A5600;
  --cyan: #5EEAD4;
  --cyan-dim: #14514A;
  --red: #FF6B6B;

  --font-display: 'Space Grotesk', sans-serif;
  --font-mono: 'IBM Plex Mono', monospace;

  --radius: 3px;
  --radius-lg: 6px;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  background-image:
    radial-gradient(ellipse 900px 500px at 15% -10%, rgba(255,176,0,0.06), transparent 60%),
    radial-gradient(ellipse 700px 500px at 100% 10%, rgba(94,234,212,0.05), transparent 60%);
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

::selection { background: var(--amber); color: #1a1200; }

a { color: var(--cyan); }

/* subtle CRT scanline overlay — decorative only, very low opacity */
.scanlines {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 999;
  background: repeating-linear-gradient(
    to bottom,
    rgba(255,255,255,0.012) 0px,
    rgba(255,255,255,0.012) 1px,
    transparent 1px,
    transparent 3px
  );
  mix-blend-mode: overlay;
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important; }
}

:focus-visible {
  outline: 2px solid var(--amber);
  outline-offset: 2px;
}

/* ============================================================
   TOPBAR
   ============================================================ */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 28px;
  border-bottom: 1px solid var(--border);
  background: rgba(13,19,25,0.85);
  backdrop-filter: blur(6px);
  position: sticky;
  top: 0;
  z-index: 100;
  flex-wrap: wrap;
}

.topbar__left { display: flex; align-items: center; gap: 10px; }

.live-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--amber);
  box-shadow: 0 0 8px var(--amber);
  animation: pulse 2.4s ease-in-out infinite;
  flex-shrink: 0;
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}

.topbar__title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 15px;
  letter-spacing: 0.06em;
}
.topbar__slash { color: var(--amber); }

.topbar__right { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.topbar__source {
  font-size: 11px;
  color: var(--text-muted);
  letter-spacing: 0.04em;
  max-width: 320px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.02em;
  padding: 7px 12px;
  border-radius: var(--radius);
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--bg-panel);
  color: var(--text-primary);
  transition: border-color 0.15s ease, color 0.15s ease, background 0.15s ease;
}
.btn:hover { border-color: var(--amber); color: var(--amber); }
.btn--ghost { background: transparent; }
.btn--outline { background: transparent; color: var(--text-muted); }
.btn--outline:hover { color: var(--cyan); border-color: var(--cyan); }

/* ============================================================
   LAYOUT
   ============================================================ */
.wrap {
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 28px 60px;
}

/* ============================================================
   HERO
   ============================================================ */
.hero {
  padding: 56px 0 36px;
  max-width: 720px;
}
.hero__eyebrow {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--cyan);
  margin-bottom: 14px;
}
.hero__headline {
  font-family: var(--font-display);
  font-size: clamp(28px, 4.4vw, 44px);
  line-height: 1.12;
  font-weight: 700;
  margin: 0 0 14px;
  letter-spacing: -0.01em;
}
.hero__sub {
  color: var(--text-muted);
  font-size: 14px;
  max-width: 560px;
  margin: 0;
}

/* ============================================================
   KPI ROW
   ============================================================ */
.kpis {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  margin-bottom: 28px;
}
.kpi {
  background: var(--bg-panel);
  padding: 18px 20px;
}
.kpi__label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-dim);
  margin-bottom: 10px;
}
.kpi__value {
  font-family: var(--font-display);
  font-size: clamp(20px, 2.6vw, 28px);
  font-weight: 600;
  color: var(--amber);
  text-shadow: 0 0 18px rgba(255,176,0,0.25);
  line-height: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.kpi__hint {
  font-size: 10.5px;
  color: var(--text-dim);
  margin-top: 8px;
}

/* ============================================================
   PANELS / GRID
   ============================================================ */
.grid-main {
  display: grid;
  grid-template-columns: 1.1fr 1fr;
  gap: 16px;
  margin-bottom: 16px;
}

.panel {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.panel--heatmap { grid-row: span 2; }

.panel__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.panel__head h2 {
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 600;
  margin: 0;
  letter-spacing: 0.01em;
}
.panel__tag {
  font-size: 10.5px;
  color: var(--text-dim);
  letter-spacing: 0.03em;
}
.panel__body { padding: 18px; }

/* ============================================================
   HEATMAP (signature element)
   ============================================================ */
.heatmap {
  display: grid;
  grid-template-columns: 34px repeat(24, 1fr);
  gap: 3px;
  font-size: 9px;
}
.heatmap-cell {
  aspect-ratio: 1 / 1;
  border-radius: 2px;
  background: var(--bg-panel-alt);
  position: relative;
  cursor: default;
  transition: transform 0.1s ease;
}
.heatmap-cell:hover {
  transform: scale(1.25);
  z-index: 5;
  outline: 1px solid var(--amber);
}
.heatmap-cell[data-level="0"] { background: #101820; }
.heatmap-rowlabel, .heatmap-collabel {
  color: var(--text-dim);
  font-size: 9px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding-right: 4px;
}
.heatmap-collabel { justify-content: center; padding-right: 0; writing-mode: horizontal-tb; }
.heatmap-corner {}

.heatmap__legend {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 14px;
  font-size: 10px;
  color: var(--text-dim);
}
.heatmap__scale {
  flex: 1;
  height: 6px;
  border-radius: 3px;
  background: linear-gradient(to right, #101820, var(--cyan-dim), var(--amber-dim), var(--amber));
}

.heatmap-tooltip {
  position: fixed;
  pointer-events: none;
  background: #060a0e;
  border: 1px solid var(--amber);
  color: var(--text-primary);
  font-size: 11px;
  padding: 6px 9px;
  border-radius: var(--radius);
  z-index: 200;
  white-space: nowrap;
  display: none;
}

/* ============================================================
   TOP PATHS LIST
   ============================================================ */
.pathlist {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.pathlist li {
  display: grid;
  grid-template-columns: 20px 1fr auto;
  align-items: center;
  gap: 10px;
  font-size: 12px;
}
.pathlist .idx { color: var(--text-dim); }
.pathlist .path {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-primary);
}
.pathlist .count { color: var(--cyan); font-variant-numeric: tabular-nums; }
.pathlist .bar {
  grid-column: 1 / -1;
  height: 3px;
  background: var(--grid-line);
  border-radius: 2px;
  overflow: hidden;
}
.pathlist .bar span {
  display: block;
  height: 100%;
  background: var(--cyan);
}

/* ============================================================
   STATUS CODES
   ============================================================ */
.statusbars {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.statusrow {
  display: grid;
  grid-template-columns: 60px 1fr 70px;
  align-items: center;
  gap: 12px;
  font-size: 12px;
}
.statusrow .code { font-weight: 600; }
.statusrow .code[data-class="2"] { color: var(--cyan); }
.statusrow .code[data-class="3"] { color: var(--amber); }
.statusrow .code[data-class="4"], .statusrow .code[data-class="5"] { color: var(--red); }
.statusrow .track {
  height: 8px;
  background: var(--bg-panel-alt);
  border-radius: 4px;
  overflow: hidden;
  border: 1px solid var(--border);
}
.statusrow .fill { display: block; height: 100%; }
.statusrow .pct { text-align: right; color: var(--text-muted); font-variant-numeric: tabular-nums; }

/* ============================================================
   ABOUT
   ============================================================ */
.about { padding: 48px 0 20px; border-top: 1px solid var(--border); margin-top: 32px; }
.about h2 { font-family: var(--font-display); font-size: 16px; margin: 0 0 22px; }
.about__grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 22px;
}
.about__grid h3 {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--amber);
  letter-spacing: 0.06em;
  margin: 0 0 8px;
}
.about__grid p { font-size: 12.5px; color: var(--text-muted); margin: 0; }
.about__note { margin-top: 24px; font-size: 11px; color: var(--text-dim); }

/* ============================================================
   FOOTER
   ============================================================ */
.footer {
  text-align: center;
  padding: 22px;
  font-size: 11px;
  color: var(--text-dim);
  border-top: 1px solid var(--border);
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 880px) {
  .grid-main { grid-template-columns: 1fr; }
  .panel--heatmap { grid-row: auto; }
  .kpis { grid-template-columns: repeat(2, 1fr); }
  .about__grid { grid-template-columns: 1fr; }
  .heatmap { grid-template-columns: 26px repeat(24, minmax(10px, 1fr)); overflow-x: auto; }
}

@media (max-width: 560px) {
  .topbar { padding: 12px 16px; }
  .wrap { padding: 0 16px 40px; }
  .hero { padding: 36px 0 24px; }
}
