/* ============================================================
   PVE-security — editorial security console
   Space Grotesk / Inter / JetBrains Mono
   Чёрный #0A0A0A + кислотный лайм #B8FF57
   ============================================================ */

:root {
  --bg: #0a0a0a;
  --panel: #111111;
  --panel-2: #161616;
  --inset: #0d0d0d;
  --border: #1e1e1e;
  --border-hi: #2c2c2c;
  --text: #e8e8e8;
  --muted: #8a8a8a;
  --faint: #4a4a4a;
  --accent: #b8ff57;
  --accent-dim: rgba(184, 255, 87, 0.08);
  --accent-glow: rgba(184, 255, 87, 0.25);
  --crit: #ff4d4d;
  --high: #ff8a3d;
  --med: #ffc93d;
  --low: #4da6ff;
  --info: #6b6b6b;
  --ok: #4dcc8a;
  --radius: 6px;
  --mono: "JetBrains Mono", "Cascadia Code", "SF Mono", Consolas, monospace;
  --display: "Space Grotesk", "Inter", sans-serif;
  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --gap: 16px;
  --pad: 1.5rem;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }
html { font-size: 14px; scrollbar-color: #2a2a2a var(--bg); }

body {
  font-family: var(--font);
  font-size: 0.875rem;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
}

html { overflow-x: hidden; }
body { max-width: 100%; overflow-x: hidden; }

::selection { background: rgba(184, 255, 87, 0.25); color: var(--text); }

a { color: var(--accent); text-decoration: none; }
.mono { font-family: var(--mono); }
.muted { color: var(--muted); }

main { padding: 0 var(--pad) 2rem; }

/* ============ Topbar ============ */

.topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(10, 10, 10, 0.85);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

.topbar-row {
  display: flex;
  align-items: center;
  gap: 1rem;
  height: 52px;
  padding: 0 var(--pad);
}

.topbar-left { display: flex; align-items: baseline; gap: 0.5rem; }

.logo {
  font-family: var(--display);
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: var(--text);
}

.logo-dim {
  font-family: var(--mono);
  font-size: 0.6rem;
  color: var(--faint);
}

.topbar-search {
  flex: 1 1 200px;
  max-width: 22rem;
}

#search {
  width: 100%;
  font-family: var(--mono);
  font-size: 0.74rem;
  color: var(--text);
  background: var(--inset);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.4rem 0.7rem;
  transition: border-color 0.15s, box-shadow 0.15s;
}

#search::placeholder { color: var(--faint); }
#search:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}
#search::-webkit-search-cancel-button { -webkit-appearance: none; }

.topbar-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 0.8rem;
}

