/* ─── BASE STYLES ─── */
:root {
  --bg: #ffffff;
  --bg2: #f5f5f5;
  --card: #ffffff;
  --border: #53006c;
  --border-light: #d0bada;
  --text: #53006c;
  --muted: #7a3a8a;
  --accent: #53006c;
  --accent-dark: #35004a;
  --radius: 0px;
  --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;
  height: 100vh;
  overflow-y: hidden;
  display: flex;
  flex-direction: column;
}

/* ─── HEADER ─── */
header {
  padding: 0 16px;
  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; }

.header-logo {
  height: 40px;
  width: auto;
  display: block;
  flex-shrink: 0;
  object-fit: contain;
  user-select: none;
  -webkit-user-drag: none;
}

.header-logo-link {
  display: flex;
  align-items: center;
  flex-shrink: 0;
  cursor: pointer;
  text-decoration: none;
  transition: opacity 0.15s ease;
}
.header-logo-link:hover { opacity: 0.8; }

.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;
}

/* ─── LAYOUT ─── */
.app-body {
  flex: 1;
  display: grid;
  grid-template-columns: 300px 1fr;
  align-items: stretch;
  min-height: 0;
}

/* ─── SIDEBAR ─── */
.sidebar {
  background: var(--bg);
  border-right: 2px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  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;
}

.city-info {
  display: flex;
  align-items: center;
  gap: 12px;
  border: none;
  padding: 0;
  background: var(--bg);
}

.city-name {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.01em;
}
.city-meta { font-size: 10px; color: var(--muted); margin-top: 2px; }
.city-source { font-size: 10px; color: var(--muted); margin-top: 3px; letter-spacing: 0.02em; opacity: 0.85; }

.score-ring-wrap {
  position: relative;
  width: 72px;
  height: 72px;
  flex-shrink: 0;
  margin-left: auto;
}
.score-ring-wrap canvas { width: 72px !important; height: 72px !important; display: block; }
.score-val {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0;
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
  line-height: 1;
  pointer-events: none;
}
.score-val .score-sub {
  font-size: 7px;
  font-weight: 400;
  color: var(--muted);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-top: 2px;
  line-height: 1;
}
.score-label { font-size: 9px; color: var(--muted); text-align: center; letter-spacing: 0.08em; text-transform: uppercase; }

.cat-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  max-height: 999px;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: none;
  -ms-overflow-style: none;
  scroll-behavior: smooth;
}
.cat-grid::-webkit-scrollbar { width: 0; height: 0; background: transparent; }

.cat-grid-wrap {
  position: relative;
}
.cat-grid-arrow {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  width: 22px;
  height: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--card);
  border: 1px solid var(--border-light);
  color: var(--accent);
  cursor: pointer;
  font-size: 10px;
  line-height: 1;
  padding: 0;
  z-index: 5;
  opacity: 0.85;
  transition: opacity 120ms ease, background 120ms ease;
  user-select: none;
}
.cat-grid-arrow:hover {
  opacity: 1;
  background: var(--bg2);
}
.cat-grid-arrow.up   { top: -14px; }
.cat-grid-arrow.down { bottom: -14px; }
.cat-grid-arrow[hidden] { display: none !important; }

.cat-btn {
  background: var(--bg);
  border: 1px solid var(--border-light);
  padding: 10px 6px;
  cursor: pointer;
  text-align: center;
  transition:
    background 0.28s cubic-bezier(0.4, 0, 0.2, 1),
    border-color 0.28s cubic-bezier(0.4, 0, 0.2, 1),
    color 0.28s cubic-bezier(0.4, 0, 0.2, 1),
    box-shadow 0.28s cubic-bezier(0.4, 0, 0.2, 1);
  color: var(--text);
  font-family: var(--font);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.04em;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  border-radius: 4px !important;
}

.cat-btn:hover {
  border-color: var(--border);
  background: var(--bg2);
}

