/* ============================================================
   COLOMBIA SECURITY & ECONOMY DASHBOARD
   Art Direction: Data-intelligence / geopolitical analysis
   Palette: Deep slate + crimson danger + amber warning + teal accent
   Fonts: Cabinet Grotesk (display) + Satoshi (body)
   ============================================================ */

/* -- Design Tokens -- */
:root {
  --text-xs: clamp(0.75rem, 0.7rem + 0.25vw, 0.875rem);
  --text-sm: clamp(0.875rem, 0.8rem + 0.35vw, 1rem);
  --text-base: clamp(1rem, 0.95rem + 0.25vw, 1.125rem);
  --text-lg: clamp(1.125rem, 1rem + 0.75vw, 1.5rem);
  --text-xl: clamp(1.5rem, 1.2rem + 1.25vw, 2.25rem);
  --text-2xl: clamp(2rem, 1.2rem + 2.5vw, 3.5rem);

  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.25rem;
  --space-6: 1.5rem;
  --space-8: 2rem;
  --space-10: 2.5rem;
  --space-12: 3rem;
  --space-16: 4rem;

  --radius-sm: 0.375rem;
  --radius-md: 0.5rem;
  --radius-lg: 0.75rem;
  --radius-xl: 1rem;
  --radius-full: 9999px;

  --transition-fast: 120ms cubic-bezier(0.16, 1, 0.3, 1);
  --transition-interactive: 200ms cubic-bezier(0.16, 1, 0.3, 1);

  /* Risk colors — consistent across modes */
  --risk-critical: #c0392b;
  --risk-high: #e67e22;
  --risk-medium: #f39c12;
  --risk-low: #27ae60;
  --risk-critical-bg: rgba(192, 57, 43, 0.12);
  --risk-high-bg: rgba(230, 126, 34, 0.12);
  --risk-medium-bg: rgba(243, 156, 18, 0.12);
  --risk-low-bg: rgba(39, 174, 96, 0.12);

  --font-display: 'Cabinet Grotesk', 'Helvetica Neue', sans-serif;
  --font-body: 'Satoshi', 'Inter', sans-serif;

  --content-wide: 1440px;
}

/* LIGHT MODE */
:root, [data-theme="light"] {
  --color-bg: #f0f0ed;
  --color-surface: #f5f5f2;
  --color-surface-2: #fafaf8;
  --color-surface-offset: #e8e8e4;
  --color-surface-dynamic: #deded9;
  --color-divider: #d0d0cb;
  --color-border: #c8c8c3;
  --color-text: #1a1a18;
  --color-text-muted: #5c5c58;
  --color-text-faint: #a8a8a4;
  --color-text-inverse: #f5f5f2;
  --color-primary: #0f7c8a;
  --color-primary-hover: #0a5f6b;
  --color-primary-highlight: #c6dfe3;
  --color-accent: #c0392b;
  --color-accent-hover: #962d22;
  --color-amber: #b8720a;
  --color-success: #267a38;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.08);
  --shadow-lg: 0 12px 40px rgba(0,0,0,0.12);
}

/* DARK MODE */
[data-theme="dark"] {
  --color-bg: #0e0f0f;
  --color-surface: #141616;
  --color-surface-2: #1a1c1c;
  --color-surface-offset: #111313;
  --color-surface-dynamic: #222525;
  --color-divider: #1e2121;
  --color-border: #2a2e2e;
  --color-text: #d4d8d8;
  --color-text-muted: #767c7c;
  --color-text-faint: #444a4a;
  --color-text-inverse: #141616;
  --color-primary: #3fa8b5;
  --color-primary-hover: #2a8e9a;
  --color-primary-highlight: #1a3538;
  --color-accent: #e05247;
  --color-accent-hover: #c7443a;
  --color-amber: #e8962a;
  --color-success: #4caf68;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.3);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.4);
  --shadow-lg: 0 12px 40px rgba(0,0,0,0.5);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    --color-bg: #0e0f0f;
    --color-surface: #141616;
    --color-surface-2: #1a1c1c;
    --color-surface-offset: #111313;
    --color-surface-dynamic: #222525;
    --color-divider: #1e2121;
    --color-border: #2a2e2e;
    --color-text: #d4d8d8;
    --color-text-muted: #767c7c;
    --color-text-faint: #444a4a;
    --color-text-inverse: #141616;
    --color-primary: #3fa8b5;
    --color-primary-hover: #2a8e9a;
    --color-primary-highlight: #1a3538;
    --color-accent: #e05247;
    --color-accent-hover: #c7443a;
    --color-amber: #e8962a;
    --color-success: #4caf68;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.3);
    --shadow-md: 0 4px 16px rgba(0,0,0,0.4);
    --shadow-lg: 0 12px 40px rgba(0,0,0,0.5);
  }
}

