/* ═══════════════════════════════════════════════════
   MSCIP — Institutional Intelligence Terminal Theme
   ═══════════════════════════════════════════════════ */
:root {
  /* ── Backgrounds (slate palette) ── */
  --bg-base:      #020617;   /* slate-950 — page background */
  --bg-panel:     #0f172a;   /* slate-900 — sidebar, header, footer */
  --bg-card:      #0f172a;   /* slate-900 — panel/card surface */
  --bg-card-alt:  #1e293b;   /* slate-800 — card headers, alt rows */
  --bg-hover:     #1e293b;   /* slate-800 — hover state */
  --bg-input:     #0f172a;
  --border:       #1e293b;   /* slate-800 */
  --border-dim:   #0f172a;   /* slate-900 — subtle dividers */
  --border-hi:    #334155;   /* slate-700 — hover/focus borders */

  /* ── Text (slate palette) ── */
  --text-pri:     #f1f5f9;   /* slate-100 — headlines */
  --text-sec:     #cbd5e1;   /* slate-300 — body */
  --text-dim:     #64748b;   /* slate-500 — muted/eyebrows */
  --text-ter:     #94a3b8;   /* slate-400 — tertiary/captions */
  --text-inv:     #020617;

  /* ── Accent palette ── */
  --accent:       #3b82f6;   /* blue-500 — primary accent (nav active, links) */
  --accent-dim:   rgba(59,130,246,0.12);
  --accent-glow:  rgba(59,130,246,0.25);
  --green:        #10b981;   /* emerald-500 — online/positive */
  --green-dim:    rgba(16,185,129,0.12);
  --red:          #f43f5e;   /* rose-500 — alert/negative */
  --red-dim:      rgba(244,63,94,0.12);
  --amber:        #f59e0b;   /* amber-500 — warning/inferred */
  --amber-dim:    rgba(245,158,11,0.12);
  --blue:         #3b82f6;   /* blue-500 */
  --purple:       #8b5cf6;   /* violet-500 */
  --teal:         #2ab7ca;

  /* ── Truth-model badge colors (for reference):
       LIVE / OBSERVED  → --green
       FORECAST·v1      → --amber
       TREND·v1         → --blue
       NOWCAST·v1       → --purple
       MANUAL REVIEW    → --red
     ── */

  --radius:       4px;
  --radius-lg:    8px;       /* dispatch: 8px panel corners */

  --font-sans:  -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono:  "JetBrains Mono", "Fira Code", ui-monospace, "Cascadia Code", monospace;

  --chart-bg:    #0f172a;    /* slate-900 */
  --chart-grid:  #1e293b;    /* slate-800 */
  --chart-text:  #64748b;    /* slate-500 */
  --chart-cross: rgba(59,130,246,0.3);
}

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 13px; -webkit-font-smoothing: antialiased; -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  background: var(--bg-base);
  color: var(--text-sec);
  font-family: var(--font-sans);
  line-height: 1.5;
  min-height: 100vh;
}
a { color: inherit; text-decoration: none; }
button { font-family: inherit; }

/* ── Shell (flex-row: sidebar left + main area right) ── */
.shell { display: flex; flex-direction: row; min-height: 100vh; }

/* ── Sidebar ── */
.sidebar {
  width: 220px;
  flex-shrink: 0;
  height: 100vh;
  position: sticky;
  top: 0;
  background: var(--bg-panel);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  z-index: 100;
}
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 14px 14px;
  border-bottom: 1px solid var(--border);
  text-decoration: none;
  flex-shrink: 0;
}
.brand-name {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--text-pri);
  line-height: 1;
}

.brand-svg {
  width: 20px; height: 20px;
  color: var(--accent);
  flex-shrink: 0;
}

/* Sidebar nav (vertical) */
.sidebar-nav {
  flex: 1;
  padding: 10px 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.nav-link {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  border-radius: var(--radius);
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-dim);
  white-space: nowrap;
  transition: color 0.12s, background 0.12s;
  border: 1px solid transparent;
  text-decoration: none;
}
.nav-link:hover {
  color: var(--text-sec);
  background: var(--bg-hover);
}
.nav-link.active {
  color: var(--accent);
  background: var(--accent-dim);
  border-color: rgba(59,130,246,0.2);
}
.nav-icon {
  width: 15px; height: 15px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  opacity: 0.7;
}
.nav-link.active .nav-icon { opacity: 1; }
.nav-icon svg,
.nav-icon .section-svg { width: 15px; height: 15px; display: block; }

