/* === CSS Variables === */
:root {
  --bg: #EEF2F5;
  --surface: #FFFFFF;
  --surface-alt: #F7F9FB;
  --bg-card: #F7F9FB;
  --border: #D8E0E8;
  --border-light: #E7EDF2;
  --text: #171B2C;
  --text-muted: #4B586C;
  --text-faint: #748096;
  --text-secondary: #4B586C;
  --primary: #086D72;
  --primary-hover: #07585D;
  --primary-soft: #E4F2F1;
  --blue: #315F9F;
  --blue-soft: #E8EEF8;

  /* Group colors */
  --group-a: #315F9F;
  --group-b: #946218;
  --group-c: #086D72;

  /* Shadows */
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.08);
  --shadow-md: 0 10px 24px rgba(23, 27, 44, 0.08);

  /* Spacing */
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 20px;
  --sp-6: 24px;
  --sp-8: 32px;

  /* Radius */
  --radius: 6px;
  --radius-sm: 6px;
  --radius-lg: 8px;
  --radius-pill: 999px;

  /* Transitions */
  --transition: 200ms ease;
  --transition-slow: 300ms ease;

  /* Layout */
  --shell-h: 56px;
  --controls-h: 52px;
  --kpi-h: 58px;
  --footer-h: 32px;
  --info-w: 380px;

  /* Panel / overlay backgrounds */
  --panel-bg: rgba(255, 255, 255, 0.95);
  --panel-bg-solid: #fff;
  --overlay-bg: rgba(0, 0, 0, 0.3);
  --hover-bg: rgba(0, 0, 0, 0.04);
  --active-bg: rgba(0, 0, 0, 0.06);
  --tooltip-bg: rgba(30, 30, 30, 0.9);
  --tooltip-text: #fff;
}

/* === Dark Mode Variables === */
html.dark {
  --bg: #11161B;
  --surface: #181E24;
  --surface-alt: #20272E;
  --bg-card: #20272E;
  --border: #333C45;
  --border-light: #293139;
  --text: #F0F3F5;
  --text-muted: #BBC3CC;
  --text-faint: #8F9AA6;
  --text-secondary: #BBC3CC;
  --primary: #55C1BD;
  --primary-hover: #82D4D0;
  --primary-soft: #183C3D;
  --blue: #8DB7F0;
  --blue-soft: #1D3048;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 2px 8px rgba(0, 0, 0, 0.4);
  --panel-bg: rgba(26, 25, 24, 0.95);
  --panel-bg-solid: #1A1918;
  --overlay-bg: rgba(0, 0, 0, 0.5);
  --hover-bg: rgba(255, 255, 255, 0.06);
  --active-bg: rgba(255, 255, 255, 0.1);
  --tooltip-bg: rgba(40, 38, 36, 0.95);
  --tooltip-text: #D5D4D0;
}

/* === Reset & Base === */
*,
*::before,
*::after {
  box-sizing: border-box;
  letter-spacing: 0;
}

body {
  margin: 0;
  font-family: 'IBM Plex Sans', 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  letter-spacing: 0;
}

.qazgeo-skip {
  position: fixed;
  top: 8px;
  left: 8px;
  z-index: 2100;
  padding: 7px 11px;
  border: 1px solid var(--primary);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  transform: translateY(-160%);
}
.qazgeo-skip:focus { transform: translateY(0); }

.qazgeo-shell {
  position: fixed;
  inset: 0 0 auto 0;
  z-index: 1100;
  height: var(--shell-h);
  display: flex;
  align-items: center;
  gap: 28px;
  padding: 0 16px;
  border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(12px);
}
html.dark .qazgeo-shell { background: rgba(26, 25, 24, 0.96); }
.qazgeo-brand { display: inline-flex; align-items: center; gap: 8px; color: var(--text); text-decoration: none; font-size: 15px; font-weight: 750; }
.qazgeo-brand small { padding: 2px 5px; border-radius: 4px; background: var(--primary-soft); color: var(--primary); font-size: 9px; }
.qazgeo-mark { width: 21px; height: 21px; display: grid; grid-template-columns: 1fr 1fr; gap: 2px; padding: 3px; border: 1px solid color-mix(in srgb, var(--primary) 30%, var(--border)); border-radius: 5px; background: var(--primary-soft); }
.qazgeo-mark i { display: block; border-radius: 1px; background: var(--primary); }
.qazgeo-mark i:nth-child(2), .qazgeo-mark i:nth-child(3) { background: #285a9f; }
.qazgeo-mark i:nth-child(4) { background: #d9a12e; }
.qazgeo-shell nav { display: flex; align-self: stretch; gap: 4px; }
.qazgeo-shell nav a { position: relative; display: inline-flex; align-items: center; padding: 0 10px; color: var(--text-muted); text-decoration: none; font-size: 12px; font-weight: 600; }
.qazgeo-shell nav a:hover, .qazgeo-shell nav a[aria-current="page"] { color: var(--text); }
.qazgeo-shell nav a[aria-current="page"]::after { content: ''; position: absolute; left: 10px; right: 10px; bottom: -1px; height: 2px; background: var(--primary); }
.qazgeo-live { margin-left: auto; display: inline-flex; align-items: center; gap: 7px; color: var(--text-muted); text-decoration: none; font-size: 11px; font-weight: 600; }
.qazgeo-live span { width: 7px; height: 7px; border-radius: 50%; background: #18794e; box-shadow: 0 0 0 3px rgba(24, 121, 78, 0.11); }

.hidden {
  display: none !important;
}

/* === Focus Visible === */
:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}
button:focus:not(:focus-visible),
input:focus:not(:focus-visible),
select:focus:not(:focus-visible) {
  outline: none;
}


/* === Controls Bar === */
#controls-bar {
  position: fixed;
  top: var(--shell-h);
  left: 0;
  right: 0;
  z-index: 1000;
  height: var(--controls-h);
  display: flex;
  align-items: center;
  gap: var(--sp-4);
  padding: 0 var(--sp-4);
  background: var(--panel-bg);
  border-bottom: 1px solid var(--border-light);
  box-shadow: var(--shadow-sm);
  backdrop-filter: blur(8px);
}

.controls-left,
.controls-center,
.controls-right {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
}

.controls-center {
  margin-left: auto;
}

.controls-right {
  margin-left: auto;
}

.control-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.toolbar-menu .btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  font-weight: 600;
}

.btn,
button.btn,
.btn-sm,
.btn-outline-secondary {
  min-height: 32px;
  border-radius: var(--radius) !important;
  border-color: var(--border) !important;
  background: var(--surface) !important;
  color: var(--text-muted) !important;
  box-shadow: none !important;
}
.btn:hover,
.btn:focus,
.btn-outline-secondary:hover,
.btn-outline-secondary:focus {
  border-color: var(--primary) !important;
  background: var(--primary-soft) !important;
  color: var(--primary-hover) !important;
}
.btn.active,
.btn-check:checked + .btn,
.btn-outline-secondary.active {
  border-color: var(--primary) !important;
  background: var(--primary) !important;
  color: #fff !important;
}

