/* ===== THEME (shared with main app) ===== */
:root {
  --bg: #060a13; --panel: #0c1221; --card: #111b2e; --hover: #1a2740;
  --border: #1e2d45; --t1: #e2e8f0; --t2: #8b9dc3; --t3: #4a5f82;
  --gold: #f5a623; --green: #10b981; --red: #ef4444; --cyan: #06b6d4;
  --nps-dred: #991b1b; --nps-red: #dc2626; --nps-orange: #f97316;
  --nps-yellow: #eab308; --nps-lgreen: #4ade80; --nps-dgreen: #16a34a;
  --nps-grey: #374151;
  --critical: #991b1b; --high: #dc2626; --elevated: #f97316;
  --moderate: #eab308; --low: #16a34a;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: 'DM Sans', sans-serif; background: var(--bg); color: var(--t1); overflow: hidden; height: 100vh; }
.mono { font-family: 'Space Mono', monospace; }

/* ===== HEADER ===== */
#hdr {
  position: fixed; top: 0; left: 0; right: 0; z-index: 1000; height: 50px;
  background: rgba(6,10,19,0.95); backdrop-filter: blur(12px); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; padding: 0 16px; gap: 10px;
}
.logo { font-family: 'Space Mono', monospace; font-size: 15px; font-weight: 700; color: var(--gold); letter-spacing: 1px; cursor: pointer; white-space: nowrap; }
.logo span { color: var(--t3); font-weight: 400; font-size: 10px; margin-left: 6px; }

/* Navigation */
#nav-links { display: flex; gap: 6px; margin-left: 16px; }
.nav-link {
  padding: 4px 10px; font-size: 11px; font-family: 'Space Mono', monospace;
  color: var(--t3); text-decoration: none; border: 1px solid var(--border);
  border-radius: 4px; transition: all .15s; white-space: nowrap;
}
.nav-link:hover { color: var(--t1); background: var(--hover); }
.nav-link.active { color: var(--bg); background: var(--gold); border-color: var(--gold); }

/* Controls */
#ctrls { display: flex; align-items: center; gap: 8px; margin-left: auto; }
#hbtn { width: 22px; height: 22px; border-radius: 50%; background: var(--card); border: 1px solid var(--border);
  color: var(--t3); font-size: 11px; font-weight: 700; font-family: 'Space Mono', monospace;
  display: flex; align-items: center; justify-content: center; cursor: pointer; }
#hbtn:hover { border-color: var(--gold); color: var(--gold); }

/* Help */
#help { display: none; position: fixed; top: 54px; right: 16px; z-index: 1100; background: var(--card);
  border: 1px solid var(--border); border-radius: 8px; padding: 12px 14px; max-width: 320px;
  font-size: 11px; line-height: 1.5; color: var(--t2); box-shadow: 0 8px 24px rgba(0,0,0,0.5); }
#help.show { display: block; }

/* ===== SUMMARY BAR ===== */
#gbar {
  position: fixed; top: 50px; left: 0; right: 0; z-index: 950; height: 40px;
  background: rgba(6,10,19,0.92); backdrop-filter: blur(12px); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center; gap: 24px; padding: 0 16px;
}
.gb-item { display: flex; align-items: center; gap: 5px; }
.gb-v { font-family: 'Space Mono', monospace; font-size: 14px; font-weight: 700; }
.gb-v.gb-nps { font-size: 18px; }
.gb-l { font-size: 9px; color: var(--t3); font-family: 'Space Mono', monospace; text-transform: uppercase; letter-spacing: 0.5px; }
.gb-sep { color: var(--border); font-size: 16px; font-weight: 300; }

/* ===== LOADER ===== */
#loader { position: fixed; top: 90px; left: 0; right: 0; bottom: 0; background: var(--bg);
  display: flex; flex-direction: column; align-items: center; justify-content: center; z-index: 999; transition: opacity .4s; }
#loader.gone { opacity: 0; pointer-events: none; }
.lp { width: 32px; height: 32px; border-radius: 50%; background: var(--red); opacity: .3; animation: lp 1.4s ease-in-out infinite; }
@keyframes lp { 0%,100% { transform: scale(.8); opacity: .3; } 50% { transform: scale(1.2); opacity: .7; } }
.lt { margin-top: 10px; font-family: 'Space Mono', monospace; font-size: 10px; color: var(--t3); letter-spacing: 1px; }

