/* ─── Reset & Base ─────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #1c1f26;
  --bg2: #23262f;
  --bg3: #2a2d37;
  --surface: #23262f;
  --surface2: #282b35;
  --border: rgba(255,255,255,0.06);
  --border2: rgba(255,255,255,0.10);
  --accent: #3b82f6;
  --accent-light: #1a2d4a;
  --accent-hover: #60a5fa;
  --danger: #f87171;
  --text: #e2e5ed;
  --text2: #8b93a8;
  --text3: #525c72;
  --sidebar-w: 340px;
  --header-h: 58px;
  --radius: 14px;
  --radius-sm: 10px;
  --radius-xs: 6px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.25), 0 1px 2px rgba(0,0,0,0.18);
  --shadow: 0 4px 12px rgba(0,0,0,0.35), 0 1px 4px rgba(0,0,0,0.22);
  --shadow-lg: 0 8px 30px rgba(0,0,0,0.45), 0 2px 8px rgba(0,0,0,0.28);
  --shadow-xl: 0 16px 48px rgba(0,0,0,0.55);
  --transition: 0.2s cubic-bezier(0.4,0,0.2,1);
  --transition-fast: 0.12s cubic-bezier(0.4,0,0.2,1);
}

body {
  font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  height: 100dvh;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

/* ─── Layout ────────────────────────────────────────────────────────── */
#app {
  display: flex;
  height: 100dvh;
  width: 100vw;
}

/* ─── Sidebar ───────────────────────────────────────────────────────── */
#sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  background: var(--bg2);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  transition: width 0.28s cubic-bezier(0.4,0,0.2,1),
              min-width 0.28s cubic-bezier(0.4,0,0.2,1);
  overflow: hidden;
  z-index: 10;
  box-shadow: 1px 0 0 var(--border), 4px 0 16px rgba(0,0,0,0.05);
}

#sidebar.collapsed {
  width: 0;
  min-width: 0;
}

#sidebar-header {
  height: var(--header-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px 0 18px;
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

#logo {
  display: flex;
  align-items: center;
  gap: 9px;
  font-weight: 700;
  font-size: 15px;
  color: var(--accent);
  letter-spacing: -0.3px;
  white-space: nowrap;
  user-select: none;
}

#logo svg {
  color: var(--accent);
  filter: drop-shadow(0 0 6px rgba(37,99,235,0.25));
}

#sidebar-toggle {
  background: none;
  border: none;
  color: var(--text3);
  cursor: pointer;
  padding: 7px;
  border-radius: var(--radius-xs);
  display: flex;
  align-items: center;
  transition: background var(--transition-fast), color var(--transition-fast);
  flex-shrink: 0;
}
#sidebar-toggle:hover {
  background: var(--bg3);
  color: var(--text2);
}

#sidebar-content {
  flex: 1;
  overflow-y: auto;
  padding: 6px 0 16px;
  scrollbar-width: thin;
  scrollbar-color: var(--border2) transparent;
}
#sidebar-content::-webkit-scrollbar { width: 3px; }
#sidebar-content::-webkit-scrollbar-thumb {
  background: var(--border2);
  border-radius: 2px;
}

.sidebar-section {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}
.sidebar-section:last-child { border-bottom: none; }

.section-title {
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.9px;
  text-transform: uppercase;
  color: var(--text3);
  margin-bottom: 11px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* ─── Search ────────────────────────────────────────────────────────── */
.search-box {
  position: relative;
  display: flex;
  align-items: center;
}

.search-icon {
  position: absolute;
  left: 11px;
  color: var(--text3);
  pointer-events: none;
  transition: color var(--transition-fast);
}

#search-input {
  width: 100%;
  background: var(--surface2);
  border: 1.5px solid var(--border2);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 13px;
  padding: 9px 32px 9px 33px;
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition),
              background var(--transition);
  font-family: inherit;
}
#search-input::placeholder { color: var(--text3); }
#search-input:focus {
  border-color: var(--accent);
  background: var(--surface2);
  box-shadow: 0 0 0 3px rgba(59,130,246,0.15);
}
#search-input:focus + .search-icon,
.search-box:focus-within .search-icon {
  color: var(--accent);
}

#search-clear {
  position: absolute;
  right: 8px;
  background: none;
  border: none;
  color: var(--text3);
  cursor: pointer;
  padding: 3px;
  display: flex;
  align-items: center;
  border-radius: 4px;
  transition: color var(--transition-fast);
}
#search-clear:hover { color: var(--text2); }
#search-clear.hidden { display: none; }

#search-results {
  background: var(--surface);
  border: 1px solid var(--border2);
  border-radius: var(--radius-sm);
  margin-top: 7px;
  max-height: 220px;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  animation: fadeInDown 0.15s ease;
}
#search-results.hidden { display: none; }

@keyframes fadeInDown {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.search-result-item {
  padding: 9px 13px;
  font-size: 13px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  transition: background var(--transition-fast);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.search-result-item:last-child { border-bottom: none; }
.search-result-item:hover { background: var(--accent-light); }
.search-result-item .res-name { color: var(--text); font-weight: 500; flex: 1; }
.search-result-item .res-type {
  color: var(--text3);
  font-size: 10px;
  text-transform: uppercase;
  background: var(--bg3);
  padding: 2px 7px;
  border-radius: 20px;
  flex-shrink: 0;
  font-weight: 600;
  letter-spacing: 0.4px;
}

/* ─── Layers — toggle switch style ──────────────────────────────── */
.layers-list {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.layer-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--transition-fast);
  user-select: none;
}
.layer-item:hover { background: var(--bg3); }

/* Hide native checkbox */
.layer-item input[type="checkbox"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
  pointer-events: none;
}

/* Custom toggle track */
.layer-toggle {
  position: relative;
  width: 34px;
  height: 19px;
  flex-shrink: 0;
  order: 999; /* push to right */
  margin-left: auto;
}

.layer-toggle::before {
  content: '';
  position: absolute;
  inset: 0;
  background: #3a3f4e;
  border-radius: 10px;
  transition: background var(--transition);
}

.layer-toggle::after {
  content: '';
  position: absolute;
  top: 2.5px;
  left: 2.5px;
  width: 14px;
  height: 14px;
  background: #c8cdd8;
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0,0,0,0.18);
  transition: transform var(--transition), box-shadow var(--transition);
}

.layer-item input:checked ~ .layer-toggle::before {
  background: var(--accent);
}
.layer-item input:checked ~ .layer-toggle::after {
  transform: translateX(15px);
  box-shadow: 0 1px 4px rgba(37,99,235,0.35);
}

.layer-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex-shrink: 0;
  box-shadow: 0 0 0 2px rgba(0,0,0,0.06);
}

.layer-label {
  flex: 1;
  font-size: 13px;
  color: var(--text);
  font-weight: 500;
  line-height: 1;
}
.layer-label small { color: var(--text3); font-size: 10px; font-weight: 400; margin-left: 3px; }

/* ─── Basemap — pill switcher ────────────────────────────────────── */
.basemap-list {
  display: flex;
  background: var(--bg3);
  border-radius: var(--radius-sm);
  padding: 3px;
  gap: 0;
}

.basemap-btn {
  flex: 1;
  padding: 7px 6px;
  background: transparent;
  border: none;
  border-radius: 8px;
  color: var(--text2);
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
  text-align: center;
  font-family: inherit;
  letter-spacing: 0.1px;
}
.basemap-btn:hover:not(.active) {
  color: var(--text);
  background: rgba(255,255,255,0.08);
}
.basemap-btn.active {
  background: var(--surface);
  color: var(--accent);
  font-weight: 600;
  box-shadow: var(--shadow-sm);
}

/* ─── Info panel ────────────────────────────────────────────────────── */
#info-section .section-title button {
  background: none;
  border: none;
  color: var(--text3);
  cursor: pointer;
  font-size: 13px;
  padding: 2px 6px;
  border-radius: 4px;
  transition: color var(--transition-fast), background var(--transition-fast);
}
#info-section .section-title button:hover {
  color: var(--danger);
  background: rgba(248,113,113,0.12);
}