/* -- Base Reset -- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; -webkit-font-smoothing: antialiased; }
body {
  font-family: var(--font-body);
  font-size: var(--text-base);
  color: var(--color-text);
  background: var(--color-bg);
  min-height: 100dvh;
  line-height: 1.6;
}
img, svg { display: block; max-width: 100%; height: auto; }
button { cursor: pointer; background: none; border: none; font: inherit; color: inherit; }
input, select { font: inherit; color: inherit; }

/* -- HEADER -- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}
.header-inner {
  max-width: var(--content-wide);
  margin: 0 auto;
  padding: var(--space-3) var(--space-6);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
}
.header-brand {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}
.logo { flex-shrink: 0; }
.brand-title {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: var(--text-sm);
  color: var(--color-text);
  letter-spacing: -0.01em;
  line-height: 1.2;
}
.brand-sub {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  line-height: 1.2;
}
.header-controls {
  display: flex;
  align-items: center;
  gap: var(--space-4);
}
.data-badge {
  font-size: var(--text-xs);
  color: var(--color-text-faint);
  letter-spacing: 0.02em;
  display: none;
}
@media (min-width: 768px) { .data-badge { display: block; } }
.theme-toggle {
  width: 36px; height: 36px;
  border-radius: var(--radius-md);
  background: var(--color-surface-offset);
  border: 1px solid var(--color-border);
  display: flex; align-items: center; justify-content: center;
  color: var(--color-text-muted);
  transition: background var(--transition-fast), color var(--transition-fast);
}
.theme-toggle:hover { background: var(--color-surface-dynamic); color: var(--color-text); }

.lang-toggle {
  height: 36px;
  padding: 0 12px;
  border-radius: var(--radius-md);
  background: var(--color-surface-offset);
  border: 1px solid var(--color-border);
  display: flex; align-items: center; justify-content: center;
  color: var(--color-text-muted);
  font-family: var(--font-body);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  cursor: pointer;
  transition: background var(--transition-fast), color var(--transition-fast), border-color var(--transition-fast);
}
.lang-toggle:hover { background: var(--color-primary); color: #fff; border-color: var(--color-primary); }
.lang-toggle.active { background: var(--color-primary); color: #fff; border-color: var(--color-primary); }

/* -- KPI BAND -- */
.kpi-band {
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
}
.kpi-band-inner {
  max-width: var(--content-wide);
  margin: 0 auto;
  padding: var(--space-4) var(--space-6);
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: var(--space-3);
}
.kpi-card {
  padding: var(--space-4) var(--space-5);
  border-radius: var(--radius-lg);
  border: 1px solid var(--color-border);
  background: var(--color-surface-2);
  transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}
.kpi-card:hover { transform: translateY(-1px); box-shadow: var(--shadow-md); }
.kpi-value {
  font-family: var(--font-display);
  font-size: var(--text-xl);
  font-weight: 800;
  line-height: 1;
  letter-spacing: -0.02em;
  margin-bottom: var(--space-1);
}
.kpi-label { font-size: var(--text-xs); color: var(--color-text-muted); font-weight: 500; line-height: 1.3; margin-bottom: var(--space-1); }
.kpi-delta { font-size: var(--text-xs); color: var(--color-text-faint); }
.kpi-danger .kpi-value { color: var(--risk-critical); }
.kpi-warning .kpi-value { color: var(--color-amber); }
.kpi-negative .kpi-value { color: var(--color-accent); }
.kpi-critical .kpi-value { color: var(--risk-critical); }
.kpi-neutral .kpi-value { color: var(--color-primary); }

