/* Taller PRC Coronel. Pantalla de trabajo de tres columnas (alternativa | mapa | resultados).
   Criterios (taste-skill, pantallas de aplicación): el color va en los datos y no en el cromo; superficies planas
   separadas por una línea de 1 px; rótulos en minúscula y legibles en proyector (texto ≥ 15 px, rótulos ≥ 13 px);
   un solo primario casi negro; el mapa manda. Grilla: 300 + mapa + 320 sobre 1440 px; 280 + mapa + 300 desde
   1000 px; bajo 1000 px se apila con el mapa primero. */
:root {
  --suelo: #f3f4f3;          /* fondo de la ventana */
  --hoja: #ffffff;           /* superficies */
  --hoja-2: #f6f7f6;         /* superficie un paso más oscura */
  --activo: #e9ebea;         /* herramienta y fila elegidas */
  --tinta: #121614;
  --tenue: #545c58;          /* 6,6:1 sobre blanco */
  --linea: #e3e6e4;
  --control: #c9cecb;
  --primario: #1c201e;       /* botón principal casi negro */
  --primario-tinta: #ffffff;
  --acento: #0b6a5d;         /* verde mar: el dato principal (líneas nuevas, cambios propios) */
  --zt: #b4530a;             /* zonas de transporte (ESTRAUS): ocre, distinto de la tinta de las zonas censales y de las familias PRC */
  --acento-suave: #e3f1ee;
  --gana: #0b6a5d;
  --pierde: #a94716;
  --alerta: #b8322f;
  --alerta-suave: #fbe9e7;
  --sombra-flota: 0 2px 10px rgba(18, 22, 20, .12);
  --f-ui: "Archivo", "Helvetica Neue", Arial, sans-serif;
  --r: 6px;
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 24px;
  --t-xs: 12.5px; --t-s: 13.5px; --t-m: 15px; --t-l: 18px; --t-xl: 24px;
  --c-editor: 300px; --c-res: 320px;
  --filtro-teselas: grayscale(1) contrast(.85) brightness(1.06);
  --halo: #ffffff;           /* contorno de las líneas del mapa */
  --red-nueva: #c2277a; --red-base: #7a837e;       /* tramos sin flujo */
  /* datos del mapa: se definen una sola vez y los usan el mapa, la leyenda y los reportes (taller/informes.py) */
  --subidas: #16894a;        /* verde: subidas por paradero */
  --bajadas: #d42f2f;        /* rojo: bajadas por paradero */
  --tp-bus: #b4541d; --tp-txc: #8a7a00; --tp-biot: #1f6aa5;
  --vc-0: #2a6fbb; --vc-1: #12a08a; --vc-2: #e0a100; --vc-3: #e0531b; --vc-4: #a3102f;   /* saturación 0 | 0,5 | 0,75 | 1 | 1,3 */
  /* aliases usados por el código del mapa */
  --papel: var(--suelo);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --suelo: #0c0e0d; --hoja: #141716; --hoja-2: #1b1f1d; --activo: #262b29; --tinta: #eef2f0; --tenue: #a9b2ae;
    --linea: #29302d; --control: #424a46; --primario: #eef2f0; --primario-tinta: #0c0e0d;
    --acento: #4cc2ad; --acento-suave: #12302b; --gana: #4cc2ad; --pierde: #e99464; --alerta: #f17b72; --alerta-suave: #3a1d1b; --zt: #f0b35a;
    --sombra-flota: 0 2px 12px rgba(0, 0, 0, .5);
    --filtro-teselas: invert(1) hue-rotate(180deg) grayscale(1) brightness(.75) contrast(.9);
    --halo: #000000; --red-nueva: #f07ab8; --red-base: #8d9692;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --suelo: #0c0e0d; --hoja: #141716; --hoja-2: #1b1f1d; --activo: #262b29; --tinta: #eef2f0; --tenue: #a9b2ae;
  --linea: #29302d; --control: #424a46; --primario: #eef2f0; --primario-tinta: #0c0e0d;
  --acento: #4cc2ad; --acento-suave: #12302b; --gana: #4cc2ad; --pierde: #e99464; --alerta: #f17b72; --alerta-suave: #3a1d1b; --zt: #f0b35a;
  --sombra-flota: 0 2px 12px rgba(0, 0, 0, .5);
  --filtro-teselas: invert(1) hue-rotate(180deg) grayscale(1) brightness(.75) contrast(.9);
  --halo: #000000; --red-nueva: #f07ab8; --red-base: #8d9692;
  color-scheme: dark;
}