.ui-icon,
.layer-symbol,
.mobile-more-icon,
.mobile-nav-icon {
  position: relative;
  display: inline-grid;
  place-items: center;
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
  border: 1px solid color-mix(in srgb, var(--primary) 24%, var(--border));
  border-radius: 5px;
  background: var(--primary-soft);
  color: var(--primary);
  font-size: 0;
}
.mobile-nav-icon {
  width: 20px;
  height: 20px;
  margin-bottom: 2px;
}
.layer-symbol {
  width: 16px;
  height: 16px;
}
.ui-icon::before,
.layer-symbol::before,
.mobile-more-icon::before,
.mobile-nav-icon::before { content: ''; display: block; }
.ui-icon-compare::before { width: 10px; height: 10px; border-left: 2px solid currentColor; border-right: 2px solid currentColor; }
.ui-icon-export::before { width: 9px; height: 9px; border: 2px solid currentColor; border-top: 0; transform: translateY(2px); }
.ui-icon-more::before { width: 3px; height: 3px; border-radius: 50%; background: currentColor; box-shadow: -5px 0 0 currentColor, 5px 0 0 currentColor; }
.ui-icon-transport::before { width: 12px; height: 7px; border: 2px solid currentColor; border-left-width: 4px; border-radius: 2px; }
.ui-icon-poi::before { width: 9px; height: 9px; border: 2px solid currentColor; border-radius: 50% 50% 50% 0; transform: rotate(-45deg); }
.ui-icon-map::before { width: 11px; height: 11px; border: 2px solid currentColor; border-radius: 2px; box-shadow: inset 4px 0 0 color-mix(in srgb, currentColor 35%, transparent); }
.ui-icon-data::before { width: 12px; height: 10px; background: linear-gradient(90deg, currentColor 0 2px, transparent 2px 4px, currentColor 4px 6px, transparent 6px 8px, currentColor 8px 10px); }
.ui-icon-search::before { width: 9px; height: 9px; border: 2px solid currentColor; border-radius: 50%; box-shadow: 5px 5px 0 -3px currentColor; }
.ui-icon-menu::before { width: 12px; height: 2px; background: currentColor; box-shadow: 0 -4px 0 currentColor, 0 4px 0 currentColor; }
.ui-icon-layers::before { width: 11px; height: 8px; border: 2px solid currentColor; border-radius: 2px; transform: skewY(-12deg); }
.ui-icon-theme::before { width: 10px; height: 10px; border-radius: 50%; background: linear-gradient(90deg, currentColor 50%, transparent 50%); border: 1px solid currentColor; }
.ui-icon-air::before { width: 12px; height: 8px; border-top: 2px solid currentColor; border-bottom: 2px solid currentColor; }
.ui-icon-road::before { width: 12px; height: 12px; border-left: 3px solid currentColor; border-right: 3px solid currentColor; transform: perspective(12px) rotateX(35deg); }
.ui-icon-rail::before { width: 12px; height: 12px; border-left: 2px solid currentColor; border-right: 2px solid currentColor; box-shadow: inset 0 4px 0 -2px currentColor, inset 0 -4px 0 -2px currentColor; }
.ui-icon-station::before { width: 11px; height: 11px; border: 2px solid currentColor; border-radius: 2px; box-shadow: inset 0 -3px 0 currentColor; }
.ui-icon-project::before { width: 11px; height: 11px; border: 2px dashed currentColor; border-radius: 3px; }
.ui-icon-school::before { width: 12px; height: 9px; border: 2px solid currentColor; border-top-width: 4px; border-radius: 2px; }
.ui-icon-hospital::before { width: 12px; height: 12px; background: linear-gradient(currentColor 0 0) center/2px 9px no-repeat, linear-gradient(currentColor 0 0) center/9px 2px no-repeat; }
.ui-icon-settlement::before { width: 12px; height: 9px; border: 2px solid currentColor; border-top: 0; transform: translateY(2px); }

#group-filter-summary {
  margin-left: 3px;
  color: var(--text-faint);
  font-variant-numeric: tabular-nums;
}

.toolbar-menu .dropdown-menu {
  min-width: 210px;
  padding: 6px;
  border-color: var(--border);
  background: var(--surface);
  box-shadow: var(--shadow-md);
}

.toolbar-menu .dropdown-item {
  display: flex;
  align-items: center;
  width: 100%;
  min-height: 34px;
  padding: 7px 9px;
  border: 0;
  border-radius: calc(var(--radius) - 2px);
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 12px;
  text-align: left;
  cursor: pointer;
}

.toolbar-menu .dropdown-item:hover,
.toolbar-menu .dropdown-item:focus {
  background: var(--hover-bg);
  color: var(--text);
}

.toolbar-menu__label {
  padding: 5px 9px 6px;
  color: var(--text-faint);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

/* Custom select */
.select-wrapper {
  position: relative;
}

.select-wrapper select {
  appearance: none;
  -webkit-appearance: none;
  font-family: inherit;
  font-size: 13px;
  padding: var(--sp-1) var(--sp-6) var(--sp-1) var(--sp-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  transition: border-color var(--transition);
  outline: none;
}

.select-wrapper select:hover {
  border-color: var(--primary);
}

.select-wrapper select:focus {
  border-color: var(--primary);
}

.select-wrapper::after {
  content: '\25BE';
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  pointer-events: none;
  color: var(--text-muted);
  font-size: 11px;
}

/* Group filter checkboxes */
.group-filter {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  min-height: 34px;
  padding: var(--sp-1) var(--sp-2);
  border-radius: var(--radius);
  transition: background var(--transition);
  user-select: none;
}

.group-filter:hover {
  background: var(--hover-bg);
}

.group-filter input[type="checkbox"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.filter-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
  transition: opacity var(--transition);
}

.group-filter input[type="checkbox"]:not(:checked) ~ .filter-dot,
.group-filter:has(input:not(:checked)) .filter-dot {
  opacity: 0.3;
}

#toggle-tiles.tiles-hidden {
  opacity: 0.5;
}

/* === KPI Summary Strip === */
#kpi-strip {
  position: fixed;
  top: calc(var(--shell-h) + var(--controls-h));
  left: 0;
  right: 0;
  z-index: 999;
  height: var(--kpi-h);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  padding: 0 var(--sp-4);
  background: linear-gradient(180deg, var(--panel-bg), color-mix(in srgb, var(--surface-alt) 70%, transparent));
  border-bottom: 1px solid var(--border-light);
  backdrop-filter: blur(6px);
}

.kpi-card {
  min-width: 132px;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: var(--sp-1) var(--sp-4);
}

.kpi-label {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  line-height: 1.2;
}

.kpi-value {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  font-variant-numeric: tabular-nums lining-nums;
  line-height: 1.3;
}

.kpi-divider {
  width: 1px;
  height: 28px;
  background: var(--border-light);
  flex-shrink: 0;
}

/* === Main Layout === */
#main-content {
  position: fixed;
  top: calc(var(--shell-h) + var(--controls-h) + var(--kpi-h));
  left: 0;
  right: 0;
  bottom: var(--footer-h);
  display: flex;
}

#map {
  flex: 1;
  min-width: 0;
}

/* Subdued tile layer */
.leaflet-tile-pane {
  filter: saturate(0.42) brightness(1.06);
}

/* Style Leaflet zoom controls */
.leaflet-control-zoom {
  border: 1px solid var(--border) !important;
  border-radius: var(--radius) !important;
  box-shadow: var(--shadow-sm) !important;
  overflow: hidden;
}

.leaflet-control-zoom a {
  background: var(--panel-bg) !important;
  color: var(--text-muted) !important;
  border-bottom: 1px solid var(--border-light) !important;
  width: 30px !important;
  height: 30px !important;
  line-height: 30px !important;
  font-size: 16px !important;
  transition: all var(--transition);
}

.leaflet-control-zoom a:hover {
  background: var(--surface) !important;
  color: var(--text) !important;
}

.leaflet-control-zoom a:last-child {
  border-bottom: none !important;
}

/* Attribution */
.leaflet-control-attribution {
  font-size: 10px !important;
  background: var(--panel-bg) !important;
  padding: 2px 6px !important;
  color: var(--text-faint) !important;
}

.leaflet-control-attribution a {
  color: var(--text-muted) !important;
}

/* === Info Panel === */
#info {
  width: var(--info-w);
  flex-shrink: 0;
  background: var(--surface);
  border-left: 1px solid var(--border-light);
  box-shadow: -8px 0 22px rgba(23, 27, 44, 0.05);
  overflow-y: auto;
  padding: 16px;
  position: relative;
}

.info-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  margin: 0 0 var(--sp-1) 0;
}

.info-hint {
  font-size: 13px;
  color: var(--text-faint);
  margin: 0 0 var(--sp-5) 0;
}

#info-default {
  margin-top: 10px;
  padding: 12px;
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  background: var(--surface-alt);
}
#info-default .info-title {
  margin-bottom: 3px;
}
#info-default .info-hint {
  margin-bottom: 10px;
}

/* Summary stats cards */
.summary-card {
  background: var(--surface-alt);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  padding: 10px 12px;
  margin-bottom: var(--sp-2);
}

.summary-card-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 2px;
}

.summary-card-value {
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
  font-variant-numeric: tabular-nums lining-nums;
}

.summary-card-value .summary-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 4px;
  vertical-align: middle;
}

/* Detail view */
#info-close {
  position: absolute;
  top: var(--sp-3);
  right: var(--sp-3);
  border: none;
  background: none;
  font-size: 22px;
  color: var(--text-faint);
  cursor: pointer;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius);
  transition: all var(--transition);
  padding: 0;
  line-height: 1;
}

#info-close:hover {
  background: var(--hover-bg);
  color: var(--text);
}

.detail-oblast {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  margin: 0 0 2px 0;
  padding-right: 28px;
}

.detail-district {
  font-size: 13px;
  color: var(--text-muted);
  margin: 0 0 var(--sp-3) 0;
}

.group-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: var(--sp-1) var(--sp-3);
  border-radius: var(--radius-pill);
  font-size: 12px;
  font-weight: 600;
  color: #fff;
  margin-bottom: var(--sp-4);
}

/* Metric rows */
.metric-row {
  display: flex;
  align-items: center;
  padding: 7px 0;
  border-bottom: 1px solid var(--border-light);
}

.metric-row:last-child {
  border-bottom: none;
}

