/*! JDServer-Webs — WM-26 Mapa Ahora + capas territoriales */
#jd-map-module { overflow: hidden; }
.jd-map-toolbar { display: flex; align-items: center; gap: 10px; margin: 10px 0 10px; }
.jd-map-search,
.jd-map-btn,
.jd-map-filter {
  min-height: 40px; border: 1px solid var(--border, #0000001f); background: var(--card, #ffffffb3);
  color: var(--text, #111); border-radius: 999px; font-weight: 800;
}
.jd-map-search { height: 42px; flex: 1; min-width: 0; padding: 0 15px; font-weight: 650; }
.jd-map-btn { height: 42px; padding: 0 16px; cursor: pointer; }
.jd-map-filters { display: flex; gap: 7px; margin: 0 0 12px; padding: 2px 0; overflow-x: auto; scrollbar-width: none; }
.jd-map-filters::-webkit-scrollbar { display: none; width: 0; height: 0; }
.jd-map-filter { flex: 0 0 auto; padding: 7px 12px; cursor: pointer; font-size: 12px; line-height: 1; }
.jd-map-filter.is-active { border-color: var(--brand, #12bdb3); background: color-mix(in srgb, var(--brand, #12bdb3) 16%, var(--card, #fff)); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--brand, #12bdb3) 42%, transparent); }
.jd-map-webcam-filter { display: inline-flex; align-items: center; gap: 6px; }
.jd-map-webcam-filter input { width: 15px; height: 15px; margin: 0; accent-color: var(--brand, #12bdb3); }
html[data-theme=dark] .jd-map-search,
html[data-theme=dark] .jd-map-btn,
html[data-theme=dark] .jd-map-filter { border-color: var(--border, #2b2f36); background: var(--card, #111418); color: #dfe7ef; }
html[data-theme=dark] .jd-map-search,
html[data-theme=dark] .jd-map-btn { color: #dfe7ef; }
html[data-theme=dark] .jd-map-search::placeholder { color: #aeb9c5; opacity: .85; }

.jd-map-summary {
  display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 8px; margin: 0 0 12px;
}
.jd-map-summary > div {
  min-width: 0; padding: 9px 8px; text-align: center; border: 1px solid var(--border, #00000018);
  border-radius: 13px; background: color-mix(in srgb, var(--card, #fff) 92%, transparent);
}
.jd-map-summary strong { display: block; font-size: 18px; line-height: 1.05; font-weight: 950; }
.jd-map-summary span { display: block; margin-top: 4px; opacity: .78; font-size: 10px; font-weight: 800; line-height: 1.15; }
.jd-map-summary .is-fresh strong { color: #18864b; }
.jd-map-summary .is-stale strong { color: #b86b00; }
.jd-map-summary .is-offline strong { color: #c43c48; }
.jd-map-summary-time strong { font-size: 14px; padding-top: 2px; }

.jd-stations-map,
#jdStationsMap,
#jdStationsMapLocal {
  height: max(560px, min(78vh, 900px)) !important; min-height: 560px !important; overflow: hidden;
  border: 1px solid var(--border, #0000001f); border-radius: 18px; background: var(--card, #fff);
}
html[data-theme=dark] .jd-stations-map,
html[data-theme=dark] #jdStationsMap,
html[data-theme=dark] #jdStationsMapLocal { border-color: var(--border, #2b2f36); background: var(--card, #111418); }
.leaflet-control-attribution { opacity: .88; font-size: 11px; }

.jd-now-marker-wrap,
.jd-now-cluster-wrap { border: 0; background: transparent; }
.jd-now-marker,
.jd-now-cluster {
  display: grid; width: 46px; height: 46px; place-items: center; border-radius: 50%; color: #fff;
  font-size: 13px; font-weight: 950; letter-spacing: -.3px; text-shadow: 0 1px 3px #0009;
  box-shadow: 0 5px 16px #0005; transform: translateZ(0); transition: transform .16s ease, box-shadow .16s ease;
}
.jd-now-marker { border: 4px solid #fff; background: var(--marker, #12bdb3); }
.jd-now-marker.is-stale { border-color: #ffb12b; }
.jd-now-marker.is-offline,
.jd-now-marker.is-unavailable { border-color: #d74b56; filter: saturate(.55); }
.jd-now-cluster { width: 50px; height: 50px; border: 4px solid #fff; background: #12263a; font-size: 17px; }
.jd-now-marker-wrap:hover .jd-now-marker,
.jd-now-marker-wrap:focus .jd-now-marker,
.jd-now-cluster-wrap:hover .jd-now-cluster,
.jd-now-cluster-wrap:focus .jd-now-cluster { transform: scale(1.08); box-shadow: 0 7px 20px #0007; }
.jd-now-marker-wrap:focus-visible,
.jd-now-cluster-wrap:focus-visible { outline: 3px solid var(--brand, #12bdb3); outline-offset: 4px; }

.leaflet-popup-content,
.leaflet-popup-content * { box-sizing: border-box; }
.leaflet-popup-content { width: auto; min-width: 280px; max-width: 360px; margin: 14px 14px 12px; }
.jd-map-popup { --st: #12bdb3; }
.jd-map-pop-top { height: 6px; margin-bottom: 10px; border-radius: 999px; opacity: .95; background: linear-gradient(90deg, var(--st), transparent); }
.jd-map-popup .title { margin: 0 0 3px; font-size: 18px; font-weight: 950; }
.jd-map-popup .meta { margin: 0 0 8px; opacity: .78; font-weight: 750; }
.jd-map-freshness,
.jd-map-risk,
.jd-map-state { display: inline-flex; align-items: center; gap: 6px; font-size: 11px; font-weight: 850; }
.jd-map-freshness span,
.jd-map-risk span { width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.jd-map-freshness.is-fresh,
.jd-map-state.is-fresh,
.jd-map-risk.is-normal { color: #157a43; }
.jd-map-freshness.is-stale,
.jd-map-state.is-stale,
.jd-map-risk.is-attention { color: #a66000; }
.jd-map-freshness.is-offline,
.jd-map-freshness.is-unavailable,
.jd-map-state.is-offline,
.jd-map-state.is-unavailable,
.jd-map-risk.is-warn,
.jd-map-risk.is-high,
.jd-map-risk.is-critical { color: #b52f3c; }
.jd-map-live { max-width: 100%; margin: 9px 0; padding: 8px; overflow: hidden; border: 1px solid color-mix(in srgb, var(--st) 40%, #0000001f); border-radius: 14px; background: #ffffffeb; box-shadow: 0 8px 20px #00000014; }
html[data-theme=dark] .jd-map-live { border-color: color-mix(in srgb, var(--st) 35%, #ffffff24); background: #111418e8; box-shadow: 0 10px 24px #00000059; }
.jd-map-live-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; width: 100%; }
.jd-map-live-grid .jd-metric { min-width: 0; padding: 6px 4px; text-align: center; border: 1px solid #0000000f; border-radius: 10px; background: #00000009; }
html[data-theme=dark] .jd-map-live-grid .jd-metric { border-color: #ffffff14; background: #ffffff0f; }
.jd-map-live-grid .jd-metric .v { display: block; overflow: hidden; font-size: 12px; font-weight: 950; line-height: 1.1; white-space: nowrap; text-overflow: ellipsis; }
.jd-map-live-grid .jd-metric .k { display: block; margin-top: 3px; opacity: .76; font-size: 9px; font-weight: 850; line-height: 1.1; }
.jd-map-cam { display: block; margin-top: 8px; overflow: hidden; border: 1px solid #0000001a; border-radius: 12px; background: #0000000a; }
.jd-map-cam-big { width: 100%; height: 110px; }
.jd-map-cam-img { display: block; width: 100%; height: 100%; object-fit: cover; }
.jd-map-risk { margin: 1px 0 7px; padding: 7px 9px; border-radius: 10px; background: color-mix(in srgb, currentColor 9%, transparent); }
.jd-map-risk.is-loading { opacity: .68; color: inherit; }
.jd-map-popup-actions { display: flex; flex-wrap: wrap; gap: 6px 11px; align-items: center; }
.jd-map-open,
.jd-map-share { display: inline-flex; align-items: center; gap: 5px; padding: 0; border: 0; background: transparent; color: var(--brand, #0f8f87); cursor: pointer; font: inherit; font-size: 11px; font-weight: 900; text-decoration: none; }
.jd-map-legend { margin-top: 10px; opacity: .82; font-size: 12px; font-weight: 700; }
.jd-map-tip { font-size: 12px; opacity: .8; }

.jd-map-list { margin-top: 12px; border: 1px solid var(--border, #0000001f); border-radius: 15px; background: color-mix(in srgb, var(--card, #fff) 94%, transparent); }
.jd-map-list > summary { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 14px; cursor: pointer; font-weight: 900; }
.jd-map-list > summary b { display: grid; min-width: 28px; height: 28px; place-items: center; border-radius: 999px; background: color-mix(in srgb, var(--brand, #12bdb3) 16%, transparent); }
.jd-map-list > p { margin: 0; padding: 0 14px 10px; opacity: .76; font-size: 12px; }
.jd-map-table-wrap { overflow-x: auto; border-top: 1px solid var(--border, #00000015); }
.jd-map-table-wrap table { width: 100%; border-collapse: collapse; font-size: 12px; }
.jd-map-table-wrap th,
.jd-map-table-wrap td { padding: 9px 10px; border-bottom: 1px solid var(--border, #00000012); text-align: left; vertical-align: middle; white-space: nowrap; }
.jd-map-table-wrap tbody tr:last-child th,
.jd-map-table-wrap tbody tr:last-child td { border-bottom: 0; }
.jd-map-table-wrap th[scope=row] { white-space: normal; min-width: 180px; }
.jd-map-table-wrap a { color: var(--brand, #0f8f87); font-weight: 850; text-decoration: none; }
.jd-map-table-wrap small { display: block; margin-top: 2px; opacity: .67; font-size: 10px; font-weight: 650; }
.jd-map-empty,
.jd-map-error { grid-column: 1 / -1; padding: 16px; text-align: center; font-weight: 800; }

.jd-map-layers {
  margin: 0 0 12px; padding: 11px; border: 1px solid var(--border, #0000001f); border-radius: 16px;
  background: color-mix(in srgb, var(--card, #fff) 94%, transparent);
}
.jd-map-layer-open[hidden],
.jd-map-layer-meta[hidden],
.jd-map-timeline[hidden],
.jd-map-layer-list[hidden] { display: none !important; }
.jd-map-layers-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; margin-bottom: 8px; }
.jd-map-layers-head h4 { margin: 0; font-size: 14px; font-weight: 950; }
.jd-map-layers-head p { margin: 3px 0 0; opacity: .72; font-size: 11px; line-height: 1.35; }
.jd-map-layer-open { flex: 0 0 auto; color: var(--brand, #0f8f87); font-size: 11px; font-weight: 900; text-decoration: none; }
.jd-map-layer-buttons { display: flex; gap: 7px; padding: 2px 0; overflow-x: auto; scrollbar-width: none; }
.jd-map-layer-buttons::-webkit-scrollbar { display: none; width: 0; height: 0; }
.jd-map-layer-button {
  flex: 0 0 auto; min-height: 38px; padding: 7px 12px; border: 1px solid var(--border, #0000001f); border-radius: 999px;
  background: color-mix(in srgb, var(--card, #fff) 88%, transparent); color: var(--text, #111); cursor: pointer;
  font: inherit; font-size: 11px; font-weight: 900;
}
.jd-map-layer-button.is-active {
  border-color: var(--brand, #12bdb3); background: color-mix(in srgb, var(--brand, #12bdb3) 18%, var(--card, #fff));
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--brand, #12bdb3) 38%, transparent);
}
.jd-map-layer-button:focus-visible { outline: 3px solid color-mix(in srgb, var(--brand, #12bdb3) 62%, transparent); outline-offset: 2px; }
.jd-map-layer-meta {
  display: flex; flex-wrap: wrap; align-items: center; gap: 5px 12px; margin-top: 9px; padding: 9px 10px;
  border-radius: 12px; background: #00000008; font-size: 11px; line-height: 1.3;
}
.jd-map-layer-meta a { color: var(--brand, #0f8f87); font-weight: 900; }
.jd-map-layer-meta small { flex-basis: 100%; opacity: .72; }
.jd-map-layer-state { display: inline-flex; align-items: center; gap: 6px; font-weight: 900; }
.jd-map-layer-state i { width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.jd-map-layer-meta.is-fresh .jd-map-layer-state { color: #158047; }
.jd-map-layer-meta.is-stale .jd-map-layer-state { color: #a86400; }
.jd-map-layer-meta.is-unavailable .jd-map-layer-state { color: #b52f3c; }
.jd-map-layer-meta.is-external .jd-map-layer-state { color: #2563eb; }
.jd-map-layer-meta.is-loading { opacity: .7; font-weight: 800; }
.jd-map-timeline { display: grid; grid-template-columns: 38px 38px minmax(120px, 1fr) 38px auto; align-items: center; gap: 7px; margin-top: 9px; }
.jd-map-timeline button {
  width: 38px; height: 38px; border: 1px solid var(--border, #0000001f); border-radius: 10px; background: var(--card, #fff);
  color: var(--text, #111); cursor: pointer; font-weight: 900;
}
.jd-map-timeline input { width: 100%; accent-color: var(--brand, #12bdb3); }
.jd-map-timeline strong { min-width: 104px; font-size: 11px; text-align: right; }
.jd-map-layer-popup { --layer-color: #475569; min-width: 220px; }
.jd-map-layer-popup-bar { height: 5px; margin-bottom: 8px; border-radius: 999px; background: var(--layer-color); }
.jd-map-layer-popup > strong { display: block; font-size: 15px; }
.jd-map-layer-popup > span,
.jd-map-layer-popup > small { display: block; margin-top: 3px; opacity: .72; }
.jd-map-layer-popup p { margin: 8px 0; font-size: 11px; line-height: 1.4; }
.jd-map-layer-popup a { display: inline-block; margin-top: 8px; color: var(--brand, #0f8f87); font-size: 11px; font-weight: 900; text-decoration: none; }
.jd-map-layer-list { margin-top: 10px; border: 1px solid var(--border, #0000001f); border-radius: 14px; background: color-mix(in srgb, var(--card, #fff) 94%, transparent); }
.jd-map-layer-list > summary { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 11px 13px; cursor: pointer; font-size: 12px; font-weight: 900; }
.jd-map-layer-list > summary b { min-width: 27px; padding: 5px 8px; border-radius: 999px; background: color-mix(in srgb, var(--brand, #12bdb3) 15%, transparent); text-align: center; }
.jd-map-layer-list ul { max-height: 430px; margin: 0; padding: 0; overflow: auto; border-top: 1px solid var(--border, #00000015); list-style: none; }
.jd-map-layer-list li { display: grid; grid-template-columns: 10px minmax(0, 1fr) auto; gap: 9px; align-items: start; padding: 10px 12px; border-bottom: 1px solid var(--border, #00000010); }
.jd-map-layer-list li:last-child { border-bottom: 0; }
.jd-map-layer-list li strong,
.jd-map-layer-list li small { display: block; }
.jd-map-layer-list li small { margin-top: 2px; opacity: .68; font-size: 10px; }
.jd-map-layer-list li p { margin: 4px 0 0; opacity: .82; font-size: 10px; line-height: 1.35; }
.jd-map-layer-list li time { opacity: .66; font-size: 10px; white-space: nowrap; }
.jd-map-layer-dot { width: 9px; height: 9px; margin-top: 4px; border-radius: 50%; background: var(--layer-color); box-shadow: 0 0 0 2px #ffffffcc; }
.jd-map-layer-empty { margin: 0; padding: 13px; opacity: .78; font-size: 11px; }
html[data-theme=dark] .jd-map-layer-button,
html[data-theme=dark] .jd-map-timeline button { border-color: var(--border, #2b2f36); background: var(--card, #111418); color: #dfe7ef; }
html[data-theme=dark] .jd-map-layer-meta { background: #ffffff0b; }
html[data-theme=dark] .jd-map-layer-dot { box-shadow: 0 0 0 2px #111418cc; }

@media (max-width: 760px) {
  .jd-map-summary { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .jd-map-summary-time { display: none; }
  .jd-stations-map,
  #jdStationsMap,
  #jdStationsMapLocal { height: max(540px, min(74vh, 760px)) !important; min-height: 540px !important; }
  .jd-map-table-wrap { padding: 0 10px 10px; overflow: visible; }
  .jd-map-table-wrap thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .jd-map-table-wrap table,
  .jd-map-table-wrap tbody,
  .jd-map-table-wrap tr,
  .jd-map-table-wrap th,
  .jd-map-table-wrap td { display: block; width: 100%; }
  .jd-map-table-wrap tr { margin-top: 9px; padding: 10px; border: 1px solid var(--border, #00000018); border-radius: 13px; }
  .jd-map-table-wrap th,
  .jd-map-table-wrap td { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; padding: 4px 0; border: 0; white-space: normal; text-align: right; }
  .jd-map-table-wrap th[scope=row] { display: block; min-width: 0; padding-bottom: 7px; text-align: left; }
  .jd-map-table-wrap td::before { content: attr(data-label); flex: 0 0 42%; opacity: .68; text-align: left; font-size: 10px; font-weight: 850; }
  .jd-map-table-wrap td small { display: inline; }
  .jd-map-layers { padding: 10px 9px; }
  .jd-map-layers-head { display: block; }
  .jd-map-layer-open { display: inline-block; margin-top: 6px; }
  .jd-map-timeline { grid-template-columns: 36px 36px minmax(90px, 1fr) 36px; }
  .jd-map-timeline strong { grid-column: 1 / -1; text-align: center; }
  .jd-map-layer-list li { grid-template-columns: 10px minmax(0, 1fr); }
  .jd-map-layer-list li time { grid-column: 2; }
}

@media (max-width: 420px) {
  .jd-map-toolbar { align-items: stretch; }
  .jd-map-btn { padding-inline: 12px; }
  .jd-map-summary { gap: 6px; }
  .jd-map-summary > div { padding: 8px 5px; }
  .jd-map-summary strong { font-size: 16px; }
  .leaflet-popup-content { min-width: 248px; margin: 12px 12px 10px; }
  .jd-map-live-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (prefers-reduced-motion: reduce) {
  .jd-now-marker,
  .jd-now-cluster { transition: none; }
}

@media (prefers-color-scheme: dark) {
  html:not([data-theme=light]) .jd-map-search,
  html:not([data-theme=light]) .jd-map-btn,
  html:not([data-theme=light]) .jd-map-filter { color: #dfe7ef; }
  html:not([data-theme=light]) .jd-map-search::placeholder { color: #aeb9c5; opacity: .85; }
}
