:root {
  --bg: #12151c;
  --glass: rgba(18, 22, 31, 0.88);
  --glass-strong: rgba(15, 19, 27, 0.95);
  --glass-b: rgba(148, 163, 184, 0.16);
  --tx: #f1f5f9;
  --mut: #94a3b8;
  --acc: #38bdf8;
  --danger: #ef4444;
  --danger-fill: #dc2626;
  --attn: #eab308;
  --attn-fill: #ca8a04;
  --calm: #22c55e;
  --kov: #f43f5e;
  --vanga: #a78bfa;
  --r: 12px;
  --font: Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--tx);
  font-family: var(--font);
  font-size: 14px;
}

#map {
  position: fixed;
  inset: 0;
  background: #12151c;
}

.theme-light #map {
  background: #e2e8f0;
}

button {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  cursor: pointer;
}

svg {
  display: block;
}

/* Leaflet map refinements — NO ugly tile inversion! */
.leaflet-container {
  font-family: var(--font);
  background: inherit;
}

.leaflet-control-attribution {
  background: rgba(15, 19, 27, 0.65) !important;
  color: #64748b !important;
  font-size: 9px !important;
  padding: 1px 5px !important;
}

.leaflet-control-attribution a {
  color: #94a3b8 !important;
}

/* Region polygons */
path.reg {
  transition: fill-opacity 0.25s ease, stroke-width 0.2s ease;
  cursor: pointer;
  outline: none;
}

path.reg-danger {
  animation: regDangerPulse 2.8s ease-in-out infinite;
}

@keyframes regDangerPulse {
  0%, 100% { fill-opacity: 0.34; }
  50% { fill-opacity: 0.48; }
}

path.reg-attn {
  animation: regAttnPulse 3.4s ease-in-out infinite;
}

@keyframes regAttnPulse {
  0%, 100% { fill-opacity: 0.23; }
  50% { fill-opacity: 0.33; }
}

/* Trajectory dashed line (no ugly arrowheads) */
path.vec-line {
  stroke-dasharray: 6 7;
  animation: vecDash 1.1s linear infinite;
  stroke-linecap: round;
}

@keyframes vecDash {
  to { stroke-dashoffset: -13; }
}

/* Origin red radar dot */
.vec-origin {
  position: relative;
  width: 14px;
  height: 14px;
}

.vec-origin i {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: rgba(239, 68, 68, 0.45);
  animation: originPing 2s ease-out infinite;
}

.vec-origin b {
  position: absolute;
  left: 3px;
  top: 3px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #ef4444;
  border: 1.5px solid #fca5a5;
  box-shadow: 0 0 8px #ef4444;
}

@keyframes originPing {
  0% { transform: scale(0.7); opacity: 0.9; }
  100% { transform: scale(2.2); opacity: 0; }
}

/* Animated UAV / Missile marker along flight path */
.uav-wrap {
  position: relative;
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  pointer-events: auto;
}

.uav-rot {
  width: 26px;
  height: 26px;
  filter: drop-shadow(0 1px 5px rgba(239, 68, 68, 0.75)) drop-shadow(0 0 2px rgba(0, 0, 0, 0.9));
  transition: transform 0.1s linear;
}

.uav-wrap.rocket .uav-rot {
  filter: drop-shadow(0 1px 6px rgba(244, 63, 94, 0.9)) drop-shadow(0 0 2px rgba(0, 0, 0, 0.9));
}

.uav-qty {
  position: absolute;
  top: -7px;
  right: -14px;
  background: rgba(15, 23, 42, 0.92);
  border: 1px solid rgba(248, 113, 113, 0.65);
  color: #fef2f2;
  font-size: 10px;
  font-weight: 700;
  line-height: 1;
  padding: 2px 4px;
  border-radius: 5px;
  white-space: nowrap;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.6);
}

/* Yellow '+' Fixation Marker (exact match to @URAL_RADAR) */
.fix-wrap {
  position: relative;
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
}

.fix-ring {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: rgba(234, 179, 8, 0.24);
  border: 1.8px solid #facc15;
  box-shadow: 0 0 8px rgba(234, 179, 8, 0.45), inset 0 0 4px rgba(0, 0, 0, 0.5);
  display: grid;
  place-items: center;
  color: #fef08a;
  font-weight: 700;
  font-size: 12px;
  line-height: 1;
}