#info-content {
  font-size: 12px;
  color: var(--text2);
  line-height: 1.6;
}

/* ─── Map area ──────────────────────────────────────────────────────── */
#map-wrap {
  flex: 1;
  position: relative;
  overflow: hidden;
}

#map {
  position: absolute;
  inset: 0;
}

.maplibregl-ctrl-top-right,
.maplibregl-ctrl-bottom-right,
.maplibregl-ctrl-bottom-left { display: none; }

/* ─── Custom map controls ───────────────────────────────────────────── */
#map-controls {
  position: absolute;
  top: 14px;
  right: 14px;
  display: flex;
  flex-direction: column;
  gap: 5px;
  z-index: 5;
}

.ctrl-btn {
  width: 40px;
  height: 40px;
  background: rgba(35,38,47,0.92);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid var(--border2);
  border-radius: var(--radius-sm);
  color: var(--text2);
  font-size: 20px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
  box-shadow: var(--shadow);
  font-family: inherit;
}
.ctrl-btn:hover {
  background: var(--surface);
  color: var(--accent);
  box-shadow: var(--shadow-lg);
  transform: translateY(-1px);
}
.ctrl-btn:active {
  transform: scale(0.92) translateY(0);
  box-shadow: var(--shadow-sm);
}
.ctrl-btn.active {
  background: var(--accent-light);
  color: var(--accent);
  border-color: rgba(59,130,246,0.35);
}

/* ─── Sidebar open button ───────────────────────────────────────────── */
#sidebar-open-btn {
  position: absolute;
  top: 14px;
  left: 14px;
  width: 40px;
  height: 40px;
  background: rgba(35,38,47,0.92);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid var(--border2);
  border-radius: var(--radius-sm);
  color: var(--text2);
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 5;
  box-shadow: var(--shadow);
  transition: all var(--transition-fast);
}
#sidebar-open-btn:hover {
  background: var(--surface);
  color: var(--accent);
  box-shadow: var(--shadow-lg);
  transform: translateY(-1px);
}
#sidebar.collapsed ~ #map-wrap #sidebar-open-btn { display: flex; }

/* ─── Footer ────────────────────────────────────────────────────────── */
#map-footer {
  position: absolute;
  bottom: 12px;
  left: 12px;
  display: flex;
  gap: 12px;
  font-size: 11px;
  color: var(--text2);
  background: rgba(35,38,47,0.88);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  padding: 5px 12px;
  border-radius: 20px;
  border: 1px solid var(--border2);
  pointer-events: none;
  z-index: 4;
  box-shadow: var(--shadow-sm);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.2px;
}

/* ─── Loading overlay ───────────────────────────────────────────────── */
#loading-overlay {
  position: absolute;
  inset: 0;
  background: rgba(28,31,38,0.88);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  transition: opacity 0.5s ease;
}
#loading-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

.loader-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  background: var(--surface);
  padding: 28px 36px;
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border);
}

.spinner {
  width: 36px;
  height: 36px;
  border: 2.5px solid var(--border2);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s cubic-bezier(0.4,0,0.6,1) infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

#loading-text {
  font-size: 13px;
  color: var(--text2);
  letter-spacing: 0.3px;
  font-weight: 500;
}

/* ─── Popup ─────────────────────────────────────────────────────────── */
.maplibregl-popup {
  animation: popupIn 0.18s cubic-bezier(0.34,1.56,0.64,1);
}
@keyframes popupIn {
  from { opacity: 0; transform: scale(0.88) translateY(4px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

.maplibregl-popup-content {
  background: var(--surface) !important;
  color: var(--text) !important;
  border: 1px solid var(--border2) !important;
  border-radius: var(--radius) !important;
  padding: 0 !important;
  box-shadow: var(--shadow-xl) !important;
  min-width: 200px;
  max-width: 300px;
  font-family: inherit !important;
  font-size: 12px !important;
  overflow: hidden;
}
.maplibregl-popup-tip { display: none !important; }
.maplibregl-popup-close-button {
  color: var(--text3) !important;
  font-size: 16px !important;
  width: 28px !important;
  height: 28px !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  top: 6px !important;
  right: 6px !important;
  background: none !important;
  border-radius: 6px !important;
  transition: color var(--transition-fast), background var(--transition-fast) !important;
}
.maplibregl-popup-close-button:hover {
  color: var(--danger) !important;
  background: rgba(248,113,113,0.12) !important;
}

.popup-inner { padding: 14px 16px 12px; }

.popup-title {
  font-weight: 600;
  font-size: 14px;
  color: var(--text);
  margin-bottom: 9px;
  padding-right: 24px;
  line-height: 1.35;
}

.popup-row {
  display: flex;
  gap: 8px;
  padding: 4px 0;
  border-bottom: 1px solid var(--border);
  font-size: 12px;
  align-items: baseline;
}
.popup-row:last-child { border-bottom: none; }
.popup-key {
  color: var(--text3);
  min-width: 70px;
  flex-shrink: 0;
  font-size: 11px;
  font-weight: 500;
}
.popup-val { color: var(--text2); font-weight: 500; }

.popup-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border-radius: 20px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  margin-bottom: 8px;
}
.badge-road     { background: rgba(194,65,12,0.18);  color: #fb923c; }
.badge-building { background: rgba(29,78,216,0.18);  color: #60a5fa; }
.badge-water    { background: rgba(3,105,161,0.18);  color: #38bdf8; }
.badge-green    { background: rgba(22,101,52,0.18);  color: #4ade80; }
.badge-boundary { background: rgba(185,28,28,0.18);  color: #f87171; }

/* ─── Scrollbar ─────────────────────────────────────────────────────── */
* { scrollbar-width: thin; scrollbar-color: var(--border2) transparent; }
::-webkit-scrollbar { width: 3px; height: 3px; }
::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 2px; }

/* ════════════════════════════════════════════════════════════════════
   TABS
   ════════════════════════════════════════════════════════════════════ */
#tab-bar {
  display: flex;
  background: var(--bg3);
  border-bottom: 1px solid var(--border);
  padding: 4px 6px;
  gap: 2px;
  flex-shrink: 0;
}

.tab-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 7px 4px;
  background: transparent;
  border: none;
  border-radius: var(--radius-xs);
  color: var(--text3);
  font-size: 11.5px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-fast);
  font-family: inherit;
  white-space: nowrap;
  letter-spacing: 0.1px;
}
.tab-btn:hover:not(.active) {
  background: rgba(255,255,255,0.06);
  color: var(--text2);
}
.tab-btn.active {
  background: var(--surface2);
  color: var(--accent);
  font-weight: 600;
  box-shadow: var(--shadow-sm);
}
.tab-btn svg { flex-shrink: 0; }

.tab-panel { display: block; }
.tab-panel.hidden { display: none; }

/* ════════════════════════════════════════════════════════════════════
   COMMON FORM ELEMENTS
   ════════════════════════════════════════════════════════════════════ */
.field-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-bottom: 12px;
}
.field-group:last-child { margin-bottom: 0; }

.field-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: 0.7px;
}

.field-input {
  width: 100%;
  background: var(--surface2);
  border: 1.5px solid var(--border2);
  border-radius: var(--radius-xs);
  color: var(--text);
  font-size: 13px;
  padding: 8px 10px;
  outline: none;
  font-family: inherit;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.field-input::placeholder { color: var(--text3); }
.field-input:focus {
  border-color: var(--accent);
  background: var(--surface);
  box-shadow: 0 0 0 3px rgba(37,99,235,0.10);
}

.field-select {
  width: 100%;
  background: var(--surface2);
  border: 1.5px solid var(--border2);
  border-radius: var(--radius-xs);
  color: var(--text);
  font-size: 13px;
  padding: 8px 10px;
  outline: none;
  font-family: inherit;
  cursor: pointer;
  transition: border-color var(--transition), box-shadow var(--transition);
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%239ca3af' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 30px;
}
.field-select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37,99,235,0.10);
}

