:root {
  color-scheme: light;
  --nav-h: 70px;
  --navy: #08304D;
  /* Colores de destino del esquema oficial, compartidos por los tres productos. */
  --green: #98B826;
  --red: #CC523D;
  --gold: #EDC23F;
  --deep-blue: #1E4F78;
  --turquoise: #1BCDBE;
  --ice: #A6E9F7;
  --text: #153044;
  --muted: #5B7080;
  --surface: rgba(255, 255, 255, .96);
  --surface-solid: #FFFFFF;
  --surface-soft: #F2F8FA;
  --border: rgba(8, 48, 77, .17);
  --shadow: 0 16px 42px rgba(8, 48, 77, .2);
  --focus: #CC513F;
  font-family: Inter, "Segoe UI", system-ui, sans-serif;
}

[data-theme="dark"],
[data-tema="oscuro"] {
  color-scheme: dark;
  --text: #F3FCFF;
  --muted: #B7CBD4;
  --surface: rgba(8, 48, 77, .95);
  --surface-solid: #0A3958;
  --surface-soft: #0D4262;
  --border: rgba(166, 233, 247, .25);
  --shadow: 0 18px 46px rgba(0, 0, 0, .38);
}

* { box-sizing: border-box; }
html, body { width: 100%; height: 100%; margin: 0; overflow: hidden; }
body { color: var(--text); background: var(--surface-soft); }
[data-theme="dark"] body,
[data-tema="oscuro"] body { background: var(--navy); }
button, select, a { font: inherit; }
button { color: inherit; }
.icon-button svg,
.layers-fab svg,
.download-button svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.leaflet-container svg {
  width: auto;
  height: auto;
  max-width: none;
}
button:focus-visible, a:focus-visible, select:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
.skip-link {
  position: fixed;
  z-index: 10000;
  left: 12px;
  top: -60px;
  padding: 10px 14px;
  border-radius: 8px;
  color: #fff;
  background: var(--red);
  transition: top .18s ease;
}
.skip-link:focus { top: 8px; }