/* Sidebar infrastructure panel (pinned to bottom) */
.sidebar-infra {
  flex-shrink: 0;
  padding: 12px 14px;
  border-top: 1px solid var(--border);
}
.sidebar-infra-hdr {
  font-family: var(--font-mono);
  font-size: 8px;
  font-weight: 700;
  letter-spacing: 0.14em;
  color: var(--text-dim);
  text-transform: uppercase;
  margin-bottom: 8px;
}
.infra-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 3px 0;
}
.infra-label {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-dim);
  flex: 1;
  letter-spacing: 0.03em;
}
.infra-val {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-sec);
  letter-spacing: 0.02em;
}

/* ── Main area (right of sidebar) ── */
.main-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 100vh;
}

/* ── Slim header (route title + clock + feed dot) ── */
.slim-header {
  display: flex;
  align-items: center;
  padding: 0 20px;
  height: 40px;
  background: var(--bg-panel);
  border-bottom: 1px solid var(--border);
  gap: 10px;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  z-index: 50;
}
.route-title {
  flex: 1;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: var(--text-dim);
  text-transform: uppercase;
}
.slim-header-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

/* ── Topbar (kept for reference; no longer in DOM) ── */
.topbar {
  display: flex;
  align-items: center;
  height: 44px;
  padding: 0 16px;
  background: var(--bg-panel);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
  gap: 0;
}

/* old .brand / .nav / .nav-link topbar variants removed — sidebar definitions above are canonical */

/* ── Edge node status ── */
.edge-status {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 2px 7px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: default;
}
.edge-dot {
  width: 5px; height: 5px;
  border-radius: 50%;
  background: var(--text-dim);
  flex-shrink: 0;
  transition: background 0.3s, box-shadow 0.3s;
}
.edge-dot.online  { background: var(--green); box-shadow: 0 0 4px var(--green); }
.edge-dot.offline { background: var(--red); }
.edge-dot.unknown { background: var(--text-dim); }
.edge-label {
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.08em;
  color: var(--text-dim);
}
.edge-label.online  { color: var(--green); }
.edge-label.offline { color: var(--red); }

.topbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
  margin-left: 12px;
}
.clock {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-dim);
  letter-spacing: 0.05em;
  min-width: 72px;
  text-align: right;
}
.status-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--text-dim);
  flex-shrink: 0;
  transition: background 0.3s, box-shadow 0.3s;
}
.status-dot.ok   { background: var(--green); box-shadow: 0 0 5px var(--green); }
.status-dot.warn { background: var(--accent); box-shadow: 0 0 5px var(--accent); }
.status-dot.err  { background: var(--red); box-shadow: 0 0 5px var(--red); }

/* ── Main content ── */
.main-content {
  flex: 1;
  padding: 20px 20px;
  width: 100%;
}


/* ── Dashboard grid ── */
.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(360px, 100%), 1fr));
  gap: 12px;
}
.dashboard-grid.two-col { grid-template-columns: repeat(2, 1fr); }
.dashboard-grid.three-col { grid-template-columns: repeat(3, 1fr); }
.dashboard-grid.full { grid-template-columns: 1fr; }