/* -- MAIN LAYOUT -- */
.main-layout {
  max-width: var(--content-wide);
  margin: 0 auto;
  padding: var(--space-6);
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-6);
  align-items: start;
}
@media (max-width: 1024px) { .main-layout { grid-template-columns: 1fr; } }

/* -- PANELS -- */
.panel {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.panel-header {
  padding: var(--space-5) var(--space-6) var(--space-4);
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--space-3);
}
.panel-title {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: var(--text-lg);
  letter-spacing: -0.02em;
  color: var(--color-text);
}
.panel-subtitle {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  margin-top: var(--space-1);
}

/* -- MAP -- */
.map-mode-tabs {
  display: flex;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-6);
  background: var(--color-surface-offset);
  border-bottom: 1px solid var(--color-border);
}
.map-tab {
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--color-text-muted);
  background: transparent;
  border: 1px solid transparent;
  transition: all var(--transition-fast);
}
.map-tab:hover { color: var(--color-text); background: var(--color-surface-dynamic); }
.map-tab.active {
  color: var(--color-primary);
  background: var(--color-primary-highlight);
  border-color: var(--color-primary);
}
.map-container {
  position: relative;
  width: 100%;
  background: var(--color-surface-2);
  min-height: 480px;
  display: flex;
  align-items: center;
  justify-content: center;
}
#colombia-map {
  width: 100%;
  height: 480px;
  cursor: pointer;
}
.map-tooltip {
  position: absolute;
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-3) var(--space-4);
  font-size: var(--text-xs);
  pointer-events: none;
  box-shadow: var(--shadow-md);
  max-width: 200px;
  z-index: 10;
}
.map-tooltip-name { font-weight: 700; font-size: var(--text-sm); margin-bottom: var(--space-1); }
.map-tooltip-row { display: flex; justify-content: space-between; gap: var(--space-4); }
.map-tooltip-val { font-weight: 600; }
.map-legend-inline {
  display: flex;
  gap: var(--space-3);
  align-items: center;
}
.legend-item {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  font-size: var(--text-xs);
  color: var(--color-text-muted);
}
.legend-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.map-footnote {
  padding: var(--space-2) var(--space-6);
  font-size: var(--text-xs);
  color: var(--color-text-faint);
  border-top: 1px solid var(--color-border);
  background: var(--color-surface-offset);
}

/* -- TABLE -- */
.table-controls {
  display: flex;
  gap: var(--space-2);
  flex-wrap: wrap;
}
.search-input {
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
  background: var(--color-surface-2);
  font-size: var(--text-xs);
  width: 160px;
  outline: none;
  transition: border-color var(--transition-fast);
}
.search-input:focus { border-color: var(--color-primary); }
.sort-select {
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
  background: var(--color-surface-2);
  font-size: var(--text-xs);
  outline: none;
  cursor: pointer;
}
.table-wrapper {
  overflow-x: auto;
  overflow-y: auto;
  max-height: 540px;
}
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-xs);
}
.data-table thead {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--color-surface-offset);
}
.data-table th {
  padding: var(--space-2) var(--space-3);
  text-align: left;
  font-weight: 700;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-size: 10px;
  white-space: nowrap;
  border-bottom: 1px solid var(--color-border);
  cursor: pointer;
  user-select: none;
}
.data-table th:hover { color: var(--color-text); }
.data-table td {
  padding: var(--space-2) var(--space-3);
  border-bottom: 1px solid var(--color-divider);
  vertical-align: middle;
  white-space: nowrap;
}
.data-table tbody tr {
  cursor: pointer;
  transition: background var(--transition-fast);
}
.data-table tbody tr:hover { background: var(--color-surface-offset); }
.data-table tbody tr.selected { background: var(--color-primary-highlight); }
.col-name { min-width: 160px; white-space: normal; font-weight: 600; }
.dept-name-cell { font-weight: 600; color: var(--color-text); }
.risk-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  white-space: nowrap;
}
.risk-critical { color: var(--risk-critical); background: var(--risk-critical-bg); }
.risk-high { color: var(--risk-high); background: var(--risk-high-bg); }
.risk-medium { color: var(--risk-medium); background: var(--risk-medium-bg); }
.risk-low { color: var(--risk-low); background: var(--risk-low-bg); }
.bar-cell { display: flex; align-items: center; gap: var(--space-2); }
.mini-bar {
  height: 6px;
  border-radius: 3px;
  flex-shrink: 0;
  transition: width var(--transition-interactive);
}
.gdp-positive { color: var(--color-success); font-weight: 600; }
.gdp-negative { color: var(--color-accent); font-weight: 600; }
.gdp-na { color: var(--color-text-faint); }

