.map-layout {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  gap: 18px;
  padding: 12px 0 56px;
}

.map-sidebar {
  background: linear-gradient(180deg, rgba(16, 41, 59, 0.92) 0%, rgba(9, 25, 36, 0.92) 100%);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
  max-height: calc(100vh - 120px);
  overflow-y: auto;
  position: sticky;
  top: 96px;
}

.map-sidebar h2 {
  font-size: 22px;
  margin: 0 0 14px;
}

.map-search {
  width: 100%;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  font-size: 14px;
  margin-bottom: 14px;
  outline: none;
}

.map-search:focus {
  border-color: var(--accent);
  background: rgba(61, 214, 255, 0.08);
}

.map-controls {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.map-controls button {
  flex: 1;
  min-width: 90px;
  padding: 8px 10px;
  border-radius: 999px;
  border: 1px solid rgba(61, 214, 255, 0.24);
  background: rgba(61, 214, 255, 0.08);
  color: var(--text);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  cursor: pointer;
  text-transform: uppercase;
}

.map-controls button:hover {
  background: rgba(61, 214, 255, 0.16);
}

.map-category {
  margin-bottom: 14px;
  border-bottom: 1px solid rgba(146, 214, 255, 0.08);
  padding-bottom: 12px;
}

.map-category:last-of-type {
  border-bottom: none;
}

.map-category-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  padding: 4px 0;
  user-select: none;
  font-weight: 700;
  font-size: 13px;
  color: var(--text);
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.map-category-header .toggle-icon {
  color: var(--accent);
  font-size: 10px;
  transition: transform 0.2s;
}

.map-category.collapsed .toggle-icon {
  transform: rotate(-90deg);
}

.map-category.collapsed .map-sub-list {
  display: none;
}

.map-sub-list {
  display: grid;
  gap: 4px;
  margin-top: 10px;
}

.map-sub-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 8px;
  border-radius: 10px;
  cursor: pointer;
  font-size: 13px;
  color: var(--muted);
  transition: background 0.15s;
}

.map-sub-item:hover {
  background: rgba(61, 214, 255, 0.06);
  color: var(--text);
}

.map-sub-item.muted {
  opacity: 0.4;
}

.map-sub-item input[type="checkbox"] {
  appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 4px;
  border: 1px solid rgba(146, 214, 255, 0.3);
  background: rgba(255, 255, 255, 0.04);
  cursor: pointer;
  position: relative;
  flex-shrink: 0;
}

.map-sub-item input[type="checkbox"]:checked {
  background: var(--accent);
  border-color: var(--accent);
}

.map-sub-item input[type="checkbox"]:checked::after {
  content: "✓";
  color: #021018;
  font-size: 11px;
  font-weight: 800;
  position: absolute;
  top: -2px;
  left: 1px;
}

.map-sub-swatch {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.map-sub-label {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.map-sub-count {
  font-size: 11px;
  font-weight: 700;
  color: var(--accent);
  background: rgba(61, 214, 255, 0.1);
  padding: 2px 7px;
  border-radius: 999px;
  flex-shrink: 0;
}

.map-routes-section {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid rgba(146, 214, 255, 0.12);
}

.map-routes-section h3 {
  font-size: 13px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 10px;
  color: var(--accent-2);
}

.map-route-item {
  display: grid;
  gap: 4px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.02);
  margin-bottom: 8px;
  cursor: pointer;
}

.map-route-item:hover,
.map-route-item.active {
  border-color: rgba(61, 214, 255, 0.35);
  background: rgba(61, 214, 255, 0.08);
}

.map-route-item strong {
  font-size: 13px;
  color: var(--text);
}

.map-route-item span {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.5;
}

.map-canvas {
  background: #02121b;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  height: clamp(520px, 80vh, 900px);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.map-canvas .leaflet-container {
  background: transparent;
  height: 100%;
  width: 100%;
  font-family: inherit;
}

.leaflet-popup-content-wrapper,
.leaflet-popup-tip {
  background: #0e2738;
  color: var(--text);
  border: 1px solid var(--line);
}

.leaflet-popup-content {
  margin: 14px 16px;
  font-size: 13px;
  line-height: 1.5;
}

.leaflet-popup-content .popup-title {
  font-weight: 800;
  margin-bottom: 4px;
  color: var(--text);
}

.leaflet-popup-content .popup-meta {
  display: inline-block;
  margin-bottom: 6px;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(61, 214, 255, 0.12);
  color: var(--accent);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.leaflet-popup-content .popup-depth {
  display: inline-block;
  margin-left: 6px;
  color: var(--muted);
  font-size: 11px;
}

.leaflet-popup-content .popup-tip {
  color: var(--muted);
}

.leaflet-popup-close-button {
  color: var(--muted) !important;
}

.sn-marker {
  border: 2px solid #021018;
  border-radius: 50%;
  box-shadow: 0 0 0 1.5px rgba(255, 255, 255, 0.7), 0 2px 6px rgba(0, 0, 0, 0.4);
  width: 14px !important;
  height: 14px !important;
  margin-left: -7px !important;
  margin-top: -7px !important;
}

.sn-cluster {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(61, 214, 255, 0.22);
  border: 2px solid rgba(61, 214, 255, 0.7);
  color: #e9f7ff;
  font-weight: 800;
  font-size: 13px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.4);
}

.leaflet-control-zoom a {
  background: rgba(14, 39, 56, 0.92);
  color: var(--text);
  border: 1px solid var(--line);
  font-weight: 800;
}

.leaflet-control-zoom a:hover {
  background: rgba(61, 214, 255, 0.16);
  color: var(--accent);
}

.map-attribution {
  font-size: 11px;
  color: var(--muted);
  text-align: right;
  margin-top: 6px;
  padding-right: 4px;
}

.map-legend-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin: 0 0 14px;
  padding: 12px 14px;
  border-radius: 14px;
  background: rgba(61, 214, 255, 0.06);
  border: 1px solid rgba(61, 214, 255, 0.18);
  font-size: 12px;
  color: var(--muted);
}

.map-legend-bar strong {
  color: var(--text);
  margin-right: 4px;
}

.mobile-sidebar-toggle {
  display: none;
}

@media (max-width: 980px) {
  .map-layout {
    grid-template-columns: 1fr;
  }

  .map-sidebar {
    position: static;
    max-height: none;
    order: 2;
  }

  .map-canvas {
    height: 60vh;
    min-height: 420px;
    order: 1;
  }

  .mobile-sidebar-toggle {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
    padding: 10px 16px;
    border-radius: 999px;
    border: 1px solid rgba(61, 214, 255, 0.24);
    background: rgba(61, 214, 255, 0.08);
    color: var(--text);
    font-weight: 700;
    cursor: pointer;
  }
}

@media (max-width: 640px) {
  .map-canvas {
    height: 55vh;
  }
}