.cat-btn.active {
  border-color: #6b2a85;
  background: #6b2a85;
  color: var(--bg);
  box-shadow:
    0 1px 2px rgba(83, 0, 108, 0.15),
    0 2px 6px rgba(83, 0, 108, 0.10);
}

.cat-btn.active svg path,
.cat-btn.active svg rect,
.cat-btn.active svg circle,
.cat-btn.active svg line,
.cat-btn.active svg polyline,
.cat-btn.active svg polygon {
  stroke: #ffffff;
  fill: none;
}

.cat-btn.active svg .fill-black {
  fill: #ffffff;
  stroke: none;
}

.cat-icon-svg { width: 22px; height: 22px; display: block; }

.legend-bar {
  height: 18px;
  background: linear-gradient(90deg,
              rgba(34, 197, 94, 0.85) 0%,
              rgba(34, 197, 94, 0.85) 25%,
              rgba(253, 224, 71, 0.88) 25%,
              rgba(202, 138, 4, 0.85) 50%,
              rgba(248, 113, 113, 0.85) 50%,
              rgba(127, 29, 29, 0.85) 95%,
              rgba(156, 163, 175, 0.80) 95%,
              rgba(156, 163, 175, 0.80) 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);
}
.legend-labels {
  display: flex;
  justify-content: space-between;
  font-size: 10px;
  color: var(--muted);
  margin-top: 6px;
  padding: 0 2px;
}

/* ─── Legend mode toggle ─── */
.legend-toggle {
  display: flex;
  margin-top: 10px;
  border: 1px solid var(--border);
  background: var(--bg);
  user-select: none;
}
.legend-toggle-opt {
  flex: 1;
  text-align: center;
  padding: 5px 6px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  cursor: pointer;
  color: var(--muted);
  transition: background 0.12s, color 0.12s;
}
.legend-toggle-opt + .legend-toggle-opt { border-left: 1px solid var(--border-light); }
.legend-toggle-opt:hover { background: var(--bg2); }
.legend-toggle-opt.active {
  background: var(--accent-dark);
  color: #fff;
}

/* ─── Steps pill toggle (segmented control) ─── */
.controls-row {
  margin-top: 18px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  align-items: stretch;
}

.steps-wrap {
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: stretch;
  width: 100%;
}

.opacity-slider-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 4px;
  width: 70%;
  align-self: center;
}
.opacity-slider-wrap input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  flex: 1;
  height: 4px;
  background: linear-gradient(90deg, transparent 0%, var(--border-light) 50%, var(--accent) 100%);
  outline: none;
  cursor: pointer;
  border: 1px solid var(--border-light);
}
.opacity-slider-wrap input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 12px;
  height: 12px;
  background: var(--accent);
  border: 1px solid var(--accent-dark);
  cursor: pointer;
}
.opacity-slider-wrap input[type="range"]::-moz-range-thumb {
  width: 12px;
  height: 12px;
  background: var(--accent);
  border: 1px solid var(--accent-dark);
  cursor: pointer;
  border-radius: 0;
}
.opacity-val {
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  min-width: 32px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.steps-label {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--muted);
  text-align: left;
}

.steps-pill {
  display: flex;
  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;
  width: 70%;
  align-self: center;
  -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);
  position: relative;
}

.steps-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%);
  -webkit-backdrop-filter: blur(6px) saturate(160%);
  backdrop-filter: blur(6px) saturate(160%);
  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 3px 8px 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;
}
.steps-pill[data-pos="1"]::before {
  transform: translateX(100%);
}

.steps-pill-opt {
  flex: 1;
  padding: 5px 14px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  cursor: pointer;
  color: var(--muted);
  background: transparent;
  transition: color 0.32s cubic-bezier(0.4, 0, 0.2, 1);
  border-radius: 999px !important;
  text-align: center;
  position: relative;
  z-index: 1;
}

.steps-pill-opt:hover:not(.active) {
  color: var(--accent);
}