.seg {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.seg button {
  font: inherit;
  font-family: var(--mono);
  font-size: 0.66rem;
  font-weight: 600;
  color: var(--muted);
  background: none;
  border: none;
  border-right: 1px solid var(--border);
  padding: 0.3rem 0.6rem;
  cursor: pointer;
  transition: all 0.15s;
}

.seg button:last-child { border-right: none; }
.seg button:hover { color: var(--text); background: var(--panel-2); }
.seg button.on { color: #0a0a0a; background: var(--accent); }

.seg-sev button.on[data-sev="crit"] { background: var(--crit); color: #0a0a0a; }
.seg-sev button.on[data-sev="high"] { background: var(--high); color: #0a0a0a; }
.seg-sev button.on[data-sev="med"] { background: var(--med); color: #0a0a0a; }

.clock {
  font-size: 0.7rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.topbar-btns { display: flex; gap: 0.3rem; }

.tbtn {
  font: inherit;
  font-size: 0.68rem;
  font-weight: 500;
  color: var(--muted);
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.3rem 0.6rem;
  cursor: pointer;
  transition: all 0.15s;
}

.tbtn:hover { color: var(--text); border-color: var(--border-hi); }
.tbtn.on { color: #0a0a0a; background: var(--accent); border-color: var(--accent); }
.tbtn-accent { color: #0a0a0a; background: var(--accent); border-color: var(--accent); }
.tbtn-accent:hover { opacity: 0.85; }

.status-dot {
  width: 0.4rem; height: 0.4rem;
  border-radius: 50%;
  background: var(--ok);
  display: inline-block;
}
.status-dot.off { background: var(--faint); }

.refresh-bar {
  height: 1px;
  background: var(--accent);
  opacity: 0.5;
  width: 0%;
  transition: width 0.3s linear;
}

/* ============ Filter bar ============ */

.filter-bar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.8rem var(--pad) 0;
  font-size: 0.74rem;
  color: var(--muted);
}

.fb-label {
  font-size: 0.58rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--faint);
}

.filter-bar code {
  color: var(--accent);
  font-size: 0.72rem;
  background: var(--accent-dim);
  border: 1px solid var(--accent-glow);
  border-radius: 4px;
  padding: 0.1rem 0.45rem;
}

/* ============ Hero ============ */

.hero {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  padding: 2.5rem var(--pad) 2rem;
  gap: 2rem;
  flex-wrap: wrap;
}

.hero-left { min-width: 0; }

.hero-label {
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--muted);
  margin-bottom: 0.5rem;
}

.hero-number {
  font-family: var(--display);
  font-size: clamp(4rem, 12vw, 8rem);
  font-weight: 700;
  line-height: 0.95;
  letter-spacing: -0.03em;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.hero-sub {
  margin-top: 0.75rem;
  font-size: 0.78rem;
  color: var(--muted);
}

.delta {
  display: inline-flex;
  font-family: var(--mono);
  font-size: 0.66rem;
  font-weight: 700;
  padding: 0.1rem 0.4rem;
  border-radius: 4px;
  margin-right: 0.4rem;
}
.delta.up { color: var(--crit); background: rgba(255, 77, 77, 0.12); }
.delta.down { color: var(--ok); background: rgba(77, 204, 138, 0.12); }

.hero-right {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  align-items: flex-end;
}

.threat-block { text-align: right; }

.threat-label {
  font-size: 0.6rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--faint);
  display: block;
  margin-bottom: 0.35rem;
}

.threat-word {
  font-family: var(--display);
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  display: block;
  margin-bottom: 0.5rem;
}
.threat-word.l1 { color: var(--ok); }
.threat-word.l2 { color: var(--low); }
.threat-word.l3 { color: var(--med); }
.threat-word.l4 { color: var(--high); }
.threat-word.l5 { color: var(--crit); }

.threat-seg {
  display: flex;
  gap: 3px;
  justify-content: flex-end;
}
.threat-seg i {
  width: 2.2rem;
  height: 0.4rem;
  border-radius: 2px;
  background: var(--panel-2);
  border: 1px solid var(--border);
}
.threat-seg[data-level="1"] i:nth-child(1) { background: var(--ok); border-color: var(--ok); }
.threat-seg[data-level="2"] i:nth-child(-n+2) { background: var(--low); border-color: var(--low); }
.threat-seg[data-level="3"] i:nth-child(-n+3) { background: var(--med); border-color: var(--med); }
.threat-seg[data-level="4"] i:nth-child(-n+4) { background: var(--high); border-color: var(--high); }
.threat-seg[data-level="5"] i:nth-child(-n+5) { background: var(--crit); border-color: var(--crit); }

.hero-stats {
  display: flex;
  gap: 1.75rem;
}

.hs-item {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.1rem;
}

.hs-val {
  font-family: var(--display);
  font-size: 1.35rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}

.hs-lab {
  font-size: 0.58rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--faint);
}

/* ============ Map Hero ============ */

.maphero {
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: var(--gap);
  padding: 0 var(--pad);
  margin-bottom: var(--gap);
}

.maphero-map {
  position: relative;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--inset);
  min-width: 0;
}

#map {
  width: 100%;
  min-width: 0;
  height: 32rem;
  background: var(--inset);
}

.map-overlay {
  position: absolute;
  bottom: 0.75rem;
  left: 0.75rem;
  z-index: 500;
}

.map-note {
  font-family: var(--mono);
  font-size: 0.62rem;
  color: var(--muted);
  background: rgba(10, 10, 10, 0.75);
  backdrop-filter: blur(6px);
  padding: 0.25rem 0.55rem;
  border-radius: 4px;
  border: 1px solid var(--border);
}

.maphero-side {
  display: flex;
  flex-direction: column;
  gap: var(--gap);
}

.side-block {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
}

.side-label {
  font-size: 0.58rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--faint);
  display: block;
  margin-bottom: 0.65rem;
}

.side-enemy { border-color: var(--accent-glow); }

.enemy-ip {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--accent);
  margin-bottom: 0.2rem;
  word-break: break-all;
}