/* ─── Primary button ──────────────────────────────────────────────── */
.primary-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 9px 16px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: background var(--transition-fast), transform var(--transition-fast), box-shadow var(--transition-fast);
  box-shadow: 0 2px 8px rgba(37,99,235,0.25);
  white-space: nowrap;
}
.primary-btn:hover { background: var(--accent-hover); box-shadow: 0 4px 14px rgba(37,99,235,0.35); transform: translateY(-1px); }
.primary-btn:active { transform: scale(0.97) translateY(0); }
.primary-btn.active {
  background: #e53935;
  box-shadow: 0 2px 8px rgba(229,57,53,0.3);
}
.primary-btn.full-width { width: 100%; }

/* ─── Action buttons (small, outlined) ───────────────────────────── */
.action-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 7px 12px;
  background: var(--surface2);
  border: 1.5px solid var(--border2);
  border-radius: var(--radius-xs);
  color: var(--text2);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
  transition: all var(--transition-fast);
}
.action-btn:hover { background: var(--bg3); color: var(--text); border-color: var(--border2); }
.action-btn.success {
  background: rgba(22,163,74,0.15);
  border-color: rgba(22,163,74,0.4);
  color: #4ade80;
}
.action-btn.success:not(:disabled):hover { background: rgba(22,163,74,0.2); }
.action-btn:disabled { opacity: 0.45; cursor: not-allowed; }

/* Вернуть (undo) — красный акцент */
#btn-undo-draw:not(:disabled) {
  border-color: #d25a5a;
  color: #d25a5a;
}
#btn-undo-draw:not(:disabled):hover {
  background: rgba(192,64,64,0.12);
  border-color: #c04040;
  color: #c04040;
}

/* ─── Icon-only buttons ───────────────────────────────────────────── */
.icon-btn {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: 1.5px solid var(--border2);
  border-radius: var(--radius-xs);
  color: var(--text3);
  cursor: pointer;
  transition: all var(--transition-fast);
  flex-shrink: 0;
}
.icon-btn:hover { background: var(--bg3); color: var(--text2); }
.icon-btn.danger:hover { background: rgba(248,113,113,0.12); border-color: rgba(248,113,113,0.3); color: var(--danger); }
.icon-btn.active {
  background: var(--accent-light);
  border-color: var(--accent);
  color: var(--accent);
}

/* ─── Count badge ─────────────────────────────────────────────────── */
.count-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--accent);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  letter-spacing: 0;
}

/* ─── Empty hint ──────────────────────────────────────────────────── */
.empty-hint {
  text-align: center;
  color: var(--text3);
  font-size: 12.5px;
  line-height: 1.6;
  padding: 20px 8px;
}

/* ════════════════════════════════════════════════════════════════════
   ZONES TAB
   ════════════════════════════════════════════════════════════════════ */

/* Toolbar */
.zones-toolbar {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.draw-actions {
  display: flex;
  gap: 6px;
}
.draw-actions.hidden { display: none; }

/* Zone editor card */
.zone-editor {
  background: var(--bg3);
  border: 1.5px solid rgba(59,130,246,0.15);
  border-radius: var(--radius-sm);
  margin: 4px 8px;
  padding: 12px !important;
}
.zone-editor.hidden { display: none !important; }

.zone-editor-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.zone-editor-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: 0.2px;
  text-transform: uppercase;
  font-size: 10.5px;
}
.zone-editor-controls {
  display: flex;
  gap: 4px;
}
.zone-editor-body {
  display: flex;
  flex-direction: column;
}

/* Color picker */
.color-picker-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.color-dot-wrap {
  display: contents;
}

/* скрываем labels цветов */
.color-dot-label {
  display: none;
}

.color-dot-btn {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-xs);
  border: 2px solid transparent;
  background: var(--dot-color, #ccc);
  cursor: pointer;
  transition: transform var(--transition-fast), border-color var(--transition-fast), 
              box-shadow var(--transition-fast), opacity var(--transition-fast);
  position: relative;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
  flex-shrink: 0;
  opacity: 0.75;
}
.color-dot-btn:hover {
  transform: scale(1.12) translateY(-2px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.35);
  border-color: rgba(255,255,255,0.3);
  opacity: 1;
}
.color-dot-btn:active {
  transform: scale(1.05) translateY(0);
  box-shadow: 0 2px 6px rgba(0,0,0,0.25);
}
.color-dot-btn.active {
  border-color: #fff;
  box-shadow: 0 0 0 3px var(--dot-color, #ccc), 0 4px 12px rgba(0,0,0,0.3);
  transform: scale(1.08);
  opacity: 1;
}

/* Zone list */
.zone-list-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 8px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--transition-fast);
  border: 1.5px solid transparent;
  margin-bottom: 3px;
}
.zone-list-item:hover { background: var(--bg3); }
.zone-list-item.selected {
  background: var(--accent-light);
  border-color: rgba(37,99,235,0.2);
}

.zone-color-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.zone-list-name {
  flex: 1;
  min-width: 0;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.zone-list-promoter {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 9px;
  font-weight: 700;
  flex-shrink: 0;
  letter-spacing: 0.3px;
}

.zone-color-badge {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
  box-shadow: 0 0 0 2px rgba(0,0,0,0.07);
}

.zone-item-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.zone-item-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.zone-item-promoter {
  font-size: 11px;
  color: var(--text3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.zone-item-promoter.no-promoter { color: var(--text3); font-style: italic; }

.zone-item-actions {
  display: flex;
  gap: 3px;
  opacity: 0;
  transition: opacity var(--transition-fast);
}
.zone-list-item:hover .zone-item-actions { opacity: 1; }
.zone-list-item.selected .zone-item-actions { opacity: 1; }

.zone-action-btn {
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  border-radius: var(--radius-xs);
  color: var(--text3);
  cursor: pointer;
  transition: all var(--transition-fast);
}
.zone-action-btn:hover { background: var(--bg); color: var(--text2); }
.zone-action-btn.danger:hover { background: rgba(248,113,113,0.12); color: var(--danger); }

/* ════════════════════════════════════════════════════════════════════
   PROMOTERS TAB
   ════════════════════════════════════════════════════════════════════ */

.add-promoter-form {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.promoter-item {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 8px;
  padding-bottom: 36px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border);
  margin-bottom: 6px;
  background: var(--surface);
  transition: box-shadow var(--transition-fast), border-color var(--transition-fast);
}
.promoter-item:hover { border-color: var(--border2); box-shadow: var(--shadow-sm); }

.promoter-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), #7c3aed);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  letter-spacing: 0.5px;
}

.promoter-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.promoter-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}
.promoter-phone {
  font-size: 11px;
  color: var(--text3);
}
.promoter-zones {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 5px;
}

.zone-chip {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.2px;
}
.zone-chip.empty {
  background: var(--bg3);
  color: var(--text3);
  font-style: italic;
  font-weight: 400;
}

/* Zone search */
.zone-search-box {
  margin-bottom: 8px;
}
.zone-search-box .field-input {
  font-size: 12px;
  padding: 7px 10px;
}

/* ════════════════════════════════════════════════════════════════════
   DRAWING MODE
   ════════════════════════════════════════════════════════════════════ */

#draw-hint {
  position: absolute;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(17,24,39,0.88);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  color: #fff;
  font-size: 12.5px;
  font-weight: 500;
  padding: 8px 16px;
  border-radius: 20px;
  display: flex;
  align-items: center;
  gap: 8px;
  z-index: 20;
  box-shadow: var(--shadow-lg);
  letter-spacing: 0.2px;
  animation: fadeInDown 0.2s ease;
  white-space: nowrap;
}
#draw-hint.hidden { display: none; }

/* Vertex dot */
.draw-vertex {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #fff;
  border: 2.5px solid #dc2626;
  box-shadow: 0 0 0 2px rgba(220,38,38,0.3), 0 2px 6px rgba(0,0,0,0.2);
  cursor: grab;
}
.draw-vertex:active { cursor: grabbing; }

