:root {
  --fondo: #f5f6f8;
  --superficie: #ffffff;
  --texto: #14161a;
  --suave: #52565f;
  --tenue: #8a8f98;
  --borde: #e4e6ea;
  --acento: #2a78d6;
  --acento-suave: #eaf2fc;
  --critical: #d03b3b;
  --serious: #ec835a;
  --warning: #fab219;
  --good: #0ca30c;
  --lateral: 236px;
  --kamke: #232051;  /* azul del logo */
}

* { box-sizing: border-box; }
body {
  margin: 0; background: var(--fondo); color: var(--texto);
  font: 14px/1.5 Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
}
a { color: var(--acento); text-decoration: none; }
a:hover { text-decoration: underline; }
code { font-size: 12px; background: #f0f1f3; padding: 1px 4px; border-radius: 4px; }
.muted { color: var(--suave); font-size: 13px; }

/* -- barra lateral con las pestañas -- */
.lateral {
  position: fixed; inset: 0 auto 0 0; width: var(--lateral); overflow-y: auto;
  background: var(--superficie); border-right: 1px solid var(--borde); padding: 20px 14px;
  display: flex; flex-direction: column; gap: 16px;
}
.logo { display: block; background: var(--kamke); border-radius: 10px; padding: 10px 12px; }
.logo img { display: block; width: 100%; height: auto; }
.marca { font-weight: 700; font-size: 15px; }
.marca span { display: block; font-weight: 400; font-size: 12px; color: var(--suave); }
nav a.separado { margin-top: 8px; border-top: 1px solid var(--borde); border-radius: 0 0 8px 8px; padding-top: 12px; }
.sugerir { font-size: 13px; white-space: nowrap; }
.fuente { display: flex; border: 1px solid var(--borde); border-radius: 8px; overflow: hidden; }
.fuente a { flex: 1; text-align: center; padding: 6px 4px; font-size: 12.5px; color: var(--suave); }
.fuente a.activa { background: var(--acento); color: #fff; }
.fuente a:hover { text-decoration: none; }
nav { display: flex; flex-direction: column; gap: 2px; }
nav a {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px;
  color: var(--texto); font-size: 14px;
}
nav a:hover { background: #f0f1f3; text-decoration: none; }
nav a.activa { background: var(--acento-suave); color: var(--acento); font-weight: 600; }
nav .icono { width: 20px; text-align: center; }
.ayuda { font-size: 12.5px; color: var(--suave); }
.ayuda summary { cursor: pointer; color: var(--texto); font-weight: 600; margin-bottom: 6px; }
.ayuda p { margin: 0 0 8px; }
.pie { margin-top: auto; font-size: 12px; color: var(--tenue); }

/* -- contenido -- */
main { margin-left: var(--lateral); padding: 24px 32px 48px; max-width: 1500px; }
.cabecera h1 { margin: 0 0 4px; font-size: 26px; }
.cabecera p { margin: 0 0 14px; max-width: 980px; }
h2 { font-size: 16px; margin: 0 0 12px; }
h3 { font-size: 14px; margin: 14px 0 8px; }

.filtros {
  display: flex; flex-wrap: wrap; gap: 10px 14px; align-items: flex-end; margin-bottom: 14px;
  background: var(--superficie); border: 1px solid var(--borde); border-radius: 10px; padding: 12px 14px;
}
.filtros label, label.en-linea, .selector label { display: flex; flex-direction: column; gap: 3px; font-size: 12px; color: var(--suave); }
label.en-linea { flex-direction: row; align-items: center; gap: 8px; }
input, select, button {
  font: inherit; font-size: 13px; padding: 6px 8px; border: 1px solid #cfd2d8; border-radius: 6px; background: #fff; color: var(--texto);
}
button { background: var(--acento); color: #fff; border-color: var(--acento); cursor: pointer; padding: 6px 14px; }
.boton-secundario { font-size: 13px; padding: 6px 4px; }
.selector { margin-bottom: 14px; }
.selector select { min-width: 280px; font-size: 14px; }

.aviso, .nota { border-radius: 10px; padding: 10px 14px; margin-bottom: 16px; font-size: 13.5px; }
.aviso { background: #fff8e1; border: 1px solid #f3dc8b; }
.nota { background: var(--acento-suave); border: 1px solid #c9ddf6; }

.kpis { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpis-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.kpis-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.kpi { background: var(--superficie); border: 1px solid var(--borde); border-radius: 10px; padding: 12px 14px; min-width: 0; }
.kpi-etiqueta { font-size: 12.5px; color: var(--suave); }
.kpi-valor { font-size: 26px; font-weight: 600; margin: 2px 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi-detalle { font-size: 12px; color: var(--suave); }

.panel { background: var(--superficie); border: 1px solid var(--borde); border-radius: 10px; padding: 16px 18px; margin-bottom: 16px; min-width: 0; }
.fila { display: flex; gap: 16px; }
.fila > .panel { flex: 1; }
.fila > .ancho-2 { flex: 2; }
.fila > .ancho-3 { flex: 1.3; }
.columna { display: flex; flex-direction: column; gap: 16px; flex: 1; min-width: 0; margin-bottom: 16px; }
.columna > .panel { margin-bottom: 0; }
.grilla-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 24px; }
.ancho-limitado { max-width: 820px; }
.titulo-con-controles { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 10px; }
.titulo-con-controles h2, .titulo-con-controles h3 { margin: 0; }
.controles { display: flex; gap: 10px; flex-wrap: wrap; }
.segmentado { display: inline-flex; border: 1px solid var(--borde); border-radius: 8px; overflow: hidden; }
.segmentado a { padding: 5px 12px; font-size: 13px; color: var(--suave); border-right: 1px solid var(--borde); }
.segmentado a:last-child { border-right: 0; }
.segmentado a.activa { background: var(--acento-suave); color: var(--acento); font-weight: 600; }
.segmentado a:hover { text-decoration: none; background: #f0f1f3; }
.segmentado.bloque { margin-bottom: 14px; }

.hallazgos p { margin: 0 0 8px; padding-left: 12px; border-left: 3px solid var(--acento); }
.alerta { margin: 0 0 8px; }
.leyenda { display: flex; gap: 16px; font-size: 12.5px; color: var(--suave); margin: 4px 0 0; }

.chip {
  display: inline-block; font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 999px; margin: 0 4px 4px 0;
  white-space: nowrap; border: 1px solid transparent;
}
.chip-critical { background: #fbe4e4; color: #9c1f1f; border-color: #f2c2c2; }
.chip-serious { background: #fdeee6; color: #9a3d16; border-color: #f6cfbb; }
.chip-warning { background: #fff4d6; color: #7a5600; border-color: #f4dd95; }
.chip-good { background: #e2f5e2; color: #0a6b0a; border-color: #bfe5bf; }

.tarjetas { display: grid; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); gap: 12px; }
.tarjetas-2 { grid-template-columns: repeat(auto-fill, minmax(360px, 1fr)); margin-top: 12px; }
.tarjeta { border: 1px solid var(--borde); border-radius: 10px; padding: 12px 14px; background: var(--superficie); display: flex; flex-direction: column; gap: 4px; }
.tarjeta h3 { margin: 0; font-size: 15px; }
.tarjeta p { margin: 0; }
.tarjeta .chips { margin: 6px 0 2px; }
.tarjeta .ver { margin-top: auto; font-size: 13px; }
.borde-critical { border-left: 4px solid var(--critical); }
.borde-serious { border-left: 4px solid var(--serious); }
.borde-warning { border-left: 4px solid var(--warning); }
.borde-good { border-left: 4px solid var(--good); }

.tabla-scroll { overflow-x: auto; max-height: 640px; overflow-y: auto; border: 1px solid var(--borde); border-radius: 8px; }
.tabla { width: 100%; border-collapse: collapse; font-size: 13px; }
.tabla th { position: sticky; top: 0; background: #f7f8fa; text-align: left; font-weight: 600; color: var(--suave);
  padding: 7px 10px; border-bottom: 1px solid var(--borde); white-space: nowrap; }
.tabla.ordenable th { cursor: pointer; }
.tabla th[data-orden="asc"]::after { content: " ▲"; }
.tabla th[data-orden="desc"]::after { content: " ▼"; }
.tabla td { padding: 6px 10px; border-bottom: 1px solid #eef0f3; vertical-align: top; }
.tabla tbody tr:hover { background: #fafbfc; }
.tabla .num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.tabla td.texto { min-width: 260px; }
.barra { display: inline-block; width: 60px; height: 6px; background: #eceef1; border-radius: 3px; margin-right: 6px; vertical-align: middle; overflow: hidden; }
.barra span { display: block; height: 100%; background: var(--acento); }
.punto { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 6px; vertical-align: -1px; }

.mapa { border-radius: 8px; border: 1px solid var(--borde); margin-bottom: 8px; }
.leaflet-control-layers { font-size: 12px; }
.ayuda-uso { background: var(--acento-suave); border: 1px solid #c9ddf6; border-radius: 8px; padding: 8px 14px;
  margin: 4px 0 12px; font-size: 13px; line-height: 1.5; }
.ayuda-uso summary { cursor: pointer; font-weight: 600; color: var(--acento); }
.ayuda-uso ul { margin: 8px 0 2px; padding-left: 18px; }
.ayuda-uso li { margin-bottom: 4px; }
.controles-mapa { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-bottom: 10px; }
.controles-mapa[hidden], .reproductor[hidden] { display: none; }
.detalle-capa { color: var(--suave); font-size: 12.5px; }
.leyenda-calor { display: inline-flex; align-items: center; gap: 8px; font-size: 12px; color: var(--suave); }
.leyenda-calor i { width: 160px; height: 10px; border-radius: 5px;
  background: linear-gradient(90deg, #f9bea0, #f39566, #eb6834, #b8461c, #7a2a0c); }
.reproductor { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 10px; }
.reproductor input[type="range"] { flex: 1; min-width: 200px; accent-color: var(--acento); }
.reproductor .reloj { font-variant-numeric: tabular-nums; font-size: 13px; min-width: 250px; }
details summary { cursor: pointer; }
h2.en-linea { display: inline; }

/* -- pantallas angostas: las pestañas pasan arriba -- */
@media (max-width: 1000px) {
  .lateral { position: static; width: auto; border-right: 0; border-bottom: 1px solid var(--borde); padding: 12px 16px; gap: 10px; }
  nav { flex-direction: row; flex-wrap: wrap; }
  .ayuda, .pie { display: none; }
  main { margin-left: 0; padding: 16px; }
  .kpis, .kpis-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .fila { flex-direction: column; }
  .grilla-2 { grid-template-columns: 1fr; }
}

/* -- portada, ingreso y feedback -- */
.portada { background: var(--fondo); }
.banda { background: var(--kamke); color: #fff; display: flex; align-items: center; gap: 28px; padding: 28px 40px; }
.banda img { height: 96px; width: auto; }
.banda h1 { margin: 0 0 4px; font-size: 28px; }
.banda p { margin: 0; color: #c9c8e6; }
.elegir { max-width: 1100px; margin: 0 auto; padding: 32px 24px; }
.elegir h2 { font-size: 20px; margin-bottom: 16px; }
.opciones { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 20px; }
.opcion { display: flex; flex-direction: column; gap: 6px; background: var(--superficie); border: 1px solid var(--borde);
  border-radius: 14px; padding: 22px 24px; color: var(--texto); transition: border-color .15s, box-shadow .15s; }
.opcion:hover { text-decoration: none; border-color: var(--acento); box-shadow: 0 6px 18px rgba(20, 22, 26, .08); }
.opcion h3 { margin: 4px 0 0; font-size: 19px; }
.opcion p { margin: 0; }
.opcion-icono { font-size: 30px; }
.boton { display: inline-block; align-self: flex-start; margin-top: 10px; background: var(--acento); color: #fff;
  border-radius: 8px; padding: 8px 16px; font-weight: 600; }
.boton:hover { text-decoration: none; }
.boton-grande { font-size: 15px; padding: 10px 22px; margin-top: 14px; }
.pie-portada { margin-top: 24px; }
.ingreso { max-width: 440px; margin: 10vh auto; background: var(--superficie); border: 1px solid var(--borde);
  border-radius: 14px; padding: 28px; text-align: center; }
.ingreso-logo { background: var(--kamke); border-radius: 10px; padding: 14px; margin-bottom: 16px; }
.ingreso-logo img { max-width: 260px; width: 100%; }
.ingreso h1 { font-size: 22px; margin: 0 0 8px; }
.texto-legal { max-width: 680px; margin: 5vh auto; text-align: left; line-height: 1.55; }
.texto-legal h2 { font-size: 15px; margin: 18px 0 4px; }
.texto-legal p { margin: 0 0 8px; }
.formulario { display: flex; flex-direction: column; gap: 12px; }
.formulario label { display: flex; flex-direction: column; gap: 4px; font-size: 12.5px; color: var(--suave); }
.formulario button { align-self: flex-start; }
textarea { font: inherit; font-size: 14px; padding: 8px 10px; border: 1px solid #cfd2d8; border-radius: 6px; resize: vertical; }
.comentario { border-bottom: 1px solid var(--borde); padding: 10px 0; }
.comentario p { margin: 0 0 6px; white-space: pre-wrap; }
.comentario.nuevo { border-left: 3px solid var(--acento); padding-left: 10px; }
.boton-chico { font-size: 12px; padding: 3px 10px; background: #fff; color: var(--acento); border-color: #c9ddf6; }
.en-linea { display: inline-block; margin: 0 4px 4px 0; }
@media (max-width: 700px) {
  .banda { flex-direction: column; align-items: flex-start; padding: 20px; gap: 12px; }
  .banda img { height: 64px; }
}