/* -- DETAIL OVERLAY -- */
.detail-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 200;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  backdrop-filter: blur(4px);
}
@media (min-width: 768px) {
  .detail-overlay { align-items: center; }
}
.detail-panel {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  width: 100%;
  max-width: 680px;
  max-height: 90dvh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
}
@media (min-width: 768px) {
  .detail-panel { border-radius: var(--radius-xl); }
}
.detail-header {
  padding: var(--space-5) var(--space-6);
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-4);
  position: sticky;
  top: 0;
  background: var(--color-surface);
  z-index: 2;
}
.detail-title {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: var(--text-lg);
  letter-spacing: -0.02em;
}
.detail-risk-badge { margin-top: var(--space-2); }
.detail-close {
  width: 32px; height: 32px;
  border-radius: var(--radius-md);
  background: var(--color-surface-offset);
  color: var(--color-text-muted);
  font-size: 16px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.detail-close:hover { background: var(--color-surface-dynamic); color: var(--color-text); }
.detail-body { padding: var(--space-6); }
.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-4);
  margin-bottom: var(--space-6);
}
.detail-stat {
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
}
.detail-stat-value {
  font-family: var(--font-display);
  font-size: var(--text-xl);
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1;
  margin-bottom: var(--space-1);
}
.detail-stat-label { font-size: var(--text-xs); color: var(--color-text-muted); }
.detail-section { margin-bottom: var(--space-5); }
.detail-section-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: var(--text-sm);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-text-muted);
  margin-bottom: var(--space-3);
}
.tag-list { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.tag {
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: 500;
  background: var(--color-surface-offset);
  border: 1px solid var(--color-border);
  color: var(--color-text-muted);
}
.tag.armed-group { color: var(--color-accent); background: var(--risk-critical-bg); border-color: rgba(192,57,43,0.2); }
.tag.sector { color: var(--color-primary); background: var(--color-primary-highlight); border-color: rgba(15,124,138,0.2); }
.detail-key-event {
  background: var(--color-surface-offset);
  border-left: 3px solid var(--color-accent);
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  padding: var(--space-3) var(--space-4);
  font-size: var(--text-sm);
  color: var(--color-text);
  margin-bottom: var(--space-4);
}
.detail-note {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  line-height: 1.6;
}

/* -- BOTTOM SECTION -- */
.bottom-section {
  max-width: var(--content-wide);
  margin: 0 auto;
  padding: 0 var(--space-6) var(--space-6);
}
.bottom-inner {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: var(--space-6);
}
@media (max-width: 1100px) { .bottom-inner { grid-template-columns: 1fr; } }

/* Sector panel */
.sector-panel, .chart-panel {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.sector-grid {
  padding: var(--space-5) var(--space-6);
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-4);
}
@media (max-width: 640px) { .sector-grid { grid-template-columns: 1fr; } }
.sector-card {
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
  cursor: pointer;
  transition: transform var(--transition-fast), box-shadow var(--transition-fast), border-color var(--transition-fast);
}
.sector-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); border-color: var(--color-primary); }
.sector-card-header { display: flex; align-items: center; gap: var(--space-3); margin-bottom: var(--space-3); }
.sector-icon { font-size: 1.5rem; }
.sector-name { font-family: var(--font-display); font-weight: 700; font-size: var(--text-sm); }
.sector-cost {
  font-size: var(--text-xs);
  font-weight: 600;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  background: var(--risk-critical-bg);
  color: var(--risk-critical);
}
.sector-bar-wrap { margin-bottom: var(--space-3); }
.sector-bar-label { display: flex; justify-content: space-between; font-size: var(--text-xs); color: var(--color-text-muted); margin-bottom: var(--space-1); }
.sector-bar-track {
  height: 6px;
  background: var(--color-surface-offset);
  border-radius: 3px;
  overflow: hidden;
}
.sector-bar-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.8s cubic-bezier(0.16, 1, 0.3, 1);
}
.impact-critical .sector-bar-fill { background: var(--risk-critical); }
.impact-high .sector-bar-fill { background: var(--risk-high); }
.impact-medium .sector-bar-fill { background: var(--risk-medium); }
.sector-depts { font-size: var(--text-xs); color: var(--color-text-faint); }

