/* === CSS Variables === */
:root {
  --bg: #EDF2F6;
  --surface: #FFFFFF;
  --surface-alt: #F6F8FB;
  --surface-muted: #EEF3F7;
  --bg-card: #F6F8FB;
  --border: #D8E0E8;
  --border-light: #E7EDF2;
  --text: #151A2D;
  --text-muted: #4B586C;
  --text-faint: #5F6F83;
  --text-secondary: #4B586C;
  --primary: #006F76;
  --primary-hover: #005C62;
  --primary-strong: #005C62;
  --on-primary: #FFFFFF;
  --primary-soft: #E1F2F0;
  --success: #18794E;
  --danger: #B42318;
  --ok: #18794E;
  --warning: #8A6410;
  --text-primary: #151A2D;
  --border-soft: #E7EDF2;
  --blue: #315F9F;
  --blue-soft: #E8EEF8;

  /* Group colors */
  --group-a: #315F9F;
  --group-b: #B17B0B;
  --group-c: #00777D;

  /* Shadows */
  --shadow-sm: 0 2px 8px rgba(23, 35, 52, 0.055);
  --shadow-md: 0 14px 34px rgba(23, 35, 52, 0.1);

  /* 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;
  --ranking-collapsed-h: 34px;
  --ranking-expanded-h: min(280px, 34vh);
  --info-w: 420px;

  /* Panel / overlay backgrounds */
  --panel-bg: rgba(255, 255, 255, 0.93);
  --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;
  --surface-muted: #252D34;
  --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-strong: #82D4D0;
  --on-primary: #11161B;
  --primary-soft: #183C3D;
  --success: #67CF9A;
  --danger: #FF8C82;
  --ok: #67CF9A;
  --warning: #EFB554;
  --text-primary: #F0F3F5;
  --border-soft: #293139;
  --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(24, 30, 36, 0.95);
  --panel-bg-solid: #181E24;
  --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(21, 26, 45, 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;
  overflow-x: hidden;
}

.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.94);
  backdrop-filter: blur(16px) saturate(1.12);
}
html.dark .qazgeo-shell { background: rgba(24, 30, 36, 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; transition: color var(--transition); }
.qazgeo-shell nav a:hover, .qazgeo-shell nav a:focus-visible, .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; transition: color var(--transition); }
.qazgeo-live:hover, .qazgeo-live:focus-visible { color: var(--primary); }
.qazgeo-live__status-dot { width: 7px; height: 7px; flex: 0 0 7px; border-radius: 50%; background: #18794e; box-shadow: 0 0 0 3px rgba(24, 121, 78, 0.11); }
.qazgeo-mobile-context { display: none; color: var(--text-muted); font-size: 11px; font-weight: 650; }

.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: none;
  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;
  transition: border-color var(--transition), background var(--transition), color var(--transition), transform var(--transition) !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: var(--on-primary) !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-boundary::before { width: 11px; height: 11px; border: 2px dashed currentColor; border-radius: 50%; }
.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: 10px;
}

/* 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: color-mix(in srgb, var(--surface-alt) 82%, var(--surface));
  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;
  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: calc(var(--footer-h) + var(--ranking-collapsed-h));
  display: flex;
}

/* The expanded ranking is part of the workspace, not an overlay over it. */
body.ranking-open #main-content {
  bottom: calc(var(--footer-h) + var(--ranking-expanded-h));
}

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

#map-load-state {
  position: absolute;
  top: 14px;
  left: calc((100% - var(--info-w)) / 2);
  z-index: 850;
  display: inline-flex;
  align-items: center;
  gap: 9px;
  max-width: min(420px, calc(100% - 32px));
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--panel-bg-solid);
  box-shadow: var(--shadow-md);
  color: var(--text-muted);
  font-size: 12px;
  transform: translateX(-50%);
}
#map-load-state[hidden] { display: none; }
#map-load-state.is-error { border-color: color-mix(in srgb, var(--danger) 36%, var(--border)); color: var(--danger); }
.map-load-state__marker {
  width: 10px;
  height: 10px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--success) 16%, transparent);
}
#map-load-state.is-error .map-load-state__marker { background: var(--danger); box-shadow: 0 0 0 4px color-mix(in srgb, var(--danger) 14%, transparent); }

/* 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;
}

/* The layer switcher occupies the map's top-left corner; keep zoom reachable. */
#map .leaflet-top.leaflet-left {
  left: calc(var(--sp-3) + 182px);
}

