:root {
  --bg: #ffffff;
  --surface: #ffffff;
  --surface-soft: #f6f8fb;
  --surface-selected: #eef6ff;
  --text: #071936;
  --text-muted: #647187;
  --text-soft: #8791a2;
  --border: #dbe2ea;
  --border-soft: #edf1f5;
  --blue: #0a66db;
  --blue-dark: #0757c4;
  --green: #16a04b;
  --green-dark: #0e8b3c;
  --gray-marker: #8f9aa8;
  --shadow: 0 18px 44px rgba(10, 30, 64, 0.16);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body,
#map {
  height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
}

.leaflet-container {
  position: relative;
  overflow: hidden;
  outline-offset: 1px;
  background: #dce5ea;
}

.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 {
  max-width: none !important;
  max-height: none !important;
}

.leaflet-tile {
  width: 256px;
  height: 256px;
  user-select: none;
  border: 0;
}

.leaflet-marker-icon {
  display: block;
}

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

.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-top,
.leaflet-bottom {
  position: absolute;
  z-index: 1000;
  pointer-events: none;
}

.leaflet-top {
  top: 0;
}

.leaflet-bottom {
  bottom: 0;
}

.leaflet-left {
  left: 0;
}

.leaflet-right {
  right: 0;
}

.leaflet-control-zoom {
  margin: 0 16px 16px 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  background: #ffffff;
  box-shadow: 0 8px 22px rgba(10, 30, 64, 0.14);
}

.leaflet-control-zoom a {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-bottom: 1px solid var(--border);
  background: #ffffff;
  color: var(--text);
  text-decoration: none;
  font-size: 22px;
  font-weight: 500;
}

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

.leaflet-control-attribution {
  margin: 0 0 6px 6px;
  padding: 4px 7px;
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.86);
}

.leaflet-popup {
  position: absolute;
  margin-bottom: 20px;
  text-align: left;
}

.leaflet-popup-content-wrapper {
  background: #ffffff;
  overflow: hidden;
}

.leaflet-popup-content {
  line-height: 1.4;
}

.leaflet-popup-tip-container {
  position: absolute;
  left: 50%;
  width: 40px;
  height: 20px;
  margin-left: -20px;
  overflow: hidden;
  pointer-events: none;
}

.leaflet-popup-tip {
  width: 17px;
  height: 17px;
  margin: -9px auto 0;
  background: #ffffff;
  transform: rotate(45deg);
  box-shadow: var(--shadow);
}

.leaflet-popup-close-button {
  position: absolute;
  top: 16px;
  right: 16px;
  z-index: 2;
  width: 24px;
  height: 24px;
  color: var(--text-muted);
  text-align: center;
  text-decoration: none;
  font-size: 24px;
  line-height: 22px;
}

.leaflet-popup-close-button:hover {
  color: var(--text);
}

button,
input {
  font: inherit;
}

a {
  color: inherit;
}

.app-shell {
  min-height: 100vh;
  overflow: hidden;
}

.app-header {
  display: grid;
  grid-template-columns: 420px minmax(280px, 520px) 1fr;
  align-items: center;
  gap: 28px;
  height: 74px;
  border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.96);
  padding: 0 28px;
  position: relative;
  z-index: 20;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 16px;
  width: fit-content;
  color: var(--text);
  text-decoration: none;
  font-size: 28px;
  font-weight: 800;
  line-height: 1;
  letter-spacing: 0;
}

.brand-mark {
  color: var(--blue);
  font-size: 24px;
  line-height: 1;
}

.search-box {
  display: flex;
  align-items: center;
  gap: 12px;
  height: 46px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text-muted);
  padding: 0 16px;
  box-shadow: 0 1px 0 rgba(10, 30, 64, 0.03);
}

.search-box:focus-within {
  border-color: rgba(10, 102, 219, 0.45);
  box-shadow: 0 0 0 4px rgba(10, 102, 219, 0.1);
}

