/* Mapa eólico del Perú — Corporación Nexus
   Mismo sistema visual que los laboratorios de vigas y columnas (Laboratoriocon/css/lab.css):
   tokens, barra superior, escenario con HUD, tarjetas y lecturas. */
:root {
  --bg: #f6f7f8;
  --bg-alt: #eef0f2;
  --surface: #ffffff;
  --surface-2: #fbfbfc;
  --border: #e6e8eb;
  --border-strong: #d4d8dd;
  --fg: #1a1f24;
  --fg-muted: #687079;
  --fg-faint: #9aa1a9;
  --fg-strong: #10141a;
  --gray-brand: #43494f;
  --red: #ea4f50;
  --red-600: #d63e3f;
  --red-tint: #fdf2f2;
  --teal: #244c5b;
  --teal-deep: #1a3a45;
  --teal-tint: #eef3f5;
  --teal-soft: #5aa0b6;
  --ochre: #b07a2a;
  --ochre-tint: #f8f1e6;
  --ok: #2f7a55;
  --ok-tint: #edf6f1;
  --hud-bg: rgba(255, 255, 255, 0.78);
  --hud-border: rgba(16, 20, 26, 0.08);
  --stage-bg: #e9ebee;
  --halo: rgba(255, 255, 255, 0.92);
  --linea-iso: rgba(12, 14, 18, 0.62);     /* oscura en ambos temas: va sobre la escala de colores */
  --shadow-sm: 0 1px 2px rgba(16, 20, 26, 0.04), 0 6px 20px rgba(16, 20, 26, 0.05);
  --shadow-md: 0 10px 30px rgba(16, 20, 26, 0.08), 0 2px 8px rgba(16, 20, 26, 0.05);
  --sans: "Geist", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: "Geist Mono", ui-monospace, "Cascadia Code", SFMono-Regular, Menlo, monospace;
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --radius: 14px;
  --radius-sm: 9px;
  --gutter: clamp(16px, 3vw, 32px);
  color-scheme: light;
}