.enemy-meta {
  font-size: 0.7rem;
  color: var(--muted);
  margin-bottom: 0.5rem;
}

.enemy-hits {
  font-size: 1.5rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  margin-bottom: 0.75rem;
}

/* ============ Live Feed ============ */

.livefeed {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin: 0 var(--pad) var(--gap);
  overflow: hidden;
}

.livefeed-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
  gap: 0.5rem;
}

.section-title {
  font-family: var(--display);
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: 0.01em;
}

.livefeed-side {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.livefeed-foot {
  padding: 0.65rem;
  display: flex;
  justify-content: center;
  border-top: 1px solid var(--border);
}

.table-wrap { overflow-x: auto; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.78rem;
}

thead th {
  text-align: left;
  font-weight: 600;
  font-size: 0.54rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--faint);
  padding: 0 0.4rem 0.5rem 0;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

td {
  padding: 0.35rem 0.4rem 0.35rem 0;
  border-bottom: 1px solid rgba(30, 30, 30, 0.6);
  vertical-align: middle;
}

tbody tr { transition: background 0.12s; }
tbody tr:hover { background: rgba(184, 255, 87, 0.03); }
tbody tr:last-child td { border-bottom: none; }
tbody tr[data-hit] { cursor: pointer; }

tbody tr.sev-row-crit { background: rgba(255, 77, 77, 0.04); }
tbody tr.sev-row-crit:hover { background: rgba(255, 77, 77, 0.08); }

.num {
  text-align: right;
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.col-sev { width: 4.4rem; }
.col-time { width: 5.2rem; }
.col-src { width: 6.6rem; }
.col-ip { width: 9.5rem; }
.col-cls { width: 9.5rem; }

.sev {
  display: inline-flex;
  font-family: var(--mono);
  font-size: 0.56rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 0.1rem 0.35rem;
  border-radius: 3px;
}
.sev-crit { color: var(--crit); background: rgba(255, 77, 77, 0.14); }
.sev-high { color: var(--high); background: rgba(255, 138, 61, 0.14); }
.sev-med { color: var(--med); background: rgba(255, 201, 61, 0.14); }
.sev-low { color: var(--low); background: rgba(77, 166, 255, 0.14); }
.sev-info { color: var(--info); background: rgba(107, 107, 107, 0.14); }

.ip-btn {
  font-family: var(--mono);
  font-size: 0.75rem;
  font-weight: 600;
  background: none;
  border: none;
  color: var(--text);
  cursor: pointer;
  padding: 0;
  text-align: left;
  font-variant-numeric: tabular-nums;
  transition: color 0.12s;
}
.ip-btn:hover { color: var(--accent); }

.path-text {
  font-family: var(--mono);
  font-size: 0.72rem;
  font-weight: 500;
  color: #e2e2e2;
  word-break: break-all;
}

#live-table .mono.muted {
  font-size: 0.67rem;
  font-variant-numeric: tabular-nums;
}

.chip {
  display: inline-block;
  font-family: var(--mono);
  font-size: 0.58rem;
  font-weight: 600;
  color: var(--muted);
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 0.05rem 0.3rem;
}
.chip.src { color: var(--accent); background: var(--accent-dim); border-color: var(--border-hi); }

.panel-note {
  font-size: 0.62rem;
  color: var(--faint);
}

/* ============ Bottom Grid ============ */

.grid-bottom {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr 1fr;
  gap: var(--gap);
  padding: 0 var(--pad);
}

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.85rem;
  min-width: 0;
}

.panel-title {
  font-family: var(--display);
  font-size: 0.78rem;
  font-weight: 600;
  margin-bottom: 0.6rem;
}

.rows { list-style: none; }
.rows li {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.22rem 0;
  border-bottom: 1px solid rgba(30, 30, 30, 0.6);
  font-size: 0.74rem;
}
.rows li:last-child { border-bottom: none; }
.rows .r-name {
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}
.rows .r-count {
  font-family: var(--mono);
  font-size: 0.66rem;
  font-weight: 600;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}
.rows li.hot .r-name, .rows li.hot .r-count { color: var(--high); }

.bar-bg {
  height: 0.2rem;
  background: rgba(138, 138, 138, 0.12);
  border-radius: 999px;
  overflow: hidden;
  min-width: 2.4rem;
  max-width: 5rem;
}
.bar-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 999px;
  transition: width 0.4s ease;
}

