:root {
  --bg: #161616;
  --surface: #1c1c1c;
  --surface-2: #242424;
  --line: #2e2e2e;
  --text: #e8e8e8;
  --muted: #8a8a8a;
  --region: #262626;
  --region-line: #3c3c3c;
  --alert: #8e2c33;      /* ракетная тревога — приглушённый бордовый */
  --uav: #7a6a22;        /* дроновая тревога — приглушённый оливковый */
  --ok: #3fb950;
  --arrow: #f5c451;
  --top-h: 0px;          /* шапки нет — карта на весь экран */
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text);
  font: 15px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; overflow: hidden; }

/* ── Плавающие элементы поверх карты (карта на весь экран, как у Контура) ── */
.corner-tl { position: fixed; z-index: 1001; top: calc(12px + env(safe-area-inset-top)); left: 12px;
  display: flex; gap: 8px; align-items: center; flex-wrap: wrap; max-width: calc(100% - 24px); }
.chip { display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 12px; border-radius: 12px;
  border: 1px solid var(--line); background: rgb(22 22 22 / .92); color: var(--text); text-decoration: none;
  font: 600 12px/1 system-ui, sans-serif; cursor: pointer; white-space: nowrap; }
.chip.icon { width: 34px; padding: 0; justify-content: center; }
.chip:hover { background: var(--surface-2); }
#top-summary:empty { display: none; }
.status { cursor: default; color: var(--muted); font-weight: 500; }

.toolbar { position: fixed; z-index: 1001; left: 50%; transform: translateX(-50%);
  bottom: calc(14px + env(safe-area-inset-bottom)); display: flex; align-items: center; gap: 4px;
  padding: 6px; border-radius: 16px; border: 1px solid var(--line); background: rgb(22 22 22 / .94);
  box-shadow: 0 6px 24px rgb(0 0 0 / .45); }
.toolbar button { width: 40px; height: 40px; border: 0; border-radius: 11px; background: none; color: var(--text);
  font-size: 18px; display: grid; place-items: center; cursor: pointer; }
.toolbar button:hover { background: var(--surface-2); }
.toolbar .sep { width: 1px; height: 22px; background: var(--line); margin: 0 4px; }

.night-card { position: fixed; z-index: 1001; right: 12px; bottom: calc(14px + env(safe-area-inset-bottom));
  display: flex; align-items: center; gap: 10px; text-align: left; padding: 8px 14px 8px 8px;
  border-radius: 14px; border: 1px solid var(--line); background: rgb(22 22 22 / .94); color: var(--text);
  font: 12px/1.3 system-ui, sans-serif; cursor: pointer; }