.metric-icon {
  width: 18px;
  flex-shrink: 0;
  font-size: 14px;
  text-align: center;
  color: var(--text-faint);
}

.metric-body {
  flex: 1;
  margin-left: var(--sp-2);
}

.metric-label {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.metric-value {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  font-variant-numeric: tabular-nums lining-nums;
}

.metric-value-sm {
  font-size: 14px;
  font-weight: 500;
}

/* Progress bar with national average marker */
.progress-bar {
  height: 6px;
  background: var(--border-light);
  border-radius: 3px;
  margin-top: 4px;
  overflow: visible;
  position: relative;
}

.progress-fill {
  height: 100%;
  border-radius: 3px;
  transition: width var(--transition-slow);
}

.progress-fill--urban {
  background: var(--primary);
}

.progress-fill--poverty {
  background: #9A4E42;
}

.progress-fill--grp {
  background: #1A8A7D;
}

.progress-fill--income {
  background: #2E86AB;
}

.progress-fill--unemployment {
  background: var(--group-b);
}

.avg-marker {
  position: absolute;
  top: -3px;
  width: 2px;
  height: 12px;
  background: var(--text);
  border-radius: 1px;
  transform: translateX(-1px);
}

.avg-marker-label {
  position: absolute;
  top: -16px;
  font-size: 9px;
  font-weight: 600;
  color: var(--text-muted);
  white-space: nowrap;
  transform: translateX(-50%);
}

/* Population rank bar */
.rank-bar-container {
  margin-top: 4px;
}

.rank-bar-track {
  height: 6px;
  background: var(--border-light);
  border-radius: 3px;
  position: relative;
  overflow: hidden;
}

.rank-bar-fill {
  height: 100%;
  border-radius: 3px;
  background: var(--primary);
  transition: width var(--transition-slow);
}

.rank-bar-label {
  font-size: 10px;
  color: var(--text-muted);
  margin-top: 2px;
}

.metric-section-title {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-faint);
  margin-top: var(--sp-3);
  margin-bottom: var(--sp-1);
  padding-top: var(--sp-2);
  border-top: 1px solid var(--border-light);
}

.metric-source {
  font-size: 10px;
  color: var(--text-faint);
  margin-top: var(--sp-3);
  padding-top: var(--sp-2);
  border-top: 1px solid var(--border-light);
  font-style: italic;
}

.editorial-signal {
  margin-top: var(--sp-2);
  padding: var(--sp-2) var(--sp-3);
  border: 1px solid color-mix(in srgb, var(--primary) 24%, var(--border));
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--primary) 6%, var(--surface));
}
.editorial-signal span {
  display: block;
  color: var(--text-faint);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.editorial-signal p {
  margin: 3px 0 0;
  color: var(--text);
  font-size: 12px;
  line-height: 1.45;
}
.group-context {
  margin: var(--sp-2) 0 0;
  color: var(--text-muted);
  font-size: 11px;
  line-height: 1.4;
}
.source-notes {
  margin-top: var(--sp-3);
  padding-top: var(--sp-2);
  border-top: 1px solid var(--border-light);
  color: var(--text-muted);
  font-size: 10px;
  line-height: 1.45;
}
.source-notes summary {
  color: var(--text-secondary);
  cursor: pointer;
  font-weight: 600;
}
.source-notes p { margin: var(--sp-1) 0 0; }

.sparkline-container {
  margin: var(--sp-2) 0;
  min-height: 40px;
}
.sparkline-loading, .sparkline-empty {
  font-size: 11px;
  color: var(--text-faint);
  font-style: italic;
}
.sparkline-chart {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: var(--sp-2);
  border: 1px solid var(--border-light);
}
.sparkline-title {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 4px;
}
.sparkline-year {
  font-size: 10px;
  fill: var(--text-faint);
}

.history-toolbar {
  display: grid;
  gap: 6px;
  padding: 12px 12px 8px;
}

.history-toolbar label,
.history-latest span {
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 650;
}

.history-toolbar select {
  width: 100%;
  min-height: 34px;
  padding: 6px 9px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 12px;
}

#history-chart { padding: 0 12px 12px; }
.history-latest { display: grid; grid-template-columns: 1fr 1fr; gap: 1px; margin: 4px 0 10px; border: 1px solid var(--border); background: var(--border); }
.history-latest > div { min-width: 0; padding: 9px 10px; background: var(--surface); }
.history-latest span, .history-latest strong, .history-latest small { display: block; }
.history-latest strong { margin-top: 3px; overflow-wrap: anywhere; font-size: 14px; line-height: 1.25; }
.history-latest small { margin-top: 2px; color: var(--text-faint); font-size: 10px; }
.history-description { margin: 7px 0; color: var(--text-muted); font-size: 11px; line-height: 1.45; }
.history-source { color: var(--primary); font-size: 11px; font-weight: 650; }

/* Inline spark bars for economic section */
.spark-inline {
  display: inline-flex;
  align-items: flex-end;
  gap: 2px;
  height: 20px;
  vertical-align: middle;
  margin-left: 4px;
}
.spark-bar {
  display: inline-block;
  width: 6px;
  min-height: 2px;
  border-radius: 1px;
}
.spark-bar-red { background: #EF4444; }
.spark-bar-teal { background: #14B8A6; }
.delta-up { color: #DC2626; font-size: 0.85em; margin-left: 2px; }
.delta-down { color: #059669; font-size: 0.85em; margin-left: 2px; }
.delta-zero { color: var(--text-muted); font-size: 0.85em; margin-left: 2px; }

.info-divider {
  height: 1px;
  background: var(--border-light);
  margin: var(--sp-4) 0;
}

.detail-name-row {
  margin-bottom: var(--sp-2);
}

.detail-name-label {
  font-size: 11px;
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.detail-name-value {
  font-size: 13px;
  color: var(--text-muted);
}

/* === Info Panel Tabs === */

.info-tabs-bar {
  display: flex;
  align-items: stretch;
  gap: var(--sp-1);
  border-bottom: 2px solid var(--border-light);
}

#info-tabs { min-width: 0; }

.nav-tabs-sm {
  gap: 0;
  flex-wrap: nowrap;
  border-bottom: 0;
}
.nav-tabs-sm .nav-link {
  font-size: 11px;
  font-weight: 600;
  padding: 6px 7px;
  color: var(--text-faint);
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  background: none;
  cursor: pointer;
  white-space: nowrap;
  transition: color 0.15s, border-color 0.15s;
}
.nav-tabs-sm .nav-link:hover {
  color: var(--text-secondary);
}
.nav-tabs-sm .nav-link.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}
.info-tabs-more {
  position: relative;
  flex-shrink: 0;
}
.info-tabs-more__toggle {
  height: 100%;
  padding: 6px 7px;
  border: 0;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  background: transparent;
  color: var(--text-muted);
  font: inherit;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
}
.info-tabs-more__toggle::after { content: ' ▾'; color: var(--text-faint); }
.info-tabs-more__toggle:hover,
.info-tabs-more__toggle:focus { color: var(--text); }
.info-tabs-more__menu {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  z-index: 20;
  min-width: 148px;
  padding: var(--sp-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-md);
}
.info-tab-menu-item {
  display: block;
  width: 100%;
  min-height: 32px;
  padding: 6px 8px;
  border: 0;
  border-radius: calc(var(--radius) - 2px);
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 11px;
  text-align: left;
  cursor: pointer;
}
.info-tab-menu-item:hover,
.info-tab-menu-item:focus,
.info-tab-menu-item.active { background: var(--hover-bg); color: var(--primary); }
.info-tab-pane {
  padding-top: var(--sp-2);
}

/* === Strata Tab === */
.strata-total {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: var(--sp-2);
  padding: var(--sp-2);
  background: var(--bg-card);
  border-radius: var(--radius);
  border: 1px solid var(--border-light);
}
.strata-section-title {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-faint);
  margin-top: var(--sp-3);
  margin-bottom: var(--sp-1);
}
.strata-bars {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.strata-bar-row {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
}
.strata-bar-label {
  width: 28px;
  flex-shrink: 0;
  font-weight: 600;
  color: var(--text-secondary);
  text-align: right;
}
.strata-bar-track {
  flex: 1;
  height: 14px;
  background: var(--border-light);
  border-radius: 3px;
  overflow: hidden;
}
.strata-bar-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.3s ease;
}
.strata-bar-value {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
  min-width: 80px;
}
.strata-bar-value small {
  color: var(--text-faint);
}

/* Matrix heatmap */
.strata-matrix {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-top: var(--sp-1);
}
.strata-matrix-row {
  display: flex;
  gap: 2px;
}
.strata-matrix-cell {
  width: 36px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  border-radius: 3px;
}
.strata-matrix-corner {
  background: none;
}
.strata-matrix-col-header,
.strata-matrix-row-header {
  font-weight: 600;
  color: var(--text-faint);
  font-size: 10px;
  background: none;
}
.strata-matrix-data {
  border-radius: 3px;
  cursor: default;
}

/* Top strata list */
.strata-top-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.strata-top-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  padding: 4px 6px;
  background: var(--bg-card);
  border-radius: var(--radius);
  border: 1px solid var(--border-light);
}
.strata-top-rank {
  font-weight: 700;
  color: var(--primary);
  width: 18px;
  text-align: center;
}
.strata-top-code {
  font-weight: 600;
  color: var(--text-secondary);
  font-family: 'IBM Plex Mono', ui-monospace, monospace;
}
.strata-top-pop {
  margin-left: auto;
  color: var(--text-muted);
}
.strata-top-ei {
  font-size: 11px;
  color: var(--text-faint);
}

/* === Roads Tab === */
.roads-list {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
}
.road-card {
  padding: var(--sp-2);
  background: var(--bg-card);
  border-radius: var(--radius);
  border: 1px solid var(--border-light);
}
.road-card-header {
  font-size: 13px;
  color: var(--text-primary);
  margin-bottom: 4px;
}
.road-ref {
  font-size: 11px;
  color: var(--text-faint);
}
.road-card-status {
  margin-bottom: 4px;
}
.road-status-badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  color: #fff;
  padding: 2px 8px;
  border-radius: 10px;
}
.road-card-details {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 12px;
  color: var(--text-muted);
}
.road-detail {
  white-space: nowrap;
}
.road-card-desc {
  font-size: 11px;
  color: var(--text-faint);
  margin-top: 4px;
  line-height: 1.4;
}

/* === Legend === */
#legend {
  position: fixed;
  bottom: calc(var(--footer-h) + var(--sp-3));
  right: calc(var(--info-w) + var(--sp-3));
  z-index: 800;
  background: var(--panel-bg-solid);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  backdrop-filter: blur(6px);
  transition: all var(--transition);
}

#legend-toggle {
  padding: 7px;
  cursor: pointer;
  font-size: 16px;
  color: var(--text-muted);
  text-align: center;
  user-select: none;
}