/* Chart panel */
.chart-container {
  padding: var(--space-5) var(--space-6);
  position: relative;
}
.chart-container canvas { max-height: 280px; }
.chart-note {
  padding: var(--space-3) var(--space-6);
  font-size: var(--text-xs);
  color: var(--color-text-faint);
  border-top: 1px solid var(--color-border);
}

/* -- TIMELINE -- */
.timeline-section {
  background: var(--color-surface);
  border-top: 1px solid var(--color-border);
  padding: var(--space-8) 0;
}
.timeline-inner {
  max-width: var(--content-wide);
  margin: 0 auto;
  padding: 0 var(--space-6);
}
.timeline-charts {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-6);
  margin-top: var(--space-6);
}
@media (max-width: 768px) { .timeline-charts { grid-template-columns: 1fr; } }
.timeline-chart-wrap {
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
}
.tchart-label {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: var(--text-sm);
  margin-bottom: var(--space-3);
  color: var(--color-text);
}
.timeline-chart-wrap canvas { max-height: 180px; }

/* -- FOOTER -- */
.site-footer {
  background: var(--color-surface-offset);
  border-top: 1px solid var(--color-border);
  padding: var(--space-8) 0;
}
.footer-inner {
  max-width: var(--content-wide);
  margin: 0 auto;
  padding: 0 var(--space-6);
}
.footer-sources {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  line-height: 1.8;
  margin-bottom: var(--space-4);
}
.footer-sources strong { color: var(--color-text); }
.footer-note { font-size: var(--text-xs); color: var(--color-text-faint); }

/* -- D3 MAP STYLES -- */
.dept-path {
  stroke: var(--color-surface);
  stroke-width: 0.5;
  cursor: pointer;
  transition: opacity 0.15s, stroke-width 0.15s;
}
.dept-path:hover { stroke-width: 1.5; stroke: var(--color-text); opacity: 0.85; }
.dept-path.selected { stroke: white; stroke-width: 1.5; }

/* Sort icons */
.sort-icon { opacity: 0.4; font-size: 10px; }
th.sorted-asc .sort-icon::after { content: ' ↑'; opacity: 1; }
th.sorted-desc .sort-icon::after { content: ' ↓'; opacity: 1; }

/* Scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--color-surface-offset); }
::-webkit-scrollbar-thumb { background: var(--color-border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--color-text-faint); }

/* ============================================================
   NEW COMPONENTS — GLOSSARY, KPI MODAL, SECTOR MODAL, HINTS
   ============================================================ */

/* ── GLOSSARY BANNER ──────────────────────────────────────── */
.glossary-banner {
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
}
.glossary-inner {
  max-width: 1320px;
  margin: 0 auto;
  padding: 0 24px;
}
.glossary-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 12px 0;
  background: none;
  border: none;
  color: var(--color-primary);
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
}
.glossary-toggle:hover { color: var(--color-text); }
.glossary-toggle span { flex: 1; }
.glossary-chevron { transition: transform 0.2s; }
.glossary-toggle.open .glossary-chevron { transform: rotate(180deg); }

.glossary-body {
  padding-bottom: 20px;
}
.glossary-intro {
  font-size: 13px;
  color: var(--color-text-muted);
  margin-bottom: 16px;
  line-height: 1.6;
  max-width: 860px;
}
.glossary-intro strong { color: var(--color-text); }