.steps-pill-opt.active {
  background: transparent;
  color: #fff;
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
  box-shadow: none;
  text-shadow: 0 1px 0 rgba(40, 0, 60, 0.25);
}

/* ─── MAIN ─── */
.main-content {
  display: flex;
  flex-direction: column;
  background: var(--bg);
  --charts-h: 160px;
  height: calc(100vh - 52px);
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
}
.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 (charts + POI) ─── */
.bottom-panel {
  min-height: 60px;
  border-top: 2px solid var(--border);
  background: var(--bg);
  position: relative;
  flex-shrink: 0;
}

/* ─── CHARTS PANEL ─── */
.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: 13px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.charts-subtitle { font-size: 10px; color: var(--muted); }
.spacer { flex: 1; }

.charts-grid {
  flex: 0 0 auto;
  height: 440px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 220px 220px;
  gap: 0;
  overflow: hidden;
}

.charts-scroll {
}

.chart-card {
  padding: 12px 14px;
  border-right: 1px solid var(--border-light);
  border-bottom: 1px solid var(--border-light);
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
  min-height: 0;
}

.chart-card:nth-child(2),
.chart-card:nth-child(4) { border-right: none; }
.chart-card:nth-child(3),
.chart-card:nth-child(4) { border-bottom: none; }
#chartsGrid .chart-card:nth-child(1),
#chartsGrid .chart-card:nth-child(2) { border-bottom: 1px solid var(--border-light); }
#chartsGrid .chart-card:nth-child(3),
#chartsGrid .chart-card:nth-child(4) { border-bottom: none; }
#chartsGrid .chart-card:nth-child(2),
#chartsGrid .chart-card:nth-child(4),
#chartsGrid .chart-card:nth-child(6) { border-right: none; }

.chart-card-title {
  font-size: 9px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  flex-shrink: 0;
}

.chart-card canvas {
  flex: 1;
  min-height: 0;
}

.stat-row {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
  margin-bottom: 8px;
}

.stat-chip {
  background: transparent;
  border: none;
  padding: 0;
  font-size: 10px;
  flex: 1;
  text-align: center;
}

.stat-chip .val {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  display: block;
}

.stat-chip .lbl { color: var(--muted); font-size: 9px; letter-spacing: 0.05em; }

.stat-chip + .stat-chip {
  border-left: 1px solid rgba(208, 186, 218, 0.45);
}

.empty-charts {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 12px;
}

.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(255,255,255,0.92);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  gap: 14px;
}

.loading-overlay.hidden { display: none; }

.spinner {
  width: 36px;
  height: 36px;
  border: 2px solid var(--border-light);
  border-top-color: var(--border);
  animation: spin 0.7s linear infinite;
  border-radius: 50% !important;
}

@keyframes spin { to { transform: rotate(360deg); } }
.loading-text { font-size: 12px; color: var(--muted); letter-spacing: 0.05em; }

.leaflet-container { background: #f0f0f0 !important; }

/* ─── VIEWPORT DONUT ─── */
.viewport-donut {
  position: fixed;
  top: 68px;
  right: 18px;
  width: 110px;
  height: 110px;
  z-index: 1001;
  padding: 0;
  margin: 0;
  user-select: none;
  pointer-events: none;
  background: rgba(255, 255, 255, 0.72);
  -webkit-backdrop-filter: blur(14px) saturate(140%);
  backdrop-filter: blur(14px) saturate(140%);
  border: 1px solid rgba(83, 0, 108, 0.18);
  border-radius: 50% !important;
  box-shadow:
    0 1px 2px rgba(15, 0, 30, 0.05),
    0 6px 18px rgba(15, 0, 30, 0.10),
    0 18px 38px rgba(15, 0, 30, 0.12),
    inset 0 1px 0 rgba(255, 255, 255, 0.6);
  transition: opacity 0.15s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.viewport-donut--light-text {
  background: rgba(20, 12, 28, 0.42);
  border-color: rgba(255, 255, 255, 0.22);
  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);
}

.viewport-donut-canvas {
  width: 110px !important;
  height: 110px !important;
  display: block;
  background: transparent;
  position: absolute;
  inset: 0;
  filter: none;
}

.viewport-donut-text {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  gap: 0;
}
.viewport-donut-value {
  font-family: 'Inter', sans-serif;
  font-size: 19px;
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  color: #0f0a14;
  transition: color 0.2s ease;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.4);
}
.viewport-donut-label {
  font-family: 'Inter', sans-serif;
  font-size: 8px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: rgba(15, 10, 20, 0.62);
  transition: color 0.2s ease;
  margin-top: 3px;
  text-shadow: none;
}
.viewport-donut--light-text .viewport-donut-value {
  color: #ffffff;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
}
.viewport-donut--light-text .viewport-donut-label {
  color: rgba(255, 255, 255, 0.78);
  text-shadow: none;
}