.product-header {
  position: fixed;
  z-index: 2000;
  inset: 0 0 auto;
  height: var(--nav-h);
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 0 18px;
  color: var(--navy);
  background: var(--surface-solid);
  border-bottom: 4px solid;
  border-image: linear-gradient(90deg, var(--green) 0 25%, var(--red) 25% 50%, var(--gold) 50% 75%, var(--deep-blue) 75%) 1;
  box-shadow: 0 4px 18px rgba(8, 48, 77, .12);
}
[data-theme="dark"] .product-header,
[data-tema="oscuro"] .product-header {
  color: #fff;
  background: var(--navy);
  box-shadow: 0 4px 18px rgba(8, 48, 77, .25);
}
.brand {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 11px;
  color: inherit;
  text-decoration: none;
}
.gob-logo {
  flex: none;
  width: auto;
  height: 26px;
  padding: 7px 10px;
  background: var(--navy);
  border-radius: 4px;
  box-sizing: content-box;
}
[data-theme="dark"] .gob-logo,
[data-tema="oscuro"] .gob-logo { background: rgba(255, 255, 255, .1); }
.brand-copy { min-width: 0; display: flex; flex-direction: column; line-height: 1.1; }
.brand-copy small {
  color: var(--green);
  font-size: .67rem;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
}
[data-theme="dark"] .brand-copy small,
[data-tema="oscuro"] .brand-copy small { color: var(--ice); }
.brand-copy strong {
  margin-top: 5px;
  max-width: 430px;
  overflow: hidden;
  font-size: .98rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.language { margin-left: auto; }
.language select {
  min-height: 36px;
  padding: 0 27px 0 10px;
  color: var(--navy);
  background: var(--surface-soft);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: .78rem;
  font-weight: 700;
}
[data-theme="dark"] .language select,
[data-tema="oscuro"] .language select {
  color: #fff;
  background: #0C4164;
  border-color: rgba(255, 255, 255, .3);
}

main { position: fixed; inset: var(--nav-h) 0 0; }
#mapa { position: absolute; inset: 0; background: #DDEDF1; }
.leaflet-container { font-family: inherit; }
.leaflet-control-attribution {
  color: var(--muted) !important;
  background: var(--surface) !important;
  backdrop-filter: blur(8px);
}
.leaflet-control-attribution a { color: var(--navy) !important; }
.leaflet-bar { border-color: var(--border) !important; box-shadow: var(--shadow) !important; }
.leaflet-bar a { color: var(--navy) !important; background: var(--surface-solid) !important; }
[data-theme="dark"] .leaflet-bar a,
[data-tema="oscuro"] .leaflet-bar a { color: var(--ice) !important; }

.layers-panel {
  position: absolute;
  z-index: 1000;
  top: 14px;
  bottom: 14px;
  left: 14px;
  width: min(390px, calc(100vw - 92px));
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
  transition: transform .25s ease, opacity .25s ease;
}
.layers-panel.closed { transform: translateX(calc(-100% - 28px)); opacity: 0; pointer-events: none; }
.panel-heading {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 17px 16px 14px;
  border-bottom: 1px solid var(--border);
}
.panel-heading small {
  color: var(--green);
  font-size: .65rem;
  font-weight: 800;
  letter-spacing: .12em;
  text-transform: uppercase;
}
.panel-heading h1 { margin: 4px 0 0; color: var(--navy); font-size: 1.05rem; }
[data-theme="dark"] .panel-heading h1,
[data-tema="oscuro"] .panel-heading h1 { color: var(--ice); }
.panel-scroll {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 12px;
  overscroll-behavior: contain;
}
.layer-section + .layer-section { margin-top: 17px; }
.layer-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 0 4px 7px;
  color: var(--muted);
  font-size: .63rem;
  font-weight: 800;
  letter-spacing: .11em;
  text-transform: uppercase;
}
.layer-title button {
  padding: 2px 7px;
  color: var(--navy);
  background: transparent;
  border: 0;
  font-size: .62rem;
  font-weight: 800;
  cursor: pointer;
}
[data-theme="dark"] .layer-title button,
[data-tema="oscuro"] .layer-title button { color: var(--ice); }
.layer-item {
  width: 100%;
  display: grid;
  grid-template-columns: 34px 30px minmax(0, 1fr) auto;
  align-items: center;
  gap: 9px;
  margin: 5px 0;
  padding: 9px;
  color: var(--text);
  text-align: left;
  background: var(--surface-soft);
  border: 1px solid transparent;
  border-radius: 10px;
  cursor: pointer;
}
.layer-item:hover { border-color: var(--border); }
.layer-item[aria-pressed="true"] { border-color: color-mix(in srgb, var(--layer-color) 60%, var(--border)); }
.layer-item[aria-pressed="false"] { opacity: .63; }
.switch {
  position: relative;
  width: 34px;
  height: 20px;
  border-radius: 999px;
  background: #B8C4CA;
}
.switch::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .25);
  transition: transform .18s ease;
}
[aria-pressed="true"] .switch { background: var(--layer-color); }
[aria-pressed="true"] .switch::after { transform: translateX(14px); }
.layer-symbol {
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
}
.layer-symbol img { max-width: 23px; max-height: 23px; filter: drop-shadow(0 1px 2px rgba(0, 0, 0, .3)); }
.layer-symbol i {
  width: 16px;
  height: 22px;
  border-radius: 50% 50% 50% 0;
  background: var(--layer-color);
  border: 2px solid var(--layer-color);
  box-shadow: inset 0 0 0 3px #fff, 0 1px 3px rgba(0, 0, 0, .25);
  transform: rotate(-45deg);
}
.layer-copy { min-width: 0; }
.layer-copy strong {
  display: block;
  overflow: hidden;
  font-size: .78rem;
  font-weight: 650;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.layer-copy small { color: var(--muted); font-size: .64rem; }
.layer-count { color: var(--muted); font-size: .7rem; font-variant-numeric: tabular-nums; }
.download-button {
  flex: none;
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 12px 12px;
  padding: 12px 14px;
  color: #08304D;
  background: #A6E9F7;
  border: 1px solid #7ad4e8;
  border-radius: 12px;
  font-size: .8rem;
  font-weight: 800;
  text-decoration: none;
}
.download-button span { display: flex; flex-direction: column; line-height: 1.2; }
.download-button small {
  margin-top: 3px;
  color: #0d4266;
  font-size: .64rem;
  font-weight: 650;
}
.download-button:hover { background: #8fe0f0; }
.download-button svg { width: 20px; height: 20px; flex: none; }
[data-theme="dark"] .download-button,
[data-tema="oscuro"] .download-button {
  color: #08304D;
  background: #A6E9F7;
}

.icon-button, .layers-fab {
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: 0 5px 18px rgba(8, 48, 77, .15);
  backdrop-filter: blur(10px);
  cursor: pointer;
}
.icon-button {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 11px;
}
.icon-button:hover, .icon-button.active { color: var(--navy); background: var(--ice); }
.panel-heading .icon-button { width: 34px; height: 34px; box-shadow: none; }
.layers-fab {
  position: absolute;
  z-index: 980;
  top: 14px;
  left: 14px;
  display: none;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-radius: 999px;
  font-size: .78rem;
  font-weight: 750;
}
.layers-fab.visible { display: flex; }
.layers-fab b {
  min-width: 22px;
  padding: 2px 6px;
  color: var(--navy);
  background: var(--ice);
  border-radius: 999px;
  font-size: .67rem;
}
.map-tools {
  position: absolute;
  z-index: 1120;
  top: 14px;
  right: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.icon-button.geo-start {
  width: auto;
  min-width: 42px;
  padding: 0 10px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: #08304D;
  background: #A6E9F7;
  border-color: #7ad4e8;
}
.icon-button.geo-start .geo-label {
  font-size: .68rem;
  font-weight: 800;
  white-space: nowrap;
}
.geo-start.tracking { color: #fff; background: var(--navy); border-color: var(--navy); }

.base-picker {
  position: absolute;
  z-index: 1140;
  top: 14px;
  right: 68px;
  width: 208px;
  padding: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 13px;
  box-shadow: var(--shadow);
}
.picker-heading { display: flex; align-items: center; justify-content: space-between; padding: 2px 3px 8px; }
.picker-heading strong { font-size: .74rem; }
.picker-heading button { border: 0; background: transparent; color: var(--muted); font-size: 1.2rem; cursor: pointer; }
.base-option {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px;
  color: var(--text);
  text-align: left;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 8px;
  cursor: pointer;
}
.base-option:hover, .base-option.active { background: var(--surface-soft); border-color: var(--border); }
.base-swatch { width: 37px; height: 27px; flex: none; border-radius: 6px; }
.base-option span:last-child { font-size: .72rem; font-weight: 650; }

.geo-panel {
  position: absolute;
  z-index: 1130;
  right: 68px;
  bottom: 18px;
  width: min(340px, calc(100vw - 86px));
  padding: 13px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 13px;
  box-shadow: var(--shadow);
}
.geo-panel strong { color: var(--navy); font-size: .76rem; }
[data-theme="dark"] .geo-panel strong,
[data-tema="oscuro"] .geo-panel strong { color: var(--ice); }
.geo-panel p { margin: 4px 0 10px; color: var(--muted); font-size: .72rem; line-height: 1.35; }
.geo-panel.error { border-color: var(--red); }
.geo-actions { display: flex; gap: 6px; }
.geo-actions button {
  flex: 1;
  padding: 7px 8px;
  color: var(--navy);
  background: var(--surface-soft);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: .68rem;
  font-weight: 750;
  cursor: pointer;
}
.geo-actions button[aria-pressed="true"] { color: #fff; background: var(--navy); }
.geo-actions button:disabled { opacity: .45; cursor: not-allowed; }

.tourism-marker, .user-marker, .cluster-icon { background: transparent !important; border: 0 !important; }
.tourism-marker {
  width: 30px !important;
  height: 39px !important;
}
.tourism-marker .pin,
.cluster-stack .pin {
  display: block;
  width: 30px;
  height: 39px;
  filter: drop-shadow(0 3px 5px rgba(4, 16, 24, .5));
  transform-origin: 50% 100%;
  transition: transform .16s ease;
}
.tourism-marker .pin svg,
.cluster-stack .pin svg { display: block; width: 30px; height: 39px; overflow: visible; }
.tourism-marker .pin-body,
.cluster-stack .pin-body { fill: var(--marker-color, var(--turquoise)); }
.tourism-marker .pin-ring,
.cluster-stack .pin-ring { fill: #fff; }
.tourism-marker .pin-core,
.cluster-stack .pin-core { fill: var(--marker-color, var(--turquoise)); }
.tourism-marker:hover .pin,
.tourism-marker.selected .pin { transform: translateY(-4px) scale(1.15); }
.tourism-marker:hover, .tourism-marker.selected { z-index: 900 !important; }

/* Semáforo de intervenciones: mismo símbolo del esquema impreso. */
.works-marker { background: transparent !important; border: 0 !important; }
.works-light { display: block; width: 26px; height: 34px; }
.works-light svg {
  display: block;
  width: 26px;
  height: 34px;
  filter: drop-shadow(0 3px 5px rgba(4, 16, 24, .55));
}
.works-light .light-box {
  fill: #16222B;
  stroke: #fff;
  stroke-width: 2.2;
}
.works-light .light-post { stroke: #fff; stroke-width: 2.6; fill: none; }
.works-light .light { fill: #3B4A55; stroke: none; }
.works-light .light.red.on { fill: var(--works-color, var(--red)); }
.works-light .light.amber.on { fill: #FFB300; }
.layer-symbol .works-light,
.layer-symbol .works-light svg { width: 18px; height: 24px; filter: none; }

.cluster-icon { width: 44px !important; height: 41px !important; overflow: visible !important; }
.cluster-stack {
  position: relative;
  width: 44px;
  height: 41px;
}
.cluster-stack b {
  position: absolute;
  right: 0;
  top: 1px;
  z-index: 0;
  min-width: 26px;
  height: 26px;
  padding: 0 6px;
  display: grid;
  place-items: center;
  color: #fff;
  background: var(--cluster-color, var(--navy));
  border-radius: 999px;
  box-shadow: 0 2px 7px rgba(4, 16, 24, .5);
  font-size: .7rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}
.cluster-stack .pin {
  position: absolute;
  left: 0;
  bottom: 0;
  z-index: 1;
}

.user-marker { width: 72px !important; height: 72px !important; }
.gps-pin {
  position: relative;
  width: 72px;
  height: 72px;
  pointer-events: none;
}
.gps-pin .gps-pulse,
.gps-pin .gps-core {
  position: absolute;
  border-radius: 50%;
}
.gps-pin .gps-pulse {
  top: 50%;
  left: 50%;
  width: 72px;
  height: 72px;
  margin: -36px 0 0 -36px;
  background: rgba(23, 102, 165, .32);
  animation: gps-pulse 2.4s cubic-bezier(.22, .7, .3, 1) infinite;
}
.gps-pin .gps-pulse-2 { animation-delay: 1.2s; }
.gps-pin .gps-core {
  top: 50%;
  left: 50%;
  width: 30px;
  height: 30px;
  margin: -15px 0 0 -15px;
  display: grid;
  place-items: center;
  background: #1766A5;
  border: 5px solid #fff;
  box-shadow: 0 0 0 2px rgba(8, 48, 77, .55), 0 6px 16px rgba(8, 48, 77, .55);
}
.gps-pin .gps-core b {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #fff;
}
@keyframes gps-pulse {
  0% { transform: scale(.42); opacity: .75; }
  70% { opacity: 0; }
  100% { transform: scale(1); opacity: 0; }
}
[data-embed="true"] .brand-copy small { display: none; }

.leaflet-popup-content-wrapper {
  color: var(--text);
  background: var(--surface-solid);
  border: 1px solid var(--border);
  border-radius: 13px;
  box-shadow: var(--shadow);
}
.leaflet-popup-tip { background: var(--surface-solid); }
.leaflet-popup-content { width: min(290px, calc(100vw - 74px)) !important; margin: 14px 16px; }
.place-card .eyebrow {
  display: block;
  margin-bottom: 5px;
  color: var(--green);
  font-size: .58rem;
  font-weight: 850;
  letter-spacing: .11em;
  text-transform: uppercase;
}
.place-card h2 { margin: 0; color: var(--navy); font-size: .96rem; line-height: 1.25; }
[data-theme="dark"] .place-card h2,
[data-tema="oscuro"] .place-card h2 { color: var(--ice); }
.place-card p {
  max-height: 130px;
  overflow: auto;
  margin: 7px 0 0;
  color: var(--muted);
  font-size: .72rem;
  line-height: 1.45;
  white-space: pre-line;
}
.health-details { margin: 9px 0 0; font-size: .72rem; }
.health-details div {
  display: grid;
  grid-template-columns: 82px minmax(0, 1fr);
  gap: 8px;
  padding: 7px 0;
  border-top: 1px solid var(--border);
}
.health-details dt { color: var(--muted); font-weight: 750; }
.health-details dd { margin: 0; color: var(--text); line-height: 1.4; }
.health-details .health-emergency dd { color: var(--red); font-weight: 850; }
.popup-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 11px; }
.popup-actions a {
  padding: 7px 9px;
  color: var(--navy);
  background: var(--ice);
  border-radius: 7px;
  font-size: .67rem;
  font-weight: 800;
  text-decoration: none;
}
.popup-actions a.external { color: #fff; background: var(--navy); }
.road-state {
  display: inline-flex;
  margin: 7px 0 0;
  padding: 3px 8px;
  color: var(--state-color);
  background: color-mix(in srgb, var(--state-color) 14%, transparent);
  border: 1px solid color-mix(in srgb, var(--state-color) 45%, transparent);
  border-radius: 999px;
  font-size: .65rem;
  font-weight: 800;
}

@media (max-width: 820px) {
  :root { --nav-h: 64px; }
  .product-header { padding: 0 10px; gap: 10px; }
  .gob-logo { height: 19px; padding: 5px 7px; }
  .brand-copy small { font-size: .55rem; }
  .brand-copy strong { font-size: .78rem; }
  .icon-button.geo-start { width: auto; max-width: 118px; padding: 0 9px; }
  .layers-panel {
    top: auto;
    right: 0;
    bottom: 57px;
    left: 0;
    width: 100%;
    max-height: min(58vh, 520px);
    border-radius: 18px 18px 0 0;
    border-right: 0;
    border-bottom: 0;
    border-left: 0;
  }
  .layers-panel.closed { transform: translateY(105%); }
  .layers-fab { top: auto; bottom: 72px; }
  .map-tools { top: 10px; right: 10px; }
  .icon-button { width: 40px; height: 40px; }
  .base-picker { top: 10px; right: 60px; }
  .geo-panel { right: 10px; bottom: 124px; }
  .leaflet-bottom.leaflet-right { bottom: 116px; }
}

@media (max-width: 430px) {
  .brand-copy strong { max-width: 245px; }
  .base-picker { width: min(200px, calc(100vw - 72px)); }
  .geo-panel { right: 10px; bottom: 124px; width: calc(100vw - 20px); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; }
}