/* Four-panel row: spans full dashboard-grid width, 4 equal columns */
.four-panel-row {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

/* ── Cards ── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border-dim);
  background: var(--bg-card-alt);
}
.card-title {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.1em;
  color: var(--text-dim);
  text-transform: uppercase;
}
.card-badge {
  font-size: 11px;
  padding: 1px 6px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  color: var(--text-dim);
  background: var(--bg-base);
  letter-spacing: 0.04em;
  min-width: 40px;
  text-align: right;
}
.card-badge.live { color: var(--green); border-color: rgba(16,185,129,0.3); background: var(--green-dim); }
.card-badge.warn { color: var(--amber); border-color: rgba(245,158,11,0.3); background: var(--amber-dim); }
.card-badge.err  { color: var(--red); border-color: rgba(244,63,94,0.3); background: var(--red-dim); }

.card-body { padding: 14px; }
.card-body-tight { padding: 10px 14px; }

/* ── KPI row ── */
.kpi-row {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 8px;
  margin-bottom: 14px;
}
.kpi {
  background: var(--bg-card);
  border: 1px solid var(--border-dim);
  border-radius: var(--radius);
  padding: 10px 12px;
  position: relative;
  overflow: hidden;
}
.kpi::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: var(--border);
}
.kpi.pos::before { background: var(--green); }
.kpi.neg::before { background: var(--red); }
.kpi.neu::before { background: var(--accent); }
.kpi-label {
  font-size: 9px;
  font-weight: 500;
  color: var(--text-ter);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.kpi-value {
  font-family: var(--font-mono);
  font-size: 20px;
  font-weight: 600;
  color: var(--text-pri);
  line-height: 1;
  letter-spacing: -0.02em;
}
.kpi-value.sm { font-size: 16px; }
.kpi-change {
  font-family: var(--font-mono);
  font-size: 11px;
  margin-top: 4px;
  display: flex;
  align-items: center;
  gap: 3px;
}
.kpi-change.pos { color: var(--green); }
.kpi-change.neg { color: var(--red); }
.kpi-change.neu { color: var(--text-dim); }
.kpi-src {
  font-family: var(--font-mono);
  font-size: 8px;
  color: var(--text-dim);
  letter-spacing: 0.04em;
  margin-top: 3px;
  opacity: 0.75;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── Nowcast tile variant ── */
.kpi.kpi-nowcast::before { background: var(--accent); opacity: 0.5; }
/* ── Extended context tile variant ── */
.kpi.kpi-ext::before { background: #4a9eff; opacity: 0.4; }
.kpi-info-btn {
  position: absolute; top: 4px; right: 6px;
  background: none; border: none; cursor: pointer;
  font-size: 11px; color: #3b82f6; opacity: 0.4;
  padding: 0; line-height: 1; transition: opacity 0.15s; z-index: 2;
}
.kpi-info-btn:hover { opacity: 1; }
.kpi.kpi-open { overflow: visible; z-index: 10; }
.kpi-expl-panel {
  position: fixed;
  background: #1e293b; border: 1px solid #334155; border-radius: 4px;
  padding: 8px 10px; font: 400 10px/1.55 var(--font-mono); color: #94a3b8;
  z-index: 100; min-width: 180px; box-shadow: 0 4px 12px rgba(0,0,0,0.4);
}
.kpi-expl-panel strong { display: block; font-size: 10px; color: #e2e8f0; margin-bottom: 5px; letter-spacing: 0.05em; text-transform: uppercase; }
.kpi-expl-row { margin-bottom: 4px; }
.kpi-expl-lbl { display: inline-block; font-weight: 600; color: #3b82f6; min-width: 38px; margin-right: 4px; }
.kpi-stale {
  color: var(--warn, #f59e0b);
  margin-left: 4px;
}

/* ── Chart containers ── */
.chart-container {
  position: relative;
  width: 100%;
  height: 220px;
}
.chart-container.tall  { height: 300px; }
.chart-container.short { height: 160px; }
.chart-container.mini  { height: 130px; margin-top: 8px; }
.chart-container > div { width: 100% !important; height: 100% !important; }

/* ── Mini KPI grid (used in Macro Brief sector panels) ── */
.mini-kpi-grid {
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.mini-kpi-row {
  display: flex;
  align-items: baseline;
  gap: 6px;
  padding: 4px 0;
  border-bottom: 1px solid var(--border-dim);
}
.mini-kpi-row:last-child { border-bottom: none; }
.mini-kpi-label {
  font-size: 10px;
  color: var(--text-ter);
  width: 52px;
  flex-shrink: 0;
  letter-spacing: 0.04em;
}
.mini-kpi-val {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 500;
  color: var(--text-pri);
  flex: 1;
}
.mini-kpi-chg {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.02em;
}
.mini-kpi-chg.pos { color: var(--green); }
.mini-kpi-chg.neg { color: var(--red); }
.mini-kpi-chg.neu { color: var(--text-dim); }

/* ── Map container ── */
.map-container {
  width: 100%;
  height: 380px;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--bg-card);
  position: relative;
}
.map-overlay {
  position: absolute;
  bottom: 12px;
  left: 12px;
  right: 12px;
  z-index: 10;
  background: rgba(8,10,12,0.88);
  border: 1px solid var(--border-hi);
  border-radius: var(--radius);
  padding: 10px 14px;
  backdrop-filter: blur(4px);
}
.map-overlay-title {
  font-size: 11px;
  font-weight: 600;
  color: var(--accent);
  letter-spacing: 0.08em;
  margin-bottom: 3px;
}
.map-overlay-sub {
  font-size: 10px;
  color: var(--text-sec);
  letter-spacing: 0.04em;
}
.map-overlay-dot {
  display: inline-block;
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--accent);
  margin-right: 6px;
  animation: pulse-dot 2s ease-in-out infinite;
}
@keyframes pulse-dot {
  0%, 100% { opacity: 1; box-shadow: 0 0 4px var(--accent); }
  50%       { opacity: 0.4; box-shadow: none; }
}

/* ── Data table ── */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}
.data-table th {
  text-align: left;
  padding: 6px 10px;
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.1em;
  color: var(--text-ter);
  text-transform: uppercase;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.data-table td {
  padding: 7px 10px;
  border-bottom: 1px solid var(--border-dim);
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-sec);
  white-space: nowrap;
}
.data-table td:first-child { color: var(--text-pri); font-size: 12px; }
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: var(--bg-hover); }
.num-pos  { color: var(--green)  !important; }
.num-neg  { color: var(--red)    !important; }
.num-warn { color: var(--amber)  !important; }

/* ── MapLibre popup — dark theme override ── */
.maplibregl-popup-content {
  background: #0d1a2a !important;
  border: 1px solid rgba(100,160,220,0.2);
  border-radius: 5px !important;
  padding: 0 !important;
  box-shadow: 0 4px 16px rgba(0,0,0,0.6) !important;
}
.maplibregl-popup-tip {
  border-top-color: #0d1a2a !important;
  border-bottom-color: #0d1a2a !important;
}
/* OSINT / Energy-Oil vessel popup */
.vessel-popup {
  padding: 10px 13px;
  font-family: var(--font-sans);
  line-height: 1.55;
}
.vessel-popup-name {
  font-size: 14px;
  font-weight: 600;
  color: #e0f0ff;
  margin-bottom: 2px;
}
.vessel-popup-type {
  font-size: 12px;
  color: #7ab0d8;
  margin-bottom: 6px;
  font-style: italic;
}
.vessel-popup-row {
  font-size: 12px;
  color: #b8d4ec;
  display: flex;
  gap: 8px;
  margin-bottom: 1px;
}
.vessel-popup-lbl {
  font-size: 11px;
  font-family: var(--font-mono);
  color: #5a8aaa;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  min-width: 46px;
}
/* Macro Brief compact map popup */
.mb-vessel-popup {
  padding: 9px 12px;
  font-family: var(--font-sans);
  line-height: 1.5;
}
.mb-vessel-popup-name {
  font-size: 13px;
  font-weight: 600;
  color: #e0f0ff;
  margin-bottom: 2px;
}
.mb-vessel-popup-type {
  font-size: 11px;
  color: #7ab0d8;
  margin-bottom: 5px;
  font-style: italic;
}
.mb-vessel-popup-row {
  font-size: 11px;
  color: #b8d4ec;
  margin-bottom: 1px;
}

/* ── Map layer toggle buttons ── */
.map-layer-btn {
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.1);
  color: var(--text-dim);
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.06em;
  padding: 0;
  width: 90px;
  height: 26px;
  border-radius: 3px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  white-space: nowrap;
}
.map-layer-btn:hover { background: rgba(255,255,255,0.1); color: var(--text-pri); }
.map-layer-btn.active { background: rgba(245,158,11,0.15); border-color: rgba(245,158,11,0.4); color: var(--amber); }

/* ── Map navigation controls (OSINT map) ── */
.map-nav-controls {
  position: absolute; top: 10px; left: 10px; z-index: 10;
  display: flex; flex-direction: column; gap: 4px;
}
.map-nav-btn {
  background: rgba(13,17,23,0.9); border: 1px solid rgba(255,255,255,0.12);
  color: var(--text-sec); font-family: var(--font-mono); font-size: 11px; font-weight: 600;
  padding: 4px 10px; border-radius: 3px; cursor: pointer; white-space: nowrap; text-align: left;
  transition: background 0.15s, color 0.15s; min-width: 90px;
}
.map-nav-btn:hover { background: rgba(245,158,11,0.15); border-color: rgba(245,158,11,0.4); color: var(--amber); }
.map-zoom-row { display: flex; gap: 4px; }
.map-zoom-btn {
  background: rgba(13,17,23,0.9); border: 1px solid rgba(255,255,255,0.12);
  color: var(--text-sec); font-size: 16px; font-weight: 600;
  width: 32px; height: 28px; border-radius: 3px; cursor: pointer;
  display: flex; align-items: center; justify-content: center; transition: background 0.15s;
}
.map-zoom-btn:hover { background: rgba(245,158,11,0.15); color: var(--amber); }
.map-vessel-count {
  position: absolute; bottom: 10px; right: 10px; z-index: 10;
  background: rgba(13,17,23,0.88); border: 1px solid rgba(255,255,255,0.1);
  color: var(--text-sec); font-family: var(--font-mono); font-size: 11px;
  padding: 4px 10px; border-radius: 3px; pointer-events: none;
}

/* ── Macro Brief composite ── */
.macro-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  grid-template-rows: auto;
  gap: 12px;
}
.macro-grid .span-2 { grid-column: span 2; }
.macro-grid .span-3 { grid-column: span 3; }

.ticker-strip {
  display: flex;
  gap: 0;
  overflow-x: auto;
  scrollbar-width: none;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-card-alt);
  padding: 0;
}
.ticker-strip::-webkit-scrollbar { display: none; }
.ticker-item {
  flex-shrink: 0;
  padding: 8px 14px;
  border-right: 1px solid var(--border-dim);
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 100px;
}
.ticker-item:last-child { border-right: none; }
.ticker-sym {
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 600;
  color: var(--text-dim);
  letter-spacing: 0.1em;
  text-transform: uppercase;
}
.ticker-price {
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 600;
  color: var(--text-pri);
  letter-spacing: -0.01em;
}
.ticker-chg {
  font-family: var(--font-mono);
  font-size: 10px;
}
.ticker-chg.pos { color: var(--green); }
.ticker-chg.neg { color: var(--red); }
.ticker-chg.neu { color: var(--text-dim); }