:root[data-theme="dark"] {
  --bg: #111418;
  --bg-alt: #161a1f;
  --surface: #1b1f25;
  --surface-2: #20252c;
  --border: #2a3138;
  --border-strong: #39414a;
  --fg: #e7ebf0;
  --fg-muted: #98a2ad;
  --fg-faint: #6b747e;
  --fg-strong: #ffffff;
  --gray-brand: #c7ccd1;
  --red: #f56364;
  --red-600: #ff7374;
  --red-tint: #2a1b1c;
  --teal: #5aa0b6;
  --teal-deep: #122e38;
  --teal-tint: #15303a;
  --teal-soft: #7cbcd0;
  --ochre: #d9a456;
  --ochre-tint: #2b2316;
  --ok: #5cbf8a;
  --ok-tint: #16271e;
  --hud-bg: rgba(20, 23, 27, 0.74);
  --hud-border: rgba(255, 255, 255, 0.07);
  --stage-bg: #0d1013;
  --halo: rgba(13, 16, 19, 0.86);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px rgba(0, 0, 0, 0.32);
  --shadow-md: 0 14px 40px rgba(0, 0, 0, 0.45);
  color-scheme: dark;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #111418; --bg-alt: #161a1f; --surface: #1b1f25; --surface-2: #20252c; --border: #2a3138;
    --border-strong: #39414a; --fg: #e7ebf0; --fg-muted: #98a2ad; --fg-faint: #6b747e; --fg-strong: #ffffff;
    --gray-brand: #c7ccd1; --red: #f56364; --red-600: #ff7374; --red-tint: #2a1b1c; --teal: #5aa0b6;
    --teal-deep: #122e38; --teal-tint: #15303a; --teal-soft: #7cbcd0; --ochre: #d9a456; --ochre-tint: #2b2316;
    --ok: #5cbf8a; --ok-tint: #16271e; --hud-bg: rgba(20, 23, 27, 0.74);
    --hud-border: rgba(255, 255, 255, 0.07); --stage-bg: #0d1013; --halo: rgba(13, 16, 19, 0.86);
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px rgba(0, 0, 0, 0.32);
    --shadow-md: 0 14px 40px rgba(0, 0, 0, 0.45);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 400 15px/1.55 var(--sans);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
a { color: inherit; }
button, input, select { font: inherit; color: inherit; }
::selection { background: var(--red); color: #fff; }

.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.eyebrow {
  font: 500 11px/1.4 var(--mono);
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--fg-muted);
}

/* ---------------------------------------------------------------- barra superior */
.topbar {
  position: sticky; top: 0; z-index: 1100;
  display: flex; align-items: center; gap: 18px;
  height: 64px; padding: 0 var(--gutter);
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(1.4) blur(14px);
  -webkit-backdrop-filter: saturate(1.4) blur(14px);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; }
.brand svg { height: 26px; width: auto; display: block; }
.brand .word { font: 500 21px/1 var(--sans); letter-spacing: -0.02em; color: var(--gray-brand); }
.topbar .divider { width: 1px; height: 26px; background: var(--border-strong); }
.topbar .title { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
.topbar .title strong { font-weight: 600; font-size: 14.5px; color: var(--fg-strong); white-space: nowrap; }
.topbar .title span { font: 400 10.5px/1.3 var(--mono); letter-spacing: 0.16em; text-transform: uppercase; color: var(--fg-muted); white-space: nowrap; }
.topbar .spacer { flex: 1; }
.seg {
  display: inline-flex; padding: 3px; gap: 2px;
  border: 1px solid var(--border); border-radius: 999px; background: var(--surface);
}
.seg button {
  border: 0; background: transparent; cursor: pointer; white-space: nowrap;
  padding: 5px 12px; border-radius: 999px;
  font: 500 12px/1.2 var(--mono); color: var(--fg-muted); letter-spacing: 0.02em;
  transition: background 0.2s var(--ease-out), color 0.2s;
}
.seg button:hover { color: var(--fg); }
.seg button[aria-pressed="true"] { background: var(--fg-strong); color: var(--bg); }
.icon-btn {
  width: 36px; height: 36px; display: grid; place-items: center;
  border: 1px solid var(--border); border-radius: 10px; background: var(--surface);
  cursor: pointer; color: var(--fg-muted);
}
.icon-btn:hover { color: var(--fg-strong); border-color: var(--border-strong); }
.icon-btn svg { width: 17px; height: 17px; }

/* ---------------------------------------------------------------- encabezado */
.intro {
  padding: 22px var(--gutter) 16px;
  display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 20px; align-items: end;
  max-width: 1720px; margin: 0 auto;
}
.intro h1 {
  margin: 8px 0 6px; font-weight: 600; letter-spacing: -0.035em;
  font-size: clamp(28px, 3.4vw, 46px); line-height: 1.02; color: var(--fg-strong);
}
.intro h1 em { font-style: normal; color: var(--red); }
.intro p { margin: 0; max-width: 760px; color: var(--fg-muted); font-size: 15.5px; }
.norms { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px; border-radius: 999px; border: 1px solid var(--border);
  font: 500 11px/1.4 var(--mono); color: var(--fg-muted); background: var(--surface); white-space: nowrap;
}
.chip.red { color: var(--red); border-color: color-mix(in srgb, var(--red) 35%, transparent); background: var(--red-tint); }
.chip.teal { color: var(--teal); border-color: color-mix(in srgb, var(--teal) 30%, transparent); background: var(--teal-tint); }
.chip.ochre { color: var(--ochre); border-color: color-mix(in srgb, var(--ochre) 35%, transparent); background: var(--ochre-tint); }

/* ---------------------------------------------------------------- área de trabajo */
.workspace {
  max-width: 1720px; margin: 0 auto; padding: 0 var(--gutter) 28px;
  display: grid; grid-template-columns: minmax(0, 1fr) 388px; gap: 18px; align-items: start;
}
.stage-wrap { position: sticky; top: 76px; }
.stage {
  position: relative; overflow: hidden;
  height: clamp(480px, calc(100vh - 200px), 880px);
  border-radius: var(--radius); background: var(--stage-bg);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  isolation: isolate;
  container-type: inline-size;
}
.mapa { position: absolute; inset: 0; outline: none; }

.hud {
  position: absolute; z-index: 900;
  background: var(--hud-bg); border: 1px solid var(--hud-border);
  backdrop-filter: blur(14px) saturate(1.3); -webkit-backdrop-filter: blur(14px) saturate(1.3);
  border-radius: 12px; box-shadow: 0 8px 28px rgba(0, 0, 0, 0.12);
}
.hud-read { top: 14px; left: 14px; padding: 12px 14px 10px; display: grid; grid-template-columns: 7.4em 7.4em minmax(0, 12em); gap: 8px 22px; pointer-events: none; }
.hud-read .k { font: 500 9.5px/1.3 var(--mono); letter-spacing: 0.14em; text-transform: uppercase; color: var(--fg-muted); white-space: nowrap; }
.hud-read .v { font: 500 19px/1.15 var(--mono); color: var(--fg-strong); font-variant-numeric: tabular-nums; white-space: nowrap; }
.hud-read .v small { font-size: 11px; color: var(--fg-muted); margin-left: 3px; font-weight: 400; }
.hud-read .v.txt { font: 600 14px/1.55 var(--sans); overflow: hidden; text-overflow: ellipsis; }
.hud-read .v.min { color: var(--fg-muted); }

.hud-state { top: 14px; right: 14px; padding: 10px 12px; width: 268px; }
.hud-state .row { display: flex; align-items: center; gap: 8px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--fg-faint); flex: none; }
.dot.live { background: var(--ok); box-shadow: 0 0 0 4px color-mix(in srgb, var(--ok) 22%, transparent); animation: latido 2.4s ease-in-out infinite; }
@keyframes latido { 50% { box-shadow: 0 0 0 7px color-mix(in srgb, var(--ok) 0%, transparent); } }
.hud-state .stage-name { font: 600 13px/1.3 var(--sans); color: var(--fg-strong); }
.hud-state .stage-desc { margin-top: 4px; font-size: 12px; line-height: 1.45; color: var(--fg-muted); }

/* con el escenario angosto el aviso se reduce a una etiqueta (el texto completo queda en su title) */
@container (max-width: 900px) {
  .hud-state { width: auto; padding: 8px 11px; }
  .hud-state .stage-desc { display: none; }
  .hud-read { gap: 8px 16px; grid-template-columns: 7.2em 7.2em minmax(0, 9em); }
}
@container (max-width: 640px) { .hud-state { display: none; } }

.hud-zoom { right: 14px; top: 50%; transform: translateY(-50%); padding: 4px; display: flex; flex-direction: column; gap: 2px; }
.hud-zoom .tab { width: 32px; height: 32px; padding: 0; display: grid; place-items: center; }
.hud-zoom svg { width: 15px; height: 15px; }

.hud-views { left: 14px; bottom: 82px; padding: 4px; display: flex; gap: 2px; }
.hud-cams { right: 14px; bottom: 82px; padding: 4px; display: flex; gap: 2px; }
.hud button.tab {
  border: 0; background: transparent; cursor: pointer; padding: 7px 11px; border-radius: 8px;
  font: 500 12px/1 var(--sans); color: var(--fg-muted); white-space: nowrap;
}
.hud button.tab:hover { color: var(--fg-strong); }
.hud button.tab[aria-pressed="true"] { background: var(--fg-strong); color: var(--bg); }
.hud button.tab:disabled { opacity: 0.4; cursor: default; }
.hud button.tab:disabled:hover { color: var(--fg-muted); }

.timeline {
  left: 14px; right: 14px; bottom: 14px; padding: 8px 16px 8px 8px;
  display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 16px; align-items: center;
}
.play {
  width: 44px; height: 44px; border-radius: 10px; border: 0; cursor: pointer;
  background: var(--red); color: #fff; display: grid; place-items: center;
  box-shadow: 0 6px 16px color-mix(in srgb, var(--red) 40%, transparent);
  transition: transform 0.2s var(--ease-out), background 0.2s;
}
.play:hover { background: var(--red-600); transform: translateY(-1px); }
.play svg { width: 16px; height: 16px; grid-area: 1 / 1; }
.play .ico-play { display: none; }
.play[aria-pressed="false"] .ico-play { display: block; }
.play[aria-pressed="false"] .ico-pausa { display: none; }

.escala { min-width: 0; }
.escala-cab { display: flex; justify-content: space-between; gap: 12px; font: 500 9.5px/1.3 var(--mono); letter-spacing: 0.14em; text-transform: uppercase; color: var(--fg-muted); white-space: nowrap; }
.escala-nota { letter-spacing: 0.06em; text-transform: none; overflow: hidden; text-overflow: ellipsis; }
.escala-barra { position: relative; height: 9px; border-radius: 3px; margin: 6px 0 3px; }
.escala-barra .umbral { position: absolute; top: -3px; bottom: -3px; width: 2px; margin-left: -1px; border-radius: 1px; background: var(--fg-strong); box-shadow: 0 0 0 1.5px var(--halo); }
.escala-ticks { position: relative; height: 13px; font: 400 10px/1.3 var(--mono); color: var(--fg-muted); }
.escala-ticks span { position: absolute; top: 0; transform: translateX(-50%); white-space: nowrap; }
.escala-ticks span:first-child { transform: none; }
.escala-ticks span:last-child { transform: translateX(-100%); }
.escala-ticks b { color: var(--fg-strong); font-weight: 600; }

/* atribución de Leaflet: texto mínimo sobre los botones de capas */
.stage .leaflet-bottom.leaflet-right { bottom: 124px; right: 10px; }
.stage .leaflet-control-attribution {
  margin: 0 !important; padding: 0 4px !important; background: none !important;
  font: 400 10px/1.4 var(--sans); color: var(--fg-muted);
  text-shadow: 0 0 3px var(--halo), 0 0 6px var(--halo);
}
.stage .leaflet-control-attribution a { color: var(--fg-muted); text-decoration: none; }

.loading { position: absolute; inset: 0; display: grid; place-items: center; z-index: 950; background: var(--stage-bg); transition: opacity 0.6s; }
.loading.done { opacity: 0; pointer-events: none; }
.loading.error .eyebrow { color: var(--red); max-width: 420px; text-align: center; letter-spacing: 0.08em; line-height: 1.6; }

/* ---------------------------------------------------------------- capas del mapa */
.leaflet-container { background: var(--stage-bg); font-family: var(--sans); }
.leaflet-container a { color: var(--fg); }
.leaflet-container svg, .leaflet-container img { max-width: none !important; max-height: none !important; }
.capa-raster { transition: opacity 0.4s ease; }
.capa-viento { opacity: 0.94; }
.capa-relieve { opacity: 0.85; }
.capa-calles { opacity: 0.9; }
:root[data-theme="dark"] .capa-calles { filter: invert(1) hue-rotate(180deg) grayscale(0.75) brightness(0.82) contrast(0.92); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .capa-calles { filter: invert(1) hue-rotate(180deg) grayscale(0.75) brightness(0.82) contrast(0.92); } }
.con-calles .capa-viento { opacity: 0.5; }
.capa-particulas { pointer-events: none; }

.lim-peru { stroke: var(--fg-strong); stroke-opacity: 0.55; fill: none; }
.lim-dep { stroke: var(--fg); stroke-opacity: 0.25; fill: none; }
.iso { stroke: var(--linea-iso); fill: none; stroke-linecap: round; stroke-linejoin: round; }
.iso-baja { stroke-dasharray: 5 4; }
.iso-costa { stroke-dasharray: 1.5 3.5; }
.icono-etq { background: none; border: 0; }
.etq {
  font: 500 11.5px/1.2 var(--sans); color: var(--fg-strong); white-space: nowrap; letter-spacing: 0.01em;
  text-shadow: 0 0 3px var(--halo), 0 0 6px var(--halo), 0 0 1px var(--halo);
  pointer-events: none;
}
.etq-ciudad { display: flex; align-items: center; gap: 5px; transform: translate(-4px, -50%); }
.etq-ciudad::before {
  content: ""; width: 5px; height: 5px; border-radius: 50%; flex: none;
  background: var(--fg-strong); box-shadow: 0 0 0 1.5px var(--halo);
}
.etq-iso {
  display: inline-block; transform: translate(-50%, -50%);
  font: 600 10px/16px var(--mono); color: #fff; background: rgba(16, 20, 26, 0.82);
  border: 1px solid rgba(255, 255, 255, 0.14); border-radius: 6px; padding: 0 5px; pointer-events: none;
}
.etq-iso.costa { border-style: dashed; }
.etq-mar { font: 500 10.5px/1 var(--mono); letter-spacing: 0.42em; text-transform: uppercase; color: var(--fg-muted); opacity: 0.8; transform: translate(-50%, -50%); text-shadow: none; }

.marcador-punto {
  width: 18px; height: 18px; border-radius: 50%; position: relative;
  background: var(--red); border: 3px solid #fff;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.25), 0 4px 14px rgba(0, 0, 0, 0.4);
}
.marcador-punto::after {
  content: ""; position: absolute; inset: -12px; border-radius: 50%;
  border: 2px solid var(--red); opacity: 0; animation: onda 2.2s ease-out infinite;
}
@keyframes onda { 0% { transform: scale(0.45); opacity: 0.7; } 100% { transform: scale(1.3); opacity: 0; } }

.pista-rueda {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); z-index: 960;
  padding: 9px 14px; border-radius: 10px; background: var(--fg-strong); color: var(--bg);
  font: 500 12.5px/1.3 var(--sans); opacity: 0; pointer-events: none; transition: opacity 0.25s;
}
.pista-rueda.visible { opacity: 0.92; }

