/* Тёмная тема в духе Chrome/macOS + анимации/микровзаимодействия в духе
   презентационных сайтов Apple (запрос от 31.08.2026: "стильно, приятно
   пользоваться"). Матовое стекло на панелях (backdrop-filter), мягкие тени
   в несколько слоёв вместо жёстких, системный шрифт (даёт настоящий SF Pro
   на Mac/iPhone и Segoe UI Variable на Windows — оба уже "дизайнерские"
   шрифты своих платформ), пружинные easing-кривые на анимациях. */
:root {
  --bg: #08090d;
  --panel-bg: rgba(22, 23, 29, 0.8);
  --panel-border: rgba(255, 255, 255, 0.09);
  --text: #f5f5f7;
  --muted: #98989d;
  --accent: #0a84ff;
  --accent-hover: #409cff;
  --success: #30d158;
  --warning: #ff9f0a;
  --danger: #ff453a;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow-md: 0 10px 30px rgba(0,0,0,0.45), 0 1px 2px rgba(0,0,0,0.3);
  --shadow-lg: 0 24px 60px rgba(0,0,0,0.55), 0 2px 8px rgba(0,0,0,0.35);
  --ease-spring: cubic-bezier(0.32, 0.72, 0, 1);
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI Variable", "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  color: var(--text);
  background: var(--bg);
}

@keyframes panelIn {
  from { opacity: 0; transform: translateY(6px) scale(0.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes cardIn {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes bellRing {
  0%, 100% { transform: rotate(0); }
  15% { transform: rotate(14deg); }
  30% { transform: rotate(-12deg); }
  45% { transform: rotate(8deg); }
  60% { transform: rotate(-6deg); }
  75% { transform: rotate(2deg); }
}
@keyframes badgePop {
  0% { transform: scale(0); }
  60% { transform: scale(1.25); }
  100% { transform: scale(1); }
}
@keyframes pillPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(48,209,88,0.45); }
  50% { box-shadow: 0 0 0 6px rgba(48,209,88,0); }
}

#map {
  position: absolute;
  inset: 0;
  /* Долгое нажатие на квадрат — это наш собственный жест (открывает
     контекстное меню, см. showContextMenu()). Без этого на iPhone то же
     самое долгое нажатие ДОПОЛНИТЕЛЬНО запускало системное выделение текста
     во всплывающей подсказке — поверх нашего меню вылезало ещё и нативное
     "Скопировать / Найти в Google" (репорт с реального iPhone 31.08.2026). */
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

#sidebar-toggle, #notif-bell {
  position: absolute;
  top: 14px;
  z-index: 1000;
  width: 42px;
  height: 42px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--panel-border);
  background: var(--panel-bg);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  color: var(--text);
  cursor: pointer;
  box-shadow: var(--shadow-md);
  transition: transform 0.15s var(--ease-out), background 0.15s var(--ease-out), box-shadow 0.15s var(--ease-out);
}
#sidebar-toggle:hover, #notif-bell:hover { background: rgba(255,255,255,0.12); }
#sidebar-toggle:active, #notif-bell:active { transform: scale(0.92); }

#sidebar-toggle {
  left: 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
}
#sidebar-toggle .bar {
  display: block;
  width: 18px;
  height: 2px;
  border-radius: 2px;
  background: var(--text);
  transition: transform 0.32s var(--ease-spring), opacity 0.2s var(--ease-out);
}
#sidebar-toggle.is-open .bar:nth-child(1) { transform: translateY(7px) rotate(45deg); }
#sidebar-toggle.is-open .bar:nth-child(2) { opacity: 0; transform: scaleX(0); }
#sidebar-toggle.is-open .bar:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

#notif-bell {
  left: 64px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}
#notif-bell.is-ringing svg { animation: bellRing 0.6s var(--ease-out); transform-origin: top center; }
#notif-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  background: var(--danger);
  color: white;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 700;
  min-width: 16px;
  height: 16px;
  line-height: 16px;
  padding: 0 3px;
  animation: badgePop 0.35s var(--ease-spring);
}
#notif-panel {
  position: absolute;
  top: 60px;
  left: 64px;
  z-index: 1200;
  width: 300px;
  max-height: 60vh;
  overflow-y: auto;
  background: var(--panel-bg);
  backdrop-filter: blur(24px) saturate(180%);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
}
.notif-row {
  padding: 8px 12px;
  font-size: 12px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}
.notif-row .when { color: var(--muted); font-size: 11px; margin-top: 2px; }

