:root {
  --ink: #17201c;
  --muted: #65736d;
  --paper: #fffaf1;
  --panel: #fffdf8;
  --line: #e4ded2;
  --accent: #0f7b66;
  --accent-dark: #085747;
  --municipal: #1976d2;
  --private: #da7b0b;
  --commercial: #0f9f72;
  --event: #c23764;
  --regional: #5b6c2d;
  --strike: #2f3136;
  --panel-width: 540px;
  font-family: "Aptos", "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  height: 100%;
}

body {
  margin: 0;
  height: 100%;
  min-height: 0;
  overflow: hidden;
  color: var(--ink);
  background:
    radial-gradient(circle at 18% 8%, rgba(15, 123, 102, 0.16), transparent 34%),
    linear-gradient(135deg, #f7eedc 0%, #eef5ed 48%, #f8f4e9 100%);
}

a {
  text-decoration: none;
  color: #464feb;
}

tr th, tr td {
  border: 1px solid #e6e6e6;
}

tr th {
  background-color: #f5f5f5;
}

button,
input {
  font: inherit;
}

.app-shell {
  display: grid;
  grid-template-columns: var(--panel-width) 1fr;
  height: 100vh;
  height: 100dvh;
  min-height: 0;
  overflow: hidden;
}

.app-shell.panel-collapsed {
  grid-template-columns: 0 1fr;
}

.menu-toggle,
.sources-toggle,
.sources-close {
  border: 0;
  cursor: pointer;
  font-weight: 800;
}

.menu-toggle {
  display: none;
}

.menu-backdrop {
  display: none;
}

.panel {
  container-type: inline-size;
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 26px;
  background: rgba(255, 253, 248, 0.94);
  border-right: 1px solid var(--line);
  box-shadow: 0 18px 60px rgba(53, 46, 33, 0.12);
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  z-index: 2;
}

.panel-collapsed .panel {
  visibility: hidden;
  pointer-events: none;
  transform: translateX(-100%);
}

.brand-block {
  position: relative;
  display: grid;
  gap: 8px;
  padding-right: 140px;
}

.eyebrow {
  margin: 0;
  color: var(--accent-dark);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(1.7rem, 2.2vw, 2.6rem);
  line-height: 1.02;
  letter-spacing: 0;
}

h2 {
  font-size: 1rem;
}

.intro {
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.45;
}

.site-nav {
  position: absolute;
  top: 0;
  right: 0;
  display: grid;
  gap: 6px;
}

.site-nav a,
.site-nav .language-toggle {
  min-width: 58px;
  min-height: 30px;
  padding: 6px 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--accent-dark);
  font-size: 0.78rem;
  font-weight: 800;
  text-align: center;
}

.site-nav a:hover,
.site-nav .language-toggle:hover {
  background: #e7f2ee;
}

.site-nav .potholes-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.site-nav .potholes-link img {
  width: 17px;
  height: 17px;
  flex: 0 0 17px;
}

.site-nav .compact-nav-icon {
  display: none;
}

.site-nav a.missing-restrictions-link {
  flex: 0 0 auto;
  width: 90px;
  padding: 5px 7px;
  font-size: 0.68rem;
  line-height: 1.2;
  text-align: center;
}

.site-nav a.is-current {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

.site-nav .language-toggle {
  border-color: var(--accent-dark);
  background: var(--accent-dark);
  color: #fff;
  cursor: pointer;
}

.site-nav .visual-assist-toggle {
  display: none;
  min-height: 30px;
  padding: 6px 9px;
  border: 1px solid var(--accent-dark);
  border-radius: 8px;
  background: #fff;
  color: var(--accent-dark);
  font-size: 0.74rem;
  font-weight: 800;
  cursor: pointer;
}

.accessible-list-panel[hidden] {
  display: none !important;
}

.accessible-list-panel:focus {
  outline: none;
}

.accessible-list-panel .section-content {
  margin-top: 0;
}

.controls {
  display: grid;
  gap: 12px;
}

.map-mode-nav {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(0, 1fr);
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 6px;
}

.map-mode-nav a {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 40px;
  padding: 6px;
  border-radius: 4px;
  color: var(--accent-dark);
  font-weight: 700;
}

.map-mode-nav a:hover {
  background: #e7f2ee;
}

.map-mode-nav svg {
  width: 24px;
  height: 24px;
}

.map-mode-nav a[aria-current="page"] {
  background: var(--accent-dark);
  color: #fff;
}

.install-app:not([hidden]) {
  display: grid;
  justify-items: start;
  gap: 6px;
  position: absolute;
  right: 18px;
  bottom: 76px;
  z-index: 1050;
}

.install-app button {
  min-height: 30px;
  padding: 3px 8px;
  border: 1px solid var(--accent-dark);
  border-radius: 6px;
  background: #fffdf8;
  color: var(--accent-dark);
  font: inherit;
  font-size: 0.76rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 10px 26px rgba(20, 29, 26, 0.16);
}

.install-app p {
  position: absolute;
  right: 0;
  bottom: calc(100% + 8px);
  width: min(280px, calc(100vw - 36px));
  margin: 0;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fffdf8;
  color: var(--ink);
  font-size: 0.82rem;
  box-shadow: 0 10px 26px rgba(20, 29, 26, 0.16);
}

@media (max-width: 1200px) {
  .install-app:not([hidden]) {
    bottom: 154px;
  }
}

@media (max-width: 880px) {
  .install-app:not([hidden]) {
    bottom: 68px;
  }

  .install-app button {
    display: grid;
    grid-template-columns: 22px 70px;
    align-items: center;
    gap: 4px;
    min-height: 48px;
    padding: 4px 7px;
    text-align: left;
  }

  .install-app button span:first-child {
    font-size: 1.9rem;
    line-height: 1;
    transform: scaleY(1.2);
  }

  .install-app button span:last-child {
    line-height: 1.15;
  }

  html[lang="en"] .install-app button span:last-child {
    max-width: 44px;
  }
}

body[data-map-mode="pedestrian"] h1 {
  font-size: 1.9rem;
  overflow-wrap: anywhere;
}

body[data-map-mode="pedestrian"] .brand-block {
  padding-right: 110px;
}

body[data-map-mode="pedestrian"] #mapFirstVisitHint {
  display: none;
}

.date-range-fields {
  position: relative;
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 10px;
  align-items: end;
}

.today-button {
  grid-column: 1 / -1;
  min-height: 42px;
  padding-inline: 12px;
  white-space: nowrap;
}

.icon-help {
  width: 38px;
  height: 42px;
  padding: 0;
  border-radius: 999px;
  background: #17201c;
  color: #fff;
  line-height: 1;
}

.date-range-fields > .icon-help {
  align-self: end;
  margin-bottom: 9px;
}

.date-label-with-help {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.date-label-with-help .icon-help {
  position: static !important;
  flex: 0 0 24px;
  width: 24px;
  height: 24px;
  min-height: 24px;
  margin: 0 !important;
}

.help-bubble {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  width: min(320px, 100%);
  padding: 12px 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 16px 34px rgba(20, 29, 26, 0.18);
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.4;
  z-index: 20;
}

.help-bubble p + p {
  margin-top: 8px;
}

.filter-title {
  color: var(--ink);
  font-size: 0.86rem;
  text-transform: uppercase;
}

.filter-heading {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
}

.filter-section {
  min-width: 0;
}

.filter-section > summary {
  min-height: 40px;
  flex-wrap: nowrap;
  cursor: pointer;
  list-style: none;
  border-radius: 4px;
}

.filter-section > summary::-webkit-details-marker {
  display: none;
}

.filter-section > summary::after {
  content: "\25BC";
  flex: 0 0 20px;
  margin-left: auto;
  color: var(--accent-dark);
  font-size: 0.65rem;
  text-align: center;
}

.filter-section[open] > summary::after {
  content: "\25B2";
}

.filter-section > summary:hover {
  background: #e7f2ee;
}

.filter-section > summary:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.section-content {
  margin-top: 8px;
}

.icon-help.small {
  flex: 0 0 24px;
  width: 24px;
  height: 24px;
  min-height: 24px;
  font-size: 0.78rem;
}

.filter-help {
  left: 0;
  right: auto;
  top: calc(100% + 8px);
  width: min(390px, 100%);
}

.field {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 700;
}

.field input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 11px 12px;
  background: #fff;
  color: var(--ink);
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.toggle-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.source-filters {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.toggle-grid label {
  display: flex;
  min-height: 42px;
  align-items: center;
  gap: 8px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  font-size: 0.86rem;
  line-height: 1.2;
}

@container (max-width: 380px) {
  .toggle-grid,
  .source-filters {
    grid-template-columns: 1fr;
  }
}

@container (max-width: 440px) {
  .panel {
    padding: 18px;
    gap: 14px;
  }

  .date-range-fields {
    grid-template-columns: 1fr;
  }

  .date-range-fields .icon-help {
    position: absolute;
    top: 50px;
    left: 70px;
    margin: 0;
  }

  .filter-heading {
    flex-wrap: wrap;
  }

}

@container (max-width: 330px) {
  .panel {
    padding: 14px;
  }

  .toggle-grid,
  .source-filters {
    grid-template-columns: 1fr;
  }

  .brand-block {
    padding-right: 0;
  }

  .site-nav {
    position: static;
    grid-template-columns: repeat(3, 1fr);
  }

  .site-nav a,
  .site-nav .language-toggle {
    min-width: 0;
  }

  h1 {
    font-size: 1.55rem;
  }
}

.panel-resize-handle {
  position: fixed;
  top: 50%;
  left: calc(var(--panel-width) - 15px);
  width: 30px;
  height: 30px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--panel);
  box-shadow: 0 4px 12px rgba(20, 29, 26, 0.16);
  cursor: ew-resize;
  z-index: 1300;
  transform: translateY(-50%);
}

.panel-resize-handle::before {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--accent-dark);
  content: "↔";
  font-size: 1.1rem;
  font-weight: 900;
  line-height: 1;
}