/* Edit-mode vertex — slightly larger, distinct */
.edit-vertex {
  width: 13px;
  height: 13px;
  cursor: grab;
}
.edit-vertex:active { cursor: grabbing; }

/* ════════════════════════════════════════════════════════════════════
   PROMOTER COMBOBOX
   ════════════════════════════════════════════════════════════════════ */
.promoter-combobox {
  position: relative;
}

.promoter-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: var(--surface);
  border: 1.5px solid var(--border2);
  border-radius: var(--radius-xs);
  box-shadow: var(--shadow-lg);
  max-height: 160px;
  overflow-y: auto;
  z-index: 100;
  margin-top: 3px;
}
.promoter-dropdown.hidden { display: none; }

.promoter-dropdown-item {
  padding: 8px 10px;
  font-size: 13px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  transition: background var(--transition-fast);
}
.promoter-dropdown-item:last-child { border-bottom: none; }
.promoter-dropdown-item:hover,
.promoter-dropdown-item.selected {
  background: var(--accent-light);
  color: var(--accent);
}
.promoter-dropdown-item.no-results {
  color: var(--text3);
  font-style: italic;
  cursor: default;
}
.promoter-dropdown-item.no-results:hover { background: none; color: var(--text3); }

/* ════════════════════════════════════════════════════════════════════
   ZONE CARD MODAL
   ════════════════════════════════════════════════════════════════════ */

.zone-card-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.38);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: zcFadeIn 0.18s ease;
}

.zone-card-backdrop.zone-card-closing {
  animation: zcFadeOut 0.22s ease forwards;
}

@keyframes zcFadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}
@keyframes zcFadeOut {
  from { opacity: 1; }
  to   { opacity: 0; }
}

.zone-card-dialog {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-xl);
  width: 100%;
  max-width: 520px;
  max-height: 82vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: zcSlideIn 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.zone-card-backdrop.zone-card-closing .zone-card-dialog {
  animation: zcSlideOut 0.22s ease forwards;
}

@keyframes zcSlideIn {
  from { opacity: 0; transform: translateY(16px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes zcSlideOut {
  from { opacity: 1; transform: translateY(0) scale(1); }
  to   { opacity: 0; transform: translateY(10px) scale(0.97); }
}

/* Header */
.zc-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px 14px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  background: var(--bg3);
}

.zc-title-row {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.zc-zone-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
  box-shadow: 0 0 0 2px rgba(0,0,0,0.07);
}

.zc-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.zc-close-btn {
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: 1.5px solid var(--border2);
  border-radius: var(--radius-xs);
  color: var(--text3);
  cursor: pointer;
  flex-shrink: 0;
  margin-left: 10px;
  transition: all var(--transition-fast);
}
.zc-close-btn:hover {
  background: rgba(248,113,113,0.12);
  border-color: rgba(248,113,113,0.3);
  color: var(--danger);
}

/* Stats row */
.zc-stats {
  display: flex;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.zc-stat {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 12px 8px;
  border-right: 1px solid var(--border);
  gap: 3px;
}
.zc-stat:last-child { border-right: none; }

.zc-stat-val {
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}

.zc-stat-lbl {
  font-size: 10px;
  font-weight: 600;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: 0.6px;
}

/* List header */
.zc-list-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px 8px;
  flex-shrink: 0;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.7px;
  text-transform: uppercase;
  color: var(--text3);
  border-bottom: 1px solid var(--border);
}

.zc-copy-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 11px;
  background: var(--surface2);
  border: 1.5px solid var(--border2);
  border-radius: var(--radius-xs);
  color: var(--text2);
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: all var(--transition-fast);
  text-transform: none;
  letter-spacing: 0;
}
.zc-copy-btn:hover {
  background: var(--accent-light);
  border-color: var(--accent);
  color: var(--accent);
}
.zc-copy-btn.copied {
  background: rgba(22,163,74,0.15);
  border-color: rgba(22,163,74,0.4);
  color: #4ade80;
}

/* Scrollable list */
.zc-list {
  flex: 1;
  overflow-y: auto;
  padding: 4px 0 8px;
  scrollbar-width: thin;
  scrollbar-color: var(--border2) transparent;
}
.zc-list::-webkit-scrollbar { width: 3px; }
.zc-list::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 2px; }

/* Building row */
.zc-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 7px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 12.5px;
  transition: background var(--transition-fast);
}
.zc-row:last-child { border-bottom: none; }
.zc-row:hover { background: var(--bg3); }

.zc-addr {
  flex: 1;
  min-width: 0;
  color: var(--text);
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.zc-mkd .zc-addr::before {
  content: '';
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #2563eb;
  margin-right: 7px;
  flex-shrink: 0;
  vertical-align: middle;
  margin-bottom: 1px;
}

.zc-chd .zc-addr::before {
  content: '';
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 2px;
  background: #d97706;
  margin-right: 7px;
  flex-shrink: 0;
  vertical-align: middle;
  margin-bottom: 1px;
}

.zc-apts {
  font-size: 11.5px;
  font-weight: 600;
  white-space: nowrap;
  flex-shrink: 0;
  background: rgba(37,99,235,0.15);
  color: var(--accent-hover);
  padding: 2px 7px;
  border-radius: 10px;
}

.zc-apts-unknown {
  background: var(--bg3);
  color: var(--text3);
}

.zc-badge-chd {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.5px;
  background: rgba(180,130,0,0.18);
  color: #d4a017;
  padding: 2px 7px;
  border-radius: 10px;
  white-space: nowrap;
  flex-shrink: 0;
}

.zc-empty {
  text-align: center;
  color: var(--text3);
  font-size: 13px;
  padding: 28px 16px;
  line-height: 1.6;
}

/* Row action buttons (2GIS + edit) */
.zc-row-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
  opacity: 0;
  transition: opacity var(--transition-fast);
}
.zc-row:hover .zc-row-actions {
  opacity: 1;
}

.zc-icon-btn {
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: 1.5px solid var(--border2);
  border-radius: var(--radius-xs);
  color: var(--text3);
  cursor: pointer;
  transition: all var(--transition-fast);
  flex-shrink: 0;
  padding: 0;
}
.zc-icon-btn:hover {
  background: var(--bg3);
  color: var(--text2);
  border-color: var(--border2);
}
.zc-btn-2gis:hover {
  color: #34a853;
  border-color: rgba(52,168,83,0.4);
  background: rgba(52,168,83,0.08);
}
.zc-btn-edit:hover {
  color: var(--accent-hover);
  border-color: rgba(59,130,246,0.4);
  background: rgba(59,130,246,0.08);
}

