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

:root {
  --bg: #0a0e17;
  --bg-card: #111827;
  --bg-card-hover: #1a2332;
  --border: #1e293b;
  --text: #e2e8f0;
  --text-dim: #94a3b8;
  --text-bright: #f8fafc;
  --accent: #3b82f6;
  --accent-dim: #1e40af;
  --red: #ef4444;
  --orange: #f97316;
  --yellow: #eab308;
  --green: #22c55e;
  --cyan: #06b6d4;
  --purple: #a855f7;
  --font-mono: 'SF Mono', 'Cascadia Code', 'Fira Code', 'Consolas', monospace;
  --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.6;
  min-height: 100vh;
}

/* === Header === */
header {
  background: linear-gradient(180deg, #0f1729 0%, var(--bg) 100%);
  border-bottom: 1px solid var(--border);
  padding: 24px 32px 16px;
}

.header-content h1 {
  font-size: 20px;
  font-weight: 600;
  color: var(--text-bright);
  letter-spacing: -0.02em;
}

.subtitle {
  color: var(--text-dim);
  font-size: 13px;
  margin-top: 4px;
}

.last-updated {
  color: var(--text-dim);
  font-size: 11px;
  font-family: var(--font-mono);
  margin-top: 8px;
}

/* === Navigation === */
nav {
  display: flex;
  gap: 4px;
  padding: 8px 32px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  position: sticky;
  top: 0;
  z-index: 100;
  overflow-x: auto;
}

.nav-btn {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-dim);
  font-size: 12px;
  font-family: var(--font-sans);
  padding: 6px 14px;
  border-radius: 6px;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s ease;
}

.nav-btn:hover {
  color: var(--text);
  background: var(--bg-card);
}

.nav-btn.active {
  color: var(--text-bright);
  background: var(--bg-card);
  border-color: var(--border);
}

/* Sub-navigation (Inputs subtabs) */
.subnav {
  display: flex;
  gap: 4px;
  padding: 4px 32px 6px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  position: sticky;
  top: 42px; /* below main nav (8+6+~14+6+8+1border ≈ 43px) */
  z-index: 99;
}
.subnav.hidden { display: none; }

.subnav-btn {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-dim);
  font-size: 11px;
  font-family: var(--font-sans);
  padding: 4px 10px;
  border-radius: 4px;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s ease;
}
.subnav-btn:hover {
  color: var(--text);
  background: var(--bg-card);
}
.subnav-btn.active {
  color: var(--text-bright);
  background: var(--bg-card);
  border-color: var(--border);
}

/* === Main Layout === */
main {
  padding: 24px 32px;
  max-width: 1400px;
  margin: 0 auto;
}

.dashboard-section {
  display: none;
}

.dashboard-section.active {
  display: block;
}

/* === Grid === */
.grid-2col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 16px;
}

@media (max-width: 900px) {
  .grid-2col {
    grid-template-columns: 1fr;
  }
  main { padding: 16px; }
  nav { padding: 8px 16px; }
  header { padding: 16px; }
}

/* === Cards === */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 20px;
}

.card h2 {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-bright);
  margin-bottom: 4px;
}

.card-desc {
  font-size: 12px;
  color: var(--text-dim);
  margin-bottom: 16px;
}

.card.full-width {
  margin-bottom: 16px;
}

/* === Charts (Chart.js canvases only — not force-graph) === */
.card > canvas {
  width: 100% !important;
  max-height: 300px;
}

/* === Timeline === */
.timeline {
  max-height: 320px;
  overflow-y: auto;
}

.timeline-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}

.timeline-item:last-child {
  border-bottom: none;
}

.timeline-date {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-dim);
  min-width: 80px;
  flex-shrink: 0;
}

.timeline-body {
  flex: 1;
}

.timeline-title {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
}

.timeline-meta {
  font-size: 11px;
  color: var(--text-dim);
  margin-top: 2px;
}

