:root {
  --bg: #ffffff;
  --text: #111827;
  --shadow: 0 2px 6px rgba(0,0,0,0.08);
}

* { box-sizing: border-box; }
html, body, #app {
  height: 100%;
  margin: 0;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Ubuntu, Helvetica Neue, Arial, Noto Sans;
  color: var(--text);
  display: flex;
  flex-direction: column;
}

/* Header */
#ui {
  flex: 0 0 auto;
  min-height: 72px;
  background: var(--bg);
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
}
#map { flex: 1; min-height: 0; }

/* 3 columnas */
.ui-inner {
  width: 100%;
  max-width: 1400px;
  margin: 0 auto;
  padding: 10px 20px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
}
.ui-left  { display: flex; justify-content: flex-start; align-items: center; }
.ui-center { display: flex; justify-content: center; }
.ui-right  { display: flex; justify-content: flex-end; }

/* Título */
.map-title {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  color: #111;
  white-space: nowrap;
}

/* Leyenda */
.legend { text-align: center; }
.legend-title {
  margin: 0 0 2px;
  font-size: 15px;
  font-weight: 700;
  color: #111;
}
.legend-subtitle {
  margin: 0 0 6px;
  font-size: 12px;
  font-weight: 400;
  color: #6b7280;
}
.legend-grid { display: grid; gap: 4px; }
.legend-swatches,
.legend-labels {
  display: grid;
  grid-template-columns: repeat(8, 36px);
  gap: 2px 4px;
  justify-content: center;
  align-items: center;
}
.legend-swatches .sw {
  width: 36px;
  height: 12px;
  border-radius: 2px;
  border: 1px solid rgba(0,0,0,0.08);
}
.legend-labels span {
  font-size: 10px;
  font-weight: 600;
  color: #374151;
  white-space: nowrap;
  text-align: center;
}

/* Popup */
.maplibregl-popup {
  max-width: 260px;
  font: 13px/1.4 system-ui, -apple-system, Segoe UI, Roboto, Ubuntu, Helvetica Neue, Arial, Noto Sans;
}
.maplibregl-popup-content {
  padding: 12px 14px;
  border-radius: 12px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.15);
}
.pp-title {
  margin: 0 0 8px;
  font-size: 14px;
  font-weight: 700;
  color: #111;
}
.pp-time {
  font-size: 22px;
  font-weight: 700;
  color: #111;
  margin-bottom: 4px;
}
.pp-footer {
  font-size: 11px;
  color: #6b7280;
  margin-top: 6px;
}

/* Geocoder */
.geocoder-ctrl {
  position: relative;
  width: 260px;
}
.geocoder-input {
  width: 100%;
  padding: 8px 12px;
  font-size: 13px;
  font-family: inherit;
  border: none;
  border-radius: 4px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.20);
  background: #fff;
  color: #111;
  outline: none;
}
.geocoder-input:focus {
  box-shadow: 0 0 0 2px rgba(59,130,246,0.5);
}
.geocoder-input::placeholder { color: #9ca3af; }
.geocoder-results {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: #fff;
  border-radius: 4px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.18);
  z-index: 10;
  max-height: 260px;
  overflow-y: auto;
}
.geocoder-item {
  padding: 9px 12px;
  font-size: 12px;
  line-height: 1.4;
  cursor: pointer;
  color: #111;
  border-bottom: 1px solid #f3f4f6;
}
.geocoder-item:last-child { border-bottom: none; }
.geocoder-item:hover { background: #f0f4ff; }
.geocoder-empty { color: #9ca3af; cursor: default; }
.geocoder-empty:hover { background: none; }

/* Responsive */
@media (max-width: 860px) {
  .ui-inner {
    grid-template-columns: 1fr;
    row-gap: 8px;
  }
  .ui-left, .ui-center, .ui-right { justify-content: center; }
  .map-title { font-size: 14px; }
  .legend-swatches,
  .legend-labels {
    grid-template-columns: repeat(8, 1fr);
  }
  .legend-swatches .sw { width: 100%; }
}