#login-overlay {
  position: absolute;
  inset: 0;
  z-index: 2000;
  background: rgba(2, 3, 6, 0.7);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  display: flex;
  align-items: center;
  justify-content: center;
  animation: panelIn 0.3s var(--ease-out);
}
#login-box {
  width: 300px;
  background: var(--panel-bg);
  backdrop-filter: blur(24px) saturate(180%);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 28px 24px;
  text-align: center;
  animation: panelIn 0.35s var(--ease-spring);
}
#login-box h1 { font-size: 19px; margin: 0 0 6px; letter-spacing: -0.01em; }
#login-box input {
  width: 100%;
  margin-top: 10px;
  background: rgba(255,255,255,0.06);
  color: var(--text);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-sm);
  padding: 11px 12px;
  font-size: 14px;
  transition: border-color 0.15s var(--ease-out), background 0.15s var(--ease-out);
}
#login-box input:focus { outline: none; border-color: var(--accent); background: rgba(255,255,255,0.09); }
#login-box button { width: 100%; margin-top: 16px; }
#login-error { color: var(--danger); margin-top: 8px; }

#sidebar-backdrop {
  display: none;
  position: absolute;
  inset: 0;
  z-index: 850;
  background: rgba(0,0,0,0);
  pointer-events: none;
  transition: background 0.28s var(--ease-out);
}
#sidebar-backdrop.visible { background: rgba(0,0,0,0.5); pointer-events: auto; }

#sidebar {
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  width: 300px;
  background: var(--panel-bg);
  border-right: 1px solid var(--panel-border);
  z-index: 900;
  padding: 64px 16px 16px;
  overflow-y: auto;
  transition: transform 0.32s var(--ease-spring);
  backdrop-filter: blur(24px) saturate(180%);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  box-shadow: var(--shadow-lg);
}

#sidebar.collapsed {
  transform: translateX(-100%);
}

#sidebar h1 {
  font-size: 18px;
  margin: 0 0 16px;
  letter-spacing: -0.01em;
}

#sidebar:not(.collapsed) .card {
  animation: cardIn 0.4s var(--ease-out) backwards;
}
#sidebar:not(.collapsed) .card:nth-of-type(1) { animation-delay: 0.03s; }
#sidebar:not(.collapsed) .card:nth-of-type(2) { animation-delay: 0.07s; }
#sidebar:not(.collapsed) .card:nth-of-type(3) { animation-delay: 0.11s; }
#sidebar:not(.collapsed) .card:nth-of-type(4) { animation-delay: 0.15s; }
#sidebar:not(.collapsed) .card:nth-of-type(5) { animation-delay: 0.19s; }
#sidebar:not(.collapsed) .card:nth-of-type(6) { animation-delay: 0.23s; }
#sidebar:not(.collapsed) .card:nth-of-type(7) { animation-delay: 0.27s; }

.card {
  background: rgba(255,255,255,0.045);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 12px;
}

.whoami-row { display: flex; align-items: center; gap: 6px; margin-bottom: 8px; }
.whoami-row #whoami-line { margin-bottom: 0; }

.icon-btn {
  width: 26px;
  height: 26px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255,255,255,0.07);
  border: 1px solid var(--panel-border);
  color: var(--text);
  border-radius: 8px;
  flex-shrink: 0;
}
.icon-btn:hover { background: rgba(255,255,255,0.14); }

.card h2 {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin: 0 0 10px;
  font-weight: 700;
}

button {
  background: var(--accent);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  width: 100%;
  box-shadow: 0 1px 2px rgba(0,0,0,0.3);
  transition: background 0.15s var(--ease-out), transform 0.12s var(--ease-out), box-shadow 0.15s var(--ease-out);
}
button:hover { background: var(--accent-hover); box-shadow: 0 4px 16px rgba(10,132,255,0.35); }
button:active { transform: scale(0.97); }
button:disabled { background: #3a3a3e; cursor: default; box-shadow: none; transform: none; }

.hidden { display: none !important; }

.import-force-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-top: 10px;
  font-size: 11.5px;
  line-height: 1.4;
  color: var(--muted);
  cursor: pointer;
}
.import-force-row input[type="checkbox"] {
  margin-top: 2px;
  flex-shrink: 0;
  width: 15px;
  height: 15px;
  accent-color: var(--accent);
}

.progress-bar {
  margin-top: 10px;
  height: 7px;
  border-radius: 4px;
  background: rgba(255,255,255,0.08);
  overflow: hidden;
}
#import-progress-fill {
  height: 100%;
  width: 0%;
  background: var(--accent);
  transition: width 0.2s var(--ease-out);
}
#import-progress-text {
  margin-top: 6px;
  font-size: 12px;
  color: var(--muted);
}

#stats { font-size: 13px; line-height: 1.7; }
#stats .stat-row { display: flex; justify-content: space-between; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; }

button.secondary {
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--panel-border);
  color: var(--text);
  box-shadow: none;
}
button.secondary:hover { background: rgba(255,255,255,0.12); box-shadow: none; }

.btn-icon-label { display: flex; align-items: center; justify-content: center; gap: 6px; }

.muted-path {
  font-size: 12px;
  color: var(--muted);
  word-break: break-all;
  margin-bottom: 8px;
  line-height: 1.4;
}
.btn-row { display: flex; gap: 8px; margin-top: 8px; }
.btn-row button { width: auto; flex: 1; }

#render-library-input {
  width: 100%;
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--panel-border);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  font-size: 12px;
}
#render-library-change { margin-top: 4px; }