.tag {
  display: inline-block;
  font-size: 10px;
  font-family: var(--font-mono);
  padding: 1px 6px;
  border-radius: 3px;
  margin-right: 4px;
}

.tag-frontier-closed {
  background: var(--accent-dim);
  color: var(--accent);
}

.tag-open-weights, .tag-frontier-open {
  background: #14532d;
  color: var(--green);
}

.tag-fine-tune {
  background: #3b0764;
  color: var(--purple);
}

/* === Event Feed === */
.event-feed {
  max-height: 320px;
  overflow-y: auto;
}

.event-feed-merged {
  max-height: 600px;
}

.event-filter-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 10px;
}

.event-chip {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-dim);
  font-family: var(--font-mono);
  font-size: 11px;
  padding: 3px 10px;
  border-radius: 12px;
  cursor: pointer;
}

.event-chip:hover {
  color: var(--text);
  border-color: var(--text-dim);
}

.event-chip.active {
  background: var(--border);
  color: var(--text);
  border-color: var(--text-dim);
}

.event-category {
  font-size: 9px;
  font-family: var(--font-mono);
  text-transform: uppercase;
  padding: 1px 5px;
  border-radius: 3px;
  font-weight: 600;
  letter-spacing: 0.03em;
}

.event-category-agents { background: #1e293b; color: #93c5fd; }
.event-category-ecosystem { background: #422006; color: var(--yellow); }
.event-category-geopolitical { background: #3b0764; color: var(--purple); }
.event-category-regulatory { background: #052e16; color: var(--green); }

.event-item {
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}

.event-item:last-child {
  border-bottom: none;
}

.event-header {
  display: flex;
  align-items: center;
  gap: 8px;
}

.event-date {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-dim);
}

.impact-badge {
  font-size: 9px;
  font-family: var(--font-mono);
  text-transform: uppercase;
  padding: 1px 5px;
  border-radius: 3px;
  font-weight: 600;
}

.impact-critical { background: #450a0a; color: var(--red); }
.impact-high { background: #431407; color: var(--orange); }
.impact-medium { background: #422006; color: var(--yellow); }
.impact-low { background: #052e16; color: var(--green); }

/* RSI potential badges */
.rsi-badge {
  font-size: 9px;
  font-family: var(--font-mono);
  text-transform: uppercase;
  padding: 1px 5px;
  border-radius: 3px;
  font-weight: 600;
}
.rsi-none   { background: #1e293b; color: var(--text-dim); }
.rsi-low    { background: #052e16; color: var(--green); }
.rsi-medium { background: #422006; color: var(--yellow); }
.rsi-high   { background: #450a0a; color: var(--red); }

.event-title {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  margin-top: 4px;
}

.event-detail {
  font-size: 12px;
  color: var(--text-dim);
  margin-top: 2px;
}

.event-subtitle {
  font-size: 11px;
  color: var(--text-dim);
  opacity: 0.7;
  margin-top: 1px;
  font-family: var(--font-mono);
}

/* === Data Tables === */
.data-table-container {
  overflow-x: auto;
}

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

.data-table th {
  text-align: left;
  font-weight: 600;
  color: var(--text-dim);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.data-table th[data-sort]:hover {
  color: var(--text);
  background: var(--bg-card-hover);
}

.data-table td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  vertical-align: top;
}

.data-table tr:hover td {
  background: var(--bg-card-hover);
}

.data-table a {
  color: var(--accent);
  text-decoration: none;
}

.data-table a:hover {
  text-decoration: underline;
}

/* === Status indicators === */
.status {
  font-size: 10px;
  font-family: var(--font-mono);
  padding: 2px 6px;
  border-radius: 3px;
}

.status-enacted, .status-in-effect {
  background: #052e16;
  color: var(--green);
}

.status-proposed {
  background: #422006;
  color: var(--yellow);
}

.status-repealed {
  background: #1c1917;
  color: var(--text-dim);
}

/* === Log badges === */
.tag-collector { background: #1e3a5f; color: var(--cyan); }
.tag-curator   { background: #3b0764; color: var(--purple); }
.tag-manual    { background: #422006; color: var(--yellow); }
.tag-scheduler { background: #1c1917; color: var(--text-dim); }

.action-badge {
  font-size: 9px;
  font-family: var(--font-mono);
  text-transform: uppercase;
  padding: 1px 5px;
  border-radius: 3px;
  font-weight: 600;
}

.action-added     { background: #052e16; color: var(--green); }
.action-updated   { background: #1e3a5f; color: var(--accent); }
.action-removed   { background: #450a0a; color: var(--red); }
.action-refreshed { background: #1c1917; color: var(--text-dim); }
.action-error     { background: #450a0a; color: var(--red); }

.log-details {
  cursor: help;
  color: var(--text-dim);
  font-size: 10px;
}

/* === Footer === */
footer {
  border-top: 1px solid var(--border);
  padding: 16px 32px;
  text-align: center;
  font-size: 12px;
  color: var(--text-dim);
}

footer a {
  color: var(--accent);
  text-decoration: none;
}

footer a:hover {
  text-decoration: underline;
}

/* === Print === */
@media print {
  /* Force dark background and colors to print */
  * {
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
    color-adjust: exact !important;
  }

  body {
    background: var(--bg) !important;
    color: var(--text) !important;
    font-size: 11px;
    min-height: auto !important;
  }

  header {
    background: #0f1729 !important;
    padding: 4px 16px !important;
    border: none !important;
  }

  .header-content h1 {
    font-size: 16px !important;
  }

  .subtitle, .last-updated {
    margin: 0 !important;
    font-size: 10px !important;
  }

  /* Hide nav — not useful on paper */
  nav {
    display: none !important;
    height: 0 !important;
  }

  main {
    padding: 4px 16px !important;
    margin: 0 !important;
  }

  /* Only show the active section */
  .dashboard-section {
    display: none !important;
    height: 0 !important;
    overflow: hidden !important;
  }

  .dashboard-section.active {
    display: block !important;
    height: auto !important;
    overflow: visible !important;
  }

  /* Cards */
  .card {
    background: var(--bg-card) !important;
    border-color: var(--border) !important;
    page-break-inside: avoid;
  }

  /* Charts — give them a fixed height so they render */
  canvas {
    max-height: 250px !important;
  }

  /* Grids — keep side by side if space allows */
  .grid-2col {
    grid-template-columns: 1fr 1fr;
  }

  /* Keep scrollable containers compact for print */
  .timeline, .event-feed {
    max-height: 300px !important;
    overflow: hidden !important;
  }

  /* Tables — allow content to show fully in print */
  .data-table-container {
    max-height: none !important;
    overflow: visible !important;
  }

  .data-table th {
    color: var(--text-dim) !important;
    border-bottom-color: var(--border) !important;
  }

  .data-table td {
    color: var(--text) !important;
    border-bottom-color: var(--border) !important;
  }

  .data-table tr:hover td {
    background: transparent !important;
  }

  /* Tags and badges — force colors */
  .tag, .impact-badge, .status {
    border: 1px solid var(--border);
  }

  /* Footer */
  footer {
    page-break-before: avoid;
    padding: 4px 16px !important;
  }

  /* Prevent canvases from overflowing */
  .card {
    overflow: hidden !important;
  }

  /* Avoid page breaks inside chart cards */
  .card:has(canvas) {
    page-break-inside: avoid;
  }

  /* Margins for paper */
  @page {
    margin: 1cm;
  }
}

/* === Focus-visible === */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
.data-table th[data-sort]:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* === Scrollbar === */
/* Firefox */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--border) var(--bg);
}

/* Chromium / Safari */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: var(--bg);
}

::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: #334155;
}

/* === Knowledge Graph Browser === */

.kb-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.kb-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  flex: 1;
}

.kb-type-btn {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text-dim);
  font-size: 11px;
  padding: 4px 10px;
  border-radius: 4px;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s;
}

.kb-type-btn:hover {
  border-color: var(--type-color, var(--accent));
  color: var(--text);
}

.kb-type-btn.active {
  background: var(--bg-card);
  border-color: var(--type-color, var(--accent));
  color: var(--type-color, var(--accent));
}

.kb-search {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: 13px;
  padding: 6px 12px;
  width: 220px;
  outline: none;
}

.kb-search:focus {
  border-color: var(--accent);
}

.kb-view-toggle {
  display: flex;
  gap: 4px;
}

.kb-view-btn {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text-dim);
  font-size: 11px;
  padding: 4px 10px;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.15s;
}

.kb-view-btn.active {
  background: var(--bg-card);
  border-color: var(--accent);
  color: var(--accent);
}

.kb-status-bar {
  font-size: 11px;
  font-family: var(--font-mono);
  color: var(--text-dim);
  margin-top: 4px;
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 18px;
}

@keyframes kb-spin {
  to { transform: rotate(360deg); }
}

.kb-spinner {
  display: inline-block;
  width: 11px;
  height: 11px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: kb-spin 0.7s linear infinite;
  flex-shrink: 0;
}

/* Node list (table view) */
.kb-node-list {
  max-height: 600px;
  overflow-y: auto;
}

.kb-node-row {
  display: grid;
  grid-template-columns: 90px 1fr 2fr 2fr;
  gap: 12px;
  align-items: baseline;
  padding: 7px 4px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.1s;
}

.kb-node-row:hover {
  background: var(--bg-card-hover);
}

.kb-node-type {
  font-size: 11px;
  font-family: var(--font-mono);
  font-weight: 600;
  flex-shrink: 0;
}

.kb-node-label {
  font-size: 13px;
  color: var(--text-bright);
  font-weight: 500;
}

.kb-node-summary {
  font-size: 12px;
  color: var(--text-dim);
}

.kb-node-edges {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  align-items: flex-start;
}

.kb-edge-pill {
  display: inline-block;
  font-size: 11px;
  font-family: var(--font-mono);
  color: var(--text-dim);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 1px 5px;
  cursor: pointer;
  white-space: nowrap;
  transition: color 0.1s, border-color 0.1s;
}

.kb-edge-pill:hover {
  color: var(--accent);
  border-color: var(--accent);
}

.kb-empty {
  padding: 24px;
  text-align: center;
  color: var(--text-dim);
  font-size: 13px;
}

/* Graph view */
.kb-graph-card {
  position: relative;
}

.kb-graph-container {
  width: 100%;
  height: calc(100vh - 280px);
  min-height: 500px;
  background: var(--bg);
  border-radius: 6px;
  border: 1px solid var(--border);
  overflow: hidden;
}

.kb-graph-canvas {
  width: 100%;
  height: 100%;
}



/* Force-graph tooltip (2D — positioned near cursor) */
.kb-graph-tooltip {
  position: fixed;
  z-index: 300;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 12px;
  font-size: 12px;
  color: var(--text);
  line-height: 1.5;
  max-width: 300px;
  pointer-events: none;
  box-shadow: 0 4px 16px rgba(0,0,0,0.5);
}

.kb-graph-tooltip strong {
  color: var(--text-bright);
}

.kb-graph-tooltip em {
  color: var(--text-dim);
  font-style: normal;
}

/* 3D graph tooltip (generated by force-graph nodeLabel) */
.graph-tooltip {
  background: var(--bg-card) !important;
  border: 1px solid var(--border) !important;
  border-radius: 6px !important;
  padding: 8px 12px !important;
  font-size: 12px !important;
  color: var(--text) !important;
  line-height: 1.5 !important;
  max-width: 300px !important;
  box-shadow: 0 4px 16px rgba(0,0,0,0.5) !important;
  font-family: var(--font-sans) !important;
}

/* Graph legend */
.kb-graph-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 16px;
  padding: 8px 0;
  font-size: 11px;
  color: var(--text-dim);
}

.kb-legend-section {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 10px;
}

.kb-legend-title {
  font-weight: 600;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-dim);
  margin-right: 4px;
}

.kb-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
}

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

.kb-legend-line {
  display: inline-block;
  width: 14px;
  height: 2px;
  border-radius: 1px;
  flex-shrink: 0;
}

/* Detail sidebar — fixed right panel, slides in over content */
.kb-detail {
  position: fixed;
  top: 0;
  right: 0;
  width: 380px;
  height: 100vh;
  background: var(--bg-card);
  border-left: 1px solid var(--border);
  z-index: 200;
  display: flex;
  flex-direction: column;
  box-shadow: -4px 0 24px rgba(0,0,0,0.4);
}

.kb-type-badge {
  font-size: 11px;
  font-family: var(--font-mono);
  font-weight: 600;
  margin-left: 8px;
  vertical-align: middle;
}

.kb-detail-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  padding: 16px 16px 0 16px;
  flex-shrink: 0;
}

.kb-detail-header h2 {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-bright);
  line-height: 1.4;
}

.kb-close-btn {
  background: transparent;
  border: none;
  color: var(--text-dim);
  font-size: 16px;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
  flex-shrink: 0;
  line-height: 1;
}

.kb-close-btn:hover {
  color: var(--text);
  background: var(--bg);
}

.kb-detail-summary {
  font-size: 12px;
  color: var(--text-dim);
  line-height: 1.5;
  padding: 8px 16px 12px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.kb-detail-body {
  flex: 1;
  overflow-y: auto;
  padding: 0 16px 16px 16px;
}

@media (max-width: 900px) {
  .kb-detail {
    width: 100vw;
    top: auto;
    bottom: 0;
    height: 60vh;
    border-left: none;
    border-top: 1px solid var(--border);
    box-shadow: 0 -4px 24px rgba(0,0,0,0.4);
  }
}

.kb-detail-section {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-dim);
  margin: 16px 0 8px;
}

.kb-edge-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 0;
  border-bottom: 1px solid var(--border);
  font-size: 12px;
}

.kb-edge-rel {
  font-family: var(--font-mono);
  color: var(--accent);
  min-width: 120px;
}

.kb-edge-dir {
  color: var(--text-dim);
}

.kb-edge-other {
  color: var(--text);
  cursor: pointer;
  text-decoration: underline;
  text-decoration-color: var(--border);
}

.kb-edge-other:hover {
  color: var(--accent);
}

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

.kb-data-key {
  font-family: var(--font-mono);
  color: var(--text-dim);
  padding: 4px 12px 4px 0;
  vertical-align: top;
  white-space: nowrap;
  width: 160px;
}

.kb-data-group {
  color: var(--text);
  font-weight: 600;
  padding-top: 10px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.kb-data-sub {
  padding-left: 16px;
  color: var(--text-dim);
}

.kb-data-val {
  color: var(--text);
  padding: 4px 0;
  word-break: break-word;
}

.kb-source {
  font-size: 11px;
  padding: 2px 0;
}

.kb-source a {
  color: var(--accent);
  text-decoration: none;
  word-break: break-all;
}

.kb-source a:hover {
  text-decoration: underline;
}

/* === Markets / Drift Cards === */

.markets-drift-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 12px;
  margin-top: 12px;
}

.market-forecast-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

@media (max-width: 900px) {
  .market-forecast-grid {
    grid-template-columns: 1fr;
  }
}

.drift-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 12px;
}

.drift-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}

.drift-platform {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.drift-change {
  font-size: 13px;
  font-weight: 600;
  font-family: var(--font-mono);
}

.drift-up { color: var(--green); }
.drift-down { color: var(--red); }

.drift-label {
  font-size: 12px;
  color: var(--text);
  line-height: 1.4;
  margin-bottom: 8px;
  min-height: 34px;
}

.drift-label a {
  color: var(--text);
  text-decoration: none;
}

.drift-label a:hover {
  color: var(--accent);
  text-decoration: underline;
}

.drift-sparkline {
  height: 40px;
  margin-bottom: 6px;
}

.drift-sparkline canvas {
  width: 100% !important;
  height: 40px !important;
}

.drift-footer {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}

.drift-current {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-bright);
  font-family: var(--font-mono);
}

.drift-meta {
  font-size: 10px;
  color: var(--text-dim);
}

/* Relevance score indicator */
.relevance-dot {
  display: inline-block;
  width: 16px;
  height: 16px;
  line-height: 16px;
  border-radius: 50%;
  text-align: center;
  font-size: 9px;
  font-weight: 600;
  font-family: var(--font-mono);
  color: var(--bg);
}

.relevance-5 { background: var(--green); }
.relevance-4 { background: var(--cyan); }
.relevance-3 { background: var(--yellow); }
.relevance-2 { background: var(--orange); }
.relevance-1 { background: var(--red); opacity: 0.6; }
.relevance-0 { background: var(--text-dim); opacity: 0.4; }

/* Indicator cards (Forecasts section, Phase 3) */
.indicators-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 12px;
  margin-top: 12px;
}

.indicator-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.indicator-card.indicator-ok {
  border-left: 3px solid var(--green);
}

.indicator-card.indicator-not_reached,
.indicator-card.indicator-no_crossing {
  border-left: 3px solid var(--yellow);
}

.indicator-card.indicator-already_met {
  border-left: 3px solid var(--cyan);
}

.indicator-card.indicator-insufficient_data,
.indicator-card.indicator-no_result {
  border-left: 3px solid var(--text-dim);
}

.indicator-question {
  font-size: 13px;
  color: var(--text);
  line-height: 1.4;
  font-weight: 500;
}

.indicator-result {
  display: flex;
  align-items: baseline;
}

.indicator-answer {
  font-size: 24px;
  font-weight: 700;
  color: var(--text-bright);
  font-family: var(--font-mono);
}

.indicator-prob {
  color: var(--green);
}

.indicator-unreached {
  color: var(--yellow);
  font-size: 18px;
}

.indicator-met {
  color: var(--cyan);
  font-size: 18px;
}

.indicator-nodata {
  color: var(--text-dim);
  font-size: 14px;
  font-weight: 400;
}

.indicator-detail {
  font-size: 11px;
  color: var(--text-dim);
  line-height: 1.5;
  font-family: var(--font-mono);
}

.indicator-series {
  font-size: 10px;
  color: var(--text-dim);
  opacity: 0.7;
}

.indicator-tags {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

.indicator-tag {
  font-size: 9px;
  padding: 1px 6px;
  border-radius: 3px;
  background: var(--accent-dim);
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* Model comparison within indicator cards */
.indicator-mc {
  margin-top: 4px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}

.mc-warning {
  display: inline-block;
  font-size: 10px;
  font-weight: 600;
  color: var(--yellow);
  margin-bottom: 6px;
}

.mc-table {
  width: 100%;
  font-size: 10px;
  border-collapse: collapse;
  font-family: var(--font-mono);
}

.mc-table th {
  text-align: left;
  color: var(--text-dim);
  font-weight: 500;
  padding: 2px 6px 2px 0;
  border-bottom: 1px solid var(--border);
}

.mc-table td {
  padding: 3px 6px 3px 0;
  color: var(--text-dim);
}

.mc-table tr.mc-selected td {
  color: var(--text-bright);
  font-weight: 600;
}

/* Calibration display (backtest results) */
.cal-summary {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 16px;
}

.cal-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12px;
  font-family: var(--font-mono);
}

.cal-band {
  width: 30px;
  color: var(--text-dim);
  font-weight: 600;
}

.cal-bar-container {
  flex: 1;
  height: 16px;
  background: var(--bg-card);
  border-radius: 3px;
  position: relative;
  overflow: hidden;
}

.cal-bar-expected {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  border-right: 2px dashed var(--text-dim);
  opacity: 0.4;
}

.cal-bar-actual {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  border-radius: 3px;
  opacity: 0.7;
}

.cal-bar-actual.cal-ok { background: var(--green); }
.cal-bar-actual.cal-over { background: var(--red); }
.cal-bar-actual.cal-under { background: var(--yellow); }

.cal-value {
  width: 80px;
  text-align: right;
  color: var(--text);
}

.cal-verdict {
  width: 100px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
}

.cal-verdict.cal-ok { color: var(--green); }
.cal-verdict.cal-over { color: var(--red); }
.cal-verdict.cal-under { color: var(--yellow); }

.cal-n {
  color: var(--text-dim);
  font-size: 10px;
}

.cal-table {
  width: 100%;
  font-size: 11px;
  border-collapse: collapse;
  font-family: var(--font-mono);
}

.cal-table th {
  text-align: left;
  color: var(--text-dim);
  font-weight: 500;
  padding: 4px 8px;
  border-bottom: 1px solid var(--border);
}

.cal-table td {
  padding: 4px 8px;
  color: var(--text);
  border-bottom: 1px solid var(--border);
}

.cal-table td.cal-ok { color: var(--green); }
.cal-table td.cal-over { color: var(--red); }
.cal-table td.cal-under { color: var(--yellow); }

/* ---- Forecast interval toggle ---- */

.forecast-controls {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 8px;
}

.forecast-interval-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
}

.interval-label {
  font-size: 12px;
  color: var(--text-dim);
  cursor: pointer;
  transition: color 0.15s;
  user-select: none;
}

.interval-label--active {
  color: var(--accent);
  font-weight: 600;
}

.forecast-controls .toggle-switch {
  position: relative;
  width: 36px;
  height: 20px;
  background: var(--accent);
  border: none;
  border-radius: 10px;
  cursor: pointer;
  padding: 0;
  transition: background 0.2s;
  flex-shrink: 0;
}

.forecast-controls .toggle-switch::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  background: var(--bg-card);
  border-radius: 50%;
  transition: transform 0.2s;
}

.forecast-controls .toggle-switch[aria-checked="true"] {
  background: var(--text-dim);
}

.forecast-controls .toggle-switch[aria-checked="true"]::after {
  transform: translateX(16px);
}

/* ---- Track record stats ---- */

.tr-stats {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.tr-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 70px;
  padding: 8px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
}

.tr-stat-value {
  font-size: 18px;
  font-weight: 600;
  color: var(--text);
  font-family: var(--font-mono);
}

.tr-stat-label {
  font-size: 11px;
  color: var(--text-dim);
  margin-top: 2px;
}

.tr-section-title {
  color: var(--text-dim);
  font-size: 13px;
  margin: 16px 0 6px;
}

.tr-charts-row {
  display: flex;
  gap: 24px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}

.tr-charts-row > * {
  flex: 1;
  min-width: 300px;
}

.tr-spark {
  vertical-align: middle;
}

.tr-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 8px;
}

.tr-tab {
  padding: 3px 10px;
  font-size: 11px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text-dim);
  cursor: pointer;
}

.tr-tab:hover {
  color: var(--text);
  border-color: var(--text-dim);
}

.tr-tab-active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.tr-toggle-label {
  color: var(--text-dim);
  font-weight: 400;
}

.tr-sortable {
  cursor: pointer;
  user-select: none;
}

.tr-sortable:hover {
  color: var(--text);
}
