/* ============================================================
   TrafficMesh — Dark Theme Styles
   Leaflet map + sparklines + connected systems + decision modal
   Fonts are self-hosted — loaded via /vendor/fonts/fonts.css.
   ============================================================ */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --tier1-color:     #C9A84C;
  --tier1-bg:        rgba(201,168,76,0.12);
  --tier2-color:     #2E6DA4;
  --tier2-bg:        rgba(46,109,164,0.12);
  --tier3-color:     #0A8A7A;
  --tier3-bg:        rgba(10,138,122,0.12);
  --intel-teal:      #0A8A7A;
  --intel-amber:     #D4860A;
  --intel-red:       #C0392B;
  --intel-purple:    #6C3A9E;
  --intel-gray:      #5A6472;
  --accent-color:    #C9A84C;
  --accent-bg:       rgba(201,168,76,0.1);
  --dash-bg:         #070D1A;
  --panel-bg:        #0D1526;
  --panel-border:    rgba(255,255,255,0.06);
  --text-primary:    #E8EDF5;
  --text-secondary:  #8A96A8;
  --text-muted:      #4A5568;
  --strip-collapsed: 52px;
  --strip-expanded:  280px;
  --overlay-bg:      rgba(7,13,26,0.92);
  --border-radius:   8px;
  --border-radius-lg:12px;
}

html, body {
  width: 100%; height: 100%; overflow: hidden;
  background: var(--dash-bg);
  color: var(--text-primary);
  font-family: 'Noto Sans', system-ui, -apple-system, sans-serif;
  font-size: 13px;
}

/* ── Activity Strip ─────────────────────────────────────── */
#activity-strip {
  position: fixed; left: 0; top: 0; bottom: 0;
  width: var(--strip-collapsed);
  background: var(--panel-bg);
  border-right: 1px solid var(--panel-border);
  z-index: 100;
  transition: width 250ms ease;
  overflow: hidden;
  display: flex; flex-direction: column;
}
#activity-strip:hover { width: var(--strip-expanded); }

.strip-collapsed-content {
  position: absolute; top: 0; left: 0; width: var(--strip-collapsed);
  height: 100%; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 12px;
  transition: opacity 150ms;
}
#activity-strip:hover .strip-collapsed-content { opacity: 0; pointer-events: none; }

.strip-label {
  writing-mode: vertical-rl; transform: rotate(180deg);
  font-size: 9px; letter-spacing: 2px; text-transform: uppercase;
  color: var(--text-muted); white-space: nowrap;
}

.tier-dot {
  width: 8px; height: 8px; border-radius: 50%;
  animation: tierPulse 1.5s ease-in-out infinite;
}
.tier-dot.t1 { background: var(--tier1-color); animation-delay: 0s; }
.tier-dot.t2 { background: var(--tier2-color); animation-delay: 0.5s; }
.tier-dot.t3 { background: var(--tier3-color); animation-delay: 1.0s; }

@keyframes tierPulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%       { opacity: 0.3; transform: scale(1.4); }
}

.strip-expanded-content {
  position: absolute; top: 0; left: 0; width: var(--strip-expanded);
  height: 100%; display: flex; flex-direction: column;
  opacity: 0; transition: opacity 150ms 80ms;
  padding: 12px 10px 8px;
}
#activity-strip:hover .strip-expanded-content { opacity: 1; }

.strip-header { font-size: 12px; font-weight: 500; margin-bottom: 2px; }
.strip-header-ar { font-size: 10px; color: var(--text-muted); font-family: 'Noto Sans Arabic', sans-serif; direction: rtl; margin-bottom: 10px; }

#strip-log {
  flex: 1; overflow: hidden; display: flex; flex-direction: column;
  gap: 2px;
}

.strip-entry {
  display: flex; align-items: center; gap: 6px;
  height: 26px; min-height: 26px;
  animation: stripSlideIn 150ms ease;
  padding: 0 2px;
  border-radius: 4px;
  transition: opacity 200ms;
}
.strip-entry.dimmed { opacity: 0.25; }

@keyframes stripSlideIn {
  from { opacity: 0; transform: translateY(-8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.strip-dot {
  width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0;
}
.strip-dot.t1 { background: var(--tier1-color); }
.strip-dot.t2 { background: var(--tier2-color); }
.strip-dot.t3 { background: var(--tier3-color); }

.strip-task { flex: 1; font-size: 11px; color: var(--text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.strip-latency { font-size: 10px; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.strip-time { font-size: 9px; color: var(--text-muted); }

.strip-tally {
  padding-top: 8px; border-top: 1px solid var(--panel-border);
  display: flex; gap: 8px; flex-wrap: wrap;
  font-size: 10px; color: var(--text-muted);
}
.tally-t1 { color: var(--tier1-color); }
.tally-t2 { color: var(--tier2-color); }
.tally-t3 { color: var(--tier3-color); }

/* ── Main Layout ────────────────────────────────────────── */
#app {
  margin-left: var(--strip-collapsed);
  height: 100vh;
  display: flex; flex-direction: column;
}

/* ── Header ─────────────────────────────────────────────── */
#header {
  height: 56px; flex-shrink: 0;
  background: var(--panel-bg);
  border-bottom: 1px solid var(--panel-border);
  display: flex; align-items: center; gap: 12px;
  padding: 0 16px;
}

.partner-logo {
  border-radius: 6px; padding: 4px 10px;
  font-size: 11px; color: #fff;
  font-weight: 700; letter-spacing: 0.08em;
  white-space: nowrap;
}

.header-sep { color: var(--text-muted); font-size: 16px; }

.header-brand { font-size: 18px; font-weight: 500; color: var(--text-primary); }
.header-brand-ar { font-size: 12px; color: var(--text-muted); font-family: 'Noto Sans Arabic', sans-serif; direction: rtl; }

.internal-badge {
  background: rgba(201,168,76,0.15); color: var(--tier1-color);
  border: 1px solid rgba(201,168,76,0.4);
  border-radius: 4px; padding: 2px 8px; font-size: 10px; font-weight: 600;
  letter-spacing: 1px; text-transform: uppercase;
}

.header-spacer { flex: 1; }

.ops-time {
  display: flex; align-items: center; gap: 6px;
  font-size: 12px; color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
}
.live-dot {
  width: 7px; height: 7px; border-radius: 50%; background: #2ECC71;
  animation: livePulse 1.5s ease-in-out infinite;
}
@keyframes livePulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.3; }
}

.btn-secondary {
  background: transparent; border: 1px solid var(--panel-border);
  color: var(--text-secondary); border-radius: 6px;
  padding: 5px 11px; font-size: 12px; cursor: pointer;
  transition: all 150ms;
}
.btn-secondary:hover { border-color: var(--text-muted); color: var(--text-primary); }

.btn-exec {
  background: transparent; border: 1px solid var(--accent-color);
  color: var(--accent-color); border-radius: 6px;
  padding: 5px 11px; font-size: 12px; cursor: pointer;
  transition: all 150ms;
}
.btn-exec:hover { background: var(--accent-bg); }

/* ── Body ───────────────────────────────────────────────── */
#body {
  flex: 1; display: flex; overflow: hidden;
}

/* ── Map Panel ──────────────────────────────────────────── */
#map-panel {
  flex: 0 0 60%; position: relative; overflow: hidden;
  background: #060C18;
  display: flex; flex-direction: column;
}

.map-container {
  flex: 1; position: relative;
}

#leaflet-map {
  position: absolute; inset: 0;
  z-index: 1;
}

/* Map zoom toggle overlay */
.map-zoom-toggle {
  position: absolute; top: 8px; right: 8px; z-index: 10;
  display: flex; border-radius: 6px; overflow: hidden;
  border: 1px solid var(--panel-border);
}
.zoom-btn {
  background: rgba(13,21,38,0.85); backdrop-filter: blur(4px);
  border: none; color: var(--text-secondary);
  padding: 4px 10px; font-size: 11px; cursor: pointer; transition: all 150ms;
}
.zoom-btn.active { background: rgba(255,255,255,0.12); color: var(--text-primary); }