#legend-toggle:hover {
  color: var(--text);
}

#legend-content {
  padding: 0 var(--sp-3) var(--sp-3);
}

.legend-collapsed #legend-content {
  display: none;
}

.legend-title {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: var(--sp-2);
}

.legend-item {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  font-size: 12px;
  color: var(--text);
  padding: 2px 0;
}

.legend-swatch {
  width: 14px;
  height: 14px;
  border-radius: 3px;
  flex-shrink: 0;
}

/* Heatmap gradient bar */
.legend-gradient {
  height: 10px;
  border-radius: 3px;
  margin-bottom: 4px;
  width: 150px;
}

.legend-gradient-labels {
  display: flex;
  justify-content: space-between;
  font-size: 10px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums lining-nums;
}

.legend-gradient-labels span {
  min-width: 0;
}

/* === Hover Tooltip === */
#map-tooltip {
  position: fixed;
  z-index: 1100;
  pointer-events: none;
  background: var(--tooltip-bg);
  color: var(--tooltip-text);
  border-radius: 6px;
  padding: 8px 12px;
  font-size: 13px;
  line-height: 1.4;
  max-width: 220px;
  opacity: 0;
  transition: opacity 150ms ease;
  box-shadow: var(--shadow-md);
  font-family: 'IBM Plex Sans', 'Inter', sans-serif;
}

#map-tooltip.visible {
  opacity: 1;
}

.tooltip-name {
  font-weight: 600;
  font-size: 13px;
  margin-bottom: 2px;
}

.tooltip-oblast {
  font-weight: 400;
  font-size: 11px;
  opacity: 0.75;
  margin-top: 1px;
}

.tooltip-badge {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 600;
  color: #fff;
  margin-bottom: 4px;
}

.tooltip-metric {
  font-size: 12px;
  color: var(--tooltip-text);
}

.tooltip-metric strong {
  color: #fff;
  font-weight: 600;
}

/* === Ranking Panel === */
#ranking-panel {
  position: fixed;
  bottom: var(--footer-h);
  left: 0;
  right: var(--info-w);
  z-index: 850;
  background: var(--panel-bg-solid);
  border-top: 1px solid var(--border);
  box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.06);
  backdrop-filter: blur(6px);
  transition: max-height var(--transition-slow);
}

#ranking-toggle {
  padding: var(--sp-2) var(--sp-4);
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  user-select: none;
  text-align: center;
  transition: color var(--transition);
}

#ranking-toggle:hover {
  color: var(--text);
}

#ranking-content {
  max-height: 250px;
  overflow-y: auto;
  padding: 0 var(--sp-4) var(--sp-3);
}

.ranking-collapsed #ranking-content {
  display: none;
}

.rank-row {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: 3px 0;
  cursor: pointer;
  border-radius: var(--radius);
  transition: background var(--transition);
}

.rank-row:hover {
  background: var(--hover-bg);
}

.rank-row.rank-row--active {
  background: var(--active-bg);
}

.rank-position {
  width: 22px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-faint);
  text-align: right;
  flex-shrink: 0;
}

.rank-name {
  width: 130px;
  font-size: 12px;
  color: var(--text);
  flex-shrink: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.rank-bar-outer {
  flex: 1;
  height: 16px;
  background: var(--border-light);
  border-radius: 3px;
  overflow: hidden;
  position: relative;
}

.rank-bar-inner {
  height: 100%;
  border-radius: 3px;
  transition: width var(--transition-slow);
  min-width: 2px;
}

.rank-value {
  width: 60px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-align: right;
  flex-shrink: 0;
  font-variant-numeric: tabular-nums lining-nums;
}

/* === Colorblind Group Markers === */
.group-marker {
  pointer-events: none;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--panel-bg);
  border: 2px solid currentColor;
  font-family: 'IBM Plex Sans', 'Inter', sans-serif;
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
  opacity: 0;
  transition: opacity var(--transition);
}

.group-marker.visible {
  opacity: 1;
}

/* === Region Labels on Map === */
.region-label {
  pointer-events: none;
  white-space: normal;
  line-height: 1.25;
  background: none;
  border: none;
  text-align: center;
  font-family: 'IBM Plex Sans', 'Inter', sans-serif;
  font-size: 11px;
  font-weight: 600;
  color: var(--text);
  text-shadow:
    0 0 4px rgba(255, 255, 255, 0.9),
    0 0 8px rgba(255, 255, 255, 0.7),
    1px 1px 2px rgba(255, 255, 255, 0.8);
  padding: 2px 4px;
  opacity: 0;
  transition: opacity var(--transition);
}

.region-label.visible {
  opacity: 1;
}

/* === Footer === */
footer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--footer-h);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  background: var(--bg);
  border-top: 1px solid var(--border-light);
  font-size: 11px;
  color: var(--text-faint);
  z-index: 900;
}

/* === Air Quality Badges === */
.aq-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  font-size: 12px;
  font-weight: 600;
  color: #fff;
}

.aq-1 { background: #1A8A7D; }
.aq-2 { background: #4A9A6B; }
.aq-3 { background: #B0B040; }
.aq-4 { background: #C07840; }
.aq-5 { background: #823A3A; }

/* === Transport Layer Controls === */
#transport-panel {
  position: fixed;
  top: calc(var(--shell-h) + var(--controls-h) + var(--kpi-h) + var(--sp-3));
  left: var(--sp-3);
  z-index: 800;
  background: var(--panel-bg-solid);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  backdrop-filter: blur(6px);
  min-width: 174px;
}

#transport-toggle {
  padding: 8px 10px;
  cursor: pointer;
  font-size: 12px;
  color: var(--text-muted);
  user-select: none;
  display: flex;
  align-items: center;
  gap: var(--sp-1);
}

#transport-toggle:hover {
  color: var(--text);
}

.transport-chevron {
  margin-left: auto;
  font-size: 10px;
  transition: transform var(--transition);
}

#transport-body {
  padding: var(--sp-1) var(--sp-2) var(--sp-2);
}

#transport-body.transport-collapsed {
  display: none;
}

.transport-check {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 4px 0;
}

.transport-check input[type="checkbox"] {
  margin: 0;
  cursor: pointer;
  accent-color: var(--primary);
}

.transport-check label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text);
  cursor: pointer;
  white-space: nowrap;
  user-select: none;
}

.transport-loading {
  font-size: 11px;
  color: var(--text-faint);
  font-style: italic;
  padding: 2px 0;
}