#target-area-edit { margin-top: 10px; }
#target-area-input {
  width: 100%;
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--panel-border);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  font-size: 12px;
}

.legend-gradient {
  height: 12px;
  border-radius: 6px;
  background: linear-gradient(90deg, hsl(0,70%,50%), hsl(60,70%,50%), hsl(120,70%,50%));
}
.legend-labels {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--muted);
  margin-top: 4px;
}

#tile-tooltip {
  position: absolute;
  z-index: 1100;
  pointer-events: none;
  background: var(--panel-bg);
  backdrop-filter: blur(16px) saturate(180%);
  -webkit-backdrop-filter: blur(16px) saturate(180%);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-sm);
  padding: 5px 9px;
  font-size: 12px;
  transform: translate(12px, 12px);
}

#context-menu, #tool-banner {
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

#context-menu {
  position: absolute;
  z-index: 1200;
  background: var(--panel-bg);
  backdrop-filter: blur(24px) saturate(180%);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  min-width: 220px;
  overflow: hidden;
  box-shadow: var(--shadow-lg);
}
.ctx-header {
  padding: 10px 14px;
  font-size: 12px;
  color: var(--muted);
  border-bottom: 1px solid var(--panel-border);
}
.ctx-item {
  padding: 11px 14px;
  font-size: 13px;
  cursor: pointer;
  transition: background 0.12s var(--ease-out);
}
.ctx-item:hover { background: rgba(10,132,255,0.22); }
.ctx-item.disabled { color: var(--muted); cursor: default; pointer-events: none; }

#comment-form {
  position: absolute;
  z-index: 1250;
  width: 280px;
  background: var(--panel-bg);
  backdrop-filter: blur(24px) saturate(180%);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
}
#comment-form input, #comment-form textarea {
  width: 100%;
  background: rgba(255,255,255,0.06);
  color: var(--text);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  font-size: 13px;
  font-family: inherit;
  transition: border-color 0.15s var(--ease-out);
}
#comment-form textarea { margin-top: 8px; resize: vertical; }
#comment-form input:focus, #comment-form textarea:focus { outline: none; border-color: var(--accent); }

.tool-btn-active { background: var(--accent) !important; color: white !important; border-color: transparent !important; }

/* Присутствие "вживую" (запрос от 31.08.2026) — кто ещё сейчас на сайте. */
.presence-row { display: flex; align-items: center; gap: 6px; font-size: 12px; padding: 3px 0; }
.presence-row .activity { color: var(--muted); margin-left: auto; font-size: 11px; white-space: nowrap; }

.leaflet-div-icon.presence-avatar { background: transparent; border: none; }
.presence-dot {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #0f172a;
  font-weight: 700;
  font-size: 11px;
  border: 2px solid #0f172a;
  box-shadow: 0 2px 6px rgba(0,0,0,0.5);
}
.leaflet-tooltip.presence-label {
  background: rgba(15,23,42,0.9);
  color: #e2e8f0;
  border: none;
  font-size: 11px;
  font-weight: 600;
  box-shadow: 0 2px 6px rgba(0,0,0,0.4);
}
.leaflet-tooltip.presence-label::before { display: none; }

/* Реальная GPS-позиция устройства (запрос от 03.09.2026) — отдельно от
   "куда сейчас смотрит на карте" (presence-avatar выше): пилоту в поле
   нужно видеть, где он физически стоит, и оценивать покрытие вокруг. Точка
   пульсирует, как "you are here" в Google/Apple Maps — иначе на плотной
   сетке квадратов её легко потерять среди прочих цветных элементов. */
#gps-toggle.active { background: var(--accent); color: white; border-color: transparent; }
.leaflet-div-icon.gps-marker, .leaflet-div-icon.track-marker { background: transparent; border: none; }
#pilot-mode-toggle.active { background: var(--accent); color: white; border-color: transparent; }

/* "Полётное задание" (запрос от 03.09.2026, расширено 04.09.2026 до
   отдельной широкой панели — аналог собственного окна Litchi Hub) —
   маршрут-змейка над выбранными квадратами сетки, экспорт в .kmz для DJI Fly. */
#mission-view {
  position: absolute;
  top: 0; left: 0; bottom: 0;
  width: 420px;
  max-width: 92vw;
  z-index: 950;
  background: var(--panel-bg);
  border-right: 1px solid var(--panel-border);
  backdrop-filter: blur(24px) saturate(180%);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  box-shadow: var(--shadow-lg);
  padding: 64px 20px 24px;
  overflow-y: auto;
  animation: dashIn 0.28s var(--ease-spring);
}
#mission-view.hidden { display: none; }

.mission-view-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 5;
  margin: -64px -20px 14px;
  padding: 64px 20px 14px;
  background: rgb(8, 10, 16);
}
.mission-view-header h2 { margin: 0; font-size: 18px; font-weight: 800; letter-spacing: -0.01em; }