/* ─── BASEMAP SWITCHER ─── */
.basemap-switcher {
  position: fixed;
  top: 194px;
  right: 18px;
  z-index: 1001;
  transition: opacity 0.15s ease;
}
.viewport-donut.hidden-by-scroll,
.basemap-switcher.hidden-by-scroll {
  opacity: 0;
  pointer-events: none;
  visibility: hidden;
}

.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: 160px;
  z-index: 1002;
  height: 380px;
  overflow-y: scroll;
  overflow-x: hidden;
}
.basemap-dropdown::-webkit-scrollbar { width: 6px; }
.basemap-dropdown::-webkit-scrollbar-thumb { background: var(--border-light); }
.basemap-dropdown::-webkit-scrollbar-track { background: transparent; }

.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-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-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);
}

/* ─── POI LAYERS (basemap dropdown) ─── */
.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;
}

.osm-labels-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 12px 8px;
  cursor: pointer;
  user-select: none;
}
.osm-labels-row input[type=checkbox] {
  width: 13px;
  height: 13px;
  accent-color: var(--accent);
  cursor: pointer;
  margin: 0;
  flex-shrink: 0;
  border-radius: 0 !important;
}
.osm-labels-label {
  font-size: 11px;
  font-weight: 500;
  color: var(--text);
}
.osm-labels-row:hover .osm-labels-label { color: var(--accent); }

.poi-layer-list {
  max-height: 132px;
  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; }

.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);
}

.neighborhood-layer-row .poi-layer-check { border-right: 0; }

.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-row.current-cat .poi-layer-label {
  font-weight: 700;
}

.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 SECTION ─── */
.poi-section {
  border-top: 1px solid var(--border-light);
  margin-top: 0;
  background: var(--bg);
  flex-shrink: 0;
}

.poi-header {
  padding: 10px 16px;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
}

.poi-info-bar {
  display: flex;
  border-bottom: 1px solid var(--border-light);
}

.poi-stat {
  flex: 1;
  padding: 10px 16px;
  border-right: 1px solid var(--border-light);
}
.poi-stat:last-child { border-right: none; }
.poi-stat .val {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1;
}
.poi-stat .lbl {
  font-size: 9px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-top: 3px;
}

.poi-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 220px 220px;
  border-top: none;
}

.poi-alpha-list {
  overflow-y: auto;
  flex: 1;
  min-height: 0;
  font-size: 10px;
}

.poi-alpha-list::-webkit-scrollbar { width: 3px; }
.poi-alpha-list::-webkit-scrollbar-thumb { background: var(--border-light); }

.poi-alpha-item {
  display: flex;
  align-items: baseline;
  gap: 6px;
  padding: 3px 0;
  border-bottom: 1px solid var(--bg2);
  line-height: 1.3;
}

.poi-alpha-item:last-child { border-bottom: none; }