/* Map ticker */
#map-ticker {
  height: 28px; background: rgba(13,21,38,0.95);
  border-top: 1px solid var(--panel-border);
  overflow: hidden; display: flex; align-items: center;
  flex-shrink: 0; z-index: 10; position: relative;
}
.ticker-track {
  display: flex; gap: 60px;
  animation: tickerScroll 30s linear infinite;
  white-space: nowrap;
}
@keyframes tickerScroll {
  0%   { transform: translateX(0); }
  100% { transform: translateX(-50%); }
}
.ticker-item { font-size: 11px; color: var(--text-muted); }
.ticker-sep { color: var(--accent-color); }

/* ── Leaflet Dark Theme Overrides ───────────────────────── */
.leaflet-container {
  background: #060C18 !important;
  font-family: inherit;
}
.leaflet-control-attribution {
  background: rgba(7,13,26,0.75) !important;
  color: var(--text-muted) !important;
  font-size: 9px !important;
  padding: 2px 5px !important;
  border-radius: 3px 0 0 0 !important;
}
.leaflet-control-attribution a { color: var(--text-muted) !important; }

.dark-popup .leaflet-popup-content-wrapper {
  background: var(--panel-bg);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: var(--border-radius-lg);
  box-shadow: 0 8px 32px rgba(0,0,0,0.6);
  color: var(--text-primary);
  padding: 0;
}
.dark-popup .leaflet-popup-content {
  margin: 0;
  width: auto !important;
}
.dark-popup .leaflet-popup-tip-container { display: none; }
.dark-popup .leaflet-popup-close-button {
  color: var(--text-muted) !important;
  font-size: 18px !important;
  top: 8px !important; right: 10px !important;
}
.dark-popup .leaflet-popup-close-button:hover { color: var(--text-primary) !important; }

/* Leaflet popup content */
.lf-popup { padding: 12px; min-width: 230px; }
.lf-popup-name { font-size: 13px; font-weight: 500; padding-right: 20px; }
.lf-popup-ar { font-size: 11px; color: var(--text-muted); font-family: 'Noto Sans Arabic', sans-serif; direction: rtl; margin-top: 2px; margin-bottom: 8px; }
.lf-popup-construction {
  margin-bottom: 8px; padding: 4px 8px;
  background: rgba(243,156,18,0.1); border-radius: 5px;
  font-size: 10px; color: #F39C12;
}
.lf-popup-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.lf-popup-metric { font-size: 11px; }
.lf-popup-metric span:first-child { color: var(--text-muted); display: block; margin-bottom: 2px; }
.lf-popup-metric span:last-child { color: var(--text-primary); font-weight: 500; font-size: 13px; }
.lf-popup-state { margin-top: 8px; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; }

/* ANPR marker */
.anpr-marker-wrap {
  width: 18px; height: 18px; position: relative;
  display: flex; align-items: center; justify-content: center;
}
.anpr-marker-core {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--tier3-color);
  border: 2px solid rgba(10,138,122,0.6);
  position: relative; z-index: 2;
}
.anpr-marker-ring {
  position: absolute; inset: -3px; border-radius: 50%;
  border: 1.5px solid rgba(10,138,122,0.4);
  animation: anprRing 2s ease-out infinite;
}
@keyframes anprRing {
  0%   { transform: scale(1); opacity: 0.8; }
  100% { transform: scale(2.2); opacity: 0; }
}

.leaflet-tooltip.anpr-tooltip {
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  color: var(--text-secondary);
  font-size: 10px;
  padding: 3px 7px;
  border-radius: 4px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.4);
}
.leaflet-tooltip.anpr-tooltip::before { display: none; }

.leaflet-tooltip.int-tooltip {
  background: rgba(13,21,38,0.9);
  border: 1px solid var(--panel-border);
  color: var(--text-muted);
  font-size: 9px;
  padding: 2px 6px;
  border-radius: 3px;
  white-space: nowrap;
  box-shadow: none;
}
.leaflet-tooltip.int-tooltip::before { display: none; }

/* ── Right Panel ────────────────────────────────────────── */
#right-panel {
  flex: 0 0 40%;
  display: flex; flex-direction: column;
  border-left: 1px solid var(--panel-border);
  overflow-y: auto;
  overflow-x: hidden;
}

/* Metrics strip */
#metrics-strip {
  flex-shrink: 0; height: 90px;
  display: flex; gap: 1px;
  background: var(--panel-border);
  border-bottom: 1px solid var(--panel-border);
}
.metric-card {
  flex: 1; background: var(--panel-bg);
  display: flex; flex-direction: column;
  justify-content: center; align-items: center; gap: 2px;
  padding: 6px 4px;
  position: relative;
}
.metric-value {
  font-size: 22px; font-weight: 600;
  font-variant-numeric: tabular-nums;
  transition: color 500ms;
}
.metric-value.good { color: #2ECC71; }
.metric-value.warn { color: #F39C12; }
.metric-value.bad  { color: #E74C3C; }
.metric-value.neutral { color: var(--text-primary); }
.metric-label { font-size: 10px; color: var(--text-muted); text-align: center; }
.metric-label-ar { font-size: 9px; color: var(--text-muted); font-family: 'Noto Sans Arabic', sans-serif; direction: rtl; }

/* Sparkline canvas */
.sparkline-canvas {
  display: block; margin-top: 3px;
  opacity: 0.85;
}

/* ── B4 Impact Counter ─────────────────────────────────── */
#impact-strip {
  flex-shrink: 0;
  background: var(--panel-bg);
  border-bottom: 1px solid var(--panel-border);
  padding: 5px 8px 4px;
  display: flex; flex-direction: column; gap: 3px;
}
.impact-header {
  display: flex; align-items: baseline; gap: 6px;
}
.impact-title {
  font-size: 8px; font-weight: 700; letter-spacing: 1.5px;
  color: var(--text-muted); text-transform: uppercase;
}
.impact-title-ar {
  font-size: 8px; color: var(--text-muted);
}
.impact-cards {
  display: flex; gap: 1px;
}
.impact-card {
  flex: 1; display: flex; flex-direction: column; align-items: center;
  padding: 3px 0; gap: 1px;
}
.impact-value {
  font-size: 17px; font-weight: 700; font-variant-numeric: tabular-nums;
  color: var(--tier2-color); line-height: 1;
}
.impact-unit {
  font-size: 8.5px; color: var(--text-muted); text-align: center;
}
.impact-unit-ar {
  font-size: 8px; color: var(--text-muted); text-align: center;
}
.impact-footnote {
  font-size: 7.5px; color: var(--text-muted); opacity: 0.65;
  text-align: center;
}

/* ── B8 Signature scenario beat badge ──────────────────── */
.scenario-beat-badge {
  display: inline-block; font-size: 8.5px; font-weight: 700;
  letter-spacing: 0.8px; text-transform: uppercase;
  padding: 2px 7px; border-radius: 3px;
  margin: 0 0 4px 0;
  background: rgba(108, 58, 158, 0.15);
  color: var(--intel-purple);
  border: 1px solid rgba(108, 58, 158, 0.3);
}
.scenario-beat-badge.resolved {
  background: rgba(10, 138, 122, 0.15);
  color: var(--intel-teal);
  border-color: rgba(10, 138, 122, 0.3);
}

/* ── Connected Systems Bar ─────────────────────────────── */
#systems-bar {
  flex-shrink: 0; height: 32px;
  background: var(--panel-bg);
  border-bottom: 1px solid var(--panel-border);
  display: flex; align-items: center; padding: 0 4px; gap: 0;
  overflow: hidden;
}

.sys-entry {
  display: flex; align-items: center; gap: 4px; flex: 1; min-width: 0;
  padding: 0 5px; border-right: 1px solid var(--panel-border);
  height: 100%; transition: background 300ms ease;
}
.sys-entry:last-child { border-right: none; }

.sys-entry.tx-active {
  background: rgba(10,138,122,0.12);
  animation: sysTxPulse 700ms ease;
}
@keyframes sysTxPulse {
  0%   { background: rgba(10,138,122,0); }
  35%  { background: rgba(10,138,122,0.25); }
  100% { background: rgba(10,138,122,0.12); }
}

.sys-dot {
  width: 5px; height: 5px; border-radius: 50%;
  background: #2ECC71; flex-shrink: 0;
  animation: livePulse 2.2s ease-in-out infinite;
}
.sys-name {
  font-size: 9px; font-weight: 600; color: var(--text-primary);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  letter-spacing: 0.3px;
}
.sys-proto {
  font-size: 8px; color: var(--text-muted);
  white-space: nowrap; flex-shrink: 0;
}
.sys-rate {
  font-size: 9px; color: var(--tier3-color);
  font-variant-numeric: tabular-nums;
  white-space: nowrap; flex-shrink: 0; margin-left: auto;
}

/* Advisory feed */
#advisory-section {
  flex-shrink: 0; height: 135px;
  background: var(--panel-bg);
  border-bottom: 1px solid var(--panel-border);
  padding: 8px 10px;
  overflow: hidden;
}
.section-title {
  font-size: 11px; font-weight: 500; color: var(--text-secondary);
  text-transform: uppercase; letter-spacing: 1px; margin-bottom: 6px;
}
.section-title.clickable {
  display: flex; align-items: center; justify-content: space-between;
  gap: 8px; cursor: pointer; user-select: none;
  border-radius: 4px; padding: 2px 4px; margin: -2px -4px 4px;
  transition: background 150ms, color 150ms;
}
.section-title.clickable:hover {
  background: rgba(255,255,255,0.04);
  color: var(--text-primary);
}
.section-title.clickable:hover .section-title-hint {
  color: var(--accent-color);
}
.section-title-hint {
  font-size: 9px; font-weight: 600; letter-spacing: 0.5px;
  color: var(--text-muted); text-transform: uppercase;
  transition: color 150ms;
}
#advisory-list { display: flex; flex-direction: column; gap: 4px; overflow: hidden; }
.advisory-entry {
  display: flex; align-items: flex-start; gap: 6px;
  font-size: 11px;
  animation: slideDown 300ms ease;
}
@keyframes slideDown {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: translateY(0); }
}
.adv-time { color: var(--text-muted); white-space: nowrap; flex-shrink: 0; font-size: 10px; margin-top: 1px; }
.adv-tier {
  border-radius: 3px; padding: 1px 4px; font-size: 9px; font-weight: 600;
  flex-shrink: 0; margin-top: 1px;
}
.adv-tier.t1 { background: var(--tier1-bg); color: var(--tier1-color); }
.adv-tier.t2 { background: var(--tier2-bg); color: var(--tier2-color); }
.adv-tier.t3 { background: var(--tier3-bg); color: var(--tier3-color); }
.adv-text { color: var(--text-secondary); line-height: 1.4; }