/* ===== MAP ===== */
#map-wrap { position: fixed; top: 90px; left: 0; bottom: 0; overflow: hidden; transition: right .3s ease; }
#map-wrap.po { right: 420px; }
#map-wrap:not(.po) { right: 0; }
svg.map { width: 100%; height: 100%; cursor: grab; }
svg.map:active { cursor: grabbing; }
svg.map path { transition: opacity .15s; }
.water { fill: #080e1a; }
.border { fill: none; stroke: var(--border); stroke-width: 0.3; pointer-events: none; }
.graticule { fill: none; stroke: #0d1525; stroke-width: 0.3; }

/* Conflict zones on map */
.conflict-zone { cursor: pointer; transition: opacity .15s; }
.conflict-zone:hover { opacity: 0.8; }
.conflict-marker {
  pointer-events: all; cursor: pointer;
  filter: drop-shadow(0 0 4px rgba(220,38,38,0.6));
}
.conflict-pulse {
  animation: pulse-ring 2s ease-out infinite;
}
@keyframes pulse-ring {
  0% { r: 6; opacity: 0.9; stroke-width: 2; }
  100% { r: 22; opacity: 0; stroke-width: 0.5; }
}

/* ===== TOOLTIP ===== */
#tt { position: fixed; pointer-events: none; z-index: 2000; background: rgba(12,18,33,0.95);
  border: 1px solid var(--border); border-radius: 5px; padding: 7px 10px; font-size: 11px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.4); display: none; max-width: 260px; }
#tt.show { display: block; }
.tt-t { font-weight: 600; margin-bottom: 2px; }
.tt-v { font-family: 'Space Mono', monospace; color: var(--red); }
.tt-s { font-size: 9px; color: var(--t3); margin-top: 1px; }

/* ===== LEGEND ===== */
#legend { position: fixed; bottom: 16px; left: 14px; z-index: 800; background: rgba(12,18,33,0.9);
  border: 1px solid var(--border); border-radius: 5px; padding: 8px 12px; backdrop-filter: blur(8px); }
.lg-t { font-size: 8px; color: var(--t3); font-family: 'Space Mono', monospace; text-transform: uppercase; letter-spacing: 1px; margin-bottom: 4px; }
.lg-bar { width: 160px; height: 6px; border-radius: 3px; }
.lg-lb { display: flex; justify-content: space-between; margin-top: 2px; font-size: 8px; color: var(--t3); font-family: 'Space Mono', monospace; }
#info { position: fixed; bottom: 16px; right: 14px; z-index: 800; font-size: 8px; color: var(--t3); font-family: 'Space Mono', monospace; }

/* ===== SIDE PANEL ===== */
#panel {
  position: fixed; top: 90px; bottom: 0; right: -420px; width: 420px; z-index: 900;
  background: var(--panel); border-left: 1px solid var(--border);
  overflow-y: auto; transition: right .3s ease; scrollbar-width: thin; scrollbar-color: var(--border) transparent;
}
#panel.open { right: 0; }
.ph {
  position: sticky; top: 0; z-index: 10; background: var(--panel);
  padding: 14px 16px 10px; border-bottom: 1px solid var(--border);
}
.ph-x {
  position: absolute; top: 10px; right: 12px; background: none; border: 1px solid var(--border);
  color: var(--t3); width: 24px; height: 24px; border-radius: 4px; font-size: 16px;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
}
.ph-x:hover { color: var(--t1); border-color: var(--t1); }
.ph-back {
  background: none; border: 1px solid var(--border); color: var(--t3);
  padding: 2px 8px; border-radius: 4px; font-size: 14px; cursor: pointer; margin-bottom: 6px;
  font-family: 'Space Mono', monospace;
}
.ph-back:hover { color: var(--t1); border-color: var(--t1); }
.ph-t { font-size: 16px; font-weight: 700; margin-top: 2px; }
.ph-s { font-size: 11px; color: var(--t3); font-family: 'Space Mono', monospace; margin-top: 2px; }
.ps { padding: 12px 16px; border-bottom: 1px solid var(--border); }
.psl { font-size: 9px; color: var(--t3); font-family: 'Space Mono', monospace; text-transform: uppercase; letter-spacing: 1px; margin-bottom: 8px; }