.anomaly-list { display: flex; flex-direction: column; gap: 6px; }
.anomaly-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  background: var(--bg-base);
  border: 1px solid var(--border-dim);
  border-radius: var(--radius);
}
.anomaly-dir {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  width: 28px;
  text-align: center;
  padding: 2px 4px;
  border-radius: var(--radius);
}
.anomaly-dir.up   { color: var(--green); background: var(--green-dim); }
.anomaly-dir.down { color: var(--red);   background: var(--red-dim); }
.anomaly-name {
  flex: 1;
  font-size: 12px;
  color: var(--text-pri);
  font-weight: 500;
}
.anomaly-val {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-sec);
}
.anomaly-mag {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  min-width: 48px;
  text-align: right;
}
.anomaly-mag.up   { color: var(--green); }
.anomaly-mag.down { color: var(--red); }

.synthesis-panel {
  background: var(--bg-card-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
}
.synthesis-title {
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.14em;
  color: var(--text-dim);
  text-transform: uppercase;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.synthesis-title::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}
.synthesis-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 5px 0;
  border-bottom: 1px solid var(--border-dim);
  gap: 12px;
}
.synthesis-row:last-child { border-bottom: none; }
.synthesis-label {
  font-size: 12px;
  color: var(--text-sec);
  flex: 1;
}
.synthesis-val {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 600;
  color: var(--text-pri);
  text-align: right;
}
.synthesis-val.pos { color: var(--green); }
.synthesis-val.neg { color: var(--red); }