/* Incident log */
#incident-section {
  flex-shrink: 0; height: 130px;
  background: var(--panel-bg);
  border-bottom: 1px solid var(--panel-border);
  padding: 8px 10px; overflow: hidden;
}
#incident-list { display: flex; flex-direction: column; gap: 4px; overflow: hidden; }
.incident-row {
  display: flex; align-items: center; gap: 8px;
  font-size: 11px; height: 24px;
  animation: slideDown 300ms ease;
}
.inc-severity {
  border-radius: 3px; padding: 1px 5px; font-size: 9px; font-weight: 700;
  flex-shrink: 0; text-transform: uppercase;
}
.inc-severity.high   { background: rgba(192,57,43,0.2); color: #E74C3C; }
.inc-severity.medium { background: rgba(211,84,0,0.2);  color: #E67E22; }
.inc-severity.low    { background: rgba(90,100,114,0.2);color: var(--text-secondary); }
.inc-type { color: var(--text-primary); font-weight: 500; }
.inc-location { color: var(--text-muted); flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.inc-elapsed { color: var(--text-muted); flex-shrink: 0; font-size: 10px; }
.inc-status { color: var(--tier3-color); font-size: 10px; flex-shrink: 0; max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ── Intel Feed ─────────────────────────────────────────── */
#intel-section {
  background: #080F1F;
  border-top: 1px solid var(--panel-border);
  display: flex; flex-direction: column;
}
#intel-header {
  padding: 8px 10px 6px;
  border-bottom: 1px solid var(--panel-border);
  display: flex; align-items: center; gap: 8px; flex-shrink: 0;
}
.intel-title { font-size: 11px; font-weight: 500; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 1px; }
.intel-count { font-size: 11px; color: var(--accent-color); margin-left: auto; }

#intel-feed {
  padding: 6px;
  display: flex; flex-direction: column; gap: 6px;
}
#intel-feed::-webkit-scrollbar { width: 4px; }
#intel-feed::-webkit-scrollbar-track { background: transparent; }
#intel-feed::-webkit-scrollbar-thumb { background: var(--text-muted); border-radius: 2px; }

.intel-thinking {
  display: flex; align-items: center; gap: 6px;
  font-size: 12px; color: var(--text-muted);
  padding: 8px 10px;
  animation: slideDown 200ms ease;
}
.intel-thinking .dots span {
  display: inline-block;
  animation: dotBlink 1.2s ease-in-out infinite;
}
.intel-thinking .dots span:nth-child(2) { animation-delay: 0.4s; }
.intel-thinking .dots span:nth-child(3) { animation-delay: 0.8s; }
@keyframes dotBlink {
  0%, 80%, 100% { opacity: 0.2; }
  40%            { opacity: 1; }
}

.intel-card {
  background: var(--panel-bg);
  border-radius: var(--border-radius);
  border: 1px solid var(--panel-border);
  overflow: hidden;
  animation: cardSlideIn 300ms ease;
  transition: opacity 300ms;
}
.intel-card.reviewed { opacity: 0.4; }

@keyframes cardSlideIn {
  from { opacity: 0; transform: translateY(-10px); }
  to   { opacity: 1; transform: translateY(0); }
}

.card-accent-bar { height: 3px; }
.intel-card[data-type="teal"]   .card-accent-bar { background: var(--intel-teal); }
.intel-card[data-type="amber"]  .card-accent-bar { background: var(--intel-amber); }
.intel-card[data-type="red"]    .card-accent-bar { background: var(--intel-red); }
.intel-card[data-type="purple"] .card-accent-bar { background: var(--intel-purple); }
.intel-card[data-type="gray"]   .card-accent-bar { background: var(--intel-gray); }

.intel-card[data-type="teal"]   { border-left: 3px solid var(--intel-teal); }
.intel-card[data-type="amber"]  { border-left: 3px solid var(--intel-amber); }
.intel-card[data-type="red"]    { border-left: 3px solid var(--intel-red); }
.intel-card[data-type="purple"] { border-left: 3px solid var(--intel-purple); }
.intel-card[data-type="gray"]   { border-left: 3px solid var(--intel-gray); }

.card-header {
  display: flex; align-items: center; gap: 6px;
  padding: 6px 8px 4px;
}
.card-sources { display: flex; gap: 4px; flex: 1; flex-wrap: wrap; }
.source-tag {
  font-size: 10px; padding: 1px 6px;
  background: rgba(255,255,255,0.05); border-radius: 10px;
  color: var(--text-muted); border: 1px solid var(--panel-border);
}
.card-tier-badges { display: flex; gap: 3px; }
.tier-badge {
  font-size: 9px; font-weight: 700; padding: 1px 5px;
  border-radius: 3px; cursor: pointer; transition: opacity 150ms;
}
.tier-badge:hover { opacity: 0.8; }
.tier-badge.t1 { background: var(--tier1-bg); color: var(--tier1-color); }
.tier-badge.t2 { background: var(--tier2-bg); color: var(--tier2-color); }
.tier-badge.t3 { background: var(--tier3-bg); color: var(--tier3-color); }

.card-headline { padding: 0 8px 4px; font-size: 12px; font-weight: 500; line-height: 1.4; }

.card-action {
  padding: 4px 8px;
  display: flex; gap: 6px; align-items: flex-start;
  background: rgba(255,255,255,0.02);
}
.action-label { font-size: 9px; color: var(--tier3-color); font-weight: 600; text-transform: uppercase; flex-shrink: 0; margin-top: 1px; }
.action-text { font-size: 11px; color: var(--text-secondary); line-height: 1.4; }

.card-footer {
  display: flex; align-items: center; gap: 6px;
  padding: 4px 8px;
  border-top: 1px solid var(--panel-border);
}
.card-time { font-size: 10px; color: var(--text-muted); flex: 1; font-variant-numeric: tabular-nums; }
.card-confidence { font-size: 10px; color: var(--text-muted); }
.card-btn {
  background: none; border: 1px solid var(--panel-border);
  color: var(--text-muted); border-radius: 4px;
  padding: 2px 7px; font-size: 10px; cursor: pointer;
  transition: all 150ms;
}
.card-btn:hover { border-color: var(--text-secondary); color: var(--text-primary); }
.card-btn.reviewed-btn { color: var(--intel-teal); border-color: rgba(10,138,122,0.3); }

/* Operator Approved badge on intel cards */
.op-approved-badge {
  display: inline-flex; align-items: center; gap: 4px;
  margin: 0 8px 6px;
  padding: 3px 8px;
  background: rgba(10,138,122,0.1);
  border: 1px solid rgba(10,138,122,0.3);
  border-radius: 10px;
  font-size: 10px; color: var(--tier3-color); font-weight: 600;
  animation: slideDown 300ms ease;
}

/* ── Badge Popover ──────────────────────────────────────── */
#badge-popover {
  position: fixed; z-index: 200;
  width: 320px;
  background: #12203A;
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: var(--border-radius-lg);
  padding: 16px;
  box-shadow: 0 16px 48px rgba(0,0,0,0.6);
  display: none;
}
#badge-popover.visible { display: block; animation: popoverIn 200ms ease; }
@keyframes popoverIn {
  from { opacity: 0; transform: scale(0.95); }
  to   { opacity: 1; transform: scale(1); }
}
.popover-tier-name { font-size: 15px; font-weight: 600; margin-bottom: 2px; }
.popover-tier-ar { font-size: 12px; color: var(--text-muted); font-family: 'Noto Sans Arabic', sans-serif; direction: rtl; margin-bottom: 10px; }
.popover-divider { border: none; border-top: 1px solid rgba(255,255,255,0.08); margin: 8px 0; }
.popover-desc { font-size: 12px; color: var(--text-secondary); line-height: 1.6; margin-bottom: 10px; }
.popover-tags { display: flex; flex-wrap: wrap; gap: 5px; margin-bottom: 10px; }
.popover-tag {
  font-size: 11px; padding: 3px 10px;
  border-radius: 20px; border: 1px solid;
}
.popover-tag.t1 { background: var(--tier1-bg); color: var(--tier1-color); border-color: rgba(201,168,76,0.3); }
.popover-tag.t2 { background: var(--tier2-bg); color: var(--tier2-color); border-color: rgba(46,109,164,0.3); }
.popover-tag.t3 { background: var(--tier3-bg); color: var(--tier3-color); border-color: rgba(10,138,122,0.3); }
.popover-meta { font-size: 11px; color: var(--text-muted); margin-bottom: 12px; line-height: 1.7; }
.btn-view-arch {
  width: 100%; background: transparent;
  border: 1px solid var(--accent-color);
  color: var(--accent-color); border-radius: 6px;
  padding: 8px; font-size: 12px; cursor: pointer;
  transition: background 150ms;
}
.btn-view-arch:hover { background: var(--accent-bg); }

