html, body {
  height: 100%;
  margin: 0;
  font-family: system-ui, -apple-system, Segoe UI, sans-serif;
}

#map {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
}

.legend {
  position: absolute;
  z-index: 1000;
  top: 12px;
  left: 52px;
  background: rgba(255, 255, 255, 0.92);
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 13px;
  line-height: 1.4;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
  max-width: 260px;
}

.legend strong {
  font-size: 14px;
}

.layer-toggle {
  display: flex;
  gap: 4px;
  margin: 6px 0;
}

.layer-btn {
  flex: 1;
  font-size: 12px;
  padding: 4px 6px;
  cursor: pointer;
  border: 1px solid #999;
  border-radius: 4px;
  background: #fff;
  color: #333;
}

.layer-btn.active {
  background: #0a3d62;
  color: #fff;
  border-color: #0a3d62;
}

.grid-chunk-canvas {
  pointer-events: none;
}

.locate-box {
  position: absolute;
  z-index: 1000;
  top: 12px;
  right: 12px;
  background: rgba(255, 255, 255, 0.92);
  padding: 10px 12px;
  border-radius: 6px;
  font-size: 13px;
  line-height: 1.4;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: 170px;
}

.locate-box strong {
  font-size: 13px;
}

.locate-box label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.locate-box input {
  width: 90px;
  font-size: 12px;
  padding: 2px 4px;
}

.locate-box button {
  font-size: 12px;
  padding: 4px 6px;
  cursor: pointer;
}

#locate-result {
  font-size: 12px;
  color: #0a3d62;
  min-height: 1.4em;
}

.heatmap-legend {
  position: absolute;
  z-index: 1000;
  bottom: 24px;
  left: 12px;
  background: rgba(255, 255, 255, 0.92);
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 12px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
  width: 200px;
}

.heatmap-legend strong {
  font-size: 13px;
}

.heatmap-gradient {
  height: 10px;
  margin: 6px 0 4px;
  border-radius: 3px;
  background: linear-gradient(
    to right,
    rgb(44, 123, 182),
    rgb(255, 255, 140),
    rgb(215, 25, 28)
  );
}

#heatmap-legend-counts {
  color: #555;
  margin-top: 2px;
}

.legend-key {
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px solid rgba(0, 0, 0, 0.15);
  font-size: 11px;
  color: #333;
  line-height: 1.8;
}

.key-swatch {
  display: inline-block;
  width: 10px;
  height: 10px;
  margin-right: 4px;
  vertical-align: middle;
  border: 1px solid #333;
}

.key-data {
  background: rgba(120, 120, 120, 0.5);
}

.key-survey {
  background: rgba(120, 120, 120, 0.5);
  border-style: dotted;
}

.key-interp {
  background: rgba(120, 120, 120, 0.25);
  border-style: dashed;
}

.key-city {
  background: rgba(184, 134, 11, 0.4);
  border-style: groove;
}

.key-soil {
  background: rgba(120, 120, 120, 0.5);
}

.source-soil {
  background: #1b7a3d;
  color: #fff;
}

.grid-popup h3 {
  margin: 0 0 6px;
  font-size: 14px;
  color: #0a3d62;
}

.source-badge {
  font-size: 10px;
  padding: 1px 5px;
  border-radius: 3px;
  font-weight: 600;
  vertical-align: middle;
}

.source-data {
  background: #2c7bb6;
  color: #fff;
}

.source-survey {
  background: #1b7a3d;
  color: #fff;
}

.source-interpolated {
  background: #888;
  color: #fff;
}

.source-city {
  background: #b8860b;
  color: #fff;
}

.grid-popup table {
  border-collapse: collapse;
  font-size: 12px;
}

.grid-popup td {
  padding: 2px 6px;
}

.grid-popup td:first-child {
  color: #555;
  font-weight: 600;
}