/* ── Home page module grid ── */
.home-hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 48px 0 32px;
}
.hero-wordmark {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 6px;
}
.hero-brand-svg {
  width: 32px; height: 32px;
  color: var(--accent);
}
.hero-brand-text {
  font-family: var(--font-mono);
  font-size: 28px;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--text-pri);
}
.hero-sub {
  font-size: 11px;
  color: var(--text-dim);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin-bottom: 40px;
  text-align: center;
}
.module-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 10px;
  width: 100%;
  max-width: 860px;
}
.module-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 20px 12px 16px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  text-decoration: none;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.module-card:hover {
  background: var(--bg-hover);
  border-color: var(--border-hi);
}
.module-icon {
  width: 32px; height: 32px;
  color: var(--accent);
  opacity: 0.8;
  display: flex; align-items: center; justify-content: center;
}
.module-icon .section-svg { width: 28px; height: 28px; }
.module-name {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.06em;
  color: var(--text-pri);
  text-align: center;
  line-height: 1.3;
}
.module-status {
  display: flex;
  align-items: center;
  gap: 5px;
}
.module-status-text {
  font-size: 9px;
  color: var(--text-dim);
  letter-spacing: 0.04em;
}
.dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}
.dot-pending { background: var(--text-dim); }
.dot-ok      { background: var(--green); box-shadow: 0 0 4px var(--green); }
.dot-warn    { background: var(--accent); }
.dot-err     { background: var(--red); }

/* ── OSINT reports ── */
.report-list { display: flex; flex-direction: column; gap: 6px; }
.report-item {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 12px 14px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-decoration: none;
  transition: border-color 0.12s;
}
.report-item:hover { border-color: var(--border-hi); }
.report-date {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-dim);
  white-space: nowrap;
  padding-top: 2px;
  min-width: 80px;
}
.report-title {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-pri);
  line-height: 1.4;
}
.report-tags {
  display: flex;
  gap: 5px;
  margin-top: 4px;
  flex-wrap: wrap;
}
.report-tag {
  font-family: var(--font-mono);
  font-size: 9px;
  padding: 1px 5px;
  border-radius: 2px;
  background: var(--bg-hover);
  border: 1px solid var(--border);
  color: var(--text-dim);
  letter-spacing: 0.05em;
}

