:root {
  color-scheme: dark;
  --page: #0b0d10;
  --surface-1: #14171c;
  --surface-2: #1b1f26;
  --surface-3: #232833;
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.16);
  --text-primary: #eceef1;
  --text-secondary: #9aa1ab;
  --text-tertiary: #6b727d;
  --grid: #262b33;
  --axis: #3a404a;

  /* categorical — validated (dark, surface #14171c) */
  --cat-cyber: #338ced;
  --cat-aviation: #e76624;
  --cat-cloud: #00a888;
  --cat-power: #d28e05;
  --cat-telecom: #e24d8b;
  --cat-rail: #0aac23;

  /* status — reserved */
  --critical: #dc3c3d;
  --warning: #fbb315;
  --good: #0aac23;

  --radius: 10px;
  --font: system-ui, -apple-system, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--page);
  color: var(--text-primary);
  font: 14px/1.45 var(--font);
  display: grid;
  grid-template-rows: auto auto auto minmax(420px, 1fr) auto auto;
  min-height: 100vh;
}
h1, h2, h3 { margin: 0; font-weight: 600; }
h2 { font-size: 13px; letter-spacing: 0.02em; color: var(--text-primary); }
a { color: #7fb6f5; text-decoration: none; }
a:hover { text-decoration: underline; }
.muted { color: var(--text-secondary); font-size: 12px; }
.count { color: var(--text-secondary); font-weight: 500; margin-left: 4px; font-variant-numeric: tabular-nums; }

/* ---------- header ---------- */
.top {
  display: flex; align-items: center; gap: 24px;
  padding: 14px 20px; border-bottom: 1px solid var(--border); background: var(--surface-1);
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand h1 { font-size: 17px; letter-spacing: 0.01em; }
.brand .sub { margin: 0; color: var(--text-secondary); font-size: 12px; }
.brand-mark {
  width: 28px; height: 28px; border-radius: 8px;
  background: radial-gradient(circle at 50% 50%, var(--critical) 0 4px, transparent 5px),
              radial-gradient(circle at 50% 50%, transparent 0 8px, rgba(220,60,61,.45) 9px 10px, transparent 11px),
              var(--surface-3);
  border: 1px solid var(--border-strong);
}
.regions { display: flex; background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; padding: 3px; }
.regions button {
  background: none; border: 0; color: var(--text-secondary); font: inherit; font-size: 13px;
  padding: 5px 14px; border-radius: 6px; cursor: pointer;
}
.regions button[aria-selected="true"] { background: var(--surface-3); color: var(--text-primary); }
.status { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.pill { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; padding: 4px 10px; border-radius: 999px; border: 1px solid var(--border-strong); }
.pill .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--text-tertiary); }
.pill-live.on .dot { background: var(--good); box-shadow: 0 0 0 0 rgba(10,172,35,.6); animation: pulse 2s infinite; }
.pill-live.err .dot { background: var(--warning); }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(10,172,35,.55); } 70% { box-shadow: 0 0 0 7px rgba(10,172,35,0); } 100% { box-shadow: 0 0 0 0 rgba(10,172,35,0); } }

/* ---------- KPIs ---------- */
.kpis { display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; padding: 14px 20px 0; }
.kpi { background: var(--surface-1); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px;
  text-align: left; font: inherit; color: inherit; cursor: pointer; transition: border-color .12s, background .12s; }