.chart-wrap { position: relative; }
canvas { width: 100% !important; }

.heatmap {
  display: grid;
  grid-template-columns: auto repeat(24, 1fr);
  gap: 2px;
  font-family: var(--mono);
  font-size: 0.5rem;
  color: var(--faint);
}
.hm-lab { display: flex; align-items: center; padding-right: 0.3rem; justify-content: flex-end; }
.hm-hour { display: flex; align-items: center; justify-content: center; padding-top: 0.15rem; }
.hm-cell {
  aspect-ratio: 1.2;
  min-height: 0.55rem;
  border-radius: 2px;
  background: var(--panel-2);
}

/* ============ Footer ============ */

footer {
  border-top: 1px solid var(--border);
  padding: 1rem var(--pad) 1.5rem;
  font-size: 0.64rem;
  color: var(--faint);
  margin-top: 1rem;
}
.footer-row { display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }

/* ============ Drawer ============ */

.drawer { position: fixed; inset: 0; z-index: 500; }
.drawer-backdrop { position: absolute; inset: 0; background: rgba(5, 5, 5, 0.6); }
.drawer-card {
  position: absolute;
  top: 0; right: 0; bottom: 0;
  width: min(30rem, 100vw);
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border-left: 1px solid var(--border-hi);
  animation: drawer-in 0.18s ease-out;
}
@keyframes drawer-in { from { transform: translateX(1.5rem); opacity: 0; } }

.drawer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.6rem 0.85rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.drawer-tabs { display: inline-flex; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.tab {
  font: inherit;
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--muted);
  background: none;
  border: none;
  border-right: 1px solid var(--border);
  padding: 0.3rem 0.7rem;
  cursor: pointer;
}
.tab:last-child { border-right: none; }
.tab:hover { color: var(--text); }
.tab.on { color: #0a0a0a; background: var(--accent); }

.drawer-body { padding: 0.85rem; overflow-y: auto; font-size: 0.8rem; flex: 1; }

.sev-banner {
  display: flex;
  border: 1px solid var(--border);
  border-left-width: 3px;
  border-radius: var(--radius);
  padding: 0.45rem 0.65rem;
  margin-bottom: 0.8rem;
  font-family: var(--mono);
  font-size: 0.64rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.sev-banner.crit { border-left-color: var(--crit); color: var(--crit); }
.sev-banner.high { border-left-color: var(--high); color: var(--high); }
.sev-banner.med { border-left-color: var(--med); color: var(--med); }
.sev-banner.low { border-left-color: var(--low); color: var(--low); }
.sev-banner.info { border-left-color: var(--info); color: var(--info); }

.detail-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0.45rem; margin-bottom: 0.8rem; }
.detail-cell {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.4rem 0.55rem;
  min-width: 0;
}
.detail-cell dt {
  font-size: 0.52rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--faint);
  margin-bottom: 0.1rem;
}
.detail-cell dd { font-family: var(--mono); font-size: 0.7rem; word-break: break-all; }

.detail-section { margin-top: 0.8rem; }
.detail-section h3 {
  font-size: 0.54rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--faint);
  margin-bottom: 0.3rem;
}
.detail-section pre {
  font-family: var(--mono);
  font-size: 0.62rem;
  line-height: 1.6;
  color: #a0a0a0;
  background: var(--inset);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.5rem 0.65rem;
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-all;
  max-height: 13rem;
}

.detail-actions { display: flex; gap: 0.4rem; flex-wrap: wrap; margin-top: 0.9rem; }

.ip-head { margin-bottom: 0.8rem; }
.ip-title { font-family: var(--mono); font-size: 1rem; font-weight: 700; word-break: break-all; }
.ip-geo-line { font-size: 0.68rem; color: var(--muted); margin-top: 0.1rem; }

.ip-recent { list-style: none; }
.ip-recent li {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.28rem 0;
  border-bottom: 1px solid rgba(30, 30, 30, 0.6);
  font-size: 0.7rem;
  cursor: pointer;
}
.ip-recent li:hover .ip-recent-path { color: var(--accent); }
.ip-recent .t { font-family: var(--mono); font-size: 0.58rem; color: var(--faint); flex-shrink: 0; }
.ip-recent-path { font-family: var(--mono); font-size: 0.62rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; flex: 1; }

/* ============ Modal ============ */