/* 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: -12px 0 30px rgba(23, 35, 52, 0.055);
  overflow-y: auto;
  padding: 20px 22px;
  position: relative;
  scrollbar-gutter: stable;
}

.info-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
  margin: 0 0 var(--sp-2) 0;
}

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

#info-default {
  margin-top: var(--sp-4);
  padding: var(--sp-4) 0 0;
  border: 0;
  border-top: 1px solid var(--border-light);
  border-radius: 0;
  background: transparent;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--primary);
  font-size: 11px;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

#info-default .info-title {
  margin-bottom: 3px;
}
#info-default .info-hint {
  margin-bottom: 10px;
}

.overview-strip {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--sp-2);
  margin-bottom: var(--sp-3);
}

.overview-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px 14px;
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  background: linear-gradient(180deg, color-mix(in srgb, var(--surface-alt) 92%, var(--surface)) 0%, var(--surface) 100%);
  box-shadow: var(--shadow-sm);
}

.overview-card__top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.overview-card__eyebrow {
  font-size: 11px;
  font-weight: 700;
  color: var(--primary);
  text-transform: uppercase;
  line-height: 1.2;
}

.overview-card em {
  min-width: 0;
  width: fit-content;
  max-width: 100%;
  padding: 2px 8px;
  border: 1px solid var(--border-light);
  border-radius: 999px;
  background: color-mix(in srgb, var(--surface-alt) 72%, var(--surface));
  color: var(--text-muted);
  font-family: 'IBM Plex Mono', monospace;
  font-size: 10px;
  font-style: normal;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.overview-card__note {
  margin: 0;
  font-size: 12px;
  line-height: 1.45;
  color: var(--text-faint);
}

.overview-card__facts {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px 10px;
  margin: 0;
}

.overview-card__facts div {
  min-width: 0;
}

.overview-card__facts dt {
  margin: 0 0 2px;
  font-size: 10px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  line-height: 1.2;
}

.overview-card__facts dd {
  margin: 0;
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.3;
  font-variant-numeric: tabular-nums lining-nums;
}

.overview-card__footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding-top: 4px;
  border-top: 1px solid var(--border-light);
}

.overview-card__footer small {
  min-width: 0;
  color: var(--text-faint);
  font-size: 11px;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.overview-card__action {
  flex: 0 0 auto;
  min-height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 10px;
  border: 1px solid var(--border-light);
  border-radius: 999px;
  background: var(--surface);
  color: var(--primary);
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  transition: border-color 160ms ease, background 160ms ease, color 160ms ease, transform 160ms ease;
}

.overview-card__action:hover,
.overview-card__action:focus-visible {
  border-color: var(--primary);
  background: color-mix(in srgb, var(--surface-alt) 70%, var(--surface));
  color: var(--primary-strong);
}

.overview-card__action:focus-visible {
  outline: 2px solid color-mix(in srgb, var(--primary) 36%, transparent);
  outline-offset: 2px;
}

.overview-route-strip {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--sp-2);
  margin-bottom: var(--sp-3);
}

.overview-route-card {
  display: grid;
  gap: 8px;
  padding: 12px 14px;
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  background: linear-gradient(180deg, color-mix(in srgb, var(--surface-alt) 88%, var(--surface)) 0%, var(--surface) 100%);
  box-shadow: var(--shadow-sm);
}

.overview-route-card__eyebrow {
  font-size: 11px;
  font-weight: 700;
  color: var(--primary);
  text-transform: uppercase;
  line-height: 1.2;
}

.overview-route-card strong {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.35;
}

.overview-route-card p {
  margin: 0;
  font-size: 12px;
  line-height: 1.45;
  color: var(--text-faint);
}

.overview-route-card__source {
  display: block;
  margin-top: -2px;
  color: var(--text-muted);
  font-size: 10px;
  line-height: 1.35;
}

.overview-route-card__facts {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1px;
  overflow: hidden;
  margin: 0;
  border: 1px solid var(--border-light);
  border-radius: calc(var(--radius) - 1px);
  background: color-mix(in srgb, var(--border-light) 78%, var(--surface));
}

.overview-route-card__facts div {
  min-width: 0;
  padding: 8px 9px;
  background: color-mix(in srgb, var(--surface-alt) 76%, var(--surface));
}

.overview-route-card__facts dt {
  margin: 0 0 3px;
  color: var(--text-faint);
  font-size: 10px;
  font-weight: 700;
  line-height: 1.2;
  text-transform: uppercase;
}

.overview-route-card__facts dd {
  margin: 0;
  color: var(--text);
  font-size: 12px;
  line-height: 1.4;
  font-weight: 650;
  overflow-wrap: anywhere;
}

.overview-route-card__footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: auto;
  color: var(--text-faint);
  font-size: 11px;
  line-height: 1.35;
}

.overview-route-card__footer span {
  min-width: 0;
  overflow-wrap: anywhere;
}

.overview-route-card__action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  padding: 0 12px;
  border: 1px solid color-mix(in srgb, var(--primary) 28%, var(--border-light));
  border-radius: 999px;
  background: color-mix(in srgb, var(--primary-soft) 40%, var(--surface));
  color: var(--primary-strong);
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color .16s ease, border-color .16s ease, color .16s ease, transform .16s ease;
}

.overview-route-card__action:hover,
.overview-route-card__action:focus-visible {
  background: color-mix(in srgb, var(--primary-soft) 64%, var(--surface));
  border-color: color-mix(in srgb, var(--primary) 42%, var(--border-light));
  color: var(--primary);
}

.overview-route-card__action:focus-visible {
  outline: 2px solid color-mix(in srgb, var(--primary) 34%, transparent);
  outline-offset: 2px;
}

.overview-route-card__action:active {
  transform: translateY(1px);
}

.data-viz-grid.mapregion-compare-grid,
.mapregion-compare-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--sp-2);
  margin-bottom: var(--sp-3);
}

.data-viz-panel.mapregion-compare-panel,
.mapregion-compare-panel {
  min-width: 0;
  display: grid;
  gap: 10px;
  padding: 12px 14px;
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  background: linear-gradient(180deg, color-mix(in srgb, var(--surface-alt) 86%, var(--surface)) 0%, var(--surface) 100%);
  box-shadow: var(--shadow-sm);
}

.data-viz-panel__head.mapregion-compare-panel__head,
.mapregion-compare-panel__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.mapregion-compare-panel__eyebrow {
  margin: 0 0 4px;
  color: var(--primary);
  font-size: 11px;
  font-weight: 700;
  line-height: 1.2;
  text-transform: uppercase;
}

.mapregion-compare-panel__head p,
.data-viz-panel__head.mapregion-compare-panel__head p {
  margin: 0;
  color: var(--text-faint);
  font-size: 12px;
  line-height: 1.45;
}

.mapregion-compare-panel__badge,
.data-viz-panel__badge.mapregion-compare-panel__badge {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  max-width: 45%;
  padding: 0 10px;
  border: 1px solid var(--border-light);
  border-radius: 999px;
  background: color-mix(in srgb, var(--surface-alt) 80%, var(--surface));
  color: var(--text-muted);
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.data-viz-bars.mapregion-compare-bars,
.mapregion-compare-bars {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.data-viz-bar-row.mapregion-compare-row,
.mapregion-compare-row {
  min-width: 0;
  display: grid;
  gap: 5px;
}

.data-viz-bar-row__head.mapregion-compare-row__head,
.mapregion-compare-row__head {
  min-width: 0;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}

.mapregion-compare-row__head span,
.data-viz-bar-row__head.mapregion-compare-row__head span {
  min-width: 0;
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 650;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mapregion-compare-row__head strong,
.data-viz-bar-row__head.mapregion-compare-row__head strong {
  flex: 0 0 auto;
  color: var(--text);
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  font-weight: 760;
  font-variant-numeric: tabular-nums;
}

.mapregion-compare-row progress,
.data-viz-bar-row.mapregion-compare-row progress {
  width: 100%;
  height: 8px;
  display: block;
  border: 0;
  border-radius: 999px;
  overflow: hidden;
  background: var(--border-light);
  accent-color: var(--primary);
}

.mapregion-compare-row progress::-webkit-progress-bar,
.data-viz-bar-row.mapregion-compare-row progress::-webkit-progress-bar {
  background: var(--border-light);
  border-radius: 999px;
}

.mapregion-compare-row progress::-webkit-progress-value,
.data-viz-bar-row.mapregion-compare-row progress::-webkit-progress-value {
  border-radius: 999px;
  background: linear-gradient(90deg, var(--primary), color-mix(in srgb, var(--primary-strong) 72%, var(--primary)));
}

.mapregion-compare-row progress::-moz-progress-bar,
.data-viz-bar-row.mapregion-compare-row progress::-moz-progress-bar {
  border-radius: 999px;
  background: linear-gradient(90deg, var(--primary), color-mix(in srgb, var(--primary-strong) 72%, var(--primary)));
}

.mapregion-compare-row small,
.data-viz-bar-row.mapregion-compare-row small {
  color: var(--text-muted);
  font-size: 10px;
  line-height: 1.35;
}

.mapregion-compare-panel .data-viz-panel__footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 2px;
  padding-top: 9px;
  border-top: 1px solid var(--border-soft);
}

.mapregion-compare-panel .data-viz-panel__footer small {
  color: var(--text-muted);
  font-size: 10px;
  line-height: 1.35;
}

.mapregion-compare-panel .data-viz-panel__action {
  flex: 0 0 auto;
  min-height: 28px;
  display: inline-flex;
  align-items: center;
  padding: 0 9px;
  border: 1px solid var(--border-light);
  border-radius: 999px;
  background: var(--surface);
  color: var(--primary);
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}

.mapregion-compare-panel .data-viz-panel__action:hover {
  border-color: var(--primary);
  background: color-mix(in srgb, var(--primary-soft) 65%, var(--surface));
}

@media (max-width: 1023.98px) {
  .data-viz-grid.mapregion-compare-grid,
  .mapregion-compare-grid {
    grid-template-columns: 1fr;
  }

  .mapregion-compare-panel__badge,
  .mapregion-compare-panel .data-viz-panel__action {
    max-width: 100%;
  }
}

/* Summary stats cards */
#summary-stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--sp-2);
}