.mission-info-banner {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  background: rgba(10,132,255,0.12);
  border: 1px solid rgba(10,132,255,0.3);
  border-radius: var(--radius-sm);
  padding: 10px 10px 10px 12px;
  font-size: 11.5px;
  line-height: 1.5;
  margin-bottom: 14px;
}
.mission-info-banner button { flex-shrink: 0; background: transparent; box-shadow: none; padding: 2px; width: auto; color: var(--muted); }
.mission-info-banner button:hover { color: var(--text); background: rgba(255,255,255,0.1); }
.mission-info-banner.hidden { display: none; }

.mission-summary {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 5px;
  margin-bottom: 14px;
}
.mission-summary > div {
  background: rgba(255,255,255,0.045);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-sm);
  padding: 8px 1px;
  text-align: center;
}
.mission-summary b { display: block; font-size: 13px; font-variant-numeric: tabular-nums; }
.mission-summary span { font-size: 8.5px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.01em; }

.mission-mode-toggle { display: flex; gap: 6px; margin-top: 4px; margin-bottom: 8px; }
.mission-mode-btn {
  flex: 1;
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--panel-border);
  color: var(--muted);
  border-radius: var(--radius-sm);
  padding: 8px 6px;
  font-size: 11.5px;
  box-shadow: none;
}
.mission-mode-btn:hover { background: rgba(255,255,255,0.1); box-shadow: none; }
.mission-mode-btn.active { background: var(--accent); color: white; border-color: transparent; }
.mission-summary.hidden { display: none; }

.mission-section-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  margin: 16px 0 4px;
}

.mission-field-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 8px;
  font-size: 12.5px;
}
.mission-field-row label { color: var(--muted); flex: 1; cursor: default; }
.mission-field-row input[type="number"],
.mission-field-row input[type="text"] {
  width: 76px;
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--panel-border);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 6px 6px 6px 8px;
  font-size: 12.5px;
  /* text-align:right раньше выталкивал цифры прямо под нативные
     стрелочки-спиннер числового поля — на реальном Chrome они визуально
     наезжали друг на друга (репорт от 04.09.2026). Слева — как в обычном
     числовом поле браузера, спиннеру всегда есть куда рисоваться. */
  text-align: left;
}
.mission-field-row input:focus { outline: none; border-color: var(--accent); }
.mission-field-row .dash-select { width: 190px; padding: 6px 8px; font-size: 12px; }

.mission-field-input { display: flex; align-items: center; gap: 4px; }
.mission-field-input span { color: var(--muted); font-size: 11px; }
.mission-orientation-input { gap: 6px; }
.mission-orientation-input input[type="range"] {
  flex: 1;
  width: auto;
  padding: 0;
  background: transparent;
  border: none;
  accent-color: var(--accent);
}
.mission-orientation-input input[type="number"] { width: 54px; padding-right: 2px; }

.mission-advanced-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: transparent;
  border: 1px solid var(--panel-border);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  margin-top: 14px;
  font-size: 12.5px;
  box-shadow: none;
}
.mission-advanced-toggle:hover { background: rgba(255,255,255,0.08); box-shadow: none; }
.mission-advanced-toggle svg { transition: transform 0.2s var(--ease-out); }
.mission-advanced-toggle.open svg { transform: rotate(180deg); }
#mission-advanced { margin-top: 4px; }
#mission-advanced.hidden { display: none; }

.mission-toggle-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-top: 10px;
  font-size: 12px;
  line-height: 1.4;
  color: var(--text);
  cursor: pointer;
}
.mission-toggle-row input[type="checkbox"] {
  margin-top: 2px;
  flex-shrink: 0;
  width: 15px;
  height: 15px;
  accent-color: var(--accent);
}
.mission-note { margin-top: 10px; font-size: 10.5px; line-height: 1.5; }

#mission-name {
  width: 100%;
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--panel-border);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  font-size: 12.5px;
}
#mission-name:focus { outline: none; border-color: var(--accent); }
#mission-status { margin-top: 8px; }
#mission-status.ok { color: var(--success); }
#mission-status.err { color: var(--danger); }
#mission-status.warn { color: var(--warning); }
.mission-howto {
  margin-top: 14px;
  padding-top: 10px;
  border-top: 1px solid var(--panel-border);
  font-size: 11px;
  line-height: 1.55;
}
.mission-howto code {
  background: rgba(255,255,255,0.08);
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 10.5px;
  word-break: break-all;
}
.gps-dot-outer {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: color-mix(in srgb, var(--gps-color) 30%, transparent);
  animation: gpsPulse 2s ease-in-out infinite;
}
.gps-dot-inner {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 2px solid white;
  box-shadow: 0 1px 4px rgba(0,0,0,0.6);
}
@keyframes gpsPulse {
  0%, 100% { transform: scale(0.85); }
  50% { transform: scale(1.15); }
}

.comment-popup b { color: var(--accent-hover); }
.comment-popup .meta { font-size: 11px; color: var(--muted); margin-top: 4px; }
.comment-popup button { margin-top: 8px; font-size: 12px; padding: 6px 10px; }