.glossary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}
.glossary-item {
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  padding: 12px 14px;
}
.glossary-term {
  font-size: 12px;
  font-weight: 700;
  color: var(--color-primary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 6px;
}
.glossary-def {
  font-size: 12px;
  color: var(--color-text-muted);
  line-height: 1.55;
}

.glossary-howto {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}
.glossary-howto-item {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  border-radius: 6px;
  padding: 8px 12px;
  font-size: 12px;
  color: var(--color-text-muted);
}
.howto-icon { font-size: 14px; }

/* ── KPI CLICKABLE ────────────────────────────────────────── */
.kpi-clickable {
  cursor: pointer;
  position: relative;
  transition: transform 0.15s, box-shadow 0.15s;
}
.kpi-clickable:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0,0,0,0.3);
}
.kpi-click-hint {
  position: absolute;
  top: 8px;
  right: 10px;
  font-size: 9px;
  font-weight: 500;
  color: var(--color-text-faint);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  opacity: 0;
  transition: opacity 0.15s;
}
.kpi-clickable:hover .kpi-click-hint { opacity: 1; }

/* ── TABLE HINT ───────────────────────────────────────────── */
.table-hint {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--color-text-faint);
  padding: 4px 0 8px 0;
}

/* ── DEPT NAME CELL WITH ARROW ────────────────────────────── */
.dept-name-cell {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}
.dept-row-arrow {
  font-size: 10px;
  color: var(--color-text-faint);
  opacity: 0;
  transition: opacity 0.15s, transform 0.15s;
}
#table-body tr:hover .dept-row-arrow {
  opacity: 1;
  transform: translateX(3px);
}
#table-body tr { cursor: pointer; }

/* ── MAP TOOLTIP CLICK HINT ───────────────────────────────── */
.map-tooltip-click {
  font-size: 10px;
  color: var(--color-primary);
  margin-top: 6px;
  font-weight: 500;
}

/* ── SECTOR CLICKABLE ─────────────────────────────────────── */
.sector-clickable {
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
}
.sector-clickable:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0,0,0,0.3);
}
.sector-arrow-hint {
  margin-left: auto;
  font-size: 14px;
  color: var(--color-text-faint);
  opacity: 0;
  transition: opacity 0.15s, transform 0.15s;
}
.sector-clickable:hover .sector-arrow-hint {
  opacity: 1;
  transform: translateX(3px);
}

/* ── KPI MODAL ────────────────────────────────────────────── */
.kpi-modal-overlay,
.sector-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.65);
  z-index: 1100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  backdrop-filter: blur(4px);
}
.kpi-modal,
.sector-modal {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 16px;
  max-width: 600px;
  width: 100%;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}
.kpi-modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 24px 24px 16px;
  border-bottom: 1px solid var(--color-border);
  position: sticky;
  top: 0;
  background: var(--color-surface);
  z-index: 1;
}
.kpi-modal-title {
  font-size: 17px;
  font-weight: 700;
  color: var(--color-text);
  line-height: 1.3;
  margin: 0;
}
.kpi-modal-body {
  padding: 20px 24px 24px;
}
.kpi-modal-body p {
  font-size: 14px;
  color: var(--color-text-muted);
  line-height: 1.65;
  margin: 0 0 16px;
}
.kpi-modal-body strong { color: var(--color-text); }

.kpi-modal-stat-row {
  display: flex;
  gap: 12px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.kpi-modal-stat {
  flex: 1;
  min-width: 110px;
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  border-radius: 10px;
  padding: 12px 14px;
  text-align: center;
}
.kpi-modal-stat-val {
  font-size: 22px;
  font-weight: 800;
  font-family: 'Cabinet Grotesk', sans-serif;
  line-height: 1.1;
  margin-bottom: 4px;
}
.kpi-modal-stat-lbl {
  font-size: 11px;
  color: var(--color-text-muted);
  line-height: 1.4;
}

.kpi-modal-breakdown {
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  border-radius: 10px;
  padding: 14px 16px;
  margin-bottom: 16px;
}
.kpi-modal-breakdown-title {
  font-size: 11px;
  font-weight: 600;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 12px;
}
.kpi-modal-bar-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}
.kpi-bar-label {
  font-size: 12px;
  color: var(--color-text);
  width: 140px;
  flex-shrink: 0;
}
.kpi-bar-track {
  flex: 1;
  height: 6px;
  background: var(--color-border);
  border-radius: 3px;
  overflow: hidden;
}
.kpi-bar-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.4s;
}
.kpi-bar-val {
  font-size: 11px;
  color: var(--color-text-muted);
  width: 60px;
  text-align: right;
}