/* ── Architecture Overlay ───────────────────────────────── */
#arch-overlay {
  position: fixed; inset: 0; z-index: 300;
  background: var(--overlay-bg);
  display: none; flex-direction: column;
}
#arch-overlay.visible { display: flex; animation: overlayIn 400ms ease; }
@keyframes overlayIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.overlay-header {
  height: 56px; flex-shrink: 0;
  display: flex; align-items: center; gap: 8px;
  padding: 0 20px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}
.overlay-title { font-size: 16px; font-weight: 500; }
.overlay-title-ar { font-size: 13px; color: var(--text-muted); font-family: 'Noto Sans Arabic', sans-serif; direction: rtl; }
.btn-close-overlay {
  margin-left: auto; background: transparent;
  border: 1px solid var(--panel-border); color: var(--text-secondary);
  border-radius: 6px; padding: 5px 12px; font-size: 12px; cursor: pointer;
  transition: all 150ms;
}
.btn-close-overlay:hover { border-color: var(--text-muted); color: var(--text-primary); }

.overlay-body {
  flex: 1; display: flex; gap: 0; overflow: hidden;
  padding: 20px;
}

.overlay-left {
  width: 35%; display: flex; flex-direction: column; gap: 8px;
  padding-right: 20px; border-right: 1px solid rgba(255,255,255,0.06);
}

.tier-card {
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: var(--border-radius-lg);
  padding: 14px;
  opacity: 0; transition: opacity 300ms ease;
}
.tier-card.visible { opacity: 1; }

.tier-card-header {
  display: flex; align-items: center; gap: 10px; margin-bottom: 10px;
}
.tier-icon { width: 22px; height: 22px; flex-shrink: 0; }
.tier-card-name { font-size: 13px; font-weight: 600; }
.tier-card-name-ar { font-size: 11px; color: var(--text-muted); font-family: 'Noto Sans Arabic', sans-serif; direction: rtl; }
.tier-card-model {
  display: inline-block; margin: 4px 0 8px;
  font-size: 10px; padding: 2px 8px; border-radius: 3px;
  font-weight: 600;
}
.tier-card[data-tier="1"] .tier-card-model { background: var(--tier1-bg); color: var(--tier1-color); }
.tier-card[data-tier="2"] .tier-card-model { background: var(--tier2-bg); color: var(--tier2-color); }
.tier-card[data-tier="3"] .tier-card-model { background: var(--tier3-bg); color: var(--tier3-color); }
.tier-card-desc { font-size: 11px; color: var(--text-secondary); line-height: 1.6; }
.connector-line { stroke: rgba(255,255,255,0.15); stroke-dasharray: 4 3; stroke-width: 1.5; animation: connectorFlow 2s linear infinite; }
@keyframes connectorFlow { from { stroke-dashoffset: 0; } to { stroke-dashoffset: -14; } }

.overlay-center {
  flex: 1; padding: 0 20px; display: flex; flex-direction: column;
}
.overlay-center-title { font-size: 12px; font-weight: 500; text-transform: uppercase; letter-spacing: 1px; color: var(--text-muted); margin-bottom: 14px; }
.pipeline-monitor { text-align: center; color: var(--text-muted); font-size: 12px; padding: 20px 0; }

.pipeline-node {
  background: rgba(255,255,255,0.03); border: 1px solid rgba(255,255,255,0.06);
  border-radius: var(--border-radius); padding: 12px 14px; margin-bottom: 10px;
  opacity: 0; transition: opacity 300ms ease;
}
.pipeline-node.visible { opacity: 1; }
.pipeline-node-header { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.pipeline-node-label { font-size: 11px; font-weight: 500; flex: 1; }
.pipeline-latency { font-size: 10px; color: var(--tier3-color); font-variant-numeric: tabular-nums; }
.pipeline-bar-track { height: 3px; background: rgba(255,255,255,0.06); border-radius: 2px; }
.pipeline-bar { height: 3px; border-radius: 2px; width: 0; transition: width 800ms ease; }
.pipeline-node[data-tier="3"] .pipeline-bar { background: var(--tier3-color); }
.pipeline-node[data-tier="2"] .pipeline-bar { background: var(--tier2-color); }
.pipeline-node[data-tier="1"] .pipeline-bar { background: var(--tier1-color); }

.pipeline-result {
  margin-top: auto; padding: 14px;
  background: rgba(201,168,76,0.06); border: 1px solid rgba(201,168,76,0.2);
  border-radius: var(--border-radius); opacity: 0; transition: opacity 300ms;
}
.pipeline-result.visible { opacity: 1; }
.result-label { font-size: 9px; text-transform: uppercase; letter-spacing: 1px; color: var(--tier1-color); margin-bottom: 6px; font-weight: 600; }
.result-headline { font-size: 12px; color: var(--text-primary); line-height: 1.5; }

.overlay-tally { display: flex; gap: 12px; margin-top: 10px; }
.overlay-tally span { font-size: 10px; font-variant-numeric: tabular-nums; }

.overlay-right {
  width: 25%; padding-left: 20px;
  border-left: 1px solid rgba(255,255,255,0.06);
  display: flex; flex-direction: column; gap: 10px;
}
.overlay-right-title { font-size: 12px; font-weight: 500; text-transform: uppercase; letter-spacing: 1px; color: var(--text-muted); }

.compliance-card {
  background: rgba(255,255,255,0.03); border: 1px solid rgba(255,255,255,0.06);
  border-radius: var(--border-radius); padding: 12px;
  opacity: 0; transition: opacity 300ms ease;
}
.compliance-card.visible { opacity: 1; }
.comp-card-header { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.comp-icon { width: 16px; height: 16px; color: var(--accent-color); flex-shrink: 0; }
.comp-card-title { font-size: 12px; font-weight: 500; }
.comp-card-desc { font-size: 11px; color: var(--text-secondary); line-height: 1.5; }

.overlay-close-statement {
  margin-top: auto; padding: 12px;
  background: rgba(255,255,255,0.02); border-radius: var(--border-radius);
  font-size: 11px; color: var(--text-muted); line-height: 1.6;
}

#claude-quote {
  font-size: 12px; color: var(--text-secondary); line-height: 1.7;
  font-style: italic;
}

/* ── Executive View ─────────────────────────────────────── */
#exec-view {
  position: fixed; inset: 0; z-index: 250;
  background: var(--overlay-bg);
  display: none; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 40px;
}
#exec-view.visible { display: flex; animation: execFadeIn 300ms ease; }
@keyframes execFadeIn { from { opacity: 0; } to { opacity: 1; } }