/* ===== CONFLICT LIST ===== */
.conflict-item {
  padding: 10px 12px; margin-bottom: 6px; background: var(--card); border: 1px solid var(--border);
  border-radius: 6px; cursor: pointer; transition: all .15s;
  display: flex; align-items: center; gap: 10px;
}
.conflict-item:hover { background: var(--hover); border-color: var(--t3); }
.conflict-item:last-child { margin-bottom: 0; }
.ci-severity {
  width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0;
}
.ci-info { flex: 1; min-width: 0; }
.ci-name { font-size: 12px; font-weight: 600; margin-bottom: 2px; }
.ci-meta { font-size: 9px; color: var(--t3); font-family: 'Space Mono', monospace; }
.ci-cii {
  font-family: 'Space Mono', monospace; font-size: 14px; font-weight: 700;
  flex-shrink: 0; text-align: right; min-width: 32px;
}
.ci-trend { font-size: 10px; text-align: right; }

/* ===== CONFLICT OVERVIEW ===== */
.overview-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-bottom: 10px;
}
.ov-card {
  background: var(--card); border: 1px solid var(--border); border-radius: 6px; padding: 10px;
}
.ov-label { font-size: 9px; color: var(--t3); font-family: 'Space Mono', monospace; text-transform: uppercase; margin-bottom: 4px; }
.ov-value { font-family: 'Space Mono', monospace; font-size: 16px; font-weight: 700; }
.ov-desc { font-size: 11px; color: var(--t2); line-height: 1.5; margin-top: 8px; }
.ov-parties {
  display: flex; gap: 8px; margin-top: 8px; flex-wrap: wrap;
}
.ov-party {
  padding: 3px 8px; background: var(--card); border: 1px solid var(--border);
  border-radius: 4px; font-size: 10px; font-family: 'Space Mono', monospace; color: var(--t2);
}

/* ===== CII GAUGE ===== */
.cii-gauge {
  text-align: center; padding: 10px 0;
}
.cii-score {
  font-family: 'Space Mono', monospace; font-size: 42px; font-weight: 700;
}
.cii-label { font-size: 10px; color: var(--t3); font-family: 'Space Mono', monospace; margin-top: 2px; }
.cii-bar-wrap {
  margin-top: 10px; height: 8px; background: var(--card); border-radius: 4px; overflow: hidden;
  border: 1px solid var(--border);
}
.cii-bar-fill {
  height: 100%; border-radius: 4px; transition: width .5s ease;
}
.cii-components {
  display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 6px; margin-top: 10px;
}
.cii-comp {
  background: var(--card); border: 1px solid var(--border); border-radius: 4px; padding: 8px; text-align: center;
}
.cii-comp-val { font-family: 'Space Mono', monospace; font-size: 14px; font-weight: 700; }
.cii-comp-label { font-size: 8px; color: var(--t3); font-family: 'Space Mono', monospace; margin-top: 2px; }

/* ===== FRAMEWORK TABS ===== */
.fw-tabs {
  display: flex; gap: 4px; margin-bottom: 10px; flex-wrap: wrap;
}
.fw-tab {
  padding: 4px 8px; font-size: 9px; font-family: 'Space Mono', monospace;
  background: var(--card); border: 1px solid var(--border); border-radius: 4px;
  cursor: pointer; color: var(--t3); transition: all .15s;
}
.fw-tab:hover { color: var(--t1); border-color: var(--t3); }
.fw-tab.active { background: var(--gold); color: var(--bg); border-color: var(--gold); }

.fw-content {
  background: var(--card); border: 1px solid var(--border); border-radius: 6px; padding: 12px;
}
.fw-title { font-size: 12px; font-weight: 700; margin-bottom: 6px; }
.fw-subtitle { font-size: 9px; color: var(--t3); font-family: 'Space Mono', monospace; margin-bottom: 8px; }
.fw-body { font-size: 11px; color: var(--t2); line-height: 1.6; }
.fw-body p { margin-bottom: 8px; }
.fw-body strong { color: var(--t1); }
.fw-key-insight {
  margin-top: 10px; padding: 8px 10px; background: rgba(245,166,35,0.08);
  border-left: 3px solid var(--gold); border-radius: 0 4px 4px 0; font-size: 10px; line-height: 1.5;
}
.fw-key-insight strong { color: var(--gold); }