.panel-resize-handle:hover,
.is-resizing-panel .panel-resize-handle {
  background: rgba(15, 123, 102, 0.16);
}

.is-resizing-panel {
  cursor: ew-resize;
  user-select: none;
}

.panel-collapsed .panel-resize-handle {
  display: none;
}

@media (min-width: 881px) {
  .panel {
    padding-top: 14px;
  }

  .brand-block {
    padding-top: 0;
    padding-right: 0;
  }

  /* In the flow beside the fixed menu button so it wraps instead of overflowing a narrowed panel. */
  .panel .brand-block .site-nav {
    position: static;
    order: -1;
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    align-items: center;
    gap: 6px;
    min-height: 44px;
    margin-left: 44px;
    margin-right: -8px;
    width: auto;
  }

  .panel .brand-block .site-nav > * {
    flex: 0 0 auto;
  }

  .site-nav a,
  .site-nav .language-toggle {
    min-width: 48px;
    padding-inline: 7px;
  }

  .date-range-fields .field:has(.date-label-with-help) {
    position: relative;
  }

  .date-range-fields .field:has(.date-label-with-help) .date-label-with-help .icon-help {
    position: absolute !important;
    right: -26px;
    bottom: 9px;
  }

  .menu-toggle {
    position: fixed;
    top: 14px;
    left: 14px;
    display: grid;
    place-content: center;
    gap: 4px;
    width: 44px;
    height: 44px;
    padding: 0;
    border-radius: 8px;
    background: #fffdf8;
    box-shadow: 0 10px 26px rgba(20, 29, 26, 0.2);
    z-index: 1300;
  }

  .menu-toggle span {
    display: block;
    width: 21px;
    height: 2px;
    background: var(--ink);
    transition: transform 180ms ease, opacity 180ms ease;
  }

  .menu-toggle.is-open {
    background: var(--accent);
  }

  .menu-toggle.is-open span {
    background: #fff;
  }

  .menu-toggle.is-open span:nth-child(1) {
    transform: translateY(6px) rotate(45deg);
  }

  .menu-toggle.is-open span:nth-child(2) {
    opacity: 0;
  }

  .menu-toggle.is-open span:nth-child(3) {
    transform: translateY(-6px) rotate(-45deg);
  }

  .panel-collapsed .menu-toggle {
    background: #fffdf8;
  }

  .panel-collapsed .site-nav {
    display: none;
  }
}

.impact-dot {
  width: 13px;
  height: 13px;
  border-radius: 999px;
  display: inline-block;
  flex: 0 0 auto;
  box-shadow: 0 0 0 2px #fff, 0 0 0 3px rgba(23, 32, 28, 0.18);
}