.exec-header {
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 32px; font-size: 18px; font-weight: 500;
}
.exec-kpis {
  display: flex; gap: 24px; margin-bottom: 32px;
}
.exec-kpi {
  background: var(--panel-bg); border: 1px solid var(--panel-border);
  border-radius: var(--border-radius-lg); padding: 24px 32px;
  text-align: center; min-width: 160px;
}
.exec-kpi-value { font-size: 42px; font-weight: 700; color: var(--accent-color); font-variant-numeric: tabular-nums; }
.exec-kpi-label { font-size: 13px; color: var(--text-secondary); margin-top: 4px; }
.exec-kpi-delta { font-size: 12px; color: #2ECC71; margin-top: 4px; }

.exec-insight {
  max-width: 640px; text-align: center;
  font-size: 15px; color: var(--text-secondary); line-height: 1.8;
  margin-bottom: 32px;
}
.btn-return-ops {
  background: transparent; border: 1px solid var(--accent-color);
  color: var(--accent-color); border-radius: 6px;
  padding: 10px 24px; font-size: 13px; cursor: pointer;
  transition: background 150ms;
}
.btn-return-ops:hover { background: var(--accent-bg); }

/* ── Traffic Flow Overlay ───────────────────────────────── */
/* Lives inside a Leaflet pane, positioned by L.DomUtil.setPosition so canvas
   pixel (0,0) tracks container pixel (0,0). Never interactive. */
.flow-canvas {
  position: absolute;
  left: 0; top: 0;
  pointer-events: none;
}

/* ── Operator Decision Modal ────────────────────────────── */
#decision-modal-backdrop {
  position: fixed; inset: 0; z-index: 150;
  background: rgba(7,13,26,0.72);
  display: none; align-items: center; justify-content: center;
}
#decision-modal-backdrop.visible {
  display: flex;
  animation: decisionBackdropIn 250ms ease;
}
@keyframes decisionBackdropIn { from { opacity: 0; } to { opacity: 1; } }

#decision-modal {
  position: relative; z-index: 155;
  width: 560px;
  max-width: calc(100vw - 80px);
  max-height: calc(100vh - 80px);
  overflow-y: auto;
  background: var(--panel-bg);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: var(--border-radius-lg);
  box-shadow: 0 24px 64px rgba(0,0,0,0.7);
  animation: decisionModalIn 300ms ease;
}
#decision-modal::-webkit-scrollbar { width: 4px; }
#decision-modal::-webkit-scrollbar-thumb { background: var(--text-muted); border-radius: 2px; }

@keyframes decisionModalIn {
  from { opacity: 0; transform: scale(0.96) translateY(-12px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

.dm-urgency-bar {
  height: 4px;
  border-radius: var(--border-radius-lg) var(--border-radius-lg) 0 0;
}
.dm-urgency-bar.purple { background: var(--intel-purple); }
.dm-urgency-bar.amber  { background: var(--intel-amber); }
.dm-urgency-bar.red    { background: var(--intel-red); }

.dm-header {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 12px 16px 8px;
  border-bottom: 1px solid var(--panel-border);
}
.dm-urgency-icon {
  width: 28px; height: 28px; border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; flex-shrink: 0; margin-top: 1px;
}
.dm-urgency-icon.purple { background: rgba(108,58,158,0.2); }
.dm-urgency-icon.amber  { background: rgba(212,134,10,0.2); }
.dm-urgency-icon.red    { background: rgba(192,57,43,0.2); }

.dm-header-text { flex: 1; }
.dm-title { font-size: 13px; font-weight: 600; color: var(--text-primary); line-height: 1.3; }
.dm-title-ar { font-size: 11px; color: var(--text-muted); font-family: 'Noto Sans Arabic', sans-serif; direction: rtl; margin-top: 2px; }
.dm-id-badge {
  font-size: 9px; font-weight: 700; padding: 2px 6px;
  border-radius: 3px; background: rgba(255,255,255,0.06);
  color: var(--text-muted); letter-spacing: 1px;
  flex-shrink: 0; align-self: flex-start; margin-top: 2px;
}

.dm-situation { padding: 10px 16px; border-bottom: 1px solid var(--panel-border); }
.dm-situation-label { font-size: 9px; font-weight: 600; text-transform: uppercase; letter-spacing: 1px; color: var(--text-muted); margin-bottom: 4px; }
.dm-situation-text { font-size: 12px; color: var(--text-secondary); line-height: 1.5; }
.dm-situation-ar { font-size: 11px; color: var(--text-muted); font-family: 'Noto Sans Arabic', sans-serif; direction: rtl; margin-top: 4px; line-height: 1.5; }

.dm-timeline {
  padding: 7px 16px;
  border-bottom: 1px solid var(--panel-border);
  display: flex; align-items: center; gap: 6px;
  font-size: 11px; color: var(--tier1-color);
}

.dm-options { padding: 10px 12px; display: flex; flex-direction: column; gap: 8px; }

.dm-option {
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--panel-border);
  border-radius: var(--border-radius); padding: 10px 12px;
  cursor: pointer; transition: border-color 150ms, background 150ms;
}
.dm-option:hover {
  border-color: rgba(255,255,255,0.15);
  background: rgba(255,255,255,0.05);
}
.dm-option:active { background: rgba(255,255,255,0.08); }
.dm-option:focus-visible {
  outline: none;
  border-color: var(--tier3-color);
  box-shadow: 0 0 0 2px rgba(10,138,122,0.25);
}
/* The whole card is the click target — the button is a visual affordance
   inside it, so it must not swallow hover feedback from the card. */
.dm-option:hover .dm-option-btn { border-color: var(--text-secondary); color: var(--text-primary); }
.dm-option.dispatching {
  border-color: var(--tier3-color);
  background: rgba(10,138,122,0.08);
  pointer-events: none;
}

.dm-option-row1 { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.dm-option-label {
  width: 22px; height: 22px; background: rgba(255,255,255,0.08);
  border-radius: 4px; display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700; color: var(--text-secondary); flex-shrink: 0;
}
.dm-option-title { font-size: 12px; font-weight: 500; color: var(--text-primary); flex: 1; line-height: 1.3; }
.dm-option-title-ar { font-size: 10px; color: var(--text-muted); font-family: 'Noto Sans Arabic', sans-serif; direction: rtl; margin-bottom: 5px; line-height: 1.4; padding-left: 30px; }

.dm-option-row2 { display: flex; align-items: flex-start; gap: 6px; padding-left: 30px; }
.dm-option-outcome { font-size: 11px; color: var(--text-secondary); flex: 1; line-height: 1.4; }
.dm-proto-badge {
  font-size: 9px; padding: 2px 6px;
  background: var(--tier3-bg); border: 1px solid rgba(10,138,122,0.25);
  color: var(--tier3-color); border-radius: 10px; flex-shrink: 0;
  white-space: nowrap; font-weight: 600;
}

.dm-targets { padding-left: 30px; margin-top: 4px; display: flex; gap: 4px; flex-wrap: wrap; }
.dm-target-tag {
  font-size: 9px; padding: 1px 5px;
  background: rgba(255,255,255,0.04); border: 1px solid var(--panel-border);
  border-radius: 3px; color: var(--text-muted);
}

.dm-option-btn {
  display: block; margin-top: 8px; margin-left: 30px;
  background: none; border: 1px solid var(--panel-border);
  color: var(--text-secondary); border-radius: 5px;
  padding: 4px 10px; font-size: 11px; cursor: pointer;
  transition: all 150ms;
}
.dm-option-btn:hover { border-color: var(--text-secondary); color: var(--text-primary); }

.dm-dispatching-btn {
  display: inline-flex; align-items: center; gap: 5px;
  margin-top: 8px; margin-left: 30px;
  color: var(--tier3-color); font-size: 11px;
}

.dm-spinner {
  width: 11px; height: 11px;
  border: 2px solid rgba(10,138,122,0.3);
  border-top-color: var(--tier3-color);
  border-radius: 50%;
  animation: dmSpin 600ms linear infinite;
  display: inline-block;
}
@keyframes dmSpin { to { transform: rotate(360deg); } }

.dm-footer {
  padding: 8px 16px 12px; border-top: 1px solid var(--panel-border);
  text-align: center;
}
.dm-dismiss {
  background: none; border: none; color: var(--text-muted);
  font-size: 11px; cursor: pointer; text-decoration: underline;
  transition: color 150ms;
}
.dm-dismiss:hover { color: var(--text-secondary); }

/* ── History Modals (Incident + Advisory) ───────────────── */
#incident-history-backdrop,
#advisory-history-backdrop {
  position: fixed; inset: 0; z-index: 150;
  background: rgba(7,13,26,0.78);
  display: none; align-items: center; justify-content: center;
}
#incident-history-backdrop.visible,
#advisory-history-backdrop.visible {
  display: flex;
  animation: decisionBackdropIn 250ms ease;
}
#incident-history-modal,
#advisory-history-modal {
  position: relative; z-index: 155;
  width: 880px;
  max-width: calc(100vw - 80px);
  max-height: calc(100vh - 80px);
  display: flex; flex-direction: column;
  background: var(--panel-bg);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: var(--border-radius-lg);
  box-shadow: 0 24px 64px rgba(0,0,0,0.7);
  animation: decisionModalIn 300ms ease;
  overflow: hidden;
}