/* ── Pending / phase placeholder ── */
.phase-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 24px;
  text-align: center;
  border: 1px dashed var(--border-hi);
  border-radius: var(--radius-lg);
  gap: 14px;
}
.phase-placeholder-icon {
  width: 40px; height: 40px;
  color: var(--text-dim);
}
.phase-placeholder-icon svg { width: 40px; height: 40px; }
.phase-placeholder-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-sec);
  letter-spacing: 0.06em;
}
.phase-placeholder-body {
  font-size: 12px;
  color: var(--text-dim);
  max-width: 480px;
  line-height: 1.6;
}
.phase-tag {
  font-family: var(--font-mono);
  font-size: 10px;
  padding: 3px 10px;
  border-radius: var(--radius);
  border: 1px solid var(--accent-dim);
  color: var(--accent);
  background: var(--accent-dim);
  letter-spacing: 0.08em;
}

/* ── Loading / error ── */
.loading-state {
  grid-column: 1 / -1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 60px;
  color: var(--text-dim);
  font-family: var(--font-mono);
  font-size: 11px;
}
.spinner {
  width: 20px; height: 20px;
  border: 1.5px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.error-state {
  grid-column: 1 / -1;
  padding: 16px;
  background: var(--red-dim);
  border: 1px solid rgba(244,63,94,0.25);
  border-radius: var(--radius);
  color: var(--red);
  font-family: var(--font-mono);
  font-size: 11px;
}

/* ── Divider label ── */
.section-label {
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.14em;
  color: var(--text-dim);
  text-transform: uppercase;
  display: flex;
  align-items: center;
  gap: 8px;
  grid-column: 1 / -1;
  margin-top: 4px;
}
.section-label::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border-dim);
}

/* ── Footer / status strip ── */
.footer {
  border-top: 1px solid var(--border-dim);
  background: var(--bg-panel);
}
.status-strip {
  display: flex;
  align-items: center;
  gap: 0;
  padding: 5px 16px;
  overflow-x: auto;
  scrollbar-width: none;
  border-bottom: 1px solid var(--border-dim);
}
.status-strip::-webkit-scrollbar { display: none; }
.status-item {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 2px 12px;
  border-right: 1px solid var(--border-dim);
  flex-shrink: 0;
}
.status-item:first-child { padding-left: 0; }
.status-item:last-child  { border-right: none; }
.status-label {
  font-size: 9px;
  letter-spacing: 0.08em;
  color: var(--text-dim);
  text-transform: uppercase;
  flex-shrink: 0;
}
.status-val {
  font-family: var(--font-mono);
  font-size: 9px;
  color: var(--text-sec);
  letter-spacing: 0.02em;
}
.status-dot-sm {
  width: 5px; height: 5px;
  border-radius: 50%;
  background: var(--text-dim);
  flex-shrink: 0;
  transition: background 0.3s;
}
.status-dot-sm.ok      { background: var(--green); box-shadow: 0 0 3px var(--green); }
.status-dot-sm.warn    { background: var(--accent); }
.status-dot-sm.err     { background: var(--red); }
.status-dot-sm.unknown { background: var(--text-dim); }
.footer-bottom {
  display: flex;
  justify-content: space-between;
  padding: 4px 16px;
  font-family: var(--font-mono);
  font-size: 9px;
  color: var(--text-dim);
  letter-spacing: 0.04em;
}

/* ── Prose ── */
.prose { max-width: 720px; color: var(--text-sec); line-height: 1.7; }
.prose h2, .prose h3 { color: var(--text-pri); margin: 20px 0 6px; font-size: 13px; }

/* ── Phase placeholder spec table ── */
.phase-placeholder-specs {
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: 100%;
  max-width: 560px;
  margin-top: 8px;
  border: 1px solid var(--border-dim);
  border-radius: var(--radius);
  overflow: hidden;
}
.spec-row {
  display: flex;
  align-items: baseline;
  gap: 12px;
  padding: 6px 14px;
  border-bottom: 1px solid var(--border-dim);
}
.spec-row:last-child { border-bottom: none; }
.spec-label {
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-dim);
  width: 80px;
  flex-shrink: 0;
}
.spec-val {
  font-size: 11px;
  color: var(--text-sec);
}
.spec-pending {
  color: var(--accent);
}