/* Leaflet-попапы по умолчанию белые с тёмным текстом — переопределяем под
   тёмную тему приложения, иначе светлый текст комментария невидим. */
.leaflet-popup-content-wrapper, .leaflet-popup-tip {
  background: var(--panel-bg);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  color: var(--text);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
}
.leaflet-popup-content { color: var(--text); margin: 12px 14px; }
.leaflet-popup-close-button { color: var(--muted) !important; }
.leaflet-popup { animation: panelIn 0.18s var(--ease-out); }

.leaflet-tooltip.ruler-label {
  background: var(--warning);
  color: #1c1400;
  border: none;
  font-weight: 600;
  font-size: 12px;
  border-radius: 8px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.4);
}
.leaflet-tooltip.ruler-label::before { display: none; }

/* Плавное появление всплывающих панелей/меню/попапов при снятии .hidden —
   работает "само", без JS: анимация проигрывается заново каждый раз, когда
   элемент переходит display:none -> отображается. */
#tile-detail-panel:not(.hidden), #context-menu:not(.hidden), #comment-form:not(.hidden),
#notif-panel:not(.hidden), #rename-form:not(.hidden) {
  animation: panelIn 0.22s var(--ease-out);
}

#tile-detail-panel {
  position: absolute;
  top: 14px;
  right: 14px;
  z-index: 1000;
  width: 360px;
  max-height: calc(100% - 28px);
  overflow-y: auto;
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  padding: 18px;
  backdrop-filter: blur(24px) saturate(180%);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  box-shadow: var(--shadow-lg);
}
#detail-close {
  position: absolute;
  top: 10px;
  right: 12px;
  width: 28px;
  height: 28px;
  background: rgba(255,255,255,0.06);
  border-radius: 50%;
  font-size: 16px;
  line-height: 1;
  padding: 0;
  color: var(--muted);
  box-shadow: none;
  transition: transform 0.25s var(--ease-spring), background 0.15s var(--ease-out), color 0.15s var(--ease-out);
}
#detail-close:hover { background: rgba(255,69,58,0.18); color: var(--danger); transform: rotate(90deg); }
#detail-content h3 { margin-top: 0; }
#detail-content .row { display: flex; justify-content: space-between; margin: 6px 0; font-size: 13px; }
#detail-content .muted { color: var(--muted); font-size: 12px; }
#detail-content h4 {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  margin: 16px 0 6px;
}
.session-row {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  padding: 4px 0;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}
.badge-warn {
  display: inline-block;
  background: rgba(255,159,10,0.16);
  color: var(--warning);
  border: 1px solid rgba(255,159,10,0.4);
  border-radius: 8px;
  padding: 6px 8px;
  font-size: 12px;
  margin-top: 8px;
}
.badge-ok {
  display: inline-block;
  background: rgba(48,209,88,0.15);
  color: var(--success);
  border: 1px solid rgba(48,209,88,0.35);
  border-radius: 8px;
  padding: 6px 8px;
  font-size: 12px;
  margin-top: 8px;
}
#detail-render-status {
  margin-top: 10px;
  font-size: 12px;
  line-height: 1.5;
}
#detail-render-status.ok { color: var(--success); }
#detail-render-status.err { color: var(--danger); }

#rename-form input[type="text"] {
  width: 100%;
  background: rgba(255,255,255,0.06);
  color: var(--text);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-sm);
  padding: 9px 11px;
  font-size: 13px;
  transition: border-color 0.15s var(--ease-out);
}
#rename-form input[type="text"]:focus { outline: none; border-color: var(--accent); }
#rename-form { margin-bottom: 14px; }
#rename-error { color: var(--danger); margin: 6px 0 0; }

/* "Интересные факты" (запрос от 31.08.2026) — суммарная площадь, дистанция,
   время в полёте, оценка энергозатрат, % покрытия города. */
.fun-stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.fun-stat {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-sm);
  padding: 10px;
  transition: background 0.15s var(--ease-out), transform 0.15s var(--ease-out);
}
.fun-stat:hover { background: rgba(255,255,255,0.06); transform: translateY(-1px); }
.fun-stat-icon {
  width: 26px;
  height: 26px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  background: rgba(10,132,255,0.16);
  color: var(--accent-hover);
}
.fun-stat-value {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
}
.fun-stat-label {
  font-size: 10.5px;
  color: var(--muted);
  line-height: 1.3;
  margin-top: 1px;
}
.fun-stats-note {
  margin: 10px 0 0;
  font-size: 10.5px;
  line-height: 1.5;
  opacity: 0.85;
}

/* Отчётная плашка суммарного покрытия — всегда на виду поверх карты, не
   нужно открывать панель (запрос от 31.08.2026: "чтобы было всегда видно";
   расширено 01.09.2026: "больше и чётче видна сразу, как отчёт для всех
   зрителей"). Клик открывает карточку "Интересные факты" в сайдбаре. */
