html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: Arial, sans-serif;
  color: #111827;
}

#map {
  position: absolute;
  top: 0;
  left: 0;
  right: 540px;
  bottom: 0;
  background: #dfe6ee;
}

#sidebar {
  position: absolute;
  top: 0;
  right: 0;
  width: 540px;
  bottom: 0;
  overflow: auto;
  border-left: 1px solid #cbd5e1;
  background: #ffffff;
  padding: 12px;
  box-sizing: border-box;
}

h1 {
  margin: 0 0 4px 0;
  font-size: 21px;
  font-weight: 700;
}

h2 {
  margin: 0 0 8px 0;
  font-size: 15px;
  font-weight: 700;
}

h3 {
  margin: 0 0 6px 0;
  font-size: 14px;
}

.subtitle {
  margin-bottom: 10px;
  color: #4b5563;
}

.panel {
  border: 1px solid #d1d5db;
  background: #fafafa;
  padding: 9px;
  margin: 8px 0;
}

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

.grid2.tight {
  gap: 6px;
}

.grid2 label {
  display: block;
  font-size: 12px;
  color: #374151;
}

.grid2 select,
.grid2 input,
.floating-controls select,
.floating-controls input {
  width: 100%;
  box-sizing: border-box;
  padding: 6px;
  font-size: 13px;
  margin-top: 4px;
  border: 1px solid #cbd5e1;
  background: #ffffff;
}

.floating-controls {
  position: absolute;
  z-index: 1200;
  right: 14px;
  top: 14px;
  width: 365px;
  max-height: calc(100vh - 28px);
  overflow-y: auto;
  background: rgba(255,255,255,0.95);
  border: 1px solid #cbd5e1;
  box-shadow: 0 8px 28px rgba(0,0,0,0.18);
  padding: 10px;
}

.float-title {
  font-size: 13px;
  font-weight: 800;
  margin-bottom: 8px;
  color: #1f2937;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.floating-controls label {
  display: block;
  font-size: 12px;
  color: #374151;
  margin-bottom: 7px;
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

.button-row.compact {
  margin-bottom: 8px;
}

button {
  padding: 8px 10px;
  border: 1px solid #999;
  background: #f4f4f4;
  cursor: pointer;
  font-size: 13px;
}

button:hover {
  background: #e8e8e8;
}

.btn-small {
  padding: 4px 8px;
  font-size: 12px;
}

.small {
  font-size: 12px;
  color: #444;
}

.muted {
  color: #6b7280;
}

.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  white-space: pre-wrap;
}

.legend-note,
.chart-note {
  margin-top: 6px;
  color: #4b5563;
}

canvas {
  width: 100%;
  height: 320px;
  border: 1px solid #e5e7eb;
  background: #ffffff;
}

.station-list {
  max-height: 360px;
  overflow-y: auto;
  border: 1px solid #e5e7eb;
  background: #ffffff;
  padding: 6px;
}

.station-row {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  border-bottom: 1px solid #e5e7eb;
  padding: 8px 0;
}

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

.station-main {
  flex: 1;
  min-width: 0;
}

.station-actions {
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: flex-end;
  min-width: 115px;
}

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

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

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.data-table th,
.data-table td {
  border-bottom: 1px solid #e5e7eb;
  padding: 6px 7px;
  text-align: left;
  vertical-align: top;
}

.data-table th {
  color: #374151;
  background: #f3f4f6;
  font-weight: 700;
}

.data-table td.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.station-id {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-weight: 700;
  color: #1d4ed8;
}

.badge {
  display: inline-block;
  padding: 2px 6px;
  border-radius: 999px;
  background: #e0f2fe;
  color: #075985;
  border: 1px solid #bae6fd;
  font-weight: 700;
}

.excluded {
  opacity: 0.45;
}

.keep-card {
  background: linear-gradient(90deg, rgba(34, 139, 34, 0.18), rgba(0, 100, 0, 0.58));
  border-color: rgba(0, 100, 0, 0.45);
}

.pass-card {
  background: linear-gradient(90deg, rgba(143, 55, 38, 0.50), rgba(143, 55, 38, 0.05));
  border-color: rgba(143, 55, 38, 0.45);
}

.ffa-card {
  border: 1px solid #ddd;
  background: #fff;
  padding: 10px;
  margin: 10px 0;
}

.ffa-card-header {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: baseline;
  margin-bottom: 8px;
}

.ffa-title {
  font-weight: 700;
}

.ffa-meta {
  color: #555;
  font-size: 12px;
}