.poi-alpha-name {
  flex: 1;
  color: var(--text);
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.poi-alpha-type {
  color: var(--muted);
  font-size: 9px;
  flex-shrink: 0;
}

.map-tooltip {
  background: #fff !important;
  border: 1px solid #000 !important;
  color: #000 !important;
  font-family: 'Inter', sans-serif !important;
  font-size: 11px !important;
  padding: 10px 14px !important;
  box-shadow: 2px 2px 0 #000 !important;
}
.map-tooltip.popup-noheader {
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
  padding: 0 !important;
}
.popup-noheader .leaflet-popup-content {
  margin: 0 !important;
  width: 260px !important;
}
.popup-noheader .leaflet-popup-content-wrapper {
  padding: 0 !important;
  background: transparent !important;
  box-shadow: none !important;
  border: none !important;
}

.sidebar{
  min-width: 300px;
  flex-shrink: 0;
  box-sizing: border-box;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  height: calc(100vh - 52px);
}

.app-body,
.app-grid,
.app-container,
.layout,
body{
  overflow-x: auto;
}

.cat-grid{
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
  width: 100%;
  box-sizing: border-box;
}

.cat-btn{
  white-space: normal !important;
  word-break: break-word;
  overflow-wrap: anywhere;
  overflow: visible !important;
  text-overflow: clip !important;
  height: auto !important;
  min-height: 36px;
  min-width: 0;
  line-height: 1.15;
  padding: 6px 6px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  box-sizing: border-box;
  border-radius: 4px !important;
  transition:
    background 0.28s cubic-bezier(0.4, 0, 0.2, 1),
    border-color 0.28s cubic-bezier(0.4, 0, 0.2, 1),
    color 0.28s cubic-bezier(0.4, 0, 0.2, 1),
    box-shadow 0.28s cubic-bezier(0.4, 0, 0.2, 1);
}

.cat-btn[data-cat^="shelter_"]{
  white-space: normal !important;
  font-size: 10px;
  letter-spacing: normal;
  padding-left: 6px;
  padding-right: 6px;
}

#map .leaflet-overlay-pane svg path {
  transition:
    fill 0.45s cubic-bezier(0.4, 0, 0.2, 1),
    fill-opacity 0.45s cubic-bezier(0.4, 0, 0.2, 1),
    stroke 0.45s cubic-bezier(0.4, 0, 0.2, 1),
    stroke-opacity 0.45s cubic-bezier(0.4, 0, 0.2, 1);
}

.leaflet-zoom-anim .leaflet-overlay-pane svg path,
.leaflet-drag-target .leaflet-overlay-pane svg path {
  transition: none !important;
}

/* ─── CENSUS / BUILDINGS LAYER BUTTONS ─── */
.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: 13px; height: 13px;
  flex: 0 0 auto;
  border-radius: 3px !important;
  border: 1.5px solid rgba(83, 0, 108, 0.55);
  background: #fff !important;
  position: relative;
  overflow: hidden;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.census-btn.is-active .census-btn-dot {
  background: #6b2a85 !important;
  border-color: #6b2a85;
}
.census-btn.is-active .census-btn-dot::after {
  content: "";
  position: absolute;
  left: 3.5px;
  top: 0.5px;
  width: 3.5px;
  height: 7px;
  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;
}

/* ─── POPUPS ─── */
.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-noheader .leaflet-popup-content-wrapper {
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
  border-radius: 0 !important;
  overflow: visible !important;
}
.popup-noheader .leaflet-popup-close-button {
  display: none !important;
}
.popup-noheader .leaflet-popup-tip-container { display: none !important; }
.popup-noheader .popup-body--noheader {
  padding-top: 16px;
  border: 1px solid var(--border);
  border-radius: 10px !important;
  box-shadow: 0 10px 32px rgba(83, 0, 108, 0.22),
              0 4px 10px rgba(83, 0, 108, 0.12);
}
.popup-noheader .popup-hero .popup-big-label:first-child { opacity: 0.7; }

.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-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;
}