.modal { position: fixed; inset: 0; z-index: 600; display: flex; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(5, 5, 5, 0.62); }
.modal-card {
  position: relative;
  margin: auto;
  width: min(30rem, calc(100vw - 2rem));
  max-height: min(80vh, 40rem);
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border: 1px solid var(--border-hi);
  border-radius: 8px;
  overflow: hidden;
}
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.6rem 0.85rem;
  border-bottom: 1px solid var(--border);
}
.modal-head h2 { font-size: 0.85rem; font-weight: 600; }
.modal-body { padding: 0.85rem; overflow-y: auto; font-size: 0.76rem; }

.help-h {
  font-size: 0.56rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--faint);
  margin: 0.75rem 0 0.4rem;
}
.help-h:first-child { margin-top: 0; }
.help-grid {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.25rem 0.75rem;
  font-size: 0.68rem;
  align-items: center;
}
.help-grid > span:nth-child(odd) { color: var(--accent); }
.help-grid > span:nth-child(even) { color: var(--muted); font-family: var(--font); }
.help-grid kbd {
  font-family: var(--mono);
  font-size: 0.58rem;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-bottom-width: 2px;
  border-radius: 3px;
  padding: 0.02rem 0.28rem;
}

/* ============ Toasts ============ */

.toasts {
  position: fixed;
  bottom: 1rem;
  right: 1rem;
  z-index: 700;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  pointer-events: none;
}
.toast {
  display: flex;
  align-items: center;
  background: var(--panel-2);
  border: 1px solid var(--border-hi);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius);
  padding: 0.45rem 0.7rem;
  font-size: 0.7rem;
  animation: toast-in 0.18s ease-out;
  max-width: 19rem;
}
.toast.leaving { animation: toast-out 0.18s ease-in forwards; }
@keyframes toast-in { from { opacity: 0; transform: translateX(1rem); } }
@keyframes toast-out { to { opacity: 0; transform: translateX(1rem); } }
.toast.hot { border-left-color: var(--crit); }
.toast .mono { color: var(--accent); }

/* ============ Map (Leaflet) ============ */

.leaflet-container { font-family: var(--font); background: var(--inset); }
.leaflet-popup-content-wrapper {
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--border-hi);
  border-radius: var(--radius);
  font-size: 0.76rem;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
}
.leaflet-popup-tip { background: var(--panel-2); border: 1px solid var(--border-hi); }
.leaflet-popup-content { margin: 0.5rem 0.7rem; }
.leaflet-popup-content strong { font-family: var(--mono); font-size: 0.78rem; color: var(--accent); }
.leaflet-popup-close-button { color: var(--muted) !important; }
.leaflet-popup-content small { display: block; color: var(--muted); margin-top: 0.06rem; font-size: 0.68rem; }
.leaflet-popup-content button {
  font: inherit;
  margin-top: 0.35rem;
  background: var(--accent);
  color: #0a0a0a;
  border: none;
  border-radius: 3px;
  padding: 0.2rem 0.5rem;
  cursor: pointer;
  font-size: 0.66rem;
  font-weight: 600;
}
.leaflet-popup-content button:hover { opacity: 0.85; }
.leaflet-control-zoom a { background: var(--panel-2) !important; color: var(--text) !important; border-color: var(--border) !important; }
.leaflet-control-attribution { background: rgba(10, 10, 10, 0.7) !important; color: var(--faint) !important; font-size: 0.52rem !important; }
.leaflet-control-attribution a { color: var(--muted) !important; }

.hp-marker { background: none !important; border: none !important; }
.hp-wrap { position: relative; }

/* ============ A11y / Scrollbar ============ */