.ih-header {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 14px 18px 12px;
  border-bottom: 1px solid var(--panel-border);
  flex-shrink: 0;
}
.ih-header-text { flex: 1; }
.ih-title {
  font-size: 14px; font-weight: 600; color: var(--text-primary);
  letter-spacing: 0.5px;
}
.ih-title-ar {
  font-size: 12px; color: var(--text-muted);
  font-family: 'Noto Sans Arabic', sans-serif; direction: rtl; margin-top: 2px;
}
.ih-summary {
  display: flex; gap: 14px; align-items: center;
  font-size: 11px; color: var(--text-muted); margin-top: 6px;
}
.ih-summary strong { color: var(--text-secondary); font-weight: 600; }
.ih-summary .sep { color: var(--text-muted); opacity: 0.5; }

.ih-close {
  background: none; border: 1px solid var(--panel-border);
  color: var(--text-secondary); border-radius: 5px;
  padding: 5px 12px; font-size: 12px; cursor: pointer;
  flex-shrink: 0; transition: all 150ms;
}
.ih-close:hover {
  border-color: var(--text-secondary); color: var(--text-primary);
  background: rgba(255,255,255,0.04);
}

.ih-body {
  overflow-y: auto;
  flex: 1;
  padding: 0 4px;
}
.ih-body::-webkit-scrollbar { width: 6px; }
.ih-body::-webkit-scrollbar-track { background: transparent; }
.ih-body::-webkit-scrollbar-thumb { background: var(--text-muted); border-radius: 3px; }

.ih-empty {
  padding: 40px 18px; text-align: center;
  color: var(--text-muted); font-size: 12px;
}

.ih-row {
  display: grid;
  grid-template-columns: 70px 70px 120px 1fr 90px 80px;
  gap: 10px; align-items: start;
  padding: 10px 14px;
  border-bottom: 1px solid var(--panel-border);
  font-size: 12px;
}
.ih-row.head {
  position: sticky; top: 0; z-index: 1;
  background: rgba(13,21,38,0.95);
  backdrop-filter: blur(6px);
  font-size: 9px; font-weight: 700; letter-spacing: 1px;
  text-transform: uppercase; color: var(--text-muted);
  padding-top: 8px; padding-bottom: 8px;
}
.ih-row:not(.head):hover { background: rgba(255,255,255,0.025); }

.ih-sev {
  border-radius: 3px; padding: 2px 6px; font-size: 9px; font-weight: 700;
  text-transform: uppercase; text-align: center;
  align-self: start; justify-self: start;
}
.ih-sev.high   { background: rgba(192,57,43,0.2); color: #E74C3C; }
.ih-sev.medium { background: rgba(211,84,0,0.2);  color: #E67E22; }
.ih-sev.low    { background: rgba(90,100,114,0.2);color: var(--text-secondary); }

.ih-state {
  border-radius: 3px; padding: 2px 6px; font-size: 9px; font-weight: 700;
  text-transform: uppercase; text-align: center;
  align-self: start; justify-self: start;
}
.ih-state.active   { background: rgba(212,134,10,0.18); color: var(--intel-amber); }
.ih-state.resolved { background: rgba(10,138,122,0.15); color: var(--tier3-color); }

.ih-type { color: var(--text-primary); font-weight: 500; }
.ih-type-ar {
  font-size: 10px; color: var(--text-muted);
  font-family: 'Noto Sans Arabic', sans-serif; direction: rtl; margin-top: 2px;
}

.ih-location { color: var(--text-secondary); line-height: 1.4; }
.ih-status   { color: var(--text-muted); font-size: 11px; margin-top: 3px; line-height: 1.4; }

.ih-time {
  color: var(--text-secondary); font-size: 11px; font-variant-numeric: tabular-nums;
}
.ih-time-label {
  font-size: 9px; color: var(--text-muted); text-transform: uppercase;
  letter-spacing: 0.5px; margin-bottom: 1px;
}
.ih-time-val { color: var(--text-secondary); }
.ih-time-val.resolved { color: var(--tier3-color); }

.ih-duration {
  color: var(--text-secondary); font-variant-numeric: tabular-nums;
  text-align: right;
}

.ih-footer {
  padding: 8px 18px; border-top: 1px solid var(--panel-border);
  font-size: 10px; color: var(--text-muted); text-align: center;
  flex-shrink: 0;
}

/* Advisory history row layout */
.ah-row {
  display: grid;
  grid-template-columns: 64px 50px 1fr;
  gap: 12px; align-items: start;
  padding: 10px 14px;
  border-bottom: 1px solid var(--panel-border);
  font-size: 12px;
}
.ah-row.head {
  position: sticky; top: 0; z-index: 1;
  background: rgba(13,21,38,0.95);
  backdrop-filter: blur(6px);
  font-size: 9px; font-weight: 700; letter-spacing: 1px;
  text-transform: uppercase; color: var(--text-muted);
  padding-top: 8px; padding-bottom: 8px;
}
.ah-row:not(.head):hover { background: rgba(255,255,255,0.025); }

.ah-time {
  color: var(--text-secondary); font-size: 11px;
  font-variant-numeric: tabular-nums;
}
.ah-row .adv-tier {
  border-radius: 3px; padding: 2px 6px; font-size: 10px; font-weight: 700;
  text-align: center; justify-self: start; align-self: start;
}
.ah-body-col { min-width: 0; }
.ah-text { color: var(--text-primary); line-height: 1.45; }
.ah-meta {
  font-size: 10px; color: var(--text-muted);
  margin-top: 3px; letter-spacing: 0.3px;
}

/* ── LIVE Data Indicator ─────────────────────────────────── */
.live-indicator {
  position: relative;
  display: flex; align-items: center; gap: 6px;
  font-size: 11px; color: var(--text-secondary);
  letter-spacing: 0.5px;
  padding: 4px 8px; border-radius: 6px;
  border: 1px solid var(--panel-border);
  cursor: default;
}
.live-feed-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: #5A6472;
}
.live-tooltip {
  display: none;
  position: absolute; top: calc(100% + 8px); right: 0;
  width: 260px; z-index: 400;
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: var(--border-radius);
  padding: 10px 12px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.5);
}
.live-indicator:hover .live-tooltip { display: block; }
.lt-row {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 11px; color: var(--text-secondary);
  padding: 3px 0;
}
.lt-status { font-size: 10px; }

/* ── Map Footer Attribution ──────────────────────────────── */
.map-footer {
  position: absolute; left: 8px; bottom: 8px; z-index: 10;
  display: flex; gap: 14px;
  font-size: 9px; color: var(--text-muted);
  background: rgba(13,21,38,0.75); backdrop-filter: blur(4px);
  padding: 3px 8px; border-radius: 4px;
  pointer-events: none;
}