.summary-card {
  background: var(--surface-alt);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  padding: 12px 14px;
  margin-bottom: 0;
}

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

.summary-card-value {
  font-size: 22px;
  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-detail {
  position: relative;
}

#detail-header {
  padding-bottom: var(--sp-3);
}

.detail-header__top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.detail-header__meta {
  min-width: 180px;
  display: grid;
  gap: 1px;
  overflow: hidden;
  margin: 0;
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--border-light) 78%, var(--surface));
}

.detail-header__meta div {
  min-width: 0;
  padding: 8px 10px;
  background: color-mix(in srgb, var(--surface-alt) 78%, var(--surface));
}

.detail-header__meta dt {
  margin: 0 0 3px;
  color: var(--text-faint);
  font-size: 10px;
  font-weight: 700;
  line-height: 1.2;
  text-transform: uppercase;
}

.detail-header__meta dd {
  margin: 0;
  color: var(--text);
  font-family: 'IBM Plex Mono', monospace;
  font-size: 12px;
  line-height: 1.35;
  font-weight: 700;
  overflow-wrap: anywhere;
}

#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: 24px;
  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-3);
}

/* Metric rows */
.metric-row {
  display: flex;
  align-items: center;
  padding: 10px 0 5px;
  border-bottom: 0;
}

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

.metric-icon {
  width: 9px;
  height: 9px;
  flex-shrink: 0;
  overflow: hidden;
  border: 1px solid color-mix(in srgb, var(--primary) 58%, var(--border));
  border-radius: 3px;
  background: color-mix(in srgb, var(--primary) 12%, var(--surface));
  color: transparent;
  font-size: 0;
}

.metric-icon:empty { visibility: hidden; }

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

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

.metric-value {
  font-size: 17px;
  font-weight: 700;
  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: 20px;
  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;
  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-3);
  padding: 10px 12px;
  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;
  text-transform: uppercase;
}
.editorial-signal p {
  margin: 3px 0 0;
  color: var(--text);
  font-size: 13px;
  line-height: 1.5;
}
.group-context {
  margin: var(--sp-3) 0 0;
  color: var(--text-muted);
  font-size: 12px;
  line-height: 1.5;
}
.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; }
.sparkline-delta {
  font-size: 12px;
  font-weight: 600;
}
.sparkline-delta-up { color: #16A34A; }
.sparkline-delta-down { color: #DC2626; }
.sparkline-delta-zero { color: var(--text-muted); }

.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 {
  position: sticky;
  top: -20px;
  z-index: 12;
  display: flex;
  align-items: stretch;
  gap: var(--sp-1);
  margin: 0 -22px;
  padding: 12px 22px 0;
  border-bottom: 2px solid var(--border-light);
  background: color-mix(in srgb, var(--surface) 96%, transparent);
  backdrop-filter: blur(12px);
}

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

.nav-tabs-sm {
  gap: 0;
  flex-wrap: nowrap;
  border-bottom: 0;
}
.nav-tabs-sm .nav-link {
  min-height: 38px;
  font-size: 12px;
  font-weight: 600;
  padding: 8px 9px;
  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%;
  min-height: 38px;
  padding: 8px 9px;
  border: 0;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  background: transparent;
  color: var(--text-muted);
  font: inherit;
  font-size: 12px;
  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-3);
}

/* Detail tabs all share a compact evidence table. Without an explicit
   baseline, the SSR fallback leaves dt/dd margins and spacing to the browser
   default, making otherwise consistent region details look unfinished. */
.tab-baseline {
  display: grid;
  gap: 1px;
  margin: 0;
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--border-light) 78%, var(--surface));
}

.tab-baseline > div {
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(120px, 0.42fr) minmax(0, 1fr);
  gap: 12px;
  align-items: baseline;
  padding: 9px 10px;
  background: color-mix(in srgb, var(--surface-alt) 82%, var(--surface));
}

.tab-baseline dt {
  min-width: 0;
  margin: 0;
  color: var(--text-faint);
  font-size: 10px;
  font-weight: 700;
  line-height: 1.25;
  text-transform: uppercase;
}

.tab-baseline dd {
  min-width: 0;
  margin: 0;
  color: var(--text);
  font-size: 12px;
  font-weight: 650;
  line-height: 1.4;
  overflow-wrap: anywhere;
  font-variant-numeric: tabular-nums lining-nums;
}

.tab-load-state {
  margin: 0;
  padding: 14px 16px;
  color: var(--text-muted);
  font-size: 12px;
  line-height: 1.45;
}

