.geo-grid{
  display: grid;
  grid-template-columns: 360px 1fr;
  gap: 14px;
}
@media (max-width: 991.98px){
  .geo-grid{ grid-template-columns: 1fr; }
}

.geo-main .card{ min-height: 70vh; }

.map-switcher{
  display:flex;
  gap:10px;
  flex-wrap:wrap;
}
.map-switcher-btn{
  border:1px solid rgba(15, 23, 42, .10);
  background: rgba(255,255,255,.72);
  color:#0f172a;
  border-radius: 14px;
  padding: 10px 14px;
  font-weight: 700;
  transition: .18s ease;
}
.map-switcher-btn:hover{
  background: rgba(255,255,255,.90);
  transform: translateY(-1px);
}
.map-switcher-btn.active{
  background: rgba(37,99,235,.10);
  border-color: rgba(37,99,235,.24);
  color:#1d4ed8;
  box-shadow: 0 10px 24px rgba(37,99,235,.10);
}

.map-view{ display:none; }
.map-view.active{ display:block; }

.map-wrap{
  position: relative;
  border: 1px solid rgba(15, 23, 42, .10);
  border-radius: 18px;
  overflow: hidden;
  background: rgba(255,255,255,.55);
}
#map,
#epiMap{
  width: 100%;
  height: clamp(420px, 62vh, 740px);
}
.map-hud{
  position: absolute;
  left: 12px;
  bottom: 12px;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  z-index: 500;
}
.hud-item{
  border: 1px solid rgba(15, 23, 42, .10);
  border-radius: 16px;
  background: rgba(255,255,255,.85);
  backdrop-filter: blur(10px);
  padding: 10px 12px;
  min-width: 150px;
}
.hud-item .t{ font-size: .82rem; color: rgba(11,18,32,.72); }
.hud-item .v{ font-size: 1.25rem; font-weight: 900; margin-top: 2px; }

.epi-kpis{
  display:grid;
  grid-template-columns: repeat(3, minmax(0,1fr));
  gap:12px;
}
.epi-kpi-card{
  border:1px solid rgba(15,23,42,.10);
  border-radius:18px;
  background: rgba(255,255,255,.76);
  padding: 14px 16px;
}
.epi-kpi-card .label{
  color: rgba(11,18,32,.68);
  font-size: .84rem;
  font-weight: 700;
}
.epi-kpi-card .value{
  font-size: 1.75rem;
  line-height: 1.1;
  font-weight: 900;
  margin-top: 4px;
}
.epi-kpi-card .hint{
  color: rgba(11,18,32,.62);
  font-size: .82rem;
  margin-top: 6px;
}

.results{
  border: 1px solid rgba(15, 23, 42, .10);
  border-radius: 18px;
  background: rgba(255,255,255,.60);
  overflow: hidden;
}
.results-list{
  max-height: 260px;
  overflow: auto;
}
.epi-results-list{ max-height: 320px; }
.result-item,
.epi-item{
  display:flex;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border-bottom: 1px solid rgba(15, 23, 42, .08);
}
.result-item:last-child,
.epi-item:last-child{ border-bottom: 0; }
.result-item .name,
.epi-item .name{ font-weight: 900; }
.result-item .meta,
.epi-item .meta{ color: rgba(11,18,32,.72); font-size: .9rem; }

.badges,
.epi-badges{
  display:flex;
  gap: 6px;
  flex-wrap: wrap;
  align-items: center;
}

.epi-badges .badge{
  border-radius: 999px;
  padding: .42rem .68rem;
  font-weight: 700;
}

.btn-mini{
  border: 1px solid rgba(15, 23, 42, .12);
  background: rgba(255,255,255,.75);
  border-radius: 12px;
  padding: 6px 9px;
}
.btn-mini:hover{ background: rgba(255,255,255,.92); }

@media (max-width: 991.98px){
  .epi-kpis{
    grid-template-columns: 1fr;
  }
}