/* ── Provenance badges ── */
.prov-badge {
  font-family: var(--font-mono);
  font-size: 8px;
  font-weight: 700;
  letter-spacing: 0.12em;
  padding: 1px 5px;
  border-radius: 2px;
  text-transform: uppercase;
  flex-shrink: 0;
}
.prov-obs      { background: rgba(16,185,129,0.15);  color: #10b981; border: 1px solid rgba(16,185,129,0.3); }
.prov-inferred { background: rgba(59,130,246,0.12);  color: #3b82f6; border: 1px solid rgba(59,130,246,0.25); }
.prov-parsed   { background: rgba(139,92,246,0.12);  color: #8b5cf6; border: 1px solid rgba(139,92,246,0.25); }


/* ── Agriculture section dividers ── */
.agri-section-hdr {
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.14em;
  color: var(--text-dim);
  text-transform: uppercase;
  display: flex;
  align-items: center;
  gap: 8px;
  grid-column: 1 / -1;
  padding: 4px 0 2px;
}
.agri-section-hdr::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border-dim);
}

/* ── Map AOI markers ── */
.aoi-marker {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  cursor: default;
}
.aoi-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid rgba(59,130,246,0.4);
  box-shadow: 0 0 8px var(--accent);
  animation: pulse-aoi 2.5s ease-in-out infinite;
}
@keyframes pulse-aoi {
  0%, 100% { box-shadow: 0 0 8px rgba(59,130,246,0.8); }
  50%       { box-shadow: 0 0 2px rgba(59,130,246,0.2); }
}
.aoi-label {
  background: rgba(8,10,12,0.88);
  border: 1px solid var(--border-hi);
  border-radius: 2px;
  padding: 2px 6px;
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 600;
  color: var(--accent);
  letter-spacing: 0.08em;
  white-space: nowrap;
  backdrop-filter: blur(3px);
}

/* ── Macro Brief KPI hero row ── */
.macro-hero-kpis {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 8px;
  grid-column: 1 / -1;
}
.macro-hero-kpi {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.macro-hero-kpi.pos { border-top: 2px solid var(--green); }
.macro-hero-kpi.neg { border-top: 2px solid var(--red); }
.macro-hero-kpi-label {
  font-size: 9px;
  letter-spacing: 0.1em;
  color: var(--text-ter);
  text-transform: uppercase;
}
.macro-hero-kpi-val {
  font-family: var(--font-mono);
  font-size: 22px;
  font-weight: 700;
  color: var(--text-pri);
  letter-spacing: -0.02em;
  line-height: 1;
}
.macro-hero-kpi-chg {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-dim);
}
.macro-hero-kpi-chg.pos { color: var(--green); }
.macro-hero-kpi-chg.neg { color: var(--red); }
.macro-hero-kpi-src {
  font-family: var(--font-mono);
  font-size: 8px;
  color: var(--text-dim);
  letter-spacing: 0.04em;
  margin-top: 2px;
}

/* ── Responsive ── */
@media (max-width: 1100px) {
  .macro-grid { grid-template-columns: 1fr 1fr; }
  .macro-grid .span-3 { grid-column: span 2; }
}
@media (max-width: 900px) {
  .module-grid { grid-template-columns: repeat(3, 1fr); }
  .macro-grid { grid-template-columns: 1fr; }
  .macro-grid .span-2, .macro-grid .span-3 { grid-column: span 1; }
}
@media (max-width: 640px) {
  .module-grid { grid-template-columns: repeat(2, 1fr); }
  .nav-label { display: none; }
  .nav-icon { width: 16px; height: 16px; }
  .nav-icon .section-svg { width: 16px; height: 16px; }
  .dashboard-grid.two-col { grid-template-columns: 1fr; }
}

/* ════════════════════════════════════════════════════════
   MOBILE LAYOUT — sidebar flips to horizontal topbar
   ════════════════════════════════════════════════════════ */