.metric-provenance {
  margin: 0;
  padding: 0 0 10px 17px;
  border-bottom: 1px solid var(--border-light);
  color: var(--text-faint);
  font-size: 11px;
  line-height: 1.4;
}

.metric-provenance a {
  color: var(--primary);
  font-weight: 600;
  text-decoration: none;
}

.metric-provenance a:hover,
.metric-provenance a:focus {
  text-decoration: underline;
}

/* === 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-status-completed { background: #16a34a; }
.road-status-active { background: #ea580c; }
.road-status-planned { background: #9ca3af; }
.road-status-text { font-weight: 600; }
.road-status-completed-text { color: #16a34a; }
.road-status-active-text { color: #ea580c; }
.road-status-planned-text { color: #6b7280; }
.road-card-details {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 12px;
  color: var(--text-muted);
}
.road-detail {
  white-space: nowrap;
}
.road-detail-label {
  color: var(--text-secondary);
  font-weight: 600;
}
.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(--ranking-collapsed-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-lg);
  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;
}

.legend-symbol-scale {
  width: 150px;
  height: 42px;
  display: flex;
  align-items: flex-end;
  justify-content: space-around;
  border-bottom: 1px solid var(--border);
  margin-bottom: 4px;
}

.legend-symbol {
  display: block;
  border-radius: 50%;
  border: 2px solid #fff;
  background: #087f86;
  box-shadow: 0 0 0 1px rgba(8, 127, 134, 0.3);
}

.legend-symbol--small { width: 12px; height: 12px; }
.legend-symbol--medium { width: 22px; height: 22px; }
.legend-symbol--large { width: 36px; height: 36px; }

.legend-method {
  max-width: 190px;
  margin-top: var(--sp-2);
  color: var(--text-muted);
  font-size: 10px;
  line-height: 1.35;
}

.legend-source {
  max-width: 190px;
  margin-top: var(--sp-2);
  padding-top: var(--sp-2);
  border-top: 1px solid var(--border-light);
  color: var(--text-faint);
  font-size: 10px;
  line-height: 1.35;
}

/* === 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);
  height: var(--ranking-collapsed-h);
  transition: height var(--transition-slow);
}

#ranking-panel:not(.ranking-collapsed) {
  height: var(--ranking-expanded-h);
}

#ranking-toggle {
  width: 100%;
  min-height: var(--ranking-collapsed-h);
  padding: var(--sp-2) var(--sp-4);
  border: 0;
  background: transparent;
  cursor: pointer;
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0;
  user-select: none;
  text-align: center;
  transition: color var(--transition);
}

#ranking-toggle-icon {
  display: inline-block;
  margin-left: 4px;
  transition: transform var(--transition);
}

#ranking-panel:not(.ranking-collapsed) #ranking-toggle-icon {
  transform: rotate(180deg);
}

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

#ranking-toggle:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--primary) 30%, transparent);
  outline-offset: -3px;
}

#ranking-content {
  max-height: calc(var(--ranking-expanded-h) - var(--ranking-collapsed-h));
  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-empty {
  padding: 8px;
  color: var(--text-faint);
  font-size: 12px;
}

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

/* === Runtime Contract Block (collapsed workspace reference) === */
.mapregion-runtime {
  position: fixed;
  left: 12px;
  bottom: calc(var(--footer-h) + var(--ranking-collapsed-h) + 10px);
  z-index: 870;
  width: min(430px, calc(100% - var(--info-w) - 34px));
  max-height: min(58vh, 520px);
  padding: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.mapregion-runtime[open] {
  overflow: auto;
}

.mapregion-runtime__summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 42px;
  padding: 9px 12px;
  cursor: pointer;
  list-style: none;
}

.mapregion-runtime__summary::-webkit-details-marker {
  display: none;
}

.mapregion-runtime__summary::after {
  content: '+';
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  flex: 0 0 auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--primary);
  font-weight: 700;
}

.mapregion-runtime[open] .mapregion-runtime__summary::after {
  content: '−';
}

.mapregion-runtime__summary strong {
  display: block;
  font-size: 12px;
  line-height: 1.2;
}

.mapregion-runtime__summary small {
  display: block;
  margin-top: 2px;
  color: var(--text-muted);
  font-size: 11px;
  line-height: 1.3;
}

.mapregion-runtime__list {
  display: grid;
  gap: 8px;
  padding: 0 10px 10px;
}

.mapregion-runtime__section {
  min-width: 0;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  padding: 9px 10px;
  background: var(--surface-alt);
}

.mapregion-runtime__section h3 {
  margin: 0 0 7px;
  font-size: 12px;
  color: var(--primary);
}

.mapregion-runtime__section .endpoint-item,
.mapregion-runtime__section a {
  display: block;
  min-width: 0;
  max-width: 100%;
  padding: 9px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  margin-top: 6px;
  text-decoration: none;
  color: var(--primary-strong);
  overflow: hidden;
}

.mapregion-runtime__section a:hover {
  border-color: var(--primary);
}

.mapregion-runtime__section .endpoint-item--contract {
  border-style: dashed;
  opacity: 0.82;
}

