/* Índices de Contaminación · Jutiapa
   Misma estética que el Perfil de Pozos: fondo oscuro, tipografía del
   sistema / Inter local, una tinta de acento y líneas finas. */
@font-face {
  font-family: "Inter"; font-style: normal; font-weight: 400 700; font-display: swap;
  src: url(fonts/inter-latin.woff2) format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  color-scheme: dark;
  --fondo:   #0b0f14;
  --suave:   #131a23;
  --panel:   #10161d;
  --texto:   #e8edf3;
  --tenue:   #8b97a7;
  --linea:   #232d3b;
  --linea-f: #3a475a;
  --acento:  #4da3ff;
  --rio:     #5aa9e6;
  --lago:    #2f78c4;
  --radio:   6px;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }
html, body { background: var(--fondo); }
html, .panel { scrollbar-color: var(--linea-f) transparent; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Inter", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-feature-settings: "tnum" 1, "cv11" 1;
  -webkit-font-smoothing: antialiased;
  color: var(--texto);
  line-height: 1.45;
  min-height: 100vh;
}
#app { max-width: 1600px; margin: 0 auto; padding: 24px 28px 28px; }
*:focus-visible { outline: 2px solid var(--acento); outline-offset: 2px; }
button, select, input { font: inherit; color: inherit; }