/* === POI Layer Panel === */
#poi-panel {
  position: fixed;
  top: calc(var(--shell-h) + var(--controls-h) + var(--kpi-h) + var(--sp-3) + 180px);
  left: var(--sp-3);
  z-index: 800;
  background: var(--panel-bg-solid);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  backdrop-filter: blur(6px);
  min-width: 190px;
}

#poi-toggle {
  padding: 8px 10px;
  cursor: pointer;
  font-size: 12px;
  color: var(--text-muted);
  user-select: none;
  display: flex;
  align-items: center;
  gap: var(--sp-1);
}

#poi-toggle:hover {
  color: var(--text);
}

.poi-chevron {
  margin-left: auto;
  font-size: 10px;
  transition: transform var(--transition);
}

#poi-body {
  padding: var(--sp-1) var(--sp-2) var(--sp-2);
}

#poi-body.poi-collapsed {
  display: none;
}

.poi-badge {
  font-size: 10px;
  color: var(--text-faint);
  margin-left: 2px;
}

/* === Region Transitions (SVG paths) === */
.leaflet-interactive {
  transition: fill-opacity 200ms ease, stroke-width 150ms ease;
}

/* === Sheet Handle (hidden on desktop) === */
.sheet-handle {
  display: none;
}

/* === Mobile Nav (hidden on desktop) === */
.mobile-nav {
  display: none;
}

/* === Tablet Layout (768px - 991px) === */
@media (min-width: 768px) and (max-width: 991.98px) {
  :root {
    --info-w: 280px;
  }

  #controls-bar {
    gap: var(--sp-2);
    padding: 0 var(--sp-2);
  }

  .control-label {
    font-size: 11px;
  }

  .select-wrapper select {
    font-size: 12px;
    padding: var(--sp-1) var(--sp-5) var(--sp-1) var(--sp-2);
  }

  #btn-compare {
    font-size: 11px;
    padding: 3px 8px;
  }

  .kpi-card {
    padding: var(--sp-1) var(--sp-3);
  }

  .kpi-value {
    font-size: 17px;
  }

  .kpi-label {
    font-size: 9px;
  }

  #compare-panel {
    width: 500px;
    max-width: 55vw;
  }
}

/* === Mobile Layout (< 768px) === */
@media (max-width: 767.98px) {
  :root { --shell-h: 48px; }
  .qazgeo-shell { height: var(--shell-h); padding: 0 10px; }
  .qazgeo-shell nav, .qazgeo-live, .qazgeo-brand small { display: none; }

  /* -- Mobile Nav Bar -- */
  .mobile-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 56px;
    background: var(--surface);
    display: flex;
    border-top: 1px solid var(--border);
    z-index: 1001;
    padding-bottom: env(safe-area-inset-bottom, 0);
  }

  .mobile-nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    color: var(--text-muted);
    cursor: pointer;
    border: none;
    background: none;
    padding: var(--sp-1) 0;
    min-height: 44px;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
  }

  .mobile-nav-item.active {
    color: var(--primary);
  }

  .mobile-nav-icon {
    font-size: 20px;
    line-height: 1;
    margin-bottom: 2px;
  }

  .mobile-nav-item small {
    font-size: 10px;
    line-height: 1.2;
  }

  /* -- Hide desktop controls, KPI strip, footer on mobile -- */
  #controls-bar {
    display: none !important;
  }

  #kpi-strip {
    display: none !important;
  }

  footer {
    display: none !important;
  }

  /* -- Main layout: full-screen map -- */
  #main-content {
    position: fixed;
    top: var(--shell-h);
    left: 0;
    right: 0;
    bottom: 56px;
    display: block;
  }

  #map {
    width: 100% !important;
    height: 100% !important;
  }

  /* -- Remove zoom controls on mobile (use gestures) -- */
  .leaflet-control-zoom {
    display: none !important;
  }

  /* -- Sidebar → Bottom Sheet -- */
  #info {
    position: fixed;
    bottom: 56px;
    left: 0;
    right: 0;
    width: 100%;
    max-height: 70vh;
    border-left: none;
    border-radius: 16px 16px 0 0;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.15);
    z-index: 1000;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    transform: translateY(calc(100% - 60px));
    transition: transform 0.3s ease;
    background: var(--surface);
    padding-top: 0;
  }

  #info.sheet-half {
    transform: translateY(50%);
  }

  #info.sheet-full {
    transform: translateY(0);
  }

  /* -- Sheet Handle -- */
  .sheet-handle {
    display: block;
    width: 40px;
    height: 4px;
    background: var(--border);
    border-radius: 2px;
    margin: 8px auto;
    flex-shrink: 0;
  }

  /* -- KPI strip inside bottom sheet for collapsed state -- */
  .mobile-kpi-strip {
    display: flex;
    align-items: center;
    justify-content: space-around;
    padding: 0 var(--sp-2) var(--sp-2);
    gap: var(--sp-1);
  }

  .mobile-kpi-strip .kpi-card {
    padding: 2px var(--sp-1);
  }

  .mobile-kpi-strip .kpi-label {
    font-size: 8px;
  }

  .mobile-kpi-strip .kpi-value {
    font-size: 14px;
  }

  /* -- Hide ranking panel on mobile -- */
  #ranking-panel {
    display: none !important;
  }

  /* -- Legend repositioned above bottom nav -- */
  #legend {
    right: var(--sp-3);
    bottom: calc(56px + 68px);
    left: auto;
    max-width: 180px;
  }

  /* -- Transport panel repositioned -- */
  #transport-panel {
    top: var(--sp-3);
    left: var(--sp-3);
  }

  /* -- POI panel hidden on mobile (too crowded) -- */
  #poi-panel {
    display: none;
  }

  /* -- Comparison panel on mobile -- */
  #compare-panel {
    position: fixed;
    bottom: 56px;
    left: 0;
    right: 0;
    top: auto;
    width: 100%;
    max-width: 100%;
    max-height: 60vh;
    border-radius: 16px 16px 0 0;
    z-index: 1050;
    animation: none;
  }

  #compare-body {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .compare-table {
    min-width: 500px;
  }

  /* -- Compare hint repositioned -- */
  #compare-hint {
    top: var(--sp-3);
    font-size: 12px;
    padding: 6px 14px;
  }

  /* -- Tooltip hidden on mobile (use tap popups) -- */
  #map-tooltip {
    display: none !important;
  }

  /* -- Touch-optimized: larger tap targets -- */
  .search-input {
    font-size: 16px;
    padding: 10px 0;
    min-height: 44px;
  }

  .search-item {
    padding: 10px;
    min-height: 44px;
  }

  .filter-header {
    padding: 10px var(--sp-2);
    min-height: 44px;
  }

  .filter-select {
    padding: 8px 6px;
    font-size: 14px;
    min-height: 44px;
  }

  .filter-num {
    padding: 8px 6px;
    font-size: 14px;
    min-height: 44px;
  }

  #info-close {
    width: 44px;
    height: 44px;
    font-size: 24px;
  }

  /* -- Transport: full-width toggle switches on mobile -- */
  .transport-check {
    padding: 8px 0;
    min-height: 44px;
  }

  .transport-check input[type="checkbox"] {
    width: 20px;
    height: 20px;
  }

  .transport-check label {
    font-size: 14px;
  }

  /* -- "Ещё" (more) panel for transport/filters on mobile -- */
  .mobile-more-panel {
    position: fixed;
    bottom: 56px;
    left: 0;
    right: 0;
    max-height: 60vh;
    background: var(--panel-bg-solid);
    border-radius: 16px 16px 0 0;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.15);
    z-index: 1002;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: var(--sp-4);
    transform: translateY(100%);
    transition: transform 0.3s ease;
  }

  .mobile-more-panel.open {
    transform: translateY(0);
  }

  .mobile-more-item {
    display: flex;
    align-items: center;
    gap: var(--sp-3);
    padding: var(--sp-3) var(--sp-2);
    border-bottom: 1px solid var(--border-light);
    cursor: pointer;
    min-height: 48px;
    font-size: 14px;
    color: var(--text);
    -webkit-tap-highlight-color: transparent;
  }

  .mobile-more-item:last-child {
    border-bottom: none;
  }

  .mobile-more-item.is-selected {
    background: var(--active-bg);
    color: var(--primary);
    font-weight: 700;
  }

  .mobile-more-heading {
    padding: 8px var(--sp-2) 5px;
    color: var(--text-faint);
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
  }

  .mobile-group-state {
    margin-left: auto;
    color: var(--text-muted);
    font-size: 12px;
    font-weight: 500;
  }

  .mobile-more-icon {
    font-size: 20px;
    width: 28px;
    text-align: center;
    flex-shrink: 0;
  }

  /* -- Mobile overlay backdrop -- */
  .mobile-overlay {
    position: fixed;
    inset: 0;
    background: var(--overlay-bg);
    z-index: 999;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
  }

  .mobile-overlay.visible {
    opacity: 1;
    pointer-events: auto;
  }
}

