
:root {
  --bg: #ffffff;
  --bg2: #f5f5f5;
  --card: #ffffff;
  --border: #53006c;
  --border-light: #d0bada;
  --text: #53006c;
  --muted: #7a3a8a;
  --accent: #53006c;
  --accent-dark: #35004a;
  --font: 'Inter', sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; border-radius: 0 !important; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 13px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

header {
  padding: 0 32px;
  height: 52px;
  display: flex;
  align-items: center;
  gap: 16px;
  border-bottom: 2px solid var(--border);
  background: var(--bg);
  position: sticky;
  top: 0;
  z-index: 1000;
}
.logo {
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text);
}
.logo span {
  font-size: 10px;
  font-weight: 400;
  color: var(--muted);
  display: block;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
header .spacer { flex: 1; }
.badge {
  background: var(--bg);
  border: 1px solid var(--border);
  padding: 4px 12px;
  font-size: 11px;
  color: var(--muted);
  font-weight: 500;
  letter-spacing: 0.05em;
}

.app-body {
  flex: 1;
  display: grid;
  grid-template-columns: 300px 1fr;
  align-items: stretch;
  min-height: 0;
}

.sidebar {
  background: var(--bg);
  border-right: 2px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
  height: calc(100vh - 52px);
}
.sidebar::-webkit-scrollbar { width: 3px; }
.sidebar::-webkit-scrollbar-thumb { background: var(--border-light); }

.sidebar-section {
  padding: 16px;
  border-bottom: 1px solid var(--border-light);
}
.sidebar-section h3 {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 10px;
}
.sidebar-placeholder {
  font-size: 10px;
  color: var(--muted);
  font-style: italic;
  padding: 12px;
  border: 1px dashed var(--border-light);
  text-align: center;
  letter-spacing: 0.04em;
}

.main-content {
  display: flex;
  flex-direction: column;
  background: var(--bg);
  --charts-h: 56px;
  height: calc(100vh - 52px);
  overflow-y: auto;
  overflow-x: hidden;
}

.main-content:has(> #bottomPanel[style*="display:none"]),
.main-content:has(> #bottomPanel[style*="display: none"]) {
  --charts-h: 0px;
}
.main-content::-webkit-scrollbar { width: 8px; }
.main-content::-webkit-scrollbar-thumb { background: var(--border-light); }

#map {
  width: 100%;
  height: calc(100vh - 52px - var(--charts-h));
  min-height: 120px;
  flex-shrink: 0;
  position: relative;
}

.bottom-panel {
  height: auto;
  min-height: 0;
  border-top: 2px solid var(--border);
  background: var(--bg);
  position: relative;
  flex-shrink: 0;
  overflow: hidden;
}

.charts-resize-handle { display: none !important; }
.charts-panel { overflow: hidden !important; padding: 0 !important; }
.bottom-panel { padding: 2px 0 !important; }
.charts-panel {
  background: var(--bg);
  display: flex;
  flex-direction: column;
}
.charts-resize-handle {
  position: absolute;
  top: -6px;
  left: 0;
  right: 0;
  height: 12px;
  cursor: ns-resize;
  z-index: 1005;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
}
.charts-resize-handle::before {
  content: '';
  width: 48px;
  height: 4px;
  background: var(--border);
  border-radius: 2px !important;
  opacity: 0.55;
  transition: opacity 0.15s, background 0.15s;
}
.charts-resize-handle:hover::before,
.charts-resize-handle.dragging::before {
  opacity: 1;
  background: var(--accent-dark);
}
body.charts-resizing { cursor: ns-resize !important; user-select: none !important; }
body.charts-resizing * { cursor: ns-resize !important; user-select: none !important; }

.charts-header {
  padding: 10px 16px;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}
.charts-title {
  font-weight: 700;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text);
}
.charts-body {
  padding: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100px;
  color: var(--muted);
  font-style: italic;
  font-size: 11px;
  letter-spacing: 0.04em;
}

.pop-kpi-strip {
  padding: 6px 16px;
  margin: 0;
  flex: 0 0 auto;
  display: flex;
  align-items: center;
}

.pop-kpi-strip-title {
  display: none !important;
}
.pop-kpi-strip-row {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  width: 100%;
}
.pop-kpi-item {
  flex: 1 1 0;
  min-width: 0;
  padding: 0 12px;
  border-right: 1px solid var(--border-light);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 3px;
}
.pop-kpi-item:first-child { padding-left: 0; }
.pop-kpi-item:last-child  { border-right: none; }
.pop-kpi-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  white-space: nowrap;
}
.pop-kpi-value {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
}
.pop-kpi-value .pop-kpi-unit {
  font-size: 11px;
  font-weight: 500;
  color: var(--muted);
  margin-left: 3px;
}

.basemap-switcher {
  position: absolute;
  top: 16px;
  right: 16px;
  z-index: 1001;
  transition: opacity 0.15s ease;
}

.basemap-btn {
  width: 44px;
  height: 44px;
  border-radius: 50% !important;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  user-select: none;
  padding: 0;
  pointer-events: auto;
  transition:
    background 0.18s ease,
    border-color 0.18s ease,
    box-shadow 0.18s ease,
    transform 0.12s ease,
    color 0.18s ease;

  background: rgba(250, 246, 252, 0.82);
  -webkit-backdrop-filter: blur(12px) saturate(140%);
  backdrop-filter: blur(12px) saturate(140%);
  border: 1px solid rgba(83, 0, 108, 0.20);
  color: #3a1a4a;
  box-shadow:
    0 1px 2px rgba(40, 0, 60, 0.06),
    0 6px 16px rgba(40, 0, 60, 0.10),
    0 14px 32px rgba(40, 0, 60, 0.12),
    inset 0 1px 0 rgba(255, 255, 255, 0.65);
}

.basemap-btn--dark {
  background: rgba(20, 12, 28, 0.42);
  border: 1px solid rgba(255, 255, 255, 0.22);
  color: #f3e8f7;
  box-shadow:
    0 1px 2px rgba(0, 0, 0, 0.18),
    0 6px 18px rgba(0, 0, 0, 0.28),
    0 18px 38px rgba(0, 0, 0, 0.32),
    inset 0 1px 0 rgba(255, 255, 255, 0.18);
}

.basemap-btn:hover {
  transform: translateY(-1px);
  background: rgba(250, 246, 252, 0.95);
  border-color: rgba(83, 0, 108, 0.38);
  box-shadow:
    0 2px 4px rgba(40, 0, 60, 0.08),
    0 10px 22px rgba(40, 0, 60, 0.14),
    0 18px 40px rgba(40, 0, 60, 0.16),
    inset 0 1px 0 rgba(255, 255, 255, 0.75);
}
.basemap-btn--dark:hover {
  background: rgba(20, 12, 28, 0.58);
  border-color: rgba(255, 255, 255, 0.35);
  box-shadow:
    0 2px 4px rgba(0, 0, 0, 0.22),
    0 10px 24px rgba(0, 0, 0, 0.34),
    0 22px 44px rgba(0, 0, 0, 0.38),
    inset 0 1px 0 rgba(255, 255, 255, 0.24);
}