.kpi:hover { border-color: var(--border-strong); background: var(--surface-2); }
.kpi.on { border-color: rgba(127,182,245,.6); background: var(--surface-2); box-shadow: inset 0 0 0 1px rgba(127,182,245,.25); }
.kpi:focus-visible { outline: 2px solid #7fb6f5; outline-offset: 2px; }
.kpi .label { color: var(--text-secondary); font-size: 12px; display: flex; justify-content: space-between; gap: 8px; }
.kpi .value { font-size: 24px; font-weight: 600; margin-top: 4px; letter-spacing: -0.01em; }
.kpi .value small { font-size: 14px; color: var(--text-secondary); font-weight: 500; }
.kpi .hint { color: var(--text-tertiary); font-size: 11.5px; margin-top: 2px; }

.badge { display: inline-block; font-size: 10.5px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; padding: 1px 6px; border-radius: 4px; border: 1px solid; white-space: nowrap; }
.badge.reported { color: #9fd0a8; border-color: rgba(159,208,168,.35); }
.badge.estimated { color: #f0c36b; border-color: rgba(240,195,107,.35); }
.badge.modeled { color: #b7a8f5; border-color: rgba(183,168,245,.35); }
.badge.unknown { color: var(--text-tertiary); border-color: var(--border-strong); }

/* ---------- filters ---------- */
.filters { display: flex; align-items: center; gap: 16px; padding: 12px 20px; flex-wrap: wrap; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; font: inherit; font-size: 12.5px; cursor: pointer;
  background: var(--surface-1); color: var(--text-primary); border: 1px solid var(--border-strong);
  padding: 4px 10px 4px 5px; border-radius: 999px;
}
.chip[aria-pressed="false"] { color: var(--text-tertiary); background: transparent; }
.chip[aria-pressed="false"] .icon { background: var(--surface-3) !important; }
.chip .n { color: var(--text-secondary); font-variant-numeric: tabular-nums; }
.filter-right { margin-left: auto; display: flex; gap: 14px; align-items: center; color: var(--text-secondary); font-size: 12.5px; }
.filter-right select {
  margin-left: 6px; background: var(--surface-1); color: var(--text-primary); border: 1px solid var(--border-strong);
  border-radius: 6px; padding: 4px 6px; font: inherit;
}
.toggle { display: flex; align-items: center; gap: 6px; cursor: pointer; }

.icon { display: inline-grid; place-items: center; width: 20px; height: 20px; border-radius: 50%; flex: none; }
.icon svg { width: 12px; height: 12px; fill: #fff; }
.icon.power svg { fill: #0b0b0b; }

/* ---------- main ---------- */
.main { display: grid; grid-template-columns: 1fr 400px; gap: 12px; padding: 0 20px; min-height: 0; }
.map-wrap { position: relative; border-radius: var(--radius); overflow: hidden; border: 1px solid var(--border); min-height: 420px; }
#map { position: absolute; inset: 0; background: #0e1014; }
.leaflet-container { font-family: var(--font); }
.leaflet-control-attribution { background: rgba(20,23,28,.8) !important; color: var(--text-tertiary) !important; font-size: 10px; }
.leaflet-control-attribution a { color: var(--text-secondary) !important; }
.leaflet-bar a { background: var(--surface-2); color: var(--text-primary); border-color: var(--border) !important; }
.leaflet-bar a:hover { background: var(--surface-3); }

.map-legend {
  position: absolute; left: 12px; bottom: 12px; z-index: 500; background: rgba(20,23,28,.92);
  border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; font-size: 11.5px; color: var(--text-secondary);
  display: grid; gap: 5px;
}
.map-legend .row { display: flex; align-items: center; gap: 8px; }
.map-legend .ring { width: 14px; height: 14px; border-radius: 50%; border: 1.5px dashed var(--text-secondary); }
.map-legend .diamond { width: 9px; height: 9px; transform: rotate(45deg); border: 1.5px solid var(--text-secondary); margin: 0 2.5px; }
.map-empty {
  position: absolute; inset: 0; z-index: 600; display: grid; place-items: center; pointer-events: none;
}
.map-empty > div {
  pointer-events: auto; background: rgba(20,23,28,.95); border: 1px solid var(--border-strong); border-radius: var(--radius);
  padding: 18px 22px; max-width: 380px; text-align: center;
}

.marker { position: relative; }
.marker .m {
  border-radius: 50%; display: grid; place-items: center;
  box-shadow: 0 0 0 2px var(--surface-1), 0 2px 8px rgba(0,0,0,.5);
  transition: transform .12s;
}
.marker .m svg { width: 55%; height: 55%; max-width: 16px; max-height: 16px; fill: #fff; }
.marker.power .m svg { fill: #0b0b0b; }
.marker.secondary .m { opacity: .75; }
.marker:hover .m, .marker.sel .m { transform: scale(1.15); }
.marker.sel .m { box-shadow: 0 0 0 2px var(--surface-1), 0 0 0 4px var(--text-primary); }
.marker .pulse { position: absolute; inset: -6px; border-radius: 50%; border: 2px solid; opacity: .0; animation: ring 2.2s infinite; }
@keyframes ring { 0% { transform: scale(.6); opacity: .7; } 100% { transform: scale(1.5); opacity: 0; } }
.marker.wide .m { box-shadow: 0 0 0 2px var(--surface-1), 0 0 0 5px rgba(255,255,255,.0); }
.marker.wide::before {
  content: ""; position: absolute; inset: -9px; border-radius: 50%; border: 1.5px dashed rgba(236,238,241,.55);
}
.live-marker { width: 10px; height: 10px; transform: rotate(45deg); border: 2px solid; background: rgba(20,23,28,.85); }

/* ---------- side list ---------- */
.side {
  position: relative; background: var(--surface-1); border: 1px solid var(--border); border-radius: var(--radius);
  display: flex; flex-direction: column; min-height: 420px; max-height: calc(100vh - 230px); overflow: hidden;
}
.side-head { padding: 12px 14px 8px; border-bottom: 1px solid var(--border); }
.ev-list { list-style: none; margin: 0; padding: 4px 0; overflow-y: auto; flex: 1; }
.ev {
  display: grid; grid-template-columns: 4px 1fr; gap: 0 12px; padding: 10px 14px 10px 10px; cursor: pointer;
  border-bottom: 1px solid var(--border);
}
.ev:hover, .ev.sel { background: var(--surface-2); }
.ev .bar { border-radius: 2px; }
.ev .t { font-weight: 600; font-size: 13.5px; line-height: 1.3; }
.ev .meta { color: var(--text-secondary); font-size: 12px; margin-top: 3px; display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.ev .nums { display: flex; gap: 14px; margin-top: 6px; font-size: 12.5px; font-variant-numeric: tabular-nums; }
.ev .nums span b { font-weight: 600; }
.ev .nums span { color: var(--text-secondary); }
.ev .nums span b { color: var(--text-primary); }
.status-pill { display: inline-flex; align-items: center; gap: 5px; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.status-pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--text-tertiary); }
.status-pill.ongoing { color: #f08a8a; }
.status-pill.ongoing::before { background: var(--critical); animation: pulse-red 1.6s infinite; }
.status-pill.investigating { color: #f5c96a; }
.status-pill.investigating::before { background: var(--warning); }
.status-pill.resolved { color: var(--text-secondary); }
.status-pill.resolved::before { background: var(--good); }
@keyframes pulse-red { 50% { opacity: .35; } }
.ai-tag { font-size: 10.5px; font-weight: 700; padding: 1px 5px; border-radius: 4px; background: rgba(51,140,237,.18); color: #8fc0f7; letter-spacing: .04em; }

/* ---------- detail ---------- */
.detail { position: absolute; inset: 0; background: var(--surface-1); overflow-y: auto; padding: 14px 16px 20px; z-index: 5; }
.detail .back { background: none; border: 0; color: var(--text-secondary); font: inherit; font-size: 12.5px; cursor: pointer; padding: 0; margin-bottom: 10px; }
.detail .back:hover { color: var(--text-primary); }
.detail h3 { font-size: 17px; line-height: 1.3; }
.detail .org { color: var(--text-secondary); margin-top: 4px; font-size: 13px; }
.detail .tags { display: flex; gap: 6px; flex-wrap: wrap; margin: 10px 0 12px; align-items: center; }
.tag { font-size: 11.5px; padding: 2px 8px; border-radius: 999px; background: var(--surface-3); color: var(--text-secondary); display: inline-flex; gap: 5px; align-items: center; }
.metrics { display: grid; gap: 8px; }
.metric { background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; }
.metric .mtop { display: flex; justify-content: space-between; align-items: center; color: var(--text-secondary); font-size: 12px; }
.metric .v { font-size: 19px; font-weight: 600; margin: 3px 0 4px; font-variant-numeric: tabular-nums; }
.metric .note { color: var(--text-secondary); font-size: 12px; line-height: 1.45; }
.detail .when { display: grid; grid-template-columns: auto 1fr; gap: 3px 12px; font-size: 12.5px; margin: 14px 0; }
.detail .when dt { color: var(--text-secondary); }
.detail .when dd { margin: 0; font-variant-numeric: tabular-nums; }
.detail .desc { font-size: 13.5px; line-height: 1.6; color: #d6d9de; }
.detail h4 { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--text-secondary); margin: 18px 0 8px; }
.sources { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.sources li { background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; }
.sources .pub { color: var(--text-secondary); font-size: 11.5px; margin-top: 2px; }
.locs { color: var(--text-secondary); font-size: 12.5px; }

/* ---------- bottom ---------- */
.bottom { display: grid; grid-template-columns: 1fr 400px; gap: 12px; padding: 12px 20px; }
.panel { background: var(--surface-1); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; min-width: 0; }
.panel-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-bottom: 8px; }
#timeline svg { display: block; width: 100%; overflow: visible; }
#timeline .row-label { fill: var(--text-secondary); font-size: 11.5px; }
#timeline .tick { fill: var(--text-tertiary); font-size: 11px; font-variant-numeric: tabular-nums; }
#timeline .gridline { stroke: var(--grid); stroke-width: 1; }
#timeline .now { stroke: var(--critical); stroke-width: 1.5; stroke-dasharray: 3 3; }
#timeline .now-label { fill: #f08a8a; font-size: 11px; }
#timeline .ev-g { cursor: pointer; }
#timeline .ev-g:hover .dot, #timeline .ev-g.sel .dot { stroke: var(--text-primary); stroke-width: 2; }
#timeline .hit { fill: transparent; }

.wire { list-style: none; margin: 0; padding: 0; max-height: 230px; overflow-y: auto; display: grid; }
.wire li { display: grid; grid-template-columns: 20px 1fr; gap: 10px; padding: 7px 0; border-bottom: 1px solid var(--border); }
.wire li:last-child { border-bottom: 0; }
.wire a { color: var(--text-primary); font-size: 12.5px; line-height: 1.35; }
.wire .wm { color: var(--text-tertiary); font-size: 11.5px; margin-top: 2px; }
.wire .empty { color: var(--text-secondary); font-size: 12.5px; padding: 10px 0; display: block; }

.foot { padding: 4px 20px 16px; line-height: 1.5; }

.tooltip {
  position: fixed; z-index: 2000; pointer-events: none; max-width: 300px;
  background: #0b0d10; border: 1px solid var(--border-strong); border-radius: 8px; padding: 8px 10px;
  font-size: 12px; box-shadow: 0 6px 20px rgba(0,0,0,.5);
}
.tooltip .tt-t { font-weight: 600; font-size: 12.5px; margin-bottom: 4px; }
.tooltip .tt-r { color: var(--text-secondary); font-variant-numeric: tabular-nums; }
.tooltip .tt-r b { color: var(--text-primary); font-weight: 600; }

@media (max-width: 1100px) {
  .kpis { grid-template-columns: repeat(2, 1fr); }
  .main, .bottom { grid-template-columns: 1fr; }
  .side { max-height: 520px; }
}

.wire .wsum { color: var(--text-secondary); font-size: 12px; margin-top: 2px; line-height: 1.4; }
.wire .src { font-weight: 600; color: var(--text-secondary); }
.wire .src.reddit { color: #ff8b60; }
.wire .sev { font-variant-numeric: tabular-nums; }
.wire .kw { color: var(--text-tertiary); font-style: italic; }
.pill { white-space: nowrap; }

.list-tabs { display: flex; gap: 4px; }
.list-tabs button { background: none; border: 0; border-bottom: 2px solid transparent; color: var(--text-secondary); font: inherit; font-size: 13px; font-weight: 600; padding: 2px 8px 6px; cursor: pointer; }
.list-tabs button[aria-selected="true"] { color: var(--text-primary); border-bottom-color: #7fb6f5; }
.list-filter { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-top: 6px; font-size: 12px; color: var(--text-secondary); min-height: 20px; }
.list-filter b { color: var(--text-primary); font-weight: 600; }
.list-filter .clear { background: var(--surface-3); border: 0; color: var(--text-primary); font: inherit; font-size: 11.5px; padding: 2px 8px; border-radius: 999px; cursor: pointer; }
.ev .lsum { color: var(--text-secondary); font-size: 12px; margin-top: 3px; line-height: 1.4; }
.ev .t a { color: var(--text-primary); }
.ev .kw { color: var(--text-tertiary); font-style: italic; }
#timeline .row-sep { stroke: var(--grid); stroke-width: 1; opacity: .6; }
#timeline .ev-g:hover .span, #timeline .ev-g.sel .span { opacity: 1; }
.attr-tag { font-size: 10.5px; font-weight: 700; padding: 1px 5px; border-radius: 4px; letter-spacing: .04em; margin-left: 4px; }
.attr-tag.reclassified { background: rgba(226,77,139,.18); color: #f29bc0; }
.attr-tag.suspected { background: rgba(210,142,5,.2); color: #f0c060; }
.attr-tag.disputed { background: rgba(160,168,180,.18); color: #c4cad3; }
.attr-note { margin: 10px 0 4px; padding: 8px 10px; border-radius: 6px; font-size: 12.5px; line-height: 1.45; color: var(--text-secondary); border-left: 3px solid #a0a8b4; background: rgba(255,255,255,.03); }
.attr-note.reclassified { border-left-color: #e24d8b; }
.attr-note.suspected { border-left-color: #d28e05; }
.attr-note b { color: var(--text-primary); font-weight: 600; }

/* topic hubs (SEO pillars) — the home page is the only page that links to all of them */
.topics { display: flex; flex-wrap: wrap; gap: 6px 8px; align-items: center; margin: 0 0 8px; }
.topics-label { color: var(--text-secondary); font-weight: 600; }
.topics a { color: var(--text-primary); text-decoration: none; border: 1px solid var(--border-strong); border-radius: 999px; padding: 2px 10px; }
.topics a:hover { background: var(--surface-2); }
.topics .count { color: var(--text-tertiary); font-variant-numeric: tabular-nums; margin-left: 2px; }
.report-link { display: inline-block; margin: 10px 0 2px; color: var(--cat-cyber); font-weight: 600; text-decoration: none; }
.report-link:hover { text-decoration: underline; }

/* server-rendered summary under the dashboard (crawlable text; see lib/pages.js homeLatest) */
.latest { margin: 0 0 12px; color: var(--text-secondary); }
.latest h2 { font-size: 14px; color: var(--text-primary); margin: 4px 0 4px; }
.latest-intro { margin: 0 0 6px; max-width: 980px; }
.latest ol { margin: 0; padding: 0; list-style: none; columns: 2 420px; column-gap: 28px; }
.latest li { break-inside: avoid; padding: 2px 0; }
.latest a, .latest-links a { color: var(--text-primary); }
.latest-links { margin: 6px 0 0; }

/* dashboard ad (below the map and timeline only) */
.latest .ad { margin: 10px 0 4px; min-height: 100px; }
.latest .ad-label { display: block; font-size: 10px; letter-spacing: .06em; text-transform: uppercase; color: var(--text-tertiary); margin-bottom: 4px; }
.latest .ad:has(ins[data-ad-status="unfilled"]) { display: none; }
