/* Карта шахедів — dark, map-first. */
:root {
  --bg: #0B1020;
  --bg2: #111830;
  --card: rgba(17, 24, 48, .86);
  --card-solid: #131B35;
  --line: rgba(255, 255, 255, .09);
  --line2: rgba(255, 255, 255, .16);
  --text: #EEF2FF;
  --muted: #9AA6C8;
  --dim: #6B7699;
  --accent: #4CC3FF;
  --ok: #2FD27E;
  --warn: #FFB020;
  --danger: #FF3B47;
  --uav: #FF8A1F;
  --recon: #4CC3FF;
  --missile: #FF3B47;
  --ballistic: #E040FB;
  --kab: #FFD60A;
  --mig: #B388FF;
  --unknown: #B0BEC5;
  --r: 16px;
  --tab-h: 64px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  color-scheme: dark;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font: 15px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; overflow: hidden; }
button { font: inherit; color: inherit; cursor: pointer; }
input, select { font: inherit; color: var(--text); }
a { color: var(--accent); }
h2, h3 { margin: 0; font-weight: 650; letter-spacing: -.01em; }
[hidden] { display: none !important; }

#app { position: fixed; inset: 0; }
.map { position: absolute; inset: 0; background: #0A0F1C; }
.leaflet-container { background: #0A0F1C; font: inherit; }
.leaflet-control-attribution { display: none; }
.leaflet-control-zoom { display: none; }

/* ---------- top status card ---------- */
.top { position: absolute; z-index: 600; top: calc(10px + var(--safe-t)); left: 10px; right: 10px; pointer-events: none; display: flex; flex-direction: column; gap: 6px; align-items: stretch; }
.status { pointer-events: auto; background: var(--card); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); border: 1px solid var(--line); border-radius: var(--r); padding: 10px 12px; box-shadow: 0 10px 30px rgba(0,0,0,.35); max-width: 560px; }
.status.alert { border-color: rgba(255, 59, 71, .55); box-shadow: 0 0 0 1px rgba(255,59,71,.25), 0 10px 40px rgba(255, 59, 71, .25); }
.status.danger { border-color: rgba(255, 59, 71, .9); animation: glow 1.4s ease-in-out infinite; }
.status.watch { border-color: rgba(255, 176, 32, .5); }
@keyframes glow { 50% { box-shadow: 0 0 0 2px rgba(255,59,71,.6), 0 10px 50px rgba(255,59,71,.45); } }
.st-row { display: flex; align-items: center; gap: 10px; }
.st-place { display: flex; align-items: center; gap: 6px; background: none; border: 0; padding: 0; font-weight: 650; font-size: 16px; min-width: 0; }
.st-place span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.st-place .chev { color: var(--muted); font-size: 12px; }
.st-sub { color: var(--muted); font-size: 12.5px; }
.pill { display: inline-flex; align-items: center; gap: 6px; border-radius: 999px; padding: 4px 10px; font-weight: 700; font-size: 12.5px; letter-spacing: .02em; white-space: nowrap; margin-left: auto; }
.pill.calm { background: rgba(47, 210, 126, .14); color: var(--ok); }
.pill.watch { background: rgba(255, 176, 32, .16); color: var(--warn); }
.pill.alert { background: var(--danger); color: #fff; }
.pill.danger { background: var(--danger); color: #fff; animation: blink 1s steps(2, start) infinite; }
@keyframes blink { 50% { opacity: .55; } }
.pill .dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.near { margin-top: 8px; display: flex; flex-direction: column; gap: 4px; }
.near-item { display: flex; align-items: center; gap: 8px; background: rgba(255,255,255,.04); border: 1px solid var(--line); border-radius: 12px; padding: 6px 8px; text-align: left; width: 100%; }
.near-item .ti { width: 26px; height: 26px; flex: none; }
.near-item b { font-weight: 650; }
.near-item .km { margin-left: auto; font-variant-numeric: tabular-nums; font-weight: 700; white-space: nowrap; }
.near-item .km.hot { color: var(--danger); }
.near-item small { color: var(--muted); display: block; font-size: 12px; }
.near-more { color: var(--muted); font-size: 12.5px; background: none; border: 0; padding: 2px 0 0; text-align: left; }
.offline { pointer-events: auto; align-self: flex-start; background: rgba(255,176,32,.16); color: var(--warn); border: 1px solid rgba(255,176,32,.35); border-radius: 10px; padding: 5px 10px; font-size: 12.5px; backdrop-filter: blur(10px); }

/* ---------- floating buttons ---------- */
.fabs { position: absolute; z-index: 600; right: 10px; bottom: calc(var(--tab-h) + 52px + var(--safe-b)); display: flex; flex-direction: column; gap: 8px; }
.fab { width: 44px; height: 44px; border-radius: 14px; border: 1px solid var(--line2); background: var(--card); backdrop-filter: blur(12px); display: grid; place-items: center; box-shadow: 0 6px 18px rgba(0,0,0,.35); }
.fab svg { width: 22px; height: 22px; stroke: var(--text); stroke-width: 2; stroke-linecap: round; fill: var(--text); }
.fab svg [fill="none"], .fab svg path { fill: none; }
.fab svg circle[r="3.2"] { fill: var(--text); }
.fab.on { border-color: var(--accent); }
.fab.on svg { stroke: var(--accent); }
.fab.off svg { stroke: var(--dim); }

/* ---------- bottom tabs ---------- */
.tabbar { position: absolute; z-index: 700; left: 0; right: 0; bottom: 0; height: calc(var(--tab-h) + var(--safe-b)); padding-bottom: var(--safe-b); display: flex; background: rgba(11, 16, 32, .94); backdrop-filter: blur(14px); border-top: 1px solid var(--line); }
.tab { flex: 1; border: 0; background: none; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; color: var(--dim); font-size: 11.5px; font-weight: 600; position: relative; }
.tab svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.tab.on { color: var(--text); }
.tab.on::before { content: ""; position: absolute; top: 0; left: 30%; right: 30%; height: 3px; border-radius: 0 0 3px 3px; background: var(--accent); }
.tab .badge { position: absolute; top: 8px; left: 54%; min-width: 16px; height: 16px; border-radius: 8px; background: var(--danger); color: #fff; font-size: 10px; line-height: 16px; padding: 0 4px; }

.credit { position: absolute; z-index: 600; left: 10px; bottom: calc(var(--tab-h) + 8px + var(--safe-b)); font-size: 10.5px; color: var(--muted); background: rgba(11,16,32,.7); border-radius: 8px; padding: 3px 7px; max-width: calc(100% - 80px); }
.credit a { color: var(--muted); }

/* ---------- panels (events, places, settings, admin) ---------- */
.panel { position: absolute; z-index: 650; left: 0; right: 0; top: 0; bottom: calc(var(--tab-h) + var(--safe-b)); background: var(--bg); display: flex; flex-direction: column; padding-top: var(--safe-t); }
.panel-head { display: flex; align-items: center; padding: 16px 16px 8px; gap: 10px; }
.panel-head h2 { font-size: 22px; flex: 1; }
.x { border: 0; background: rgba(255,255,255,.06); border-radius: 10px; width: 36px; height: 36px; }
.panel-body { overflow-y: auto; padding: 4px 16px 24px; flex: 1; -webkit-overflow-scrolling: touch; }
.card { background: var(--card-solid); border: 1px solid var(--line); border-radius: var(--r); padding: 14px; margin-bottom: 12px; }
.card h3 { font-size: 15px; margin-bottom: 8px; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.row { display: flex; align-items: center; gap: 10px; }
.row + .row { margin-top: 10px; }
.grow { flex: 1; min-width: 0; }
.btn { border: 1px solid var(--line2); background: rgba(255,255,255,.05); border-radius: 12px; padding: 10px 14px; font-weight: 600; display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #04121D; }
.btn.danger { background: rgba(255,59,71,.12); border-color: rgba(255,59,71,.45); color: #FF7A82; }
.btn.block { width: 100%; }
.btn.sm { padding: 6px 10px; font-size: 13px; border-radius: 10px; }
.btn:disabled { opacity: .5; }
.field { display: block; margin-bottom: 10px; }
.field > span { display: block; color: var(--muted); font-size: 12.5px; margin-bottom: 4px; }
.input { width: 100%; background: rgba(255,255,255,.05); border: 1px solid var(--line2); border-radius: 12px; padding: 11px 12px; outline: none; }
.input:focus { border-color: var(--accent); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { border: 1px solid var(--line2); background: rgba(255,255,255,.04); border-radius: 999px; padding: 6px 12px; font-size: 13px; font-weight: 600; }
.chip.on { background: var(--accent); border-color: var(--accent); color: #04121D; }
.switch { position: relative; width: 46px; height: 28px; flex: none; }
.switch input { opacity: 0; position: absolute; inset: 0; margin: 0; cursor: pointer; }
.switch i { position: absolute; inset: 0; border-radius: 14px; background: rgba(255,255,255,.14); transition: .15s; pointer-events: none; }
.switch i::after { content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; transition: .15s; }
.switch input:checked + i { background: var(--ok); }
.switch input:checked + i::after { transform: translateX(18px); }
.trow { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-top: 1px solid var(--line); }
.trow:first-of-type { border-top: 0; }
.trow .ti { width: 28px; height: 28px; flex: none; }

/* events */
.ev { display: flex; gap: 10px; padding: 10px 0; border-top: 1px solid var(--line); }
.ev:first-child { border-top: 0; }
.ev .ti { width: 30px; height: 30px; flex: none; }
.ev time { color: var(--muted); font-variant-numeric: tabular-nums; font-size: 12.5px; white-space: nowrap; }
.ev .t { font-weight: 600; }
.ev .s { color: var(--muted); font-size: 13px; }
.ev.alert .t { color: #FF7A82; }
.ev.clear .t { color: var(--ok); }
.ev button { background: none; border: 0; padding: 0; text-align: left; }
.seg { display: inline-flex; background: rgba(255,255,255,.05); border: 1px solid var(--line); border-radius: 12px; padding: 3px; margin-bottom: 12px; }
.seg button { border: 0; background: none; padding: 6px 12px; border-radius: 9px; font-weight: 600; font-size: 13px; color: var(--muted); }
.seg button.on { background: rgba(255,255,255,.1); color: var(--text); }

/* places */
.place { display: flex; align-items: center; gap: 10px; }
.place .pin { width: 36px; height: 36px; border-radius: 12px; display: grid; place-items: center; background: rgba(76,195,255,.12); color: var(--accent); flex: none; font-size: 18px; }
.place .st { font-size: 12.5px; }

/* ---------- modal & sheet ---------- */
.modal { position: fixed; inset: 0; z-index: 900; background: rgba(4, 7, 16, .66); display: flex; align-items: flex-end; justify-content: center; backdrop-filter: blur(3px); }
.modal-box { background: var(--card-solid); border: 1px solid var(--line2); border-radius: 22px 22px 0 0; width: 100%; max-width: 520px; max-height: 92vh; overflow-y: auto; padding: 18px 16px calc(18px + var(--safe-b)); box-shadow: 0 -20px 60px rgba(0,0,0,.5); }
.modal-box h2 { font-size: 20px; margin-bottom: 4px; }
.modal-box .lead { color: var(--muted); margin: 0 0 14px; }
.results { max-height: 42vh; overflow-y: auto; margin: 6px -4px 10px; }
.res { display: block; width: 100%; text-align: left; border: 0; background: none; padding: 9px 8px; border-radius: 10px; }
.res:hover, .res:focus { background: rgba(255,255,255,.06); outline: none; }
.res b { font-weight: 650; }
.res small { display: block; color: var(--muted); font-size: 12px; }
.picked { background: rgba(76,195,255,.1); border: 1px solid rgba(76,195,255,.4); border-radius: 12px; padding: 10px 12px; margin: 8px 0 12px; }
.or { text-align: center; color: var(--dim); font-size: 12px; margin: 8px 0; }

.sheet { position: fixed; z-index: 800; left: 10px; right: 10px; bottom: calc(var(--tab-h) + 10px + var(--safe-b)); background: var(--card-solid); border: 1px solid var(--line2); border-radius: 18px; padding: 14px; box-shadow: 0 16px 50px rgba(0,0,0,.55); max-width: 520px; margin: 0 auto; }
.sheet .hd { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.sheet .ti { width: 40px; height: 40px; flex: none; }
.sheet h3 { font-size: 17px; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; font-size: 13.5px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
.note { font-size: 12px; color: var(--dim); margin-top: 8px; }

/* ---------- welcome ---------- */
.welcome h1 { font-size: 24px; margin: 4px 0 6px; letter-spacing: -.02em; }
.welcome .logo { width: 56px; height: 56px; }
.welcome ul { margin: 10px 0 16px; padding-left: 18px; color: var(--muted); }
.welcome li { margin: 3px 0; }
.stack { display: flex; flex-direction: column; gap: 8px; }
.linkbtn { background: none; border: 0; color: var(--accent); padding: 6px; font-weight: 600; }

/* ---------- siren overlay ---------- */
.siren { position: fixed; inset: 0; z-index: 1000; display: flex; align-items: center; justify-content: center; flex-direction: column; gap: 16px; padding: 24px; text-align: center; background: radial-gradient(circle at center, rgba(255,59,71,.55), rgba(120,0,10,.92)); animation: sirenbg 1s ease-in-out infinite; }
@keyframes sirenbg { 50% { background: radial-gradient(circle at center, rgba(255,59,71,.25), rgba(60,0,6,.95)); } }
.siren .big { font-size: 34px; font-weight: 800; letter-spacing: .02em; }
.siren .sub { font-size: 18px; max-width: 420px; }
.siren .btn { background: #fff; color: #7A0010; border: 0; font-size: 17px; padding: 14px 26px; border-radius: 16px; }

.toast { position: fixed; z-index: 1100; left: 50%; bottom: calc(var(--tab-h) + 20px + var(--safe-b)); transform: translate(-50%, 30px); opacity: 0; transition: .2s; background: #fff; color: #0B1020; border-radius: 12px; padding: 10px 14px; font-weight: 600; pointer-events: none; max-width: 90vw; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.err { background: #FF5A64; color: #fff; }

/* ---------- map markers ---------- */
.thr { position: relative; width: 44px; height: 44px; }
.thr .rot { position: absolute; inset: 0; display: grid; place-items: center; transition: transform .6s; }
.thr svg { width: 34px; height: 34px; filter: drop-shadow(0 0 6px var(--c)) drop-shadow(0 1px 2px rgba(0,0,0,.8)); }
.thr .cnt { position: absolute; right: -4px; top: -4px; min-width: 18px; height: 18px; border-radius: 9px; background: #fff; color: #000; font-size: 11px; font-weight: 800; line-height: 18px; text-align: center; padding: 0 4px; }
.thr .lbl { position: absolute; top: 42px; left: 50%; transform: translateX(-50%); white-space: nowrap; font-size: 11px; font-weight: 700; color: #fff; background: rgba(0,0,0,.55); border-radius: 6px; padding: 1px 5px; }
.thr.hot::before { content: ""; position: absolute; inset: -6px; border-radius: 50%; border: 2px solid var(--c); animation: ping 1.4s ease-out infinite; }
.thr.stale svg { opacity: .55; }
.thr.sel svg { filter: drop-shadow(0 0 10px #fff) drop-shadow(0 0 4px var(--c)); }
@keyframes ping { from { transform: scale(.6); opacity: 1; } to { transform: scale(1.6); opacity: 0; } }
.me { position: relative; width: 22px; height: 22px; }
.me i { position: absolute; inset: 5px; border-radius: 50%; background: var(--accent); border: 2px solid #fff; box-shadow: 0 0 10px var(--accent); }
.me::after { content: ""; position: absolute; inset: 0; border-radius: 50%; background: var(--accent); opacity: .35; animation: ping 2s ease-out infinite; }
.me-lbl { color: #fff; font-weight: 700; font-size: 12px; text-shadow: 0 1px 3px #000, 0 0 6px #000; white-space: nowrap; }
path.alert-red { animation: pulse-red 1.6s ease-in-out infinite; }
@keyframes pulse-red { 50% { fill-opacity: .1; stroke-opacity: .5; } }
.town { color: rgba(220,228,255,.75); font-size: 11px; font-weight: 600; text-shadow: 0 1px 2px #000, 0 0 4px #000; white-space: nowrap; transform: translate(-50%, -50%); position: absolute; }

.ti { display: inline-grid; place-items: center; border-radius: 10px; background: color-mix(in srgb, var(--c) 18%, transparent); }
.ti svg { width: 72%; height: 72%; }

/* ---------- desktop ---------- */
@media (min-width: 900px) {
  :root { --tab-h: 0px; }
  .tabbar { top: 0; bottom: 0; right: auto; width: 76px; height: auto; flex-direction: column; justify-content: flex-start; padding: 14px 0; gap: 6px; border-top: 0; border-right: 1px solid var(--line); }
  .tab { flex: none; height: 64px; }
  .tab.on::before { top: 20%; bottom: 20%; left: 0; right: auto; width: 3px; height: auto; border-radius: 0 3px 3px 0; }
  .map { left: 76px; }
  .top { left: 92px; right: auto; width: 420px; }
  .panel { left: 76px; right: auto; width: 440px; bottom: 0; border-right: 1px solid var(--line); box-shadow: 20px 0 40px rgba(0,0,0,.3); }
  body.panel-open .top { left: 532px; }
  .fabs { bottom: 40px; right: 16px; }
  .credit { left: 92px; bottom: 10px; }
  body.panel-open .credit { left: 532px; }
  .sheet { left: auto; right: 76px; bottom: 16px; width: 380px; }
  .modal { align-items: center; }
  .modal-box { border-radius: 22px; }
}

/* Leaflet tooltip with the place name */
.leaflet-tooltip.me-lbl-tt { background: rgba(11,16,32,.82); border: 1px solid rgba(76,195,255,.5); color: #fff; font-weight: 700; font-size: 12px; border-radius: 8px; padding: 2px 7px; box-shadow: none; }
.leaflet-tooltip.me-lbl-tt::before { display: none; }

/* OSM standard tiles turned into a night map */
.leaflet-tile.osm-dark, .osm-dark .leaflet-tile { filter: invert(1) hue-rotate(185deg) brightness(.82) contrast(.92) saturate(.45); }