.mapregion-runtime__section code {
  display: block;
  overflow: hidden;
  max-width: 100%;
  color: var(--primary);
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.mapregion-runtime__section span {
  display: block;
  margin-top: 3px;
  color: var(--text-muted);
  font-size: 11px;
  overflow-wrap: anywhere;
}

.mapregion-runtime__section em {
  display: inline-block;
  margin-top: 6px;
  color: var(--text-faint);
  font-size: 10px;
  font-style: normal;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

/* === 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-md);
  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-md);
  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;
}

#map-first-action {
  position: absolute;
  z-index: 620;
  left: 50%;
  bottom: 22px;
  transform: translateX(-50%);
  width: max-content;
  max-width: min(420px, calc(100% - 32px));
  margin: 0;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  box-shadow: var(--shadow-sm);
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 600;
  text-align: center;
  backdrop-filter: blur(10px);
}

#legend {
  box-shadow: var(--shadow-sm);
}

#legend:not(.legend-collapsed) {
  max-width: min(260px, calc(100vw - var(--info-w) - 48px));
}

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

@media (hover: hover) {
  .qazgeo-brand:hover { opacity: 0.82; }
  #controls-bar .btn:hover, #btn-compare:hover { transform: translateY(-1px); }
  .summary-card { transition: border-color var(--transition), background var(--transition); }
  .summary-card:hover { border-color: color-mix(in srgb, var(--primary) 34%, var(--border)); background: color-mix(in srgb, var(--primary-soft) 28%, var(--surface-alt)); }
}

/* === 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;
  }

  .overview-strip,
  .overview-route-strip {
    grid-template-columns: 1fr;
  }

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

  .mapregion-runtime {
    width: min(360px, calc(100% - var(--info-w) - 28px));
  }
}

/* Keep the map failure notice below the interaction rail on tablet widths.
   The rail otherwise sits above the centered notice and hides its leading
   text, making the recovery action look truncated. */
@media (min-width: 768px) and (max-width: 1023.98px) {
  #map-load-state {
    top: 56px;
    max-width: min(360px, calc(100% - var(--info-w) - 32px));
  }
}

/* === 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; }
  .qazgeo-mobile-context { display: inline-flex; margin-left: auto; }
  #map-load-state { left: 50%; }

  #strata-matrix-panel {
    width: min(520px, calc(100vw - 24px));
    min-width: min(380px, calc(100vw - 24px));
    max-width: calc(100vw - 24px);
  }

  .mapregion-runtime {
    display: none;
  }

  /* -- Mobile Nav Bar -- */
  .mobile-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 56px;
    background: color-mix(in srgb, var(--surface) 96%, transparent);
    display: flex;
    border-top: 1px solid var(--border);
    z-index: 1001;
    padding-bottom: env(safe-area-inset-bottom, 0);
    box-shadow: 0 -8px 24px rgba(23, 35, 52, 0.08);
    backdrop-filter: blur(14px);
  }

  .mobile-nav-item {
    position: relative;
    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-item.active::before {
    content: '';
    position: absolute;
    top: -1px;
    left: 28%;
    right: 28%;
    height: 2px;
    border-radius: 0 0 2px 2px;
    background: 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: 78vh;
    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% - 44px));
    transition: transform 0.3s ease;
    background: var(--surface);
    padding: 0 0 calc(16px + env(safe-area-inset-bottom, 0));
  }

  .search-container {
    padding: 0 var(--sp-3) var(--sp-3);
  }

  .filter-panel {
    margin: 0 var(--sp-3) var(--sp-3);
  }

  #info-default,
  #info-detail {
    margin-inline: var(--sp-3);
  }

  .overview-strip {
    grid-template-columns: 1fr;
  }

  .overview-route-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .overview-route-card__facts {
    grid-template-columns: 1fr;
  }

  .info-tabs-bar {
    position: static;
    margin-inline: 0;
    padding: 0;
    backdrop-filter: none;
  }

  .tab-baseline > div {
    grid-template-columns: 1fr;
    gap: 3px;
  }

  #summary-stats {
    grid-template-columns: 1fr;
  }

  #info:not(.sheet-half):not(.sheet-full) {
    overflow: hidden;
  }

  #info:not(.sheet-half):not(.sheet-full)::after {
    content: attr(data-sheet-hint);
    position: absolute;
    top: 25px;
    left: 50%;
    transform: translateX(-50%);
    width: max-content;
    max-width: calc(100% - 32px);
    color: var(--text-muted);
    font-size: 11px;
    font-weight: 650;
    white-space: nowrap;
  }

  #info:not(.sheet-half):not(.sheet-full) > :not(.sheet-handle) {
    visibility: hidden;
  }

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

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

  /* -- Sheet Handle -- */
  .sheet-handle {
    display: block;
    position: relative;
    width: 64px;
    height: 32px;
    margin: 0 auto;
    padding: 0;
    border: 0;
    background: transparent;
    flex-shrink: 0;
    cursor: pointer;
  }

  .sheet-handle::before {
    content: '';
    position: absolute;
    top: 12px;
    left: 12px;
    right: 12px;
    height: 4px;
    border-radius: 2px;
    background: var(--border);
  }

  /* -- KPI strip inside bottom sheet for collapsed state -- */
  .mobile-kpi-strip {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    align-items: center;
    padding: 0 var(--sp-3) var(--sp-2);
    gap: 0;
  }

  #info:not(.sheet-half):not(.sheet-full) .mobile-kpi-strip {
    display: none;
  }

  .mobile-kpi-strip .kpi-card {
    min-width: 0;
    padding: 2px var(--sp-1);
    border-left: 1px solid var(--border-light);
  }

  .mobile-kpi-strip .kpi-card:first-child { border-left: 0; }

  .mobile-kpi-strip .kpi-label {
    font-size: 10px;
    line-height: 1.2;
    min-height: 24px;
  }

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

  #info .nav-tabs-sm .nav-link,
  #info .info-tabs-more__toggle {
    min-height: 44px;
    padding: 8px 7px;
    font-size: 11px;
  }

  #map-first-action {
    bottom: 64px;
    font-size: 11px;
  }

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

  body.ranking-open #main-content {
    bottom: var(--footer-h);
  }

  /* -- Keep the legend on the map, away from the bottom sheet -- */
  #legend {
    right: var(--sp-3);
    top: calc(var(--shell-h) + var(--sp-3));
    bottom: auto;
    left: auto;
    max-width: 180px;
  }

  #legend.legend-collapsed {
    width: 38px;
    height: 38px;
    max-width: 38px;
    border-radius: var(--radius-lg);
  }

  #legend.legend-collapsed #legend-toggle {
    width: 38px;
    height: 38px;
    display: grid;
    place-items: center;
    padding: 0;
  }

  /* -- 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;
  }

  .search-dropdown {
    top: auto;
    bottom: calc(100% + 2px);
    max-height: min(38vh, 260px);
    border: 1px solid var(--border);
    border-radius: var(--radius);
  }

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

  .overview-card__footer,
  .overview-route-card__footer {
    flex-direction: column;
    align-items: stretch;
  }

  .overview-route-card__action {
    width: 100%;
  }

  .detail-header__top {
    flex-direction: column;
    align-items: stretch;
  }

  .detail-header__meta {
    min-width: 0;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .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);
    width: 100%;
    border: 0;
    border-bottom: 1px solid var(--border-light);
    background: transparent;
    cursor: pointer;
    min-height: 48px;
    font-family: inherit;
    font-size: 14px;
    color: var(--text);
    text-align: left;
    -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;
  }
}

@media (max-width: 480px) {
  .overview-route-strip {
    grid-template-columns: 1fr;
  }
}

/* ========== 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: var(--on-primary);
  border-color: var(--primary);
}
#btn-compare.compare-active {
  background: var(--primary);
  color: var(--on-primary);
  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;
}

.compare-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 10px;
}
.compare-summary div,
.compare-delta {
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  background: var(--surface-alt);
  padding: 8px 10px;
}
.compare-summary strong {
  display: block;
  color: var(--text);
  font-size: 15px;
  line-height: 1.1;
}
.compare-summary span,
.compare-delta span {
  display: block;
  margin-top: 2px;
  color: var(--text-muted);
  font-size: 10px;
  line-height: 1.35;
}
.compare-deltas {
  display: grid;
  gap: 6px;
  margin-bottom: 12px;
}
.compare-delta strong {
  display: block;
  margin-top: 3px;
  color: var(--text);
  font-size: 11px;
  line-height: 1.35;
}

/* Comparison table */
.compare-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}
.compare-table-wrap {
  overflow-x: auto;
}
.compare-empty {
  color: var(--text-muted);
  padding: 16px;
}
.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;
}
.group-tone-a { background: #315f9f; }
.group-tone-b { background: #086d72; }
.group-tone-c { background: #946218; }

/* 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;
}
.compare-tone-0 { background: #315f9f; }
.compare-tone-1 { background: #086d72; }
.compare-tone-2 { background: #946218; }
.compare-tone-3 { background: #6b778c; }
.compare-tone-4 { background: #8c4a7e; }

/* 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-empty {
  font-size: 10px;
  color: var(--text-faint);
}
.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: 0 0 var(--sp-3);
}
.search-input-wrap {
  display: flex;
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  min-height: 40px;
  padding: 0 10px;
  gap: 7px;
}
.search-icon { flex-shrink: 0; }
.search-input {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  font: inherit;
  font-size: 14px;
  padding: 8px 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: 100%;
  left: 0;
  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-item:focus-visible { outline: 2px solid var(--primary); outline-offset: -2px; }
.search-empty { padding: 10px; color: var(--text-muted); font-size: 13px; }
.search-empty.search-error { color: var(--danger, #b42318); }
.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: 0 0 var(--sp-3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-alt);
}
.filter-header {
  min-height: 38px;
  padding: 8px 10px;
  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; }

/* === 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: var(--on-primary); 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-card {
  margin-bottom: 8px;
  padding: 6px;
  border: 1px solid var(--border-light);
  border-radius: 4px;
  cursor: pointer;
  background: var(--surface);
}
.rol-doc-card:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}
.rol-doc-title { font-weight: 600; font-size: 13px; }
.rol-doc-version { font-size: 11px; color: var(--text-muted); }
.rol-doc-meta {
  font-size: 11px;
  color: var(--text-muted);
}
.rol-doc-meta--spaced { margin-bottom: 6px; }
.rol-toolbar { margin-bottom: 6px; }
.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; }

/* === Small Mobile (≤375px) === */
@media (max-width: 375px) {
  .mobile-nav-item small { font-size: 10px; }
  .mobile-nav-icon { font-size: 18px; }
  .mobile-kpi-strip .kpi-value { font-size: 12px; }
  .mobile-kpi-strip .kpi-label { font-size: 9px; }
  #legend { max-width: 150px; font-size: 11px; }
  .sheet-handle { width: 56px; }
  #info .nav-tabs-sm .nav-link { font-size: 10px; padding: 7px 5px; }
  .overview-route-strip { grid-template-columns: 1fr; }
  .overview-route-card__facts { grid-template-columns: 1fr; }
}

/* === Report / Passport Tab === */
.report-passport-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  font-size: 13px;
  font-weight: 600;
  color: var(--on-primary);
  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: var(--on-primary);
}
.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);
}