html, body { height: 100%; }
[hidden] { display: none !important; }
body {
  margin: 0; background: var(--suelo); color: var(--tinta); font: 400 var(--t-m)/1.5 var(--f-ui);
  display: flex; flex-direction: column; overflow: hidden;
}
* { box-sizing: border-box; }
h1, h2, h3 { margin: 0; text-wrap: balance; }
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--acento); outline-offset: 2px; }

/* rótulo pequeño sobre un campo o un valor: minúscula, gris legible */
.etq { display: block; font-size: var(--t-xs); font-weight: 600; color: var(--tenue); letter-spacing: 0; }
.ayuda { margin: 0; color: var(--tenue); font-size: var(--t-s); max-width: 62ch; }

/* ---------- barra superior ---------- */
.barra {
  display: flex; align-items: center; gap: var(--s5); flex-wrap: wrap;
  padding: var(--s2) var(--s4); padding-top: calc(var(--s2) + env(safe-area-inset-top, 0px));
  background: var(--hoja); border-bottom: 1px solid var(--linea);
}
.marca { display: flex; align-items: center; gap: var(--s3); min-width: 0; }
.marca-sello { display: block; width: 36px; height: 36px; flex: none; color: var(--tinta); }
.marca h1 { font-size: var(--t-l); font-weight: 700; letter-spacing: -.01em; }
.marca-sub { margin: 0; font-size: var(--t-s); color: var(--tenue); }
.marca-sub a { color: inherit; text-decoration: underline; text-underline-offset: 2px; }
.marca-sub a:hover { color: var(--tinta); }
.barra-escenario { display: flex; align-items: center; gap: var(--s2); margin-left: auto; min-width: 0; }
.barra-escenario .etq { white-space: nowrap; }
.barra-escenario select { max-width: 360px; }
.barra-estado { font-size: var(--t-s); color: var(--tenue); }

/* ---------- mesa ---------- */
.taller { flex: 1; min-height: 0; display: grid; grid-template-columns: var(--c-editor) minmax(0, 1fr) var(--c-res); }
.panel { min-height: 0; overflow-y: auto; background: var(--hoja); display: flex; flex-direction: column; }
.editor { border-right: 1px solid var(--linea); }
.resultados { border-left: 1px solid var(--linea); }
.panel-cab { padding: var(--s4); display: flex; flex-direction: column; gap: var(--s2); border-bottom: 1px solid var(--linea); }
.bloque { padding: var(--s4); display: flex; flex-direction: column; gap: var(--s3); border-bottom: 1px solid var(--linea); }
.bloque h2, .bloque h3 { font-size: 16px; font-weight: 650; }

.titulo-input {
  width: 100%; border: 0; border-bottom: 1px dashed var(--control); background: transparent; padding: 2px 0;
  font-size: var(--t-xl); font-weight: 650; letter-spacing: -.01em;
}
.titulo-input:focus { border-bottom-color: var(--acento); outline: none; }

.campo { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.campo input, .campo select, .barra select {
  width: 100%; min-width: 0; height: 36px; padding: 0 10px; border: 1px solid var(--control); border-radius: var(--r);
  background: var(--hoja); font-variant-numeric: tabular-nums;
}
.campo input::placeholder { color: var(--tenue); opacity: .85; }
.fila-campos { display: flex; gap: var(--s3); flex-wrap: wrap; }
.fila-campos .campo { flex: 1 1 120px; }
.rejilla-4, .rejilla-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s2) var(--s3); }
.campo.ancho, .campo.dos { grid-column: 1 / -1; }