/* ---------------------------------------------------------------- panel de control */
.panel { display: flex; flex-direction: column; gap: 12px; }
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.card > header {
  display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap;
  padding: 11px 16px; min-height: 52px; border-bottom: 1px solid var(--border);
}
.card > header h2, .card > header h3 {
  margin: 0; font: 600 11.5px/1.3 var(--mono); letter-spacing: 0.16em; text-transform: uppercase; color: var(--fg-strong);
}
.card > header .meta { font: 400 11px/1.3 var(--mono); color: var(--fg-muted); }
.card .body { padding: 14px 16px 16px; }

.buscador { position: relative; }
.buscador .inp { background: var(--surface-2); }
.buscador .lupa { width: 15px; height: 15px; margin: 0 0 0 10px; align-self: center; color: var(--fg-muted); flex: none; }
.buscador input { font-family: var(--sans); font-weight: 400; font-size: 13.5px; padding: 9px 10px; }
.buscador input::-webkit-search-cancel-button { cursor: pointer; }
.sugerencias {
  position: absolute; left: 0; right: 0; top: calc(100% + 6px); z-index: 1000;
  margin: 0; padding: 4px; list-style: none; max-height: 320px; overflow: auto;
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: 11px; box-shadow: var(--shadow-md);
}
.sugerencias li { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 7px 10px; border-radius: 8px; cursor: pointer; }
.sugerencias li[aria-selected="true"], .sugerencias li:hover { background: var(--bg-alt); }
.sugerencias .sug-nombre { display: block; font-weight: 600; font-size: 13px; color: var(--fg-strong); }
.sugerencias .sug-nombre.sug-osm { font-weight: 500; color: var(--teal); }
.sugerencias .sug-sub { display: block; font-size: 11.5px; color: var(--fg-muted); }
.sugerencias .sug-v { font: 500 11.5px/1 var(--mono); color: var(--fg-muted); white-space: nowrap; }
.sugerencias .sug-estado { cursor: default; font-size: 12.5px; color: var(--fg-muted); }
.sugerencias .sug-estado:hover { background: none; }

