/* ========== TOKENS ========== */
:root {
  /* Dark mode (default) */
  --bg: #07131c;
  --bg-grad-1: #0a1c2a;
  --bg-grad-2: #061018;
  --panel: #0d2233;
  --panel-2: #143046;
  --panel-3: #1c3f5b;
  --panel-glass: rgba(20, 48, 70, 0.55);
  --line: #1d3953;
  --line-2: #264e6f;
  --grid: #15334b;

  --ink: #eaf3f8;
  --ink-2: #aac0ce;
  --ink-3: #6f8a9c;
  --ink-4: #4b6478;

  --brand: #3abddc;         /* ERA cyan */
  --brand-2: #5fcfeb;
  --brand-3: #1d8aa8;
  --navy: #023c59;          /* ERA deep navy */
  --navy-2: #08527a;
  --gold: #f4b942;          /* warm accent */
  --gold-2: #f9d27a;

  --red: #ef5b5b;
  --red-2: #c93939;
  --orange: #f08a3e;
  --yellow: #f4cc3a;
  --green: #2fc18a;
  --blue: #3a9aff;

  --flag-alto: #ef5b5b;
  --flag-anom: #f08a3e;
  --flag-sosp: #f4cc3a;
  --flag-norm: #2fc18a;

  --exceso: #ef5b5b;
  --defecto: #3abddc;

  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 16px;
  --radius-xl: 22px;

  --shadow-1: 0 1px 0 rgba(255,255,255,0.04) inset, 0 1px 3px rgba(0,0,0,0.4);
  --shadow-2: 0 8px 28px rgba(0,0,0,0.45);
  --shadow-glow: 0 0 0 1px rgba(58, 189, 220, 0.25), 0 8px 32px rgba(58, 189, 220, 0.18);

  --font-display: 'Manrope', system-ui, sans-serif;
  --font-body: 'Manrope', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, monospace;
}

:root.light {
  --bg: #f3f6f9;
  --bg-grad-1: #ffffff;
  --bg-grad-2: #e8eef3;
  --panel: #ffffff;
  --panel-2: #f1f5f9;
  --panel-3: #e1eaf2;
  --panel-glass: rgba(255,255,255,0.85);
  --line: #d8e2eb;
  --line-2: #b8c8d6;
  --grid: #e1eaf2;

  --ink: #07131c;
  --ink-2: #3a526a;
  --ink-3: #6a8194;
  --ink-4: #94a5b4;

  --brand: #1f8aa8;
  --brand-2: #3abddc;
  --brand-3: #023c59;
  --navy: #023c59;
  --navy-2: #08527a;
  --gold: #c89020;
  --gold-2: #e0a93b;

  --flag-alto: #d63838;
  --flag-anom: #d77c2a;
  --flag-sosp: #c69d20;
  --flag-norm: #1f9f70;

  --shadow-2: 0 4px 14px rgba(2, 60, 89, 0.12);
  --shadow-glow: 0 0 0 1px rgba(31, 138, 168, 0.25), 0 6px 18px rgba(31, 138, 168, 0.15);
}

/* ========== BASE ========== */
* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  font-feature-settings: "cv11", "ss03";
}
body {
  background:
    radial-gradient(ellipse 80% 60% at 20% -10%, rgba(58,189,220,0.10), transparent 60%),
    radial-gradient(ellipse 60% 40% at 90% 5%, rgba(244,185,66,0.06), transparent 60%),
    linear-gradient(180deg, var(--bg-grad-1) 0%, var(--bg-grad-2) 600px, var(--bg) 1200px);
  min-height: 100vh;
}
:root.light body {
  background:
    radial-gradient(ellipse 80% 60% at 20% -10%, rgba(31,138,168,0.10), transparent 60%),
    linear-gradient(180deg, var(--bg-grad-1) 0%, var(--bg-grad-2) 600px, var(--bg) 1200px);
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; }
input { font-family: inherit; }
.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.num { font-family: var(--font-mono); font-variant-numeric: tabular-nums; font-feature-settings: "ss01"; }
.tab-num { font-variant-numeric: tabular-nums; }