/* ── Dust Alert Ticker Badge ─────────────────────────────── */
.dust-alert-badge {
  flex-shrink: 0;
  background: rgba(212,134,10,0.18); color: var(--intel-amber);
  border-right: 1px solid var(--panel-border);
  font-size: 10px; font-weight: 600; letter-spacing: 0.5px;
  padding: 0 10px; height: 100%;
  display: flex; align-items: center;
  z-index: 2;
}

/* ── Live Incident Badge ─────────────────────────────────── */
.inc-live-badge {
  color: #27AE60; font-size: 9px; font-weight: 700; letter-spacing: 0.5px;
}

/* ── RCRC name line in intersection popup ────────────────── */
.lf-popup-rcrc {
  font-size: 10px; color: var(--text-muted);
  margin: 2px 0 4px;
}

/* ── Situation Briefing Overlay ──────────────────────────── */
#briefing-overlay {
  position: fixed; inset: 0; z-index: 260;
  display: none;
  align-items: flex-start; justify-content: center;
  background: rgba(7,13,26,0.55);
}
#briefing-overlay.visible { display: flex; }
#briefing-card {
  margin-top: 80px;
  width: min(560px, calc(100vw - 120px));
  background: var(--panel-bg);
  border: 1px solid var(--accent-color);
  border-radius: var(--border-radius-lg);
  padding: 20px 24px;
  box-shadow: 0 16px 48px rgba(0,0,0,0.6);
  animation: briefingSlide 300ms ease;
}
@keyframes briefingSlide {
  from { opacity: 0; transform: translateY(-16px); }
  to   { opacity: 1; transform: translateY(0); }
}
.briefing-title {
  font-size: 13px; font-weight: 600; color: var(--accent-color);
  letter-spacing: 0.5px; margin-bottom: 10px;
}
#briefing-text {
  font-size: 13px; line-height: 1.6; color: var(--text-primary);
}
.briefing-hint {
  margin-top: 12px; font-size: 10px; color: var(--text-muted);
}

/* ── Mesh power-on (B1) ──────────────────────────────────── */
/* The demo boots with body.mesh-off: everything except the header
   toggle is dimmed + frozen. powerOnMesh() swaps to .mesh-powering
   and stages add .powered region by region; .mesh-on unlocks all.
   Dimming uses opacity/filter only — never display — so Leaflet
   sizing is unaffected. */

.mesh-toggle {
  display: flex; align-items: center; gap: 8px;
  background: none;
  border: 1px solid var(--panel-border); border-radius: 20px;
  padding: 5px 12px; cursor: pointer;
  color: var(--text-secondary); font-size: 11px;
}
.mesh-toggle-label { font-size: 11px; }
.mesh-toggle-track {
  position: relative; width: 30px; height: 14px;
  border-radius: 7px;
  background: rgba(255,255,255,0.08);
  border: 1px solid var(--panel-border);
  transition: background 300ms, border-color 300ms;
}
.mesh-toggle-knob {
  position: absolute; top: 1px; left: 1px;
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--text-muted);
  transition: left 300ms ease, background 300ms;
}
.mesh-toggle[aria-pressed="true"] .mesh-toggle-track { background: var(--accent-bg); border-color: var(--accent-color); }
.mesh-toggle[aria-pressed="true"] .mesh-toggle-knob { left: 17px; background: var(--accent-color); }
.mesh-toggle:disabled { cursor: default; }
body.mesh-off .mesh-toggle {
  border-color: var(--accent-color); color: var(--accent-color);
  animation: meshTogglePulse 1.8s ease-in-out infinite;
}
@keyframes meshTogglePulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(201,168,76,0); }
  50%      { box-shadow: 0 0 12px 2px var(--accent-bg); }
}

/* Dimmed regions while off / not yet powered */
body.mesh-off #header > :not(#mesh-toggle),
body.mesh-powering #header:not(.powered) > :not(#mesh-toggle),
body.mesh-off #systems-bar,        body.mesh-powering #systems-bar:not(.powered),
body.mesh-off #map-panel,          body.mesh-powering #map-panel:not(.powered),
body.mesh-off #impact-strip,       body.mesh-powering #impact-strip:not(.powered),
body.mesh-off #metrics-strip,      body.mesh-powering #metrics-strip:not(.powered),
body.mesh-off #advisory-section,   body.mesh-powering #advisory-section:not(.powered),
body.mesh-off #incident-section,   body.mesh-powering #incident-section:not(.powered),
body.mesh-off #intel-section,      body.mesh-powering #intel-section:not(.powered),
body.mesh-off #activity-strip,
body.mesh-off #ledger-overlay {
  opacity: 0.35;
  filter: saturate(0.15) brightness(0.65);
}
body.mesh-powering #header > :not(#mesh-toggle),
body.mesh-powering #systems-bar,
body.mesh-powering #map-panel,
body.mesh-powering #impact-strip,
body.mesh-powering #metrics-strip,
body.mesh-powering #advisory-section,
body.mesh-powering #incident-section,
body.mesh-powering #intel-section,
body.mesh-powering #activity-strip,
body.mesh-powering #ledger-overlay {
  transition: opacity 700ms ease, filter 700ms ease;
}

/* Interaction freeze — the toggle is the only live element. The JS
   delegation gate is the source of truth; this covers hover/cursor
   affordances and non-delegated handlers (map drag, strip hover). */
body.mesh-off #app, body.mesh-powering #app,
body.mesh-off #activity-strip, body.mesh-powering #activity-strip { pointer-events: none; }
body.mesh-off #mesh-toggle, body.mesh-powering #mesh-toggle { pointer-events: auto; }

/* Ticker frozen until the feeds stage */
body.mesh-off .ticker-track,
body.mesh-powering #map-ticker:not(.powered) .ticker-track { animation-play-state: paused; }

/* Systems bar entries wake staggered when their stage lands */
body.mesh-powering #systems-bar.powered .sys-entry { animation: sysWake 400ms ease backwards; }
body.mesh-powering #systems-bar.powered .sys-entry:nth-child(1) { animation-delay: 0ms; }
body.mesh-powering #systems-bar.powered .sys-entry:nth-child(2) { animation-delay: 80ms; }
body.mesh-powering #systems-bar.powered .sys-entry:nth-child(3) { animation-delay: 160ms; }
body.mesh-powering #systems-bar.powered .sys-entry:nth-child(4) { animation-delay: 240ms; }
body.mesh-powering #systems-bar.powered .sys-entry:nth-child(5) { animation-delay: 320ms; }
body.mesh-powering #systems-bar.powered .sys-entry:nth-child(6) { animation-delay: 400ms; }
@keyframes sysWake {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Ghost skeletons — pure CSS shapes, no pool text, never .intel-card */
.ghost-card {
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: var(--border-radius);
  padding: 12px 10px;
  display: flex; flex-direction: column; gap: 9px;
}
.ghost-line, .ghost-row {
  height: 8px; border-radius: 4px;
  background: linear-gradient(90deg,
    rgba(255,255,255,0.04) 25%,
    rgba(255,255,255,0.09) 50%,
    rgba(255,255,255,0.04) 75%);
  background-size: 200% 100%;
  animation: ghostShimmer 1.6s linear infinite;
}
.ghost-line.w60 { width: 60%; }
.ghost-line.w75 { width: 75%; }
.ghost-line.w90 { width: 90%; }
.ghost-row { height: 18px; margin: 4px 0; }
@keyframes ghostShimmer {
  from { background-position: 200% 0; }
  to   { background-position: -200% 0; }
}
.ghost-fading { opacity: 0 !important; transition: opacity 400ms ease; }

/* ── Insight Story Replay (B2) ───────────────────────────── */
/* z-index 200 band: popover 200 < replay 205/210 < exec view 250 */
#replay-backdrop {
  position: fixed; inset: 0; z-index: 205;
  background: var(--overlay-bg);
  display: none;
  align-items: center; justify-content: center;
}
#replay-backdrop.visible { display: flex; }
#replay-panel {
  position: relative; z-index: 210;
  width: 720px; max-width: 92vw; max-height: 88vh;
  overflow-y: auto;
  background: #12203A;
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: var(--border-radius-lg);
  box-shadow: 0 16px 48px rgba(0,0,0,0.6);
  animation: popoverIn 200ms ease;
}
.replay-accent-bar { height: 3px; }
#replay-panel[data-type="teal"]   .replay-accent-bar { background: var(--intel-teal); }
#replay-panel[data-type="amber"]  .replay-accent-bar { background: var(--intel-amber); }
#replay-panel[data-type="red"]    .replay-accent-bar { background: var(--intel-red); }
#replay-panel[data-type="purple"] .replay-accent-bar { background: var(--intel-purple); }
#replay-panel[data-type="gray"]   .replay-accent-bar { background: var(--intel-gray); }

