:root {
  --bg: #0b0d12;
  --panel: #141821;
  --panel2: #1a1f2b;
  --border: #242b3a;
  --text: #dbe1ea;
  --muted: #8b93a5;
  --accent: #4f8cff;
  --jarvis: #00e5ff;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  line-height: 1.5;
}
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 20px; border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, #10131a, #0b0d12);
  position: sticky; top: 0; z-index: 1000;
}
.brand { display: flex; align-items: center; gap: 10px; }
.dot { width: 12px; height: 12px; border-radius: 50%; background: #2ecc71; box-shadow: 0 0 12px #2ecc71; animation: pulse 2s infinite; }
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:.4} }
.brand-name { font-weight: 800; letter-spacing: 2px; font-size: 18px; }
.brand-sub { color: var(--muted); font-size: 13px; }
.top-right { display: flex; align-items: center; gap: 12px; }
.live-tag { color: #2ecc71; font-size: 12px; font-weight: 700; letter-spacing: 1px; }
.updated { color: var(--muted); font-size: 12px; }
.btn { background: var(--accent); color: #fff; border: none; padding: 7px 14px; border-radius: 6px; cursor: pointer; font-size: 13px; font-weight: 600; }
.btn:hover { filter: brightness(1.1); }
.btn.ghost { background: var(--panel2); border: 1px solid var(--border); color: var(--text); }

/* Ticker */
.ticker { display: flex; align-items: stretch; border-bottom: 1px solid var(--border); background: #0e1117; overflow: hidden; }
.ticker-label { flex: 0 0 auto; background: #e74c3c; color: #fff; font-weight: 800; font-size: 11px; letter-spacing: 1px; padding: 6px 12px; display: flex; align-items: center; }
.ticker-window { flex: 1 1 auto; overflow: hidden; position: relative; }
.ticker-track { display: inline-block; white-space: nowrap; padding: 6px 0; font-size: 13px; color: var(--text); animation: ticker 60s linear infinite; }
.ticker-track a { color: var(--text); text-decoration: none; margin-right: 40px; }
.ticker-track a:hover { color: var(--accent); }
@keyframes ticker { 0% { transform: translateX(0); } 100% { transform: translateX(-50%); } }

/* Map */
.map-wrap { position: relative; height: 62vh; min-height: 420px; border-bottom: 1px solid var(--border); }
#map { position: absolute; inset: 0; background: #0b0d12; z-index: 1; }
.map-legend {
  position: absolute; top: 14px; right: 14px; z-index: 500;
  background: rgba(11,13,18,.92); border: 1px solid var(--border); border-radius: 8px;
  padding: 10px 14px; font-size: 12px; line-height: 1.9; backdrop-filter: blur(4px);
}
.legend-title { font-weight: 700; letter-spacing: 1px; margin-bottom: 4px; color: var(--muted); text-transform: uppercase; font-size: 10px; }
.swatch { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; }
.legend-note { color: var(--muted); font-size: 10px; margin-top: 6px; max-width: 220px; }
.map-stats { position: absolute; bottom: 14px; left: 14px; z-index: 500; display: flex; gap: 10px; }
.map-stat { background: rgba(11,13,18,.92); border: 1px solid var(--border); border-radius: 6px; padding: 6px 12px; font-size: 12px; color: var(--muted); backdrop-filter: blur(4px); }
.map-stat span { color: var(--text); font-weight: 700; font-size: 16px; }

/* Leaflet dark override */
.leaflet-container { background: #0b0d12 !important; }
.leaflet-tile-pane { filter: brightness(.62) contrast(1.12) saturate(.7); }
.leaflet-popup-content-wrapper, .leaflet-popup-tip { background: #141821; color: var(--text); border: 1px solid var(--border); }
.leaflet-popup-content { font-size: 12px; }
.leaflet-popup-content b { display: block; margin-bottom: 2px; font-size: 13px; }
.leaflet-control-zoom a { background: #141821 !important; color: var(--text) !important; border-color: var(--border) !important; }

/* Layout */
.wrap { max-width: 1180px; margin: 24px auto; padding: 0 20px; display: grid; grid-template-columns: repeat(2, 1fr); gap: 18px; }
.card { background: var(--panel); border: 1px solid var(--border); border-radius: 10px; padding: 20px; }
.card.wide { grid-column: 1 / -1; }
h2 { margin: 0 0 14px; font-size: 15px; letter-spacing: .5px; color: var(--muted); text-transform: uppercase; }

/* Gauge */
.gauge-wrap { position: relative; width: 220px; margin: 0 auto; }
.gauge { width: 100%; height: auto; display: block; }
.gauge-value { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.index-num { font-size: 46px; font-weight: 800; }
.index-level { font-size: 13px; letter-spacing: 2px; font-weight: 700; }
.blurb { text-align: center; color: var(--muted); font-size: 13px; margin: 10px 0 4px; }
.scale { display: flex; justify-content: space-between; font-size: 10px; letter-spacing: .5px; margin-top: 8px; }

/* components */
.components { display: flex; flex-direction: column; gap: 12px; }
.comp { display: grid; grid-template-columns: 150px 1fr 44px; align-items: center; gap: 10px; }
.comp-label { font-size: 13px; color: var(--muted); }
.comp-val { font-size: 13px; text-align: right; font-weight: 600; }
.bar { background: var(--panel2); height: 10px; border-radius: 5px; overflow: hidden; }
.fill { height: 100%; width: 0; background: var(--accent); border-radius: 5px; transition: width .6s ease; }
.kw-hits { margin-top: 14px; }
.kw-hits .tag { display: inline-block; background: var(--panel2); border: 1px solid var(--border); border-radius: 12px; padding: 2px 9px; font-size: 11px; margin: 2px 3px; color: var(--muted); }

/* history */
.history { width: 100%; height: 220px; }

/* flights */
.stat-line { display: flex; justify-content: space-between; padding: 6px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
.stat-line span { color: var(--muted); }
.countries { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0; }
.countries .tag { background: var(--panel2); border: 1px solid var(--border); border-radius: 4px; padding: 2px 8px; font-size: 11px; }
.flights { margin-top: 10px; max-height: 260px; overflow-y: auto; }
.flight { font-size: 12px; padding: 4px 0; border-bottom: 1px solid var(--border); font-family: monospace; }

/* carriers */
.carriers { display: flex; flex-direction: column; gap: 6px; max-height: 300px; overflow-y: auto; }
.carrier { padding: 8px 10px; background: var(--panel2); border-radius: 6px; font-size: 13px; border: 1px solid var(--border); }
.carrier .c-name { font-weight: 700; }
.carrier .c-meta { color: var(--muted); font-size: 12px; }

/* news */
.news, .gdelt { display: flex; flex-direction: column; }
.news-item, .gdelt-item { padding: 9px 0; border-bottom: 1px solid var(--border); }
.news-item a, .gdelt-item a { color: var(--text); text-decoration: none; font-size: 14px; }
.news-item a:hover, .gdelt-item a:hover { color: var(--accent); }
.news-meta, .gdelt-meta { color: var(--muted); font-size: 12px; margin-top: 2px; }

/* gfp */
.gfp { width: 100%; border-collapse: collapse; font-size: 13px; }
.gfp th, .gfp td { padding: 8px 10px; text-align: left; border-bottom: 1px solid var(--border); }
.gfp th { color: var(--muted); }
.gfp-note, .disclaimer { color: var(--muted); font-size: 12px; margin: 10px 0 0; }
.disclaimer { text-align: center; max-width: 900px; margin: 0 auto 30px; padding: 0 20px; }

/* JARVIS */
.jarvis-orb {
  position: fixed; right: 22px; bottom: 22px; z-index: 1100;
  width: 60px; height: 60px; border-radius: 50%; border: none; cursor: pointer;
  background: radial-gradient(circle at 35% 30%, #7ff3ff, #00b8d4 60%, #006b7f);
  color: #003; font-size: 26px; box-shadow: 0 0 22px rgba(0,229,255,.55);
  transition: transform .2s;
}
.jarvis-orb:hover { transform: scale(1.08); }
.jarvis-panel {
  position: fixed; right: 22px; bottom: 92px; z-index: 1100;
  width: 360px; max-width: calc(100vw - 44px); max-height: 70vh;
  background: #0d1117; border: 1px solid var(--border); border-radius: 14px;
  display: flex; flex-direction: column; box-shadow: 0 12px 40px rgba(0,0,0,.6);
}
.jarvis-panel.hidden { display: none; }
.jarvis-head { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-bottom: 1px solid var(--border); }
.jarvis-avatar { font-size: 22px; color: var(--jarvis); }
.jarvis-name { font-weight: 800; letter-spacing: 1px; color: var(--jarvis); }
.jarvis-status { font-size: 11px; color: var(--muted); }
.jarvis-close { margin-left: auto; background: none; border: none; color: var(--muted); font-size: 16px; cursor: pointer; }
.jarvis-close:hover { color: #fff; }
.jarvis-log { flex: 1 1 auto; overflow-y: auto; padding: 12px 14px; font-size: 13px; display: flex; flex-direction: column; gap: 8px; max-height: 320px; }
.j-line { padding: 8px 10px; border-radius: 8px; max-width: 88%; }
.j-line.user { align-self: flex-end; background: var(--panel2); border: 1px solid var(--border); }
.j-line.jarvis { align-self: flex-start; background: rgba(0,229,255,.08); border: 1px solid rgba(0,229,255,.25); color: #c9f6ff; }
.jarvis-form { display: flex; border-top: 1px solid var(--border); }
.jarvis-form input { flex: 1; background: none; border: none; padding: 12px 14px; color: var(--text); font-size: 13px; outline: none; }
.jarvis-form button { background: none; border: none; color: var(--jarvis); font-size: 16px; padding: 0 14px; cursor: pointer; }

@media (max-width: 760px) {
  .wrap { grid-template-columns: 1fr; }
  .comp { grid-template-columns: 110px 1fr 40px; }
  .map-wrap { height: 50vh; }
}