.report-evidence-list {
  display: grid;
  gap: 8px;
}

.report-evidence {
  padding: 10px 12px;
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  background: var(--surface-alt);
}

.report-evidence h4 {
  margin: 0 0 5px;
  color: var(--text);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.4;
}

.report-evidence p {
  margin: 0 0 5px;
  color: var(--text-muted);
  font-size: 11px;
  line-height: 1.4;
}

.report-evidence a {
  color: var(--primary);
  font-size: 11px;
  font-weight: 700;
  text-decoration: none;
}

.report-evidence a:hover,
.report-evidence a:focus {
  text-decoration: underline;
}

.report-limitations {
  margin: 0;
  padding-left: 18px;
  color: var(--text-muted);
  font-size: 11px;
  line-height: 1.5;
}

/* === Large Desktop (≥1440px) === */
@media (min-width: 1440px) {
  :root {
    --info-w: clamp(460px, 22vw, 640px);
  }
  .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 {
    --controls-h: 56px;
    --kpi-h: 60px;
  }
  body { font-size: 16px; }
  #info { padding: 24px 28px; }
  .info-tabs-bar {
    top: -24px;
    margin-inline: -28px;
    padding-inline: 28px;
  }
  .detail-oblast { font-size: 28px; }
  .metric-label,
  .metric-provenance { font-size: 12px; }
  .metric-value { font-size: 20px; }
  .kpi-value { font-size: 26px; }
  .kpi-label { font-size: 12px; letter-spacing: 0; }
  .select-wrapper select { font-size: 15px; }
  .control-label { font-size: 12px; }
  #ranking-panel {
    left: 0;
    right: var(--info-w);
    width: auto;
  }
}


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

/* AV DS precision pass: keep the analytical workspace calm while giving each
   control and evidence surface a deliberate elevation and focus state. */
:root {
  --shadow-card: 0 10px 28px rgba(23, 35, 52, 0.065), 0 2px 7px rgba(23, 35, 52, 0.035);
  --shadow-card-hover: 0 16px 34px rgba(23, 35, 52, 0.1), 0 3px 10px rgba(23, 35, 52, 0.045);
  --shadow-brand: 0 7px 16px color-mix(in srgb, var(--primary) 19%, transparent);
  --radius-lg: 12px;
}

html.dark {
  --shadow-card: 0 12px 30px rgba(0, 0, 0, 0.22), 0 2px 8px rgba(0, 0, 0, 0.16);
  --shadow-card-hover: 0 16px 36px rgba(0, 0, 0, 0.3), 0 3px 11px rgba(0, 0, 0, 0.2);
  --shadow-brand: 0 8px 18px color-mix(in srgb, var(--primary) 18%, transparent);
}

