/* =====================================================================
   ing.cmae · Gestor de obras · portal/css/portal-zona.css
   Módulo «zona-emergencia»: pantalla «Definir zona del frente» (#/zona/<F>)
   y ventana de EMERGENCIA. Va DESPUÉS de css/styles.css y css/portal.css y
   reutiliza su sistema de láminas (.cuadro, .cuadro-tit, .ficha-datos,
   .filas/.reg-a, .sello, .btn-gold, .btn-sec, .emerg, .btn-911,
   .btn-mantener). Sus clases propias empiezan por «zn-» (zona) y «emg-»
   (emergencia) para no chocar con nada.
   Reglas: Montserrat ≤ 700 + IBM Plex Mono; esquinas 4 px; dorado solo
   para la acción principal; objetivos ≥ 48 px (principales 56-64);
   alto contraste para el sol; movimiento reducido; cortes en «em» para
   que respondan también a la letra ampliada (130-200 %).
   ===================================================================== */

/* =====================================================================
   1. ZONA DEL FRENTE
   ===================================================================== */

/* ---------- Estado del GPS: barras de precisión · valor · ayuda ---------- */
.zn-gps { display: flex; align-items: center; flex-wrap: wrap; gap: .45rem .7rem; padding: .55rem .65rem; background: var(--cab); border-bottom: 1px solid var(--rejilla); }
.zn-gps-m { display: inline-flex; align-items: flex-end; gap: 3px; height: 22px; flex: none; }
.zn-gps-m i { display: block; width: 6px; border: 1px solid var(--navy); border-radius: 1px; background: transparent; }
.zn-gps-m i:nth-child(1) { height: 7px; } .zn-gps-m i:nth-child(2) { height: 12px; } .zn-gps-m i:nth-child(3) { height: 17px; } .zn-gps-m i:nth-child(4) { height: 22px; }
.zn-gps-m i.si { background: var(--navy); }
.zn-gps[data-calidad="buena"] .zn-gps-m i.si { background: var(--ok); border-color: var(--ok); }
.zn-gps[data-calidad="aceptable"] .zn-gps-m i.si { background: var(--reg); border-color: var(--reg); }
.zn-gps[data-calidad="mala"] .zn-gps-m i.si, .zn-gps[data-calidad="mal"] .zn-gps-m i.si { background: var(--alerta); border-color: var(--alerta); }
.zn-gps-t { display: flex; flex-direction: column; min-width: 0; flex: 1 1 12rem; line-height: 1.3; }
.zn-gps-t .k { font-family: var(--mono); font-size: .75rem; font-weight: 600; letter-spacing: .1em; text-transform: uppercase; color: var(--texto-2); }
.zn-gps-t .v { font-family: var(--mono); font-size: 1.05rem; font-weight: 600; color: var(--ink); font-variant-numeric: tabular-nums; }
.zn-gps-t .s { font-size: .8125rem; color: var(--ink); line-height: 1.35; }
.zn-gps[data-calidad="buena"] .v { color: var(--ok); }
.zn-gps[data-calidad="aceptable"] .v { color: var(--reg); }
.zn-gps[data-calidad="mala"] .v, .zn-gps[data-calidad="mal"] .v { color: var(--alerta); }
.zn-gps .zn-activar { flex: 1 1 100%; min-height: 56px; box-shadow: none; }
.zn-gps .zn-activar:hover { transform: none; }

