: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;
  font-family: "Aptos", "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  height: 100%;
}

body {
  margin: 0;
  height: 100%;
  min-height: 100vh;
  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: minmax(460px, 540px) 1fr;
  height: 100vh;
  min-height: 0;
  overflow: hidden;
}

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

.menu-toggle {
  display: none;
}

.menu-backdrop {
  display: none;
}

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

.brand-block {
  display: grid;
  gap: 8px;
}

.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 {
  max-width: 16ch;
  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 {
  display: flex;
  gap: 6px;
  margin-top: 4px;
}

.site-nav a {
  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;
}

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

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

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

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

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

.section-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 30px;
  margin-left: auto;
  padding: 5px 8px 5px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--accent-dark);
  font-size: 0.76rem;
  font-weight: 800;
}

.section-toggle:hover,
.section-toggle.is-open {
  background: #e7f2ee;
  color: var(--accent-dark);
}

.section-toggle b {
  width: 14px;
  color: var(--ink);
  font-size: 1.1rem;
  line-height: 1;
  text-align: center;
}

.source-filters[hidden] {
  display: none;
}

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

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

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

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

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

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

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

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

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

.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-faq-link {
  width: fit-content;
  margin-top: 3px;
  color: var(--accent-dark);
  font-size: 0.82rem;
  font-weight: 800;
}

.source-faq-link:hover {
  text-decoration: underline;
}

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

.popup-meta {
  margin: 0 0 6px;
  color: #52615b;
  line-height: 1.35;
}

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

.popup-group-title {
  margin-bottom: 10px;
  color: var(--ink);
  font-weight: 900;
}

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

.leaflet-popup-content {
  width: 360px !important;
  max-width: calc(100vw - 72px);
  max-height: 420px;
  overflow-y: auto;
  margin: 10px 12px;
  padding: 2px 8px 2px 4px;
  background: #fffdf8;
}

.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));
    max-height: none;
    transform: translateX(-105%);
    transition: transform 220ms ease;
    border-right: 1px solid var(--line);
    border-bottom: 0;
    z-index: 1200;
  }

  .panel.is-open {
    translate: 0;
    transform: none !important;
  }

  .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: 100vh;
    min-height: 0;
  }

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

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

  .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) 30px;
    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-bottom: 8px;
  }

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