.basemap-btn svg { width: 28px; height: 26px; display: block; }

.basemap-dropdown {
  display: none;
  position: absolute;
  top: 52px;
  right: 0;
  background: #ffffff;
  border: 2px solid var(--border);
  box-shadow: 3px 3px 0 var(--border-light);
  min-width: 200px;
  z-index: 1002;
}
.basemap-dropdown.open { display: block; }

.basemap-option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  cursor: pointer;
  font-family: var(--font);
  font-size: 11px;
  font-weight: 500;
  color: var(--text);
  border-bottom: 1px solid var(--border-light);
  user-select: none;
  transition: background 0.1s;
}
.basemap-option:last-child { border-bottom: none; }
.basemap-option:hover { background: var(--bg2); }
.basemap-option.active { background: #6b2a85; color: #fff; }
.basemap-option.active .basemap-thumb { border-color: rgba(255,255,255,0.5); }

.basemap-thumb {
  width: 28px;
  height: 20px;
  border: 1px solid var(--border-light);
  flex-shrink: 0;
}

.basemap-thumb-light {
  background: linear-gradient(135deg, #e8e8e8 0%, #f5f5f5 40%, #d0d0d0 100%);
}

.basemap-thumb-dark {
  background: linear-gradient(135deg, #3a3a3a 0%, #23262b 40%, #14161a 100%);
}
.basemap-thumb-osm {
  background: linear-gradient(135deg, #f2efe9 0%, #e6ede0 45%, #cfe0c3 100%);
}

.basemap-thumb-ortofoto {
  background: linear-gradient(135deg, #4a6741 0%, #3d5c38 30%, #8a7a5a 55%, #6b6b5a 80%, #a09080 100%);
  position: relative;
  overflow: hidden;
}
.basemap-thumb-ortofoto::after {
  content: '';
  position: absolute;
  inset: 0;
  background:
    repeating-linear-gradient(45deg, transparent, transparent 2px, rgba(255,255,255,0.04) 2px, rgba(255,255,255,0.04) 4px),
    repeating-linear-gradient(-45deg, transparent, transparent 3px, rgba(0,0,0,0.05) 3px, rgba(0,0,0,0.05) 5px);
}

.basemap-thumb-agea {
  background: linear-gradient(135deg, #6b8e3d 0%, #8fa84a 25%, #c9a85a 55%, #a8884a 80%, #6b5a3a 100%);
  position: relative;
  overflow: hidden;
}
.basemap-thumb-agea::after {
  content: '';
  position: absolute;
  inset: 0;
  background:
    repeating-linear-gradient(0deg, transparent, transparent 3px, rgba(0,0,0,0.08) 3px, rgba(0,0,0,0.08) 4px),
    repeating-linear-gradient(90deg, transparent, transparent 4px, rgba(255,255,255,0.06) 4px, rgba(255,255,255,0.06) 5px);
}

.basemap-section-title {
  padding: 6px 12px 4px;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  border-top: 1px solid var(--border-light);
  margin-top: 2px;
  user-select: none;
}

.poi-layer-list {
  max-height: 280px;
  overflow-y: auto;
}
.poi-layer-list::-webkit-scrollbar { width: 3px; }
.poi-layer-list::-webkit-scrollbar-thumb { background: var(--border-light); }

.poi-layer-row {
  display: flex;
  align-items: center;
  gap: 0;
  border-bottom: 1px solid var(--border-light);
  cursor: default;
}
.poi-layer-row:last-child { border-bottom: none; }

    .clim-shel-btnbar {
      display: flex;
      flex-direction: column;
      gap: 4px;
      padding: 6px 8px 8px;
    }
    .clim-shel-btn {
      display: flex;
      align-items: center;
      gap: 8px;
      padding: 3px 2px;
      border: none;
      background: transparent;
      color: var(--text);
      font-size: 12px;
      font-weight: 500;
      letter-spacing: 0.01em;
      cursor: pointer;
      transition: opacity 0.15s ease;
      user-select: none;
      text-align: left;
    }
    .clim-shel-btn:hover { opacity: 0.75; }
    .clim-shel-btn:active { transform: translateY(1px); }
    .clim-shel-btn.is-active { font-weight: 600; }

    .clim-shel-btn-dot {
      width: 14px; height: 14px;
      flex: 0 0 auto;
      border-radius: 0 !important;
      border: 1.5px solid rgba(83, 0, 108, 0.45);
      background: #fff;
      position: relative;
      transition: background 0.15s ease, border-color 0.15s ease;
    }

    .clim-shel-btn[data-mode="indoor"].is-active .clim-shel-btn-dot {
      background: #1d4ed8;
      border-color: #1d4ed8;
    }
    .clim-shel-btn[data-mode="outdoor"].is-active .clim-shel-btn-dot {
      background: #15803d;
      border-color: #15803d;
    }
    .clim-shel-btn[data-mode="all"].is-active .clim-shel-btn-dot {
      background: linear-gradient(135deg, #1d4ed8 0 50%, #15803d 50% 100%);
      border-color: #6b2a85;
    }

    .clim-shel-btn.is-active .clim-shel-btn-dot::after {
      content: "";
      position: absolute;
      left: 3px;
      top: 0px;
      width: 4px;
      height: 8px;
      border-right: 2px solid #fff;
      border-bottom: 2px solid #fff;
      transform: rotate(45deg);
    }
    .clim-shel-btn-label { line-height: 1; }

    .census-btnbar {
      display: flex;
      flex-direction: column;
      gap: 4px;
      padding: 6px 8px 8px;
    }
    .census-btn {
      display: flex;
      align-items: center;
      gap: 8px;
      padding: 3px 2px;
      border: none;
      background: transparent;
      color: var(--text);
      font-size: 12px;
      font-weight: 500;
      letter-spacing: 0.01em;
      cursor: pointer;
      transition: opacity 0.15s ease;
      user-select: none;
      text-align: left;
    }
    .census-btn:hover { opacity: 0.75; }
    .census-btn:active { transform: translateY(1px); }
    .census-btn.is-active { font-weight: 600; }

    .census-btn-dot {
      width: 14px; height: 14px;
      flex: 0 0 auto;
      border-radius: 0 !important;
      border: 1.5px solid rgba(83, 0, 108, 0.55);
      background: #fff;
      position: relative;
      overflow: hidden;
      transition: background 0.15s ease, border-color 0.15s ease;
    }
    .census-btn-dot .census-tile,
    .census-btn-dot::before {
      display: none !important;
    }

    .census-tile {
      position: absolute;
      left: 0; top: 0;
      width: 100%; height: 100%;
      pointer-events: none;
    }
    .census-tile-1 {
      background: rgba(191,214,232,1);
      clip-path: polygon(0% 0%, 55% 0%, 40% 45%, 0% 60%);
    }
    .census-tile-2 {
      background: rgba(138,124,186,1);
      clip-path: polygon(55% 0%, 100% 0%, 100% 55%, 70% 70%, 40% 45%);
    }
    .census-tile-3 {
      background: rgba(129,15,124,1);
      clip-path: polygon(0% 60%, 40% 45%, 70% 70%, 100% 55%, 100% 100%, 0% 100%);
    }

    .census-btn-dot::before {
      content: "";
      position: absolute;
      left: 0; top: 0;
      width: 100%; height: 100%;
      pointer-events: none;
      background:

        linear-gradient(155deg, transparent 47%, rgba(255,255,255,0.85) 47%, rgba(255,255,255,0.85) 53%, transparent 53%) no-repeat 47% -10% / 18% 60%,

        linear-gradient(40deg, transparent 47%, rgba(255,255,255,0.85) 47%, rgba(255,255,255,0.85) 53%, transparent 53%) no-repeat 55% 55% / 38% 32%,

        linear-gradient(75deg, transparent 47%, rgba(255,255,255,0.85) 47%, rgba(255,255,255,0.85) 53%, transparent 53%) no-repeat 0% 50% / 42% 18%,

        linear-gradient(110deg, transparent 47%, rgba(255,255,255,0.85) 47%, rgba(255,255,255,0.85) 53%, transparent 53%) no-repeat 75% 60% / 30% 18%;
      z-index: 1;
    }

    .census-btn.is-active .census-btn-dot .census-tile,
    .census-btn.is-active .census-btn-dot::before {
      display: none;
    }
    .census-btn.is-active .census-btn-dot {
      background: #6b2a85;
      border-color: #6b2a85;
    }
    .census-btn.is-active .census-btn-dot::after {
      content: "";
      position: absolute;
      left: 4px;
      top: 1px;
      width: 4px;
      height: 8px;
      border-right: 2px solid #fff;
      border-bottom: 2px solid #fff;
      transform: rotate(45deg);
      z-index: 2;
    }
    .census-btn-label { line-height: 1; }

    .census-legend {
      display: none;
      flex-direction: column;
      gap: 3px;
      margin: 6px 2px 2px 22px;
      padding: 6px 8px 7px;
      border-left: 2px solid rgba(107, 42, 133, 0.25);
      background: rgba(107, 42, 133, 0.04);
      border-radius: 0 4px 4px 0;
    }
    .census-btnbar:has(.census-btn.is-active) .census-legend {
      display: flex;
    }
    .census-legend-title {
      font-size: 10px;
      font-weight: 600;
      letter-spacing: 0.04em;
      text-transform: uppercase;
      color: var(--muted, #6b7280);
      margin-bottom: 3px;
      line-height: 1.1;
    }
    .census-legend-list {
      display: flex;
      flex-direction: column;
      gap: 2px;
    }
    .census-legend-item {
      display: flex;
      align-items: center;
      gap: 7px;
      font-size: 11px;
      line-height: 1.25;
      color: var(--text);
    }
    .census-legend-sw {
      width: 12px; height: 12px;
      flex: 0 0 auto;
      border: 1px solid rgba(0, 0, 0, 0.18);
      border-radius: 2px;
      box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.35);
    }

    .census-legend-sw--none {
      background:
        repeating-linear-gradient(
          45deg,
          rgba(107, 42, 133, 0.35) 0 1px,
          transparent 1px 4px
        ),
        #fff;
      border-color: rgba(107, 42, 133, 0.35);
    }
    .census-legend-lbl {
      font-variant-numeric: tabular-nums;
      white-space: nowrap;
    }

.clim-shel-legend {
  display: none;
  justify-content: center;
  align-items: center;
  gap: 14px;
  padding: 6px 4px 2px 4px;
  margin-top: 4px;
}

#climShelSidebarRow:has(input[type="checkbox"]:checked) ~ .clim-shel-legend,
#climShelSidebarList:has(#climShelSidebarChk:checked) .clim-shel-legend {
  display: flex;
}

.clim-shel-legend-item + .clim-shel-legend-item::before {
  content: '|';
  color: var(--border-light);
  font-weight: 400;
  margin-right: 14px;
  opacity: 0.7;
  user-select: none;
}
.clim-shel-legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 10.5px;
  color: var(--text);
  font-weight: 500;
  letter-spacing: 0.02em;
}
.clim-shel-legend-item svg { display: block; flex-shrink: 0; }
body.cat-non-shelter .clim-shel-legend { display: none !important; }
.clim-shel-legend { display: none !important; }
body.cat-is-shelter .clim-shel-legend { display: flex !important; }

.poi-layer-check {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 32px;
  flex-shrink: 0;
  cursor: pointer;
  border-right: 1px solid var(--border-light);
}
.poi-layer-check input[type=checkbox] {
  width: 12px;
  height: 12px;
  accent-color: var(--accent);
  cursor: pointer;
  margin: 0;
  border-radius: 0 !important;
}

.poi-layer-dot {
  width: 8px;
  height: 8px;
  flex-shrink: 0;
  margin: 0 6px 0 8px;
}

.poi-layer-label {
  flex: 1;
  font-size: 11px;
  font-weight: 500;
  color: var(--text);
  padding: 0 4px 0 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 32px;
}

.poi-layer-expand {
  width: 28px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  border-left: 1px solid var(--border-light);
  color: var(--muted);
  font-size: 10px;
  transition: transform 0.15s;
  user-select: none;
}
.poi-layer-expand.open { transform: rotate(180deg); }

.poi-subtype-list {
  display: none;
  background: var(--bg2);
  border-bottom: 1px solid var(--border-light);
}
.poi-subtype-list.open { display: block; }

.poi-subtype-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px 5px 36px;
  border-bottom: 1px solid rgba(208,186,218,0.4);
  cursor: pointer;
}
.poi-subtype-row:last-child { border-bottom: none; }
.poi-subtype-row:hover { background: rgba(83,0,108,0.06); }

.poi-subtype-row input[type=checkbox] {
  width: 11px;
  height: 11px;
  accent-color: var(--accent);
  cursor: pointer;
  margin: 0;
  flex-shrink: 0;
}

.poi-subtype-label {
  font-size: 10px;
  color: var(--muted);
  flex: 1;
}

.poi-subtype-dot {
  width: 8px;
  height: 8px;
  flex-shrink: 0;
}

.clim-shel-divicon { background: transparent; border: none; }
.clim-shel-divicon svg { display: block; }
.clim-shel-divicon .year-ring { display: none; }

.leaflet-popup-content-wrapper {
  border: 1px solid var(--border);
  background: var(--bg);
  box-shadow: 0 10px 32px rgba(83, 0, 108, 0.22),
              0 4px 10px rgba(83, 0, 108, 0.12);
  padding: 0;
  overflow: hidden;
  border-radius: 10px !important;
}
.leaflet-popup-tip {
  background: var(--bg);
  border: 1px solid var(--border);
}
.leaflet-popup-close-button {
  color: rgba(255,255,255,0.85) !important;
  font-size: 18px !important;
  padding: 6px 8px !important;
  right: 4px !important;
  top: 4px !important;
  text-shadow: 0 1px 2px rgba(0,0,0,0.3);
  transition: color 0.15s;
}
.leaflet-popup-close-button:hover { color: #fff !important; }
.leaflet-popup-content {
  margin: 0 !important;
  font-family: var(--font);
  font-size: 12px;
  color: var(--text);
  width: 260px !important;
}

.popup-header {
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-dark) 100%);
  color: #fff;
  padding: 12px 14px 10px 14px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  position: relative;
}
.popup-icon {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255,255,255,0.15);
  border-radius: 8px !important;
  border: 1px solid rgba(255,255,255,0.22);
}
.popup-icon svg { width: 18px; height: 18px; }
.popup-head-text { flex: 1; min-width: 0; padding-right: 18px; }
.popup-title {
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 0.02em;
  color: #fff;
  margin: 0;
  padding: 0;
  border: none;
  text-transform: none;
  line-height: 1.25;
  word-wrap: break-word;
}
.popup-subtitle {
  font-size: 10px;
  color: rgba(255,255,255,0.75);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-top: 2px;
  font-weight: 500;
}

.popup-body { padding: 12px 14px 12px 14px; background: var(--bg); }

.popup-hero {
  text-align: center;
  padding: 6px 0 10px 0;
  border-bottom: 1px dashed var(--border-light);
  margin-bottom: 10px;
}
.popup-big-label {
  font-size: 9px;
  color: var(--muted);
  text-align: center;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  margin-bottom: 4px;
  font-weight: 600;
}
.popup-big {
  font-size: 30px;
  font-weight: 800;
  color: var(--accent-dark);
  text-align: center;
  margin: 0;
  font-variant-numeric: tabular-nums;
  line-height: 1.05;
  letter-spacing: -0.02em;
  display: inline-flex;
  align-items: baseline;
  gap: 4px;
}
.popup-unit {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.popup-badge {
  display: block;
  width: max-content;
  max-width: 100%;
  margin: 8px auto 0 auto;
  padding: 3px 9px;
  font-size: 9.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  border-radius: 999px !important;
  border: 1px solid transparent;
}
.popup-badge--green  { background: rgba(34,197,94,0.15);  color: #15803d; border-color: rgba(34,197,94,0.4); }
.popup-badge--yellow { background: rgba(253,224,71,0.22); color: #a16207; border-color: rgba(202,138,4,0.45); }
.popup-badge--red    { background: rgba(248,113,113,0.18); color: #b91c1c; border-color: rgba(220,38,38,0.45); }
.popup-badge--dark   { background: rgba(127,29,29,0.15);  color: #7f1d1d; border-color: rgba(127,29,29,0.5); }
.popup-badge--purple { background: rgba(83,0,108,0.12);   color: var(--accent); border-color: rgba(83,0,108,0.35); }
.popup-badge--blue   { background: rgba(14,165,233,0.15); color: #0369a1; border-color: rgba(14,165,233,0.4); }

.popup-badge--usage-1 { background: rgba(184,141,204,0.45); color: #ffffff; border-color: rgba(155,108,184,0.55); }
.popup-badge--usage-2 { background: rgba(170,120,194,0.40); color: #ffffff; border-color: rgba(160,107,184,0.55); }
.popup-badge--usage-3 { background: rgba(160,107,184,0.30); color: #ffffff; border-color: rgba(122,46,150,0.65); }
.popup-badge--usage-4 { background: rgba(122,46,150,0.85);  color: #ffffff; border-color: rgba(83,0,108,0.85);   }
.popup-badge--usage-5 { background: rgba(107,31,135,0.90);  color: #ffffff; border-color: rgba(60,10,80,1);       }

.popup-rowlist {
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.popup-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  font-size: 11px;
  padding: 6px 0;
  border-bottom: 1px solid rgba(208, 186, 218, 0.35);
}
.popup-row:last-child { border-bottom: none; }
.popup-row .ico {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 14px;
  height: 14px;
  color: var(--muted);
  flex-shrink: 0;
  margin-right: 5px;
}
.popup-row .ico svg { width: 12px; height: 12px; }
.popup-row .k-wrap {
  display: flex;
  align-items: center;
  flex: 1;
  min-width: 0;
}
.popup-row .k {
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-size: 10px;
  font-weight: 600;
}
.popup-row .v {
  color: var(--text);
  font-weight: 700;
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-size: 11.5px;
  max-width: 60%;
  word-break: break-word;
}

.popup-header--indoor {
  background: linear-gradient(135deg, #4fa9d4 0%, #2563a8 100%);
}
.popup-header--outdoor {
  background: linear-gradient(135deg, #6fbf73 0%, #2f8a4a 100%);
}
.popup-header--indoor .popup-icon,
.popup-header--outdoor .popup-icon {
  background: rgba(255,255,255,0.20);
  border-color: rgba(255,255,255,0.30);
}

.leaflet-popup.popup-clim-indoor .leaflet-popup-content-wrapper,
.leaflet-popup.popup-clim-outdoor .leaflet-popup-content-wrapper {
  background: rgba(255,255,255,0.72);
  backdrop-filter: blur(12px) saturate(140%);
  -webkit-backdrop-filter: blur(12px) saturate(140%);
}
.leaflet-popup.popup-clim-indoor .leaflet-popup-content-wrapper {
  border-color: #2563a8;
  box-shadow: 0 10px 32px rgba(37, 99, 168, 0.28),
              0 4px 10px rgba(37, 99, 168, 0.15);
}
.leaflet-popup.popup-clim-outdoor .leaflet-popup-content-wrapper {
  border-color: #2f8a4a;
  box-shadow: 0 10px 32px rgba(47, 138, 74, 0.28),
              0 4px 10px rgba(47, 138, 74, 0.15);
}
.leaflet-popup.popup-clim-indoor .leaflet-popup-tip {
  background: rgba(255,255,255,0.72);
  backdrop-filter: blur(12px) saturate(140%);
  -webkit-backdrop-filter: blur(12px) saturate(140%);
  border-color: #2563a8;
}
.leaflet-popup.popup-clim-outdoor .leaflet-popup-tip {
  background: rgba(255,255,255,0.72);
  backdrop-filter: blur(12px) saturate(140%);
  -webkit-backdrop-filter: blur(12px) saturate(140%);
  border-color: #2f8a4a;
}

.leaflet-popup.popup-clim-indoor .popup-body,
.leaflet-popup.popup-clim-outdoor .popup-body {
  background: transparent;
}

.popup-clim-hero {
  text-align: center;
  padding: 10px 8px 10px 8px;
  margin-bottom: 10px;
  border: 1px solid transparent;
  border-radius: 10px !important;
  background: rgba(255,255,255,0.55);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
.leaflet-popup.popup-clim-indoor .popup-clim-hero {
  background: linear-gradient(180deg, rgba(79,169,212,0.16) 0%, rgba(79,169,212,0.06) 100%);
  border-color: rgba(37,99,168,0.30);
}
.leaflet-popup.popup-clim-outdoor .popup-clim-hero {
  background: linear-gradient(180deg, rgba(111,191,115,0.16) 0%, rgba(111,191,115,0.06) 100%);
  border-color: rgba(47,138,74,0.30);
}
.popup-clim-kind {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  margin: 0;
}
.leaflet-popup.popup-clim-indoor  .popup-clim-kind { color: #1d4f85; }
.leaflet-popup.popup-clim-outdoor .popup-clim-kind { color: #226b39; }
.popup-clim-sub {
  font-size: 10px;
  color: var(--muted);
  margin-top: 3px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  font-weight: 600;
}

.popup-clim-yearbadge {
  display: inline-block;
  margin-top: 8px;
  padding: 3px 9px;
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  border-radius: 999px !important;
  border: 1px solid transparent;
}
.leaflet-popup.popup-clim-indoor .popup-clim-yearbadge {
  background: rgba(37,99,168,0.12); color: #1d4f85; border-color: rgba(37,99,168,0.40);
}
.leaflet-popup.popup-clim-outdoor .popup-clim-yearbadge {
  background: rgba(47,138,74,0.12); color: #226b39; border-color: rgba(47,138,74,0.40);
}

.leaflet-popup.popup-scuola .leaflet-popup-content-wrapper {
  background: #ffffff;
  color: var(--text);
  border: 1.5px solid var(--border);
  box-shadow: 0 4px 14px rgba(83, 0, 108, 0.18);
}
.leaflet-popup.popup-scuola .leaflet-popup-tip {
  background: #ffffff;
  border: 1.5px solid var(--border);
}
.leaflet-popup.popup-scuola .popup-header--scuola {
  background: linear-gradient(135deg, #53006c 0%, #7a2e96 100%);
  color: #ffffff;
}
.leaflet-popup.popup-scuola .popup-header--scuola .popup-title,
.leaflet-popup.popup-scuola .popup-header--scuola .popup-subtitle {
  color: #ffffff;
}
.scuola-bacino {
  margin: 10px 0 6px;
  padding: 0;
  background: transparent;
  border: 0;
}
.scuola-bacino-title {
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--muted);
  margin-bottom: 10px;
}
.scuola-bacino-grid {
  display: grid;
  grid-template-columns: 28px 1fr 1fr;
  column-gap: 14px;
  row-gap: 8px;
  align-items: center;
}
.scuola-bacino-head {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--muted);
  text-align: center;
  padding-bottom: 4px;
  border-bottom: 1px solid rgba(83,0,108,0.18);
}
.scuola-bacino-house {
  width: 24px;
  height: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.scuola-bacino-house svg { width: 22px; height: 22px; display: block; }
.scuola-bacino-house--green svg path { fill: #22c55e; stroke: #166534; }
.scuola-bacino-house--red   svg path { fill: #ef4444; stroke: #7f1d1d; }
.scuola-bacino-house--gray  svg path { fill: #9ca3af; stroke: #4b5563; }
.scuola-bacino-val {
  font-size: 15px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--text);
  text-align: center;
  white-space: nowrap;
}
.scuola-bacino-val small {
  display: block;
  font-size: 9.5px;
  font-weight: 500;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.4px;
  margin-top: 1px;
}

.popup-clim-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 999px !important;
  font-size: 10.5px;
  font-weight: 700;
  text-decoration: none;
  border: 1px solid transparent;
  transition: filter 0.15s;
}
.popup-clim-link:hover { filter: brightness(1.1); text-decoration: none; }
.popup-clim-link { white-space: nowrap; line-height: 1; }
.popup-clim-link svg {
  width: 12px;
  height: 12px;
  flex-shrink: 0;
  display: inline-block;
  vertical-align: middle;
}
.popup-clim-link span {
  display: inline-block;
  vertical-align: middle;
  white-space: nowrap;
}
.popup-row .v:has(.popup-clim-link) {
  max-width: none;
  white-space: nowrap;
  flex-shrink: 0;
}
.leaflet-popup.popup-clim-indoor .popup-clim-link {
  background: rgba(37,99,168,0.10); color: #1d4f85; border-color: rgba(37,99,168,0.35);
}
.leaflet-popup.popup-clim-outdoor .popup-clim-link {
  background: rgba(47,138,74,0.10); color: #226b39; border-color: rgba(47,138,74,0.35);
}

.leaflet-popup.popup-clim-indoor .popup-row .ico  { color: #2563a8; }
.leaflet-popup.popup-clim-outdoor .popup-row .ico { color: #2f8a4a; }
.leaflet-popup.popup-clim-indoor .popup-row .k,
.leaflet-popup.popup-clim-outdoor .popup-row .k {
  color: #555;
}
.leaflet-popup.popup-clim-indoor .popup-row .v,
.leaflet-popup.popup-clim-outdoor .popup-row .v {
  color: #1f1f1f;
}
.leaflet-popup.popup-clim-indoor .popup-row,
.leaflet-popup.popup-clim-outdoor .popup-row {
  border-bottom-color: rgba(0,0,0,0.08);
}

.popup-header--cat-cultural { background: linear-gradient(135deg, #a86fdc 0%, #6a3aa8 100%); }
.leaflet-popup.popup-cat-cultural .leaflet-popup-content-wrapper {
  background: rgba(255,255,255,0.72);
  backdrop-filter: blur(12px) saturate(140%);
  -webkit-backdrop-filter: blur(12px) saturate(140%);
  border-color: #6a3aa8;
  box-shadow: 0 10px 32px rgba(106,58,168,0.28), 0 4px 10px rgba(106,58,168,0.15);
}
.leaflet-popup.popup-cat-cultural .leaflet-popup-tip {
  background: rgba(255,255,255,0.72);
  backdrop-filter: blur(12px) saturate(140%);
  -webkit-backdrop-filter: blur(12px) saturate(140%);
  border-color: #6a3aa8;
}
.leaflet-popup.popup-cat-cultural .popup-cat-hero {
  background: linear-gradient(180deg, rgba(168,111,220,0.16) 0%, rgba(168,111,220,0.06) 100%);
  border-color: rgba(106,58,168,0.30);
}
.leaflet-popup.popup-cat-cultural .popup-cat-kind { color: #4a266e; }
.leaflet-popup.popup-cat-cultural .popup-row .ico  { color: #6a3aa8; }

.popup-header--cat-education { background: linear-gradient(135deg, #e07a7a 0%, #b03030 100%); }
.leaflet-popup.popup-cat-education .leaflet-popup-content-wrapper {
  background: rgba(255,255,255,0.72);
  backdrop-filter: blur(12px) saturate(140%);
  -webkit-backdrop-filter: blur(12px) saturate(140%);
  border-color: #b03030;
  box-shadow: 0 10px 32px rgba(176,48,48,0.28), 0 4px 10px rgba(176,48,48,0.15);
}
.leaflet-popup.popup-cat-education .leaflet-popup-tip {
  background: rgba(255,255,255,0.72);
  backdrop-filter: blur(12px) saturate(140%);
  -webkit-backdrop-filter: blur(12px) saturate(140%);
  border-color: #b03030;
}
.leaflet-popup.popup-cat-education .popup-cat-hero {
  background: linear-gradient(180deg, rgba(224,122,122,0.16) 0%, rgba(224,122,122,0.06) 100%);
  border-color: rgba(176,48,48,0.30);
}
.leaflet-popup.popup-cat-education .popup-cat-kind { color: #7a1f1f; }
.leaflet-popup.popup-cat-education .popup-row .ico  { color: #b03030; }

.popup-header--cat-entertainment { background: linear-gradient(135deg, #e773b4 0%, #b32e7e 100%); }
.leaflet-popup.popup-cat-entertainment .leaflet-popup-content-wrapper {
  background: rgba(255,255,255,0.72);
  backdrop-filter: blur(12px) saturate(140%);
  -webkit-backdrop-filter: blur(12px) saturate(140%);
  border-color: #b32e7e;
  box-shadow: 0 10px 32px rgba(179,46,126,0.28), 0 4px 10px rgba(179,46,126,0.15);
}
.leaflet-popup.popup-cat-entertainment .leaflet-popup-tip {
  background: rgba(255,255,255,0.72);
  backdrop-filter: blur(12px) saturate(140%);
  -webkit-backdrop-filter: blur(12px) saturate(140%);
  border-color: #b32e7e;
}
.leaflet-popup.popup-cat-entertainment .popup-cat-hero {
  background: linear-gradient(180deg, rgba(231,115,180,0.16) 0%, rgba(231,115,180,0.06) 100%);
  border-color: rgba(179,46,126,0.30);
}
.leaflet-popup.popup-cat-entertainment .popup-cat-kind { color: #7a1f56; }
.leaflet-popup.popup-cat-entertainment .popup-row .ico  { color: #b32e7e; }

.popup-header--cat-health { background: linear-gradient(135deg, #f08a8a 0%, #c94545 100%); }
.leaflet-popup.popup-cat-health .leaflet-popup-content-wrapper {
  background: rgba(255,255,255,0.72);
  backdrop-filter: blur(12px) saturate(140%);
  -webkit-backdrop-filter: blur(12px) saturate(140%);
  border-color: #c94545;
  box-shadow: 0 10px 32px rgba(201,69,69,0.28), 0 4px 10px rgba(201,69,69,0.15);
}
.leaflet-popup.popup-cat-health .leaflet-popup-tip {
  background: rgba(255,255,255,0.72);
  backdrop-filter: blur(12px) saturate(140%);
  -webkit-backdrop-filter: blur(12px) saturate(140%);
  border-color: #c94545;
}
.leaflet-popup.popup-cat-health .popup-cat-hero {
  background: linear-gradient(180deg, rgba(240,138,138,0.16) 0%, rgba(240,138,138,0.06) 100%);
  border-color: rgba(201,69,69,0.30);
}
.leaflet-popup.popup-cat-health .popup-cat-kind { color: #8a2828; }
.leaflet-popup.popup-cat-health .popup-row .ico  { color: #c94545; }

.popup-header--cat-mobility { background: linear-gradient(135deg, #f4a258 0%, #cc6a16 100%); }
.leaflet-popup.popup-cat-mobility .leaflet-popup-content-wrapper {
  background: rgba(255,255,255,0.72);
  backdrop-filter: blur(12px) saturate(140%);
  -webkit-backdrop-filter: blur(12px) saturate(140%);
  border-color: #cc6a16;
  box-shadow: 0 10px 32px rgba(204,106,22,0.28), 0 4px 10px rgba(204,106,22,0.15);
}
.leaflet-popup.popup-cat-mobility .leaflet-popup-tip {
  background: rgba(255,255,255,0.72);
  backdrop-filter: blur(12px) saturate(140%);
  -webkit-backdrop-filter: blur(12px) saturate(140%);
  border-color: #cc6a16;
}
.leaflet-popup.popup-cat-mobility .popup-cat-hero {
  background: linear-gradient(180deg, rgba(244,162,88,0.16) 0%, rgba(244,162,88,0.06) 100%);
  border-color: rgba(204,106,22,0.30);
}
.leaflet-popup.popup-cat-mobility .popup-cat-kind { color: #8a4710; }
.leaflet-popup.popup-cat-mobility .popup-row .ico  { color: #cc6a16; }

.popup-header--cat-park { background: linear-gradient(135deg, #5fb858 0%, #2f7a2f 100%); }
.leaflet-popup.popup-cat-park .leaflet-popup-content-wrapper {
  background: rgba(255,255,255,0.72);
  backdrop-filter: blur(12px) saturate(140%);
  -webkit-backdrop-filter: blur(12px) saturate(140%);
  border-color: #2f7a2f;
  box-shadow: 0 10px 32px rgba(47,122,47,0.28), 0 4px 10px rgba(47,122,47,0.15);
}
.leaflet-popup.popup-cat-park .leaflet-popup-tip {
  background: rgba(255,255,255,0.72);
  backdrop-filter: blur(12px) saturate(140%);
  -webkit-backdrop-filter: blur(12px) saturate(140%);
  border-color: #2f7a2f;
}
.leaflet-popup.popup-cat-park .popup-cat-hero {
  background: linear-gradient(180deg, rgba(95,184,88,0.16) 0%, rgba(95,184,88,0.06) 100%);
  border-color: rgba(47,122,47,0.30);
}
.leaflet-popup.popup-cat-park .popup-cat-kind { color: #1f5520; }
.leaflet-popup.popup-cat-park .popup-row .ico  { color: #2f7a2f; }

.popup-header--cat-drinking_fountain { background: linear-gradient(135deg, #5fd0d0 0%, #1d7a8c 100%); }
.leaflet-popup.popup-cat-drinking_fountain .leaflet-popup-content-wrapper {
  background: rgba(255,255,255,0.72);
  backdrop-filter: blur(12px) saturate(140%);
  -webkit-backdrop-filter: blur(12px) saturate(140%);
  border-color: #1d7a8c;
  box-shadow: 0 10px 32px rgba(29,122,140,0.28), 0 4px 10px rgba(29,122,140,0.15);
}
.leaflet-popup.popup-cat-drinking_fountain .leaflet-popup-tip {
  background: rgba(255,255,255,0.72);
  backdrop-filter: blur(12px) saturate(140%);
  -webkit-backdrop-filter: blur(12px) saturate(140%);
  border-color: #1d7a8c;
}
.leaflet-popup.popup-cat-drinking_fountain .popup-cat-hero {
  background: linear-gradient(180deg, rgba(95,208,208,0.16) 0%, rgba(95,208,208,0.06) 100%);
  border-color: rgba(29,122,140,0.30);
}
.leaflet-popup.popup-cat-drinking_fountain .popup-cat-kind { color: #115560; }
.leaflet-popup.popup-cat-drinking_fountain .popup-row .ico  { color: #1d7a8c; }

.leaflet-popup[class*="popup-cat-"] .popup-body { background: transparent; }
.popup-cat-hero {
  text-align: center;
  padding: 10px 8px 10px 8px;
  margin-bottom: 10px;
  border: 1px solid transparent;
  border-radius: 10px !important;
  background: rgba(255,255,255,0.55);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
.popup-cat-kind {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  margin: 0;
}
.popup-cat-sub {
  font-size: 10px;
  color: var(--muted);
  margin-top: 3px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  font-weight: 600;
}

.leaflet-tooltip {
  background: var(--accent-dark);
  color: #fff;
  border: none;
  font-family: var(--font);
  font-size: 11px;
  font-weight: 600;
  padding: 4px 8px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.2);
}
.leaflet-tooltip-top:before { border-top-color: var(--accent-dark); }

.layer-list { display: flex; flex-direction: column; gap: 8px; }

.layer-row {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px 8px 14px;
  border: 1px solid var(--border-light);
  background: var(--bg);
  cursor: pointer;
  border-radius: 8px !important;

  height: 46px;
  box-sizing: border-box;
  overflow: hidden;
  transition: background 0.15s ease, border-color 0.15s ease,
              box-shadow 0.15s ease, transform 0.05s ease;
}
.layer-row:hover {
  background: var(--bg2);
  border-color: var(--border);
}
.layer-row:active { transform: translateY(1px); }

.layer-row input[type="checkbox"] {
  position: absolute;
  opacity: 0;
  pointer-events: none;
  width: 0;
  height: 0;
  margin: 0;
}

.layer-row:has(input[type="checkbox"]:checked) {
  border-color: var(--accent);
  background: var(--bg);
  box-shadow: 0 0 0 1px var(--accent) inset,
              0 2px 6px rgba(124, 58, 237, 0.10);
}

.layer-row:has(input[type="checkbox"]:focus-visible) {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.layer-icon {
  width: 26px;
  height: 26px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0.55;
  transition: opacity 0.15s ease, transform 0.15s ease;
}
.layer-icon svg { width: 24px; height: 24px; display: block; }
.layer-row:has(input[type="checkbox"]:checked) .layer-icon {
  opacity: 1;
  transform: scale(1.05);
}

.layer-name {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text);
  flex: 1;
  line-height: 1.25;

  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.layer-row:has(input[type="checkbox"]:checked) .layer-name {
  color: var(--accent-dark);
}

.layer-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--border);
  flex-shrink: 0;
  transition: background 0.15s ease, box-shadow 0.15s ease;
}
.layer-row:has(input[type="checkbox"]:checked) .layer-dot {
  background: var(--accent);
  box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.18);
}

.map-legend {
  position: absolute;
  bottom: 16px;
  right: 16px;
  z-index: 800;
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid var(--border);
  box-shadow: 0 2px 10px rgba(83, 0, 108, 0.18);
  font-family: var(--font);
  font-size: 11px;
  color: var(--text);
  max-width: 260px;
  user-select: none;
}
.map-legend-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 10px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  font-size: 10px;
}
.map-legend-header .legend-toggle {
  font-size: 13px;
  line-height: 1;
  transition: transform 0.2s ease;
}
.map-legend.collapsed .legend-toggle { transform: rotate(-90deg); }
.map-legend.collapsed .map-legend-body { display: none; }
.map-legend-body {
  padding: 8px 10px 10px 10px;
  max-height: 60vh;
  overflow-y: auto;
}
.legend-section { margin-bottom: 10px; }
.legend-section:last-child { margin-bottom: 0; }
.legend-section-title {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--accent-dark);
  margin-bottom: 4px;
  padding-bottom: 2px;
  border-bottom: 1px solid var(--border-light);
}
.legend-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 2px 0;
  line-height: 1.3;
}
.legend-swatch {
  width: 18px;
  height: 12px;
  border: 1px solid rgba(0, 0, 0, 0.18);
  flex-shrink: 0;
}
.legend-swatch-line {
  width: 22px;
  flex-shrink: 0;
  display: inline-block;
}
.legend-swatch-dot {
  width: 12px;
  height: 12px;
  border-radius: 50% !important;
  flex-shrink: 0;
  border: 1.5px solid #fff;
  box-shadow: 0 0 0 1.5px var(--accent-dark);
}
.legend-label { flex: 1; }
.legend-note {
  font-size: 10px;
  color: var(--muted);
  font-style: italic;
  margin-top: 3px;
  line-height: 1.35;
}

.sb-legend {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.sb-legend-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.sb-legend-title {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
  padding-bottom: 4px;
  border-bottom: 1px solid var(--border-light);
  margin-bottom: 2px;
}

.sb-legend-title--with-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.sb-legend-title--with-toggle .sb-legend-title-text {
  flex: 1;
  min-width: 0;
}

.dist-unit-pill {
  display: inline-flex;
  position: relative;
  background: linear-gradient(180deg,
              rgba(83, 0, 108, 0.06) 0%,
              rgba(83, 0, 108, 0.10) 100%);
  border: 1px solid rgba(83, 0, 108, 0.18);
  padding: 2px;
  user-select: none;
  border-radius: 999px !important;
  overflow: hidden;
  -webkit-backdrop-filter: blur(8px) saturate(140%);
  backdrop-filter: blur(8px) saturate(140%);
  box-shadow:
    inset 0 1px 2px rgba(83, 0, 108, 0.08),
    inset 0 -1px 0 rgba(255, 255, 255, 0.5);

  height: 18px;
  flex-shrink: 0;
}

.dist-unit-pill::before {
  content: '';
  position: absolute;
  top: 2px;
  bottom: 2px;
  left: 2px;
  width: calc(50% - 2px);
  background:
    linear-gradient(180deg,
      rgba(140, 80, 175, 0.92) 0%,
      rgba(105, 50, 140, 0.92) 50%,
      rgba(95, 40, 130, 0.94) 100%);
  border-radius: 999px !important;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.45),
    inset 0 -1px 0 rgba(60, 0, 90, 0.35),
    0 1px 2px rgba(60, 0, 90, 0.18),
    0 2px 6px rgba(83, 0, 108, 0.22);
  transition: transform 0.32s cubic-bezier(0.4, 0, 0.2, 1);
  transform: translateX(0%);
  z-index: 0;
  pointer-events: none;
}
.dist-unit-pill[data-pos="1"]::before {
  transform: translateX(100%);
}
.dist-unit-pill-opt {
  position: relative;
  z-index: 1;
  padding: 0 10px;
  font-size: 8.5px;
  font-weight: 700;
  letter-spacing: 0.10em;
  text-transform: uppercase;
  cursor: pointer;
  color: var(--muted);
  background: transparent;
  border-radius: 999px !important;
  text-align: center;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 28px;
  transition: color 0.32s cubic-bezier(0.4, 0, 0.2, 1);
}
.dist-unit-pill-opt:hover:not(.active) {
  color: var(--accent);
}
.dist-unit-pill-opt.active {
  color: #fff;
  text-shadow: 0 1px 0 rgba(40, 0, 60, 0.25);
}
.sb-legend-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  color: var(--text);
  line-height: 1.3;
}
.sb-sw {
  flex-shrink: 0;
  display: inline-block;
}
.sb-sw-square {
  width: 16px;
  height: 11px;
  border: 1px solid rgba(0,0,0,0.15);
}
.sb-sw-line {
  width: 22px;
  height: 6px;
  flex-shrink: 0;
  display: inline-block;
}
.sb-road-row {
  display: grid;
  grid-template-columns: 52px 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 5px 0;
  border-bottom: 1px dashed rgba(208, 186, 218, 0.45);
}
.sb-road-row:last-child { border-bottom: none; }
.sb-road-svg {
  width: 52px;
  height: 14px;
  display: block;
  overflow: visible;
}
.sb-road-svg .road-glow {

  opacity: 0.18;
  filter: blur(0.6px);
}
.sb-road-label {
  font-size: 11px;
  color: var(--text);
  font-weight: 500;
  line-height: 1.2;
  letter-spacing: 0.01em;
}
.sb-road-count {
  font-size: 9px;
  font-weight: 700;
  line-height: 1;
  letter-spacing: 0.02em;
  font-variant-numeric: tabular-nums;
  display: block;
  margin-bottom: 2px;
  text-align: center;
  min-width: 52px;
}
.sb-road-svg-wrap {
  display: flex;
  flex-direction: column;
  align-items: stretch;
}
.sb-road-chip {
  font-size: 9.5px;
  font-weight: 700;
  color: var(--muted);
  background: rgba(83, 0, 108, 0.06);
  border: 1px solid rgba(83, 0, 108, 0.15);
  padding: 2px 7px;
  border-radius: 999px !important;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.sb-road-hint {
  font-size: 9.5px;
  color: var(--muted);
  font-style: italic;
  margin: -2px 0 6px 0;
  line-height: 1.3;
  letter-spacing: 0.01em;
}
.sb-scale-bar {
  display: flex;
  height: 18px;
  width: 100%;
  border: 1px solid rgba(83, 0, 108, 0.18);
  border-radius: 999px !important;
  overflow: hidden;
  position: relative;
  box-shadow:
    inset 0 1px 2px rgba(83, 0, 108, 0.10),
    inset 0 -1px 0 rgba(255, 255, 255, 0.35),
    0 1px 2px rgba(83, 0, 108, 0.05);
}
.sb-scale-bar > span {
  flex: 1;
  height: 100%;
  display: block;
}

.sb-scale-bar::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg,
              rgba(255, 255, 255, 0.18) 0%,
              rgba(255, 255, 255, 0.04) 45%,
              rgba(255, 255, 255, 0) 60%,
              rgba(0, 0, 0, 0.04) 100%);
  pointer-events: none;
  border-radius: 999px !important;
}
.sb-scale-ticks {
  position: relative;
  height: 14px;
  font-size: 9.5px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  margin-top: 2px;
  letter-spacing: 0.02em;
}
.sb-scale-ticks > span {
  position: absolute;
  top: 0;
  white-space: nowrap;
  line-height: 1;
  transform: translateX(-50%);
}
.sb-scale-ticks > span:nth-child(1) { left: 25%; }
.sb-scale-ticks > span:nth-child(2) { left: 50%; }
.sb-scale-ticks > span:nth-child(3) { left: 75%; }
.sb-legend-scale {
  margin-bottom: 8px;
}
.city-info {
  display: flex;
  align-items: center;
  gap: 12px;
  border: 1px solid var(--border);
  padding: 12px;
  background: var(--bg);
}
.city-name {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.01em;
}
.city-select {
  width: 100%;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 6px 8px;
  font-family: var(--font);
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.02em;
  cursor: pointer;
  outline: none;
}
.city-select:focus { border-color: var(--accent-dark); }
.city-select option { font-weight: 600; text-transform: none; }
.city-meta { font-size: 10px; color: var(--muted); margin-top: 2px; }

#ghslLegendHint {
  display: none;
  padding: 8px 6px 10px 6px;
  margin: 2px 0 4px 0;
}
#ghslLegendHint .ghsl-line1,
#ghslLegendHint .ghsl-line2 {
  color: #53006c !important;
  transform: skewX(-10deg);
  transform-origin: left center;
  display: block;
  line-height: 1.3;
  white-space: normal;
}
#ghslLegendHint .ghsl-line1 { font-size: 11px; font-weight: 400; }
#ghslLegendHint .ghsl-line2 { font-size: 11px; font-weight: 800; margin-top: 2px; }
#ghslLegendHint .ghsl-legend-img {
  display: block;
  margin-top: 8px;
  width: 110px;
  max-width: 55%;
  height: auto;
}

#mapLoading {
  position: absolute;
  inset: 0;
  z-index: 1500;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  background: rgba(255, 255, 255, 0.92);
  -webkit-backdrop-filter: blur(2px);
  backdrop-filter: blur(2px);
  transition: opacity 0.35s ease;
}
#mapLoading.hidden { opacity: 0; pointer-events: none; }
#mapLoading .spinner {
  width: 54px;
  height: 54px;
  border-radius: 50% !important;
  border: 5px solid rgba(83, 0, 108, 0.18);
  border-top-color: #53006c;
  animation: mapLoadingSpin 0.9s linear infinite;
}
#mapLoading .loading-label {
  font-family: var(--font);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: #53006c;
}
@keyframes mapLoadingSpin { to { transform: rotate(360deg); } }