.qazgeo-shell {
  box-shadow: 0 1px 0 color-mix(in srgb, var(--border) 58%, transparent),
    0 9px 24px color-mix(in srgb, var(--text) 5%, transparent);
}

.qazgeo-mark {
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--surface) 24%, transparent),
    0 4px 10px color-mix(in srgb, var(--primary) 14%, transparent);
}

.qazgeo-shell nav a[aria-current="page"]::after {
  height: 3px;
  border-radius: 999px 999px 0 0;
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--primary) 10%, transparent);
}

#controls-bar {
  box-shadow: 0 1px 0 color-mix(in srgb, var(--border) 42%, transparent),
    0 8px 18px color-mix(in srgb, var(--text) 5%, transparent);
}

#kpi-strip {
  box-shadow: 0 1px 0 color-mix(in srgb, var(--border) 38%, transparent),
    0 7px 18px color-mix(in srgb, var(--text) 4%, transparent);
}

#info {
  box-shadow: -18px 0 34px color-mix(in srgb, var(--text) 8%, transparent);
}

.overview-card,
.overview-route-card,
.summary-card,
.mapregion-compare-panel,
.mapregion-runtime,
.road-card,
.strata-top-item,
.sparkline-chart,
.history-latest > div {
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  transition: border-color var(--transition), box-shadow var(--transition), transform var(--transition);
}

.overview-card__action,
.overview-route-card__action,
#btn-compare,
.theme-toggle-btn,
.toolbar-menu .btn,
.select-wrapper select {
  box-shadow: 0 1px 2px color-mix(in srgb, var(--text) 7%, transparent);
}

.btn-primary,
.btn.active,
.btn-check:checked + .btn,
.btn-outline-secondary.active,
#btn-compare.compare-active {
  box-shadow: var(--shadow-brand) !important;
}

:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--primary) 30%, transparent);
  outline-offset: 3px;
}

.map-load-state {
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
}

.leaflet-control-zoom {
  box-shadow: var(--shadow-card) !important;
}

@media (hover: hover) {
  .overview-card:hover,
  .overview-route-card:hover,
  .summary-card:hover,
  .mapregion-compare-panel:hover,
  .mapregion-runtime:hover,
  .road-card:hover,
  .strata-top-item:hover,
  .sparkline-chart:hover,
  .history-latest > div:hover {
    border-color: color-mix(in srgb, var(--primary) 26%, var(--border-light));
    box-shadow: var(--shadow-card-hover);
  }
}

/* Map surface states: the canvas remains intentional while tiles or region
   geometry are loading, and the interaction rail reads as one instrument. */
#map {
  background:
    radial-gradient(circle at 20% 18%, color-mix(in srgb, var(--primary-soft) 68%, transparent), transparent 35%),
    linear-gradient(145deg, color-mix(in srgb, var(--surface-alt) 78%, var(--surface)), var(--surface));
}

html.dark #map {
  background:
    radial-gradient(circle at 20% 18%, color-mix(in srgb, var(--primary-soft) 58%, transparent), transparent 35%),
    linear-gradient(145deg, color-mix(in srgb, var(--bg-card) 86%, var(--bg)), var(--bg));
}

#map-load-state,
#map-first-action {
  border-radius: var(--radius-lg);
  background: color-mix(in srgb, var(--surface) 91%, transparent);
  box-shadow: var(--shadow-card);
  backdrop-filter: blur(14px) saturate(1.12);
}

#map-load-state {
  border-color: color-mix(in srgb, var(--primary) 24%, var(--border));
}

#map-load-state .map-load-state__marker {
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--success) 13%, transparent),
    0 0 0 8px color-mix(in srgb, var(--success) 5%, transparent);
}

#map-first-action {
  padding-inline: 14px;
  color: var(--text);
  font-weight: 650;
}

.search-input-wrap {
  border-radius: 10px;
  box-shadow: 0 3px 12px color-mix(in srgb, var(--text) 5%, transparent);
  transition: border-color var(--transition), box-shadow var(--transition), background var(--transition);
}

.search-input-wrap:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--primary) 13%, transparent),
    0 6px 16px color-mix(in srgb, var(--text) 7%, transparent);
}

.filter-panel {
  border-radius: 10px;
  box-shadow: 0 3px 12px color-mix(in srgb, var(--text) 4%, transparent);
}

.filter-header:focus-visible,
.filter-clear-btn:focus-visible,
.search-clear:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--primary) 26%, transparent);
  outline-offset: 2px;
}

.kpi-value {
  letter-spacing: -0.02em;
}

@media (max-width: 767.98px) {
  .mobile-nav {
    box-shadow: 0 -12px 28px color-mix(in srgb, var(--text) 11%, transparent);
  }

  .mobile-nav-item {
    border-radius: 10px 10px 0 0;
    transition: color var(--transition), background var(--transition);
  }

  .mobile-nav-item.active {
    background: color-mix(in srgb, var(--primary-soft) 56%, transparent);
  }

  .mobile-nav-item.active::before {
    left: 24%;
    right: 24%;
    height: 3px;
    box-shadow: 0 0 0 2px color-mix(in srgb, var(--primary) 10%, transparent);
  }

  #info {
    border-top: 1px solid color-mix(in srgb, var(--primary) 20%, var(--border));
    box-shadow: 0 -12px 32px color-mix(in srgb, var(--text) 13%, transparent);
  }

  .sheet-handle::before {
    background: linear-gradient(90deg, color-mix(in srgb, var(--border) 72%, transparent), var(--primary), color-mix(in srgb, var(--border) 72%, transparent));
  }

  .mobile-kpi-strip {
    padding-top: 4px;
  }

}

/* 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; }

.clipboard-fallback-input {
  position: fixed;
  opacity: 0;
  pointer-events: none;
}

/* AV DS precision pass 02: mapregion keeps its fixed analytical canvas, but
   the control rail and detail sheet now share the same measured rhythm as
   the catalogue pages. */
:root {
  --shell-h: 60px;
  --controls-h: 56px;
  --kpi-h: 68px;
  --info-w: 432px;
  --panel-bg: rgba(255, 255, 255, 0.95);
  --shadow-page: 0 20px 56px rgba(23, 35, 52, 0.07);
}

html.dark {
  --panel-bg: rgba(24, 30, 36, 0.97);
  --shadow-page: 0 20px 56px rgba(0, 0, 0, 0.27);
}