/* ── ≤768px: tablet + phone ── */
@media (max-width: 768px) {
  /* Shell: vertical stack */
  .shell { flex-direction: column; }

  /* Sidebar → 52px sticky topbar */
  .sidebar {
    width: 100%;
    min-width: 0;
    height: 52px;
    flex-direction: row;
    align-items: center;
    position: sticky;
    top: 0;
    overflow: hidden;
    border-right: none;
    border-bottom: 1px solid var(--border);
    z-index: 100;
  }

  /* Brand: icon only — text hidden in topbar to save space */
  .brand-name { display: none; }
  .sidebar-brand {
    height: 100%;
    align-self: stretch;
    padding: 0 14px;
    border-bottom: none;
    border-right: 1px solid var(--border);
    flex-shrink: 0;
  }

  /* Nav: horizontal icon-only strip */
  .nav-label { display: none; }
  .sidebar-nav {
    flex: 1;
    flex-direction: row;
    align-items: center;
    justify-content: space-around;
    padding: 0 4px;
    gap: 0;
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }
  .sidebar-nav::-webkit-scrollbar { display: none; }

  /* Nav links: square tap targets */
  .nav-link {
    padding: 8px 14px;
    flex-shrink: 0;
    border-radius: var(--radius);
  }
  .nav-icon { width: 18px; height: 18px; opacity: 0.9; }
  .nav-icon svg,
  .nav-icon .section-svg { width: 18px; height: 18px; }

  /* Infrastructure panel: hidden from topbar */
  .sidebar-infra { display: none; }

  /* Main area: clip horizontal overflow from tables/charts */
  .main-area { overflow-x: hidden; }

  /* Card bodies: let wide tables scroll within the card */
  .card-body, .card-body-tight {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* Content padding */
  .main-content { padding: 12px; }

  /* Four-panel row: collapse to 2-col on tablet */
  .four-panel-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }

  /* Hero KPIs: switch to flex for reliable mobile reflow */
  .macro-hero-kpis {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
  }
  .macro-hero-kpi {
    flex: 1 1 calc(33.333% - 6px);
    min-width: 0;
  }

  /* OECD CLI body: override inline 1fr/260px — stack chart over quadrant */
  #oecd-cli-tile .card-body {
    grid-template-columns: 1fr !important;
  }

  /* Synthesis panel: contain children within viewport width */
  .synthesis-panel { overflow: hidden; }

  /* Synthesis headline + rows: force wrap on long pipe-separated content */
  #synthesis-headline,
  #synthesis-rows { word-break: break-word; overflow-wrap: break-word; white-space: normal; }

  /* Synthesis data rows: allow value to wrap below label when space is tight */
  .synthesis-row { flex-wrap: wrap; gap: 4px; }

  /* Synthesis values: break long monospace strings (e.g. "WTI $78.50/bbl · NatGas $2.350") */
  .synthesis-val { word-break: break-word; overflow-wrap: break-word; }

  /* Synthesis panel box constraint — hard stop on the panel + every descendant */
  #synthesis-panel {
    max-width: 100%;
    overflow-x: hidden;
    box-sizing: border-box;
  }
  #synthesis-panel * {
    max-width: 100%;
    overflow-wrap: anywhere;
    word-break: break-word;
    white-space: normal;
    box-sizing: border-box;
  }

  /* Synthesis panel: viewport-width constraint bypassing grid track expansion */
  .synthesis-panel {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
  }

  /* Crop climate grid (agriculture): 3-col → 2-col */
  .crop-climate-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ── ≤480px: narrow phones ── */
@media (max-width: 480px) {
  .sidebar { height: 48px; }
  .sidebar-brand { padding: 0 10px; }
  .main-content { padding: 10px; }

  /* KPI tiles: 2-col */
  .kpi-row { grid-template-columns: repeat(2, 1fr); }

  /* Dashboard card grid: switch to block layout to bypass grid track issues */
  .dashboard-grid,
  .dashboard-grid.two-col,
  .dashboard-grid.three-col,
  .dashboard-grid.full {
    display: block !important;
  }
  .dashboard-grid > * {
    margin-bottom: 12px;
  }
  .dashboard-grid > *:last-child {
    margin-bottom: 0;
  }

  /* Four-panel row: single column on narrow phones */
  .four-panel-row {
    display: block !important;
  }
  .four-panel-row > * {
    margin-bottom: 12px;
  }
  .four-panel-row > *:last-child {
    margin-bottom: 0;
  }

  /* Hero KPIs: 2-per-row on narrow phones */
  .macro-hero-kpi { flex: 1 1 calc(50% - 4px); }
  .macro-hero-kpi-val { font-size: 16px; }
  .macro-hero-kpi { padding: 10px 12px; }

  /* Home page module grid: 2-col → 1-col on narrow phones */
  .module-grid { grid-template-columns: 1fr; }

  /* Crop climate grid (agriculture): 2-col → 1-col */
  .crop-climate-grid { grid-template-columns: 1fr; }

  /* CPC outlook maps: 2-col → 1-col */
  .cpc-maps { grid-template-columns: 1fr; }
}