#coverage-pill {
  position: absolute;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  z-index: 950;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 12px 24px;
  background: var(--panel-bg);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border: 1px solid var(--panel-border);
  border-radius: 20px;
  box-shadow: var(--shadow-lg);
  color: var(--text);
  cursor: pointer;
  transition: transform 0.15s var(--ease-out), background 0.15s var(--ease-out);
}
#coverage-pill:hover { background: rgba(255,255,255,0.12); transform: translateX(-50%) translateY(-2px); }
.coverage-pill-main { display: flex; align-items: baseline; gap: 8px; }
.coverage-pill-value {
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--success);
  font-variant-numeric: tabular-nums;
}
.coverage-pill-caption { font-size: 13px; color: var(--muted); font-weight: 600; }
.coverage-pill-sub { font-size: 11.5px; color: var(--muted); }
#coverage-pill .pulse-dot {
  position: absolute;
  top: 10px;
  left: 10px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--success);
  animation: pillPulse 2s ease-in-out infinite;
}

/* Переключатель подложки карты (запрос от 01.09.2026: карта/спутник). */
#basemap-switcher {
  position: absolute;
  right: 14px;
  bottom: 18px;
  z-index: 950;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.basemap-btn {
  width: 38px;
  height: 38px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--panel-bg);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-sm);
  color: var(--text);
  box-shadow: var(--shadow-md);
  box-sizing: border-box;
  transition: background 0.15s var(--ease-out), transform 0.15s var(--ease-out);
}
.basemap-btn:hover { background: rgba(255,255,255,0.14); }
.basemap-btn:active { transform: scale(0.93); }
.basemap-btn.active { background: var(--accent); color: white; border-color: transparent; }

/* Небольшой отступ отделяет переключатель "скрыть слои" (не взаимоисключающая
   кнопка, просто вкл/выкл) от пары карта/спутник ниже. */
#declutter-toggle { margin-bottom: 4px; }
#declutter-toggle.active { background: var(--warning); color: #241a00; border-color: transparent; }

/* Скрыть точки и закраску квадратов (запрос от 02.09.2026: "быстрее
   ориентироваться по карте") — кнопка выше или пробел. Заливку квадратов
   переключаем через JS (setStyle() на каждом полигоне + значение по
   умолчанию при отрисовке, см. refreshGrid()/drawFocusedTileSubcells() в
   app.js) — CSS-переопределение fill-opacity с !important почему-то не
   побеждало SVG presentation-атрибут в реальном Chrome, хотя правило
   совпадало по селектору (нашли 02.09.2026). Точки прячем через пропадание
   всего pane — тут CSS отработал штатно. pointsShadowPane — отдельный слой
   теней точек (см. addGlowPoint()/03.09.2026, фикс "чёрных пятен"), его
   тоже нужно прятать отдельно, иначе тени остаются висеть на карте даже
   когда сами точки выключены (репорт с реального iPhone/Chrome 03.09.2026). */
#map.declutter .leaflet-points-pane,
#map.declutter .leaflet-pointsShadow-pane {
  display: none;
}

/* Плашка активного инструмента (линейка/комментарий) — запрос от 31.08.2026:
   раньше подсказка и кнопка очистки сидели только в сайдбаре, а на телефоне
   он часто свёрнут во время работы с картой — пользователь не понимал, как
   выйти из режима линейки или убрать нарисованную линию. Плашка на карте
   видна всегда, независимо от сайдбара, и даёт явную кнопку "Готово". */
#tool-banner {
  position: absolute;
  top: 66px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 950;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px 9px 16px;
  background: var(--panel-bg);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border: 1px solid var(--panel-border);
  border-radius: 999px;
  box-shadow: var(--shadow-md);
  font-size: 13px;
  color: var(--text);
  max-width: calc(100vw - 28px);
  animation: panelIn 0.22s var(--ease-out);
}
#tool-banner-text { white-space: nowrap; }
.tool-banner-actions { display: flex; gap: 6px; }
.tool-banner-actions button {
  width: auto;
  padding: 6px 12px;
  font-size: 12px;
  white-space: nowrap;
}
#tool-banner-done { background: var(--accent); color: white; border: none; box-shadow: none; }
#tool-banner-done:hover { background: var(--accent-hover); }

/* Анимация "прогресс с начала" (запрос от 02.09.2026) — плашка сверху с
   текущим днём и прогресс-баром, поверх карты, пока идёт показ. */
#playback-banner {
  position: absolute;
  top: 66px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 960;
  width: min(420px, calc(100vw - 28px));
  padding: 10px 16px;
  background: var(--panel-bg);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border: 1px solid var(--panel-border);
  border-radius: 16px;
  box-shadow: var(--shadow-lg);
  color: var(--text);
  animation: panelIn 0.25s var(--ease-out);
}
.playback-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 8px; }
#playback-text { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#playback-stop { width: auto; padding: 5px 12px; font-size: 12px; flex-shrink: 0; }
.playback-bar { height: 5px; border-radius: 3px; background: rgba(255,255,255,0.1); overflow: hidden; }
#playback-bar-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent), var(--success));
  transition: width 0.3s var(--ease-out);
}