.night-card svg { flex: none; width: 34px; height: 34px; padding: 7px; border-radius: 10px;
  background: #3a3220; color: #f5c542; }
.night-card .txt { display: flex; flex-direction: column; }
.night-card b { font-size: 13px; }
.night-card .txt span { color: var(--muted); font-size: 11px; }
.night-card:hover { background: var(--surface-2); }
#tb-history { display: none; }


/* ── Карточка цели (по нажатию на значок) ── */
.tcard { position: fixed; z-index: 1002; left: 50%; transform: translateX(-50%);
  bottom: calc(76px + env(safe-area-inset-bottom)); width: min(430px, calc(100% - 24px));
  padding: 12px 18px 12px; border-radius: 16px; border: 1px solid var(--line);
  background: rgb(28 28 28 / .97); box-shadow: 0 8px 30px rgb(0 0 0 / .5);
  font: 600 13px/1.3 ui-monospace, "Cascadia Mono", Consolas, monospace; }
.tcard .grab { display: block; width: 34px; height: 4px; margin: -4px auto 10px; border-radius: 2px; background: #444; }
.tcard-x { position: absolute; top: 6px; right: 6px; width: 28px; height: 28px; border: 0; border-radius: 8px;
  background: none; color: var(--muted); cursor: pointer; }
.tcard-x:hover { background: var(--surface-2); color: var(--text); }
.tcard-top { display: flex; align-items: center; gap: 10px; padding: 0 22px 10px 0;
  border-bottom: 1px solid var(--line); }
.tcard-top .tname { text-transform: uppercase; letter-spacing: .4px; }
.tcard-top .arr { color: var(--muted); }
.tcard-top .dest { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tcard-top .time { margin-left: auto; color: var(--muted); font-weight: 500; }
.tcard-meta { display: flex; flex-wrap: wrap; gap: 6px 14px; padding-top: 10px; font-size: 12px;
  color: var(--muted); text-transform: uppercase; letter-spacing: .3px; }
.tcard-meta b { color: var(--text); }
.tcard-meta .ok { color: var(--ok); }
.tcard-meta .sep { width: 1px; background: var(--line); }
.tcard-meta .sub { flex-basis: 100%; text-transform: none; letter-spacing: 0; font-weight: 500; }

/* ── «Історія цілей» ── */
.tabs { display: flex; gap: 4px; margin: 4px 0 8px; border-bottom: 1px solid var(--line); }
.tab { flex: 1; padding: 9px 0; border: 0; border-bottom: 2px solid transparent; background: none;
  color: var(--muted); font: 600 13px/1 system-ui, sans-serif; cursor: pointer; }
.tab.active { color: var(--text); border-bottom-color: #f5c542; }
.hist { list-style: none; margin: 0; padding: 0; }
.hist li { border-bottom: 1px solid var(--line); }
.hist .row { display: grid; grid-template-columns: 44px 22px 1fr 16px; align-items: center; gap: 8px;
  width: 100%; padding: 11px 2px; border: 0; background: none; color: var(--text); text-align: left;
  font: 600 13px/1.25 system-ui, sans-serif; cursor: pointer; }
.hist .row .when { color: var(--muted); font-weight: 500; font-size: 12px; font-variant-numeric: tabular-nums; }
.hist .row .dest { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hist .row .chev { color: var(--muted); transition: transform .15s; }
.hist li.open .chev { transform: rotate(180deg); }
.hist .more { display: none; padding: 0 2px 11px 54px; color: var(--muted); font-size: 12px; line-height: 1.5; }
.hist li.open .more { display: block; }
.hist .empty { padding: 14px 2px; color: var(--muted); font-size: 13px; }

.toast { position: fixed; z-index: 1200; left: 50%; transform: translateX(-50%); bottom: 80px;
  padding: 8px 14px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--line); font-size: 13px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.status.live .dot { background: var(--ok); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ok) 25%, transparent); }
.status.lost .dot { background: var(--uav); }

.banner { position: fixed; top: calc(56px + env(safe-area-inset-top)); left: 50%; transform: translateX(-50%);
  z-index: 1000; max-width: calc(100% - 32px); padding: 8px 14px; border-radius: 10px;
  background: var(--surface-2); border: 1px solid var(--line); font-size: 14px; text-align: center; }
.banner.warn { border-color: var(--uav); }
.banner.stop { border-color: var(--alert); }

/* ── Карта (MapLibre GL) ── */
#map { position: fixed; inset: var(--top-h) 0 0 0; background: var(--bg); }
.maplibregl-map { font: inherit; }
.maplibregl-ctrl-attrib { background: color-mix(in srgb, var(--bg) 75%, transparent) !important; color: var(--muted); font-size: 10px; }
.maplibregl-ctrl-attrib a { color: var(--muted) !important; }
.maplibregl-ctrl-attrib-button { filter: invert(1) opacity(.5); }
.maplibregl-ctrl-bottom-right { bottom: calc(76px + env(safe-area-inset-bottom)); }
/* подсказка при наведении на цель */
.tip .maplibregl-popup-content { background: var(--surface-2); color: var(--text); border: 1px solid var(--line);
  border-radius: 8px; padding: 6px 10px; font-size: 13px; box-shadow: none; }
.tip .maplibregl-popup-tip { display: none; }
.tip { pointer-events: none; }

/* Значки целей: положение задаёт карта (transform) — не переопределять */
.tgt { cursor: pointer; }
.tgt-svg { display: block; overflow: visible; filter: drop-shadow(0 0 2px rgb(0 0 0 / .8)); transition: transform .3s; }
.tgt.only-heading .tgt-svg { opacity: .55; }
.tgt-n { position: absolute; left: 18px; top: -6px; font: 700 10px/1 system-ui, sans-serif; color: #fff;
  text-shadow: 0 0 3px #000, 0 0 3px #000; white-space: nowrap; pointer-events: none; }
.tgt.sel .tgt-svg { filter: drop-shadow(0 0 2px #000) drop-shadow(0 0 6px #fff); }
.tgt.sel { z-index: 2; }
/* «я здесь» */
.me-dot { width: 14px; height: 14px; border-radius: 50%; background: #2f81f7; border: 2px solid #fff;
  box-shadow: 0 0 0 6px rgb(47 129 247 / .25); }

/* Строка-счётчик целей сверху */
.counters { position: fixed; top: calc(12px + env(safe-area-inset-top)); left: 50%; transform: translateX(-50%);
  z-index: 1001; display: flex; gap: 14px; align-items: center; padding: 7px 14px;
  background: rgb(22 22 22 / .92); border: 1px solid var(--line); border-radius: 12px;
  max-width: calc(100% - 32px); overflow-x: auto; white-space: nowrap; scrollbar-width: none; }
.counters .cnt { display: inline-flex; align-items: center; gap: 5px; font: 600 11px/1 system-ui, sans-serif;
  text-transform: uppercase; letter-spacing: .3px; color: var(--muted); }
.counters .cnt b { color: var(--text); font-size: 12px; }

/* ── Меню (список тревог, целей, настройки): выезжает по кнопке ☰ ── */
.panel { position: fixed; z-index: 1100; top: 0; right: 0; bottom: 0; width: min(380px, 100%);
  overflow-y: auto; overflow-x: hidden; padding: 12px 16px calc(16px + env(safe-area-inset-bottom));
  background: var(--surface); border-left: 1px solid var(--line);
  transform: translateX(105%); transition: transform .22s ease; }
.panel.open { transform: none; box-shadow: -8px 0 30px rgb(0 0 0 / .5); }
.panel-backdrop { position: fixed; inset: 0; z-index: 1050; background: rgb(0 0 0 / .45); }
.panel-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.panel-close { flex: none; width: 34px; height: 34px; border: 0; border-radius: 10px; background: var(--surface-2);
  color: var(--text); font-size: 16px; cursor: pointer; }

.summary { font-weight: 600; font-size: 16px; padding: 6px 0 10px; }
h2 { font-size: 12px; text-transform: uppercase; letter-spacing: .6px; color: var(--muted);
  margin: 10px 0 6px; font-weight: 600; }
.count { color: var(--text); }
.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; justify-content: space-between; gap: 12px; padding: 7px 0;
  border-bottom: 1px solid var(--line); font-size: 14px; }
.list li:last-child { border-bottom: 0; }
.list .when { color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.list .empty { color: var(--muted); }
.list .parts { color: var(--muted); font-size: 12px; }
.src { color: var(--muted); font-size: 11px; }
.night { font-size: 13px; line-height: 1.55; }
.settings { display: flex; align-items: center; gap: 10px; margin-top: 14px; font-size: 12px; color: var(--muted); }
.settings input[type=range] { flex: 1; accent-color: #f5c542; }
.settings span { min-width: 38px; text-align: right; color: var(--text); font-variant-numeric: tabular-nums; }
.kind-alert { color: #e5484d; }
.kind-uav { color: var(--uav); }

.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 12px; color: var(--muted); margin-top: 14px; }
.sw { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.sw-alert { background: var(--alert); }
.sw-uav { background: var(--uav); }
.sw-part { background: color-mix(in srgb, var(--alert) 25%, transparent); border: 1px dashed var(--alert); }
.sw-calm { background: var(--region); border: 1px solid var(--region-line); }

.channel-link { display: block; margin-top: 14px; padding: 12px 14px; border-radius: 12px; text-align: center;
  background: #f5c542; color: #111; font-weight: 700; text-decoration: none; }
.channel-link:hover { background: #ffd35c; }
.disclaimer { font-size: 12px; color: var(--muted); margin: 12px 0 0; }

/* ── Телефон: всё компактнее, ничего не налезает друг на друга ── */
@media (max-width: 640px) {
  .night-card { display: none; }                 /* «Історія» — кнопкой в панели снизу */
  #tb-history { display: grid; }
  .corner-tl { top: calc(8px + env(safe-area-inset-top)); left: 8px; gap: 6px; }
  .chip { height: 32px; padding: 0 10px; }
  .chip.icon { width: 32px; }
  .status #status-text { display: none; }        /* только точка: зелёная — онлайн */
  .status { width: 32px; padding: 0; justify-content: center; }
  .counters { top: calc(48px + env(safe-area-inset-top)); left: 8px; right: 8px; transform: none;
    max-width: none; justify-content: flex-start; gap: 12px; padding: 6px 10px; }
  .banner { top: calc(88px + env(safe-area-inset-top)); }
  .toolbar { bottom: calc(10px + env(safe-area-inset-bottom)); gap: 2px; padding: 4px; }
  .toolbar button { width: 40px; height: 40px; }
  .toolbar .sep { margin: 0 2px; }
  .tcard { bottom: calc(66px + env(safe-area-inset-bottom)); padding: 10px 14px; font-size: 12px; }
  .tcard-meta { font-size: 11px; }
  .panel { width: 100%; border-left: 0; }
  .maplibregl-ctrl-attrib { display: none; }   /* на телефоне закрывала кнопки; источники — в меню */
}
@media (max-width: 360px) { #tb-share { display: none; } }