/* ========== Comparison Feature ========== */

#btn-compare {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text);
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
}
#btn-compare:hover {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}
#btn-compare.compare-active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

#compare-hint {
  position: fixed;
  top: calc(var(--shell-h) + var(--controls-h) + var(--kpi-h) + 8px);
  left: 50%;
  transform: translateX(-50%);
  background: rgba(23, 27, 44, 0.88);
  color: #fff;
  padding: 8px 18px;
  border-radius: var(--radius-pill);
  font-size: 13px;
  font-weight: 500;
  z-index: 1100;
  pointer-events: none;
  animation: compareHintFade 0.3s ease;
}
@keyframes compareHintFade {
  from { opacity: 0; transform: translateX(-50%) translateY(-8px); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}

#compare-panel {
  position: fixed;
  top: calc(var(--shell-h) + var(--controls-h) + var(--kpi-h));
  right: 0;
  width: 620px;
  max-width: 45vw;
  bottom: var(--footer-h);
  background: var(--surface);
  border-left: 1px solid var(--border);
  box-shadow: -4px 0 16px rgba(0,0,0,0.08);
  z-index: 1050;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: comparePanelSlide 0.3s ease;
}
@keyframes comparePanelSlide {
  from { transform: translateX(100%); }
  to   { transform: translateX(0); }
}

#compare-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.compare-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  margin: 0;
}
#compare-close {
  background: none;
  border: none;
  font-size: 22px;
  color: var(--text-muted);
  cursor: pointer;
  line-height: 1;
  padding: 0 4px;
}
#compare-close:hover {
  color: var(--text);
}

#compare-body {
  flex: 1;
  overflow-y: auto;
  padding: 12px 16px;
}

/* Comparison table */
.compare-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}
.compare-table th,
.compare-table td {
  padding: 6px 8px;
  text-align: left;
  vertical-align: middle;
  border-bottom: 1px solid var(--border-light);
}
.compare-table thead th {
  font-weight: 600;
  font-size: 13px;
  color: var(--text);
  border-bottom: 2px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--surface);
}
.compare-table th:first-child {
  position: sticky;
  left: 0;
  background: var(--surface);
  z-index: 2;
  min-width: 120px;
}
.compare-table thead th:first-child {
  z-index: 3;
}
.compare-table tbody tr:hover {
  background: var(--surface-alt);
}

/* Group badge in header */
.compare-group-badge {
  display: inline-block;
  padding: 1px 8px;
  border-radius: var(--radius-pill);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
}

/* Region header column */
.compare-region-col {
  text-align: center;
  min-width: 100px;
}
.compare-region-name {
  font-weight: 600;
  font-size: 12px;
  margin-bottom: 2px;
}
.compare-region-border {
  width: 100%;
  height: 3px;
  border-radius: 2px;
  margin-top: 4px;
}

/* Indicator label column */
.compare-indicator {
  font-weight: 500;
  color: var(--text-muted);
  white-space: nowrap;
}

/* Cell with bar */
.compare-cell {
  position: relative;
}
.compare-cell-value {
  position: relative;
  z-index: 1;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}
.compare-cell-bar {
  position: absolute;
  left: 0;
  top: 2px;
  bottom: 2px;
  border-radius: 2px;
  opacity: 0.15;
}
.compare-cell--best .compare-cell-value {
  font-weight: 700;
  color: var(--primary);
}

/* Sparkline section */
.compare-sparklines {
  margin-top: 12px;
  border-top: 1px solid var(--border);
  padding-top: 12px;
}
.compare-sparklines h3 {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  margin: 0 0 8px 0;
}
.compare-spark-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-bottom: 8px;
}
.compare-spark-label {
  width: 100px;
  flex-shrink: 0;
  font-size: 11px;
  font-weight: 500;
  color: var(--text-muted);
  padding-top: 4px;
}
.compare-spark-charts {
  display: flex;
  gap: 6px;
  flex: 1;
  flex-wrap: wrap;
}
.compare-spark-item {
  text-align: center;
}
.compare-spark-item svg {
  display: block;
}
.compare-spark-region-name {
  font-size: 9px;
  color: var(--text-faint);
  margin-top: 1px;
}

/* Map cursor in comparison mode */
.compare-cursor {
  cursor: crosshair !important;
}
.compare-cursor .leaflet-interactive {
  cursor: crosshair !important;
}

/* === Search & Filter === */
.search-container {
  position: relative;
  padding: 8px 10px;
  padding-bottom: 0;
}
.search-input-wrap {
  display: flex;
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0 8px;
  gap: 4px;
}
.search-icon { flex-shrink: 0; }
.search-input {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  font: inherit;
  font-size: 13px;
  padding: 6px 0;
  color: var(--text);
}
.search-input::placeholder { color: var(--text-faint); }
.search-clear {
  border: none;
  background: none;
  cursor: pointer;
  font-size: 16px;
  color: var(--text-muted);
  padding: 0 2px;
  line-height: 1;
}
.search-clear:hover { color: var(--text); }
.search-dropdown {
  position: absolute;
  z-index: 1000;
  width: calc(100% - var(--sp-3) * 2);
  left: var(--sp-3);
  background: var(--panel-bg-solid);
  border: 1px solid var(--border);
  border-top: none;
  border-radius: 0 0 var(--radius) var(--radius);
  max-height: 200px;
  overflow-y: auto;
  box-shadow: var(--shadow-md);
}
.search-item {
  padding: 6px 10px;
  cursor: pointer;
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.search-item:hover, .search-item.active { background: var(--hover-bg); }
.search-badge {
  font-size: 10px;
  padding: 1px 5px;
  border-radius: 3px;
  background: var(--active-bg);
  color: var(--text-muted);
  flex-shrink: 0;
}
.search-item .search-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.search-item .search-oblast { font-size: 11px; color: var(--text-muted); flex-shrink: 0; }

/* Filter panel */
.filter-panel {
  margin: 8px 10px 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-alt);
}
.filter-header {
  padding: 6px var(--sp-2);
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  user-select: none;
}
.filter-header:hover { background: var(--surface); border-radius: var(--radius); }
.filter-body { padding: var(--sp-2); padding-top: 0; }
.filter-row { margin-bottom: var(--sp-2); }
.filter-select {
  width: 100%;
  padding: 4px 6px;
  font-size: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
}
.filter-inputs {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-bottom: var(--sp-1);
}
.filter-num {
  flex: 1;
  padding: 4px 6px;
  font-size: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  width: 0;
}
.filter-num::-webkit-inner-spin-button { -webkit-appearance: none; }
.filter-dash { color: var(--text-muted); font-size: 12px; }
.filter-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.filter-clear-btn {
  border: none;
  background: none;
  color: var(--primary);
  cursor: pointer;
  font-size: 12px;
  padding: 0;
}
.filter-clear-btn:hover { text-decoration: underline; }
.mb-2 { margin-bottom: 8px; }
.float-end { float: right; }
.text-muted { color: var(--text-muted); font-size: 12px; }

