:root {
  --bg: #0f1a2b;
  --panel: #16243a;
  --panel-2: #1e3050;
  --line: #2c4466;
  --text: #f2efe6;
  --muted: #9fb3c8;
  --accent: #f28c28;
  --blue: #4c9be8;
  --danger: #e5484d;
  --safe-b: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text);
  font: 15px/1.35 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif; overflow: hidden; }
button { font: inherit; color: inherit; cursor: pointer; }

#map { position: fixed; inset: 0; background: #0b1320; }
.leaflet-container { font: inherit; background: #0b1320; }

/* Верхняя панель */
.topbar { position: fixed; top: 0; left: 0; right: 0; z-index: 1000; display: flex; align-items: center;
  justify-content: space-between; gap: 8px; padding: 10px 12px 6px; background: linear-gradient(var(--bg) 70%, transparent); }
.brand { display: flex; align-items: center; gap: 8px; font-size: 16px; }
.live { width: 10px; height: 10px; border-radius: 50%; background: var(--muted); box-shadow: 0 0 0 3px rgba(159,179,200,.2); }
.live.on { background: #3ccf7a; box-shadow: 0 0 0 3px rgba(60,207,122,.25); }
.live.off { background: var(--danger); box-shadow: 0 0 0 3px rgba(229,72,77,.25); }
.chip { border: 1px solid var(--line); background: var(--panel); border-radius: 999px; padding: 5px 12px; font-size: 13px;
  max-width: 55%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Поиск */
.search { position: fixed; top: 44px; left: 12px; right: 12px; z-index: 1000; }
.search input { width: 100%; padding: 11px 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--panel);
  color: var(--text); font-size: 16px; outline: none; }
.search input:focus { border-color: var(--blue); }
.results { list-style: none; margin: 6px 0 0; padding: 4px; background: var(--panel); border: 1px solid var(--line);
  border-radius: 12px; max-height: 50vh; overflow: auto; }
.results li { padding: 10px; border-radius: 8px; display: flex; justify-content: space-between; gap: 8px; }
.results li:active, .results li:hover { background: var(--panel-2); }
.results small { color: var(--muted); }

/* Подписи населённых пунктов */
.place-label { color: #dfe7f0; font-size: 11px; white-space: nowrap; text-shadow: 0 0 3px #0b1320, 0 0 3px #0b1320, 0 0 2px #0b1320;
  pointer-events: none; transform: translate(6px, -7px); }
.place-label.city { font-size: 14px; font-weight: 700; color: #fff; }
.place-label.town { font-size: 12px; font-weight: 600; }

/* Цели */
.target-icon { display: flex; align-items: center; justify-content: center; width: 34px; height: 34px; border-radius: 50%;
  font-weight: 800; font-size: 13px; color: #fff; border: 2px solid #fff; box-shadow: 0 0 0 4px rgba(0,0,0,.25);
  animation: pulse 1.6s infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(242,140,40,.55); } 70% { box-shadow: 0 0 0 14px rgba(242,140,40,0); } 100% { box-shadow: 0 0 0 0 rgba(242,140,40,0); } }
.arrow-head { width: 0; height: 0; border-left: 9px solid transparent; border-right: 9px solid transparent;
  border-bottom: 18px solid var(--accent); transform-origin: 50% 50%; }
.pin-icon { width: 14px; height: 14px; border-radius: 50%; background: var(--blue); border: 2px solid #fff; }

.leaflet-popup-content-wrapper, .leaflet-popup-tip { background: var(--panel); color: var(--text); }
.leaflet-popup-content { margin: 12px 14px; min-width: 200px; }
.pop h4 { margin: 0 0 4px; font-size: 16px; }
.pop p { margin: 2px 0; color: var(--muted); }
.pop .row { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }
.pop button { border: 1px solid var(--line); background: var(--panel-2); border-radius: 8px; padding: 6px 10px; font-size: 13px; }
.pop button.danger { border-color: var(--danger); color: #ffb4b6; }
.pop button.primary { background: var(--blue); border-color: var(--blue); color: #fff; }

/* Лента событий */
.feed { position: fixed; left: 0; right: 0; bottom: 0; z-index: 1000; background: var(--panel); border-top: 1px solid var(--line);
  border-radius: 16px 16px 0 0; padding-bottom: var(--safe-b); max-height: 48vh; display: flex; flex-direction: column; }
.feed-head { border: 0; background: none; padding: 8px 16px 12px; display: flex; flex-direction: column; align-items: center; gap: 8px; font-weight: 600; }
.grip { width: 36px; height: 4px; border-radius: 2px; background: var(--line); }
.feed-list { list-style: none; margin: 0; padding: 0 12px 12px; overflow: auto; display: none; }
.feed.open .feed-list { display: block; }
.feed-list li { display: flex; gap: 10px; align-items: center; padding: 10px 4px; border-top: 1px solid var(--line); }
.feed-list .badge { flex: none; width: 30px; height: 30px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 12px; color: #fff; }
.feed-list .meta { color: var(--muted); font-size: 13px; }

/* Кнопки админа */
.fab { position: fixed; right: 16px; bottom: calc(80px + var(--safe-b)); z-index: 1001; width: 58px; height: 58px; border-radius: 50%;
  border: 0; background: var(--accent); color: #1a1205; font-size: 30px; line-height: 1; box-shadow: 0 6px 18px rgba(0,0,0,.4); }
.hint { position: fixed; top: 100px; left: 12px; right: 12px; z-index: 1002; background: var(--accent); color: #1a1205;
  border-radius: 12px; padding: 10px 12px; display: flex; align-items: center; justify-content: space-between; gap: 8px; font-weight: 600; }
.hint button { border: 0; background: rgba(0,0,0,.15); border-radius: 8px; padding: 6px 10px; }

.sheet { position: fixed; inset: 0; z-index: 1003; background: rgba(5,10,18,.55); display: flex; align-items: flex-end; }
.sheet-card { width: 100%; background: var(--panel); border-radius: 18px 18px 0 0; padding: 16px 16px calc(16px + var(--safe-b)); }
.sheet-card h3 { margin: 0 0 12px; }
.type-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.type-grid button { border: 2px solid var(--line); background: var(--panel-2); border-radius: 12px; padding: 10px 4px; display: flex;
  flex-direction: column; align-items: center; gap: 6px; font-size: 13px; }
.type-grid button.sel { border-color: var(--accent); }
.type-grid .badge { width: 28px; height: 28px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 12px; color: #fff; }
.sheet-card input { width: 100%; margin: 12px 0; padding: 11px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg); color: var(--text); font-size: 16px; }
.sheet-actions { display: flex; gap: 8px; }
.btn { flex: 1; border-radius: 12px; padding: 12px; border: 1px solid var(--line); background: var(--panel-2); font-weight: 600; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #1a1205; }
.btn.link { width: 100%; margin-top: 8px; border: 0; background: none; color: var(--muted); }
.btn:disabled { opacity: .45; }

.toast { position: fixed; left: 50%; top: 100px; transform: translateX(-50%); z-index: 1004; background: #000c; color: #fff;
  padding: 10px 14px; border-radius: 10px; max-width: 90vw; text-align: center; }

.leaflet-control-attribution { font-size: 10px; background: rgba(15,26,43,.7) !important; color: var(--muted); }
.leaflet-control-attribution a { color: var(--muted); }

/* Атрибуция и кнопки Leaflet — над лентой событий */
.leaflet-bottom { bottom: calc(52px + var(--safe-b)); }
[hidden] { display: none !important; }

/* Назви районів */
.district-label { color: #9fb3c8; font-size: 12px; font-weight: 700; letter-spacing: 1.5px; text-transform: uppercase; white-space: nowrap;
  text-shadow: 0 0 3px #0b1320, 0 0 3px #0b1320; pointer-events: none; transform: translate(-50%, -50%); opacity: .9; }

/* Светлая карта (OpenStreetMap): тёмные подписи с белой обводкой */
body.map-light #map, body.map-light .leaflet-container { background: #f2efe9; }
body.map-light .place-label { color: #1f2d3d; text-shadow: 0 0 3px #fff, 0 0 3px #fff, 0 0 2px #fff; }
body.map-light .place-label.city { color: #0f1a2b; }
body.map-light .district-label { color: #3d4f63; text-shadow: 0 0 3px #fff, 0 0 3px #fff, 0 0 2px #fff; }

/* Значки целей (силуэты) */
.target-icon { width: 38px; height: 38px; font-size: 0; }
.target-icon svg, .badge svg { display: block; transition: transform .3s; filter: drop-shadow(0 1px 1px rgba(0,0,0,.35)); }
.badge { display: inline-flex; align-items: center; justify-content: center; border-radius: 50%; flex: none; }
.feed-list .badge, .type-grid .badge { font-size: 0; }

/* Скорость */
.speed-field { display: flex; align-items: center; gap: 8px; margin: -4px 0 12px; color: var(--muted); font-size: 14px; flex-wrap: wrap; }
.speed-field input { width: 110px; margin: 0; padding: 9px 10px; }
.speed-field small { width: 100%; font-size: 12px; }
.pop .speed-row { align-items: center; color: var(--muted); font-size: 13px; }
.pop .speed-input { width: 80px; padding: 5px 8px; border-radius: 8px; border: 1px solid var(--line); background: var(--bg); color: var(--text); font-size: 14px; }

/* ── Ціль йде на удар ── */
.target-wrap { position: relative; width: 38px; height: 38px; }
.target-icon.attack { border-color: #e03131; border-width: 3px; animation: strike-pulse .7s infinite; }
@keyframes strike-pulse { 0% { box-shadow: 0 0 0 0 rgba(224,49,49,.85); } 100% { box-shadow: 0 0 0 18px rgba(224,49,49,0); } }
.strike-ring { position: absolute; left: 50%; top: 50%; width: 76px; height: 76px; margin: -38px 0 0 -38px; border-radius: 50%;
  border: 3px solid #e03131; animation: strike-ring 1.1s ease-out infinite; pointer-events: none; }
@keyframes strike-ring { 0% { transform: scale(.45); opacity: 1; } 100% { transform: scale(1.25); opacity: 0; } }
.strike-tag { position: absolute; left: 50%; bottom: 44px; transform: translateX(-50%); background: #e03131; color: #fff;
  font-size: 11px; font-weight: 800; letter-spacing: 1px; padding: 2px 6px; border-radius: 6px; white-space: nowrap;
  box-shadow: 0 2px 6px rgba(0,0,0,.35); animation: strike-blink 1s steps(2, start) infinite; }
@keyframes strike-blink { to { opacity: .55; } }
.pop .strike-line { color: #ff8787; font-weight: 700; }
.feed-list li.attack { background: rgba(224,49,49,.14); border-radius: 10px; border-top-color: transparent; padding-left: 8px; }
.feed.has-strike { border-top: 3px solid #e03131; }
.feed.has-strike .feed-head { color: #ff8787; }
.strike-toggle { display: flex; align-items: center; gap: 10px; margin: 0 0 12px; padding: 10px 12px; border-radius: 10px;
  border: 1px solid #e03131; color: #ffb4b6; font-weight: 600; }
.strike-toggle input { width: 20px; height: 20px; margin: 0; accent-color: #e03131; }
@media (prefers-reduced-motion: reduce) { .strike-ring, .strike-tag, .target-icon.attack { animation: none; } }