.form-cambio {
  display: flex; flex-direction: column; gap: var(--s3); padding: var(--s3); border-radius: var(--r); background: var(--hoja-2);
}
.norma-vigente { margin: 0; font-size: var(--t-s); color: var(--tenue); font-variant-numeric: tabular-nums; }
.norma-vigente b { color: var(--tinta); font-weight: 600; }
.chk, .capas-chk label { display: inline-flex; align-items: center; gap: 8px; font-size: var(--t-s); cursor: pointer; min-height: 28px; }
input[type="checkbox"], input[type="radio"] { accent-color: var(--tinta); width: 16px; height: 16px; }

.acciones { display: flex; gap: var(--s2); justify-content: flex-end; flex-wrap: wrap; }
.btn {
  height: 36px; border: 1px solid var(--control); background: var(--hoja); border-radius: var(--r); padding: 0 14px;
  font-weight: 600; font-size: var(--t-s); cursor: pointer;
}
.btn:hover { border-color: var(--tinta); }
.btn:active { transform: translateY(1px); }
.btn.prim { background: var(--primario); border-color: var(--primario); color: var(--primario-tinta); padding: 0 18px; }
.btn.prim:hover { opacity: .88; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.btn.sec { background: transparent; }

.lista-cambios { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.lista-cambios:empty { display: none; }
.lista-cambios li {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: start; gap: var(--s2);
  padding: 8px 8px 8px 12px; background: var(--acento-suave); border-radius: var(--r); font-size: var(--t-s);
}
.lista-cambios li b { font-weight: 650; }
.quitar { border: 0; background: transparent; cursor: pointer; color: var(--tenue); font-size: 20px; line-height: 1; padding: 0 6px; min-width: 28px; }
.quitar:hover { color: var(--alerta); }

.acciones.izq { justify-content: flex-start; }
.descargas { display: flex; gap: var(--s2); flex-wrap: wrap; }
.descargas:empty { display: none; }
.descargas a { display: inline-flex; align-items: center; text-decoration: none; color: var(--tinta); }
.informe-lista { max-height: 260px; overflow-y: auto; }
.pie-pagina .version { white-space: nowrap; }
.pie-pagina .aviso-version { color: var(--acento); font-weight: 600; white-space: nowrap; }
.pie-pagina {
  padding: 5px var(--s4); padding-bottom: calc(5px + env(safe-area-inset-bottom, 0px)); background: var(--hoja); border-top: 1px solid var(--linea);
  color: var(--tenue); font-size: var(--t-xs); text-align: center;
}
.pie-editor {
  position: sticky; bottom: 0; margin-top: auto; padding: var(--s3) var(--s4);
  padding-bottom: calc(var(--s3) + env(safe-area-inset-bottom, 0px));
  background: var(--hoja); border-top: 1px solid var(--linea); display: flex; flex-direction: column; gap: var(--s2);
}
.estado-trabajo { margin: 0; font-size: var(--t-s); color: var(--tenue); min-height: 1.2em; }
.estado-trabajo.error { color: var(--alerta); }

/* ---------- mapa ---------- */
.mapa-wrap { position: relative; min-width: 0; min-height: 0; }
#mapa { position: absolute; inset: 0; background: var(--suelo); }
.leaflet-container { font: inherit; background: var(--suelo); }
.leaflet-tile-pane { filter: var(--filtro-teselas); }
.leaflet-tooltip {
  background: var(--hoja); color: var(--tinta); border: 1px solid var(--linea); box-shadow: var(--sombra-flota);
  font-size: var(--t-s); padding: 4px 8px; border-radius: var(--r);
}
.leaflet-tooltip-top:before { border-top-color: var(--linea); }
.leaflet-control-attribution { background: color-mix(in srgb, var(--hoja) 85%, transparent) !important; color: var(--tenue); }
.leaflet-control-attribution a { color: var(--tenue); }
.leaflet-bar a { background: var(--hoja); color: var(--tinta); border-bottom-color: var(--linea); }

/* menú «Editar red»: se oculta con su propio botón, sin cambiar la herramienta activa */
.mapa-herr {
  position: absolute; z-index: 800; top: var(--s3); left: var(--s3); display: flex; flex-wrap: wrap; gap: var(--s2);
  max-width: calc(100% - 24px - 124px);
}
.herr-grupo {
  display: flex; flex-wrap: wrap; align-items: center; gap: 2px; padding: 3px 3px 3px 10px;
  background: var(--hoja); border: 1px solid var(--linea); border-radius: 8px; box-shadow: var(--sombra-flota);
}
.herr-titulo { font-size: var(--t-xs); font-weight: 600; color: var(--tinta); margin-right: 6px; white-space: nowrap; }
.herr-grupo button {
  border: 0; border-radius: var(--r); background: transparent; height: 32px; padding: 0 11px; cursor: pointer;
  font-size: var(--t-s); font-weight: 600; color: var(--tenue); white-space: nowrap;
}
.herr-grupo button:hover { color: var(--tinta); }
.herr-grupo button.activo { background: var(--activo); color: var(--tinta); }
.btn-editar { box-shadow: var(--sombra-flota); }
.menu-dc {
  position: absolute; z-index: 830; display: flex; flex-direction: column; min-width: 190px; padding: 4px; background: var(--hoja);
  border: 1px solid var(--linea); border-radius: 8px; box-shadow: var(--sombra-flota);
}
.menu-dc-tit { margin: 0; padding: 4px 8px; font-size: var(--t-xs); color: var(--tenue); }
.menu-dc button { border: 0; background: transparent; color: var(--tinta); text-align: left; min-height: 32px; padding: 0 8px; border-radius: var(--r); cursor: pointer; font-size: var(--t-s); font-weight: 600; }
.menu-dc button:hover, .menu-dc button:focus-visible { background: var(--activo); }
.bloque.destacado { outline: 2px solid var(--acento); outline-offset: -2px; }
.ley-muestra { display: inline-block; width: 12px; height: 12px; border-radius: 2px; flex: none; }
.btn-capas { position: absolute; z-index: 810; top: var(--s3); right: var(--s3); box-shadow: var(--sombra-flota); }
.mapa-capas {
  position: absolute; z-index: 800; top: 56px; right: var(--s3); width: 250px; padding: var(--s3); max-height: calc(100% - 68px); overflow-y: auto;
  display: flex; flex-direction: column; gap: var(--s2); background: var(--hoja); border: 1px solid var(--linea);
  border-radius: 8px; box-shadow: var(--sombra-flota);
}
.capas-chk { display: flex; flex-direction: column; gap: 0; }
/* la leyenda flota abajo a la izquierda y nunca cubre las herramientas: tiene alto máximo y desplazamiento propio */
.mapa-leyenda {
  position: absolute; z-index: 800; left: var(--s3); bottom: var(--s5); padding: var(--s3); width: 264px;
  max-height: calc(100% - 136px); overflow-y: auto;   /* bajo las dos filas de herramientas */
  background: var(--hoja); border: 1px solid var(--linea); border-radius: 8px; box-shadow: var(--sombra-flota);
  display: flex; flex-direction: column; gap: var(--s2); font-size: var(--t-s);
}
.mapa-leyenda .etq { color: var(--tinta); font-size: var(--t-s); }
.ley-plegable summary { cursor: pointer; font-weight: 650; font-size: var(--t-s); list-style-position: inside; min-height: 24px; }
.ley-cuerpo { display: flex; flex-direction: column; gap: var(--s2); margin-top: var(--s2); }
.mapa-leyenda:has(details:not([open])) { width: auto; }
.ley-escala { display: grid; grid-template-columns: repeat(6, 1fr); gap: 0; }
.ley-escala span { height: 12px; }
.ley-marcas { display: grid; grid-template-columns: repeat(6, 1fr); font-size: var(--t-xs); color: var(--tenue); font-variant-numeric: tabular-nums; }
.ley-marcas span { text-align: left; overflow: hidden; white-space: nowrap; }
.ley-linea { display: flex; align-items: center; gap: var(--s2); color: var(--tenue); }
.ley-linea i { display: inline-block; width: 24px; height: 0; border-top: 4px solid; }
/* barras de intensidad: escala continua con marcas */
.ley-bloque { display: flex; flex-direction: column; gap: 3px; margin-top: 6px; }
.ley-barra { height: 12px; border-radius: 2px; }
.ley-rotulo { font-size: var(--t-xs); color: var(--tenue); }
.ley-ticks { position: relative; height: 16px; font-size: var(--t-xs); color: var(--tenue); font-variant-numeric: tabular-nums; }
.ley-ticks span { position: absolute; transform: translateX(-50%); white-space: nowrap; }
.ley-ticks span:first-child { transform: none; }
.ley-ticks span:last-child { transform: translateX(-100%); }
.ley-burbujas { display: flex; align-items: center; gap: var(--s3); flex-wrap: wrap; color: var(--tenue); }
.ley-burbuja { display: inline-flex; align-items: center; gap: 6px; }
.ley-burbuja i { display: inline-block; border-radius: 50%; opacity: .75; }
.ley-subidas { background: var(--subidas); }
.ley-bajadas { background: var(--bajadas); }
.mapa-aviso {
  position: absolute; z-index: 800; left: calc(50% + 72px); transform: translateX(-50%); bottom: var(--s5); padding: 10px 14px;  /* a la derecha de la leyenda */
  background: var(--tinta); color: var(--hoja); border-radius: var(--r); font-size: var(--t-s); box-shadow: var(--sombra-flota);
  max-width: min(440px, calc(100% - 24px)); pointer-events: none;  /* es solo un mensaje: no debe tapar el mapa */
}
.mapa-linea {
  position: absolute; z-index: 820; left: calc(50% + 72px); transform: translateX(-50%); bottom: calc(var(--s5) + 52px);
  display: flex; align-items: center; gap: var(--s2); padding: 6px 8px 6px 14px; background: var(--hoja);
  border: 1px solid var(--linea); border-radius: 8px; box-shadow: var(--sombra-flota); font-size: var(--t-s);
  font-variant-numeric: tabular-nums;
}
/* estado de carga: la pantalla conserva su marco y dice qué está pasando */
.cargando {
  position: absolute; inset: 0; z-index: 900; display: grid; place-items: center; background: var(--suelo);
  color: var(--tenue); font-size: var(--t-m);
}

/* ---------- resultados ---------- */
.res-titulo { font-size: var(--t-l); font-weight: 650; }
.res-sub { margin: 0; font-size: var(--t-s); color: var(--tenue); }
/* indicadores: un contenedor dividido por líneas, número par de celdas */
.kpis { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1px; background: var(--linea); border-bottom: 1px solid var(--linea); }
.kpi { background: var(--hoja); padding: var(--s3) var(--s4); display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.kpi .etq { font-weight: 500; }
.kpi-valor { font-size: var(--t-xl); font-weight: 600; font-variant-numeric: tabular-nums; line-height: 1.15; letter-spacing: -.01em; }
.kpi-nota { font-size: var(--t-xs); color: var(--tenue); }
.kpi-valor.pos { color: var(--gana); }
.kpi-valor.neg { color: var(--pierde); }
.alerta {
  margin: var(--s3) var(--s4) 0; padding: var(--s2) var(--s3); border-radius: var(--r); background: var(--alerta-suave);
  color: var(--tinta); font-size: var(--t-s);
}
.chip {
  display: inline-block; flex: none; white-space: nowrap; padding: 1px 8px; border-radius: 999px; font-size: var(--t-xs); font-weight: 600;
  background: var(--hoja-2); color: var(--tenue); font-variant-numeric: tabular-nums;
}
.chip.norma { background: var(--alerta-suave); color: var(--alerta); }
.chip.nueva { background: var(--acento-suave); color: var(--tinta); }
.cod { color: var(--tenue); font-size: var(--t-xs); white-space: nowrap; }

.barras { display: flex; flex-direction: column; gap: 4px; }
.barra-fila { display: grid; grid-template-columns: 118px minmax(0, 1fr) minmax(0, 1fr) 48px; align-items: center; gap: 6px; font-size: var(--t-s); font-variant-numeric: tabular-nums; cursor: pointer; min-height: 26px; }
.barra-fila:hover .bz { color: var(--tinta); }
.bz { color: var(--tenue); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bl { display: flex; justify-content: flex-end; }
.bl i, .br i { display: block; height: 12px; }
.bl i { background: var(--pierde); }
.br i { background: var(--gana); }
.bv { text-align: right; }
.barras-vacio { color: var(--tenue); font-size: var(--t-s); margin: 0; }

.tabla-wrap { overflow-x: auto; }
.tabla { width: 100%; border-collapse: collapse; font-size: var(--t-s); font-variant-numeric: tabular-nums; }
.tabla th { text-align: left; font-weight: 500; color: var(--tenue); font-size: var(--t-xs); }
.tabla th, .tabla td { padding: 6px 4px; border-bottom: 1px solid var(--linea); }
.tabla td.n, .tabla th.n { text-align: right; white-space: nowrap; }
.tabla tr.clic { cursor: pointer; }
.tabla tr.clic:hover td { background: var(--hoja-2); }
.pos { color: var(--gana); }
.neg { color: var(--pierde); }
/* modos de transporte público: la misma marca que en el mapa */
.chip.tp-bus { background: color-mix(in srgb, var(--tp-bus) 16%, var(--hoja)); color: var(--tinta); }
.chip.tp-txc { background: color-mix(in srgb, var(--tp-txc) 18%, var(--hoja)); color: var(--tinta); }
.chip.tp-biot { background: color-mix(in srgb, var(--tp-biot) 16%, var(--hoja)); color: var(--tinta); }
.det-lista { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 4px 12px; margin: 0; font-size: var(--t-s); font-variant-numeric: tabular-nums; }
.det-lista dt { color: var(--tenue); }
.det-lista dd { margin: 0; text-align: right; }
.det-lista.det-3 { grid-template-columns: minmax(0, 1fr) auto auto auto; }
.nota-regla { margin-top: var(--s2); font-style: italic; }
.barra-fila.sel .bz { color: var(--tinta); font-weight: 650; }
/* manzanas de una norma restringida */
.manz-norma { display: flex; flex-wrap: wrap; gap: 4px; min-height: 24px; align-items: center; }
.chip-manz { display: inline-flex; align-items: center; gap: 2px; padding: 1px 2px 1px 8px; border: 1px solid var(--linea); border-radius: 999px; font-size: var(--t-xs); font-variant-numeric: tabular-nums; background: var(--hoja-2); }
.chip-manz button { border: 0; background: transparent; color: var(--tenue); cursor: pointer; font-size: 14px; line-height: 1; padding: 0 4px; min-width: 24px; min-height: 22px; }
.chip-manz button:hover { color: var(--tinta); }
.btn.activo { background: var(--activo); }
#mapa.rect, #mapa.rect .leaflet-interactive { cursor: crosshair !important; }
/* etiqueta de zona censal sobre el mapa */
.leaflet-tooltip.etq-zc { background: transparent; border: 0; box-shadow: none; padding: 0; font-size: 11px; font-weight: 650; color: var(--tinta);
  text-shadow: 0 0 2px var(--hoja), 0 0 3px var(--hoja), 0 0 4px var(--hoja); }
.leaflet-tooltip.etq-zc::before { display: none; }
/* etiqueta de zona de transporte (ESTRAUS): número desde el zoom 13 y nombre desde el 14; va sobre las de zona censal sin taparlas */
.leaflet-tooltip.etq-zt { background: transparent; border: 0; box-shadow: none; padding: 0; font-size: 13px; font-weight: 750; color: var(--zt); text-align: center; line-height: 1.1;
  text-shadow: 0 0 2px var(--hoja), 0 0 3px var(--hoja), 0 0 5px var(--hoja); }
.leaflet-tooltip.etq-zt small { display: block; font-size: 9px; font-weight: 600; letter-spacing: .03em; text-transform: uppercase; }
.leaflet-tooltip.etq-zt::before { display: none; }
.det-lista .cab { font-size: var(--t-xs); color: var(--tenue); font-weight: 500; text-align: right; }
.det-prc { margin: 0; font-size: var(--t-s); color: var(--tenue); }

/* ---------- diálogo y aviso (flotan: llevan sombra) ---------- */
.dialogo { position: fixed; inset: 0; z-index: 2000; display: grid; place-items: center; background: rgba(10, 14, 12, .5); padding: var(--s4); }
.dialogo-caja {
  width: min(460px, 100%); max-height: calc(100vh - 32px); overflow-y: auto; background: var(--hoja); border-radius: 10px;
  padding: var(--s5); box-shadow: var(--sombra-flota); display: flex; flex-direction: column; gap: var(--s3);
}
.dialogo-caja h3 { font-size: var(--t-l); }
.aviso-flotante {
  position: fixed; z-index: 2100; left: 50%; transform: translateX(-50%); bottom: calc(var(--s5) + env(safe-area-inset-bottom, 0px));
  background: var(--tinta); color: var(--hoja); padding: 10px 16px; border-radius: var(--r); box-shadow: var(--sombra-flota); font-size: var(--t-s);
  max-width: calc(100% - 32px);
}

/* ---------- escritorio angosto (1281-1599 px): las seis herramientas de «Editar red» no caben junto al panel de capas;
   van en su propia fila, más compactas, y el panel de capas baja ---------- */
@media (min-width: 1281px) and (max-width: 1599px) {
  .mapa-herr { max-width: calc(100% - 24px); right: var(--s3); gap: 4px; }
  .herr-grupo { flex-basis: 100%; }
  .herr-grupo button { padding: 0 7px; font-size: var(--t-xs); }
  .herr-titulo { margin-right: 2px; }
  .mapa-capas { top: 106px; max-height: calc(100% - 118px); }
}

/* el subtítulo con autoría es largo: la marca crece y el texto se parte en dos líneas antes que la barra baje de fila */
.marca { flex: 1 1 360px; }

/* ---------- notebook (1000-1280 px): tres columnas más angostas; el mapa de Coronel es alto y angosto ---------- */
@media (max-width: 1280px) {
  :root { --c-editor: 280px; --c-res: 300px; --t-xl: 22px; }
  .barra { gap: var(--s4); }
  .marca-sub { display: none; }
  .marca { flex: 0 1 auto; }
  /* los dos botones en la primera fila, «Editar red» bajo ellos; leyenda plegada abajo a la izquierda */
  .mapa-herr { max-width: calc(100% - 24px); right: var(--s3); gap: 4px; }
  .herr-grupo { flex-basis: 100%; }
  .mapa-capas { top: 146px; right: var(--s3); width: 228px; max-height: calc(100% - 158px); }
  .mapa-leyenda { width: 240px; max-height: calc(100% - 136px); }
  /* cada grupo cabe en una fila: una herramienta en otra fila quedaría bajo la leyenda */
  .herr-grupo button { padding: 0 6px; font-size: var(--t-xs); }
  .herr-titulo { margin-right: 2px; }
  /* el aviso puede ocupar dos renglones: el panel de la línea en dibujo va sobre él */
  .mapa-linea { bottom: calc(var(--s5) + 76px); }
  .mapa-linea #linea-n { white-space: nowrap; }
  .mapa-aviso, .mapa-linea { left: calc(50% + 20px); }
}
/* ---------- tableta (bajo 1000 px): la página se desplaza; mapa arriba a 70 % de la altura ---------- */
@media (max-width: 999px) {
  body { overflow: auto; height: auto; }
  html { height: auto; }
  .taller { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto; }
  .mapa-wrap { order: -1; height: 70vh; min-height: 420px; border-bottom: 1px solid var(--linea); }
  .panel { overflow: visible; }
  .editor { border-right: 0; }
  .resultados { border-left: 0; border-top: 1px solid var(--linea); }
  .kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .pie-editor { position: sticky; }
  .pie-pagina { text-align: left; }
}
/* ---------- teléfono ---------- */
@media (max-width: 760px) {
  .mapa-wrap { display: flex; flex-direction: column; height: auto; min-height: 0; }
  #mapa { position: relative; inset: auto; height: 62vh; min-height: 360px; }
  .mapa-capas, .mapa-leyenda {
    position: static; width: auto; max-width: none; max-height: none; min-height: 0; box-shadow: none; border-radius: 0; border: 0; overflow: visible;
    border-top: 1px solid var(--linea); padding: var(--s3) var(--s4);
  }
  /* herramientas en dos filas, sin desplazamiento lateral */
  .mapa-herr { right: var(--s3); max-width: none; }
  .herr-grupo { width: 100%; padding-left: 8px; }
  .herr-titulo { width: 100%; margin: 2px 0 0; }
  .herr-grupo button { flex: 1 1 auto; height: 40px; }
  .btn-editar { width: 100%; }
  .mapa-aviso { bottom: auto; top: 196px; }
  .mapa-wrap > .btn-capas { position: static; display: block; width: 100%; border-radius: 0; box-shadow: none; border-width: 1px 0 0; height: 44px; }
  .mapa-linea { bottom: var(--s3); left: var(--s3); right: var(--s3); transform: none; flex-wrap: wrap; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .barra-escenario { margin-left: 0; width: 100%; }
  .barra-escenario select { max-width: none; }
  .pie-editor { position: static; }
  .barra-fila { grid-template-columns: 104px minmax(0, 1fr) minmax(0, 1fr) 44px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
.tabla tr.sel td { background: var(--activo); }

/* versión de consulta (Vercel): sin editor ni herramientas de edición */
body.estatico .panel.editor, body.estatico .mapa-herr, body.estatico #btn-abrir { display: none !important; }
body.estatico .taller { grid-template-columns: minmax(0, 1fr) var(--c-res); }
@media (max-width: 999px) { body.estatico .taller { grid-template-columns: minmax(0, 1fr); } }
.sub-bloque { font-size: var(--t-s); margin: var(--s3) 0 var(--s1); }

/* ---------- tutorial (visita guiada) ---------- */
.btn-tutorial.nuevo { border-color: var(--acento); color: var(--acento); box-shadow: 0 0 0 3px var(--acento-suave); }
.tutorial { position: fixed; inset: 0; z-index: 2200; }
.tutorial[hidden], .tut-foco[hidden] { display: none; }
.tut-velo { position: absolute; inset: 0; }
.tutorial.sin-foco .tut-velo { background: rgba(10, 14, 12, .45); }
.tut-foco {
  position: fixed; border: 2px solid var(--acento); border-radius: 8px; pointer-events: none;
  box-shadow: 0 0 0 9999px rgba(10, 14, 12, .45); transition: left .2s, top .2s, width .2s, height .2s;
}
.tut-caja {
  position: fixed; width: min(360px, calc(100vw - 16px)); padding: var(--s4); background: var(--hoja); color: var(--tinta);
  border: 1px solid var(--linea); border-radius: 10px; box-shadow: var(--sombra-flota); display: flex; flex-direction: column; gap: var(--s2);
}
.tut-caja h3 { margin: 0; font-size: var(--t-l); }
.tut-caja .etq { margin: 0; }
.tut-texto { margin: 0; font-size: var(--t-s); line-height: 1.5; }
.tut-lista { margin: 0; padding-left: 18px; font-size: var(--t-s); max-height: 180px; overflow-y: auto; }
.tut-lista[hidden] { display: none; }
.tut-caja .acciones { justify-content: flex-end; }