/* ========== Demographics Tab ========== */
.demo-section { padding: 8px 0; border-bottom: 1px solid var(--border); }
.demo-section:last-child { border-bottom: none; }
.demo-section-title { font-weight: 600; font-size: 13px; margin-bottom: 6px; color: var(--text); }
.demo-total { font-size: 12px; color: var(--text-muted); margin-bottom: 4px; }
.demo-gender-row { display: flex; gap: 12px; margin-bottom: 8px; font-size: 12px; }
.demo-male { color: #3b82f6; }
.demo-female { color: #9A4E42; }
.demo-ratio { font-size: 12px; color: var(--text-muted); margin-top: 6px; }

/* Population Pyramid */
.pyramid { margin: 8px 0; }
.pyramid-header { display: flex; justify-content: space-between; font-size: 10px; color: var(--text-muted); margin-bottom: 4px; padding: 0 2px; }
.pyramid-side-label { flex: 1; }
.pyramid-side-label:last-child { text-align: right; }
.pyramid-age-label { width: 54px; text-align: center; }
.pyramid-row { display: flex; align-items: center; margin-bottom: 3px; }
.pyramid-bar-left { flex: 1; display: flex; flex-direction: row-reverse; align-items: center; gap: 4px; }
.pyramid-bar-right { flex: 1; display: flex; align-items: center; gap: 4px; }
.pyramid-age { width: 54px; text-align: center; font-size: 11px; font-weight: 500; line-height: 1.2; flex-shrink: 0; }
.pyramid-fill { height: 18px; border-radius: 2px; min-width: 2px; transition: width .3s ease; }
.pyramid-fill-male { background: #8FB1D8; }
.pyramid-fill-female { background: #C99898; }
.pyramid-val { font-size: 10px; color: var(--text-muted); white-space: nowrap; }

/* Ethnicity Bars */
.eth-bars { margin: 6px 0; }
.eth-bar-row { display: flex; align-items: center; gap: 6px; margin-bottom: 4px; }
.eth-bar-label { width: 80px; font-size: 11px; color: var(--text); text-align: right; flex-shrink: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.eth-bar-track { flex: 1; height: 14px; background: var(--surface); border-radius: 2px; overflow: hidden; }
.eth-bar-fill { height: 100%; border-radius: 2px; min-width: 1px; transition: width .3s ease; }
.eth-bar-value { width: 44px; font-size: 11px; color: var(--text-muted); text-align: right; flex-shrink: 0; }

/* === Strata Matrix Floating Panel === */
#strata-matrix-panel {
  position: fixed;
  bottom: 60px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1100;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: 12px 16px;
  min-width: 380px;
  max-width: 520px;
}
#strata-matrix-panel.hidden { display: none; }
#strata-matrix-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}
.strata-matrix-title { font-weight: 600; font-size: 14px; }
.strata-matrix-controls { display: flex; align-items: center; gap: 8px; }
#strata-matrix-close {
  background: none; border: none; font-size: 18px; cursor: pointer;
  color: var(--text-muted); padding: 0 4px;
}
#settlement-toggle .btn { font-size: 11px; padding: 2px 8px; }
#settlement-toggle .btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* Matrix grid inside floating panel */
.smp-grid { display: grid; gap: 3px; }
.smp-grid-header { font-size: 10px; font-weight: 600; text-align: center; color: var(--text-muted); padding: 2px; }
.smp-grid-row-header { font-size: 11px; font-weight: 600; color: var(--text); padding: 4px 2px; text-align: right; }
.smp-cell {
  border-radius: 4px;
  text-align: center;
  font-size: 10px;
  font-weight: 500;
  padding: 6px 2px;
  cursor: pointer;
  transition: transform .1s, box-shadow .1s;
  min-height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.smp-cell:hover { transform: scale(1.08); box-shadow: 0 2px 6px rgba(0,0,0,.15); z-index: 1; }
.smp-cell.smp-selected { outline: 2px solid var(--text); outline-offset: -1px; }
#strata-matrix-legend { font-size: 11px; text-align: center; }

/* === ROL Document Viewer === */
.rol-section {
  margin-bottom: 12px;
  padding: 10px;
  background: var(--surface-alt);
  border-radius: 6px;
  border: 1px solid var(--border-light);
}
.rol-section-title {
  font-weight: 600;
  font-size: 12px;
  color: var(--primary);
  margin-bottom: 6px;
  cursor: pointer;
}
.rol-section-title::before { content: '\25B6 '; font-size: 9px; }
.rol-section-title.expanded::before { content: '\25BC '; }
.rol-section-body { display: none; }
.rol-section-body.expanded { display: block; }
.rol-doc-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}
.rol-doc-title { font-weight: 600; font-size: 13px; }
.rol-doc-version { font-size: 11px; color: var(--text-muted); }
.rol-channel-chips { display: flex; flex-wrap: wrap; gap: 4px; margin: 6px 0; }
.rol-channel-chip {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 12px;
  background: #e0f2fe;
  color: #0369a1;
  font-size: 11px;
  font-weight: 500;
}
.rol-tactics-table { width: 100%; font-size: 11px; border-collapse: collapse; margin: 6px 0; }
.rol-tactics-table th { background: var(--surface); padding: 4px 6px; text-align: left; font-weight: 600; border-bottom: 1px solid var(--border-light); }
.rol-tactics-table td { padding: 4px 6px; border-bottom: 1px solid var(--border-light); }
.rol-kpi-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(100px, 1fr)); gap: 6px; margin: 6px 0; }
.rol-kpi-card {
  background: var(--surface);
  border-radius: 6px;
  padding: 6px 8px;
  text-align: center;
  border: 1px solid var(--border-light);
}
.rol-kpi-name { font-size: 10px; color: var(--text-muted); }
.rol-kpi-target { font-size: 13px; font-weight: 600; color: var(--primary); }
.rol-md-content { font-size: 12px; line-height: 1.5; color: var(--text); }
.rol-md-content h1, .rol-md-content h2, .rol-md-content h3 { font-size: 13px; font-weight: 600; margin: 8px 0 4px; }
.rol-md-content ul, .rol-md-content ol { padding-left: 16px; margin: 4px 0; }
.rol-md-content li { margin-bottom: 2px; }
.rol-empty { color: var(--text-muted); font-size: 12px; padding: 8px; }

/* EI color scale */
.ei-high { color: #166534; }
.ei-mid { color: #854d0e; }
.ei-low { color: #991b1b; }

/* === Analytics Panel === */
#analytics-panel {
  position: fixed;
  top: calc(var(--shell-h) + var(--controls-h) + var(--kpi-h));
  left: 0;
  right: 0;
  bottom: var(--footer-h);
  z-index: 900;
  background: var(--surface);
  overflow-y: auto;
  padding: 0;
  display: flex;
  flex-direction: column;
}

.analytics-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--sp-3) var(--sp-4);
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, var(--surface), var(--surface-alt));
  position: sticky;
  top: 0;
  z-index: 2;
}

.analytics-tabs {
  display: flex;
  gap: var(--sp-2);
}

.analytics-tab {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: var(--sp-1) var(--sp-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  background: transparent;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  transition: var(--transition);
}

.analytics-tab:hover {
  color: var(--text);
  border-color: var(--text-muted);
}

.analytics-tab.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

.analytics-close-btn {
  background: none;
  border: none;
  font-size: 20px;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0 var(--sp-2);
  line-height: 1;
}

.analytics-close-btn:hover {
  color: var(--text);
}

.analytics-view {
  flex: 1;
  padding: var(--sp-4);
  display: none;
}

.analytics-view.active {
  display: block;
}

.analytics-method-note {
  margin: var(--sp-3) var(--sp-4) 0;
  padding: var(--sp-2) var(--sp-3);
  border-left: 3px solid var(--primary);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  background: var(--surface-alt);
  color: var(--text-muted);
  font-size: 12px;
  line-height: 1.45;
}

/* Dead Loop Summary */
.analytics-summary {
  display: flex;
  gap: var(--sp-3);
  flex-wrap: wrap;
  margin-bottom: var(--sp-4);
}

.dl-badge {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-1);
  padding: var(--sp-1) var(--sp-3);
  border-radius: var(--radius-pill);
  font-size: 12px;
  font-weight: 500;
  background: var(--surface-alt);
  border: 1px solid var(--border-light);
}

.dl-badge .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}

/* Analytics Chart Container */
.analytics-chart-container {
  position: relative;
  background: var(--panel-bg-solid);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: var(--sp-3);
  margin-bottom: var(--sp-4);
  min-height: 360px;
}

.analytics-svg {
  width: 100%;
  height: 360px;
}

/* Analytics Tooltip */
.analytics-tooltip {
  position: absolute;
  background: rgba(0, 0, 0, 0.85);
  color: #fff;
  padding: var(--sp-2) var(--sp-3);
  border-radius: var(--radius);
  font-size: 12px;
  pointer-events: none;
  z-index: 10;
  max-width: 260px;
  line-height: 1.4;
  white-space: nowrap;
  box-shadow: var(--shadow-md);
}