.sc-tit { display: block; margin: 14px 0 7px; font-size: 10px; }
.sc-list { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.sc {
  text-align: left; cursor: pointer; padding: 7px 9px 8px; border-radius: 10px; min-width: 0;
  border: 1px solid var(--border); background: var(--surface-2);
  transition: border-color 0.2s, background 0.2s, transform 0.2s var(--ease-out);
}
.sc:hover { border-color: var(--border-strong); transform: translateY(-1px); }
.sc strong { display: block; font-size: 12.5px; font-weight: 600; color: var(--fg-strong); line-height: 1.25; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sc span { display: flex; align-items: center; gap: 5px; font: 400 10.5px/1.3 var(--mono); color: var(--fg-muted); margin-top: 2px; }
.sc span i { width: 7px; height: 7px; border-radius: 2px; background: var(--c); flex: none; }
.sc[aria-pressed="true"] { border-color: var(--red); background: var(--red-tint); }
.sc[aria-pressed="true"] span { color: var(--red); }

.fields { padding: 14px 16px 16px; display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.field.full { grid-column: 1 / -1; }
.field label { font: 500 10px/1.2 var(--mono); letter-spacing: 0.12em; text-transform: uppercase; color: var(--fg-muted); }
.inp {
  display: flex; align-items: stretch; border: 1px solid var(--border); border-radius: 9px; background: var(--surface-2);
  transition: border-color 0.2s, box-shadow 0.2s;
}
.inp:focus-within { border-color: var(--teal); box-shadow: 0 0 0 3px color-mix(in srgb, var(--teal) 16%, transparent); }
.inp input, .inp select {
  flex: 1; min-width: 0; border: 0; background: transparent; outline: none;
  padding: 7px 9px; font: 500 13.5px/1.3 var(--mono); color: var(--fg-strong);
}
.inp select { cursor: pointer; font-family: var(--sans); font-size: 13px; padding-right: 4px; text-overflow: ellipsis; }
.inp select option { background: var(--surface); color: var(--fg); }
.inp .u { display: flex; align-items: center; padding: 0 9px; font: 400 11px/1 var(--mono); color: var(--fg-muted); border-left: 1px solid var(--border); white-space: nowrap; }
.hint { margin: 2px 0 0; font-size: 11.5px; line-height: 1.45; color: var(--fg-muted); }
.hint b { color: var(--fg); font-weight: 600; }
.hint button { border: 0; background: none; padding: 0; color: var(--red); cursor: pointer; font-size: inherit; text-decoration: underline; text-underline-offset: 2px; }

.kpis { display: grid; grid-template-columns: 1fr 1fr; gap: 1px; background: var(--border); border-radius: 0 0 var(--radius) var(--radius); overflow: hidden; }
.kpi { background: var(--surface); padding: 11px 14px; min-width: 0; }
.kpi .k { font: 500 9.5px/1.3 var(--mono); letter-spacing: 0.14em; text-transform: uppercase; color: var(--fg-muted); white-space: nowrap; }
.kpi .k sub { letter-spacing: 0; }
.kpi .v { margin-top: 3px; font: 500 18px/1.2 var(--mono); color: var(--fg-strong); font-variant-numeric: tabular-nums; white-space: nowrap; }
.kpi .v small { font-size: 11px; color: var(--fg-muted); margin-left: 3px; }
.kpi .s { font-size: 11.5px; color: var(--fg-muted); margin-top: 2px; }
.verdict { padding: 13px 16px; display: flex; gap: 12px; border-bottom: 1px solid var(--border); }
.verdict .bar { width: 3px; border-radius: 2px; background: var(--border-strong); flex: none; transition: background 0.3s; }
.verdict strong { display: block; font-size: 15px; color: var(--fg-strong); line-height: 1.3; }
.verdict .v-sub { display: block; font: 400 11px/1.4 var(--mono); color: var(--fg-muted); margin-top: 1px; }
.verdict .v-sub:empty { display: none; }
.verdict p { margin: 5px 0 0; font-size: 12.5px; color: var(--fg-muted); line-height: 1.5; }
.verdict p b { color: var(--fg); font-weight: 600; }
.confianza { display: inline-block; font: 600 10px/1 var(--mono); letter-spacing: 0.06em; text-transform: uppercase; padding: 3px 6px; border-radius: 5px; vertical-align: 1px; }
.confianza.alta { color: var(--ok); background: var(--ok-tint); }
.confianza.media { color: var(--ochre); background: var(--ochre-tint); }
.confianza.baja { color: var(--red); background: var(--red-tint); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 8px 13px; border-radius: 9px; border: 1px solid var(--border); background: var(--surface);
  font: 500 12.5px/1.2 var(--sans); color: var(--fg); cursor: pointer; white-space: nowrap;
  transition: border-color 0.2s, background 0.2s, color 0.2s, transform 0.08s;
}
.btn:hover:not(:disabled) { border-color: var(--border-strong); }
.btn:active:not(:disabled) { transform: translateY(1px) scale(0.97); }
.btn:disabled { opacity: 0.45; cursor: default; }
.btn.primary { background: var(--fg-strong); color: var(--bg); border-color: transparent; }
.btn.primary:hover:not(:disabled) { opacity: 0.9; }
.btn.ghost { background: transparent; }
.btn.ocupado { opacity: 0.6; pointer-events: none; }
.btn svg { width: 14px; height: 14px; flex: none; }
.pin-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* ---------------------------------------------------------------- resultados */
.section-head {
  max-width: 1720px; margin: 0 auto; padding: 34px var(--gutter) 14px;
  display: flex; align-items: end; justify-content: space-between; gap: 20px; flex-wrap: wrap;
}
.section-head h2 { margin: 6px 0 0; font-size: clamp(22px, 2.2vw, 30px); letter-spacing: -0.025em; font-weight: 600; color: var(--fg-strong); line-height: 1.1; }
.section-head p { margin: 6px 0 0; color: var(--fg-muted); max-width: 760px; }
.grid {
  max-width: 1720px; margin: 0 auto; padding: 0 var(--gutter);
  display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 16px; align-items: start;
}
.span-5 { grid-column: span 5; } .span-7 { grid-column: span 7; } .span-12 { grid-column: span 12; }
.legend-row { display: flex; flex-wrap: wrap; gap: 6px 14px; padding: 0 16px 12px; font: 400 11.5px/1.3 var(--sans); color: var(--fg-muted); }
.legend-row i { display: inline-block; width: 14px; height: 3px; border-radius: 2px; vertical-align: middle; margin-right: 6px; background: var(--red); }
.legend-row i.dash { background: repeating-linear-gradient(90deg, var(--teal) 0 4px, transparent 4px 7px); height: 2px; }

/* perfil de velocidad */
.perfil { position: relative; }
.perfil svg { display: block; width: 100%; height: auto; max-height: 380px; }
.perfil text { font: 400 10.5px var(--mono); fill: var(--fg-muted); }
.perfil .rejilla { stroke: var(--border); stroke-width: 1; }
.perfil .eje { stroke: var(--border-strong); stroke-width: 1; }
.perfil .ref { stroke: var(--teal); stroke-width: 1.2; stroke-dasharray: 4 4; }
.perfil .area { fill: var(--red); fill-opacity: 0.08; }
.perfil .linea { fill: none; stroke: var(--red); stroke-width: 2.2; stroke-linejoin: round; }
.perfil .nivel { fill: var(--surface); stroke: var(--red); stroke-width: 1.6; }
.perfil .etq-final { fill: var(--fg-strong); font-weight: 600; font-size: 11.5px; }
.perfil .cursor-h { stroke: var(--fg-strong); stroke-width: 1; stroke-dasharray: 2 3; }
.perfil .tip {
  position: absolute; pointer-events: none; z-index: 2; padding: 6px 8px; border-radius: 7px;
  background: var(--fg-strong); color: var(--bg); font: 500 11px/1.45 var(--mono); white-space: nowrap;
}
.perfil .tip b { font-weight: 600; }

/* tabla por nivel */
.tabla-scroll { overflow: auto; max-height: 440px; border-radius: 0 0 var(--radius) var(--radius); }
table.checks { width: 100%; border-collapse: collapse; font-size: 13px; }
table.checks th { position: sticky; top: 0; z-index: 1; text-align: left; font: 500 10px/1.3 var(--mono); letter-spacing: 0.12em; text-transform: uppercase; color: var(--fg-muted); padding: 8px 16px; border-bottom: 1px solid var(--border); background: var(--surface-2); white-space: nowrap; }
table.checks th sub { letter-spacing: 0; }
table.checks td { padding: 7px 16px; border-bottom: 1px solid var(--border); white-space: nowrap; }
table.checks tr:last-child td { border-bottom: 0; }
table.checks .n { text-align: right; font-family: var(--mono); font-variant-numeric: tabular-nums; }
table.checks td.fuerte { color: var(--fg-strong); font-weight: 600; }
table.checks td.neg { color: var(--teal); }
table.checks tr.bajo-10 td { background: color-mix(in srgb, var(--bg-alt) 60%, transparent); color: var(--fg-muted); }
table.checks tbody tr:hover td { background: var(--bg-alt); }

/* ---------------------------------------------------------------- explicaciones */
.reading { max-width: 1720px; margin: 0 auto; padding: 0 var(--gutter); display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.essay { padding: 22px 24px 24px; min-width: 0; }
.essay .num { font: 500 11px/1 var(--mono); color: var(--red); letter-spacing: 0.14em; }
.essay h3 { margin: 10px 0 10px; font-size: 21px; line-height: 1.2; letter-spacing: -0.02em; font-weight: 600; color: var(--fg-strong); }
.essay p { margin: 0 0 10px; color: var(--fg); font-size: 14.5px; line-height: 1.62; }
.essay p.muted { color: var(--fg-muted); font-size: 13.5px; }
.essay .live { font-family: var(--mono); font-size: 12.8px; background: var(--bg-alt); border-radius: 6px; padding: 1px 6px; color: var(--fg-strong); white-space: nowrap; }
.essay .eq { margin: 10px 0; padding: 10px 14px; border-left: 2px solid var(--teal); background: var(--teal-tint); border-radius: 0 9px 9px 0; font: 500 13.5px/1.6 var(--mono); color: var(--fg-strong); overflow-x: auto; }
.essay .eq small { display: block; font: 400 11px/1.4 var(--mono); color: var(--fg-muted); margin-top: 2px; }
.essay ul { margin: 0 0 12px; padding-left: 18px; }
.essay li { margin: 5px 0; font-size: 14px; line-height: 1.55; }
.essay li b { color: var(--fg-strong); }

.refs { max-width: 1720px; margin: 0 auto; padding: 0 var(--gutter); }
.refs ol { margin: 0; padding: 16px 20px 6px 40px; columns: 2; column-gap: 42px; }
.refs li { break-inside: avoid; margin: 0 0 9px; font-size: 13px; line-height: 1.5; color: var(--fg); }
.refs li em { color: var(--fg-strong); }
.refs li .tag { font: 500 10px/1 var(--mono); color: var(--red); margin-left: 6px; letter-spacing: 0.08em; }
.refs .descargas { margin: 0; padding: 10px 20px 16px; border-top: 1px solid var(--border); font-size: 12.5px; color: var(--fg-muted); }
.refs .descargas a { color: var(--teal); text-underline-offset: 2px; }

footer.foot {
  max-width: 1720px; margin: 40px auto 0; padding: 22px var(--gutter) 36px; border-top: 1px solid var(--border);
  display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; color: var(--fg-muted); font-size: 12.5px;
}
footer.foot strong { color: var(--fg-strong); font-weight: 600; }
footer.foot a { color: var(--red); text-underline-offset: 2px; }
footer.foot .legal { flex-basis: 100%; font-size: 11.5px; line-height: 1.5; }

.aviso {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 3000;
  background: var(--fg-strong); color: var(--bg); font-size: 13px; font-weight: 500;
  padding: 10px 16px; border-radius: 999px; box-shadow: var(--shadow-md);
}
.solo-impresion { display: none; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ---------------------------------------------------------------- adaptación */
@media (max-width: 1280px) {
  .workspace { grid-template-columns: minmax(0, 1fr) 340px; }
  .sc { padding: 7px 8px 8px; }
}
@media (max-width: 1060px) {
  .workspace { grid-template-columns: 1fr; }
  .stage-wrap { position: relative; top: 0; }
  .stage { height: 68vh; min-height: 460px; }
  .reading { grid-template-columns: minmax(0, 1fr); }
  .refs ol { columns: 1; }
  .intro { grid-template-columns: 1fr; }
  .norms { justify-content: flex-start; }
  .sc-list { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .panel { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; }
  .panel > .card:first-child { grid-column: 1 / -1; }
}
@media (max-width: 860px) {
  .span-5, .span-7 { grid-column: span 12; }
}
@media (max-width: 760px) {
  .panel { display: flex; align-items: stretch; }
  .sc-list { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .hud-state { display: none; }
}
@media (max-width: 640px) {
  .topbar .title, .topbar .divider { display: none; }
  .topbar { padding: 0 12px; gap: 10px; }
  .brand .word { font-size: 18px; }
  .brand svg { height: 22px; }
  .icon-btn { width: 32px; height: 32px; flex: none; }
  .seg button { padding: 5px 9px; font-size: 11px; }
  .essay { padding: 18px 16px 20px; }
  .essay h3 { font-size: 19px; }
  .card .body { padding: 12px; }
  .stage { height: 72vh; min-height: 440px; }
  .hud-read { top: 10px; left: 10px; right: 10px; grid-template-columns: auto auto minmax(0, 1fr); gap: 4px 14px; padding: 8px 10px; }
  .hud-read .v { font-size: 15px; }
  .hud-read .v.txt { font-size: 12.5px; line-height: 1.5; }
  .hud-zoom { right: 10px; }
  .hud-views { left: 10px; bottom: 132px; }
  .hud-cams { left: 10px; right: auto; bottom: 84px; }
  .timeline { left: 10px; right: 10px; bottom: 10px; gap: 12px; }
  .stage .leaflet-bottom.leaflet-right { bottom: 176px; }
  .escala-nota { display: none; }
  .sc-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .section-head .pin-actions { width: 100%; }
  table.checks th, table.checks td { padding-left: 12px; padding-right: 12px; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

/* ---------------------------------------------------------------- impresión: memoria de cálculo */
@media print {
  @page { margin: 16mm 14mm; }
  :root, :root[data-theme="dark"] {
    color-scheme: light; --bg: #fff; --bg-alt: #f4f4f4; --surface: #fff; --surface-2: #fafafa; --border: #ccc; --border-strong: #999;
    --fg: #111; --fg-muted: #555; --fg-strong: #000; --red: #c0392b; --red-tint: #fbeaea; --teal: #244c5b; --teal-tint: #eef3f5;
  }
  body { background: #fff; font-size: 11pt; }
  .topbar, .intro, .workspace, .reading, .refs, .foot, .aviso, .section-head, .legend-row { display: none !important; }
  .solo-impresion { display: block; margin-bottom: 12px; }
  .grid { display: block; padding: 0; }
  .card { box-shadow: none; border: 1px solid #ccc; break-inside: avoid; margin-bottom: 10px; }
  .tabla-scroll { max-height: none; overflow: visible; }
  table.checks th { position: static; }
  table.checks { font-size: 9.5pt; }
  table.checks th, table.checks td { padding: 4px 8px; }
  .perfil { max-width: 150mm; }
  .imp-titulo { font-size: 17pt; font-weight: 600; letter-spacing: -0.02em; }
  .imp-sub { color: #555; margin-top: 2px; }
  .imp-datos { display: grid; grid-template-columns: repeat(2, 1fr); gap: 4px 24px; margin-top: 12px; font-size: 10.5pt; }
  .imp-datos b { font-weight: 600; }
  .imp-nota { margin-top: 10px; font-size: 9pt; color: #555; }
}