.fix-uav {
  position: absolute;
  right: -9px;
  bottom: -7px;
  width: 16px;
  height: 16px;
  filter: drop-shadow(0 1px 3px rgba(0, 0, 0, 0.9));
}

.fix-qty {
  position: absolute;
  top: -8px;
  left: 14px;
  background: rgba(15, 23, 42, 0.92);
  border: 1px solid rgba(250, 204, 21, 0.6);
  color: #fef9c3;
  font-size: 10px;
  font-weight: 700;
  line-height: 1;
  padding: 2px 4px;
  border-radius: 5px;
  white-space: nowrap;
}

/* Air defense / explosion marker */
.blast-wrap {
  position: relative;
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
}

.blast-ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 1.8px solid #fb923c;
  animation: blastWave 1.9s ease-out infinite;
}

.blast-core {
  width: 18px;
  height: 18px;
  filter: drop-shadow(0 0 6px #f97316);
}

@keyframes blastWave {
  0% { transform: scale(0.35); opacity: 0.95; }
  100% { transform: scale(1.35); opacity: 0; }
}

/* Airport "План Ковёр" badge with city label */
.apt-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: rgba(18, 22, 31, 0.92);
  border: 1px solid rgba(244, 63, 94, 0.65);
  border-radius: 999px;
  padding: 2px 7px 2px 4px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.55);
  white-space: nowrap;
  transform: translate(-50%, -50%);
}

.apt-badge svg {
  width: 15px;
  height: 15px;
  flex: none;
}

.apt-badge span {
  font-size: 10.5px;
  font-weight: 600;
  color: #f8fafc;
}

/* Region text labels (screen-space collision-culled) */
.rlabel {
  display: inline-block;
  transform: translate(-50%, -50%);
  color: rgba(241, 245, 249, 0.92);
  font-weight: 600;
  font-size: 11px;
  letter-spacing: 0.15px;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.95), 0 0 5px rgba(0, 0, 0, 0.85);
  white-space: nowrap;
  pointer-events: none;
}

.rlabel.rlabel-danger {
  color: #ffffff;
  font-weight: 700;
  text-shadow: 0 1px 4px #000, 0 0 8px rgba(220, 38, 38, 0.7);
}

.rlabel.rlabel-attn {
  color: #fef9c3;
  font-weight: 700;
}

.plabel {
  display: inline-block;
  transform: translate(-50%, -50%);
  background: rgba(15, 19, 27, 0.9);
  border: 1px solid rgba(167, 139, 250, 0.65);
  color: #ede9fe;
  font-weight: 700;
  border-radius: 6px;
  padding: 1px 5px;
  font-size: 10.5px;
  white-space: nowrap;
  pointer-events: none;
}

.me-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #38bdf8;
  border: 2.5px solid #fff;
  box-shadow: 0 0 0 6px rgba(56, 189, 248, 0.28);
}

/* ─── Top Unified Bar ─── */
.topbar {
  position: fixed;
  top: max(10px, env(safe-area-inset-top));
  left: 12px;
  right: 12px;
  z-index: 920;
  display: flex;
  gap: 8px;
  align-items: center;
  pointer-events: none;
}

.topbar > * {
  pointer-events: auto;
}

.brand, .search, .counters {
  background: var(--glass);
  border: 1px solid var(--glass-b);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-radius: var(--r);
  box-shadow: 0 6px 22px rgba(0, 0, 0, 0.42);
}

.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 0 12px 0 9px;
  height: 44px;
  cursor: pointer;
  flex: none;
}

.brand-logo {
  width: 26px;
  height: 26px;
  color: #94a3b8;
}

.sweep {
  transform-origin: 16px 16px;
  animation: radarSweep 3.6s linear infinite;
}

@keyframes radarSweep {
  to { transform: rotate(360deg); }
}

.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
}

.brand-text b {
  font-size: 12px;
  letter-spacing: 0.1em;
  color: #f8fafc;
}

.brand-text span {
  font-size: 10.5px;
  color: var(--mut);
  font-variant-numeric: tabular-nums;
}

.search {
  position: relative;
  flex: 1;
  max-width: 380px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  height: 44px;
}

.search .ico {
  width: 16px;
  height: 16px;
  color: var(--mut);
  flex: none;
}

.search input {
  flex: 1;
  min-width: 0;
  background: none;
  border: 0;
  outline: 0;
  color: var(--tx);
  font: inherit;
  font-size: 14px;
  height: 100%;
}

.search input::placeholder {
  color: var(--mut);
}