/* Inline edit widget */
.zc-edit-wrap {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.zc-edit-input {
  width: 68px;
  background: var(--surface2);
  border: 1.5px solid var(--accent);
  border-radius: var(--radius-xs);
  color: var(--text);
  font-size: 12px;
  font-family: inherit;
  padding: 3px 7px;
  outline: none;
  box-shadow: 0 0 0 3px rgba(59,130,246,0.15);
  font-variant-numeric: tabular-nums;
  /* hide number input spinners */
  -moz-appearance: textfield;
}
.zc-edit-input::-webkit-outer-spin-button,
.zc-edit-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
.zc-edit-input--error {
  border-color: var(--danger);
  box-shadow: 0 0 0 3px rgba(248,113,113,0.18);
}

.zc-edit-ok,
.zc-edit-cancel {
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1.5px solid var(--border2);
  border-radius: var(--radius-xs);
  background: none;
  cursor: pointer;
  padding: 0;
  transition: all var(--transition-fast);
  flex-shrink: 0;
}
.zc-edit-ok {
  color: #4ade80;
  border-color: rgba(74,222,128,0.3);
}
.zc-edit-ok:hover {
  background: rgba(74,222,128,0.12);
  border-color: rgba(74,222,128,0.5);
}
.zc-edit-cancel {
  color: var(--text3);
}
.zc-edit-cancel:hover {
  background: rgba(248,113,113,0.12);
  border-color: rgba(248,113,113,0.3);
  color: var(--danger);
}

/* Zone description block in modal */
.zc-description {
  padding: 10px 18px;
  font-size: 12.5px;
  color: var(--text2);
  line-height: 1.55;
  border-bottom: 1px solid var(--border);
  background: var(--bg3);
  display: flex;
  gap: 7px;
  align-items: flex-start;
}
.zc-description::before {
  content: '📝';
  font-size: 13px;
  flex-shrink: 0;
  margin-top: 1px;
}

/* ════════════════════════════════════════════════════════════════════
   ZONES TOOLBAR — top row with draw + export buttons
   ════════════════════════════════════════════════════════════════════ */

.zones-toolbar-top {
  display: flex;
  gap: 8px;
  align-items: center;
}

.zones-toolbar-top .primary-btn {
  flex: 1;
}

/* Export GeoJSON button */
.export-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 9px 12px;
  background: rgba(22,163,74,0.12);
  border: 1.5px solid rgba(22,163,74,0.3);
  border-radius: var(--radius-sm);
  color: #4ade80;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  white-space: nowrap;
  transition: all var(--transition-fast);
  flex-shrink: 0;
}
.export-btn:hover {
  background: rgba(22,163,74,0.2);
  border-color: rgba(22,163,74,0.5);
  color: #86efac;
  transform: translateY(-1px);
  box-shadow: 0 3px 10px rgba(22,163,74,0.18);
}
.export-btn:active {
  transform: scale(0.97) translateY(0);
}
.export-btn--ok {
  background: rgba(22,163,74,0.2) !important;
  border-color: rgba(22,163,74,0.5) !important;
  color: #86efac !important;
}

/* Zone description textarea in editor */
.zone-desc-input {
  resize: vertical;
  min-height: 62px;
  line-height: 1.5;
  font-size: 12.5px;
}

/* ════════════════════════════════════════════════════════════════════
   SIDEBAR TABS (4 вкладки — более компактный шрифт)
   ════════════════════════════════════════════════════════════════════ */

.sidebar-tab-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 6px 3px;
  background: transparent;
  border: none;
  border-radius: var(--radius-xs);
  color: var(--text3);
  font-size: 10.5px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-fast);
  font-family: inherit;
  white-space: nowrap;
  letter-spacing: 0.1px;
}
.sidebar-tab-btn:hover:not(.active) {
  background: rgba(255,255,255,0.06);
  color: var(--text2);
}
.sidebar-tab-btn.active {
  background: var(--surface2);
  color: var(--accent);
  font-weight: 600;
  box-shadow: var(--shadow-sm);
}
.sidebar-tab-btn svg { flex-shrink: 0; }

.sidebar-panel { display: block; }
.sidebar-panel.hidden { display: none; }

/* ════════════════════════════════════════════════════════════════════
   ZONE LIST ITEMS (inline style helpers)
   ════════════════════════════════════════════════════════════════════ */

.zone-color-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex-shrink: 0;
}

.zone-list-name {
  flex: 0 1 auto;
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
  max-width: 140px;
}

.zone-list-promoter {
  font-size: 10px;
  font-weight: 700;
  background: var(--accent-light);
  color: var(--accent);
  padding: 2px 6px;
  border-radius: 10px;
  flex-shrink: 0;
  letter-spacing: 0.3px;
}

.zone-list-card-btn,
.zone-list-fly-btn,
.zone-list-delete-btn {
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  border-radius: var(--radius-xs);
  color: var(--text3);
  cursor: pointer;
  transition: all var(--transition-fast);
  flex-shrink: 0;
  opacity: 0;
}
.zone-list-item:hover .zone-list-card-btn,
.zone-list-item:hover .zone-list-fly-btn,
.zone-list-item:hover .zone-list-delete-btn,
.zone-list-item.selected .zone-list-card-btn,
.zone-list-item.selected .zone-list-fly-btn,
.zone-list-item.selected .zone-list-delete-btn {
  opacity: 1;
}
.zone-list-card-btn:hover {
  background: var(--bg3);
  color: var(--accent);
}
.zone-list-fly-btn:hover {
  background: var(--bg3);
  color: var(--accent);
}
.zone-list-delete-btn:hover {
  background: rgba(248,113,113,0.12);
  color: var(--danger);
}

/* Promoter delete btn */
.promoter-delete-btn {
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  border-radius: var(--radius-xs);
  color: var(--text3);
  cursor: pointer;
  transition: all var(--transition-fast);
  flex-shrink: 0;
}
.promoter-delete-btn:hover {
  background: rgba(248,113,113,0.12);
  color: var(--danger);
}

.promoter-zones-count {
  font-size: 11px;
  color: var(--text3);
}

/* ════════════════════════════════════════════════════════════════════
   DATESHEETS SECTION
   ════════════════════════════════════════════════════════════════════ */

.datesheets-section {
  border-top: 1px solid var(--border);
  padding-top: 10px;
  margin-top: 4px;
}

.datesheets-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.datesheets-title {
  font-size: 10.5px;
  font-weight: 600;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: 0.7px;
}

.add-datesheet-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 9px;
  background: var(--accent-light);
  border: 1.5px solid rgba(59,130,246,0.25);
  border-radius: var(--radius-xs);
  color: var(--accent);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: all var(--transition-fast);
}
.add-datesheet-btn:hover {
  background: rgba(59,130,246,0.2);
  border-color: rgba(59,130,246,0.45);
}

.datesheet-pair {
  background: var(--bg);
  border: 1.5px solid var(--border2);
  border-radius: var(--radius-xs);
  padding: 8px 9px;
  margin-bottom: 6px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.datesheet-pair:last-child { margin-bottom: 0; }

.datesheet-pair-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.datesheet-pair-label {
  font-size: 10px;
  font-weight: 600;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: 0.6px;
}

.datesheet-delete-btn {
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  border-radius: 4px;
  color: var(--text3);
  cursor: pointer;
  transition: all var(--transition-fast);
}
.datesheet-delete-btn:hover {
  background: rgba(248,113,113,0.12);
  color: var(--danger);
}

.datesheet-date {
  font-size: 12px;
  padding: 6px 8px;
}

.datesheet-sheets-select {
  width: 100%;
  background: var(--surface2);
  border: 1.5px solid var(--border2);
  border-radius: var(--radius-xs);
  color: var(--text);
  font-size: 12px;
  padding: 5px 7px;
  outline: none;
  font-family: inherit;
  min-height: 60px;
  max-height: 100px;
  transition: border-color var(--transition);
}
.datesheet-sheets-select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37,99,235,0.10);
}
.datesheet-sheets-select option {
  padding: 3px 5px;
  background: var(--surface2);
  color: var(--text);
}
.datesheet-sheets-select option:checked {
  background: var(--accent-light);
  color: var(--accent);
}

/* ════════════════════════════════════════════════════════════════════
   ZONE LAYERS BAR
   ════════════════════════════════════════════════════════════════════ */

.zone-layers-section {
  padding: 8px 10px 6px;
  border-bottom: 1px solid var(--border);
}

.zone-layers-bar {
  display: flex;
  align-items: center;
  gap: 6px;
}

.zone-layers-tabs {
  display: flex;
  flex: 1;
  gap: 3px;
  overflow-x: auto;
  scrollbar-width: none;
  min-width: 0;
}
.zone-layers-tabs::-webkit-scrollbar { display: none; }

.zone-layer-tab {
  padding: 5px 10px;
  background: var(--bg3);
  border: 1.5px solid var(--border2);
  border-radius: 20px;
  color: var(--text2);
  font-size: 11.5px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-fast);
  font-family: inherit;
  white-space: nowrap;
  flex-shrink: 0;
}
.zone-layer-tab:hover:not(.active) {
  border-color: var(--border2);
  color: var(--text);
  background: var(--surface2);
}
.zone-layer-tab.active {
  background: var(--accent-light);
  border-color: rgba(59,130,246,0.4);
  color: var(--accent);
  font-weight: 600;
}

