* { box-sizing: border-box; }
:root {
  --accent: #EDAD59;
}
body {
  margin: 0;
  font-family: "Segoe UI", Tahoma, sans-serif;
  background: #f6f7fb;
  color: #1f2d3d;
}
header {
  padding: 16px 20px 8px;
}
h1 {
  margin: 0 0 6px;
  font-size: 20px;
  font-weight: 700;
}
p.lead {
  margin: 0 0 10px;
  color: #4a5568;
}
p.note {
  margin: 8px 0 0;
  color: #4b5563;
  font-size: 13px;
}
main {
  display: grid;
  grid-template-columns: 1fr 380px;
  gap: 12px;
  padding: 0 20px 20px;
}
#map {
  width: 100%;
  height: 88vh;
  border-radius: 12px;
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.08);
  overflow: hidden;
  background: #e9eef4;
}
#panel {
  background: #fff;
  border-radius: 12px;
  padding: 16px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.06);
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.legend {
  display: grid;
  gap: 8px;
}

/* On larger screens the panel sits on the right: keep legends pinned to the bottom,
   and let the selected-building list take the remaining space (scrolling internally). */
@media (min-width: 961px) {
  #panel {
    height: 88vh;
    min-height: 0;
  }

  .selected-buildings {
    flex: 1 1 auto;
    max-height: none;
    min-height: 0;
  }

  .map-legends {
    margin-top: auto;
  }
}
.legend-row {
  display: grid;
  grid-template-columns: 16px 1fr;
  gap: 10px;
  align-items: center;
  font-size: 14px;
  color: #2d3748;
  cursor: pointer;
}
.legend-row.active {
  background: #f9fafc;
  border-radius: 8px;
  color: var(--accent);
  font-weight: 700;
}
#category-filter .legend-row {
  grid-template-columns: 1fr;
  padding: 0px 6px;
}
#category-filter .legend-row.active {
  background: #f8fafd;
  border-radius: 8px;
  color: var(--accent);
  font-weight: 700;
}
.swatch {
  width: 16px;
  height: 16px;
  border-radius: 4px;
  border: 1px solid rgba(0, 0, 0, 0.12);
}
.source-note {
  margin: 2px 0 4px;
  padding: 8px 10px;
  border-left: 3px solid var(--accent);
  border-radius: 4px;
  background: #f8fafc;
  color: #475569;
  font-size: 11px;
  line-height: 1.45;
}
.source-note a {
  color: #334155;
  font-weight: 700;
  text-decoration: underline;
}
.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  background: #f1f5f9;
  border-radius: 999px;
  font-size: 12px;
  color: #475569;
}

.selected-buildings {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 20px;
  max-height: 260px;
  overflow-y: auto;
  overflow-x: hidden;
  padding-right: 4px;
}

.selected-buildings.is-empty {
  opacity: 0.65;
}

.selected-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.selected-group-title {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #475569;
  margin-top: 2px;
}

.building-pill {
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: start;
  column-gap: 8px;
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  color: #000;
  text-align: right;
  border: 1px solid rgba(0, 0, 0, 0.08);
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.04);
  width: 100%;
  min-width: 0;
  cursor: pointer;
  user-select: none;
}

.building-pill.is-active {
  border-color: var(--accent);
  border-width: 2.5px;
  /* font-weight: 700; */
}

.building-pill:hover {
  filter: brightness(0.98);
}

.building-pill:focus {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.building-pill .primary {
  min-width: 0;
  overflow: visible;
  white-space: normal;
  word-break: break-word;
  justify-self: end;
  text-align: right;
}

.building-pill .sep {
  font-weight: 800;
  opacity: 1;
  white-space: nowrap;
  justify-self: end;
}

.building-pill .secondary {
  letter-spacing: 0;
  text-transform: none;
  opacity: 1;
  white-space: normal;
  min-width: 0;
  overflow: visible;
  word-break: break-word;
  justify-self: end;
  text-align: right;
}
#selected {
  font-size: 14px;
  color: #1f2937;
}
#zone-count {
  font-size: 13px;
  color: #374151;
}
.ol-overlay-container {
  pointer-events: auto;
}
.tooltip {
  background: #0f172a;
  color: #fff;
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 12px;
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.22);
  max-width: 240px;
  line-height: 1.35;
}
.tooltip a {
  color: #60a5fa;
  text-decoration: underline;
}
@media (max-width: 960px) {
  main {
    grid-template-columns: 1fr;
  }
  #map {
    height: 70vh;
  }
}