.suggest {
  position: absolute;
  top: 48px;
  left: 0;
  right: 0;
  background: var(--glass-strong);
  border: 1px solid var(--glass-b);
  border-radius: var(--r);
  backdrop-filter: blur(16px);
  overflow: hidden;
  display: none;
  max-height: 48vh;
  overflow-y: auto;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.55);
}

.suggest.on {
  display: block;
}

.suggest button {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  width: 100%;
  text-align: left;
  padding: 10px 14px;
  border-bottom: 1px solid var(--glass-b);
  font-size: 13.5px;
}

.suggest button:last-child {
  border: 0;
}

.suggest button:hover {
  background: rgba(56, 189, 248, 0.12);
}

.suggest small {
  color: var(--mut);
  font-size: 11.5px;
}

.counters {
  display: flex;
  gap: 4px;
  padding: 4px;
  height: 44px;
  align-items: center;
  margin-left: auto;
  flex: none;
}

.chip {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 10px;
  height: 34px;
  border-radius: 8px;
  font-variant-numeric: tabular-nums;
  transition: background 0.15s;
}

.chip:hover {
  background: rgba(148, 163, 184, 0.12);
}

.chip[hidden] {
  display: none;
}

.chip i {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: block;
}

.chip b {
  font-size: 14px;
}

.chip-danger i {
  background: var(--danger);
  box-shadow: 0 0 8px var(--danger);
}

.chip-attn i {
  background: var(--attn);
  box-shadow: 0 0 8px var(--attn);
}

.chip-kov i {
  background: var(--kov);
  box-shadow: 0 0 8px var(--kov);
}

/* ─── Floating Dock Toolbar ─── */
.toolbar {
  position: fixed;
  left: 12px;
  top: 66px;
  z-index: 910;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 6px;
  background: var(--glass);
  border: 1px solid var(--glass-b);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-radius: var(--r);
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.42);
}

.toolbar button {
  width: 48px;
  min-height: 44px;
  padding: 4px 2px;
  border-radius: 9px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  color: var(--mut);
  transition: 0.15s;
}

.toolbar button svg {
  width: 20px;
  height: 20px;
}

.toolbar button span {
  font-size: 9.5px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.toolbar button:hover {
  color: var(--tx);
  background: rgba(148, 163, 184, 0.12);
}

.toolbar button.on {
  color: #06101f;
  background: var(--acc);
}

.toolbar #btnVanga.on {
  background: var(--vanga);
  color: #120a2e;
}

.toolbar .sep {
  height: 1px;
  background: var(--glass-b);
  margin: 2px 4px;
}

/* ─── Bottom-Right Collapsible Legend ("ОБОЗНАЧЕНИЯ") ─── */
.legend-card {
  position: fixed;
  right: 12px;
  bottom: 22px;
  z-index: 890;
  background: var(--glass);
  border: 1px solid var(--glass-b);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-radius: 12px;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.45);
  min-width: 192px;
  overflow: hidden;
}

.legend-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 12px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--mut);
  border-bottom: 1px solid var(--glass-b);
}

.legend-card.collapsed .legend-toggle {
  border-bottom: 0;
}

.legend-toggle .chev {
  width: 15px;
  height: 15px;
  transition: transform 0.2s;
}

.legend-card.collapsed .legend-toggle .chev {
  transform: rotate(180deg);
}

.legend-body {
  padding: 8px 12px 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.legend-card.collapsed .legend-body {
  display: none;
}

.leg-item {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 12px;
  color: #e2e8f0;
}

.leg-box {
  width: 18px;
  height: 12px;
  border-radius: 3px;
  flex: none;
}

.leg-danger {
  background: rgba(220, 38, 38, 0.55);
  border: 1.5px solid #ef4444;
}

.leg-attn {
  background: rgba(234, 179, 8, 0.42);
  border: 1.5px solid #facc15;
}

.leg-vec {
  display: inline-flex;
  align-items: center;
  width: 34px;
  flex: none;
}

.leg-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #ef4444;
  flex: none;
}

.leg-dash {
  flex: 1;
  height: 0;
  border-top: 2px dashed #ef4444;
  margin: 0 2px;
}

.leg-uav {
  width: 13px;
  height: 13px;
  transform: rotate(90deg);
  flex: none;
}

.leg-fix {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: rgba(234, 179, 8, 0.25);
  border: 1.5px solid #facc15;
  display: grid;
  place-items: center;
  flex: none;
}