.kpi-modal-note {
  font-size: 13px;
  color: var(--color-text-muted);
  line-height: 1.65;
  background: var(--color-surface-2);
  border-left: 3px solid var(--color-primary);
  padding: 12px 14px;
  border-radius: 0 8px 8px 0;
  margin-bottom: 16px;
}

.kpi-modal-source {
  font-size: 11px;
  color: var(--color-text-faint);
  margin: 0;
}

.threat-item {
  font-size: 13px;
  color: var(--color-text-muted);
  padding: 5px 0;
  border-bottom: 1px solid var(--color-border);
}
.threat-item:last-child { border-bottom: none; }

/* ── DETAIL PANEL IMPROVEMENTS ────────────────────────────── */
.detail-summary {
  font-size: 14px;
  color: var(--color-text-muted);
  line-height: 1.65;
  background: var(--color-surface-2);
  border-left: 3px solid var(--color-primary);
  padding: 14px 16px;
  border-radius: 0 8px 8px 0;
  margin-bottom: 20px;
}
.detail-summary strong { color: var(--color-text); }
.detail-key-event-inline {
  display: inline-block;
  margin-top: 4px;
  color: var(--color-warning);
  font-weight: 500;
}

.detail-stat-hint {
  font-size: 10px;
  color: var(--color-text-faint);
  line-height: 1.4;
  margin-top: 3px;
}

.detail-group-legend {
  font-size: 12px;
  color: var(--color-text-faint);
  margin-bottom: 10px;
  line-height: 1.5;
}

.detail-group-glossary {
  margin-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.group-def {
  font-size: 11px;
  color: var(--color-text-muted);
  line-height: 1.5;
  background: var(--color-surface-2);
  padding: 7px 10px;
  border-radius: 6px;
}
.group-def strong { color: var(--color-text); }

.invest-risk-block {
  font-size: 13px;
}

/* dept tags clickable in sector modal */
.dept-tag[data-dept-id]:hover {
  background: var(--color-primary);
  color: #fff;
}

/* tchart hint label */
.tchart-hint {
  font-size: 10px;
  color: var(--color-text-faint);
  font-weight: 400;
  margin-left: 6px;
}

/* ============================================================
   PRESIDENTIAL TERM SELECTOR
   ============================================================ */

.timeline-header-row {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-bottom: 20px;
}

.term-selector-wrap {
  width: 100%;
}

.term-selector {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.term-btn {
  padding: 7px 14px;
  border-radius: 20px;
  border: 1px solid var(--color-border);
  background: var(--color-surface-2);
  color: var(--color-text-muted);
  font-family: inherit;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}
.term-btn:hover {
  border-color: var(--color-primary);
  color: var(--color-primary);
  background: var(--color-primary-highlight);
}
.term-btn.active {
  background: var(--color-primary);
  border-color: var(--color-primary);
  color: #fff;
  font-weight: 600;
}

/* ── CONTEXT BAR ─────────────────────────────────────────── */
.term-context-bar {
  margin-bottom: 20px;
}
.ctx-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}
.ctx-label {
  font-size: 11px;
  color: var(--color-text-faint);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-right: 4px;
}
.ctx-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 600;
}
.ctx-pos {
  background: rgba(76, 175, 104, 0.15);
  color: var(--color-success);
  border: 1px solid rgba(76, 175, 104, 0.3);
}
.ctx-neg {
  background: rgba(224, 82, 71, 0.12);
  color: var(--color-accent);
  border: 1px solid rgba(224, 82, 71, 0.25);
}

/* ── TIMELINE CHARTS GRID ────────────────────────────────── */
.timeline-charts {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 20px;
}

/* ============================================================
   CUSTOM DUAL-HANDLE YEAR RANGE SLIDER
   ============================================================ */

.range-row {
  margin-bottom: 16px;
}

/* Year labels row above the track */
.range-labels-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}

.range-year-badge {
  display: inline-block;
  font-size: 14px;
  font-weight: 800;
  font-family: 'Cabinet Grotesk', sans-serif;
  color: var(--color-primary);
  background: var(--color-primary-highlight);
  border: 1.5px solid var(--color-primary);
  border-radius: 7px;
  padding: 4px 10px;
  min-width: 44px;
  text-align: center;
  letter-spacing: -0.01em;
  transition: background 0.15s;
}