.impact-dot.critical { background: #ff1744; }
.impact-dot.major { background: #ff8c00; }
.impact-dot.moderate { background: #ffe600; }
.impact-dot.parking { background: #ff2bd6; }

.leaflet-marker-icon.closure-point-hit-target {
  border: 0 !important;
  background: transparent !important;
  box-shadow: none !important;
  opacity: 0;
  pointer-events: auto;
}

.impact-count {
  margin-left: auto;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 900;
}

.summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f6f0e4;
}

.summary strong {
  display: block;
  font-size: 1.85rem;
  line-height: 1;
}

.summary span {
  color: var(--muted);
  font-size: 0.84rem;
}

button {
  border: 0;
  border-radius: 8px;
  padding: 10px 12px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  font-weight: 800;
}

button:hover {
  background: var(--accent-dark);
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  color: var(--muted);
  font-size: 0.82rem;
}

.legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.severity-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.map-legend {
  position: absolute;
  bottom: 18px;
  left: 18px;
  max-width: calc(100% - 152px);
  padding: 9px;
  border: 1px solid rgba(255, 255, 255, 0.72);
  border-radius: 8px;
  background: rgba(255, 253, 248, 0.94);
  box-shadow: 0 10px 26px rgba(20, 29, 26, 0.16);
  pointer-events: none;
  z-index: 520;
}

.map-legend[hidden],
.map-legend .severity-chip[hidden] {
  display: none;
}

.severity-chip {
  min-height: 28px;
  border-radius: 999px;
  padding: 5px 9px;
  color: #fff;
  font-size: 0.78rem;
  font-weight: 900;
}

.severity-chip.critical {
  background: #ff1744;
}

.severity-chip.major {
  background: #ff8c00;
}

.severity-chip.moderate {
  background: #ffe600;
  color: #17201c;
}

.severity-chip.parking {
  background: #ff2bd6;
}


.municipality-section {
  display: grid;
  gap: 10px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.municipality-section[hidden] {
  display: none !important;
}

.municipality-section h2 {
  font-size: 0.95rem;
}

.section-note {
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.4;
}

.municipality-list {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 7px;
}

.municipality-link {
  display: grid;
  gap: 3px;
  min-width: 0;
  padding: 8px 9px;
  border: 1px solid #e6e6e6;
  border-radius: 8px;
  background: #fbfaf6;
  color: #464feb;
  font-size: 0.82rem;
  font-weight: 800;
  line-height: 1.2;
}

.municipality-link strong {
  color: #464feb;
  font-size: 0.82rem;
}

.municipality-link span {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
}

.municipality-link em {
  width: fit-content;
  border-radius: 999px;
  padding: 2px 6px;
  background: #eef4ef;
  color: #24413a;
  font-size: 0.68rem;
  font-style: normal;
  font-weight: 900;
}

.municipality-link:hover {
  background: #f1f3ff;
}

.swatch {
  width: 11px;
  height: 11px;
  border-radius: 999px;
  display: inline-block;
}

.municipal { background: var(--municipal); }
.private { background: var(--private); }
.commercial { background: var(--commercial); }
.event { background: var(--event); }
.regional { background: var(--regional); }
.strike { background: var(--strike); }

.list-section {
  display: grid;
  gap: 10px;
}

.list-search {
  margin-top: -2px;
}

.list-search[hidden] {
  display: none !important;
}

.panel-locate-button {
  min-height: 32px;
  padding: 6px 12px;
  font-size: 0.86rem;
  line-height: 1.2;
}

.closure-list {
  display: grid;
  gap: 10px;
}

.closure-card {
  display: grid;
  gap: 8px;
  padding: 14px;
  border: 1px solid var(--line);
  border-left: 6px solid var(--accent);
  border-radius: 8px;
  background: #fff;
  cursor: pointer;
}

.closure-card:hover,
.closure-card:focus-visible {
  outline: 2px solid rgba(15, 123, 102, 0.28);
}

.closure-card h3 {
  margin: 0;
  font-size: 1rem;
}

.meta {
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.4;
}

.abbr-tooltip {
  position: relative;
  border-bottom: 1px dotted currentColor;
  cursor: help;
  font-weight: 800;
}

.abbr-tooltip::after {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  width: max-content;
  max-width: 240px;
  padding: 6px 8px;
  border-radius: 5px;
  background: #17201c;
  color: #fff;
  content: attr(data-tooltip);
  font-size: 0.76rem;
  font-weight: 600;
  line-height: 1.3;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 4px);
  transition: opacity 0.16s ease, transform 0.16s ease;
  z-index: 20;
}

.abbr-tooltip:hover::after,
.abbr-tooltip:focus-visible::after {
  opacity: 1;
  transform: translate(-50%, 0);
}

.badge-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 3px 8px;
  background: #eef4ef;
  color: #24413a;
  font-size: 0.74rem;
  font-weight: 800;
}

.severity-badge {
  background: #17201c;
  color: #fff;
}

.closure-card[data-severity="critical"] .severity-badge {
  background: #ff1744;
}

.closure-card[data-severity="major"] .severity-badge {
  background: #ff8c00;
}

.closure-card[data-severity="moderate"] .severity-badge {
  background: #ffe600;
  color: #17201c;
}

body[data-map-mode="pedestrian"] .impact-dot.moderate,
body[data-map-mode="pedestrian"] .severity-chip.moderate,
body[data-map-mode="pedestrian"] .closure-card[data-severity="moderate"] .severity-badge {
  background: #ff8c00;
}

.closure-card[data-severity="parking"] .severity-badge {
  background: #ff2bd6;
}

.list-note {
  background: #f6f0e4;
}

.map-zone {
  position: relative;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}

body.view-stats .map-zone,
body.view-stats .map-only {
  display: none !important;
}

body:not(.view-stats) .stats-only,
body.view-stats.stats-dates-all .date-range-fields {
  display: none !important;
}

.stats-date-mode {
  position: relative;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-inline: 0;
  padding: 0;
  border: 0;
}

.stats-date-mode-option {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.stats-date-mode-option label {
  flex: 1;
  min-width: 0;
}

.stats-date-mode .help-bubble {
  left: 0;
  right: 0;
  width: auto;
}

.stats-date-mode label {
  display: flex;
  min-height: 42px;
  align-items: center;
  gap: 8px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  font-size: 0.86rem;
  line-height: 1.2;
  cursor: pointer;
}

.stats-date-mode label:has(input:checked) {
  border-color: var(--accent);
  background: #e7f2ee;
  font-weight: 700;
}

.stats-date-mode input {
  accent-color: var(--accent);
}

@container (max-width: 380px) {
  .stats-date-mode {
    grid-template-columns: 1fr;
  }
}

.stats-view[hidden] {
  display: none !important;
}

.stats-view {
  min-width: 0;
  min-height: 0;
  height: 100%;
  overflow-y: auto;
  background: var(--paper);
}

.stats-inner {
  display: grid;
  gap: 16px;
  padding: 0 16px 40px;
}

/* Same sticky tab dock as the pothole statistics page. */
.stats-dock {
  position: sticky;
  top: 0;
  z-index: 5;
  display: grid;
  justify-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
  background: var(--paper);
}

.stats-tabs {
  width: min(100%, 860px);
  background: var(--panel);
}

.stats-live-note {
  width: min(100%, 860px);
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.4;
  text-align: center;
}

.stats-live-note strong {
  color: var(--ink);
}

.stats-tabs a {
  min-height: 36px;
  padding: 6px 10px;
  font-size: 0.84rem;
  text-align: center;
  text-decoration: none;
}

.stats-header {
  display: grid;
  gap: 6px;
}

.stats-header h1 {
  font-size: clamp(1.4rem, 2vw, 2rem);
}

.stats-scope {
  font-weight: 700;
}

.stats-status {
  color: var(--muted);
  font-size: 0.82rem;
}

.stats-status.is-loading {
  color: var(--accent-dark);
  font-weight: 700;
}

.stats-status.is-error {
  color: #b3261e;
  font-weight: 700;
}

.stats-disclaimer {
  padding: 10px 12px;
  border-left: 4px solid var(--private);
  border-radius: 4px;
  background: #fff4e3;
  font-size: 0.82rem;
  line-height: 1.45;
}

.stats-kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 10px;
}

.stats-kpi {
  position: relative;
  display: grid;
  gap: 2px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.stats-kpi .stats-kpi-icon {
  position: absolute;
  top: 10px;
  right: 12px;
  font-size: 1.35rem;
  line-height: 1;
}

.stats-loading.map-status[data-mode="loading"] {
  position: fixed;
}

.stats-kpi strong {
  font-size: 1.7rem;
  line-height: 1.1;
}

.stats-kpi span {
  color: var(--muted);
  font-size: 0.8rem;
}

.stats-grid {
  display: grid;
  gap: 14px;
  align-items: start;
}

.stats-custom { container-type: inline-size; min-width: 0; }
.view-custom-stats .stats-inner { gap: 12px; padding-bottom: 12px; }
.custom-page-header { grid-template-columns: minmax(220px, 1fr) minmax(440px, 1.6fr); gap: 24px; align-items: end; margin-bottom: 14px; }
.custom-page-title { min-width: 0; display: grid; gap: 6px; }
.custom-page-title h1 { line-height: 1.2; overflow-wrap: anywhere; }
.custom-title-help { display: flex; align-items: center; gap: 10px; min-width: 0; }
.custom-title-help h1 { min-width: 0; }
.custom-select-heading { display: flex; align-items: center; justify-content: space-between; gap: 7px; min-height: 26px; }
.custom-select-heading label { min-width: 0; }
.custom-help-icon { display: inline-grid; place-items: center; flex: 0 0 24px; width: 24px; height: 24px; padding: 0; border: 0; border-radius: 50%; background: var(--panel); color: var(--accent-dark); cursor: pointer; }
.custom-help-icon img, .custom-help-panel button img { display: block; }
.custom-help-icon:hover { background: #e7f2ee; }
.custom-help-dialog { width: min(960px, calc(100vw - 32px)); max-width: none; max-height: calc(100dvh - 32px); border: 0; padding: 0; background: transparent; color: var(--ink); overflow: visible; }
.custom-help-dialog::backdrop { background: rgba(18, 30, 25, 0.48); }
.custom-help-panel { display: flex; flex-direction: column; max-height: calc(100dvh - 32px); border: 1px solid var(--line); border-radius: 8px; background: var(--panel); box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2); overflow: hidden; }
.custom-help-panel > header { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.custom-help-panel h2 { margin: 0; font-size: 1.1rem; line-height: 1.4; }
.custom-help-panel [data-custom-help-close] { display: grid; place-items: center; flex: 0 0 34px; width: 34px; height: 34px; padding: 0; border: 1px solid var(--line); border-radius: 4px; color: var(--ink); background: transparent; font-size: 1.4rem; cursor: pointer; }
.custom-help-body { overflow-y: auto; min-height: 0; padding: 20px; font-size: 0.9rem; line-height: 1.55; }
.custom-help-body section + section { margin-top: 24px; padding-top: 18px; border-top: 1px solid var(--line); }
.custom-help-body h3 { margin: 0 0 10px; font-size: 1rem; }
.custom-help-body p + p { margin-top: 10px; }
.custom-help-body ol { padding-left: 22px; margin: 10px 0 0; }
.custom-help-body li + li { margin-top: 6px; }
.custom-help-intro { margin-bottom: 20px; }
.custom-help-table { max-width: 100%; overflow-x: auto; margin: 12px 0; }
.custom-help-table table { min-width: 0; width: 100%; table-layout: fixed; }
.custom-help-table .stats-table th, .custom-help-table .stats-table td { padding: 9px 10px; overflow-wrap: anywhere; line-height: 1.5; }
.custom-help-table .stats-table th { font-size: 0.82rem; background: #eef3f0; color: var(--ink); }
.custom-help-table th:first-child { width: 24%; }
.custom-help-table th:nth-child(2):not(:last-child) { width: 22%; }
.custom-help-icon:focus-visible, .custom-help-dialog :focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
@media (max-width: 600px) {
  .custom-help-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .custom-help-table table, .custom-help-table tbody { display: block; }
  .custom-help-table tbody tr { display: grid; gap: 4px; padding: 12px 0; border-bottom: 1px solid var(--line); }
  .custom-help-table .stats-table td { display: block; padding: 0; border: 0; font-size: 0.85rem; }
  .custom-help-table td:first-child { font-weight: 700; }
  .custom-help-table .stats-table td:nth-child(2):not(:last-child) { color: var(--muted); font-size: 0.78rem; }
}
@media (max-width: 480px) {
  .custom-help-dialog { width: calc(100vw - 16px); max-height: calc(100dvh - 16px); }
  .custom-help-panel { max-height: calc(100dvh - 16px); }
  .custom-help-panel > header, .custom-help-body { padding: 12px; }
}
.view-stats #sidePanel .controls { display: none; }
.view-stats .stats-header h1 { font-size: 1.5rem; letter-spacing: 0; }
.stats-common-filters { min-width: 0; border-block: 1px solid var(--line); padding: 10px 0; }
.stats-common-filters > summary { font-size: 0.86rem; font-weight: 700; cursor: pointer; }
.stats-common-fields { display: flex; flex-wrap: wrap; gap: 16px 24px; padding-top: 14px; align-items: start; }
.stats-common-fields fieldset { min-width: 0; margin: 0; padding: 0; border: 0; }
.stats-common-fields legend { margin-bottom: 8px; font-size: 0.82rem; font-weight: 650; }
.stats-common-period { flex: 1 1 300px; display: grid; gap: 10px; }
.stats-common-time { flex: 0 1 160px; }
.stats-common-impact { flex: 1 1 350px; }
.stats-common-fields select, .stats-common-fields input[type="date"] { width: 100%; min-width: 0; min-height: 36px; padding: 7px 8px; border: 1px solid var(--line); border-radius: 4px; background: var(--panel); color: var(--ink); font: inherit; font-size: 0.84rem; }
.stats-common-fields input[type="checkbox"] { width: 16px; height: 16px; margin: 0; accent-color: var(--accent); }
.stats-common-fields :focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.custom-layout { display: grid; grid-template-columns: var(--custom-controls-width, 250px) minmax(0, 1fr); gap: 24px; align-items: start; }
.custom-controls { position: relative; min-width: 0; border-right: 1px solid var(--line); padding-right: 20px; }
.custom-resize-handle { position: absolute; right: -15px; top: 12px; display: grid; place-items: center; width: 30px; height: 30px; padding: 0; border: 1px solid var(--line); border-radius: 50%; color: var(--accent-dark); background: var(--panel); box-shadow: 0 4px 12px rgba(20, 29, 26, 0.16); cursor: ew-resize; touch-action: none; font: inherit; font-size: 1.1rem; font-weight: 900; z-index: 3; }
.custom-resize-handle:hover { background: #e7f2ee; }
.stats-custom.is-resizing-custom { cursor: ew-resize; user-select: none; }
.custom-controls > summary, .custom-controls > h2 { margin: 0; padding: 8px 0 14px; font-size: 1.05rem; font-weight: 750; }
.custom-controls > summary { cursor: pointer; }
.custom-control-body { display: grid; gap: 14px; padding-bottom: 16px; overflow-anchor: none; }
.custom-select { display: grid; min-width: 0; gap: 5px; font-size: 0.8rem; font-weight: 650; }
.stats-custom select, .stats-custom input[type="search"], .stats-custom input[type="date"] { width: 100%; min-width: 0; max-width: 100%; min-height: 36px; padding: 7px 8px; border: 1px solid var(--line); border-radius: 4px; background: var(--panel); color: var(--ink); font: inherit; font-size: 0.84rem; }
.stats-custom select:focus-visible, .stats-custom input:focus-visible, .stats-custom button:focus-visible, .stats-custom summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.custom-scope { display: grid; gap: 12px; padding-top: 14px; border-top: 1px solid var(--line); }
.custom-period .custom-scope { border-top: 0; padding-top: 12px; }
.custom-warning { margin: 0; padding: 10px 12px; border-left: 3px solid #b48422; background: #fff5db; color: var(--ink); font-size: 0.82rem; line-height: 1.45; }
.custom-date-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 8px; }
.custom-date-row label { min-width: 0; display: grid; gap: 5px; font-size: 0.78rem; }
.custom-checks { display: flex; flex-wrap: wrap; gap: 9px 14px; min-width: 0; margin: 0; padding: 0; border: 0; font-size: 0.83rem; }
.custom-checks legend { margin-bottom: 8px; font-weight: 650; }
.custom-checks label { display: flex; align-items: center; gap: 7px; min-height: 26px; cursor: pointer; }
.custom-overview { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 20px; }
.custom-overview .custom-summary { flex: 1 1 210px; }
.custom-impact-checks { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; padding: 12px 0 0; }
.custom-time .custom-checks { padding-top: 12px; }
.stats-custom input[type="checkbox"] { flex: 0 0 16px; width: 16px; height: 16px; margin: 0; accent-color: var(--accent); }
.custom-impact-checks i, .custom-legend i { display: inline-block; width: 10px; height: 10px; flex: 0 0 10px; border-radius: 2px; }
.custom-facet { border-top: 1px solid var(--line); padding: 9px 0; }
.custom-facet summary { cursor: pointer; font-size: 0.84rem; font-weight: 650; overflow-wrap: anywhere; }
.custom-facet summary span { margin-left: 7px; font-size: 0.75rem; font-weight: 400; color: var(--muted); }
.custom-facet-tools { display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center; gap: 8px; margin: 10px 0 8px; }
.custom-search-action { display: grid; align-items: center; min-width: 0; height: 48px; }
.custom-all { display: inline-flex; align-items: center; gap: 7px; min-height: 28px; font-size: 0.8rem; font-weight: 650; cursor: pointer; }
.custom-search-selection { width: 100%; min-height: 32px; padding: 4px 6px; border: 1px solid var(--accent); border-radius: 4px; background: var(--panel); color: var(--accent-dark); font: inherit; font-size: 0.75rem; line-height: 1.2; cursor: pointer; }
.custom-search-selection[hidden] { display: none; }
.custom-search-selection:disabled { opacity: 0.55; cursor: default; }
.custom-facet-tools button, .custom-reset { border: 0; border-radius: 0; background: none; padding: 3px 0; color: var(--accent-dark); font: inherit; font-size: 0.79rem; text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }
.custom-reset { justify-self: start; }
.custom-options { min-height: 36px; max-height: 190px; overflow-y: auto; margin-top: 7px; scrollbar-gutter: stable; overflow-anchor: none; }
.custom-search-empty { margin: 0; padding: 8px 3px; font-size: 0.8rem; line-height: 1.4; color: var(--muted); }
.custom-search-empty[hidden] { display: none; }
.custom-options label { display: flex; align-items: flex-start; gap: 7px; min-height: 31px; padding: 6px 3px; font-size: 0.8rem; cursor: pointer; }
.custom-options label[hidden] { display: none; }
.custom-options label span { min-width: 0; flex: 1; overflow-wrap: anywhere; }
.custom-options small { color: var(--muted); font-variant-numeric: tabular-nums; }
.custom-result { display: flex; flex-direction: column; min-width: 0; gap: 10px; }
.custom-chart-toolbar { display: grid; grid-template-columns: minmax(135px, 1.4fr) repeat(2, minmax(85px, 1fr)) minmax(85px, 0.75fr); gap: 10px; align-items: end; }
.custom-chart-toolbar.is-point-mode { grid-template-columns: minmax(160px, 1fr) minmax(180px, 1.2fr); }
.custom-chart-toolbar select:disabled { opacity: 0.6; cursor: default; }
.custom-result h2 { margin: 0; font-size: 1.12rem; line-height: 1.4; letter-spacing: 0; overflow-wrap: anywhere; }
.custom-summary { margin: 0; min-height: 1.5em; font-size: 0.83rem; color: var(--muted); }
.custom-canvas-scroll { min-width: 0; max-width: 100%; max-height: 520px; overflow: auto; padding: 12px; border: 1px solid var(--line); border-radius: 6px; background: var(--panel); }
.custom-canvas-frame { position: relative; width: 100%; }
.custom-canvas-frame canvas { display: block; }
.custom-legend { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; max-height: 160px; overflow: auto; list-style: none; padding: 0; margin: 0; font-size: 0.77rem; }
.custom-legend li { display: flex; gap: 6px; align-items: center; min-width: 0; max-width: 100%; }
.custom-legend span { overflow-wrap: anywhere; }
.custom-note, .custom-coverage { margin: 0; font-size: 0.78rem; color: var(--muted); line-height: 1.45; }
.custom-point-range { display: flex; align-items: center; min-width: 0; min-height: 36px; }
.custom-point-range .custom-all { align-items: flex-start; line-height: 1.5; }
.custom-point-range .custom-all span { min-width: 0; overflow-wrap: anywhere; }
.custom-point-range input { flex: 0 0 auto; }
.custom-empty { display: grid; place-items: center; min-height: 300px; padding: 30px; text-align: center; color: var(--muted); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.custom-chart-error { margin: 0; padding: 12px; border-left: 3px solid #b74a65; color: #8f2b46; background: #fff4f5; font-size: 0.84rem; }
.custom-chart-error[hidden] { display: none; }
.custom-chart-error button { font: inherit; padding: 4px 8px; margin-left: 6px; color: var(--ink); background: white; border: 1px solid var(--line); border-radius: 4px; cursor: pointer; }
.custom-values { min-width: 0; border-top: 1px solid var(--line); margin-top: 4px; padding-top: 12px; }
.custom-values > summary { cursor: pointer; font-size: 0.86rem; font-weight: 700; }
.custom-values > summary span { margin-left: 8px; font-weight: 400; color: var(--muted); }
.custom-table-host { min-width: 0; margin-top: 12px; }
.custom-table-scroll { max-width: 100%; overflow: auto; }
.custom-table-scroll table { min-width: 560px; width: 100%; }
.custom-table-scroll td { font-variant-numeric: tabular-nums; }
.custom-constant-status { margin: 0 0 10px; font-size: 0.8rem; color: var(--muted); }
.custom-sr-only { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
@media (min-width: 881px) {
  .app-shell {
    grid-template-columns: var(--panel-width) minmax(0, 1fr);
  }
  .view-stats .app-shell { grid-template-columns: 96px minmax(0, 1fr); }
  .menu-toggle { display: none; }
  .panel .brand-block .site-nav { margin-left: 0; }
}
  .view-stats #sidePanel { padding: 16px 9px; gap: 18px; box-shadow: none; }
  .view-stats #sidePanel .brand-block { gap: 0; padding: 0; }
  .view-stats #sidePanel .brand-block > .eyebrow,
  .view-stats #sidePanel .brand-block > h1,
  .view-stats #sidePanel .brand-block > .intro { display: none; }
  .view-stats #sidePanel .site-nav {
    position: static;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    flex-wrap: nowrap;
    gap: 8px;
    width: 100%;
    margin: 0;
  }
  .view-stats #sidePanel .site-nav a,
  .view-stats #sidePanel .site-nav .language-toggle {
    position: relative;
    display: grid;
    place-items: center;
    width: 40px;
    height: 40px;
    min-width: 0;
    padding: 0;
    flex: 0 0 40px;
    border-radius: 6px;
  }
  .view-stats #sidePanel .site-nav a > span {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }
  .view-stats #sidePanel .compact-nav-icon { display: block; }
  .view-stats #sidePanel > .map-mode-nav {
    grid-auto-flow: row;
    grid-auto-columns: auto;
    grid-template-columns: minmax(0, 1fr);
    gap: 6px;
    width: 100%;
  }
  .view-stats #sidePanel > .map-mode-nav a { min-height: 62px; gap: 5px; padding: 8px 2px; }
  .view-stats #sidePanel > .map-mode-nav .visually-hidden {
    position: static;
    width: auto;
    height: auto;
    margin: 0;
    padding: 0;
    overflow: visible;
    clip: auto;
    clip-path: none;
    white-space: normal;
    overflow-wrap: anywhere;
    font-size: 0.68rem;
    line-height: 1.2;
    text-align: center;
  }
  .view-stats .panel-resize-handle { display: none; }
  .view-stats #sidePanel a:focus-visible,
  .view-stats #sidePanel button:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
@media (max-width: 880px) {
  .view-stats #sidePanel { width: 96px; padding-top: 72px; }
  .custom-layout { grid-template-columns: minmax(0, 1fr); }
  .custom-controls { border-right: 0; border-bottom: 1px solid var(--line); padding-right: 0; }
  .custom-control-body { max-height: none; overflow: visible; padding-right: 0; }
  .custom-resize-handle { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  .app-shell { transition: none; }
  .view-stats #sidePanel > .map-mode-nav { animation: none; }
}
@container (min-width: 760px) {
  @media (min-width: 881px) {
    .custom-control-body { max-height: var(--custom-controls-body-height, calc(100dvh - 315px)); overflow-y: auto; scrollbar-gutter: stable; padding-right: 8px; }
    .custom-result:has(> .custom-values:not([open])) { height: var(--custom-available-height, auto); min-height: 0; }
    .custom-result:has(> .custom-values:not([open])) > :not(.custom-canvas-scroll) { flex-shrink: 0; }
    .custom-result:has(> .custom-values:not([open])) > .custom-canvas-scroll { flex: 1 1 auto; min-height: 180px; max-height: none; }
    .custom-result:has(> .custom-values:not([open])) > .custom-canvas-scroll > .custom-canvas-frame { min-height: 100%; }
    .custom-result:has(> .custom-values:not([open])) > .custom-legend { max-height: 80px; }
  }
  .custom-date-row { grid-template-columns: minmax(0, 1fr); }
}
@container (max-width: 759px) {
  .custom-page-header { grid-template-columns: minmax(0, 1fr); gap: 12px; }
  .custom-resize-handle { display: none; }
  .custom-layout { grid-template-columns: minmax(0, 1fr); gap: 16px; }
  .custom-controls { border-right: 0; border-bottom: 1px solid var(--line); padding-right: 0; }
  .custom-controls > summary { padding: 10px 0; }
  .custom-control-body { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .custom-scope, .custom-facets, .custom-reset { grid-column: 1 / -1; }
  .custom-chart-toolbar { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .custom-canvas-scroll { padding: 6px; }
}
@container (max-width: 400px) {
  .custom-control-body { grid-template-columns: minmax(0, 1fr); }
  .custom-chart-toolbar { grid-template-columns: minmax(0, 1fr); gap: 8px; }
  .custom-chart-toolbar.is-point-mode { grid-template-columns: minmax(0, 1fr); }
  .custom-chart-toolbar .custom-select:last-child { width: 100px; }
}

/* Two independent columns filled by js/stats.js: each card goes under the shorter column. */
.stats-columns {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  align-items: start;
}

.stats-col {
  display: grid;
  gap: 14px;
  align-content: start;
  min-width: 0;
}

.stats-pair {
  display: grid;
  grid-template-columns: minmax(0, 7fr) minmax(0, 3fr);
  gap: 14px;
  align-items: start;
}

.stats-chart-side {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(240px, 1.15fr);
  gap: 12px 14px;
  align-items: center;
}

.stats-legend.stats-legend-list {
  display: grid;
  gap: 8px;
  font-size: 0.8rem;
}

.stats-legend-side {
  display: grid;
  gap: 8px;
  min-width: 0;
}

.stats-legend-head {
  margin: 0;
  font-size: 0.84rem;
}

.stats-legend-head small {
  color: var(--muted);
}

.stats-legend-list ul {
  display: grid;
  gap: 3px;
  margin: 4px 0 0;
  padding: 0 0 0 18px;
  list-style: none;
}

.stats-swatch {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 3px;
  vertical-align: -1px;
}

.stats-sector {
  display: grid;
  gap: 6px;
}

@media (max-width: 880px) {
  .stats-chart-side {
    grid-template-columns: minmax(0, 1fr);
  }
}

.stats-card {
  display: grid;
  /* A wide table inside "Voir les chiffres" must not stretch the card and its chart. */
  grid-template-columns: minmax(0, 1fr);
  gap: 8px;
  min-width: 0;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.stats-card.is-wide {
  container-type: inline-size;
}

/* Enlarge button in the upper-right corner of long tables and charts with figures. */
.stats-card.has-expand {
  position: relative;
}

.stats-card.has-expand > .stats-card-head {
  padding-right: 40px;
}

.stats-expand {
  position: absolute;
  top: 10px;
  right: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--accent-dark);
}

.stats-expand:hover {
  background: #f1f6f3;
}

.stats-expand:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.stats-expand svg {
  width: 18px;
  height: 18px;
}

/* Below the info bubbles (z-index 1500) so they still open inside the enlarged panel. */
.stats-card.is-floating {
  position: fixed;
  z-index: 1470;
  top: 4vh;
  left: max(3vw, calc((100vw - 1400px) / 2));
  width: min(94vw, 1400px);
  max-height: 92vh;
  margin: 0;
  overflow: auto;
  overscroll-behavior: contain;
  box-shadow: 0 24px 60px rgba(20, 29, 26, 0.35);
}

/* Only a transform is animated (FLIP): no layout work on each frame. */
.stats-card.is-animating {
  overflow: hidden;
  will-change: transform;
  transition: transform 0.32s cubic-bezier(0.2, 0.8, 0.2, 1);
}

/* Back in the page but still above the fading backdrop while it shrinks into place. */
.stats-card.is-landing {
  position: relative;
  z-index: 1470;
  box-shadow: 0 24px 60px rgba(20, 29, 26, 0.35);
}

/* Wide enlarged panel: the chart on the left, its figures on the right; title and notes span both. */
@media (min-width: 881px) {
  .stats-card.is-expanded:has(> .stats-chart-values) {
    grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr);
    column-gap: 24px;
    align-items: start;
  }

  .stats-card.is-expanded:has(> .stats-chart-values) > :not(.stats-chart):not(.stats-chart-side):not(.stats-chart-values) {
    grid-column: 1 / -1;
  }
}

.stats-expand-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1460;
  background: rgba(20, 29, 26, 0.45);
  opacity: 0;
  transition: opacity 0.3s ease;
}

.stats-expand-backdrop.is-visible {
  opacity: 1;
}

@media (prefers-reduced-motion: reduce) {
  .stats-card.is-animating,
  .stats-expand-backdrop {
    transition: none;
  }
}

.stats-card-title {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.stats-th {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.stats-table th.num .stats-th {
  display: flex;
  justify-content: center;
}

.stats-table thead th {
  padding-inline: 5px;
}

.stats-th .icon-help.small {
  flex: 0 0 20px;
  width: 20px;
  height: 20px;
  min-height: 20px;
  font-size: 0.7rem;
}

.stats-table td.nowrap {
  white-space: nowrap;
}

.stats-popover {
  position: fixed;
  right: auto;
  z-index: 1500;
  max-height: min(60vh, 420px);
  overflow-y: auto;
  color: var(--ink);
}

.stats-popover:focus {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.stats-popover p {
  margin: 0;
}

.stats-card h3 {
  margin: 6px 0 0;
  font-size: 0.9rem;
}

.stats-note {
  color: var(--muted);
  font-size: 0.76rem;
  line-height: 1.4;
}

.stats-highlight {
  font-weight: 700;
}

.stats-how {
  width: 100%;
  max-width: 900px;
  margin: 0 auto;
}

.stats-card[data-card="how"] .stats-card-head {
  justify-content: center;
  text-align: center;
}

.stats-how-intro {
  margin: 0 auto 20px;
  max-width: 680px;
  font-size: 0.95rem;
  line-height: 1.6;
  text-align: center;
}

.stats-how a {
  color: var(--accent-dark);
  font-weight: 700;
  text-underline-offset: 3px;
}

.stats-how-group {
  margin: 0 0 28px;
}

.stats-how-group h3 {
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 0 0 14px;
  font-size: 1.15rem;
  text-align: center;
  color: var(--accent-dark);
}

.stats-how-group h3::before,
.stats-how-group h3::after {
  content: "";
  flex: 1;
  height: 2px;
  border-radius: 2px;
  background: var(--line);
}

.stats-how-group details {
  margin: 0 0 8px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
  overflow: hidden;
}

.stats-how-group details[open] {
  border-color: var(--accent-dark);
}

.stats-how-group summary {
  padding: 13px 16px;
  cursor: pointer;
  font-weight: 700;
  font-size: 0.93rem;
  line-height: 1.4;
}

.stats-how-group summary:hover {
  background: rgba(0, 0, 0, 0.04);
}

.stats-how-group details[open] summary {
  border-bottom: 1px solid var(--line);
}

.stats-how-answer {
  padding: 12px 16px 6px;
  font-size: 0.9rem;
  line-height: 1.6;
}

.stats-how-answer p,
.stats-how-answer ul {
  margin: 0 0 8px;
}

.stats-how-answer ul {
  padding-left: 20px;
}

.stats-empty {
  color: var(--muted);
  font-size: 0.82rem;
}

.stats-table-wrap {
  overflow-x: auto;
}

/* Always-visible scrollbar (also on macOS overlay scrollbars), as in the pothole statistics tables. */
.stats-table-wrap.is-scrollable {
  overflow-y: scroll;
  scrollbar-gutter: stable;
  scrollbar-width: auto;
  scrollbar-color: #587966 #edf2ef;
  border-bottom: 1px solid var(--line);
}

.stats-table-wrap.is-scrollable::-webkit-scrollbar {
  width: 12px;
  height: 12px;
}

.stats-table-wrap.is-scrollable::-webkit-scrollbar-track {
  background: #edf2ef;
}

.stats-table-wrap.is-scrollable::-webkit-scrollbar-thumb {
  background: #587966;
  border: 2px solid #edf2ef;
  border-radius: 6px;
}

.stats-table-wrap.is-scrollable:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.stats-table-wrap.is-scrollable thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--panel);
}

.stats-scroll-hint {
  color: var(--muted);
  font-size: 0.74rem;
}

.stats-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
}

.stats-table th,
.stats-table td {
  padding: 6px 6px;
  border: 0;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

.stats-table th {
  background: transparent;
  color: var(--muted);
  font-size: 0.74rem;
}

/* The sort arrow always stays beside its label; a long label wraps instead. */
.stats-sort > span {
  min-width: 0;
}

.stats-col .stats-table,
.stats-pair [data-pair="right"] .stats-table {
  font-size: 0.78rem;
}

.stats-col .stats-table th,
.stats-pair [data-pair="right"] .stats-table th {
  font-size: 0.7rem;
}

.stats-col .stats-table th,
.stats-col .stats-table td,
.stats-pair [data-pair="right"] .stats-table th,
.stats-pair [data-pair="right"] .stats-table td {
  padding-inline: 3px;
}

.stats-col .stats-table .stats-sort,
.stats-pair [data-pair="right"] .stats-table .stats-sort {
  gap: 3px;
}

.stats-col .stats-table .stats-sort-icon,
.stats-pair [data-pair="right"] .stats-table .stats-sort-icon {
  width: 14px;
  height: 14px;
  flex-basis: 14px;
}

.stats-table .num {
  text-align: center;
  white-space: nowrap;
}

.stats-table.has-widths {
  table-layout: fixed;
}

/* As narrow as the content: the route badge and total leave room for the other titles. */
.stats-table th.shrink,
.stats-table td.shrink {
  width: 1%;
  white-space: nowrap;
}

.stats-row3 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 14px;
  align-items: stretch;
}

.stats-table.has-widths td {
  overflow-wrap: anywhere;
}

.stats-table td.date {
  white-space: nowrap;
}

.stats-table td small,
.stats-closure-title {
  display: block;
}

.stats-table td small {
  color: var(--muted);
  font-size: 0.72rem;
}

.stats-route {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 4px;
  background: #e9e4d8;
  font-weight: 800;
  white-space: nowrap;
}

.stats-route.is-autoroute {
  background: #1f5fa8;
  color: #fff;
}

.stats-chart {
  position: relative;
  min-width: 0;
  /* A canvas not yet redrawn at a new height must not overflow and skew the panel measurements. */
  overflow: hidden;
}

.stats-stack {
  display: flex;
  height: 22px;
  overflow: hidden;
  border-radius: 6px;
}

.stats-stack-part {
  min-width: 3px;
}

.stats-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 18px;
  margin: 0;
  padding: 0;
  list-style: none;
  font-size: 0.84rem;
}

.stats-legend small {
  color: var(--muted);
}

/* Dot and words on one centred line, with a space after the dot. */
.stats-legend:not(.stats-legend-list) > li {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  line-height: 1.2;
}

.stats-legend:not(.stats-legend-list) > li > .impact-dot,
.stats-legend:not(.stats-legend-list) > li > .stats-swatch {
  margin-right: 2px;
}

.stats-legend-list [data-arc] {
  cursor: default;
}

.stats-sector + .stats-sector {
  margin-top: 8px;
}

.stats-sector .stats-card-title h3 {
  margin: 0;
}

.stats-title-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* Single choice: exactly one segment is pressed. */
.stats-segments {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 4px;
}

.stats-segment {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 32px;
  padding: 4px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--ink);
  font-size: 0.76rem;
  font-weight: 700;
}

.stats-segment:hover {
  background: #f1f6f3;
}

.stats-segment[aria-pressed="true"] {
  border-color: var(--accent);
  background: #e7f2ee;
  color: var(--accent-dark);
}

.stats-segment:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.stats-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 32px;
  padding: 4px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  font-size: 0.76rem;
  font-weight: 700;
  cursor: pointer;
}

.stats-toggle:has(input:checked) {
  border-color: var(--accent);
  background: #e7f2ee;
  color: var(--accent-dark);
}

.stats-toggle input {
  accent-color: var(--accent);
}

.stats-territory {
  display: grid;
  justify-items: center;
  gap: 4px;
  width: min(100%, 860px);
  margin-top: 8px;
}

.stats-territory-selects {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px 20px;
  width: 100%;
}

.stats-select {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  width: min(100%, 340px);
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 650;
}

.stats-select-box {
  position: relative;
  display: flex;
  align-items: center;
  min-width: 0;
  min-height: 36px;
  border: 1px solid #bccdc3;
  border-radius: 6px;
  background: #f3f7f4;
}

.stats-select-box:focus-within {
  outline: 2px solid var(--accent-dark);
  outline-offset: 2px;
}

.stats-select-box select {
  appearance: none;
  width: 100%;
  min-width: 0;
  min-height: 36px;
  padding: 6px 32px;
  border: 0;
  outline: 0;
  background: transparent;
  color: #243a31;
  font: inherit;
  font-size: 0.82rem;
  font-weight: 650;
  cursor: pointer;
}

.stats-select-box > svg {
  position: absolute;
  width: 17px;
  height: 17px;
  color: var(--accent-dark);
  pointer-events: none;
}

.stats-select-box > svg:first-child {
  left: 11px;
}

.stats-select-box > svg:last-child {
  right: 11px;
}

.stats-territory .stats-note {
  margin: 0;
  text-align: center;
}

.stats-toggle:focus-within {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.stats-badge {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 999px;
  font-size: 0.74rem;
  font-weight: 700;
  white-space: nowrap;
}

.stats-badge.is-active {
  background: #e3f1ea;
  color: #1d5b40;
}

.stats-badge.is-ended {
  background: #ece9e3;
  color: #5d574c;
}

.stats-card-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 14px;
}

.stats-filters {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  font-size: 0.8rem;
}

.stats-multi-button,
.stats-filter-search {
  min-height: 32px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  font-size: 0.8rem;
}

.stats-multi {
  position: relative;
}

.stats-multi-button {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  max-width: 260px;
  padding: 4px 8px;
  cursor: pointer;
}

/* The global button:hover paints dark green, which hid the dark filter text. */
.stats-multi-button:hover,
.stats-multi-button[aria-expanded="true"],
.stats-chip:hover {
  background: #f1f6f3;
}

.stats-multi.is-active .stats-multi-button {
  border-color: var(--accent);
  background: #e7f2ee;
}

.stats-multi-label {
  color: var(--muted);
}

.stats-multi-summary {
  overflow: hidden;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stats-multi-chevron {
  width: 14px;
  height: 14px;
  flex: 0 0 14px;
}

.stats-multi-panel {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  z-index: 30;
  display: grid;
  gap: 4px;
  width: max-content;
  min-width: 200px;
  max-width: min(320px, 80vw);
  max-height: 300px;
  margin: 0;
  padding: 8px 10px;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 12px 28px rgba(20, 29, 26, 0.18);
}

.stats-multi-panel[hidden] {
  display: none;
}

.stats-multi-panel label {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  padding: 3px 2px;
  cursor: pointer;
}

.stats-multi-panel label[hidden] {
  display: none;
}

.stats-multi-all {
  padding-bottom: 6px !important;
  border-bottom: 1px solid var(--line);
  font-weight: 700;
}

.stats-multi-options {
  display: grid;
  gap: 2px;
}

.stats-multi-search {
  min-height: 30px;
  padding: 4px 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: 0.8rem;
}

.stats-filter-search {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 0 8px;
}

.stats-filter-search svg {
  width: 15px;
  height: 15px;
  flex: 0 0 15px;
  color: var(--muted);
}

.stats-filter-search input {
  width: 150px;
  min-width: 0;
  padding: 5px 0;
  border: 0;
  outline: 0;
  background: transparent;
  font-size: 0.8rem;
}

.stats-filter-search:focus-within,
.stats-multi-button:focus-visible,
.stats-chip:focus-visible,
.stats-sort:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.stats-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.stats-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 32px;
  padding: 4px 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--ink);
  font-size: 0.76rem;
  cursor: pointer;
}

.stats-chip[aria-pressed="false"] {
  opacity: 0.45;
  text-decoration: line-through;
}

.stats-filter-count {
  color: var(--muted);
  font-weight: 700;
}

.stats-filter-count:empty {
  display: none;
}

.stats-table th.num {
  white-space: normal;
}

.stats-sort {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  text-transform: inherit;
  text-align: inherit;
  cursor: pointer;
}

.stats-sort:hover {
  background: transparent;
  color: var(--accent-dark);
}

.stats-sort-icon {
  width: 18px;
  height: 18px;
  flex: 0 0 18px;
  color: var(--accent-dark);
}

.stats-table th.is-sorted {
  color: var(--accent-dark);
}

.stats-split {
  display: grid;
  gap: 14px 20px;
}

.stats-split > div {
  display: grid;
  align-content: start;
  gap: 6px;
  min-width: 0;
}

@container (min-width: 720px) {
  .stats-split {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.stats-chart[hidden] {
  display: none;
}

.stats-chart-values summary {
  color: var(--accent-dark);
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
}

.stats-chart-values[open] summary {
  margin-bottom: 6px;
}

@media (max-width: 880px) {
  .stats-view {
    height: 100vh;
    height: 100dvh;
  }

  .stats-inner {
    padding: 0 14px 32px;
  }

  /* Leaves room for the fixed menu button in the upper-left corner. */
  .stats-dock {
    justify-items: stretch;
    padding: 8px 0 8px 58px;
  }

  .stats-tabs {
    container-type: inline-size;
    grid-auto-flow: row;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    grid-template-rows: repeat(2, auto);
  }

  .stats-tabs a {
    min-width: 0;
    padding: 4px;
    font-size: min(0.74rem, 3.2cqi);
    overflow-wrap: normal;
    word-break: normal;
    hyphens: none;
  }

  .stats-tabs a[data-stats-tab="how"] {
    grid-column: 4;
    grid-row: 1 / 3;
  }

  /* The sticky dock stays short on phones; the General tab disclaimer gives the details. */
  .stats-live-detail {
    display: none;
  }

  /* Section filters: a title row, then one full-width control per line. */
  .stats-card-head {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 10px;
  }

  .stats-filters {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    justify-content: stretch;
    gap: 8px;
  }

  .stats-multi,
  .stats-multi-button,
  .stats-filter-search {
    width: 100%;
    max-width: none;
  }

  .stats-multi-button {
    min-height: 40px;
    padding: 6px 12px;
  }

  .stats-multi-summary {
    flex: 1;
    text-align: left;
  }

  .stats-multi-panel {
    right: 0;
    left: 0;
    width: auto;
    min-width: 0;
    max-width: none;
  }

  .stats-filter-search {
    min-height: 40px;
    padding: 0 12px;
  }

  .stats-filter-search input {
    flex: 1;
    width: auto;
    font-size: 1rem;
  }

  .stats-chips {
    gap: 6px;
  }

  .stats-filter-count {
    text-align: right;
  }

  /* The fixed layout let long cells run over their neighbours: columns size to their content and wrap. */
  .stats-table.has-widths {
    table-layout: auto;
  }

  .stats-table.has-widths col {
    width: auto !important;
  }

  .stats-table.has-widths td.num,
  .stats-table td.date {
    width: auto;
    white-space: normal;
  }

  .stats-table td.date {
    width: 1%;
  }

  /* These wide tables scroll sideways rather than squeezing their main text column. */
  .stats-table-wrap[data-table="publicLongest"] td:first-child,
  .stats-table-wrap[data-table="upper"] td:nth-child(2) {
    min-width: 150px;
  }
}

#map {
  position: relative;
  width: 100%;
  height: 100%;
  min-height: 0;
  overflow: hidden;
  background: #d7e8dd;
}

.leaflet-container {
  color: var(--ink);
  font: inherit;
  overflow: hidden;
}

.leaflet-pane,
.leaflet-tile,
.leaflet-marker-icon,
.leaflet-marker-shadow,
.leaflet-tile-container,
.leaflet-pane > svg,
.leaflet-pane > canvas,
.leaflet-zoom-box,
.leaflet-image-layer,
.leaflet-layer {
  position: absolute;
  left: 0;
  top: 0;
}

.leaflet-container img.leaflet-tile,
.leaflet-container .leaflet-marker-icon,
.leaflet-container .leaflet-marker-shadow {
  max-width: none !important;
  max-height: none !important;
}

.leaflet-tile {
  border: 0;
  user-select: none;
  visibility: inherit;
}

.leaflet-tile-pane {
  z-index: 200;
}

.leaflet-overlay-pane {
  z-index: 400;
}

.leaflet-shadow-pane {
  z-index: 500;
}

.leaflet-marker-pane {
  z-index: 600;
}

.leaflet-tooltip-pane {
  z-index: 650;
}

.leaflet-popup-pane {
  z-index: 700;
}

.leaflet-control {
  position: relative;
  z-index: 800;
  pointer-events: auto;
}

.leaflet-control-zoom a {
  display: block;
  width: 32px;
  height: 32px;
  border-bottom: 1px solid #d8d8d8;
  background: #fff;
  color: var(--ink);
  line-height: 32px;
  text-align: center;
  text-decoration: none;
  font-size: 1.2rem;
  font-weight: 900;
}

.leaflet-control-zoom a:last-child {
  border-bottom: 0;
}

.location-button {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 1px solid #d8d8d8;
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  box-shadow: 0 4px 12px rgba(20, 29, 26, 0.16);
  cursor: pointer;
}

.location-button:hover {
  background: #e7f2ee;
}

.location-button:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

.location-button:disabled {
  color: #087f8c;
  background: #e7f2ee;
  cursor: progress;
}

.location-status {
  position: absolute;
  top: 0;
  right: 54px;
  width: min(250px, calc(100vw - 100px));
  padding: 10px 12px;
  border: 1px solid #d8d8d8;
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  font-size: 0.85rem;
  line-height: 1.4;
  overflow-wrap: anywhere;
  box-shadow: 0 4px 12px rgba(20, 29, 26, 0.16);
}

.location-status[hidden] {
  display: none;
}

.leaflet-top,
.leaflet-bottom {
  position: absolute;
  z-index: 1000;
  pointer-events: none;
}

.leaflet-top {
  top: 0;
}

.leaflet-right {
  right: 0;
}

.leaflet-bottom {
  bottom: 0;
}

.leaflet-left {
  left: 0;
}

.leaflet-top.leaflet-left {
  width: auto;
  right: 14px;
  left: auto;
}

.leaflet-top.leaflet-left .leaflet-control {
  margin: 14px 0 0;
}

.leaflet-control-zoom,
.leaflet-control-layers,
.leaflet-bar {
  border: 0 !important;
  border-radius: 8px !important;
  box-shadow: 0 10px 26px rgba(20, 29, 26, 0.16);
  overflow: hidden;
}

.leaflet-bar a {
  color: var(--ink);
}

.leaflet-tile-loaded,
.leaflet-tile {
  opacity: 1 !important;
}

.leaflet-overlay-pane svg {
  overflow: visible;
}

.traffic-arrow {
  display: none !important;
  width: 18px !important;
  height: 18px !important;
  margin-left: -9px !important;
  margin-top: -9px !important;
  pointer-events: none;
}

.traffic-arrow span {
  display: block;
  width: 0;
  height: 0;
  border-top: 5px solid transparent;
  border-bottom: 5px solid transparent;
  border-left: 12px solid #ffffff;
  filter:
    drop-shadow(0 0 1px var(--arrow-color))
    drop-shadow(0 0 2px rgba(0, 0, 0, 0.65));
  transform-origin: center;
}

.map-status {
  position: absolute;
  top: 18px;
  left: 18px;
  max-width: min(360px, calc(100% - 36px));
  padding: 12px 14px;
  border: 1px solid rgba(255, 255, 255, 0.72);
  border-radius: 8px;
  background: rgba(255, 253, 248, 0.96);
  box-shadow: 0 10px 26px rgba(20, 29, 26, 0.16);
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 800;
  z-index: 520;
}

.map-status[data-mode="error"] {
  border-color: rgba(194, 55, 100, 0.38);
  color: #8f2045;
}

.map-status[data-mode="loading"] {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  top: 50%;
  left: 50%;
  z-index: 1500;
  pointer-events: none;
  transform: translate(-50%, -50%);
}

.map-status[data-mode="loading"]::before {
  width: 16px;
  height: 16px;
  flex: 0 0 16px;
  border: 3px solid rgba(15, 123, 102, 0.2);
  border-top-color: var(--accent);
  border-radius: 50%;
  content: "";
  animation: map-loading-spin 800ms linear infinite;
}

@keyframes map-loading-spin {
  to {
    transform: rotate(360deg);
  }
}

.map-instruction {
  position: absolute;
  top: 18px;
  left: 50%;
  max-width: calc(100% - 420px);
  margin: 0;
  padding: 9px 13px;
  border: 1px solid rgba(255, 255, 255, 0.72);
  border-radius: 8px;
  background: rgba(255, 253, 248, 0.94);
  box-shadow: 0 10px 26px rgba(20, 29, 26, 0.14);
  color: var(--ink);
  font-size: 0.82rem;
  font-weight: 800;
  text-align: center;
  transform: translateX(-50%);
  z-index: 520;
}

.map-first-visit-hint {
  position: absolute;
  top: 50%;
  left: 50%;
  display: grid;
  gap: 4px;
  width: min(340px, calc(100% - 36px));
  padding: 14px 42px 14px 15px;
  border: 2px solid var(--accent);
  border-radius: 8px;
  background: #fffdf8;
  box-shadow: 0 14px 34px rgba(20, 29, 26, 0.22);
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.4;
  transform: translate(-50%, -50%);
  z-index: 1100;
}

.map-first-visit-hint[hidden] {
  display: none !important;
}

.map-first-visit-hint strong {
  color: var(--ink);
}

.map-first-visit-hint button {
  position: absolute;
  top: 7px;
  right: 8px;
  width: 28px;
  height: 28px;
  padding: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--ink);
  font-size: 1.3rem;
  line-height: 1;
}

.leaflet-interactive {
  cursor: pointer;
}

.source-card {
  position: absolute;
  right: 18px;
  bottom: 18px;
  display: grid;
  gap: 3px;
  max-width: min(360px, calc(100% - 36px));
  padding: 12px 14px;
  border: 1px solid rgba(255, 255, 255, 0.7);
  border-radius: 8px;
  background: rgba(255, 253, 248, 0.92);
  box-shadow: 0 12px 40px rgba(20, 29, 26, 0.16);
  z-index: 1200;
}

.source-card[hidden] {
  display: none !important;
}

.sources-toggle {
  position: absolute;
  right: 18px;
  bottom: 18px;
  min-height: 42px;
  padding: 0 14px;
  border-radius: 8px;
  background: var(--accent);
  box-shadow: 0 10px 26px rgba(20, 29, 26, 0.2);
  color: #fff;
  z-index: 520;
}

.sources-toggle:hover {
  background: var(--accent-dark);
}

.sources-close {
  position: absolute;
  top: 7px;
  right: 8px;
  width: 30px;
  height: 30px;
  padding: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--ink);
  font-size: 1.5rem;
  line-height: 1;
}

.source-card strong {
  padding-right: 30px;
}

.source-card span {
  color: var(--muted);
  font-size: 0.82rem;
}

.source-card a {
  color: var(--accent-dark);
  font-weight: 900;
}

.popup-title {
  margin: 0 0 6px;
  font-weight: 900;
}

.popup-meta {
  margin: 0 0 6px;
  color: #52615b;
  line-height: 1.35;
  overflow-wrap: anywhere;
  white-space: pre-line;
}

.closure-card .meta {
  overflow-wrap: anywhere;
  white-space: pre-line;
}

/* Leaflet's own ".leaflet-popup-content p" rule (17px/1.3em margin) otherwise outranks .popup-meta/.popup-title. */
.leaflet-popup-content p.popup-meta,
.leaflet-popup-content p.popup-title {
  margin: 0 0 6px;
}

.popup-card {
  display: grid;
  gap: 2px;
}

.popup-scroll-shell {
  position: relative;
}

.popup-group-header {
  position: sticky;
  top: 0;
  z-index: 2;
  padding: 10px 30px 12px;
  background: color-mix(in srgb, var(--popup-header-color, #ff8c00) 12%, #fffdf8);
  color: var(--ink);
  font-weight: 900;
  border-bottom: 1px solid #e6e6e6;
  text-align: center;
}

.popup-scroll-body {
  max-height: 300px;
  overflow-y: auto;
  overflow-x: hidden;
  padding-right: 4px;
  scrollbar-gutter: stable;
  scrollbar-width: thin;
  scrollbar-color: rgba(93, 109, 103, 0.55) transparent;
  position: relative;
}

.popup-scroll-body::-webkit-scrollbar {
  width: 10px;
}

.popup-scroll-body::-webkit-scrollbar-track {
  background: transparent;
}

.popup-scroll-body::-webkit-scrollbar-thumb {
  border-radius: 999px;
  background: rgba(93, 109, 103, 0.5);
}

.popup-scroll-hint {
  position: sticky;
  bottom: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  height: 22px;
  margin-top: -18px;
  background: linear-gradient(180deg, rgba(255, 253, 248, 0), rgba(255, 253, 248, 0.9) 35%, rgba(255, 253, 248, 0.98));
  color: var(--ink);
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease;
}

.popup-scroll-body.has-overflow .popup-scroll-hint {
  opacity: 1;
  animation: popupScrollBounce 1.3s ease-in-out infinite;
}

.popup-scroll-body.is-scrolled .popup-scroll-hint {
  opacity: 0;
}

.popup-scroll-hint span {
  display: inline-block;
  font-size: 1.4rem;
  line-height: 1;
  transform: translateY(0);
}

@keyframes popupScrollBounce {
  0%,
  100% {
    transform: translateY(0);
    opacity: 0.72;
  }
  50% {
    transform: translateY(6px);
    opacity: 1;
  }
}

.popup-close-button {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 28px;
  height: 28px;
  padding: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  font-size: 1.35rem;
  line-height: 1;
  z-index: 3;
}

.popup-card + .popup-card {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid #e6e6e6;
}

.popup-link-list {
  display: grid;
  gap: 6px;
  margin-top: 4px;
}

.popup-link-list a {
  width: fit-content;
  font-weight: 900;
}


.leaflet-popup-content-wrapper {
  border-radius: 8px;
  background: #fffdf8;
  padding: 4px;
  box-shadow: 0 16px 38px rgba(20, 29, 26, 0.22);
  max-height: min(420px, 68vh);
  overflow: hidden;
}

.leaflet-popup-content {
  position: relative;
  display: block;
  width: 360px !important;
  max-width: calc(100vw - 72px);
  max-height: 420px;
  overflow: hidden;
  margin: 10px 12px;
  padding: 2px 8px 2px 4px;
  background: #fffdf8;
  box-sizing: border-box;
}

.leaflet-popup-content p.popup-meta {
  max-width: 100%;
}

.leaflet-popup-tip {
  background: #fffdf8;
}

.leaflet-image-layer {
  pointer-events: none;
}

@media (max-width: 880px) {
  .app-shell {
    display: block;
  }

  .panel {
    position: fixed;
    inset: 0 auto 0 0;
    width: min(440px, calc(100vw - 54px));
    padding-top: 0;
    max-height: none;
    transform: translateX(-105%);
    visibility: hidden;
    transition: transform 220ms ease, visibility 0s linear 220ms;
    border-right: 1px solid var(--line);
    border-bottom: 0;
    z-index: 1200;
  }

  .panel-resize-handle {
    display: none;
  }

  .panel.is-open {
    translate: 0;
    transform: none !important;
    visibility: visible;
    transition: transform 220ms ease;
  }

  .brand-block {
    padding-top: 14px;
    padding-right: 0;
  }

  .site-nav {
    position: static;
    grid-row: 1;
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    align-items: center;
    gap: 6px;
    margin-left: 44px;
    min-height: 44px;
    width: auto;
  }

  .site-nav a,
  .site-nav .language-toggle {
    min-width: 48px;
    padding-inline: 7px;
  }

  .menu-toggle {
    position: fixed;
    top: 14px;
    left: 14px;
    display: grid;
    place-content: center;
    gap: 4px;
    width: 44px;
    height: 44px;
    padding: 0;
    border-radius: 8px;
    background: #fffdf8;
    box-shadow: 0 10px 26px rgba(20, 29, 26, 0.2);
    z-index: 1300;
  }

  .menu-toggle span {
    display: block;
    width: 21px;
    height: 2px;
    background: var(--ink);
    transition: transform 180ms ease, opacity 180ms ease;
  }

  .menu-toggle:hover {
    background: #fffdf8;
  }

  .menu-toggle.is-open,
  .menu-toggle.is-open:hover {
    background: var(--accent);
  }

  .menu-toggle.is-open span {
    background: #fff;
  }

  .menu-toggle.is-open span:nth-child(1) {
    transform: translateY(6px) rotate(45deg);
  }

  .menu-toggle.is-open span:nth-child(2) {
    opacity: 0;
  }

  .menu-toggle.is-open span:nth-child(3) {
    transform: translateY(-6px) rotate(-45deg);
  }

  .menu-backdrop:not([hidden]) {
    position: fixed;
    inset: 0;
    display: block;
    background: rgba(20, 29, 26, 0.3);
    z-index: 1100;
  }

  .leaflet-top.leaflet-left {
    width: auto;
    right: 14px;
    left: auto;
  }

  .leaflet-top.leaflet-left .leaflet-control {
    margin: 14px 0 0;
  }

  .map-zone,
  #map {
    height: 100%;
    min-height: 0;
  }

  .site-nav .visual-assist-toggle {
    display: inline-block;
  }

  body[data-map-mode="pedestrian"] .brand-block {
    padding-right: 0;
  }

  .site-nav.has-visual-assist > * {
    flex: 1 1 auto;
  }

  body.visual-assist .map-mode-nav {
    display: none;
  }

  body.visual-assist {
    height: auto;
    overflow: visible;
  }

  body.visual-assist .app-shell {
    display: flex;
    flex-direction: column;
    height: auto;
    overflow: visible;
  }

  body.visual-assist .map-zone {
    position: sticky;
    top: 0;
    order: 1;
    flex: 0 0 auto;
    height: 50vh;
    height: 50dvh;
    z-index: 5;
  }

  body.visual-assist .accessible-list-panel {
    order: 2;
    display: grid;
    gap: 10px;
    padding: 0 14px 24px;
    border-top: 3px solid var(--accent-dark);
    background: #fffdf8;
  }

  body.visual-assist .accessible-list-tools {
    position: sticky;
    top: 50vh;
    top: 50dvh;
    z-index: 4;
    display: grid;
    gap: 8px;
    margin-inline: -14px;
    padding: 12px 14px 10px;
    border-bottom: 1px solid var(--line);
    background: #fffdf8;
  }

  html:has(body.visual-assist) {
    scroll-padding-top: calc(50dvh + 110px);
  }

  .map-instruction {
    top: 14px;
    max-width: calc(100% - 120px);
  }

  .map-first-visit-hint {
    top: 50%;
  }

  h1 {
    max-width: none;
    white-space: normal;
  }

  .brand-block {
    padding-left: 0;
    padding-right: 0;
  }

  .date-range-fields {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 6px;
  }

  .date-range-fields .icon-help {
    position: absolute;
    top: 50px;
    left: calc(50% + 30px);
    width: 24px;
    height: 24px;
    min-height: 24px;
    margin: 0;
  }

  .site-nav a,
  .site-nav .language-toggle {
    min-width: 54px;
    padding-inline: 7px;
    font-size: 0.74rem;
  }
}

@media (max-width: 520px) {
  .panel {
    padding: 14px;
    padding-top: 0;
  }

  .brand-block {
    padding-top: 14px;
    padding-left: 0;
    padding-right: 0;
  }

  .date-range-fields {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 6px;
  }

  .date-range-fields .icon-help {
    position: absolute;
    top: 50px;
    left: calc(50% + 30px);
    width: 24px;
    height: 24px;
    min-height: 24px;
    margin: 0;
  }

  .toggle-grid {
    grid-template-columns: 1fr;
  }

  .source-filters {
    grid-template-columns: 1fr 1fr;
  }

  .time-filters {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 6px;
  }

  .time-filters label {
    min-height: 38px;
    padding: 8px;
  }

  .date-range-fields {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 6px;
  }

  .date-range-fields .today-button {
    min-height: 36px;
    padding-inline: 8px;
  }

  .date-range-fields .field {
    min-width: 0;
  }

  .date-range-fields .field input {
    min-width: 0;
    padding: 9px 6px;
    font-size: 0.8rem;
  }

  .date-range-fields .icon-help {
    width: 24px;
    height: 24px;
    min-height: 24px;
    margin: 0;
  }

  .summary {
    align-items: center;
    flex-direction: row;
    gap: 8px;
    padding: 10px;
  }

  .summary button {
    flex: 0 0 auto;
    min-height: 38px;
    padding: 8px 10px;
    white-space: nowrap;
  }
}

@container (max-width: 440px) {
  .date-range-fields .field:has(.date-label-with-help) .date-label-with-help .icon-help {
    position: static !important;
    right: auto;
    bottom: auto;
  }
}