:root { --gris-sd: #e3e3e3; --texto: #1a1a1a; --azul: #1b3a6b; font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
html, body { margin: 0; height: 100%; color: var(--texto); }
#mapa { position: absolute; inset: 0; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Barra superior: buscador + selector de capa */
.barra { position: absolute; top: 10px; left: 10px; z-index: 3; display: flex; gap: 10px; flex-wrap: wrap; max-width: calc(100% - 200px); }
.buscador { position: relative; width: 260px; }
.capa { width: 250px; }
.barra input, .barra select { box-sizing: border-box; width: 100%; height: 40px; font: inherit; font-size: 15px; padding: 0 12px; border: 1px solid #c9c9c9; border-radius: 2px; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.18); color: var(--texto); }
.barra select { font-weight: 600; color: var(--azul); cursor: pointer; }
.barra input:focus-visible, .barra select:focus-visible { outline: 2px solid #1d84ce; outline-offset: 1px; }
#sugerencias { position: absolute; top: 42px; left: 0; right: 0; margin: 0; padding: 0; list-style: none; background: #fff; border: 1px solid #c9c9c9; box-shadow: 0 4px 10px rgba(0,0,0,.2); max-height: 320px; overflow: auto; }
#sugerencias li { padding: 8px 12px; font-size: 14px; cursor: pointer; display: flex; justify-content: space-between; gap: 8px; }
#sugerencias li small { color: #777; }
#sugerencias li[aria-selected="true"], #sugerencias li:hover { background: #eaf1fb; }

/* Botones de vista */
.vista { position: absolute; top: 10px; right: 10px; z-index: 3; display: flex; box-shadow: 0 1px 4px rgba(0,0,0,.3); border-radius: 4px; overflow: hidden; }
.vista button { font: inherit; font-size: 13px; padding: 8px 12px; border: 0; background: #fff; cursor: pointer; min-height: 40px; }
.vista button + button { border-left: 1px solid #ccc; }
.vista button.activo { background: var(--azul); color: #fff; }
.vista button:focus-visible { outline: 2px solid #1d84ce; outline-offset: -2px; }

/* Leyenda */
.leyenda { position: absolute; left: 10px; bottom: 28px; z-index: 3; width: 300px; max-width: calc(100% - 20px); box-sizing: border-box; background: #fff; border: 1px solid #ddd; box-shadow: 0 1px 4px rgba(0,0,0,.25); padding: 10px 12px; font-size: 13px; }
.leyenda h2 { margin: 0; font-size: 15px; display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.leyenda h2 button { font: inherit; font-size: 13px; font-weight: 600; color: var(--azul); background: none; border: 0; cursor: pointer; padding: 2px 0; }
.leyenda p { margin: 6px 0 4px; font-weight: 600; }
.leyenda .grad { height: 10px; border-radius: 5px; margin-top: 4px; }
.leyenda .marcas { display: flex; justify-content: space-between; color: #555; font-size: 12px; margin-top: 3px; }
.leyenda .sd { display: flex; align-items: center; gap: 6px; margin-top: 6px; color: #555; }
.leyenda .sd i, .leyenda li i { width: 11px; height: 11px; border-radius: 50%; display: inline-block; flex: none; }
.leyenda .sd i { background: var(--gris-sd); border-radius: 2px; }
.leyenda ul { list-style: none; margin: 8px 0 0; padding: 0; columns: 2; font-size: 12.5px; }
.leyenda li { display: flex; align-items: center; gap: 6px; padding: 2px 0; break-inside: avoid; }

/* Tooltip */
.tooltip { position: absolute; z-index: 4; width: 310px; max-width: calc(100% - 20px); box-sizing: border-box; background: #fff; border: 1px solid #ddd; box-shadow: 0 2px 10px rgba(0,0,0,.25); padding: 12px 14px; font-size: 14px; pointer-events: none; }
.tooltip.fijo { pointer-events: auto; }
.tooltip h3 { margin: 0; font-size: 18px; }
.tooltip .prov { color: #666; margin: 2px 0 4px; }
.tooltip .meta { color: #666; font-size: 13px; }
.tooltip .meta b { color: #333; }
.tooltip .barrita { display: flex; height: 10px; margin: 8px 0 6px; background: #ddd; }
.tooltip table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.tooltip th { font-weight: 400; color: #666; text-align: right; font-size: 13px; }
.tooltip td { padding: 2px 0; }
.tooltip td:first-child { width: 14px; }
.tooltip td i { display: inline-block; width: 10px; height: 10px; border-radius: 50%; }
.tooltip td.n { text-align: right; white-space: nowrap; }
.tooltip .sin { color: #666; margin-top: 6px; }

.maplibregl-ctrl-attrib { font-size: 11px; }
@media (max-width: 700px) {
  .barra { max-width: calc(100% - 20px); top: 56px; }
  .buscador, .capa { width: calc(50% - 5px); min-width: 140px; flex: 1; }
  .leyenda { width: 250px; bottom: 24px; }
}