.range-dash {
  font-size: 14px;
  color: var(--color-text-faint);
  font-weight: 400;
}

/* Outer container — gives the rail full available width */
.slider-outer {
  width: 100%;
  padding: 0 12px;
  box-sizing: border-box;
}

/* The rail — the draggable track area */
.slider-rail {
  position: relative;
  width: 100%;
  height: 6px;
  background: var(--color-border);
  border-radius: 3px;
  cursor: pointer;
  margin-bottom: 10px;
}

/* Highlighted range between the two handles */
.slider-fill {
  position: absolute;
  height: 100%;
  background: var(--color-primary);
  border-radius: 3px;
  pointer-events: none;
  top: 0;
}

/* Drag handles */
.slider-handle {
  position: absolute;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--color-primary);
  border: 3px solid var(--color-bg, #0e0f0f);
  box-shadow: 0 0 0 2px var(--color-primary), 0 2px 8px rgba(0,0,0,0.4);
  cursor: grab;
  z-index: 2;
  transition: box-shadow 0.15s, transform 0.1s;
  outline: none;
}
.slider-handle:hover {
  box-shadow: 0 0 0 4px rgba(63,168,181,0.25), 0 2px 10px rgba(0,0,0,0.4);
}
.slider-handle.dragging,
.slider-handle:active {
  cursor: grabbing;
  transform: translate(-50%, -50%) scale(1.18);
  box-shadow: 0 0 0 5px rgba(63,168,181,0.3), 0 3px 12px rgba(0,0,0,0.5);
}
.slider-handle:focus-visible {
  box-shadow: 0 0 0 4px rgba(63,168,181,0.5), 0 2px 8px rgba(0,0,0,0.4);
}

/* Axis labels below the track */
.slider-axis-labels {
  display: flex;
  justify-content: space-between;
  font-size: 10px;
  color: var(--color-text-faint);
  font-weight: 500;
  padding: 0 2px;
  user-select: none;
}

/* ── QUICK-PICK CHIPS ─────────────────────────────────────── */
.term-chips {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-top: 4px;
}

.chips-label {
  font-size: 11px;
  color: var(--color-text-faint);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-right: 2px;
  white-space: nowrap;
}

.term-chip {
  padding: 5px 11px;
  border-radius: 16px;
  border: 1px solid var(--color-border);
  background: var(--color-surface-2);
  color: var(--color-text-muted);
  font-family: inherit;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.12s;
  white-space: nowrap;
}
.term-chip:hover {
  border-color: var(--color-primary);
  color: var(--color-primary);
  background: var(--color-primary-highlight);
}
.term-chip.active {
  background: var(--color-primary);
  border-color: var(--color-primary);
  color: #fff;
}
.term-chip-all {
  border-style: dashed;
}
.term-chip-all.active {
  border-style: solid;
}

/* ============================================================
   SIGNATURE & WATERMARK
   ============================================================ */

/* ── FOOTER SIGNATURE BLOCK ──────────────────────────────── */
.footer-signature {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--color-border);
}

.signature-lockup {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}

.signature-logo {
  flex-shrink: 0;
  opacity: 0.9;
}

.signature-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.signature-name {
  font-size: 15px;
  font-weight: 700;
  font-family: 'Cabinet Grotesk', sans-serif;
  color: var(--color-text);
  letter-spacing: -0.01em;
}

.signature-company {
  font-size: 11px;
  font-weight: 500;
  color: var(--color-primary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.signature-divider {
  width: 1px;
  height: 32px;
  background: var(--color-border);
  flex-shrink: 0;
}

.signature-meta {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.signature-tag {
  font-size: 11px;
  color: var(--color-text-muted);
  font-weight: 500;
}

.signature-year {
  font-size: 11px;
  color: var(--color-text-faint);
}

/* ── FLOATING WATERMARK ───────────────────────────────────── */
.watermark {
  position: fixed;
  bottom: 18px;
  right: 20px;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 600;
  font-family: 'Cabinet Grotesk', sans-serif;
  color: var(--color-primary);
  opacity: 0.35;
  pointer-events: none;
  user-select: none;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  z-index: 10;
  transition: opacity 0.2s;
}
.watermark:hover {
  opacity: 0.7;
  pointer-events: auto;
}