.ffa-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.keep-btn {
  background: rgba(34, 139, 34, 0.16);
  border-color: rgba(0, 100, 0, 0.45);
}

.keep-btn.active {
  background: #0b5d1e;
  color: #ffffff;
}

.pass-btn {
  background: rgba(143, 55, 38, 0.16);
  border-color: rgba(143, 55, 38, 0.45);
}

.pass-btn.active {
  background: #8f3726;
  color: #ffffff;
}

.ffa-plot-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

.ffa-plot {
  border: 1px solid #e5e7eb;
  background: #ffffff;
  padding: 6px;
}

.ffa-plot-title {
  font-size: 12px;
  font-weight: 700;
  margin-bottom: 4px;
  color: #374151;
}

.ffa-plot img {
  width: 100%;
  display: block;
}

.radius-handle {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid #dc2626;
  box-shadow: 0 0 0 1px rgba(0,0,0,0.2);
}

.circle-center {
  width: 17px;
  height: 17px;
  border-radius: 50%;
  background: #ffffff;
  border: 3px solid #2563eb;
  box-shadow: 0 0 0 2px rgba(37,99,235,0.18);
}

.station-svg-icon {
  background: transparent;
  border: none;
}

.leaflet-popup-content-wrapper {
  border-radius: 8px;
}

.leaflet-popup-content {
  margin: 10px 12px;
  font-size: 12px;
  line-height: 1.4;
}

.popup-title {
  font-weight: 700;
  margin-bottom: 4px;
}

.client-boundary {
  fill: #2563eb;
  fill-opacity: 0.07;
  stroke: #1d4ed8;
  stroke-width: 2;
}

@media (max-width: 1050px) {
  #map {
    right: 0;
    bottom: 45%;
  }

  #sidebar {
    top: 55%;
    left: 0;
    width: auto;
    border-left: none;
    border-top: 1px solid #cbd5e1;
  }

  .floating-controls {
    width: 330px;
  }
}
\n
/* Ontario / highlight patch */
.float-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

.float-collapse-btn {
  width: 30px;
  height: 28px;
  padding: 0;
  line-height: 1;
  font-weight: 800;
}

.floating-controls.collapsed {
  width: 220px;
  max-height: 42px;
  overflow: hidden;
}

.floating-controls.collapsed > *:not(.float-header) {
  display: none !important;
}

.highlight-row {
  outline: 2px solid #f59e0b;
  background: #fff7ed !important;
}

.highlight-muni-row {
  outline: 2px solid #0f766e;
  background: #ecfdf5 !important;
}

.highlight-station-card {
  outline: 3px solid #f59e0b;
  box-shadow: 0 0 0 4px rgba(245, 158, 11, 0.20);
}


/* Municipal FFA popup + catchment overlay */
.muni-ffa-popup {
  font-size: 12px;
  line-height: 1.35;
}

.popup-subtitle {
  color: #4b5563;
  margin: 2px 0 8px 0;
}

.popup-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 8px 0;
}

.popup-actions button,
.mini-popup-actions button,
.link-button {
  border: 1px solid #cbd5e1;
  background: #f8fafc;
  color: #111827;
  border-radius: 6px;
  padding: 4px 7px;
  font-size: 11px;
  cursor: pointer;
}

.link-button {
  color: #1d4ed8;
  background: transparent;
  border-color: transparent;
  padding: 0;
  font-weight: 700;
}

.popup-section {
  border-top: 1px solid #e5e7eb;
  margin-top: 8px;
  padding-top: 7px;
}

.popup-list {
  margin: 4px 0 0 16px;
  padding: 0;
}

.popup-list li {
  margin: 3px 0;
}

.mini-rug {
  display: block;
  width: 100%;
  max-width: 420px;
  margin-top: 5px;
}

.mini-rug line {
  stroke: #2f855a;
  stroke-width: 1.2;
  opacity: 0.58;
}

.mini-rug line.strong {
  stroke: #7f1d1d;
  stroke-width: 2.0;
  opacity: 0.82;
}

.mini-rug .axis,
.mini-rug .tick {
  stroke: #374151;
  stroke-width: 1;
  opacity: 0.8;
}

.mini-rug text {
  font-size: 8px;
  fill: #374151;
  text-anchor: middle;
}

.mini-rug.empty {
  color: #6b7280;
  font-style: italic;
  margin-top: 4px;
}

.mini-rug-caption {
  color: #4b5563;
  font-size: 11px;
  margin-top: 2px;
}

.error {
  color: #991b1b;
  font-weight: 700;
}