.epi-map-wrap{ isolation:isolate; }
.epi-legend-toggle{
  position:absolute;
  top:12px;
  right:12px;
  z-index:560;
  width:42px;
  height:42px;
  border-radius:14px;
  border:1px solid rgba(15,23,42,.12);
  background:rgba(255,255,255,.92);
  backdrop-filter:blur(12px);
  box-shadow:0 12px 28px rgba(15,23,42,.12);
}
.epi-legend{
  position:absolute;
  top:12px;
  left:12px;
  z-index:550;
  width:min(360px, calc(100% - 72px));
  max-height:calc(100% - 24px);
  overflow:auto;
  border:1px solid rgba(15,23,42,.12);
  border-radius:20px;
  background:rgba(255,255,255,.90);
  backdrop-filter:blur(16px);
  box-shadow:0 20px 40px rgba(15,23,42,.14);
  padding:14px;
  transition:transform .22s ease, opacity .22s ease;
}
.epi-legend.is-collapsed{
  transform:translateX(calc(-100% - 20px));
  opacity:0;
  pointer-events:none;
}
.epi-legend-head{
  display:flex;
  align-items:flex-start;
  justify-content:space-between;
  gap:10px;
  margin-bottom:12px;
}
.epi-legend-title{ font-weight:900; font-size:1rem; line-height:1.1; }
.epi-legend-subtitle{ color:rgba(11,18,32,.64); font-size:.82rem; margin-top:2px; }
.epi-legend-badge{
  white-space:nowrap;
  padding:.42rem .65rem;
  border-radius:999px;
  background:rgba(37,99,235,.10);
  color:#1d4ed8;
  font-weight:800;
  font-size:.78rem;
}
.epi-legend-grid{
  display:grid;
  grid-template-columns:repeat(2,minmax(0,1fr));
  gap:8px;
  margin-bottom:12px;
}
.epi-legend-stat{
  border:1px solid rgba(15,23,42,.08);
  background:rgba(248,250,252,.92);
  border-radius:16px;
  padding:10px 12px;
}
.epi-legend-stat .k{ display:block; color:rgba(11,18,32,.64); font-size:.76rem; font-weight:700; }
.epi-legend-stat .v{ display:block; font-size:1.15rem; font-weight:900; margin-top:2px; }
.epi-legend-section{ margin-top:12px; }
.epi-legend-section-title{ font-size:.82rem; font-weight:800; color:rgba(11,18,32,.72); margin-bottom:8px; }
.epi-scale{ position:relative; padding-top:18px; }
.epi-scale .lvl{
  position:absolute;
  top:0;
  font-size:.72rem;
  font-weight:800;
  color:rgba(11,18,32,.68);
}
.epi-scale .low{ left:0; }
.epi-scale .med{ left:50%; transform:translateX(-50%); }
.epi-scale .high{ right:0; }
.epi-scale-bar{
  height:12px;
  border-radius:999px;
  background:linear-gradient(90deg,#fde68a 0%, #f59e0b 55%, #b91c1c 100%);
  box-shadow:inset 0 1px 2px rgba(255,255,255,.55);
}
.epi-top-list{ display:flex; flex-direction:column; gap:8px; }
.epi-top-item{
  display:grid;
  grid-template-columns:auto 1fr auto;
  gap:10px;
  align-items:center;
  border:1px solid rgba(15,23,42,.08);
  background:rgba(248,250,252,.92);
  border-radius:14px;
  padding:8px 10px;
}
.epi-top-rank{
  width:28px;
  height:28px;
  border-radius:999px;
  display:grid;
  place-items:center;
  font-size:.78rem;
  font-weight:900;
  background:rgba(15,23,42,.08);
}
.epi-top-main{ min-width:0; }
.epi-top-name{ font-size:.85rem; font-weight:900; line-height:1.1; }
.epi-top-meta{ font-size:.75rem; color:rgba(11,18,32,.64); white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.epi-top-value{ font-size:.92rem; font-weight:900; color:#0f172a; }
.epi-legend-filters{
  margin-top:12px;
  border-top:1px dashed rgba(15,23,42,.12);
  padding-top:10px;
  color:rgba(11,18,32,.68);
  font-size:.78rem;
  line-height:1.45;
}
@media (max-width: 991.98px){
  .epi-legend{ width:min(320px, calc(100% - 72px)); }
}
@media (max-width: 767.98px){
  .epi-legend{ width:min(290px, calc(100% - 64px)); padding:12px; }
  .epi-legend-grid{ grid-template-columns:1fr 1fr; }
  .epi-legend-title{ font-size:.95rem; }
}

.epi-editor-section{
  border-top:1px solid rgba(15,23,42,.08);
  padding-top:12px;
}
.epi-editor-help{
  font-size:.78rem;
  color:rgba(11,18,32,.68);
  line-height:1.35;
  margin-bottom:8px;
}
.epi-editor-grid{
  display:grid;
  grid-template-columns:1.45fr .95fr;
  gap:8px;
}
.epi-editor-status{
  margin-top:8px;
  font-size:.8rem;
  color:rgba(11,18,32,.74);
  background:rgba(255,255,255,.65);
  border:1px solid rgba(15,23,42,.08);
  border-radius:12px;
  padding:8px 10px;
}
.epi-editor-actions{
  display:grid;
  grid-template-columns:1fr 1fr;
  gap:8px;
  margin-top:10px;
}
.epi-editor-actions .btn{
  display:flex;
  align-items:center;
  justify-content:center;
  gap:6px;
}
.sector-area-label{
  background:rgba(255,255,255,.92);
  border:1px solid rgba(15,23,42,.08);
  border-radius:999px;
  padding:2px 8px;
  font-size:.72rem;
  font-weight:800;
  color:#0f172a;
  box-shadow:0 8px 18px rgba(15,23,42,.12);
}
@media (max-width: 768px){
  .epi-editor-grid,
  .epi-editor-actions{ grid-template-columns:1fr; }
}

.epi-sector-label{background:transparent;border:none}.epi-sector-label span{background:rgba(255,255,255,.92);border:1px solid rgba(15,23,42,.08);border-radius:999px;padding:4px 10px;font-size:.74rem;font-weight:800;color:#0f172a;box-shadow:0 8px 18px rgba(15,23,42,.12);white-space:nowrap}

.leaflet-tooltip.sector-hover-tooltip{background:rgba(15,23,42,.92);color:#fff;border:0;border-radius:10px;padding:8px 10px;font-weight:700;box-shadow:0 8px 24px rgba(0,0,0,.22)}
.leaflet-tooltip.sector-hover-tooltip:before{display:none}


.sector-tooltip-card{min-width:220px;max-width:300px}
.sector-tooltip-title{font-weight:900;font-size:.95rem;line-height:1.1;margin-bottom:2px}
.sector-tooltip-sub{font-size:.78rem;opacity:.82;margin-bottom:8px}
.sector-tooltip-row{display:grid;grid-template-columns:1fr auto;gap:8px;align-items:start;font-size:.8rem;padding:2px 0}
.sector-tooltip-row span{opacity:.82}
.sector-tooltip-row strong{font-weight:800;text-align:right;white-space:normal}

/* Filtros separados por mapa */
.map-filter-accordion .accordion-item{
  border:1px solid rgba(13,110,253,.14);
  border-radius:16px;
  overflow:hidden;
  background:rgba(255,255,255,.72);
  box-shadow:0 12px 28px rgba(15,23,42,.06);
}
.map-filter-accordion .accordion-button{
  font-weight:800;
  color:#0f172a;
  background:linear-gradient(135deg, rgba(255,255,255,.95), rgba(239,246,255,.88));
}
.map-filter-accordion .accordion-button:not(.collapsed){
  color:#0d6efd;
  box-shadow:none;
}
.map-filter-accordion .accordion-body{
  background:rgba(255,255,255,.84);
}
.map-filter-accordion .ts-control{
  min-height:38px;
}

/* Panel lateral de diagnósticos seleccionados */
.geo-help-box{
  line-height: 1.45;
}
.diagnosis-summary-panel{
  border: 1px solid rgba(13,110,253,.14);
  border-radius: 16px;
  padding: 12px;
  background: linear-gradient(135deg, rgba(255,255,255,.86), rgba(239,246,255,.70));
}
.diag-panel-title{
  font-weight: 900;
  color: #0f172a;
  font-size: .88rem;
  line-height: 1.15;
}
.diag-panel-subtitle{
  color: rgba(11,18,32,.62);
  font-size: .76rem;
  line-height: 1.25;
  margin-top: 2px;
}
.diag-count-badge{
  min-width: 34px;
  height: 26px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(13,110,253,.10);
  color: #0d6efd;
  font-weight: 900;
  border: 1px solid rgba(13,110,253,.18);
}
.diag-empty{
  border: 1px dashed rgba(15,23,42,.16);
  border-radius: 14px;
  padding: 10px;
  font-size: .82rem;
  color: rgba(11,18,32,.62);
  background: rgba(255,255,255,.65);
}
.selected-diagnosis-list{
  display: grid;
  gap: 8px;
  max-height: 310px;
  overflow: auto;
  padding-right: 2px;
}
.selected-diagnosis-chip{
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: start;
  gap: 8px;
  padding: 8px 8px 8px 10px;
  border: 1px solid rgba(15,23,42,.08);
  border-radius: 14px;
  background: rgba(255,255,255,.88);
  box-shadow: 0 8px 18px rgba(15,23,42,.05);
  font-size: .82rem;
  line-height: 1.25;
  color: #0f172a;
}
.selected-diagnosis-chip span{
  overflow-wrap: anywhere;
}
.diag-remove-btn{
  width: 24px;
  height: 24px;
  border: 0;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(220,53,69,.10);
  color: #dc3545;
  line-height: 1;
}
.diag-remove-btn:hover{
  background: rgba(220,53,69,.18);
}

/* El selector de diagnósticos queda compacto: las selecciones se muestran en el panel lateral */
.diag-compact-select.multi .ts-control{
  min-height: 40px !important;
  max-height: 42px !important;
  overflow: hidden !important;
  flex-wrap: nowrap !important;
  align-items: center;
}
.diag-compact-select.multi .ts-control .item{
  display: none !important;
}
.diag-compact-select.has-diag-items .ts-control::before{
  content: attr(data-selected-label);
  display: inline-flex;
  align-items: center;
  max-width: 58%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-right: 8px;
  padding: 3px 8px;
  border-radius: 999px;
  background: rgba(13,110,253,.08);
  color: #0d6efd;
  font-weight: 800;
  font-size: .8rem;
  flex: 0 1 auto;
}
.diag-compact-select.has-diag-items .ts-control input{
  min-width: 135px !important;
}
@media (max-width: 991.98px){
  .diag-compact-select.has-diag-items .ts-control::before{
    max-width: 48%;
  }
}
