/* ─────────── UA-RADAR ─────────── */

:root {
  --bg: #07090d;
  --bg-2: #0c1016;
  --panel: rgba(12, 16, 23, 0.92);
  --panel-solid: #0c1016;
  --line: #1c2431;
  --line-soft: #151c26;
  --text: #dfe7f1;
  --text-dim: #8695aa;
  --text-faint: #5b6879;

  --amber: #ff9d00;
  --red: #ff2d55;
  --red-deep: #c4001f;
  --green: #00e5a0;
  --blue: #38bdf8;
  --violet: #a855f7;

  --alert: #ff2d55;
  --calm: #1e3a2f;
  --occ: #3a2230;

  --sh: 0 10px 40px rgba(0, 0, 0, 0.55);
  --mono: 'JetBrains Mono', ui-monospace, 'Cascadia Mono', Consolas, monospace;
  --sans: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;

  --top-h: 58px;
  --left-w: 316px;
  --right-w: 356px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

button { font: inherit; color: inherit; cursor: pointer; }
.hidden { display: none !important; }

/* ─────────── завантажувач ─────────── */

.boot {
  position: fixed;
  inset: 0;
  z-index: 9000;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 14px;
  background: radial-gradient(circle at 50% 45%, #0d1420, #05070a 70%);
  transition: opacity 0.5s ease, visibility 0.5s;
}
.boot.done { opacity: 0; visibility: hidden; }
.boot-radar { position: relative; width: 120px; height: 120px; }
.boot-radar span {
  position: absolute;
  inset: 0;
  margin: auto;
  border: 1px solid rgba(0, 229, 160, 0.25);
  border-radius: 50%;
}
.boot-radar span:nth-child(1) { width: 100%; height: 100%; }
.boot-radar span:nth-child(2) { width: 66%; height: 66%; }
.boot-radar span:nth-child(3) { width: 33%; height: 33%; }
.boot-radar i {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: conic-gradient(from 0deg, rgba(0, 229, 160, 0.5), transparent 28%);
  animation: sweep 1.6s linear infinite;
}
@keyframes sweep { to { transform: rotate(360deg); } }
.boot-text { font-family: var(--mono); font-weight: 700; font-size: 26px; letter-spacing: 0.32em; color: var(--green); }
.boot-sub { font-family: var(--mono); font-size: 12px; color: var(--text-faint); }

/* ─────────── верхня панель ─────────── */

.topbar {
  position: relative;
  z-index: 700;
  height: var(--top-h);
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 0 14px;
  background: linear-gradient(180deg, #0d1219, #090d13);
  border-bottom: 1px solid var(--line);
}

.brand { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.brand-mark {
  position: relative;
  width: 30px;
  height: 30px;
  border: 1.5px solid var(--amber);
  border-radius: 50%;
  display: grid;
  place-items: center;
  overflow: hidden;
}
.brand-mark::after {
  content: '';
  position: absolute;
  inset: 0;
  background: conic-gradient(from 0deg, rgba(255, 157, 0, 0.55), transparent 30%);
  animation: sweep 3s linear infinite;
}
.brand-mark i { width: 7px; height: 7px; background: var(--red); border-radius: 50%; z-index: 1; }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-text strong { font-family: var(--mono); letter-spacing: 0.14em; font-size: 14px; }
.brand-text span { font-size: 10.5px; color: var(--text-faint); }

/* індикатор рівня загрози */
.threat-level { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.tl-bar { display: flex; gap: 3px; }
.tl-bar i { width: 7px; height: 22px; border-radius: 2px; background: #1a222e; transition: background 0.4s, box-shadow 0.4s; }
.threat-level[data-level="1"] .tl-bar i:nth-child(1),
.threat-level[data-level="2"] .tl-bar i:nth-child(-n+2),
.threat-level[data-level="3"] .tl-bar i:nth-child(-n+3),
.threat-level[data-level="4"] .tl-bar i { background: var(--amber); box-shadow: 0 0 10px rgba(255, 157, 0, 0.6); }
.threat-level[data-level="3"] .tl-bar i:nth-child(-n+3),
.threat-level[data-level="4"] .tl-bar i { background: var(--red); box-shadow: 0 0 12px rgba(255, 45, 85, 0.7); }
.tl-text { display: flex; flex-direction: column; line-height: 1.2; }
.tl-text b { font-size: 13px; }
.tl-text span { font-size: 10.5px; color: var(--text-dim); font-family: var(--mono); }
.threat-level[data-level="0"] .tl-text b { color: var(--green); }
.threat-level[data-level="1"] .tl-text b,
.threat-level[data-level="2"] .tl-text b { color: var(--amber); }
.threat-level[data-level="3"] .tl-text b,
.threat-level[data-level="4"] .tl-text b { color: var(--red); animation: blink 1.1s steps(2) infinite; }
@keyframes blink { 50% { opacity: 0.35; } }

.kpis { display: flex; gap: 8px; margin-left: auto; }
.kpi {
  min-width: 78px;
  padding: 5px 10px;
  background: #0f151d;
  border: 1px solid var(--line);
  border-radius: 6px;
  display: flex;
  flex-direction: column;
  line-height: 1.15;
}
.kpi b { font-family: var(--mono); font-size: 15px; }
.kpi span { font-size: 9.5px; color: var(--text-faint); text-transform: uppercase; letter-spacing: 0.05em; }
#kpiAlerts b { color: var(--red); }
#kpiEta b { color: var(--amber); }

.topbar-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.btn {
  background: #121a24;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 7px 12px;
  font-size: 12px;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.btn:hover { background: #1a2532; border-color: #2b3a4d; }
.btn.icon { padding: 7px; display: grid; place-items: center; color: var(--text-dim); }
.btn.icon[aria-pressed="true"] { color: var(--green); border-color: rgba(0, 229, 160, 0.45); background: rgba(0, 229, 160, 0.09); }
.btn.icon[aria-pressed="false"] #soundWaves { opacity: 0.2; }
.btn.sm { padding: 5px 9px; font-size: 11px; }
.btn.danger { color: var(--red); border-color: rgba(255, 45, 85, 0.4); }
.btn.active { background: rgba(255, 157, 0, 0.14); border-color: rgba(255, 157, 0, 0.5); color: var(--amber); }

.conn { display: flex; align-items: center; gap: 6px; font-family: var(--mono); font-size: 10.5px; color: var(--text-faint); }
.conn i { width: 7px; height: 7px; border-radius: 50%; background: var(--text-faint); }
.conn[data-state="ok"] i { background: var(--green); box-shadow: 0 0 8px var(--green); }
.conn[data-state="wait"] i { background: var(--amber); animation: blink 1s infinite; }
.conn[data-state="err"] i { background: var(--red); }

/* ─────────── розкладка ─────────── */

.layout {
  position: relative;
  height: calc(100% - var(--top-h));
  display: grid;
  grid-template-columns: var(--left-w) 1fr;
}
.layout:has(.panel.right:not(.hidden)) { grid-template-columns: var(--left-w) 1fr var(--right-w); }

.panel {
  position: relative;
  background: var(--panel-solid);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}
.panel.right { border-right: 0; border-left: 1px solid var(--line); }
.panel-close {
  position: absolute;
  top: 8px;
  right: 10px;
  z-index: 5;
  background: none;
  border: 0;
  font-size: 22px;
  line-height: 1;
  color: var(--text-faint);
}
.panel-close:hover { color: var(--text); }

.tabs { display: flex; border-bottom: 1px solid var(--line); flex-shrink: 0; }
.tab {
  flex: 1;
  background: none;
  border: 0;
  border-bottom: 2px solid transparent;
  padding: 11px 6px;
  font-size: 12px;
  color: var(--text-dim);
}
.tab.active { color: var(--amber); border-bottom-color: var(--amber); background: rgba(255, 157, 0, 0.05); }
.tab-body { flex: 1; min-height: 0; display: flex; flex-direction: column; }

.search { display: flex; align-items: center; gap: 7px; padding: 9px 11px; border-bottom: 1px solid var(--line-soft); color: var(--text-faint); }
.search input {
  flex: 1;
  background: none;
  border: 0;
  outline: none;
  color: var(--text);
  font-size: 12.5px;
  font-family: var(--sans);
}
.hint {
  padding: 9px 12px;
  font-size: 11px;
  line-height: 1.5;
  color: var(--text-dim);
  background: rgba(255, 157, 0, 0.05);
  border-bottom: 1px solid var(--line-soft);
}
.hint b { color: var(--amber); }

.list { flex: 1; overflow-y: auto; overscroll-behavior: contain; }
.list::-webkit-scrollbar { width: 8px; }
.list::-webkit-scrollbar-thumb { background: #1e2835; border-radius: 4px; }
.list::-webkit-scrollbar-track { background: transparent; }

/* рядок області */
.r-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 12px;
  border-bottom: 1px solid var(--line-soft);
  cursor: pointer;
  transition: background 0.12s;
}
.r-item:hover { background: #111823; }
.r-item.on { background: rgba(255, 45, 85, 0.08); }
.r-item.on:hover { background: rgba(255, 45, 85, 0.14); }
.r-item.sel { box-shadow: inset 2px 0 0 var(--amber); }
.r-dot { width: 9px; height: 9px; border-radius: 50%; background: #23303f; flex-shrink: 0; }
.r-item.on .r-dot { background: var(--red); box-shadow: 0 0 9px var(--red); animation: pulse-dot 1.4s ease-in-out infinite; }
@keyframes pulse-dot { 50% { transform: scale(1.45); opacity: 0.6; } }
.r-main { flex: 1; min-width: 0; }
.r-name { font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.r-sub { font-size: 10px; color: var(--text-faint); font-family: var(--mono); margin-top: 2px; }
.r-item.on .r-sub { color: #ff8199; }
.r-time { font-family: var(--mono); font-size: 11px; color: var(--text-faint); flex-shrink: 0; }
.r-item.on .r-time { color: var(--red); font-weight: 700; }
.r-badges { display: flex; gap: 3px; margin-top: 4px; flex-wrap: wrap; }

.badge {
  font-family: var(--mono);
  font-size: 9px;
  padding: 1.5px 5px;
  border-radius: 3px;
  border: 1px solid currentColor;
  white-space: nowrap;
}
.badge.solid { color: #07090d; border-color: transparent; font-weight: 700; }

/* рядок загрози */
.t-item { padding: 10px 12px; border-bottom: 1px solid var(--line-soft); cursor: pointer; }
.t-item:hover { background: #111823; }
.t-head { display: flex; align-items: center; gap: 7px; }
.t-ico { width: 16px; height: 16px; flex-shrink: 0; }
.t-type { font-size: 12px; font-weight: 600; }
.t-conf { margin-left: auto; font-family: var(--mono); font-size: 10px; color: var(--text-faint); }
.t-region { font-size: 11px; color: var(--text-dim); margin-top: 3px; }
.t-meta { display: flex; gap: 10px; margin-top: 5px; font-family: var(--mono); font-size: 10px; color: var(--text-faint); }
.t-meta b { color: var(--amber); }

/* журнал */
.e-item { display: flex; gap: 9px; padding: 8px 12px; border-bottom: 1px solid var(--line-soft); font-size: 11.5px; }
.e-time { font-family: var(--mono); font-size: 10px; color: var(--text-faint); flex-shrink: 0; width: 38px; }
.e-icon { flex-shrink: 0; font-size: 11px; }
.e-text { flex: 1; line-height: 1.4; }
.e-item.on .e-icon { color: var(--red); }
.e-item.off .e-icon { color: var(--green); }
.e-dur { font-family: var(--mono); font-size: 10px; color: var(--text-faint); }
.empty { padding: 26px 16px; text-align: center; color: var(--text-faint); font-size: 12px; line-height: 1.6; }

/* ─────────── мапа ─────────── */

.map-wrap {
  position: relative;
  min-width: 0;
  overflow: hidden;
  /* власний контекст накладання: інакше контроли Leaflet (z-index 1000)
     вилазять поверх нижньої шторки на телефоні */
  isolation: isolate;
  z-index: 0;
}
#map { position: absolute; inset: 0; background: #060810; }
.leaflet-container { background: #060810; font-family: var(--sans); outline: none; }
.leaflet-control-attribution {
  background: rgba(6, 8, 16, 0.8) !important;
  color: var(--text-faint) !important;
  font-size: 9px !important;
}
.leaflet-control-attribution a { color: var(--text-dim) !important; }
.leaflet-control-zoom a {
  background: #0f151d !important;
  color: var(--text) !important;
  border-color: var(--line) !important;
}
.leaflet-control-zoom a:hover { background: #1a2532 !important; }

/* радарний промінь та скан-лінії — суто оформлення */
.radar-sweep {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 190%;
  aspect-ratio: 1;
  transform: translate(-50%, -50%);
  pointer-events: none;
  z-index: 450;
  background: conic-gradient(from 0deg, rgba(0, 229, 160, 0.09), rgba(0, 229, 160, 0.02) 8%, transparent 20%);
  animation: sweep 7s linear infinite;
  mix-blend-mode: screen;
  opacity: 0.85;
}
.scanlines {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 451;
  background: repeating-linear-gradient(0deg, rgba(0, 0, 0, 0.22) 0 1px, transparent 1px 3px);
  opacity: 0.35;
}
body.no-fx .radar-sweep, body.no-fx .scanlines { display: none; }

.map-banner {
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 620;
  padding: 8px 18px;
  background: rgba(196, 0, 31, 0.92);
  border: 1px solid #ff6b85;
  border-radius: 6px;
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  box-shadow: 0 0 30px rgba(255, 45, 85, 0.5);
  animation: blink 1.5s steps(2) infinite;
  white-space: nowrap;
  max-width: 92%;
  overflow: hidden;
  text-overflow: ellipsis;
}
.map-banner.sim { background: rgba(124, 58, 237, 0.92); border-color: #c4b5fd; animation: none; }

/* легенда */
.legend {
  position: absolute;
  left: 10px;
  bottom: 10px;
  z-index: 600;
  width: 194px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  backdrop-filter: blur(9px);
  box-shadow: var(--sh);
  overflow: hidden;
}
.legend-toggle {
  width: 100%;
  background: none;
  border: 0;
  padding: 8px 11px;
  text-align: left;
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-dim);
  border-bottom: 1px solid var(--line-soft);
}
.legend-body { padding: 9px 11px; max-height: 45vh; overflow-y: auto; }
.legend.collapsed .legend-body { display: none; }
.legend-group { margin-bottom: 9px; }
.lg-title { display: block; font-size: 9.5px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-faint); margin-bottom: 5px; }
.lg-row { display: flex; align-items: center; gap: 7px; font-size: 11px; padding: 2px 0; color: var(--text-dim); }
.sw { width: 12px; height: 12px; border-radius: 3px; flex-shrink: 0; }
.sw.alert { background: rgba(255, 45, 85, 0.5); border: 1px solid var(--red); }
.sw.calm { background: rgba(30, 58, 47, 0.6); border: 1px solid #2c4a3c; }
.sw.occ { background: rgba(140, 40, 70, 0.35); border: 1px solid #7a2b45; }
.lg-line { width: 14px; height: 0; border-top: 2px dashed currentColor; flex-shrink: 0; }
.legend-note { font-size: 9.5px; line-height: 1.5; color: var(--text-faint); border-top: 1px solid var(--line-soft); padding-top: 7px; }
.legend-note b { color: var(--amber); }

/* перемикачі шарів */
.layers {
  position: absolute;
  right: 10px;
  top: 10px;
  z-index: 600;
  display: flex;
  flex-direction: column;
  gap: 4px;
  width: 132px;
}
.layer-btn {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 6px 9px;
  font-size: 11px;
  text-align: left;
  color: var(--text-faint);
  backdrop-filter: blur(9px);
  transition: color 0.15s, border-color 0.15s;
}
.layer-btn::before {
  content: '';
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  margin-right: 7px;
  vertical-align: 1px;
  opacity: 0.35;
}
.layer-btn.active { color: var(--text); border-color: #2b3a4d; }
.layer-btn.active::before { opacity: 1; background: var(--green); box-shadow: 0 0 7px var(--green); }

/* симулятор */
.sim-bar {
  position: absolute;
  right: 10px;
  bottom: 10px;
  z-index: 600;
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 7px 9px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  backdrop-filter: blur(9px);
}
.sim-title { font-family: var(--mono); font-size: 9.5px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-faint); }

/* ─────────── маркери на мапі ─────────── */

.oblast-label {
  font-family: var(--mono);
  font-size: 9.5px;
  font-weight: 500;
  color: #93a4b8;
  text-shadow: 0 0 5px #000, 0 0 10px #000;
  white-space: nowrap;
  pointer-events: none;
}
.oblast-label.on { color: #ff9eb2; font-weight: 700; text-shadow: 0 0 6px #000, 0 0 14px rgba(255, 45, 85, 0.8); }

.city-dot {
  border-radius: 50%;
  background: #cfe0f2;
  box-shadow: 0 0 0 1.5px rgba(0, 0, 0, 0.75);
}
.city-dot.occ { background: #8a93a0; }
.city-label {
  font-size: 10px;
  color: #b8c6d8;
  text-shadow: 0 0 4px #000, 0 0 9px #000;
  white-space: nowrap;
  pointer-events: none;
  transform: translate(9px, -7px);
}

.npp-marker { display: grid; place-items: center; color: #ffe066; }
.npp-marker svg { filter: drop-shadow(0 0 4px #000); }

.origin-marker {
  width: 100%;
  height: 100%;
  border: 1.5px dashed rgba(255, 45, 85, 0.75);
  border-radius: 50%;
  background: rgba(255, 45, 85, 0.1);
  position: relative;
}
.origin-marker::after {
  content: '';
  position: absolute;
  inset: 0;
  margin: auto;
  width: 4px;
  height: 4px;
  background: var(--red);
  border-radius: 50%;
}

/* трек цілі */
.track-icon { transform-origin: 50% 50%; }
.track-icon svg { display: block; filter: drop-shadow(0 0 5px currentColor); }
.track-icon.hit { animation: hit-flash 0.6s ease-out forwards; }
.track-icon.kill { animation: kill-flash 0.7s ease-out forwards; }
@keyframes hit-flash {
  0% { transform: scale(1); opacity: 1; }
  100% { transform: scale(3.4); opacity: 0; }
}
@keyframes kill-flash {
  0% { transform: scale(1); opacity: 1; filter: brightness(1); }
  40% { transform: scale(1.9); filter: brightness(2.4); }
  100% { transform: scale(0.4); opacity: 0; }
}

.impact-ring {
  border-radius: 50%;
  border: 2px solid var(--red);
  animation: ring 1.4s ease-out forwards;
}
@keyframes ring {
  from { transform: scale(0.15); opacity: 1; }
  to { transform: scale(1); opacity: 0; }
}

/* попапи */
.leaflet-popup-content-wrapper {
  background: var(--panel-solid);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--sh);
}
.leaflet-popup-tip { background: var(--panel-solid); border: 1px solid var(--line); }
.leaflet-popup-content { margin: 10px 12px; font-size: 12px; line-height: 1.5; }
.leaflet-popup-close-button { color: var(--text-faint) !important; }
.pp-title { font-weight: 700; font-size: 13px; margin-bottom: 4px; }
.pp-row { display: flex; justify-content: space-between; gap: 14px; font-family: var(--mono); font-size: 10.5px; color: var(--text-dim); }
.pp-row b { color: var(--text); }
.pp-note { margin-top: 6px; font-size: 10.5px; color: var(--text-faint); line-height: 1.45; }

/* ─────────── права панель: деталі ─────────── */

.d-head { padding: 14px 40px 12px 14px; border-bottom: 1px solid var(--line); }
.d-title { font-size: 16px; font-weight: 700; line-height: 1.25; }
.d-status { display: flex; align-items: center; gap: 7px; margin-top: 7px; font-size: 12px; }
.d-status .r-dot { width: 8px; height: 8px; }
.d-body { padding: 12px 14px; overflow-y: auto; flex: 1; }
.d-sec { margin-bottom: 16px; }
.d-sec > h4 {
  margin: 0 0 8px;
  font-size: 9.5px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-faint);
  font-weight: 600;
}
.d-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; }
.d-cell { background: #0f151d; border: 1px solid var(--line-soft); border-radius: 6px; padding: 7px 9px; }
.d-cell span { display: block; font-size: 9.5px; color: var(--text-faint); text-transform: uppercase; letter-spacing: 0.04em; }
.d-cell b { font-family: var(--mono); font-size: 13px; }
.d-threat {
  border: 1px solid var(--line);
  border-left: 3px solid;
  border-radius: 6px;
  padding: 9px 11px;
  margin-bottom: 7px;
  background: #0f151d;
}
.d-threat .t-head { margin-bottom: 4px; }
.d-note { font-size: 11px; line-height: 1.5; color: var(--text-dim); }
.d-districts { display: flex; flex-wrap: wrap; gap: 4px; }
.d-districts .badge { cursor: default; }

/* ─────────── застереження ─────────── */

.disclaimer {
  position: fixed;
  left: 50%;
  bottom: 12px;
  transform: translateX(-50%);
  z-index: 800;
  max-width: 760px;
  width: calc(100% - 24px);
  padding: 10px 14px;
  background: rgba(12, 16, 23, 0.96);
  border: 1px solid var(--line);
  border-left: 3px solid var(--amber);
  border-radius: 8px;
  font-size: 11.5px;
  line-height: 1.55;
  color: var(--text-dim);
  box-shadow: var(--sh);
  backdrop-filter: blur(10px);
}
.disclaimer b { color: var(--amber); }
.disclaimer button {
  float: right;
  margin-left: 12px;
  background: #1a2532;
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 4px 10px;
  font-size: 11px;
  color: var(--text);
}
.disclaimer.hidden { display: none; }

/* ─────────── адаптив ─────────── */

@media (max-width: 1180px) {
  :root { --left-w: 268px; --right-w: 300px; }
  .kpi { min-width: 66px; }
}

@media (max-width: 900px) {
  :root { --top-h: 50px; }

  /* верхня панель: лишаємо тільки те, що читається з одного погляду */
  .topbar { gap: 9px; padding: 0 9px; overflow: hidden; }
  .brand-text { display: none; }
  .tl-text span { display: none; }
  .tl-text b { font-size: 12px; }
  .kpis { margin-left: auto; gap: 5px; }
  .kpi { min-width: 54px; padding: 4px 7px; }
  .kpi b { font-size: 13px; }
  #kpiPop { display: none; }
  .conn span { display: none; }
  .btn.icon { padding: 6px; }

  .layout { grid-template-columns: 1fr; }
  .layout:has(.panel.right:not(.hidden)) { grid-template-columns: 1fr; }

  /* панелі стають нижньою шторкою */
  .panel {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 750;
    height: 60vh;
    padding-top: 13px;
    border: 0;
    border-top: 1px solid var(--line);
    border-radius: 14px 14px 0 0;
    box-shadow: 0 -12px 40px rgba(0, 0, 0, 0.6);
    transform: translateY(calc(100% - 55px));
    transition: transform 0.28s ease;
  }
  .panel::before {
    content: '';
    position: absolute;
    top: 5px;
    left: 50%;
    transform: translateX(-50%);
    width: 38px;
    height: 4px;
    border-radius: 2px;
    background: #2f3e52;
  }
  .panel.open { transform: translateY(0); }
  .panel.left .tabs { cursor: pointer; }
  .panel.right { height: 72vh; transform: translateY(0); padding-top: 13px; }
  .panel-close { top: 13px; }

  /* керування мапою */
  .leaflet-control-zoom { display: none; }
  /* атрибуція ліворуч, панель симулятора праворуч — щоб не накладались */
  .leaflet-bottom.leaflet-right { bottom: 60px; right: auto; left: 0; }
  .leaflet-control-attribution { font-size: 8px !important; max-width: 40vw; }

  .legend { display: none; }
  .layers {
    top: 8px;
    left: 8px;
    right: 8px;
    width: auto;
    flex-direction: row;
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: none;
    padding-bottom: 2px;
  }
  .layers::-webkit-scrollbar { display: none; }
  .layer-btn { font-size: 10px; padding: 5px 8px; white-space: nowrap; flex: 0 0 auto; }
  .layer-btn::before { margin-right: 5px; }

  .map-banner { top: 44px; }
  .sim-bar { bottom: 58px; left: auto; right: 8px; width: max-content; }
  .disclaimer { bottom: auto; top: calc(var(--top-h) + 40px); font-size: 10.5px; }
  .radar-sweep { display: none; }
}

@media (max-width: 420px) {
  .kpi { min-width: 46px; }
  #kpiEta { display: none; }
  .sim-title { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
  .radar-sweep { display: none; }
}

/* ─────────── анімації векторів і областей у тривозі ─────────── */

path.ob-on {
  animation: ob-pulse 2.4s ease-in-out infinite;
}
@keyframes ob-pulse {
  0%, 100% { fill-opacity: 0.22; }
  50%      { fill-opacity: 0.42; }
}

path.vec-line {
  animation: vec-dash 1.1s linear infinite;
}
@keyframes vec-dash {
  to { stroke-dashoffset: -16; }
}

path.vec-ring {
  animation: vec-ring 2s ease-out infinite;
  transform-box: fill-box;
  transform-origin: 50% 50%;
}
@keyframes vec-ring {
  0%   { transform: scale(0.35); opacity: 0.9; }
  100% { transform: scale(1.15); opacity: 0; }
}

/* окупована територія: тривога стоїть роками — інший, спокійніший вигляд */
.r-item.perm { background: rgba(140, 40, 70, 0.07); }
.r-item.perm .r-dot { background: #7a2b45; }
.r-item.perm .r-name { color: #a8b3c2; }
.r-item.perm .r-sub { color: #9c6b7e; }
.r-item.perm .r-time { color: #7a2b45; }

/* підписи країн і морів на підкладці */
.country-label {
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.22em;
  color: #2f4257;
  text-transform: uppercase;
  white-space: nowrap;
  pointer-events: none;
  transform: translate(-50%, -50%);
}
.country-label.sea { color: #1f3a52; font-style: italic; letter-spacing: 0.14em; }

/* морське тло під підкладкою */
#map { background: #060d14; }
.leaflet-container { background: #060d14; }

/* на малому зумі лишаємо підписи лише тих областей, де тривога */
body.zoom-lo .oblast-label:not(.on) { opacity: 0; }
.oblast-label { transition: opacity 0.2s; }

/* банер не має налазити на перемикачі шарів праворуч */
.map-banner {
  left: 10px;
  right: 152px;
  transform: none;
  margin: 0 auto;
  width: max-content;
  max-width: calc(100% - 172px);
}
@media (max-width: 900px) {
  .map-banner { right: 10px; max-width: calc(100% - 20px); font-size: 10.5px; padding: 7px 12px; }
}

/* на дуже малому зумі лишаємо підписи лише найбільших міст */
body.zoom-xs .city-label.r2 { display: none; }

/* ─────────── монітор каналів: цілі, стрічка, досяжність ─────────── */

.tab-badge {
  display: none;
  margin-left: 5px;
  padding: 0 5px;
  border-radius: 8px;
  background: var(--red);
  color: #0b0f14;
  font-family: var(--mono);
  font-size: 9px;
  font-style: normal;
  font-weight: 700;
  vertical-align: 1px;
}
.tab-badge.on { display: inline-block; }

/* смуга джерел */
.src-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--line-soft);
  background: #0b1119;
}
.src-count {
  font-family: var(--mono);
  font-size: 9.5px;
  color: var(--green);
  margin-right: 4px;
  align-self: center;
}
.src-chip {
  font-size: 9.5px;
  padding: 2px 6px;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--text-dim);
  cursor: default;
  white-space: nowrap;
}
.src-chip.kyiv { border-color: #2a3f57; color: #7f9ab8; }
.src-chip.err { border-color: rgba(255, 45, 85, 0.5); color: var(--red); text-decoration: line-through; }

/* стрічка повідомлень */
.f-item {
  padding: 9px 12px;
  border-bottom: 1px solid var(--line-soft);
  cursor: pointer;
}
.f-item:hover { background: #111823; }
.f-head { display: flex; justify-content: space-between; gap: 8px; margin-bottom: 3px; }
.f-chan { font-family: var(--mono); font-size: 9.5px; color: var(--amber); }
.f-time { font-family: var(--mono); font-size: 9.5px; color: var(--text-faint); }
.f-text { font-size: 11.5px; line-height: 1.45; color: var(--text-dim); white-space: pre-wrap; }

/* ціль у списку */
.t-item.launch {
  background: rgba(255, 45, 85, 0.07);
  box-shadow: inset 3px 0 0 var(--red);
}
.t-meta span { white-space: nowrap; }

/* позначка цілі на мапі */
.ct-icon { position: relative; width: 20px; height: 20px; display: grid; place-items: center; }
.ct-rot { transform-origin: 50% 50%; line-height: 0; }
.ct-icon svg { display: block; filter: drop-shadow(0 0 4px currentColor); }
.ct-icon.launch { animation: ct-pulse 1.6s ease-in-out infinite; }
.ct-icon.impact { animation: ct-impact 2s ease-out infinite; }
@keyframes ct-pulse { 50% { transform: scale(1.35); } }
@keyframes ct-impact { 0% { transform: scale(1); } 40% { transform: scale(1.5); opacity: 0.6; } 100% { transform: scale(1); } }
.tk-count {
  position: absolute;
  top: -5px;
  right: -7px;
  min-width: 13px;
  padding: 0 3px;
  border-radius: 7px;
  background: #0b0f14;
  border: 1px solid currentColor;
  font-family: var(--mono);
  font-size: 8.5px;
  line-height: 12px;
  text-align: center;
}

/* цитата з каналу */
.pp-quote {
  margin-top: 7px;
  padding: 6px 8px;
  border-left: 2px solid var(--line);
  background: #0b1119;
  border-radius: 0 4px 4px 0;
  font-size: 10.5px;
  line-height: 1.45;
  color: var(--text-dim);
  font-style: italic;
}
.leaflet-popup-content a { color: var(--amber); }

/* таблиця часу підльоту */
table.reach {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--mono);
  font-size: 10.5px;
}
table.reach th {
  text-align: left;
  font-weight: 500;
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-faint);
  padding: 4px 6px;
  border-bottom: 1px solid var(--line);
}
table.reach td {
  padding: 4px 6px;
  border-bottom: 1px solid var(--line-soft);
  color: var(--text-dim);
}
table.reach td:first-child { color: var(--text); font-family: var(--sans); font-size: 11.5px; }
table.reach td b { color: var(--amber); }
table.reach tr.passed td { opacity: 0.45; }
table.reach .reached { color: var(--red); font-size: 9.5px; }

/* ─────────── рівні тривоги ─────────── */

.sw.red { background: rgba(255, 45, 85, 0.55); border: 1px solid #ff2d55; }
.sw.yellow { background: rgba(255, 157, 0, 0.5); border: 1px solid #ff9d00; }

/* червоний рівень пульсує помітніше за жовтий */
path.ob-red { animation: ob-pulse-red 1.8s ease-in-out infinite; }
@keyframes ob-pulse-red {
  0%, 100% { fill-opacity: 0.24; }
  50%      { fill-opacity: 0.46; }
}
path.ob-yellow { animation: ob-pulse 3s ease-in-out infinite; }

/* райони в тривозі */
path.raion-on { transition: fill-opacity 0.4s; }
path.raion-red { animation: ob-pulse-red 1.8s ease-in-out infinite; }

/* зовнішні агрегатори */
.src-chip.ext { border-color: #3a5170; color: #9db6d4; background: rgba(56, 189, 248, 0.07); }
.badge.ext-badge { color: #38bdf8; border-color: rgba(56, 189, 248, 0.5); font-size: 8.5px; }

/* прогноз по курсу в списку цілей */
.t-region.has-next { color: var(--text); }
.t-region.has-next::before { content: '▸ '; color: var(--amber); }

/* область, у якій промальовані райони, не пульсує:
   інакше миготить і заливка, і деталь поверх неї */
path.ob-muted { animation: none; }

/* підписи міст за рангом і зумом: на дрібному масштабі лишаються
   тільки мільйонники, при наближенні проступають менші */
.city-label.r2, .city-label.r3, .city-label.r4 { display: none; }
body[data-z="2"] .city-label.r2 { display: block; }
body[data-z="3"] .city-label.r2,
body[data-z="3"] .city-label.r3 { display: block; }
body[data-z="4"] .city-label.r2,
body[data-z="4"] .city-label.r3,
body[data-z="4"] .city-label.r4 { display: block; }
.city-label.r3 { font-size: 9.5px; color: #9fb0c4; }
.city-label.r4 { font-size: 9px; color: #8494a8; }

/* Детальна підкладка OSM: тайли світлі, тож інвертуємо їх у темну
   схему, інакше вони засвічують усю мапу. */
.detail-tiles {
  filter: invert(1) hue-rotate(180deg) brightness(0.78) contrast(0.92) saturate(0.55);
}

/* ─────────── ціль на мапі: ореол, пульс, слід ─────────── */

.ct-icon { position: relative; width: 20px; height: 20px; display: grid; place-items: center; }

/* мʼякий ореол — позначка читається поверх штриховки */
.ct-halo {
  position: absolute;
  inset: -7px;
  border-radius: 50%;
  background: radial-gradient(circle, currentColor 0%, transparent 68%);
  opacity: 0.3;
  pointer-events: none;
}

/* щойно доповіли — коротка пульсація */
.ct-icon.fresh::after {
  content: '';
  position: absolute;
  inset: -4px;
  border: 1.5px solid currentColor;
  border-radius: 50%;
  animation: ct-ping 1.6s ease-out infinite;
  pointer-events: none;
}
@keyframes ct-ping {
  0%   { transform: scale(0.6); opacity: 0.9; }
  100% { transform: scale(2.2); opacity: 0; }
}

.ct-trail { filter: drop-shadow(0 0 3px currentColor); }
.ct-icon svg { display: block; filter: drop-shadow(0 0 5px currentColor) drop-shadow(0 0 1px #000); }

/* межі областей у тривозі трохи світяться */
path.ob-on { filter: drop-shadow(0 0 3px currentColor); }

/* підписи міст: щільніший контур, щоб читались поверх штриховки */
.city-label {
  text-shadow: 0 0 3px #000, 0 0 6px #000, 0 1px 2px #000;
  font-weight: 500;
}
.oblast-label { text-shadow: 0 0 4px #000, 0 0 9px #000; }

/* ─────────── збиття ─────────── */

.ix-mark {
  position: relative;
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  color: var(--green);
}
.ix-mark i {
  position: absolute;
  inset: 0;
  border: 1.5px solid currentColor;
  border-radius: 50%;
  opacity: 0.55;
  background: radial-gradient(circle, rgba(0, 229, 160, 0.25), transparent 70%);
}
.ix-mark b {
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
  text-shadow: 0 0 5px currentColor, 0 0 2px #000;
}
.ix-mark u {
  position: absolute;
  top: -5px;
  right: -6px;
  min-width: 13px;
  padding: 0 3px;
  border-radius: 7px;
  background: #07090d;
  border: 1px solid currentColor;
  font-family: var(--mono);
  font-size: 8.5px;
  line-height: 12px;
  text-align: center;
  text-decoration: none;
}
#kpiPop.kill b { color: var(--green); }

/* підпис, який не вмістився поруч із сусідами */
.city-label.crowded, .oblast-label.crowded { display: none; }

/* ─────────── стеження за своїм містом ─────────── */

.watch-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--line);
  font-size: 12px;
  background: #0d1520;
}
.watch-bar b { font-weight: 600; }
.watch-bar span { color: var(--text-dim); font-size: 11px; }
.watch-bar u { margin-left: auto; font-family: var(--mono); font-weight: 700; text-decoration: none; }
.watch-bar i { font-family: var(--mono); font-size: 10px; color: var(--text-faint); font-style: normal; }
.watch-bar.calm { border-left: 3px solid var(--green); }
.watch-bar.calm b { color: var(--green); }
.watch-bar.alarm {
  border-left: 3px solid var(--red);
  background: rgba(255, 45, 85, 0.1);
  animation: blink 1.6s steps(2) infinite;
}
.watch-bar.alarm u { color: var(--red); }
.watch-off {
  background: none;
  border: 0;
  color: var(--text-faint);
  font-size: 15px;
  line-height: 1;
  padding: 0 2px;
}
.watch-off:hover { color: var(--text); }

.watch-ring {
  width: 26px;
  height: 26px;
  border: 2px solid var(--green);
  border-radius: 50%;
  box-shadow: 0 0 10px rgba(0, 229, 160, 0.6);
  animation: watch-pulse 2.4s ease-in-out infinite;
}
@keyframes watch-pulse { 50% { transform: scale(1.18); opacity: 0.6; } }

.pp-watch {
  margin-top: 8px;
  width: 100%;
  background: #17222f;
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 6px;
  font-size: 11.5px;
  color: var(--green);
}
.pp-watch:hover { background: #1e2c3c; }

.r-item.city-hit { background: rgba(56, 189, 248, 0.05); }
.r-item.city-hit .r-dot { background: var(--blue); }
.r-item.city-hit .r-time { color: var(--blue); font-size: 10px; }

/* ─────────── оцінка обстановки від моделі ─────────── */

.ai-box {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(56, 189, 248, 0.06), transparent);
  border-left: 3px solid var(--blue);
}
.ai-head {
  display: flex;
  align-items: baseline;
  gap: 6px;
  font-size: 9.5px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--blue);
  margin-bottom: 6px;
}
.ai-head i { font-style: normal; color: var(--text-faint); text-transform: none; letter-spacing: 0; }
.ai-head span { margin-left: auto; font-family: var(--mono); color: var(--text-faint); }
.ai-text { font-size: 11.5px; line-height: 1.5; color: var(--text-dim); }
.ai-wait { font-size: 11px; color: var(--text-faint); }
.ai-targets { list-style: none; margin: 8px 0 0; padding: 0; }
.ai-targets li {
  display: flex;
  gap: 6px;
  align-items: baseline;
  font-size: 11px;
  padding: 3px 0;
  border-top: 1px solid var(--line-soft);
}
.ai-targets b { color: var(--text); }
.ai-targets span { margin-left: auto; color: var(--text-faint); font-size: 10px; text-align: right; }
.ai-note { margin-top: 8px; font-size: 9.5px; line-height: 1.45; color: var(--text-faint); }

/* ─────────── смуга «немає звʼязку з сервером» ─────────── */

/* Раніше тут була модалка на весь екран — вона закривала мапу, і
   здавалося, що карти немає взагалі. Тепер мапа видно одразу, а
   питання про адресу сервера стоїть смугою знизу. */
.srv-bar {
  position: fixed;
  left: 50%;
  bottom: 14px;
  transform: translateX(-50%);
  z-index: 8000;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  max-width: calc(100% - 24px);
  padding: 9px 12px;
  background: rgba(12, 16, 23, 0.97);
  border: 1px solid var(--line);
  border-left: 3px solid var(--amber);
  border-radius: 8px;
  box-shadow: var(--sh);
  backdrop-filter: blur(10px);
  font-size: 11.5px;
}
.srv-txt { color: var(--text-dim); line-height: 1.45; }
.srv-txt b { color: var(--amber); }
.srv-bar code { font-family: var(--mono); font-size: 10.5px; color: var(--text); }
.srv-bar input {
  background: #0b1119;
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 6px 9px;
  color: var(--text);
  font-family: var(--mono);
  font-size: 11.5px;
  width: 190px;
  outline: none;
}
.srv-bar input:focus { border-color: var(--amber); }
.srv-bar #srvSave {
  background: var(--amber);
  color: #0b0f14;
  border: 0;
  border-radius: 5px;
  padding: 7px 12px;
  font-size: 11.5px;
  font-weight: 600;
}
.srv-hide {
  background: none;
  border: 0;
  color: var(--text-faint);
  font-size: 16px;
  line-height: 1;
  padding: 0 2px;
}
@media (max-width: 900px) {
  .srv-bar { bottom: 58px; font-size: 10.5px; }
  .srv-bar input { width: 140px; }
}

/* смуга «дані зі знімка, не в реальному часі» */
.static-note {
  position: fixed;
  left: 50%;
  bottom: 14px;
  transform: translateX(-50%);
  z-index: 7900;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px;
  background: rgba(12, 16, 23, 0.95);
  border: 1px solid var(--line);
  border-left: 3px solid var(--blue);
  border-radius: 8px;
  font-size: 11px;
  color: var(--text-dim);
  backdrop-filter: blur(9px);
  box-shadow: var(--sh);
}
.static-note b { color: var(--blue); }
.static-note button {
  background: #17222f;
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 4px 9px;
  font-size: 10.5px;
  color: var(--text);
}
@media (max-width: 900px) { .static-note { bottom: 58px; font-size: 10px; } }
.static-note .sn-wake { color: var(--text-faint); font-size: 10px; }