.leg-fix i {
  font-style: normal;
  font-size: 11px;
  font-weight: 700;
  color: #fef08a;
  line-height: 1;
}

.leg-blast {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: radial-gradient(circle, #fb923c 35%, rgba(251, 146, 60, 0.2) 70%);
  border: 1.5px solid #f97316;
  flex: none;
}

.leg-apt {
  width: 18px;
  height: 18px;
  display: grid;
  place-items: center;
  flex: none;
}

.leg-apt svg {
  width: 16px;
  height: 16px;
}

/* ─── Mode Banner ─── */
.mode-banner {
  position: fixed;
  z-index: 900;
  top: 64px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 8px 7px 14px;
  border-radius: 999px;
  background: rgba(46, 16, 101, 0.92);
  border: 1px solid var(--vanga);
  color: #ede9fe;
  backdrop-filter: blur(10px);
  font-weight: 600;
  font-size: 12.5px;
  white-space: nowrap;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.45);
}

.mode-banner[hidden] {
  display: none;
}

.pulse-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #c4b5fd;
  box-shadow: 0 0 8px #a78bfa;
}

.mode-banner button {
  background: rgba(255, 255, 255, 0.16);
  border-radius: 999px;
  padding: 4px 11px;
  font-size: 11.5px;
}

/* ─── Side Panel & Region Sheet ─── */
.panel {
  position: fixed;
  z-index: 940;
  top: 66px;
  left: 78px;
  bottom: 14px;
  width: 370px;
  max-width: calc(100vw - 92px);
  display: flex;
  flex-direction: column;
  background: var(--glass-strong);
  border: 1px solid var(--glass-b);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border-radius: var(--r);
  box-shadow: 0 12px 42px rgba(0, 0, 0, 0.55);
  animation: slideInLeft 0.2s ease-out;
}

.panel[hidden], .sheet[hidden] {
  display: none;
}

@keyframes slideInLeft {
  from { opacity: 0; transform: translateX(-12px); }
  to { opacity: 1; transform: none; }
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 13px 16px 9px;
  border-bottom: 1px solid var(--glass-b);
}

.panel-head h2 {
  font-size: 14.5px;
  letter-spacing: 0.03em;
}

.x {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  font-size: 20px;
  line-height: 1;
  color: var(--mut);
  display: grid;
  place-items: center;
}

.x:hover {
  background: rgba(148, 163, 184, 0.14);
  color: var(--tx);
}

.panel-body {
  flex: 1;
  overflow-y: auto;
  padding: 8px 14px 16px;
  overscroll-behavior: contain;
}

.panel-body::-webkit-scrollbar {
  width: 5px;
}

.panel-body::-webkit-scrollbar-thumb {
  background: rgba(100, 116, 139, 0.45);
  border-radius: 6px;
}

.row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 2px;
  border-bottom: 1px solid var(--glass-b);
}

.row:last-child {
  border: 0;
}

.row .lab {
  display: flex;
  align-items: center;
  gap: 10px;
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex: none;
}

.sw {
  position: relative;
  width: 40px;
  height: 22px;
  border-radius: 999px;
  background: #334155;
  transition: 0.2s;
  flex: none;
}

.sw:after {
  content: "";
  position: absolute;
  left: 3px;
  top: 3px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  transition: 0.2s;
}

.sw.on {
  background: var(--acc);
}

.sw.on:after {
  left: 21px;
}

.seg {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin: 6px 0 10px;
}

.seg button {
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--glass-b);
  color: var(--mut);
  font-size: 12.5px;
}

.seg button.on {
  background: var(--acc);
  color: #06101f;
  border-color: var(--acc);
  font-weight: 600;
}

.h3 {
  font-size: 10.5px;
  letter-spacing: 0.12em;
  color: var(--mut);
  margin: 13px 0 5px;
  text-transform: uppercase;
  font-weight: 700;
}

.mut {
  color: var(--mut);
}

.card {
  padding: 11px 12px;
  border-radius: 10px;
  background: rgba(30, 41, 59, 0.5);
  border: 1px solid var(--glass-b);
  margin: 7px 0;
  cursor: pointer;
  transition: border-color 0.15s;
}

.card:hover {
  border-color: #475569;
}

.card .meta {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--mut);
  margin-bottom: 5px;
}

.card .txt {
  font-size: 13px;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
}

.tags {
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
  margin-top: 7px;
}