/* ========== APP SHELL ========== */
.app {
  max-width: 1640px;
  margin: 0 auto;
  padding: 0 28px 80px;
}
.header .app {
  padding-bottom: 0;
}

/* ========== HEADER ========== */
.header {
  position: sticky;
  top: 0;
  z-index: 50;
  padding: 16px 0 0;
  background: linear-gradient(180deg, rgba(7,19,28,0.95) 0%, rgba(7,19,28,0.85) 80%, transparent 100%);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
  margin-bottom: 0;
}
:root.light .header {
  background: linear-gradient(180deg, rgba(243,246,249,0.96) 0%, rgba(243,246,249,0.85) 80%, transparent 100%);
}
.header-top {
  display: flex; justify-content: space-between; align-items: flex-start; gap: 24px; flex-wrap: wrap;
  padding-bottom: 14px;
  max-height: 120px;
  overflow: hidden;
  opacity: 1;
  transition: max-height 0.35s ease, opacity 0.25s ease, padding-bottom 0.3s ease;
}
.brand-block { display: flex; gap: 14px; align-items: center; min-width: 0; }
.brand-mark {
  width: 44px; height: 44px;
  border-radius: 11px;
  background: linear-gradient(135deg, var(--navy) 0%, var(--brand-3) 60%, var(--brand) 110%);
  display: grid; place-items: center;
  position: relative;
  box-shadow: 0 4px 16px rgba(58,189,220,0.25), inset 0 1px 0 rgba(255,255,255,0.15);
  flex-shrink: 0;
}
.brand-mark::before {
  content: ''; position: absolute; inset: 4px;
  border-radius: 8px;
  background: radial-gradient(circle at 30% 30%, rgba(255,255,255,0.18), transparent 60%);
}
.brand-mark svg { position: relative; z-index: 1; }
.brand-text { display: flex; flex-direction: column; min-width: 0; }
.brand-name {
  font-family: var(--font-display);
  font-weight: 700; font-size: 15px; letter-spacing: -0.01em;
  line-height: 1.1;
}
.brand-tag {
  font-size: 11px; color: var(--ink-3);
  letter-spacing: 0.02em;
  margin-top: 2px;
}
.brand-pipe { color: var(--ink-4); margin: 0 6px; }