.replay-header { display: flex; align-items: flex-start; gap: 10px; padding: 14px 16px 6px; }
.replay-titles { flex: 1; }
.replay-title { font-size: 14px; font-weight: 600; }
.replay-title-ar { font-size: 11px; color: var(--text-muted); font-family: 'Noto Sans Arabic', sans-serif; text-align: left; }
.replay-id-badge {
  font-size: 10px; color: var(--text-muted);
  border: 1px solid var(--panel-border); border-radius: 10px;
  padding: 2px 8px; margin-top: 2px;
  font-variant-numeric: tabular-nums;
}
.replay-close {
  background: none; border: none;
  color: var(--text-muted); font-size: 14px;
  cursor: pointer; padding: 2px 6px;
}
.replay-close:hover { color: var(--text-primary); }
.replay-headline { padding: 0 16px 8px; font-size: 13px; font-weight: 500; line-height: 1.4; }

#replay-graph { padding: 4px 16px; }
#replay-graph svg { width: 100%; height: auto; display: block; }
.replay-node { opacity: 0.25; transition: opacity 250ms ease; }
.replay-node.lit { opacity: 1; }
.replay-edge {
  stroke: rgba(255,255,255,0.25); stroke-width: 1.5; fill: none;
  transition: stroke-dashoffset 400ms ease, stroke 250ms;
}
.replay-edge.drawn { stroke-dashoffset: 0 !important; stroke: rgba(255,255,255,0.5); }

.replay-detail {
  padding: 8px 16px 10px;
  font-size: 11px; color: var(--text-secondary); line-height: 1.55;
  border-top: 1px solid var(--panel-border);
}
.replay-detail-text { margin-bottom: 6px; }
.replay-action-label {
  font-size: 9px; color: var(--tier3-color); font-weight: 600;
  text-transform: uppercase; margin-right: 6px;
}

.replay-timeline { padding: 8px 16px 4px; border-top: 1px solid var(--panel-border); }
.replay-track {
  position: relative; height: 6px; border-radius: 3px;
  background: rgba(255,255,255,0.06);
  margin: 10px 0 12px;
}
#replay-progress {
  position: absolute; left: 0; top: 0; bottom: 0;
  width: 0; border-radius: 3px;
  background: var(--accent-color);
}
#replay-ticks { position: absolute; inset: 0; }
.replay-tick {
  position: absolute; top: -3px;
  width: 2px; height: 12px; border-radius: 1px;
  background: var(--text-muted); opacity: 0.5;
  transition: opacity 200ms, background 200ms;
}
.replay-tick.lit { opacity: 1; }
.replay-tick.t1.lit { background: var(--tier1-color); }
.replay-tick.t2.lit { background: var(--tier2-color); }
.replay-tick.t3.lit { background: var(--tier3-color); }
#replay-steps { display: flex; flex-direction: column; gap: 3px; max-height: 150px; overflow-y: auto; }
.replay-step {
  display: flex; align-items: center; gap: 8px;
  font-size: 11px; color: var(--text-muted);
  opacity: 0.45;
  transition: opacity 200ms, color 200ms;
}
.replay-step.lit { opacity: 1; color: var(--text-primary); }
.replay-step-label { flex: 1; }
.replay-step-latency { font-variant-numeric: tabular-nums; color: var(--text-secondary); }
.replay-footer { display: flex; align-items: center; gap: 10px; padding: 10px 16px 14px; }
.replay-span { flex: 1; font-size: 10px; color: var(--text-muted); font-variant-numeric: tabular-nums; }

/* ── Compliance Ledger (B7) ──────────────────────────────── */
#ledger-overlay {
  position: fixed; inset: 0; z-index: 202;
  background: rgba(7,13,26,0.93);
  display: none; flex-direction: column;
  padding: 24px 32px 20px;
  box-sizing: border-box;
}
#ledger-overlay.visible { display: flex; }

.ledger-header {
  display: flex; align-items: center; gap: 16px;
  flex-shrink: 0;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--panel-border);
  margin-bottom: 14px;
}
.ledger-title-wrap { flex: 1; min-width: 0; }
.ledger-title {
  font-size: 15px; font-weight: 600; letter-spacing: 0.04em;
  color: var(--text-primary);
}
.ledger-filters { display: flex; gap: 6px; flex-shrink: 0; }
.ledger-filter-pill {
  padding: 4px 12px; border-radius: 12px; border: 1px solid var(--panel-border);
  background: transparent; color: var(--text-muted); font-size: 11px;
  cursor: pointer; transition: background 150ms, color 150ms, border-color 150ms;
}
.ledger-filter-pill:hover { border-color: var(--accent-color); color: var(--accent-color); }
.ledger-filter-pill.active {
  background: var(--accent-bg); border-color: var(--accent-color);
  color: var(--accent-color);
}
.ledger-close {
  background: transparent; border: 1px solid var(--panel-border);
  color: var(--text-muted); font-size: 18px; line-height: 1;
  width: 30px; height: 30px; border-radius: 6px;
  cursor: pointer; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  transition: border-color 150ms, color 150ms;
}
.ledger-close:hover { border-color: var(--text-secondary); color: var(--text-primary); }

.ledger-table-wrap {
  flex: 1; overflow-y: auto; min-height: 0;
  border: 1px solid var(--panel-border); border-radius: var(--border-radius);
}
.ledger-table {
  width: 100%; border-collapse: collapse;
  font-family: 'Courier New', Courier, monospace; font-size: 11px;
  color: var(--text-secondary);
}
.ledger-table thead th {
  position: sticky; top: 0; z-index: 1;
  background: var(--panel-bg); color: var(--text-muted);
  font-weight: 600; font-size: 10px; letter-spacing: 0.06em;
  text-transform: uppercase; text-align: left;
  padding: 8px 12px; border-bottom: 1px solid var(--panel-border);
}
.ledger-table tbody tr {
  border-bottom: 1px solid rgba(255,255,255,0.04);
  transition: background 120ms;
}
.ledger-table tbody tr:hover { background: rgba(255,255,255,0.03); }
.ledger-table td {
  padding: 5px 12px; vertical-align: middle; white-space: nowrap;
}
.ledger-table td:nth-child(2) { white-space: normal; max-width: 200px; }
.ledger-table td:nth-child(6) { white-space: normal; max-width: 220px; }
.ledger-tier-t1 { color: var(--tier1-color); font-weight: 600; }
.ledger-tier-t2 { color: var(--tier2-color); font-weight: 600; }
.ledger-tier-t3 { color: var(--tier3-color); font-weight: 600; }
.ledger-tier-op { color: var(--text-muted); }
.ledger-outcome-dispatched { color: var(--tier2-color); }
.ledger-outcome-acknowledged { color: var(--tier1-color); }
.ledger-outcome-operator { color: var(--accent-color); }

/* ── Session menu dropdown (B6) ──────────────────────────── */
.session-menu-wrap {
  position: relative; flex-shrink: 0;
}
.session-dropdown {
  position: absolute; top: calc(100% + 6px); right: 0;
  background: var(--panel-bg); border: 1px solid var(--panel-border);
  border-radius: var(--border-radius); min-width: 220px;
  z-index: 201; box-shadow: 0 8px 24px rgba(0,0,0,0.5);
  overflow: hidden;
}
.session-dropdown[hidden] { display: none; }
.session-menu-item {
  display: block; width: 100%;
  padding: 10px 16px; text-align: left;
  background: transparent; border: none;
  color: var(--text-primary); font-size: 12px; cursor: pointer;
  transition: background 120ms;
}
.session-menu-item:hover:not(:disabled) { background: rgba(255,255,255,0.06); }
.session-menu-item:disabled,
.session-menu-item--disabled {
  color: var(--text-muted); cursor: default;
}

/* ── Reduced motion ──────────────────────────────────────── */
/* Choreography stage timings and the anomaly schedule are fixed
   constants in JS — only the cosmetic motion collapses here. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