.tag {
  font-size: 10.5px;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(56, 189, 248, 0.14);
  color: #7dd3fc;
}

.tag.t-uav {
  background: rgba(239, 68, 68, 0.18);
  color: #fca5a5;
}

.tag.t-rkt {
  background: rgba(217, 70, 239, 0.18);
  color: #f0abfc;
}

.tag.t-kov {
  background: rgba(244, 63, 94, 0.18);
  color: #fda4af;
}

.bar {
  height: 7px;
  border-radius: 99px;
  background: #1e293b;
  overflow: hidden;
}

.bar i {
  display: block;
  height: 100%;
  border-radius: 99px;
  background: linear-gradient(90deg, #22c55e, #eab308, #ef4444);
}

.prow {
  padding: 8px 2px;
  border-bottom: 1px solid var(--glass-b);
  cursor: pointer;
}

.prow:hover {
  background: rgba(167, 139, 250, 0.08);
}

.prow .top {
  display: flex;
  justify-content: space-between;
  margin-bottom: 5px;
  font-size: 13px;
}

.prow b {
  font-variant-numeric: tabular-nums;
}

.note {
  font-size: 12px;
  color: var(--mut);
  line-height: 1.45;
  background: rgba(167, 139, 250, 0.08);
  border: 1px solid rgba(167, 139, 250, 0.24);
  border-radius: 10px;
  padding: 9px 11px;
  margin: 8px 0;
}

input[type="date"] {
  background: #0f172a;
  color: var(--tx);
  border: 1px solid var(--glass-b);
  border-radius: 9px;
  padding: 8px 10px;
  font: inherit;
  color-scheme: dark;
  width: 100%;
}

/* ─── Details Sheet ─── */
.sheet {
  position: fixed;
  z-index: 945;
  top: 66px;
  right: 12px;
  width: 350px;
  max-height: calc(100vh - 84px);
  max-width: calc(100vw - 24px);
  background: var(--glass-strong);
  border: 1px solid var(--glass-b);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border-radius: var(--r);
  box-shadow: 0 12px 42px rgba(0, 0, 0, 0.55);
  padding: 16px;
  overflow-y: auto;
  animation: slideInRight 0.2s ease-out;
}

@keyframes slideInRight {
  from { opacity: 0; transform: translateX(12px); }
  to { opacity: 1; transform: none; }
}

.sheet > .x {
  position: absolute;
  right: 10px;
  top: 10px;
}

.s-title {
  font-size: 17.5px;
  font-weight: 700;
  padding-right: 32px;
  line-height: 1.25;
}

.s-sub {
  color: var(--mut);
  font-size: 12.5px;
  margin: 2px 0 10px;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 11px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 12.5px;
}

.badge i {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
}

.b-danger {
  background: rgba(239, 68, 68, 0.18);
  color: #fca5a5;
  border: 1px solid rgba(239, 68, 68, 0.35);
}

.b-attn {
  background: rgba(234, 179, 8, 0.18);
  color: #fde047;
  border: 1px solid rgba(234, 179, 8, 0.35);
}

.b-calm {
  background: rgba(34, 197, 94, 0.14);
  color: #86efac;
  border: 1px solid rgba(34, 197, 94, 0.3);
}

.kv {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 7px 12px;
  margin: 12px 0;
  font-size: 13px;
}

.kv dt {
  color: var(--mut);
}

.kv dd {
  text-align: right;
  font-weight: 500;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 8px 13px;
  border-radius: 9px;
  border: 1px solid var(--glass-b);
  color: var(--tx);
  font-size: 12.5px;
  font-weight: 500;
}

.btn:hover {
  border-color: var(--acc);
  color: var(--acc);
}

.btn.primary {
  background: var(--acc);
  color: #06101f;
  border-color: var(--acc);
  font-weight: 600;
}

.toast {
  position: fixed;
  z-index: 3000;
  top: 66px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(15, 19, 27, 0.96);
  border: 1px solid var(--glass-b);
  padding: 9px 15px;
  border-radius: 10px;
  font-size: 13px;
  box-shadow: 0 8px 26px rgba(0, 0, 0, 0.6);
}

/* Light theme adjustments */
.theme-light {
  --glass: rgba(255, 255, 255, 0.9);
  --glass-strong: rgba(255, 255, 255, 0.96);
  --glass-b: rgba(15, 23, 42, 0.12);
  --tx: #0f172a;
  --mut: #475569;
}

.theme-light .brand-text b {
  color: #0f172a;
}

.theme-light .leg-item {
  color: #1e293b;
}

.theme-light .rlabel {
  color: #0f172a;
  text-shadow: 0 0 3px #fff, 0 0 6px #fff;
}

.theme-light .rlabel.rlabel-danger {
  color: #991b1b;
  text-shadow: 0 0 4px #fff;
}

.theme-light .rlabel.rlabel-attn {
  color: #854d0e;
  text-shadow: 0 0 4px #fff;
}

.theme-light .card {
  background: rgba(241, 245, 249, 0.85);
}

/* ─── Mobile-First Responsive Layout ─── */
@media (max-width: 760px) {
  .topbar {
    left: 8px;
    right: 8px;
    top: max(8px, env(safe-area-inset-top));
    gap: 6px;
  }

  .brand {
    padding: 0 9px;
    height: 40px;
  }

  .brand-text {
    display: none;
  }

  .search {
    height: 40px;
    padding: 0 10px;
  }

  .search input {
    font-size: 13.5px;
  }

  .counters {
    height: 40px;
    padding: 3px;
  }

  .chip {
    height: 32px;
    padding: 0 8px;
  }

  /* Bottom compact dock on mobile so top of map stays 100% open */
  .toolbar {
    left: 8px;
    right: 8px;
    top: auto;
    bottom: max(8px, env(safe-area-inset-bottom));
    flex-direction: row;
    justify-content: space-around;
    padding: 4px 6px;
  }

  .toolbar .sep {
    width: 1px;
    height: auto;
    margin: 4px 0;
  }

  .toolbar button {
    width: auto;
    flex: 1;
    min-height: 40px;
    padding: 3px 2px;
  }

  .toolbar button span {
    font-size: 9px;
  }

  .legend-card {
    right: 8px;
    bottom: calc(max(8px, env(safe-area-inset-bottom)) + 56px);
    min-width: 168px;
  }

  .legend-toggle {
    padding: 6px 10px;
    font-size: 10px;
  }

  .legend-body {
    padding: 6px 10px 8px;
    gap: 5px;
  }

  .leg-item {
    font-size: 11px;
  }

  .panel {
    left: 8px;
    right: 8px;
    top: auto;
    bottom: calc(max(8px, env(safe-area-inset-bottom)) + 54px);
    width: auto;
    max-width: none;
    height: 58vh;
  }

  .sheet {
    left: 8px;
    right: 8px;
    top: auto;
    bottom: calc(max(8px, env(safe-area-inset-bottom)) + 54px);
    width: auto;
    max-width: none;
    max-height: 56vh;
  }

  .mode-banner {
    top: 56px;
    font-size: 11.5px;
  }

  .leaflet-control-attribution {
    display: none !important;
  }
}


/* Perm Krai Dedicated Quick Bar */
.perm-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: rgba(30, 41, 59, 0.85);
  border: 1px solid rgba(148, 163, 184, 0.25);
  border-radius: 999px;
  padding: 5px 12px;
  font-size: 13px;
  color: #f1f5f9;
  cursor: pointer;
  transition: all 0.2s ease;
  backdrop-filter: blur(8px);
}
.perm-pill:hover {
  background: rgba(51, 65, 85, 0.95);
  border-color: rgba(56, 189, 248, 0.5);
  transform: translateY(-1px);
}
.perm-indicator {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  display: inline-block;
}
.dot-calm { background: #22c55e; box-shadow: 0 0 8px rgba(34, 197, 94, 0.6); }
.dot-attn { background: #f59e0b; box-shadow: 0 0 10px rgba(245, 158, 11, 0.8); animation: pulse-attn 1.5s infinite; }
.dot-danger { background: #ef4444; box-shadow: 0 0 12px rgba(239, 68, 68, 0.9); animation: pulse-danger 1s infinite; }

.tx-calm { color: #4ade80; }
.tx-attn { color: #fbbf24; }
.tx-danger { color: #f87171; }

@keyframes pulse-attn {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(1.2); }
}
@keyframes pulse-danger {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(1.3); }
}

@media (max-width: 640px) {
  .topbar {
    padding: 6px 10px;
    gap: 6px;
  }
  .brand b { font-size: 13px; }
  .perm-pill {
    padding: 4px 8px;
    font-size: 11.5px;
  }
  .perm-pill span.perm-label {
    display: none;
  }
  .sheet {
    max-height: 80vh;
    border-radius: 16px 16px 0 0;
  }
}