.header-actions { display: flex; gap: 8px; align-items: center; }
.icon-btn {
  background: var(--panel-2);
  border: 1px solid var(--line);
  color: var(--ink-2);
  border-radius: 8px;
  padding: 7px 12px;
  cursor: pointer;
  display: inline-flex; gap: 8px; align-items: center;
  font-size: 12px; font-weight: 500;
  transition: all 0.15s;
}
.icon-btn:hover { border-color: var(--brand); color: var(--ink); }
.icon-btn.active { background: var(--brand); color: #052431; border-color: var(--brand); }

/* ========== HERO KPIs ========== */
.hero-kpis {
  display: flex;
  gap: 8px;
  margin-top: 6px;
  align-items: stretch;
  transition: gap 0.3s ease, margin-top 0.3s ease;
}
.hero-kpis .kpi {
  flex: 1;
}
.hero-kpis .kpi.kpi-main {
  flex: 1.5;
}
@media (max-width: 1200px) {
  .hero-kpis { flex-wrap: wrap; }
  .hero-kpis .kpi { flex: 1 1 30%; }
  .hero-kpis .kpi.kpi-main { flex: 1 1 100%; }
}
@media (max-width: 720px) {
  .hero-kpis .kpi { flex: 1 1 45%; }
}
.kpi {
  background: linear-gradient(180deg, var(--panel) 0%, var(--panel-2) 100%);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 8px 12px;
  position: relative;
  overflow: hidden;
  transition: padding 0.3s ease;
}
.kpi::before {
  content: ''; position: absolute; left: 0; top: 0; bottom: 0;
  width: 3px;
  background: var(--brand);
  opacity: 0.6;
}
.kpi.red::before { background: var(--flag-alto); }
.kpi.orange::before { background: var(--flag-anom); }
.kpi.yellow::before { background: var(--flag-sosp); }
.kpi.green::before { background: var(--flag-norm); }
.kpi.gold::before { background: var(--gold); }

.kpi-label {
  font-size: 10.5px; color: var(--ink-3);
  text-transform: uppercase; letter-spacing: 0.08em;
  font-weight: 600;
}
.kpi-val {
  font-family: var(--font-display);
  font-weight: 700; font-size: 18px;
  line-height: 1.05;
  margin-top: 3px;
  letter-spacing: -0.025em;
  font-variant-numeric: tabular-nums;
  transition: font-size 0.3s ease, margin-top 0.3s ease;
}
.kpi.kpi-main .kpi-val { font-size: 20px; }
.kpi-sub {
  font-size: 10px; color: var(--ink-3);
  margin-top: 1px;
  transition: opacity 0.2s ease, max-height 0.3s ease;
}
.kpi-sub .accent { color: var(--brand); font-weight: 600; }

.kpi.red .kpi-val { color: #ff8273; }
.kpi.orange .kpi-val { color: #ffa75a; }
.kpi.yellow .kpi-val { color: var(--gold-2); }
.kpi.green .kpi-val { color: #5dd9aa; }
.kpi.gold .kpi-val { color: var(--gold-2); }

:root.light .kpi.red .kpi-val { color: var(--flag-alto); }
:root.light .kpi.orange .kpi-val { color: var(--flag-anom); }
:root.light .kpi.yellow .kpi-val { color: var(--flag-sosp); }
:root.light .kpi.green .kpi-val { color: var(--flag-norm); }

/* spark in KPI */
.kpi-spark { position: absolute; right: 12px; bottom: 8px; opacity: 0.4; }

/* ========== FILTER BAR ========== */
.filter-bar {
  display: flex; gap: 12px; align-items: center; flex-wrap: wrap;
  padding: 12px 0;
  border-top: 1px solid var(--line);
  margin-top: 14px;
  max-height: 140px;
  overflow: hidden;
  opacity: 1;
  transition: max-height 0.35s ease, opacity 0.25s ease, padding 0.3s ease, margin 0.3s ease, border-color 0.3s ease;
}
.search {
  position: relative;
  flex: 0 0 280px;
}
.search input {
  width: 100%;
  background: var(--panel-2);
  border: 1px solid var(--line);
  color: var(--ink);
  font-size: 13px;
  padding: 8px 12px 8px 36px;
  border-radius: 8px;
  outline: none;
  transition: all 0.15s;
}
.search input:focus { border-color: var(--brand); background: var(--panel-3); box-shadow: var(--shadow-glow); }
.search-icon {
  position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
  color: var(--ink-3);
  pointer-events: none;
}

.chip-row { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.chip {
  font-size: 11.5px;
  padding: 5px 11px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--ink-2);
  cursor: pointer;
  user-select: none;
  transition: all 0.15s;
  white-space: nowrap;
}
.chip:hover { border-color: var(--brand); color: var(--ink); }
.chip.on { background: var(--brand); color: #052431; border-color: var(--brand); font-weight: 600; }
.chip.flag-alto.on { background: var(--flag-alto); color: #fff; border-color: var(--flag-alto); }
.chip.flag-anom.on { background: var(--flag-anom); color: #fff; border-color: var(--flag-anom); }
.chip.flag-sosp.on { background: var(--flag-sosp); color: #2a1f00; border-color: var(--flag-sosp); }
.chip.flag-norm.on { background: var(--flag-norm); color: #fff; border-color: var(--flag-norm); }
.chip-sm { font-size: 10.5px; padding: 3px 8px; }

.filter-group { display: flex; gap: 8px; align-items: center; padding-right: 14px; border-right: 1px solid var(--line); }
.filter-group:last-of-type { border-right: none; }
.filter-label {
  font-size: 10px; color: var(--ink-3);
  text-transform: uppercase; letter-spacing: 0.08em;
  font-weight: 600;
}

.match-info { margin-left: auto; color: var(--ink-2); font-size: 12px; }
.match-info b { color: var(--brand); font-family: var(--font-mono); font-weight: 600; font-size: 14px; }

/* ========== TABS ========== */
.tabs {
  display: flex; gap: 2px; flex-wrap: wrap;
  border-bottom: 1px solid var(--line);
  margin: 8px 0 0;
  overflow-x: auto;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  font-size: 13px;
  padding: 12px 16px;
  color: var(--ink-3);
  border-bottom: 2px solid transparent;
  cursor: pointer;
  font-weight: 500;
  white-space: nowrap;
  display: flex; gap: 8px; align-items: center;
  transition: all 0.15s;
}
.tab:hover { color: var(--ink); }
.tab.active { color: var(--brand); border-bottom-color: var(--brand); font-weight: 600; }
.tab .num-dot {
  font-size: 10px;
  padding: 1px 6px; border-radius: 8px;
  background: var(--panel-3);
  color: var(--ink-2);
  font-family: var(--font-mono);
}
.tab.active .num-dot { background: var(--brand); color: #052431; }

/* ========== HEADER COLLAPSED ========== */
.header.collapsed {
  padding-top: 8px;
}
.header.collapsed .header-top {
  max-height: 0;
  opacity: 0;
  padding-bottom: 0;
}
.header.collapsed .filter-bar {
  max-height: 0;
  opacity: 0;
  padding: 0;
  margin-top: 0;
  border-color: transparent;
}
.header.collapsed .hero-kpis {
  margin-top: 4px;
  gap: 8px;
}
.header.collapsed .kpi {
  padding: 6px 12px;
}
.header.collapsed .kpi-val {
  font-size: 17px;
  margin-top: 2px;
}
.header.collapsed .kpi.kpi-main .kpi-val {
  font-size: 19px;
}
.header.collapsed .kpi-sub {
  opacity: 0;
  max-height: 0;
  overflow: hidden;
}
.header.collapsed .tabs {
  margin-top: 6px;
}

/* ========== SECTIONS ========== */
.section {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 22px 26px;
  margin-bottom: 20px;
}
.section.glass {
  background:
    linear-gradient(135deg, rgba(58,189,220,0.05) 0%, transparent 40%),
    var(--panel);
}
.section-head { display: flex; justify-content: space-between; gap: 16px; align-items: flex-end; margin-bottom: 18px; flex-wrap: wrap; }
.section-title {
  font-family: var(--font-display);
  font-size: 22px; font-weight: 700; letter-spacing: -0.025em;
  margin: 0;
  display: flex; gap: 12px; align-items: center;
}
.section-eyebrow {
  font-size: 10.5px;
  color: var(--brand);
  text-transform: uppercase; letter-spacing: 0.12em;
  font-weight: 700;
  margin-bottom: 6px;
}
.section-lede {
  color: var(--ink-2); font-size: 13.5px;
  max-width: 720px;
  line-height: 1.6;
}

/* ========== HERO SUMMARY ========== */
.hero {
  background:
    radial-gradient(circle at 85% 20%, rgba(58,189,220,0.18), transparent 50%),
    radial-gradient(circle at 15% 90%, rgba(244,185,66,0.10), transparent 50%),
    linear-gradient(135deg, #0a1e2d 0%, #0d2438 100%);
  border: 1px solid var(--line-2);
  border-radius: var(--radius-xl);
  padding: 36px 38px;
  margin-bottom: 28px;
  position: relative;
  overflow: hidden;
}
:root.light .hero {
  background:
    radial-gradient(circle at 85% 20%, rgba(58,189,220,0.10), transparent 50%),
    linear-gradient(135deg, #ffffff 0%, #eef3f8 100%);
}
.hero-eyebrow {
  font-size: 11px; color: var(--brand);
  text-transform: uppercase; letter-spacing: 0.16em;
  font-weight: 700;
  display: flex; align-items: center; gap: 10px;
}
.hero-eyebrow::before {
  content: ''; width: 24px; height: 1px; background: var(--brand);
}
.hero h1 {
  font-family: var(--font-display);
  font-size: 44px; font-weight: 800; letter-spacing: -0.035em;
  line-height: 1.04;
  margin: 14px 0 12px;
  text-wrap: balance;
  max-width: 22ch;
}
.hero h1 .accent { color: var(--brand); }
.hero h1 .accent-gold { color: var(--gold); }
.hero .hero-sub {
  color: var(--ink-2);
  font-size: 16px;
  max-width: 62ch;
  text-wrap: pretty;
  line-height: 1.55;
}
.hero-stats {
  display: grid; grid-template-columns: repeat(4, 1fr);
  gap: 18px;
  margin-top: 28px;
  padding-top: 24px;
  border-top: 1px solid var(--line);
}
@media (max-width: 900px) {
  .hero-stats { grid-template-columns: repeat(2, 1fr); }
}
.hero-stat-val {
  font-family: var(--font-display);
  font-size: 36px; font-weight: 800; letter-spacing: -0.03em;
  line-height: 1;
}
.hero-stat-val.cyan { color: var(--brand); }
.hero-stat-val.gold { color: var(--gold); }
.hero-stat-val.red { color: var(--flag-alto); }
.hero-stat-label {
  font-size: 11.5px; color: var(--ink-3);
  text-transform: uppercase; letter-spacing: 0.08em;
  font-weight: 600;
  margin-top: 8px;
}
.hero-stat-help { font-size: 12px; color: var(--ink-2); margin-top: 4px; }

/* ========== STAT CARDS ========== */
.stat-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
}
.card {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
}
.card-title {
  font-size: 11px; color: var(--ink-3);
  text-transform: uppercase; letter-spacing: 0.08em;
  font-weight: 600; margin-bottom: 10px;
  display: flex; justify-content: space-between; align-items: center;
}

/* ========== FLAG PILLS ========== */
.flag {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 10.5px;
  padding: 3px 8px;
  border-radius: 11px;
  font-weight: 600;
  white-space: nowrap;
  letter-spacing: 0.01em;
}
.flag .dot { width: 6px; height: 6px; border-radius: 50%; }
.flag.alto { background: rgba(239,91,91,0.15); color: var(--flag-alto); }
.flag.alto .dot { background: var(--flag-alto); }
.flag.anom { background: rgba(240,138,62,0.15); color: var(--flag-anom); }
.flag.anom .dot { background: var(--flag-anom); }
.flag.sosp { background: rgba(244,204,58,0.15); color: var(--flag-sosp); }
.flag.sosp .dot { background: var(--flag-sosp); }
.flag.norm { background: rgba(47,193,138,0.15); color: var(--flag-norm); }
.flag.norm .dot { background: var(--flag-norm); }

.flag.solid.alto { background: var(--flag-alto); color: #fff; }
.flag.solid.anom { background: var(--flag-anom); color: #fff; }
.flag.solid.sosp { background: var(--flag-sosp); color: #2a1f00; }
.flag.solid.norm { background: var(--flag-norm); color: #fff; }

/* ========== TABLE ========== */
.table-wrap {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}
.dtable {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
}
.dtable thead {
  background: var(--panel-2);
}
.dtable th {
  text-align: left;
  padding: 11px 14px;
  font-size: 10.5px; color: var(--ink-3);
  text-transform: uppercase; letter-spacing: 0.08em;
  font-weight: 600;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}
.dtable th:hover { color: var(--ink); }
.dtable th .sort-ico { opacity: 0.4; margin-left: 4px; font-size: 9px; }
.dtable th.sort-asc .sort-ico, .dtable th.sort-desc .sort-ico { opacity: 1; color: var(--brand); }
.dtable td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}
.dtable tbody tr { transition: background 0.1s; cursor: pointer; }
.dtable tbody tr:hover { background: var(--panel-2); }
.dtable tbody tr:last-child td { border-bottom: none; }
.dtable .num { text-align: right; font-family: var(--font-mono); font-size: 12px; }
.dtable .name { font-weight: 600; }
.dtable .sub { font-size: 11px; color: var(--ink-3); font-weight: 400; margin-top: 2px; }
.dtable .compact-cell { padding: 8px 14px; }
.dtable tr.selected { background: rgba(58,189,220,0.08); }
.dtable tr.selected td { border-color: var(--brand-3); }

/* mini-bar inline */
.mini-bar {
  display: inline-block;
  width: 70px; height: 4px;
  background: var(--panel-3);
  border-radius: 2px;
  position: relative;
  vertical-align: middle;
  margin-right: 8px;
}
.mini-bar .fill { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 2px; background: var(--brand); }

/* ========== TOOLTIP ========== */
.tooltip {
  position: fixed;
  background: var(--panel-2);
  border: 1px solid var(--brand-3);
  color: var(--ink);
  font-size: 12px;
  padding: 8px 11px;
  border-radius: 8px;
  pointer-events: none;
  z-index: 999;
  max-width: 280px;
  box-shadow: var(--shadow-2);
  line-height: 1.5;
}
.tooltip .tt-name { font-weight: 700; margin-bottom: 4px; font-family: var(--font-display); }
.tooltip .tt-meta { color: var(--ink-2); font-size: 11px; }
.tooltip .tt-row { display: flex; justify-content: space-between; gap: 12px; font-size: 11.5px; }
.tooltip .tt-row .lbl { color: var(--ink-3); }
.tooltip .tt-row .val { font-family: var(--font-mono); font-weight: 600; }

/* ========== MODAL ========== */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(3,12,20,0.7);
  backdrop-filter: blur(6px);
  z-index: 200;
  display: grid; place-items: center;
  padding: 24px;
}
.modal {
  background: var(--panel);
  border: 1px solid var(--line-2);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 1100px;
  max-height: 90vh;
  overflow: auto;
  box-shadow: var(--shadow-2);
}
.modal-head {
  display: flex; justify-content: space-between; align-items: flex-start;
  gap: 20px;
  padding: 24px 28px 18px;
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0;
  background: var(--panel);
  z-index: 1;
}
.modal-close {
  background: transparent; border: 1px solid var(--line); color: var(--ink-2);
  width: 32px; height: 32px; border-radius: 8px;
  cursor: pointer; font-size: 16px;
  display: grid; place-items: center;
}
.modal-close:hover { border-color: var(--red); color: var(--red); }
.modal-body { padding: 22px 28px 28px; }
.modal-title {
  font-family: var(--font-display);
  font-size: 26px; font-weight: 700; letter-spacing: -0.025em;
  line-height: 1.1; margin: 0;
}
.modal-meta { color: var(--ink-2); font-size: 13px; margin-top: 8px; }
.modal-meta .dot { color: var(--ink-4); margin: 0 8px; }

/* ========== SVG CHART HELPERS ========== */
svg text { font-family: var(--font-body); fill: var(--ink-2); }
svg .axis-line { stroke: var(--grid); stroke-width: 1; }
svg .axis-text { fill: var(--ink-3); font-size: 11px; }
svg .axis-label { fill: var(--ink-3); font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.06em; }
svg .grid-line { stroke: var(--grid); stroke-width: 1; stroke-dasharray: 2,3; opacity: 0.5; }
svg .ref-line { stroke: var(--ink-3); stroke-dasharray: 3,3; }

/* ========== HEATMAP ========== */
.heatmap {
  display: grid;
  grid-template-columns: 220px repeat(11, minmax(28px, 1fr)) 80px;
  gap: 2px;
  align-items: stretch;
  font-size: 11px;
}
.hm-head {
  font-size: 9.5px;
  color: var(--ink-3);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  text-align: center;
  padding: 4px;
  font-weight: 600;
}
.hm-name {
  padding: 4px 10px;
  color: var(--ink);
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  border-right: 1px solid var(--line);
  display: flex; flex-direction: column; justify-content: center;
}
.hm-name .sub { color: var(--ink-3); font-size: 10px; }
.hm-cell {
  height: 26px;
  border-radius: 3px;
  display: grid; place-items: center;
  font-size: 9px;
  color: #052431;
  font-weight: 700;
  font-family: var(--font-mono);
  cursor: help;
  transition: transform 0.1s;
}
.hm-cell:hover { transform: scale(1.15); z-index: 2; }
.hm-flag-col {
  display: grid; place-items: center;
  padding: 0 6px;
}

/* ========== BULLETS ========== */
.bullet {
  display: grid;
  grid-template-columns: 220px 1fr 120px;
  gap: 14px;
  align-items: center;
  margin-bottom: 10px;
  font-size: 12px;
}
.bullet-name { color: var(--ink); }
.bullet-name b { font-weight: 600; }
.bullet-name .cat { color: var(--ink-3); font-size: 11px; display: block; margin-top: 2px; }
.bullet-bar {
  height: 24px;
  background: var(--panel-3);
  border-radius: 4px;
  position: relative;
  border: 1px solid var(--line);
  overflow: hidden;
}
.bullet-peer { position: absolute; top: 0; bottom: 0; background: var(--panel-glass); }
.bullet-peer.range { background: linear-gradient(90deg, transparent 0%, rgba(58,189,220,0.18) 50%, transparent 100%); }
.bullet-median { position: absolute; top: -3px; bottom: -3px; width: 2px; background: var(--ink); }
.bullet-local { position: absolute; top: 4px; bottom: 4px; border-radius: 2px; background: var(--red); }
.bullet-local.def { background: var(--brand); }
.bullet-metric { text-align: right; font-family: var(--font-mono); font-size: 12px; }
.bullet-metric strong { font-size: 16px; display: block; font-weight: 700; }
.bullet-metric .z { font-size: 10.5px; }

/* ========== RANKING CARDS ========== */
.rank-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(380px, 1fr)); gap: 14px; }
.rank-card {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
  position: relative;
  overflow: hidden;
  cursor: pointer;
  transition: all 0.15s;
}
.rank-card:hover { border-color: var(--brand); transform: translateY(-1px); box-shadow: var(--shadow-2); }
.rank-card .rank-num {
  position: absolute; top: 14px; right: 16px;
  font-family: var(--font-display);
  font-size: 38px; font-weight: 800; letter-spacing: -0.04em;
  color: var(--ink-4);
  line-height: 1;
}
.rank-card.alto { border-left: 4px solid var(--flag-alto); }
.rank-card.anom { border-left: 4px solid var(--flag-anom); }
.rank-card.sosp { border-left: 4px solid var(--flag-sosp); }
.rank-card h3 {
  font-family: var(--font-display);
  font-size: 16px; font-weight: 700;
  margin: 0 0 4px;
  padding-right: 50px;
  line-height: 1.2;
}
.rank-card .meta { font-size: 11.5px; color: var(--ink-3); margin-bottom: 12px; }
.rank-card .metrics { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 12px; }
.rank-metric { font-size: 11px; color: var(--ink-3); }
.rank-metric b { display: block; font-size: 18px; color: var(--ink); font-family: var(--font-mono); font-weight: 700; margin-top: 2px; }
.rank-metric.cyan b { color: var(--brand); }
.rank-metric.red b { color: var(--flag-alto); }
.rank-action {
  font-size: 12px;
  color: var(--ink-2);
  border-top: 1px dashed var(--line);
  padding-top: 10px;
  margin-top: 6px;
}
.rank-action .lbl { color: var(--ink-3); font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.06em; margin-right: 8px; }

/* ========== SCATTER ========== */
.scatter-wrap { position: relative; }
.scatter-dot { transition: opacity 0.15s, r 0.15s; cursor: pointer; }
.scatter-dot:hover { stroke: var(--ink); stroke-width: 2; }
.scatter-dot.dim { opacity: 0.25; }
.scatter-quadrant {
  fill: none;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

/* ========== TWEAKS PANEL ========== */
.tweaks {
  position: fixed;
  right: 20px;
  top: 84px;
  width: 280px;
  background: var(--panel);
  border: 1px solid var(--line-2);
  border-radius: var(--radius);
  box-shadow: var(--shadow-2);
  padding: 16px 18px;
  z-index: 80;
  font-size: 12px;
}
.tweaks h4 {
  font-family: var(--font-display);
  margin: 0 0 12px;
  font-size: 13px;
  font-weight: 700;
  display: flex; justify-content: space-between; align-items: center;
}
.tweaks .close-x {
  background: transparent; border: none; color: var(--ink-3); cursor: pointer;
  font-size: 18px; line-height: 1;
}
.tweaks .group { margin-bottom: 14px; }
.tweaks .group:last-child { margin-bottom: 0; }
.tweaks .group-lbl {
  font-size: 10px; color: var(--ink-3);
  text-transform: uppercase; letter-spacing: 0.08em;
  font-weight: 600; margin-bottom: 6px;
}
.tweak-seg { display: flex; gap: 4px; background: var(--panel-2); padding: 3px; border-radius: 7px; border: 1px solid var(--line); }
.tweak-seg button {
  flex: 1; background: transparent; border: none; color: var(--ink-2);
  font-size: 11px; padding: 6px 8px; border-radius: 5px; cursor: pointer;
}
.tweak-seg button.on { background: var(--brand); color: #052431; font-weight: 600; }

/* ========== UTILITIES ========== */
.row { display: flex; gap: 12px; align-items: center; }
.row.between { justify-content: space-between; }
.row.wrap { flex-wrap: wrap; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 18px; }
@media (max-width: 1100px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } }
.spacer { flex: 1; }
.divider { height: 1px; background: var(--line); margin: 16px 0; }
.muted { color: var(--ink-3); }
.eyebrow {
  font-size: 10px; color: var(--brand);
  text-transform: uppercase; letter-spacing: 0.12em;
  font-weight: 700;
}
.delta-pos { color: var(--green); }
.delta-neg { color: var(--red); }

/* Conclusions / findings */
.finding {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-left: 3px solid var(--brand);
  border-radius: var(--radius);
  padding: 18px 22px;
  margin-bottom: 12px;
}
.finding.red { border-left-color: var(--flag-alto); }
.finding.gold { border-left-color: var(--gold); }
.finding.green { border-left-color: var(--flag-norm); }
.finding-eyebrow {
  font-size: 10.5px; color: var(--brand);
  text-transform: uppercase; letter-spacing: 0.08em;
  font-weight: 700;
  display: flex; gap: 8px; align-items: center;
}
.finding.red .finding-eyebrow { color: var(--flag-alto); }
.finding.gold .finding-eyebrow { color: var(--gold); }
.finding.green .finding-eyebrow { color: var(--flag-norm); }
.finding-num {
  font-family: var(--font-mono);
  background: var(--panel-3);
  color: var(--ink-2);
  padding: 1px 7px;
  border-radius: 6px;
  font-size: 10px;
}
.finding h3 {
  font-family: var(--font-display);
  font-size: 18px; font-weight: 700; letter-spacing: -0.02em;
  margin: 8px 0 6px;
  text-wrap: balance;
}
.finding p { color: var(--ink-2); margin: 0; line-height: 1.55; }
.finding .stat-inline {
  background: var(--panel-3);
  padding: 1px 6px;
  border-radius: 4px;
  font-family: var(--font-mono);
  font-weight: 600;
  color: var(--ink);
  font-size: 12.5px;
}

/* Region badge */
.region-pill {
  font-family: var(--font-mono);
  font-size: 10px;
  padding: 2px 7px;
  border-radius: 4px;
  background: var(--panel-3);
  color: var(--ink-2);
  font-weight: 600;
}

/* Legend */
.legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: 11.5px; color: var(--ink-3); margin: 8px 0 14px; }
.legend .sw { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: 6px; vertical-align: middle; }
.legend .sw.line { height: 2px; border-radius: 0; margin-bottom: 3px; }

/* Hide modal scroll */
.modal::-webkit-scrollbar { width: 8px; }
.modal::-webkit-scrollbar-track { background: transparent; }
.modal::-webkit-scrollbar-thumb { background: var(--line-2); border-radius: 4px; }