/* ---------- Encabezado ---------- */
.cab {
  display: flex; justify-content: space-between; align-items: flex-start; gap: 16px;
  padding-bottom: 18px; margin-bottom: 18px; border-bottom: 1px solid var(--linea);
}
.cab-marca { display: flex; gap: 16px; align-items: flex-start; }
.cab-marca img { border-radius: 50%; background: #fff; flex: none; }
.eyebrow {
  font-size: .72rem; font-weight: 600; text-transform: uppercase;
  letter-spacing: .14em; color: var(--acento); margin-bottom: 8px;
}
.cab h1 { font-size: clamp(1.5rem, 3vw, 2.2rem); font-weight: 700; letter-spacing: -.025em; line-height: 1.1; margin-bottom: 6px; }
.cab p { color: var(--tenue); max-width: 70ch; font-size: .95rem; }
.vivo {
  display: inline-flex; align-items: center; gap: 8px; white-space: nowrap;
  font-size: .78rem; color: var(--tenue); padding: 5px 12px;
  border: 1px solid var(--linea); border-radius: 999px;
}
.vivo-punto { width: 7px; height: 7px; border-radius: 50%; background: #22c55e; }
.vivo.cargando .vivo-punto { background: #fcd34d; }
.vivo.error .vivo-punto { background: #ef4444; }

/* ---------- Botones de índices ---------- */
.indices { display: flex; flex-wrap: wrap; gap: 14px 28px; margin-bottom: 16px; }
.indices-grupo { display: flex; flex-direction: column; gap: 6px; }
.indices-titulo {
  font-size: .7rem; font-weight: 600; text-transform: uppercase; letter-spacing: .08em; color: var(--tenue);
}
.indices-botones { display: flex; flex-wrap: wrap; gap: 8px; }
.ind-btn {
  position: relative; min-width: 150px; text-align: left; cursor: pointer;
  padding: 10px 14px 10px 14px; border-radius: 10px;
  background: var(--panel); border: 1px solid var(--linea-f);
  transition: border-color .15s, background .15s;
}
.ind-btn:hover { border-color: var(--texto); }
.ind-btn[aria-selected="true"] { border-color: var(--acento); background: #10243a; box-shadow: inset 0 0 0 1px var(--acento); }
.ind-btn b { display: block; font-size: 1.05rem; letter-spacing: .01em; }
.ind-btn small { display: block; font-size: .74rem; color: var(--tenue); max-width: 22ch; line-height: 1.25; margin-top: 2px; }
.ind-btn .ind-n {
  position: absolute; top: 9px; right: 10px; font-size: .68rem; color: var(--tenue);
  border: 1px solid var(--linea-f); border-radius: 999px; padding: 0 7px;
}
.ind-btn.vacio b { color: var(--tenue); }
.ind-btn.vacio .ind-n { border-style: dashed; }

/* ---------- Barra ---------- */
.barra { display: flex; flex-wrap: wrap; gap: 12px 18px; align-items: flex-end; margin-bottom: 14px; }
.campo { display: flex; flex-direction: column; gap: 5px; }
.campo label { font-size: .7rem; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--tenue); }
.campo select {
  font-size: .9rem; background: var(--fondo); border: 1px solid var(--linea-f);
  border-radius: var(--radio); padding: 7px 10px; min-width: 190px;
}
.campo select:disabled { opacity: .5; }
.barra-der { margin-left: auto; }
.btn-sec {
  font-size: .82rem; background: var(--fondo); border: 1px solid var(--linea-f);
  border-radius: var(--radio); padding: 7px 12px; cursor: pointer;
}
.btn-sec:hover { border-color: var(--texto); }
.btn-sec:disabled { opacity: .45; cursor: default; }

/* ---------- Cuerpo: mapa + panel ---------- */
.cuerpo { display: grid; grid-template-columns: minmax(0, 1fr) 430px; gap: 16px; align-items: start; }

.mapa-wrap {
  position: relative; height: min(82vh, 880px); min-height: 520px;
  border: 1px solid var(--linea); border-radius: 12px; overflow: hidden;
  background: radial-gradient(ellipse at 50% 40%, #121a24 0%, #0b0f14 75%);
}
#mapa { width: 100%; height: 100%; display: block; cursor: grab; touch-action: none; user-select: none; }
#mapa.arrastrando { cursor: grabbing; }

#gLimite path { fill: none; stroke: #e8edf3; stroke-width: 1.6; vector-effect: non-scaling-stroke; }
#gMunicipios path { fill: transparent; stroke: rgba(232, 237, 243, .28); stroke-width: .8; stroke-dasharray: 3 3; vector-effect: non-scaling-stroke; }
#gMunicipios path:hover { fill: rgba(77, 163, 255, .07); }
#gRios path { fill: none; stroke: var(--rio); stroke-width: 1.1; stroke-linejoin: round; stroke-linecap: round; vector-effect: non-scaling-stroke; opacity: .85; }
#gLagos path { fill: var(--lago); stroke: var(--rio); stroke-width: .8; vector-effect: non-scaling-stroke; }
#gRaster image { opacity: .72; }
#gCabeceras text, .muni-et {
  fill: #cfd7e2; font-size: 11px; paint-order: stroke; stroke: rgba(11, 15, 20, .85); stroke-width: 3px;
  pointer-events: none; text-anchor: middle;
}
#gCabeceras circle { fill: #e8edf3; stroke: #0b0f14; }

.est { cursor: pointer; }
.est .est-sombra { fill: rgba(0, 0, 0, .45); }
.est .est-gota { stroke: #0b0f14; stroke-width: 2px; vector-effect: non-scaling-stroke; }
.est text { font-size: 11px; font-weight: 700; text-anchor: middle; pointer-events: none; }
.est.aprox .est-gota { stroke: #e8edf3; stroke-dasharray: 3 2; }
.est.sin-dato .est-gota { fill: #3a475a; }
.est:hover .est-gota, .est.activa .est-gota { stroke: #fff; stroke-width: 3px; }
.est.atenuada { opacity: .35; }

.mapa-titulo {
  position: absolute; top: 14px; left: 16px; max-width: 60%;
  font-size: 1rem; font-weight: 600; letter-spacing: -.01em;
  text-shadow: 0 1px 6px rgba(0, 0, 0, .8); pointer-events: none;
}
.mapa-titulo small { display: block; font-size: .78rem; font-weight: 400; color: var(--tenue); }

.mapa-zoom { position: absolute; top: 14px; right: 14px; display: flex; flex-direction: column; gap: 4px; }
.mapa-zoom button {
  width: 32px; height: 32px; border-radius: var(--radio); cursor: pointer; font-size: 1.05rem;
  background: rgba(16, 22, 29, .9); border: 1px solid var(--linea-f);
}
.mapa-zoom button:hover { border-color: var(--texto); }

.mapa-capas {
  position: absolute; top: 14px; right: 56px; font-size: .8rem;
  background: rgba(16, 22, 29, .92); border: 1px solid var(--linea-f); border-radius: 8px; padding: 6px 10px;
}
.mapa-capas summary { cursor: pointer; font-weight: 600; color: var(--tenue); font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; }
.mapa-capas label { display: flex; gap: 7px; align-items: center; margin-top: 5px; cursor: pointer; white-space: nowrap; }
.mapa-capas label.inactiva { opacity: .4; cursor: default; }

.mapa-leyenda {
  position: absolute; left: 14px; bottom: 40px; font-size: .78rem; min-width: 170px;
  background: rgba(16, 22, 29, .92); border: 1px solid var(--linea-f); border-radius: 8px; padding: 9px 12px;
}
.mapa-leyenda h4 { font-size: .7rem; text-transform: uppercase; letter-spacing: .07em; color: var(--tenue); margin: 0 0 5px; font-weight: 600; }
.mapa-leyenda h4 + h4, .mapa-leyenda ul + h4 { margin-top: 8px; }
.mapa-leyenda ul { list-style: none; display: grid; gap: 3px; }
.mapa-leyenda li { display: flex; align-items: center; gap: 8px; }
.mapa-leyenda .rango { color: var(--tenue); margin-left: auto; padding-left: 10px; font-size: .72rem; }
.sw { width: 12px; height: 12px; border-radius: 50%; flex: none; border: 1px solid rgba(0, 0, 0, .5); }
.sw-rio { width: 16px; height: 2px; background: var(--rio); border: 0; border-radius: 1px; }
.sw-lago { width: 14px; height: 10px; background: var(--lago); border-radius: 3px; border: 0; }
.sw-aprox { background: transparent; border: 1.5px dashed #e8edf3; }

.mapa-pie {
  position: absolute; left: 0; right: 0; bottom: 0; display: flex; justify-content: space-between; gap: 10px;
  padding: 6px 14px; font-size: .72rem; color: var(--tenue); pointer-events: none;
  background: linear-gradient(transparent, rgba(11, 15, 20, .85));
}
.escala { display: inline-flex; align-items: center; gap: 6px; }
.escala i { display: inline-block; height: 6px; border: 1.5px solid var(--texto); border-top: 0; }

.tooltip {
  position: absolute; z-index: 30; pointer-events: none; max-width: 260px;
  background: rgba(16, 22, 29, .97); border: 1px solid var(--linea-f); border-radius: 8px;
  padding: 8px 10px; font-size: .8rem; box-shadow: 0 10px 28px rgba(0, 0, 0, .5);
}
.tooltip strong { display: block; font-size: .86rem; }
.tooltip .tt-fila { display: flex; align-items: center; gap: 6px; margin-top: 3px; }
.tooltip .tt-tenue { color: var(--tenue); }

/* ---------- Panel ---------- */
.panel {
  background: var(--panel); border: 1px solid var(--linea); border-radius: 12px;
  padding: 18px 18px 20px; max-height: min(82vh, 880px); min-height: 520px; overflow-y: auto;
}
.panel h2 { font-size: 1.2rem; letter-spacing: -.015em; line-height: 1.2; }
.panel h3 {
  font-size: .7rem; font-weight: 600; text-transform: uppercase; letter-spacing: .08em;
  color: var(--tenue); margin: 18px 0 8px;
}
.panel p { font-size: .88rem; color: #c3ccd8; }
.panel .sub { color: var(--tenue); font-size: .8rem; margin-top: 3px; }
.etiqueta-medio {
  display: inline-block; font-size: .68rem; text-transform: uppercase; letter-spacing: .08em;
  padding: 1px 8px; border-radius: 999px; border: 1px solid var(--linea-f); color: var(--tenue); margin-bottom: 8px;
}
.resumen { margin-top: 10px; padding: 10px 12px; border-left: 2px solid var(--acento); background: var(--suave); border-radius: 0 6px 6px 0; }

.distrib { display: flex; height: 14px; gap: 2px; border-radius: 4px; overflow: hidden; margin-bottom: 6px; }
.distrib span { display: block; height: 100%; }
.distrib-ley { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: .76rem; color: var(--tenue); }
.distrib-ley span { display: inline-flex; align-items: center; gap: 5px; }

.grafica svg { width: 100%; display: block; overflow: visible; }
.grafica text { fill: var(--tenue); font-size: 11px; }
.grafica .g-nombre { fill: var(--texto); }
.grafica .g-valor { fill: var(--texto); font-weight: 600; }
.grafica .g-fila { cursor: pointer; }
.grafica .g-fila:hover .g-hit, .grafica .g-fila.activa .g-hit { fill: rgba(77, 163, 255, .08); }
.grafica .g-hit { fill: transparent; }
.grafica .g-eje { stroke: var(--linea-f); stroke-width: 1; }
.grafica .g-grid { stroke: var(--linea); stroke-width: 1; }

table.tabla { width: 100%; border-collapse: collapse; font-size: .84rem; }
.tabla th { text-align: left; font-size: .68rem; text-transform: uppercase; letter-spacing: .06em; color: var(--tenue); font-weight: 600; padding: 6px 6px; border-bottom: 1px solid var(--linea-f); }
.tabla td { padding: 6px 6px; border-bottom: 1px solid var(--linea); }
.tabla td.num { text-align: right; font-variant-numeric: tabular-nums; }
.tabla th.num { text-align: right; }
.tabla tr { cursor: pointer; }
.tabla tbody tr:hover, .tabla tr.activa { background: var(--suave); }
.clase { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }

.vacio-panel {
  margin-top: 18px; padding: 22px 16px; text-align: center; color: var(--tenue);
  border: 1px dashed var(--linea-f); border-radius: 10px; font-size: .88rem;
}
.vacio-panel b { display: block; color: var(--texto); margin-bottom: 6px; font-size: .95rem; }

.volver { background: none; border: 0; color: var(--acento); cursor: pointer; font-size: .82rem; padding: 0; margin-bottom: 10px; }
.volver:hover { text-decoration: underline; }
.fichas { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 8px; }
.ficha {
  text-align: left; cursor: pointer; padding: 8px 10px; border-radius: 8px;
  background: var(--fondo); border: 1px solid var(--linea-f);
}
.ficha:hover { border-color: var(--texto); }
.ficha.actual { border-color: var(--acento); }
.ficha b { font-size: .78rem; color: var(--tenue); display: block; font-weight: 600; }
.ficha .ficha-v { font-size: 1.05rem; font-weight: 700; display: block; margin: 2px 0; }
.ficha .clase { font-size: .74rem; color: #c3ccd8; }
.ficha.sin .ficha-v { color: var(--tenue); font-weight: 400; font-size: .85rem; }
.datos-est { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; font-size: .84rem; }
.datos-est dt { color: var(--tenue); }
.nota { font-size: .76rem; color: var(--tenue); margin-top: 8px; }

.pie {
  display: flex; flex-wrap: wrap; justify-content: space-between; gap: 6px 18px;
  margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--linea);
  font-size: .74rem; color: var(--tenue);
}

/* ---------- Responsivo ---------- */
@media (max-width: 1080px) {
  .cuerpo { grid-template-columns: 1fr; }
  .panel { max-height: none; min-height: 0; }
}
@media (max-width: 640px) {
  #app { padding: 16px 16px 20px; }
  .cab { flex-direction: column; }
  .cab-marca img { width: 40px; height: 40px; }
  .ind-btn { min-width: 0; flex: 1 1 calc(50% - 8px); }
  .indices-grupo { width: 100%; }
  .mapa-wrap { height: 68vh; min-height: 420px; }
  .mapa-capas { right: 56px; }
  .mapa-capas:not([open]) { padding: 6px 8px; }
  .mapa-leyenda { bottom: 34px; font-size: .72rem; min-width: 0; max-width: 60%; }
  .mapa-titulo { max-width: 50%; font-size: .88rem; }
  .barra-der { margin-left: 0; }
  .campo select { min-width: 150px; }
}