.search-box i {
  font-size: 16px;
}

.search-box input {
  min-width: 0;
  width: 100%;
  border: 0;
  outline: 0;
  color: var(--text);
  background: transparent;
  font-size: 15px;
}

.search-box input::placeholder {
  color: var(--text-soft);
}

.open-toggle {
  display: inline-flex;
  align-items: center;
  justify-self: end;
  gap: 14px;
  color: var(--text);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  user-select: none;
}

.open-toggle input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.toggle-track {
  position: relative;
  width: 50px;
  height: 28px;
  border-radius: 999px;
  background: #e0e6ee;
  transition: background 180ms ease;
}

.toggle-thumb {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #ffffff;
  box-shadow: 0 2px 8px rgba(10, 30, 64, 0.18);
  transition: transform 180ms ease;
}

.open-toggle input:checked + .toggle-track {
  background: var(--green);
}

.open-toggle input:checked + .toggle-track .toggle-thumb {
  transform: translateX(22px);
}

.main-layout {
  display: grid;
  grid-template-columns: 420px minmax(0, 1fr);
  height: calc(100vh - 74px);
  min-height: 0;
  overflow: hidden;
}

.sidebar {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  overflow: hidden;
}

.sidebar-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 84px;
  padding: 22px 28px 18px;
  border-bottom: 1px solid var(--border-soft);
}

.pool-count {
  margin: 0;
  color: var(--text);
  font-size: 16px;
  font-weight: 800;
}

.summary-copy {
  margin: 6px 0 0;
  color: var(--text-muted);
  font-size: 13px;
  line-height: 1.35;
}

.icon-button {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #ffffff;
  color: var(--text-muted);
  cursor: pointer;
}

.icon-button:hover {
  color: var(--blue);
  border-color: rgba(10, 102, 219, 0.35);
}

.tooltip {
  position: absolute;
  right: 0;
  bottom: -34px;
  min-width: 76px;
  padding: 7px 9px;
  border-radius: 6px;
  background: var(--text);
  color: #ffffff;
  font-size: 12px;
  line-height: 1;
  opacity: 0;
  transform: translateY(-4px);
  transition:
    opacity 160ms ease,
    transform 160ms ease;
  pointer-events: none;
  white-space: nowrap;
  z-index: 50;
}

.icon-button:hover .tooltip {
  opacity: 1;
  transform: translateY(0);
}

.pool-list {
  overflow: auto;
  padding-bottom: 18px;
}

.district-group {
  border-bottom: 1px solid var(--border-soft);
}

.district-heading {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 17px 28px 8px;
  color: #59657a;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.district-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 24px;
  height: 22px;
  padding: 0 7px;
  border-radius: 999px;
  background: #edf1f6;
  color: #718094;
  font-size: 12px;
  font-weight: 700;
}

.pool-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 16px;
  width: 100%;
  min-height: 72px;
  border: 0;
  border-left: 3px solid transparent;
  background: #ffffff;
  color: var(--text);
  text-align: left;
  padding: 13px 28px 13px 25px;
  cursor: pointer;
}

.pool-row:hover {
  background: #f8fbff;
}

.pool-row.is-selected {
  border-left-color: var(--blue);
  background: var(--surface-selected);
}

.pool-row-main {
  min-width: 0;
}

.pool-row-name {
  display: block;
  overflow: hidden;
  color: var(--text);
  font-size: 14px;
  font-weight: 800;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pool-row-district {
  display: block;
  margin-top: 4px;
  overflow: hidden;
  color: var(--text-muted);
  font-size: 13px;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pool-row-status {
  display: grid;
  justify-items: start;
  align-content: center;
  min-width: 86px;
  color: var(--text-muted);
  font-size: 13px;
  line-height: 1.35;
}

.status-line {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
  font-weight: 700;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--gray-marker);
}

.status-dot.is-open {
  background: var(--green);
}

.hours-line {
  margin-top: 5px;
  color: var(--text-muted);
}

.empty-list {
  padding: 34px 28px;
  color: var(--text-muted);
  font-size: 14px;
  line-height: 1.5;
}

.map-region {
  position: relative;
  min-width: 0;
  min-height: 0;
  background: #edf2f4;
  overflow: hidden;
}

#map {
  width: 100%;
  min-height: 360px;
}