#activeTarget option[value="catchments"] {
  font-weight: 700;
}



/* Q-A popup and interaction modes patch */
.muni-ffa-qa-popup {
  min-width: 440px;
}

.popup-qa-svg {
  width: 100%;
  max-width: 440px;
  border: 1px solid #e5e7eb;
  background: white;
}

.popup-qa-svg .grid {
  stroke: #e5e7eb;
  stroke-width: 1;
}

.popup-qa-svg .axis {
  stroke: #111827;
  stroke-width: 1.2;
}

.popup-qa-svg .catch-line {
  stroke: #2f855a;
  stroke-width: 1.1;
  opacity: 0.32;
}

.popup-qa-svg .catch-line.catch-strong {
  stroke: #7f1d1d;
  stroke-width: 1.8;
  opacity: 0.70;
}

.popup-qa-svg .reg-line {
  fill: none;
  stroke: #225ea8;
  stroke-width: 2.0;
}

.popup-qa-svg .station-dot {
  stroke: #111827;
  stroke-width: 0.7;
}

.popup-qa-svg .station-dot.keep {
  fill: #225ea8;
}

.popup-qa-svg .station-dot.pass {
  fill: #cbd5e1;
}

.popup-qa-svg .plot-title {
  font-size: 10px;
  font-weight: 700;
  fill: #111827;
}

.popup-qa-svg .axis-label {
  font-size: 8px;
  fill: #374151;
  text-anchor: middle;
}

.popup-qa-svg .ylab {
  text-anchor: end;
}

.popup-qa-svg .x-title {
  font-size: 8px;
  fill: #374151;
  text-anchor: middle;
}

.popup-qa-caption,
.popup-qa-empty {
  font-size: 11px;
  color: #4b5563;
  margin-top: 3px;
}



/* Map tools fix */
.map-tools-box {
  border-top: 1px solid #e5e7eb;
  margin-top: 8px;
  padding-top: 8px;
}

.map-tools-title {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #374151;
  font-weight: 800;
  margin-bottom: 4px;
}

.map-tools-circle-center {
  background: #ffffff;
  border: 3px solid #2563eb;
  box-shadow: 0 0 0 2px rgba(37,99,235,0.24), 0 2px 7px rgba(0,0,0,0.25);
}



/* Municipality switcher + gauge-only active controls */
.hidden-by-switcher {
  display: none !important;
}

.working-community-box {
  border: 1px solid #d1d5db;
  background: #f8fafc;
  padding: 8px;
  margin: 8px 0;
}

.wc-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #475569;
  font-weight: 800;
}

.wc-name {
  font-size: 14px;
  font-weight: 800;
  color: #111827;
  margin-top: 2px;
}

.wc-slug {
  font-size: 11px;
  color: #64748b;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

.wc-buttons {
  margin-top: 7px;
}

.wc-buttons button {
  font-size: 11px;
  padding: 5px 7px;
}

.municipality-search-panel {
  position: absolute;
  z-index: 1300;
  left: 14px;
  bottom: 14px;
  width: 340px;
  max-height: 42vh;
  overflow: hidden;
  background: rgba(255,255,255,0.96);
  border: 1px solid #cbd5e1;
  box-shadow: 0 8px 28px rgba(0,0,0,0.18);
  padding: 10px;
}

.municipality-search-title {
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #1f2937;
  margin-bottom: 6px;
}

#municipalitySearchInput {
  width: 100%;
  box-sizing: border-box;
  padding: 7px;
  border: 1px solid #cbd5e1;
  font-size: 13px;
  margin-bottom: 6px;
}

.municipality-search-results {
  max-height: 30vh;
  overflow-y: auto;
  border: 1px solid #e5e7eb;
  background: #fff;
}

.municipality-result {
  width: 100%;
  display: block;
  text-align: left;
  border: 0;
  border-bottom: 1px solid #e5e7eb;
  background: #fff;
  padding: 7px 8px;
  cursor: pointer;
}

.municipality-result:hover {
  background: #f1f5f9;
}

.municipality-result.active {
  background: #dcfce7;
  font-weight: 800;
}

.municipality-result span {
  display: block;
  font-size: 12px;
  color: #111827;
}

.municipality-result small {
  display: block;
  font-size: 10px;
  color: #64748b;
  margin-top: 2px;
}

.municipality-result.muted {
  color: #64748b;
  font-size: 12px;
  cursor: default;
}

@media (max-width: 1050px) {
  .municipality-search-panel {
    width: 300px;
    max-height: 34vh;
  }
}