/* Плавный переход цвета/прозрачности квадратов сетки при наведении —
   Leaflet просто переставляет атрибуты стиля через setStyle(), без
   транзишена они "прыгают" резко. */
path.leaflet-interactive { transition: fill-opacity 0.15s var(--ease-out), fill 0.15s var(--ease-out); }

/* ------------------------------------------------------------------
   Полноэкранная статистика и рейтинг пилотов (запрос от 01.09.2026):
   скорость заполнения города, качество покрытия, темп по дням — цель
   мотивировать команду летать быстрее по мере подключения новых пилотов.
   ------------------------------------------------------------------ */
#dashboard-view {
  position: absolute;
  inset: 0;
  z-index: 3000;
  background: rgba(4, 5, 8, 0.88);
  backdrop-filter: blur(28px) saturate(180%);
  -webkit-backdrop-filter: blur(28px) saturate(180%);
  overflow: hidden;
  animation: dashIn 0.32s var(--ease-spring);
}
@keyframes dashIn {
  from { opacity: 0; transform: scale(0.97); }
  to   { opacity: 1; transform: scale(1); }
}

#dashboard-scroll {
  height: 100%;
  overflow-y: auto;
  padding: 24px 28px 60px;
  max-width: 1080px;
  margin: 0 auto;
}

/* Прячем системный скроллбар у прокручиваемых панелей (запрос от 01.09.2026
   — на Windows/Chrome он рисуется толстым и светлым, выбивается из тёмного
   дизайна). Сама прокрутка колесом/пальцем работает как обычно. */
#dashboard-scroll, #sidebar, #notif-panel, #tile-detail-panel, #mission-view {
  scrollbar-width: none;
  -ms-overflow-style: none;
}
#dashboard-scroll::-webkit-scrollbar,
#sidebar::-webkit-scrollbar,
#notif-panel::-webkit-scrollbar,
#tile-detail-panel::-webkit-scrollbar,
#mission-view::-webkit-scrollbar {
  display: none;
}

.dashboard-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 5;
  /* Растягиваем фон на всю ширину #dashboard-scroll (компенсируя его же
     padding отрицательным margin) и красим непрозрачным — иначе при скролле
     заголовок остаётся на месте (sticky), но сквозь него просвечивает и с
     ним визуально накладывается контент карточек снизу (репорт от 03.09.2026
     из реального Chrome: "надпись остаётся на месте и перекрывает текст"). */
  margin: -24px -28px 20px;
  padding: 24px 28px 16px;
  background: rgb(8, 10, 16);
}
.dashboard-header h1 {
  font-size: 24px;
  font-weight: 800;
  letter-spacing: -0.02em;
  margin: 0;
  background: linear-gradient(90deg, var(--text), var(--muted));
  -webkit-background-clip: text;
  background-clip: text;
}
#dashboard-close { width: 34px; height: 34px; }
#dashboard-close svg { width: 16px; height: 16px; }

.dash-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.dash-card-wide { grid-column: 1 / -1; }

.dash-card {
  background: rgba(255,255,255,0.045);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  padding: 18px 20px;
  animation: cardIn 0.45s var(--ease-out) backwards;
}
.dash-grid .dash-card:nth-child(1) { animation-delay: 0.04s; }
.dash-grid .dash-card:nth-child(2) { animation-delay: 0.1s; }
.dash-grid .dash-card:nth-child(3) { animation-delay: 0.16s; }
.dash-grid .dash-card:nth-child(4) { animation-delay: 0.22s; }

.dash-card h2 {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.01em;
  margin: 0 0 4px;
  text-transform: none;
  color: var(--text);
}
.dash-subtitle { margin-bottom: 12px; }

.dash-chart-wrap { width: 100%; }
.chart-svg { width: 100%; height: auto; display: block; overflow: visible; }
.chart-svg .chart-line { transition: none; }
.chart-svg .chart-area { transition: opacity 0.6s var(--ease-out); }
.chart-axis-label { font-size: 10px; fill: var(--muted); }
.chart-tooltip-dot { fill: var(--text); }

.dash-bar-track { fill: rgba(255,255,255,0.06); }
.dash-bar { transition: height 0.55s var(--ease-spring), y 0.55s var(--ease-spring); }

/* Качество покрытия — горизонтальная составная полоса зелёный/жёлтый/красный. */
.quality-bar {
  display: flex;
  height: 22px;
  border-radius: 8px;
  overflow: hidden;
  background: rgba(255,255,255,0.06);
}
.quality-bar > div { height: 100%; width: 0; transition: width 0.7s var(--ease-spring); }
.quality-legend { display: flex; flex-direction: column; gap: 6px; margin-top: 14px; font-size: 12.5px; }
.quality-legend-row { display: flex; align-items: center; gap: 8px; }
.quality-legend-row b { margin-left: auto; font-variant-numeric: tabular-nums; }