.add-layer-btn {
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: 1.5px solid var(--border2);
  border-radius: var(--radius-xs);
  color: var(--text3);
  cursor: pointer;
  transition: all var(--transition-fast);
  flex-shrink: 0;
}
.add-layer-btn:hover {
  background: var(--accent-light);
  border-color: rgba(59,130,246,0.35);
  color: var(--accent);
}

.section-action-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 9px;
  background: none;
  border: 1.5px solid var(--border2);
  border-radius: var(--radius-xs);
  color: var(--text3);
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
  transition: all var(--transition-fast);
  flex-shrink: 0;
}
.section-action-btn:hover {
  background: var(--bg3);
  color: var(--text2);
}

/* ════════════════════════════════════════════════════════════════════
   LAYERS MODAL
   ════════════════════════════════════════════════════════════════════ */

.layers-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: fadeInDown 0.15s ease;
}
.layers-modal-backdrop.hidden { display: none !important; }

.layers-modal-dialog {
  background: var(--surface);
  border: 1px solid var(--border2);
  border-radius: var(--radius);
  box-shadow: var(--shadow-xl);
  width: 100%;
  max-width: 360px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: zcSlideIn 0.18s cubic-bezier(0.34,1.56,0.64,1);
}

.layers-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--bg3);
}

.layers-modal-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.2px;
}

.layers-modal-close {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: 1.5px solid var(--border2);
  border-radius: var(--radius-xs);
  color: var(--text3);
  cursor: pointer;
  transition: all var(--transition-fast);
}
.layers-modal-close:hover {
  background: rgba(248,113,113,0.12);
  border-color: rgba(248,113,113,0.3);
  color: var(--danger);
}

.layers-modal-body {
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 70vh;
  overflow-y: auto;
}

.layers-modal-add {
  display: flex;
  gap: 6px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}

.layers-modal-add .field-input {
  flex: 1;
  font-size: 12.5px;
  padding: 7px 9px;
}

.layers-modal-add .primary-btn {
  padding: 7px 13px;
  font-size: 12px;
  flex-shrink: 0;
  white-space: nowrap;
}

.layers-modal-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.layer-modal-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 10px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border);
  background: var(--bg3);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}
.layer-modal-item:hover { border-color: var(--border2); box-shadow: var(--shadow-sm); }
.layer-modal-item.active {
  border-color: rgba(59,130,246,0.35);
  background: var(--accent-light);
}

.layer-modal-item-name {
  flex: 1;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.layer-modal-item.active .layer-modal-item-name {
  color: var(--accent);
}

.layer-modal-item-count {
  font-size: 11px;
  color: var(--text3);
  flex-shrink: 0;
}

.layer-modal-edit-btn,
.layer-modal-switch-btn,
.layer-modal-delete-btn {
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: 1.5px solid var(--border2);
  border-radius: var(--radius-xs);
  color: var(--text3);
  cursor: pointer;
  transition: all var(--transition-fast);
  flex-shrink: 0;
}
.layer-modal-edit-btn:hover {
  background: var(--bg3);
  border-color: var(--border2);
  color: var(--text2);
}
.layer-modal-switch-btn:hover {
  background: var(--accent-light);
  border-color: rgba(59,130,246,0.35);
  color: var(--accent);
}
.layer-modal-delete-btn:hover {
  background: rgba(248,113,113,0.12);
  border-color: rgba(248,113,113,0.3);
  color: var(--danger);
}

/* Layer inline edit */
.layer-inline-edit {
  display: flex;
  align-items: center;
  gap: 4px;
  flex: 1;
  min-width: 0;
}

.layer-rename-input {
  flex: 1;
  background: var(--surface2);
  border: 1.5px solid var(--accent);
  border-radius: var(--radius-xs);
  color: var(--text);
  font-size: 12.5px;
  font-family: inherit;
  padding: 5px 8px;
  outline: none;
  box-shadow: 0 0 0 3px rgba(59,130,246,0.15);
}

.layer-rename-ok,
.layer-rename-cancel {
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1.5px solid var(--border2);
  border-radius: var(--radius-xs);
  background: none;
  cursor: pointer;
  padding: 0;
  transition: all var(--transition-fast);
  flex-shrink: 0;
}
.layer-rename-ok {
  color: #4ade80;
  border-color: rgba(74,222,128,0.3);
}
.layer-rename-ok:hover {
  background: rgba(74,222,128,0.12);
  border-color: rgba(74,222,128,0.5);
}
.layer-rename-cancel {
  color: var(--text3);
}
.layer-rename-cancel:hover {
  background: rgba(248,113,113,0.12);
  border-color: rgba(248,113,113,0.3);
  color: var(--danger);
}

/* ════════════════════════════════════════════════════════════════════
   SHEETS TAB
   ════════════════════════════════════════════════════════════════════ */

.add-sheet-form {
  display: flex;
  flex-direction: column;
  gap: 7px;
  margin-bottom: 4px;
}

.add-sheet-row {
  display: flex;
  gap: 6px;
}

.add-sheet-row .field-input {
  flex: 1;
  font-size: 12.5px;
  padding: 7px 9px;
}

.add-sheet-row .primary-btn {
  padding: 7px 13px;
  font-size: 12px;
  flex-shrink: 0;
}

.sheet-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 8px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border);
  background: var(--surface);
  margin-bottom: 5px;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}
.sheet-item:hover { border-color: var(--border2); box-shadow: var(--shadow-sm); }

.sheet-item-icon {
  color: var(--text3);
  display: flex;
  align-items: center;
  flex-shrink: 0;
}

