* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: #1a1a1a;
}

#map {
  position: absolute;
  inset: 0;
  z-index: 0;
}

#controls, #detail {
  position: absolute;
  background: rgba(255, 255, 255, 0.97);
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.18);
  border-radius: 6px;
  z-index: 1000;
  padding: 14px 16px;
}

#controls {
  top: 14px;
  left: 14px;
  width: 280px;
  max-width: calc(100vw - 28px);
}

#controls h1 {
  font-size: 1.05rem;
  margin: 0 0 10px 0;
}

#controls label {
  display: block;
  font-size: 0.78rem;
  color: #555;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-top: 10px;
  margin-bottom: 4px;
}

#controls select {
  width: 100%;
  padding: 6px 8px;
  font-size: 0.92rem;
  border: 1px solid #ccc;
  border-radius: 4px;
  background: #fff;
}

#legend {
  margin-top: 14px;
  font-size: 0.82rem;
}

.legend-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 3px 0;
}

.legend-swatch {
  width: 14px;
  height: 14px;
  border-radius: 2px;
  border: 1px solid rgba(0, 0, 0, 0.15);
  flex-shrink: 0;
}

.legend-gradient {
  height: 12px;
  background: linear-gradient(to right, var(--grad-from), var(--grad-to));
  border-radius: 2px;
  border: 1px solid rgba(0, 0, 0, 0.15);
  margin: 4px 0;
}

.legend-scale {
  display: flex;
  justify-content: space-between;
  font-size: 0.75rem;
  color: #555;
}

#detail {
  top: 14px;
  right: 14px;
  width: 340px;
  max-width: calc(100vw - 28px);
  max-height: calc(100vh - 28px);
  overflow-y: auto;
  padding-right: 20px;
}

#detail.hidden {
  display: none;
}

#detail-close {
  position: absolute;
  top: 8px;
  right: 8px;
  background: transparent;
  border: none;
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
  color: #666;
}

#detail-close:hover {
  color: #000;
}

#detail h2 {
  font-size: 1rem;
  margin: 0 0 4px 0;
  padding-right: 20px;
}

#detail-address {
  font-size: 0.82rem;
  color: #666;
  margin-bottom: 10px;
}

#detail h3 {
  font-size: 0.88rem;
  margin: 12px 0 6px 0;
  color: #444;
}

#detail dl {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 2px 12px;
  margin: 0;
  font-size: 0.85rem;
}

#detail dt {
  color: #666;
}

#detail dd {
  margin: 0;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

#detail table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.84rem;
}

#detail table td {
  padding: 3px 4px;
  border-bottom: 1px solid #eee;
  vertical-align: top;
}

#detail table td:nth-child(1) {
  width: 14px;
}

#detail table td:nth-child(3),
#detail table td:nth-child(4) {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.party-swatch {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 2px;
  border: 1px solid rgba(0, 0, 0, 0.15);
}

@media (max-width: 700px) {
  #controls {
    top: 8px;
    left: 8px;
    right: 8px;
    width: auto;
  }
  #detail {
    top: auto;
    right: 8px;
    left: 8px;
    bottom: 8px;
    width: auto;
    max-height: 50vh;
  }
}