body {
  background:
    radial-gradient(circle at 50% -12%, color-mix(in srgb, var(--primary-soft) 48%, transparent), transparent 42%),
    linear-gradient(180deg, #f7fafc 0, var(--bg) 340px);
}

html.dark body { background: var(--bg); }

.qazgeo-shell {
  height: var(--shell-h);
  padding-inline: 24px;
  gap: 32px;
  border-bottom-color: color-mix(in srgb, var(--border) 78%, transparent);
  box-shadow: 0 1px 0 color-mix(in srgb, var(--border) 42%, transparent), 0 10px 28px color-mix(in srgb, var(--text) 5%, transparent);
}

.qazgeo-brand { font-size: 16px; }
.qazgeo-mark { width: 24px; height: 24px; border-radius: 6px; }
.qazgeo-shell nav { gap: 6px; }
.qazgeo-shell nav a { padding-inline: 11px; font-size: 12px; }
.qazgeo-live { font-size: 11px; }

#controls-bar {
  height: var(--controls-h);
  padding-inline: 22px;
  box-shadow: 0 1px 0 color-mix(in srgb, var(--border) 42%, transparent), 0 10px 22px color-mix(in srgb, var(--text) 5%, transparent);
}

.select-wrapper select { min-height: 38px; padding-inline: 11px 32px; border-radius: 9px; background: color-mix(in srgb, var(--surface-alt) 78%, var(--surface)); }
.toolbar-menu .btn,
#btn-compare { min-height: 38px; border-radius: 9px !important; }

#kpi-strip {
  height: var(--kpi-h);
  background: color-mix(in srgb, var(--surface-alt) 74%, var(--surface));
  box-shadow: 0 1px 0 color-mix(in srgb, var(--border) 38%, transparent), 0 10px 24px color-mix(in srgb, var(--text) 4%, transparent);
}

.kpi-card { min-width: 148px; padding-inline: 20px; }
.kpi-label { font-size: 10px; letter-spacing: 0.045em; }
.kpi-value { margin-top: 2px; font-size: 21px; letter-spacing: -0.03em; }
.kpi-divider { height: 32px; background: color-mix(in srgb, var(--border) 82%, transparent); }

#map {
  background:
    radial-gradient(circle at 18% 16%, color-mix(in srgb, var(--primary-soft) 72%, transparent), transparent 34%),
    linear-gradient(145deg, color-mix(in srgb, var(--surface-alt) 82%, var(--surface)), var(--surface));
}

.leaflet-tile-pane { filter: saturate(0.54) brightness(1.035) contrast(0.99); }
.leaflet-control-zoom { border-radius: 9px !important; box-shadow: var(--shadow-page) !important; }
.leaflet-control-zoom a { width: 32px !important; height: 32px !important; line-height: 32px !important; }

#info {
  width: var(--info-w);
  padding: 24px 24px 28px;
  background: linear-gradient(180deg, color-mix(in srgb, var(--surface-alt) 68%, var(--surface)) 0, var(--surface) 220px);
  box-shadow: -20px 0 38px color-mix(in srgb, var(--text) 8%, transparent);
}

.info-title { margin-bottom: 6px; font-size: 22px; letter-spacing: -0.02em; }
.info-hint { max-width: 360px; font-size: 13px; line-height: 1.52; }
.search-input-wrap,
.filter-panel,
.overview-card,
.overview-route-card,
.summary-card { border-radius: 11px; }
.search-input-wrap { box-shadow: 0 5px 16px color-mix(in srgb, var(--text) 5%, transparent); }
.filter-panel { margin-top: 12px; box-shadow: 0 5px 16px color-mix(in srgb, var(--text) 4%, transparent); }
.filter-match-count.is-empty,
#filter-count.is-empty { color: var(--amber, #a46900); font-weight: 760; }
.overview-strip { gap: 12px; margin-top: 16px; }
.overview-card { padding: 14px; }
.overview-card__note { max-width: 330px; line-height: 1.45; }

@media (max-width: 1023.98px) {
  .qazgeo-shell { padding-inline: 18px; gap: 22px; }
  #controls-bar { padding-inline: 16px; }
  .kpi-card { min-width: 132px; padding-inline: 14px; }
  #info { width: min(var(--info-w), 40vw); padding-inline: 20px; }
}

@media (max-width: 767.98px) {
  :root { --shell-h: 56px; --controls-h: 52px; --kpi-h: 56px; --info-w: 100%; }
  .qazgeo-shell { padding-inline: 12px; gap: 12px; }
  #controls-bar { padding-inline: 12px; }
  #kpi-strip { justify-content: flex-start; overflow-x: auto; }
  .kpi-card { min-width: 128px; padding-inline: 12px; }
  .kpi-value { font-size: 18px; }
  /* The tablet precision rule above caps the panel at 40vw.  On phones the
     sheet is the primary detail surface and must span the viewport. */
  #info { width: 100%; max-width: 100%; min-width: 0; padding: 18px 16px 24px; }
}

/* Route polish 02A – MapRegion analytical canvas. Keep the fixed map/detail
   split, but make the analytical hierarchy visible before the user opens a
   deeper tab or filter. */
#controls-bar .controls-left { gap: 10px; }
#controls-bar .controls-right { gap: 8px; }
#controls-bar .controls-right > * { flex: 0 0 auto; }
#btn-compare {
  border-color: color-mix(in srgb, var(--primary) 28%, var(--border)) !important;
  background: color-mix(in srgb, var(--primary-soft) 48%, var(--surface)) !important;
  color: var(--primary-strong) !important;
}
#btn-compare:hover,
#btn-compare:focus-visible {
  background: var(--primary-soft) !important;
}
#info-default { padding-top: 2px; }
#info-default .info-title { margin-top: 2px; }
#info-default .info-hint { margin-bottom: 14px; }
#info-default > .overview-strip { margin-top: 14px; }
#info .overview-card,
#info .overview-route-card,
#info .summary-card {
  background: linear-gradient(180deg, color-mix(in srgb, var(--surface-tint) 34%, var(--surface)), var(--surface));
}
#info .overview-card__action,
#info .overview-route-card__action { border-radius: 999px; }
#map-first-action { border-color: color-mix(in srgb, var(--primary) 24%, var(--border)); }
.mapregion-compare-panel,
.mapregion-runtime { border-top: 3px solid var(--primary); }
.mapregion-compare-panel__badge { background: var(--primary-soft); color: var(--primary-strong); }

@media (max-width: 767.98px) {
  #controls-bar .controls-right { gap: 6px; }
}


/* === 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;
  }
}