.sheet-item-name {
  flex: 1;
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sheet-delete-btn {
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  border-radius: var(--radius-xs);
  color: var(--text3);
  cursor: pointer;
  transition: all var(--transition-fast);
  flex-shrink: 0;
  opacity: 0;
}
.sheet-item:hover .sheet-delete-btn { opacity: 1; }
.sheet-delete-btn:hover {
  background: rgba(248,113,113,0.12);
  color: var(--danger);
}

/* ─── Sheet inline edit ─────────────────────────────────────────── */
.sheet-edit-btn {
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  border-radius: var(--radius-xs);
  color: var(--text3);
  cursor: pointer;
  transition: all var(--transition-fast);
  flex-shrink: 0;
  opacity: 0;
}
.sheet-item:hover .sheet-edit-btn { opacity: 1; }
.sheet-edit-btn:hover {
  background: rgba(59,130,246,0.12);
  color: var(--accent);
}

.sheet-inline-edit {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
}

.sheet-rename-input {
  flex: 1;
  min-width: 0;
  height: 26px;
  padding: 0 7px;
  background: var(--bg3);
  border: 1px solid var(--accent);
  border-radius: var(--radius-xs);
  color: var(--text);
  font-size: 12.5px;
  outline: none;
}

.sheet-rename-ok,
.sheet-rename-cancel {
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  border-radius: var(--radius-xs);
  cursor: pointer;
  transition: all var(--transition-fast);
  flex-shrink: 0;
}
.sheet-rename-ok { color: #4ade80; }
.sheet-rename-ok:hover { background: rgba(74,222,128,0.12); }
.sheet-rename-cancel { color: var(--text3); }
.sheet-rename-cancel:hover { background: rgba(248,113,113,0.12); color: var(--danger); }

/* ─── Promoter inline edit ──────────────────────────────────────── */
.promoter-edit-btn {
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  border-radius: var(--radius-xs);
  color: var(--text3);
  cursor: pointer;
  transition: all var(--transition-fast);
  flex-shrink: 0;
  opacity: 0;
}
.promoter-item:hover .promoter-edit-btn { opacity: 1; }
.promoter-edit-btn:hover {
  background: rgba(59,130,246,0.12);
  color: var(--accent);
}

/* ─── Promoter copy link button ─────────────────────────────────── */
.promoter-copy-btn {
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  border-radius: var(--radius-xs);
  color: var(--text3);
  cursor: pointer;
  transition: all var(--transition-fast);
  flex-shrink: 0;
  opacity: 0;
}
.promoter-item:hover .promoter-copy-btn { opacity: 1; }
.promoter-copy-btn:hover {
  background: rgba(34,197,94,0.12);
  color: #4ade80;
}

/* ─── Promoter toggle (active/inactive) ────────────────────────── */
.promoter-toggle {
  position: absolute;
  bottom: 8px;
  left: 12px;
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.promoter-toggle-switch {
  position: relative;
  width: 28px;
  height: 16px;
  background: var(--bg3);
  border: 1.5px solid var(--border2);
  border-radius: 10px;
  cursor: pointer;
  transition: all var(--transition);
  flex-shrink: 0;
}

.promoter-toggle-switch.active {
  background: linear-gradient(135deg, #22c55e, #16a34a);
  border-color: #22c55e;
}

.promoter-toggle-switch::after {
  content: '';
  position: absolute;
  top: 1.5px;
  left: 1.5px;
  width: 11px;
  height: 11px;
  background: #fff;
  border-radius: 50%;
  transition: transform var(--transition);
  box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}

.promoter-toggle-switch.active::after {
  transform: translateX(12px);
}

.promoter-toggle-label {
  font-size: 9px;
  font-weight: 600;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: 0.3px;
  user-select: none;
}

.promoter-toggle-switch.active + .promoter-toggle-label {
  color: #22c55e;
}

.promoter-item .promoter-actions {
  position: absolute;
  top: 8px;
  right: 8px;
  display: flex;
  gap: 6px;
}

.promoter-inline-edit {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
}

.promoter-rename-input {
  flex: 1;
  min-width: 0;
  height: 28px;
  padding: 0 8px;
  background: var(--bg3);
  border: 1px solid var(--accent);
  border-radius: var(--radius-xs);
  color: var(--text);
  font-size: 13px;
  outline: none;
}

.promoter-rename-ok,
.promoter-rename-cancel {
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  border-radius: var(--radius-xs);
  cursor: pointer;
  transition: all var(--transition-fast);
  flex-shrink: 0;
}
.promoter-rename-ok { color: #4ade80; }
.promoter-rename-ok:hover { background: rgba(74,222,128,0.12); }
.promoter-rename-cancel { color: var(--text3); }
.promoter-rename-cancel:hover { background: rgba(248,113,113,0.12); color: var(--danger); }

/* ─── Datesheet Card (Новый красивый дизайн) ─────────────────────── */
.datesheet-card {
  background: var(--bg3);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 10px;
  overflow: visible;
  transition: all var(--transition-fast);
}
.datesheet-card:hover {
  border-color: var(--border2);
  box-shadow: var(--shadow-sm);
}

/* Card Header */
.datesheet-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.datesheet-date-wrapper {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 0;
}

.datesheet-date-icon {
  display: flex;
  align-items: center;
  color: var(--accent);
  flex-shrink: 0;
}

.datesheet-date-input {
  flex: 1;
  background: var(--bg3);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-xs);
  color: var(--text);
  font-size: 12.5px;
  font-weight: 500;
  padding: 6px 10px;
  font-family: inherit;
  transition: all var(--transition-fast);
}
.datesheet-date-input:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--surface);
}

.datesheet-card-delete {
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-xs);
  color: var(--text3);
  cursor: pointer;
  flex-shrink: 0;
  margin-left: 8px;
  transition: all var(--transition-fast);
}
.datesheet-card-delete:hover {
  background: rgba(248,113,113,0.12);
  border-color: rgba(248,113,113,0.3);
  color: var(--danger);
}

/* Card Body */
.datesheet-card-body {
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.datesheet-sheets-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text3);
}
.datesheet-sheets-label svg {
  color: var(--text3);
}

/* Sheets Selector */
.datesheet-sheets-selector {
  position: relative;
}

.datesheet-search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-xs);
  padding: 6px 10px;
  transition: all var(--transition-fast);
}
.datesheet-search-box:focus-within {
  border-color: var(--accent);
  background: var(--bg3);
}

.datesheet-search-icon {
  display: flex;
  align-items: center;
  color: var(--text3);
  flex-shrink: 0;
}

.datesheet-search-input {
  flex: 1;
  background: none;
  border: none;
  color: var(--text);
  font-size: 12px;
  font-family: inherit;
  outline: none;
}
.datesheet-search-input::placeholder {
  color: var(--text3);
}

/* Dropdown */
.datesheet-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: var(--surface);
  border: 1.5px solid var(--border2);
  border-radius: var(--radius-xs);
  box-shadow: var(--shadow-lg);
  max-height: 200px;
  overflow-y: auto;
  z-index: 100;
  scrollbar-width: thin;
  scrollbar-color: var(--border2) transparent;
}
.datesheet-dropdown::-webkit-scrollbar { width: 4px; }
.datesheet-dropdown::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 2px; }
.datesheet-dropdown.hidden { display: none; }

.datesheet-dropdown-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  transition: all var(--transition-fast);
}
.datesheet-dropdown-item:last-child { border-bottom: none; }
.datesheet-dropdown-item:hover {
  background: var(--bg3);
}
.datesheet-dropdown-item.selected {
  background: var(--accent-light);
}

.datesheet-checkbox {
  width: 16px;
  height: 16px;
  border-radius: 4px;
  cursor: pointer;
  accent-color: var(--accent);
  flex-shrink: 0;
}

.datesheet-checkbox-label {
  flex: 1;
  font-size: 12.5px;
  color: var(--text2);
  cursor: pointer;
  user-select: none;
}
.datesheet-dropdown-item.selected .datesheet-checkbox-label {
  color: var(--accent);
  font-weight: 500;
}

.datesheet-dropdown-empty {
  padding: 12px;
  text-align: center;
  font-size: 12px;
  color: var(--text3);
  font-style: italic;
}

/* Selected Tags */
.datesheet-selected-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-height: 24px;
}

.datesheet-no-sheets {
  font-size: 11.5px;
  color: var(--text3);
  font-style: italic;
  padding: 4px 0;
}

.datesheet-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  background: var(--accent-light);
  border: 1px solid rgba(59,130,246,0.25);
  border-radius: 14px;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--accent);
  letter-spacing: 0.2px;
  transition: all var(--transition-fast);
}
.datesheet-tag:hover {
  background: rgba(59,130,246,0.15);
  border-color: rgba(59,130,246,0.35);
}

.datesheet-tag-remove {
  width: 16px;
  height: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(59,130,246,0.15);
  border: none;
  border-radius: 50%;
  color: var(--accent);
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  padding: 0;
  transition: all var(--transition-fast);
}
.datesheet-tag-remove:hover {
  background: rgba(59,130,246,0.25);
  transform: scale(1.1);
}