/* Dead Loop Details Table */
.dl-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.dl-table th {
  text-align: left;
  padding: var(--sp-2) var(--sp-2);
  border-bottom: 2px solid var(--border);
  font-weight: 600;
  color: var(--text-muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.dl-table td {
  padding: var(--sp-2) var(--sp-2);
  border-bottom: 1px solid var(--border-light);
  vertical-align: middle;
}

.dl-table tr:hover td {
  background: var(--surface-alt);
}

.dl-quadrant-tag {
  display: inline-block;
  padding: 1px 6px;
  border-radius: var(--radius-pill);
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.dl-quadrant-tag.dead_loop { background: #F8E8E5; color: #823A3A; }
.dl-quadrant-tag.efficient { background: #E4F2F1; color: #07585D; }
.dl-quadrant-tag.underserved { background: #F8EEDB; color: #765016; }
.dl-quadrant-tag.dormant { background: #E8EEF8; color: #315F9F; }

/* Strata gap mini bars */
.dl-strata-gaps {
  display: flex;
  gap: 2px;
  align-items: flex-end;
  height: 18px;
}

.dl-strata-bar {
  width: 4px;
  border-radius: 1px;
  background: #ef4444;
  opacity: 0.7;
}

/* Saturation Controls */
.analytics-saturation-controls {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  margin-bottom: var(--sp-4);
}

/* Saturation Insights */
.analytics-insights {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: var(--sp-3);
}

.sat-card {
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: var(--sp-3);
  background: var(--panel-bg-solid);
}

.sat-card-title {
  font-size: 12px;
  font-weight: 600;
  margin-bottom: var(--sp-2);
  display: flex;
  align-items: center;
  gap: var(--sp-2);
}

.sat-card-title .color-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
}

.sat-card-row {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--text-muted);
  padding: 2px 0;
}

.sat-card-row .value {
  font-weight: 600;
  color: var(--text);
}

.sat-headroom-bar {
  height: 4px;
  border-radius: 2px;
  background: var(--border-light);
  margin-top: var(--sp-2);
  overflow: hidden;
}

.sat-headroom-fill {
  height: 100%;
  border-radius: 2px;
  transition: width var(--transition-slow);
}


/* === Small Mobile (≤375px) === */
@media (max-width: 375px) {
  .mobile-nav-item small { font-size: 9px; }
  .mobile-nav-icon { font-size: 18px; }
  .mobile-kpi-strip .kpi-value { font-size: 12px; }
  .mobile-kpi-strip .kpi-label { font-size: 7px; }
  #legend { max-width: 150px; font-size: 10px; }
  .sheet-handle { width: 32px; }
  #info .nav-tabs-sm .nav-link { font-size: 10px; padding: 4px 6px; }
}

/* Responsive adjustments */
@media (max-width: 767.98px) {
  #analytics-panel {
    top: var(--shell-h);
    bottom: 56px;
    left: 0;
    right: 0;
    width: 100%;
    max-width: 100%;
    border-radius: 0;
  }

  .analytics-chart-container {
    min-height: 280px;
  }

  .analytics-svg {
    height: 280px;
  }

  .analytics-insights {
    grid-template-columns: 1fr;
  }

  .analytics-method-note {
    margin: var(--sp-2) var(--sp-3) 0;
    font-size: 11px;
  }
}

/* === Report / Passport Tab === */
.report-passport-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  font-size: 13px;
  font-weight: 600;
  color: #fff;
  background: var(--primary);
  border: none;
  border-radius: 6px;
  cursor: pointer;
  margin-bottom: 12px;
  transition: background 0.15s;
}
.report-passport-btn:hover { background: var(--primary-hover); }
.report-passport-btn .ui-icon {
  background: color-mix(in srgb, #fff 16%, transparent);
  border-color: color-mix(in srgb, #fff 32%, transparent);
  color: #fff;
}
.report-passport-btn:disabled { opacity: 0.6; cursor: wait; }

.report-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-2);
  margin-bottom: var(--sp-2);
  color: var(--text-faint);
  font-size: 10px;
}
.report-copy-link {
  padding: 2px 0;
  border: 0;
  background: transparent;
  color: var(--primary);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
.report-copy-link:hover,
.report-copy-link:focus { text-decoration: underline; }
.report-disclaimer,
.report-provenance {
  margin: 0 0 var(--sp-3);
  color: var(--text-muted);
  font-size: 11px;
  line-height: 1.45;
}
.report-disclaimer {
  padding: var(--sp-2) var(--sp-3);
  border-left: 2px solid var(--primary);
  background: var(--surface-alt);
}
.report-provenance {
  margin-top: var(--sp-3);
  margin-bottom: 0;
  padding-top: var(--sp-2);
  border-top: 1px solid var(--border-light);
  color: var(--text-faint);
  font-size: 10px;
}

.report-section-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  margin: 14px 0 6px;
  padding-bottom: 4px;
  border-bottom: 1px solid var(--border-light);
}

.swot-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 12px;
}
.swot-cell {
  padding: 8px 10px;
  border-radius: 6px;
  font-size: 12px;
  line-height: 1.5;
}
.swot-cell h4 {
  font-size: 12px;
  font-weight: 700;
  margin: 0 0 4px;
}
.swot-cell ul {
  margin: 0;
  padding-left: 16px;
}
.swot-strengths  { background: #e8f5e9; }
.swot-weaknesses { background: #fce4ec; }
.swot-opportunities { background: #e3f2fd; }
.swot-risks      { background: #fff3e0; }

.report-findings {
  list-style: none;
  padding: 0;
  margin: 0 0 12px;
}
.report-findings li {
  font-size: 12px;
  padding: 3px 0;
  line-height: 1.5;
}
.finding-up   { color: #2e7d32; }
.finding-down { color: #c62828; }
.finding-neutral { color: var(--text-muted); }

.report-actions {
  padding-left: 18px;
  margin: 0 0 12px;
}
.report-actions li {
  font-size: 12px;
  padding: 2px 0;
  line-height: 1.5;
}

/* === Large Desktop (≥1440px) === */
@media (min-width: 1440px) {
  :root {
    --info-w: 400px;
  }
  .kpi-value { font-size: 22px; }
  .kpi-label { font-size: 11px; }
  #controls-bar { padding: 0 var(--sp-4); }
}

/* === Ultra-wide / 4K (≥2560px) === */
@media (min-width: 2560px) {
  :root {
    --info-w: 480px;
    --controls-h: 56px;
    --kpi-h: 60px;
  }
  body { font-size: 16px; }
  .kpi-value { font-size: 26px; }
  .kpi-label { font-size: 12px; letter-spacing: 0.12em; }
  .select-wrapper select { font-size: 15px; }
  .control-label { font-size: 12px; }
  #ranking-panel { width: 320px; }
}


/* === Dark Mode Component Overrides === */
html.dark .leaflet-tile-pane {
  filter: saturate(0.3) brightness(0.85);
}

html.dark .region-label {
  text-shadow:
    0 0 4px rgba(0, 0, 0, 0.9),
    0 0 8px rgba(0, 0, 0, 0.7),
    1px 1px 2px rgba(0, 0, 0, 0.8);
}

html.dark .leaflet-control-zoom a {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border);
}
html.dark .leaflet-control-zoom a:hover {
  background: var(--surface-alt);
}

html.dark .swot-strengths  { background: rgba(34, 197, 94, 0.12); }
html.dark .swot-weaknesses { background: rgba(244, 63, 94, 0.12); }
html.dark .swot-opportunities { background: rgba(59, 130, 246, 0.12); }
html.dark .swot-risks      { background: rgba(251, 146, 60, 0.12); }

html.dark .dl-quadrant-tag.dead_loop { background: rgba(220, 38, 38, 0.15); color: #fca5a5; }
html.dark .dl-quadrant-tag.efficient { background: rgba(34, 197, 94, 0.15); color: #86efac; }
html.dark .dl-quadrant-tag.underserved { background: rgba(234, 179, 8, 0.15); color: #fde68a; }
html.dark .dl-quadrant-tag.dormant { background: rgba(99, 102, 241, 0.15); color: #a5b4fc; }

html.dark .info-badge { background: rgba(14, 165, 233, 0.15); color: #7dd3fc; }

html.dark .modal-content { background: var(--surface); color: var(--text); border-color: var(--border); }
html.dark .modal-header { border-color: var(--border); }
html.dark .modal-footer { border-color: var(--border); }
html.dark .btn-close { filter: invert(1); }

html.dark .alert-success { background: rgba(34, 197, 94, 0.15); color: #86efac; border-color: rgba(34, 197, 94, 0.3); }
html.dark .alert-warning { background: rgba(234, 179, 8, 0.15); color: #fde68a; border-color: rgba(234, 179, 8, 0.3); }
html.dark .alert-danger { background: rgba(220, 38, 38, 0.15); color: #fca5a5; border-color: rgba(220, 38, 38, 0.3); }

html.dark #settlement-toggle .btn { color: var(--text); border-color: var(--border); }

html.dark .mobile-more-panel { background: var(--surface); }
html.dark .mobile-more-item:active { background: var(--active-bg); }

/* Theme Toggle Button */
.theme-toggle-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text-muted);
  font-size: 16px;
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition);
  flex-shrink: 0;
}

#controls-bar .toolbar-menu .dropdown-item.theme-toggle-btn,
#controls-bar .toolbar-menu .dropdown-item#toggle-tiles {
  width: 100%;
  height: auto;
  justify-content: flex-start;
  border: 0;
  border-radius: calc(var(--radius) - 2px);
  background: transparent;
  color: var(--text);
  font-size: 12px;
  font-weight: 400;
  text-align: left;
}
.theme-toggle-btn:hover {
  background: var(--hover-bg);
  border-color: var(--text-faint);
  color: var(--text);
}
html:not(.dark) .theme-icon-dark { display: none; }
html.dark .theme-icon-light { display: none; }


/* === Reduced Motion === */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