/* ===== TACTICAL RECOMMENDATIONS ===== */
.tac-item {
  padding: 10px; margin-bottom: 8px; background: var(--card); border: 1px solid var(--border);
  border-radius: 6px;
}
.tac-item:last-child { margin-bottom: 0; }
.tac-header { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.tac-num {
  width: 20px; height: 20px; border-radius: 50%; background: var(--gold); color: var(--bg);
  font-family: 'Space Mono', monospace; font-size: 10px; font-weight: 700;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.tac-title { font-size: 12px; font-weight: 600; }
.tac-desc { font-size: 11px; color: var(--t2); line-height: 1.5; }
.tac-framework {
  margin-top: 6px; font-size: 9px; color: var(--t3); font-family: 'Space Mono', monospace;
  padding: 2px 6px; background: rgba(245,166,35,0.08); border-radius: 3px; display: inline-block;
}
.tac-actors {
  margin-top: 6px; display: flex; gap: 4px; flex-wrap: wrap;
}
.tac-actor {
  font-size: 9px; padding: 2px 6px; background: var(--hover); border-radius: 3px;
  color: var(--t2); font-family: 'Space Mono', monospace;
}

/* ===== ACTOR-GROUPED RECS ===== */
.tac-actor-group {
  margin-bottom: 12px;
}
.tac-actor-group:last-child { margin-bottom: 0; }
.tac-actor-header {
  display: flex; align-items: center; gap: 8px; margin-bottom: 6px;
  padding: 6px 10px; background: var(--card); border: 1px solid var(--border);
  border-radius: 6px 6px 0 0; border-bottom: 2px solid var(--gold);
}
.tac-actor-flag { font-size: 16px; }
.tac-actor-name {
  font-size: 12px; font-weight: 700; font-family: 'Space Mono', monospace;
  color: var(--gold);
}
.tac-actor-actions {
  background: var(--card); border: 1px solid var(--border); border-top: none;
  border-radius: 0 0 6px 6px; padding: 8px 10px;
}
.tac-action {
  padding: 8px 0; border-bottom: 1px solid var(--border);
}
.tac-action:last-child { border-bottom: none; }
.tac-action-title { font-size: 11px; font-weight: 600; margin-bottom: 3px; }
.tac-action-desc { font-size: 10px; color: var(--t2); line-height: 1.5; }
.tac-action-meta {
  margin-top: 4px; display: flex; gap: 6px; align-items: center; flex-wrap: wrap;
}
.tac-action-framework {
  font-size: 8px; color: var(--t3); font-family: 'Space Mono', monospace;
  padding: 1px 5px; background: rgba(245,166,35,0.08); border-radius: 3px;
}
.tac-action-with {
  font-size: 8px; color: var(--t3); font-family: 'Space Mono', monospace;
}

/* ===== NEWS FEED ===== */
.news-feed { }
.news-item {
  padding: 8px 0; border-bottom: 1px solid var(--border);
}
.news-item:last-child { border-bottom: none; }
.news-title { display: block; }
.news-title:hover { color: var(--gold) !important; }

/* ===== TIMELINE ===== */
.timeline-item {
  position: relative; padding: 8px 8px 8px 20px; margin-bottom: 4px;
  font-size: 11px; color: var(--t2); line-height: 1.4;
}
.timeline-item::before {
  content: ''; position: absolute; left: 6px; top: 12px;
  width: 6px; height: 6px; border-radius: 50%; background: var(--border);
}
.timeline-item::after {
  content: ''; position: absolute; left: 8px; top: 20px; bottom: -4px;
  width: 1px; background: var(--border);
}
.timeline-item:last-child::after { display: none; }
.tl-date { font-size: 9px; color: var(--t3); font-family: 'Space Mono', monospace; }
.tl-event { margin-top: 2px; }
.tl-source { font-size: 8px; color: var(--t3); font-family: 'Space Mono', monospace; margin-top: 2px; }
.timeline-item.escalation::before { background: var(--red); }
.timeline-item.deescalation::before { background: var(--green); }
.timeline-item.diplomatic::before { background: var(--cyan); }
.timeline-item.military::before { background: var(--high); }
.timeline-item.humanitarian::before { background: #8b5cf6; }

/* ===== TIMELINE FILTERS ===== */
.tl-filters { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 10px; }
.tl-filter-btn {
  padding: 3px 8px; font-size: 9px; font-family: 'Space Mono', monospace;
  background: var(--card); border: 1px solid var(--border); border-radius: 12px;
  color: var(--t3); cursor: pointer; transition: all .15s;
}
.tl-filter-btn:hover { color: var(--t1); border-color: var(--t3); }
.tl-filter-btn.active { background: var(--gold); color: var(--bg); border-color: var(--gold); }

/* ===== 3-TIER RECOMMENDATIONS ===== */
.tac-tier { margin-bottom: 8px; }
.tac-tier-header {
  font-size: 9px; font-family: 'Space Mono', monospace; font-weight: 700;
  text-transform: uppercase; letter-spacing: 1px; padding: 4px 0; margin-bottom: 4px;
  border-bottom: 1px solid var(--border);
}

/* ===== DEEP DIVE BUTTON ===== */
.deep-dive-btn {
  display: block; width: 100%; padding: 10px; margin-top: 12px;
  background: var(--gold); color: var(--bg); border: none; border-radius: 6px;
  font-family: 'Space Mono', monospace; font-size: 11px; font-weight: 700;
  text-align: center; text-decoration: none; cursor: pointer;
  transition: transform .15s, box-shadow .15s; letter-spacing: 0.5px;
}
.deep-dive-btn:hover { transform: translateY(-1px); box-shadow: 0 4px 16px rgba(245,166,35,0.3); }

/* ===== EMAIL GATE MODAL ===== */
#email-modal {
  display: none; position: fixed; top: 0; left: 0; right: 0; bottom: 0; z-index: 9999;
  align-items: center; justify-content: center;
}
.em-overlay { position: absolute; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,0.7); }
.em-card {
  position: relative; background: var(--panel); border: 1px solid var(--border); border-radius: 12px;
  padding: 32px 28px; max-width: 380px; width: 90%; text-align: center;
  box-shadow: 0 16px 48px rgba(0,0,0,0.5);
}
.em-close {
  position: absolute; top: 10px; right: 12px; background: none; border: none;
  color: var(--t3); font-size: 18px; cursor: pointer;
}
.em-close:hover { color: var(--t1); }
.em-icon { font-size: 36px; margin-bottom: 12px; }
.em-title { font-size: 16px; font-weight: 700; color: var(--t1); margin-bottom: 4px; }
.em-subtitle { font-size: 12px; color: var(--t2); margin-bottom: 18px; }
.em-input {
  width: 100%; padding: 10px 12px; background: var(--card); border: 1px solid var(--border);
  border-radius: 6px; color: var(--t1); font-size: 13px; font-family: 'DM Sans', sans-serif;
  outline: none; margin-bottom: 12px;
}
.em-input:focus { border-color: var(--gold); }
.em-submit {
  width: 100%; padding: 10px; background: var(--gold); color: var(--bg); border: none;
  border-radius: 6px; font-family: 'Space Mono', monospace; font-size: 12px; font-weight: 700;
  cursor: pointer; transition: transform .15s;
}
.em-submit:hover { transform: translateY(-1px); }
.em-note { font-size: 10px; color: var(--t3); margin-top: 10px; }
.em-status { font-size: 11px; margin-top: 8px; min-height: 16px; }

/* ===== RESPONSIVE ===== */
@media (max-width: 900px) {
  #panel { width: 100%; right: -100%; top: 40vh; }
  #map-wrap.po { right: 0; }
  #nav-links { display: none; }
  #gbar { gap: 10px; flex-wrap: wrap; height: auto; min-height: 36px; padding: 4px 10px; }
  .gb-l { display: none; }
  .gb-v { font-size: 11px; }
}
@media (max-width: 600px) {
  #ctrls { display: none; }
  #gbar { gap: 6px; }
}