/* ─── Draw zone icon button ─────────────────────────────────────── */
.draw-zone-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 7px;
  background: var(--accent);
  color: #fff;
  border: none;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
  flex-shrink: 0;
}
.draw-zone-icon-btn:hover { background: var(--accent-hover, #4a7fd4); }
.draw-zone-icon-btn.active { background: var(--danger, #e05252); }
.draw-zone-icon-btn.hidden { display: none !important; }

/* ─── Section title actions group ───────────────────────────────── */
.section-title-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-left: auto;
}

/* ─── Zone search box with button ────────────────────────────────── */
.zone-search-box {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 10px;
}
.zone-search-box .field-input {
  flex: 1;
  margin: 0;
}

/* ─── Draw action buttons (new icons in zone-search-box) ─────────── */
.draw-action-btn {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 7px;
  border: none;
  cursor: pointer;
  transition: all var(--transition-fast);
  flex-shrink: 0;
}
.draw-action-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.draw-action-finish {
  background: #22c55e;
  color: #fff;
}
.draw-action-finish:not(:disabled):hover {
  background: #16a34a;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(34,197,94,0.3);
}

.draw-action-undo {
  background: #e8e8e8;
  color: #333;
}
.draw-action-undo:not(:disabled):hover {
  background: #d0d0d0;
  transform: translateY(-1px);
}

.draw-action-cancel {
  background: #ef4444;
  color: #fff;
}
.draw-action-cancel:hover {
  background: #dc2626;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(239,68,68,0.3);
}

/* ─── Neutral action button ──────────────────────────────────────── */
.action-btn.neutral {
  background: #e8e8e8;
  color: #333;
}
.action-btn.neutral:hover {
  background: #d0d0d0;
}

/* ═══════════════════════════════════════════════════════════════════
   Map Search Control (top-right, minimalist)
   ═══════════════════════════════════════════════════════════════════ */

#map-search-control {
  position: absolute;
  top: 16px;
  right: 74px;
  z-index: 5;
  width: 240px;
}

.map-search-box {
  position: relative;
  display: flex;
  align-items: center;
  background: rgba(31, 35, 43, 0.92);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 8px;
  padding: 0 10px;
  transition: all 0.2s ease;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.map-search-box:focus-within {
  border-color: rgba(59, 130, 246, 0.4);
  background: rgba(31, 35, 43, 0.96);
}

.map-search-icon {
  color: var(--text3);
  flex-shrink: 0;
  margin-right: 7px;
}

#map-search-input {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  color: var(--text);
  font-size: 13px;
  padding: 9px 0;
  font-family: inherit;
}

#map-search-input::placeholder {
  color: var(--text3);
}

#map-search-clear {
  background: none;
  border: none;
  color: var(--text3);
  cursor: pointer;
  padding: 3px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  transition: all 0.15s ease;
}

#map-search-clear:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
}

#map-search-results {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  max-height: 280px;
  overflow-y: auto;
  background: rgba(31, 35, 43, 0.96);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
}

#map-search-results.hidden {
  display: none;
}

.map-search-result {
  padding: 9px 11px;
  cursor: pointer;
  transition: background 0.12s ease;
}

.map-search-result:hover {
  background: rgba(59, 130, 246, 0.1);
}

.map-search-result-addr {
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 2px;
}

.map-search-result-meta {
  color: var(--text2);
  font-size: 11px;
}

.map-search-no-results {
  padding: 14px;
  text-align: center;
  color: var(--text3);
  font-size: 12px;
}

/* ═══════════════════════════════════════════════════════════════════
   Map Layer Controls (bottom-right, minimalist)
   ═══════════════════════════════════════════════════════════════════ */

#map-layer-controls {
  position: absolute !important;
  bottom: 4px !important;
  right: 14px !important;
  display: flex;
  flex-direction: column;
  gap: 5px;
  z-index: 5;
  align-items: flex-end;
}

.map-layer-toggle {
  position: relative;
  cursor: pointer;
  user-select: none;
}

.map-layer-toggle input[type="checkbox"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
  pointer-events: none;
}

.map-layer-toggle .ctrl-btn {
  width: 40px;
  height: 40px;
  pointer-events: none;
}

.map-layer-toggle input[type="checkbox"]:checked + .ctrl-btn {
  background: var(--accent-light);
  color: var(--accent);
  border-color: rgba(59,130,246,0.35);
}

.map-layer-toggle:hover .ctrl-btn {
  background: var(--surface);
  color: var(--accent);
  box-shadow: var(--shadow-lg);
  transform: translateY(-1px);
}

/* Basemap selector (horizontal panel) */
.map-basemap-selector {
  width: 240px;
  display: flex;
  gap: 6px;
  background: rgba(31, 35, 43, 0.92);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 8px;
  padding: 5px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
  margin-right: 0;
}

.map-basemap-btn {
  flex: 1;
  height: 32px;
  background: transparent;
  border: none;
  border-radius: 6px;
  color: var(--text2);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
  font-family: inherit;
}

.map-basemap-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
}

.map-basemap-btn.active {
  background: var(--accent-light);
  color: var(--accent);
  font-weight: 600;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
}

/* ─── User Location Marker ──────────────────────────────────────────── */
.user-location-marker {
  width: 44px;
  height: 44px;
  position: relative;
  cursor: pointer;
}

.user-location-dot {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 16px;
  height: 16px;
  background: #3b82f6;
  border: 3px solid #ffffff;
  border-radius: 50%;
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.4), 0 0 0 1px rgba(0, 0, 0, 0.1);
  z-index: 2;
}

.user-location-pulse {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 44px;
  height: 44px;
  background: rgba(59, 130, 246, 0.25);
  border-radius: 50%;
  animation: locationPulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
  z-index: 1;
}

@keyframes locationPulse {
  0% {
    transform: translate(-50%, -50%) scale(0.5);
    opacity: 1;
  }
  50% {
    transform: translate(-50%, -50%) scale(1);
    opacity: 0.6;
  }
  100% {
    transform: translate(-50%, -50%) scale(1.2);
    opacity: 0;
  }
}

/* Alternative pulsing ring animation */
.user-location-pulse::before {
  content: '';
  position: absolute;
  inset: -4px;
  background: rgba(59, 130, 246, 0.15);
  border-radius: 50%;
  animation: locationRing 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
  animation-delay: 0.5s;
}

@keyframes locationRing {
  0% {
    transform: scale(0.8);
    opacity: 0.8;
  }
  100% {
    transform: scale(1.5);
    opacity: 0;
  }
}

/* ─── Responsive adjustments ───────────────────────────────────────── */
@media (max-width: 768px) {
  #map-search-control {
    width: 200px;
  }
}

/* ════════════════════════════════════════════════════════════════════
   FOLDERS & DRAG-AND-DROP
   ════════════════════════════════════════════════════════════════════ */

.folder-section {
  margin-bottom: 8px;
}

.folder-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  background: var(--bg3);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 4px;
  cursor: pointer;
  transition: all var(--transition-fast);
}
.folder-header:hover {
  background: var(--surface2);
  border-color: var(--border2);
}

.folder-color-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.folder-name {
  flex: 1;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.folder-visibility-toggle {
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  border-radius: var(--radius-xs);
  color: var(--text3);
  cursor: pointer;
  transition: all var(--transition-fast);
  flex-shrink: 0;
}
.folder-visibility-toggle:hover {
  background: var(--bg);
  color: var(--text2);
}
.folder-visibility-toggle.visible {
  color: var(--accent);
}

.folder-actions {
  display: flex;
  gap: 3px;
  opacity: 0;
  transition: opacity var(--transition-fast);
}
.folder-header:hover .folder-actions {
  opacity: 1;
}

.folder-action-btn {
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  border-radius: var(--radius-xs);
  color: var(--text3);
  cursor: pointer;
  transition: all var(--transition-fast);
}
.folder-action-btn:hover {
  background: var(--bg);
  color: var(--text2);
}
.folder-action-btn.danger:hover {
  background: rgba(248,113,113,0.12);
  color: var(--danger);
}

.folder-zones {
  padding-left: 8px;
  border-left: 2px solid var(--border);
  margin-left: 14px;
  margin-bottom: 6px;
}

.zone-item.draggable {
  cursor: grab;
  user-select: none;
}
.zone-item.draggable:active {
  cursor: grabbing;
}

.zone-item.dragging {
  opacity: 0.5;
  background: var(--accent-light);
  border-color: var(--accent);
  transform: scale(0.98);
}

.folder-section.drop-target {
  position: relative;
}
.folder-section.drop-target::before {
  content: '';
  position: absolute;
  inset: -2px;
  border: 2px dashed var(--accent);
  border-radius: var(--radius-sm);
  background: rgba(59,130,246,0.08);
  pointer-events: none;
  animation: dropTargetPulse 1.2s ease infinite;
}

@keyframes dropTargetPulse {
  0%, 100% { opacity: 0.6; }
  50% { opacity: 1; }
}

.folder-header.drop-target-header {
  background: var(--accent-light);
  border-color: var(--accent);
}

/* Uncategorized zones section (no folder) */
.uncategorized-zones {
  margin-top: 4px;
}