/* ---------- Forma de marcar (selector segmentado, como Lista | Planta) ---------- */
.zn-modo { display: flex; flex-wrap: wrap; gap: 1px; background: var(--navy); border-top: 1px solid var(--navy); border-bottom: 1px solid var(--navy); }
.zn-modo button { flex: 1 1 9.5rem; display: flex; flex-direction: column; align-items: flex-start; justify-content: center; gap: .1rem; min-height: 56px; min-width: 0; padding: .4rem .65rem; border: 0; background: #fff; color: var(--navy); font-family: var(--sans); text-align: left; cursor: pointer; }
.zn-modo button b { font-size: .875rem; font-weight: 700; line-height: 1.25; }
.zn-modo button small { font-family: var(--mono); font-size: .75rem; color: var(--texto-2); line-height: 1.3; }
.zn-modo button[aria-pressed="true"] { background: var(--navy); color: #fff; }
.zn-modo button[aria-pressed="true"] small { color: #dbe6f0; }

/* ---------- Esquema del polígono (SVG) ---------- */
.zn-esquema { margin: 0; background: #fff; border-bottom: 1px solid var(--rejilla); }
.zn-esquema svg { display: block; width: 100%; height: auto; max-height: 46vh; max-height: 46dvh; }
.zn-esquema figcaption { padding: .4rem .65rem; font-family: var(--mono); font-size: .75rem; letter-spacing: .05em; line-height: 1.4; color: var(--texto-2); border-top: 1px dashed var(--rejilla); text-transform: uppercase; }
.zn-rej { stroke: rgba(10, 26, 43, .1); stroke-width: 1; }
.zn-pol { fill: none; stroke: var(--navy); stroke-width: 2.4; stroke-linejoin: round; stroke-linecap: round; }
.zn-pol--cerrado { fill: rgba(11, 116, 188, .08); }
.zn-cur { fill: none; stroke: var(--navy); stroke-width: 2; stroke-dasharray: 7 6; }
.zn-cierre { fill: none; stroke: rgba(10, 26, 43, .45); stroke-width: 1.5; stroke-dasharray: 2 6; stroke-linecap: round; }
.zn-tr { fill: none; stroke: var(--reg); stroke-width: 1.6; stroke-dasharray: 3 4; }
.zn-tr-p { fill: var(--reg); }
.zn-cota { font-family: var(--mono); font-size: 11px; font-weight: 600; letter-spacing: .04em; fill: var(--gold-ink); text-anchor: middle; paint-order: stroke; stroke: #fff; stroke-width: 3px; stroke-linejoin: round; }
.zn-v circle { fill: #fff; stroke: var(--navy); stroke-width: 2.5; }
.zn-v text, .zn-yo text, .zn-lejos text { font-family: var(--mono); font-size: 12px; font-weight: 600; fill: var(--navy); paint-order: stroke; stroke: #fff; stroke-width: 3px; stroke-linejoin: round; }
.zn-v--nuevo circle { fill: var(--gold); }
.zn-yo path { stroke: var(--alerta); stroke-width: 2.2; }
.zn-prec { fill: rgba(180, 35, 24, .07); stroke: var(--alerta); stroke-width: 1.2; stroke-dasharray: 3 3; }
.zn-yo--buena .zn-prec { fill: rgba(23, 102, 58, .07); stroke: var(--ok); }
.zn-yo--aceptable .zn-prec { fill: rgba(11, 116, 188, .07); stroke: var(--reg); }
.zn-lejos path { fill: var(--alerta); }
.zn-lejos text { text-anchor: middle; fill: var(--alerta); }
.zn-norte path { fill: var(--navy); }
.zn-norte text { font-family: var(--mono); font-size: 11px; font-weight: 600; fill: var(--navy); text-anchor: middle; }
.zn-escala path { fill: none; stroke: var(--navy); stroke-width: 1.4; }
.zn-escala text { font-family: var(--mono); font-size: 11px; fill: var(--navy); }
.zn-rot { font-family: var(--mono); font-size: 12px; letter-spacing: .1em; fill: var(--texto-2); text-anchor: middle; }
.zn-rot--s { font-size: 11px; letter-spacing: .04em; }
@media (prefers-reduced-motion: no-preference) {
  .js .zn-dibuja { stroke-dasharray: 900; stroke-dashoffset: 900; animation: zn-dibuja 1.1s .1s cubic-bezier(.6, .1, .2, 1) forwards; }
  .zn-v--nuevo circle { animation: zn-pulso .9s ease-out 2; transform-box: fill-box; transform-origin: center; }
  @keyframes zn-dibuja { to { stroke-dashoffset: 0; } }
  @keyframes zn-pulso { 0% { transform: scale(1); } 40% { transform: scale(1.5); } 100% { transform: scale(1); } }
}

/* ---------- Acciones (marcar · deshacer · enviar) ---------- */
/* La acción principal (marcar · recorrer) queda a la vista sobre el cajetín mientras se ve la zona */
.zn-fijo { position: sticky; bottom: calc(var(--cajetin-alto) + 8px); z-index: 4; padding: .55rem .65rem; background: #fff; border-top: 1px solid var(--rejilla); box-shadow: 0 -10px 16px -14px rgba(10, 26, 43, .55); }
.zn-fijo .btn-principal { min-height: 60px; font-size: 1.02rem; box-shadow: none; white-space: normal; line-height: 1.25; }
.zn-fijo .btn-principal[disabled] { opacity: 1; background: #efe3c7; color: #5d4a22; cursor: not-allowed; }
.zn-fijo .btn-principal:hover { transform: none; }
/* Teléfono horizontal: la franja sigue fija pero más baja */
@media (max-height: 30em) { .zn-fijo { padding: .35rem .65rem; } .zn-fijo .btn-principal { min-height: 52px; } }
.zn-acc { display: grid; gap: .55rem; padding: .65rem; }
.zn-fijo + .zn-acc { padding-top: 0; }
.zn-acc .btn-principal { min-height: 60px; font-size: 1.02rem; box-shadow: none; white-space: normal; line-height: 1.25; }
.zn-acc .btn-principal[disabled] { opacity: 1; background: #efe3c7; color: #5d4a22; cursor: not-allowed; }
.zn-acc-sec { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 10rem), 1fr)); gap: .5rem; }
.zn-acc-sec:empty { display: none; }
.zn-enviar { border-width: 2px; }
.zn-enviar[disabled] { border-style: dashed; color: var(--texto-2); border-color: rgba(10, 26, 43, .45); background: transparent; cursor: not-allowed; }
.zn-marcando { position: relative; overflow: hidden; }
html[data-contraste="alto"] .zn-fijo { border-top: 2px solid var(--ink); }
@media (prefers-reduced-motion: no-preference) {
  .zn-marcando::after { content: ""; position: absolute; left: 0; bottom: 0; height: 4px; width: 100%; background: var(--navy); transform-origin: left; animation: zn-barra 3s linear forwards; }
  @keyframes zn-barra { from { transform: scaleX(0); } to { transform: scaleX(1); } }
}
.zn-msg { font-size: .875rem; font-weight: 600; line-height: 1.4; color: var(--alerta); }
.zn-msg:empty { display: none; }
.zn-msg[data-tipo="ok"] { color: var(--ok); }
.zn-msg[data-tipo="aviso"] { color: var(--pend); }
.zn-rec-info { font-family: var(--mono); font-size: .8125rem; line-height: 1.4; color: var(--ink); }
.zn-link { justify-self: start; min-height: 48px; padding: 0 .1rem; background: none; border: 0; font-family: var(--mono); font-size: .75rem; letter-spacing: .06em; text-transform: uppercase; color: var(--texto-2); text-decoration: underline; cursor: pointer; text-align: left; }

/* Confirmación antes de enviar */
.zn-conf { display: grid; gap: .55rem; padding: .65rem; border: 1px solid var(--navy); border-left: 4px solid var(--gold); background: #fffaf0; }
.zn-conf p { font-size: .9rem; line-height: 1.45; color: var(--ink); }
.zn-conf p > b:first-child { display: block; margin-bottom: .2rem; font-family: var(--mono); font-size: .75rem; letter-spacing: .1em; text-transform: uppercase; color: var(--navy); }
.zn-conf .zn-b { color: var(--pend); }
.zn-conf--err { border-color: var(--alerta); border-left-color: var(--alerta); background: #fff8f7; }
.zn-conf--err p > b:first-child { color: var(--alerta); }
.zn-conf-acc { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 10rem), 1fr)); gap: .5rem; }
.zn-conf-si { background: var(--navy); color: #fff; border-color: var(--navy); min-height: 56px; }
.zn-conf-si:hover { background: #12304d; }

/* ---------- Propuesta enviada: ficha, verificación de hoy ---------- */
.zn-ficha > div { flex-basis: 8rem; }
.zn-ficha .v { display: flex; flex-wrap: wrap; gap: .3rem; }
.zn-verif { border-bottom: 1px solid var(--rejilla); }
.zn-verif:empty { display: none; }
.zn-verif-t { display: flex; flex-wrap: wrap; align-items: center; gap: .35rem .6rem; padding: .6rem .65rem; font-size: .875rem; line-height: 1.4; color: var(--ink); }
.zn-verif-t .k { flex-basis: 100%; font-family: var(--mono); font-size: .75rem; font-weight: 600; letter-spacing: .1em; text-transform: uppercase; color: var(--navy); }
.zn-verif-t > span:last-child { flex: 1 1 14rem; }

/* ---------- Vértices y pasos ---------- */
.zn-fila { min-height: 60px; }
.zn-fila--sig { background: var(--paper); }
.zn-fila--sig:hover { background: var(--paper); }
.zn-medidas > div { flex-basis: 6.6rem; }
.zn-pasos > summary { list-style: none; cursor: pointer; min-height: 48px; align-items: center; position: relative; padding-right: 2.2rem; }
.zn-pasos > summary::-webkit-details-marker { display: none; }
.zn-pasos > summary::after { content: "+"; position: absolute; right: .7rem; top: 50%; transform: translateY(-50%); font-size: 1.2rem; color: var(--gold); }
.zn-pasos[open] > summary::after { content: "−"; }
.zn-rev .zn-acc { border-top: 1px solid var(--rejilla); }
.zn-demo { border: 1px dashed var(--rejilla); }

/* Celda «Geocerca» de la lámina con la verificación (Gestor.zona.enlazarLamina) */
.i-zona [data-zona-verif][data-estado="dentro"] { color: var(--ok); font-weight: 600; }
.i-zona [data-zona-verif][data-estado="fuera"] { color: var(--alerta); font-weight: 600; }
.i-zona [data-zona-verif][data-estado="borde"] { color: var(--pend); font-weight: 600; }

/* Alto contraste (sol directo): misma paleta, más tinta */
html[data-contraste="alto"] .zn-gps, html[data-contraste="alto"] .zn-fila--sig { background: #fff; }
html[data-contraste="alto"] .zn-gps { border-bottom-width: 2px; }
html[data-contraste="alto"] .zn-gps-m i { border-width: 2px; width: 7px; }
html[data-contraste="alto"] .zn-modo { gap: 2px; border-width: 2px; }
html[data-contraste="alto"] .zn-rej { stroke: rgba(10, 26, 43, .16); }
html[data-contraste="alto"] .zn-pol { stroke-width: 3; }
html[data-contraste="alto"] .zn-cierre { stroke: var(--navy); }
html[data-contraste="alto"] .zn-cota { fill: var(--pend); }
html[data-contraste="alto"] .zn-v circle { stroke-width: 3; }
html[data-contraste="alto"] .zn-esquema figcaption { color: var(--ink); border-top-style: solid; }
html[data-contraste="alto"] .zn-conf { border-width: 2px; border-left-width: 5px; background: #fff; }
html[data-contraste="alto"] .zn-fijo .btn-principal[disabled], html[data-contraste="alto"] .zn-acc .btn-principal[disabled] { background: #fff; color: var(--ink); border: 2px dashed var(--ink); }
html[data-contraste="alto"] .zn-enviar[disabled] { color: var(--ink); border-color: var(--ink); }
html[data-contraste="alto"] .zn-link { color: var(--ink); }

/* =====================================================================
   2. EMERGENCIA (ventana #emergencia rehecha por emergencia.js)
      Teléfono: pantalla completa (sin distracciones, nada detrás).
      Tableta y computadora: panel centrado.
   ===================================================================== */
.gestor dialog.emerg.emg { width: 100%; max-width: none; height: 100%; height: 100dvh; max-height: none; margin: 0; padding: 0; border: 0; border-radius: 0; box-shadow: none; background: #fff; overflow: auto; overscroll-behavior: contain; }
.gestor dialog.emerg.emg::backdrop { background: rgba(6, 14, 24, .9); }
.emg-in { box-sizing: border-box; min-height: 100%; width: 100%; max-width: 34rem; margin: 0 auto; padding: max(14px, env(safe-area-inset-top)) max(14px, env(safe-area-inset-right)) max(18px, env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left)); display: grid; grid-template-columns: minmax(0, 1fr); gap: .65rem; align-content: start; border-top: 6px solid var(--alerta); }
.emg .emg-sheet { display: flex; flex-wrap: wrap; }
.emg .emg-sheet span { white-space: nowrap; }
.emg h2.emg-t { font-size: 1.6rem; line-height: 1.15; }
.emg .emg-911 { min-height: 72px; font-size: 1.3rem; letter-spacing: .01em; }
.emg .emg-911 svg { width: 28px; height: 28px; }
.emg .emg-911:active { background: #8f1c13; }

/* Ubicación para dictar al 911 */
.emg-ubic { display: grid; gap: .1rem; padding: .5rem .65rem; border: 1px solid var(--rejilla); border-left: 3px solid var(--navy); background: var(--paper); line-height: 1.3; }
.emg-ubic .k { font-family: var(--mono); font-size: .75rem; font-weight: 600; letter-spacing: .1em; text-transform: uppercase; color: var(--texto-2); }
.emg-ubic b { font-family: var(--mono); font-size: 1rem; font-weight: 600; color: var(--ink); font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.emg-ubic small { font-size: .8125rem; color: var(--ink); }
.emg-ubic[data-estado="ok"] { border-left-color: var(--ok); }
.emg-ubic[data-estado="mal"] { border-left-color: var(--alerta); }
.emg-ubic .emg-verubic { justify-self: start; margin-top: .35rem; min-height: 48px; }

/* Aviso a Gerencia */
.emg-aviso { gap: .6rem; }
.emg-aviso .emerg-aviso-t .sello { white-space: normal; text-align: right; }
.emg-ultimo { font-size: .875rem; line-height: 1.4; color: var(--ink); padding: .4rem .5rem; border: 1px dashed var(--rejilla); background: #fff; }
.emg-ultimo b { font-family: var(--mono); font-size: .75rem; letter-spacing: .1em; text-transform: uppercase; color: var(--navy); margin-right: .3rem; }
.emg-tipo { margin: 0; padding: 0; border: 0; min-width: 0; }
.emg-tipo legend { padding: 0; margin-bottom: .35rem; font-family: var(--mono); font-size: .75rem; font-weight: 600; letter-spacing: .1em; text-transform: uppercase; color: var(--navy); line-height: 1.35; }
.emg-tipo legend span { font-weight: 500; letter-spacing: .02em; text-transform: none; color: var(--texto-2); }
.emg-tipo-l { display: flex; flex-wrap: wrap; gap: 1px; background: rgba(10, 26, 43, .55); border: 1px solid rgba(10, 26, 43, .55); border-radius: var(--r); overflow: hidden; }
.emg-tipo-o { flex: 1 1 6.5rem; position: relative; display: flex; min-width: 0; }
.emg-tipo-o input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.emg-tipo-o span { flex: 1; display: flex; align-items: center; justify-content: center; min-height: 48px; padding: .3rem .5rem; background: #fff; color: var(--navy); font-size: .875rem; font-weight: 600; text-align: center; cursor: pointer; line-height: 1.2; }
.emg-tipo-o input:checked + span { background: var(--navy); color: #fff; }
.emg-tipo-o input:focus-visible + span { outline: 3px solid var(--gold); outline-offset: -3px; }
.emg .emg-mantener { min-height: 72px; font-size: 1.08rem; }
.emg .emg-mantener.emg-hecho { background: var(--paper); border-style: dashed; color: var(--ink); cursor: default; }
.emg-ayuda { font-size: .875rem; line-height: 1.4; color: var(--ink); }
.emg-ayuda:empty { display: none; }
.emg-ayuda[data-tipo="aviso"] { color: var(--alerta); font-weight: 600; }
.emg-saltar { justify-self: start; min-height: 48px; padding: 0 .1rem; background: none; border: 0; font-family: var(--mono); font-size: .75rem; letter-spacing: .06em; text-transform: uppercase; color: var(--navy); text-decoration: underline; cursor: pointer; }
.emg-res { display: grid; gap: .3rem; padding: .55rem .6rem; background: #fff; border: 1px solid var(--rejilla); border-left: 3px solid var(--alerta); }
.emg-res-t { font-size: 1rem; font-weight: 600; color: var(--ink); line-height: 1.35; }
.emg-res-t b { font-family: var(--mono); font-weight: 600; }
.emg-res-d { display: flex; flex-wrap: wrap; gap: .25rem .4rem; }
.emg-res-d span { font-family: var(--mono); font-size: .75rem; letter-spacing: .04em; padding: .15rem .4rem; border: 1px solid var(--rejilla); border-radius: 2px; color: var(--ink); }
.emg-res-u { font-family: var(--mono); font-size: .875rem; color: var(--ink); line-height: 1.4; overflow-wrap: anywhere; }
.emg-res-n { font-size: .875rem; line-height: 1.45; color: var(--ink); }
.emg-demo { padding: .5rem .6rem; border: 2px solid var(--navy); background: #fff; font-size: .875rem; line-height: 1.45; color: var(--ink); }
.emg-demo b { display: block; font-family: var(--mono); font-size: .75rem; letter-spacing: .12em; text-transform: uppercase; color: var(--navy); margin-bottom: .15rem; }
.emg-demo strong { color: var(--alerta); }

.emg .emg-ger { gap: .5rem; min-height: 60px; font-size: 1rem; border-width: 2px; }
.emg .emg-ger svg { width: 22px; height: 22px; flex: none; }
.emg-sms { display: flex; flex-direction: column; justify-content: center; min-height: 52px; padding: .35rem .7rem; border: 1px solid var(--navy); border-radius: var(--r); color: var(--navy); background: #fff; text-decoration: none; font-weight: 600; font-size: .95rem; line-height: 1.25; text-align: center; }
.emg-sms small { font-family: var(--mono); font-size: .75rem; font-weight: 500; color: var(--texto-2); letter-spacing: .02em; }
.emg .emg-cerrar { justify-self: center; min-width: min(12rem, 100%); max-width: 100%; white-space: normal; }

/* Tableta y computadora: panel centrado */
@media (min-width: 48em) and (min-height: 44em) {
  .gestor dialog.emerg.emg { width: min(480px, calc(100% - 48px)); height: -webkit-fit-content; height: fit-content; max-height: calc(100vh - 48px); max-height: calc(100dvh - 48px); margin: auto; border-radius: var(--r); box-shadow: 0 40px 80px rgba(0, 0, 0, .5); }
  .emg-in { min-height: 0; padding: 1rem 1rem 1.1rem; border-top-width: 5px; }
}
/* Teléfono horizontal: el 911 y las llamadas a la izquierda; el aviso a Gerencia a la derecha */
@media (min-width: 40em) and (max-height: 32em) {
  .emg-in { max-width: 62rem; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); column-gap: 1rem; grid-template-areas: "s a" "t a" "n a" "u a" "g a" "m a" "c a"; grid-template-rows: repeat(6, auto) 1fr; }
  .emg-in > .emg-sheet { grid-area: s; } .emg-in > .emg-t { grid-area: t; } .emg-in > .emg-911 { grid-area: n; } .emg-in > .emg-ubic { grid-area: u; }
  .emg-in > .emg-aviso { grid-area: a; align-self: start; } .emg-in > .emg-ger { grid-area: g; } .emg-in > .emg-sms { grid-area: m; } .emg-in > .emg-cerrar { grid-area: c; align-self: start; }
  .emg h2.emg-t { font-size: 1.35rem; }
  .emg .emg-911 { min-height: 64px; }
}
/* Letra muy grande: el rótulo se apila y los tipos ocupan el ancho */
@media (max-width: 22em) {
  .emg .emg-sheet span { white-space: normal; }
  .emg-tipo-o { flex-basis: 45%; }
}

/* Alto contraste */
html[data-contraste="alto"] .emg-ubic, html[data-contraste="alto"] .emg-res, html[data-contraste="alto"] .emg-ultimo { border-width: 2px; border-style: solid; background: #fff; }
html[data-contraste="alto"] .emg-ubic { border-left-width: 4px; }
html[data-contraste="alto"] .emg-res { border-left-width: 4px; }
html[data-contraste="alto"] .emg-tipo-l { gap: 2px; border-width: 2px; background: var(--ink); }
html[data-contraste="alto"] .emg-sms, html[data-contraste="alto"] .emg-saltar { border-width: 2px; color: var(--ink); }
html[data-contraste="alto"] .emg .emg-911 { box-shadow: inset 0 0 0 2px #fff; }