/* Просмотр точек по дням (запрос от 02.09.2026). */
.dash-select {
  width: 100%;
  background: rgba(255,255,255,0.06);
  color: var(--text);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-sm);
  padding: 9px 11px;
  font-size: 13px;
  transition: border-color 0.15s var(--ease-out);
}
.dash-select:focus { outline: none; border-color: var(--accent); }
.dash-select option { background: #0f172a; color: var(--text); }

.day-picker { display: flex; flex-wrap: wrap; gap: 8px; }
.day-chip {
  width: auto;
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 8px 14px;
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-sm);
  color: var(--text);
  box-shadow: none;
  animation: cardIn 0.3s var(--ease-out) backwards;
}
.day-chip:hover { background: rgba(255,255,255,0.1); box-shadow: none; }
.day-chip.active { background: var(--accent); border-color: transparent; }
.day-chip-date { font-size: 13px; font-weight: 700; }
.day-chip-count { font-size: 10.5px; color: var(--muted); }
.day-chip.active .day-chip-count { color: rgba(255,255,255,0.85); }

/* Рейтинг пилотов */
.dash-pilots { display: flex; flex-direction: column; gap: 10px; }
.pilot-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 16px;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-sm);
  animation: cardIn 0.4s var(--ease-out) backwards;
}
.pilot-rank {
  width: 34px;
  height: 34px;
  flex-shrink: 0;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 14px;
  background: rgba(255,255,255,0.07);
}
.pilot-rank.gold { background: linear-gradient(135deg, #ffd76a, #b8860b); color: #241a00; }
.pilot-rank.silver { background: linear-gradient(135deg, #eef1f5, #9aa4b2); color: #1c1f24; }
.pilot-rank.bronze { background: linear-gradient(135deg, #e0a672, #8b5a2b); color: #241400; }
.pilot-name { font-weight: 700; font-size: 14px; }
.pilot-drone { font-size: 11px; color: var(--muted); }
.pilot-stats {
  margin-left: auto;
  display: grid;
  grid-template-columns: repeat(4, auto);
  gap: 4px 18px;
  text-align: right;
}
.pilot-stat-value { font-size: 14px; font-weight: 700; font-variant-numeric: tabular-nums; }
.pilot-stat-label { font-size: 9.5px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.03em; }

@media (max-width: 900px) {
  .dash-grid { grid-template-columns: 1fr; }
  .pilot-stats { grid-template-columns: repeat(2, auto); }
}
@media (max-width: 700px) {
  #dashboard-scroll { padding: 18px 14px 48px; }
  .dashboard-header { margin: -18px -14px 20px; padding: 18px 14px 14px; }
  .dashboard-header h1 { font-size: 19px; }
  .pilot-card { flex-wrap: wrap; }
  .pilot-stats { margin-left: 48px; grid-template-columns: repeat(2, auto); }
}

/* ------------------------------------------------------------------
   Мобильные экраны (телефон/планшет) — запрос от 30.08.2026: карта должна
   нормально открываться и по ссылке туннеля с телефона, без установки
   отдельного приложения. Тач-цели крупнее, шторка на весь экран, панели
   не вылезают за пределы экрана.
   ------------------------------------------------------------------ */
@media (max-width: 700px) {
  #sidebar { width: 85vw; max-width: 340px; padding-top: 64px; }
  #mission-view { width: 92vw; max-width: 420px; }
  .mission-summary { grid-template-columns: repeat(2, 1fr); }
  #tile-detail-panel {
    width: calc(100vw - 28px);
    left: 14px;
    right: 14px;
    max-height: calc(100% - 100px);
  }
  #comment-form { width: calc(100vw - 40px); }
  #notif-panel { width: calc(100vw - 92px); max-width: 320px; }
  #context-menu { min-width: 180px; }

  button, .ctx-item { min-height: 44px; } /* минимальная тач-цель по гайдлайну Apple */
  .ctx-item { display: flex; align-items: center; }
  #sidebar-toggle, #notif-bell { width: 44px; height: 44px; }
  #notif-bell { left: 68px; }

  /* На маленьком экране тултип при наведении бесполезен (наведения нет) —
     не даём ему торчать поверх и мешать тапам. */
  #tile-tooltip { display: none; }

  #sidebar-backdrop { display: block; }

  #coverage-pill {
    bottom: calc(14px + env(safe-area-inset-bottom, 0px));
    padding: 9px 16px;
    max-width: calc(100vw - 108px); /* оставляем место переключателю подложки справа */
  }
  .coverage-pill-value { font-size: 21px; }
  .coverage-pill-caption { font-size: 11.5px; }
  .coverage-pill-sub { font-size: 10px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }

  #basemap-switcher { bottom: calc(14px + env(safe-area-inset-bottom, 0px)); right: 10px; }
  .basemap-btn { width: 34px; height: 34px; }

  .fun-stats-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
  .fun-stat { padding: 8px; }
  .fun-stat-value { font-size: 15px; }

  #tool-banner {
    top: 64px;
    max-width: calc(100vw - 24px);
    padding: 8px 8px 8px 12px;
    font-size: 12px;
  }
  #tool-banner-text { white-space: normal; }
}