.skip {
  position: absolute;
  top: -3rem;
  left: 1rem;
  background: var(--accent);
  color: #0a0a0a;
  padding: 0.35rem 0.7rem;
  border-radius: var(--radius);
  z-index: 999;
  font-size: 0.76rem;
  font-weight: 700;
}
.skip:focus { top: 0.5rem; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: #2a2a2a; border-radius: 4px; }
::-webkit-scrollbar-track { background: transparent; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

/* ============ Responsive ============ */

@media (max-width: 76rem) {
  .maphero { grid-template-columns: 1fr; }
  .maphero-side { flex-direction: row; flex-wrap: wrap; }
  .maphero-side .side-block { flex: 1 1 200px; }
  .grid-bottom { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 52rem) {
  html { font-size: 13px; }
  .topbar-row { height: auto; padding: 0.5rem var(--pad); flex-wrap: wrap; gap: 0.5rem; }
  .topbar-search { order: 10; flex-basis: 100%; max-width: none; }
  .clock, .status { display: none; }
  .hero { padding: 1.5rem var(--pad) 1.25rem; }
  .hero-number { font-size: clamp(3rem, 15vw, 5rem); }
  .hero-right { align-items: flex-start; width: 100%; }
  .threat-block { text-align: left; }
  .threat-seg { justify-content: flex-start; }
  .hero-stats { gap: 1.25rem; }
  .col-src { display: none; }
  .grid-bottom { grid-template-columns: 1fr; }
  #map { height: 18rem; }
}

/* --- Phones --- */
@media (max-width: 40rem) {
  :root { --pad: 0.9rem; }
  body { -webkit-tap-highlight-color: transparent; }

  .topbar-row { gap: 0.4rem; padding: 0.45rem var(--pad); }
  .logo { font-size: 0.82rem; letter-spacing: 0.08em; }
  .logo-dim { display: none; }
  .topbar-right { margin-left: 0; width: 100%; flex-wrap: wrap; gap: 0.4rem; }
  .topbar-btns { margin-left: auto; }
  #range-seg { flex: 1 1 auto; }
  #range-seg button { padding: 0.35rem 0; flex: 1 1 25%; }
  .tbtn { padding: 0.45rem 0.65rem; }

  .filter-bar { flex-wrap: wrap; }
  .filter-bar code { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

  .hero { padding: 1.25rem var(--pad) 1rem; gap: 1.25rem; }
  .hero-number { font-size: clamp(2.6rem, 18vw, 3.8rem); }
  .hero-stats {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.7rem 1.1rem;
    width: 100%;
  }
  .hs-item { align-items: flex-start; }
  .hs-val { font-size: 1.25rem; }
  .threat-seg i { width: 1.6rem; }

  .maphero { gap: 0.7rem; margin-bottom: 0.7rem; }
  .maphero-side { gap: 0.7rem; }
  .maphero-side .side-block { flex-basis: 100%; }
  #map { height: 14rem; touch-action: manipulation; }

  .livefeed { margin: 0 var(--pad) 0.7rem; }
  .livefeed-head { padding: 0.7rem; }
  .livefeed-side { width: 100%; justify-content: space-between; }
  #sev-seg button { padding: 0.35rem 0.5rem; }

  /* Live feed as stacked cards */
  .livefeed .table-wrap { overflow: visible; }
  .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  #live-table, #live-table thead, #live-table tbody,
  #live-table tr, #live-table th, #live-table td { display: block; }
  #live-table thead { display: none; }
  #live-table tbody tr {
    margin-bottom: 0.6rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--panel-2);
    padding: 0.55rem 0.7rem;
  }
  #live-table tbody tr.sev-row-crit { border-color: var(--crit); }
  #live-table td {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 0.9rem;
    padding: 0.22rem 0;
    border: none;
    font-size: 0.92rem;
  }
  #live-table td::before {
    content: attr(data-label);
    flex-shrink: 0;
    font-size: 0.58rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--faint);
  }
  #live-table td.path-text { justify-content: flex-end; word-break: break-all; font-size: 0.84rem; color: #fff; }
  #live-table .ip-btn { font-size: 1rem; }
  #live-table .chip.src { font-size: 0.64rem; padding: 0.1rem 0.4rem; }
  #live-table .mono.muted { font-size: 0.76rem; }
  #live-table .sev { font-size: 0.62rem; padding: 0.12rem 0.45rem; }
  #live-table td:first-child {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border);
    margin-bottom: 0.25rem;
    padding-bottom: 0.35rem;
  }
  #live-table td:first-child .sev { order: 1; }
  #live-table td:first-child::before { content: attr(data-label); }

  .grid-bottom { gap: 0.7rem; }
  .panel { padding: 0.7rem; }
  .bar-bg { max-width: 3rem; }

  .footer-row { flex-direction: column; gap: 0.35rem; }

  .drawer-card { width: 100vw; }
  .detail-grid { grid-template-columns: 1fr; }

  .toasts { left: 0.9rem; right: 0.9rem; bottom: 0.9rem; }
  .toast { max-width: none; width: 100%; }
}