.map-empty {
  position: absolute;
  top: 24px;
  left: 50%;
  z-index: 600;
  transform: translateX(-50%);
  width: min(320px, calc(100% - 32px));
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #ffffff;
  color: var(--text-muted);
  box-shadow: var(--shadow);
  text-align: center;
  padding: 14px 18px;
}

.map-empty p {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
}

.pool-marker {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 3px solid #ffffff;
  border-radius: 50%;
  background: var(--gray-marker);
  color: #ffffff;
  box-shadow: 0 8px 18px rgba(10, 30, 64, 0.28);
  font-size: 14px;
}

.pool-marker.is-open {
  background: var(--green);
}

.pool-marker.is-selected {
  width: 46px;
  height: 46px;
  border-width: 4px;
  outline: 4px solid rgba(22, 160, 75, 0.22);
  font-size: 18px;
}

.leaflet-popup-content-wrapper {
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.leaflet-popup-content {
  width: 300px;
  margin: 0;
}

.pool-popup {
  padding: 22px 22px 18px;
  color: var(--text);
}

.pool-popup h2 {
  margin: 0 28px 8px 0;
  color: var(--text);
  font-size: 20px;
  font-weight: 800;
  line-height: 1.25;
  letter-spacing: 0;
}

.popup-address {
  margin: 0 0 14px;
  color: var(--text-muted);
  font-size: 14px;
  line-height: 1.45;
}

.popup-status {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 700;
}

.popup-status.is-open {
  color: var(--green-dark);
}

.popup-rule {
  height: 1px;
  background: var(--border);
  margin: 0 0 16px;
}

.popup-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
  color: var(--text-muted);
  font-size: 14px;
}

.popup-row strong {
  color: var(--text);
  font-size: 15px;
}

.popup-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.popup-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 40px;
  border: 1px solid var(--blue);
  border-radius: 6px;
  color: var(--blue-dark);
  background: #ffffff;
  text-decoration: none;
  font-size: 14px;
  font-weight: 800;
}

.popup-action.primary {
  background: var(--blue);
  color: #ffffff;
}

.popup-action:hover {
  filter: brightness(0.97);
}

.leaflet-control-zoom a {
  color: var(--text);
}

.leaflet-control-attribution {
  color: #667386;
  font-size: 11px;
}

@media (max-width: 980px) {
  .app-shell {
    overflow: auto;
  }

  .app-header {
    grid-template-columns: 1fr auto;
    height: auto;
    min-height: 74px;
    gap: 14px;
    padding: 14px 18px;
  }

  .brand {
    font-size: 23px;
  }

  .search-box {
    grid-column: 1 / -1;
    order: 3;
    width: 100%;
  }

  .main-layout {
    grid-template-columns: 1fr;
    height: auto;
  }

  .map-region {
    order: 1;
    height: 54vh;
    min-height: 420px;
  }

  .sidebar {
    order: 2;
    max-height: none;
    border-right: 0;
    border-top: 1px solid var(--border);
  }

  .sidebar-summary,
  .district-heading {
    padding-left: 20px;
    padding-right: 20px;
  }

  .pool-row {
    padding-left: 17px;
    padding-right: 20px;
  }
}

@media (max-width: 560px) {
  .app-header {
    grid-template-columns: 1fr;
    align-items: start;
  }

  .open-toggle {
    justify-self: start;
  }

  .map-region {
    height: 48vh;
    min-height: 360px;
  }

  .pool-row {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .pool-row-status {
    min-width: 0;
  }

  .leaflet-popup-content {
    width: min(290px, calc(100vw - 48px));
  }
}
