/* Centro de Mando de Emergencias — RAU
   Contraste alto, botones grandes (mínimo 44 px), texto de 16 px o más y modo claro para usar a pleno sol.
   Sin fuentes externas: con señal mala cada kilobyte cuenta. */
:root {
	--fondo: #0b0f17; --tarjeta: #141b27; --borde: #2a3446; --texto: #eef2f7; --tenue: #9aa6b8;
	--primario: #38bdf8; --primario-t: #04131d; --ok: #4ade80; --aviso: #fbbf24; --peligro: #f87171; --apagado: #64748b;
	--radio: 12px; --mono: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
	color-scheme: dark;
}
:root[data-tema="sol"] {
	--fondo: #ffffff; --tarjeta: #f3f5f8; --borde: #9aa6b8; --texto: #05070a; --tenue: #374151;
	--primario: #0b5cad; --primario-t: #ffffff; --ok: #0f7a35; --aviso: #8a5a00; --peligro: #b3161b; --apagado: #4b5563;
	color-scheme: light;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--fondo); color: var(--texto); font: 16px/1.5 system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif; }
a { color: var(--primario); }
h1 { font-size: 1.5rem; margin: 0 0 .75rem; line-height: 1.2; }
h2 { font-size: 1.05rem; margin: 0 0 .75rem; letter-spacing: .01em; }
h3 { font-size: .95rem; margin: 1rem 0 .5rem; color: var(--tenue); }
p { margin: 0 0 .6rem; }
small { color: var(--tenue); }
.em-mono { font-family: var(--mono); }
.em-nw { white-space: nowrap; }
.em-rojo { color: var(--peligro) !important; }
.em-ambar { color: var(--aviso) !important; }
.em-verde { color: var(--ok) !important; }

/* Cabecera */
.em-cab { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: .75rem; padding: .55rem 1rem; padding-top: max(.55rem, env(safe-area-inset-top));
	background: var(--fondo); border-bottom: 1px solid var(--borde); }
.em-marca { flex-shrink: 0; display: grid; place-items: center; width: 2.6rem; height: 2.6rem; border-radius: 10px; background: var(--peligro); color: #fff; font-weight: 800; text-decoration: none; letter-spacing: .03em; }
.em-titulo { min-width: 0; flex: 1; display: flex; flex-direction: column; line-height: 1.25; }
.em-titulo strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.em-titulo span { font-size: .8rem; color: var(--tenue); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.em-reloj { display: flex; flex-direction: column; align-items: flex-end; font-family: var(--mono); line-height: 1.2; }
.em-reloj strong { font-size: 1.15rem; }
.em-reloj span { font-size: .72rem; color: var(--tenue); }
.em-sync { max-width: 13rem; min-height: 2.4rem; padding: .3rem .7rem; border-radius: 999px; border: 1px solid var(--borde); background: var(--tarjeta); color: var(--texto); font-size: .78rem; cursor: pointer; }
.em-sync::before { content: '●'; margin-right: .35rem; }
.em-sync.ok::before { color: var(--ok); } .em-sync.aviso::before { color: var(--aviso); } .em-sync.peligro::before { color: var(--peligro); } .em-sync.apagado::before { color: var(--apagado); }
@media (max-width: 640px) {
	.em-cab { flex-wrap: wrap; gap: .5rem .6rem; }
	.em-sync { order: 5; flex: 1 1 100%; max-width: none; border-radius: 8px; text-align: left; }
}
.em-franja { padding: .45rem 1rem; text-align: center; font-weight: 800; letter-spacing: .06em; font-size: .85rem; }
.em-franja.simulacro { background: repeating-linear-gradient(135deg, #facc15 0 14px, #111 14px 28px); }
.em-franja span { display: inline-block; padding: .15rem .6rem; border-radius: 6px; background: #facc15; color: #111; }
.em-franja.cerrado span { background: none; color: #fff; }
.em-franja.cerrado { background: var(--apagado); color: #fff; }

/* Cuerpo y navegación */
.em-cuerpo { display: flex; }
.em-main { flex: 1; min-width: 0; padding: 1rem; padding-bottom: 6rem; max-width: 80rem; }
.em-sinjs { padding: 1rem; max-width: 60rem; }
.em-nav { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; display: grid; grid-template-columns: repeat(5, 1fr); background: var(--fondo); border-top: 1px solid var(--borde); padding-bottom: env(safe-area-inset-bottom); }
.em-nav-b { position: relative; display: flex; flex-direction: column; align-items: center; gap: 2px; min-height: 3.6rem; padding: .45rem .2rem; border: 0; background: none; color: var(--tenue); font: inherit; font-size: .72rem; cursor: pointer; }
.em-nav-b span { font-size: 1.25rem; line-height: 1; }
.em-nav-b.is-on { color: var(--primario); box-shadow: inset 0 3px 0 var(--primario); }
.em-solo-ancho { display: none; }
.em-cuenta { position: absolute; top: .3rem; left: 55%; min-width: 1.15rem; height: 1.15rem; padding: 0 .3rem; border-radius: 999px; background: var(--peligro); color: #fff; font-style: normal; font-size: .7rem; font-weight: 700; line-height: 1.15rem; text-align: center; }
@media (min-width: 900px) {
	.em-nav { position: sticky; top: 3.75rem; align-self: flex-start; display: flex; flex-direction: column; width: 13.5rem; height: calc(100vh - 3.75rem); border-top: 0; border-right: 1px solid var(--borde); padding: .75rem .5rem; overflow-y: auto; }
	.em-nav-b { flex-direction: row; justify-content: flex-start; gap: .65rem; min-height: 2.75rem; padding: .5rem .75rem; border-radius: 10px; font-size: .95rem; text-align: left; }
	.em-nav-b span { width: 1.4rem; text-align: center; font-size: 1.05rem; }
	.em-nav-b.is-on { background: var(--tarjeta); box-shadow: inset 3px 0 0 var(--primario); }
	.em-solo-ancho { display: flex; }
	.em-solo-movil { display: none; }
	.em-cuenta { position: static; margin-left: auto; }
	.em-main { padding: 1.25rem 1.5rem 3rem; }
	.em-nav-b[data-v="mas"] { margin-top: auto; }
}

/* Tarjetas y rejillas */
.em-tarjeta { background: var(--tarjeta); border: 1px solid var(--borde); border-radius: var(--radio); padding: 1rem; margin-bottom: 1rem; }
.em-grid-inicio, .em-tablero, .em-grid2 { display: grid; gap: 0 1rem; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 1100px) {
	.em-grid-inicio, .em-grid2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
	.em-tablero { grid-template-columns: repeat(2, minmax(0, 1fr)); }
	.em-tablero .em-resumen, .em-grid-inicio .em-hero { grid-column: 1 / -1; }
}
.em-hero { border-color: var(--peligro); }
.em-hero h1 { font-size: 1.75rem; }
.em-sup { font-family: var(--mono); font-size: .8rem; color: var(--tenue); text-transform: uppercase; letter-spacing: .1em; }
.em-bienvenida { max-width: 36rem; margin: 1rem auto; }
.em-barra { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .75rem; margin-bottom: .75rem; }
.em-barra h1 { margin: 0; }
.em-filtros { justify-content: flex-start; }
.em-nota { color: var(--tenue); font-size: .88rem; }
.em-aviso { padding: .75rem 1rem; border-radius: 10px; background: var(--tarjeta); border: 2px solid var(--aviso); }

/* Botones */
.em-btn { display: inline-flex; align-items: center; justify-content: center; gap: .4rem; min-height: 2.75rem; padding: .55rem 1rem; border-radius: 10px; border: 1px solid var(--borde);
	background: var(--fondo); color: var(--texto); font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; }
.em-btn:hover { border-color: var(--primario); }
.em-btn:disabled { opacity: .5; }
.em-btn.primario { background: var(--primario); border-color: var(--primario); color: var(--primario-t); }
.em-btn.peligro { background: var(--peligro); border-color: var(--peligro); color: #fff; }
.em-btn.ok { border-color: var(--ok); color: var(--ok); }
.em-grande { min-height: 3.25rem; font-size: 1.05rem; }
.em-acciones { display: flex; flex-wrap: wrap; gap: .5rem; }
.em-acciones .em-grande { flex: 1 1 12rem; }
.em-link { padding: .5rem 0; border: 0; background: none; color: var(--primario); font: inherit; cursor: pointer; text-decoration: underline; }
.em-x { width: 2.5rem; height: 2.5rem; border: 1px solid var(--borde); border-radius: 8px; background: none; color: var(--tenue); font-size: 1.3rem; cursor: pointer; }
.em-x:hover { color: var(--peligro); border-color: var(--peligro); }
.em-archivo { position: relative; overflow: hidden; }
.em-archivo input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
:focus-visible { outline: 3px solid var(--primario); outline-offset: 2px; }

/* Formularios */
.em-form { display: grid; gap: .8rem; }
.em-form label { display: grid; gap: .3rem; font-weight: 600; font-size: .92rem; }
.em-form fieldset { margin: 0; padding: 0; border: 0; display: grid; gap: .35rem; }
.em-form legend { font-weight: 600; font-size: .92rem; margin-bottom: .3rem; }
.em-campo { width: 100%; min-height: 2.75rem; padding: .55rem .75rem; border-radius: 10px; border: 1px solid var(--borde); background: var(--fondo); color: var(--texto); font: inherit; font-weight: 400; }
textarea.em-campo { min-height: 6rem; resize: vertical; }
.em-campo:focus { border-color: var(--primario); outline: none; box-shadow: 0 0 0 3px color-mix(in srgb, var(--primario) 30%, transparent); }
.em-campo[readonly] { opacity: .75; }
.em-campo.em-grande { font-size: 1.25rem; letter-spacing: .05em; }
.em-dos, .em-tres { display: grid; gap: .8rem; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 560px) { .em-dos { grid-template-columns: repeat(2, minmax(0, 1fr)); } .em-tres { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.em-con-boton { display: flex; gap: .4rem; }
.em-con-boton .em-btn { flex-shrink: 0; padding: 0 .8rem; }
label.em-check, .em-form label.em-check { display: flex; align-items: flex-start; gap: .6rem; font-weight: 400; }
.em-check input { width: 1.35rem; height: 1.35rem; flex-shrink: 0; margin: .1rem 0 0; accent-color: var(--primario); }
.em-inline { display: inline-flex; align-items: center; gap: .5rem; font-size: .9rem; color: var(--tenue); }
.em-inline .em-campo { width: auto; min-height: 2.4rem; padding: .3rem .5rem; }
.em-buscar { display: block; margin-bottom: .75rem; }

/* Opciones en forma de botón */
.em-chips { display: flex; flex-wrap: wrap; gap: .4rem; }
.em-chip { position: relative; }
.em-chip input { position: absolute; opacity: 0; pointer-events: none; }
.em-chip span, button.em-chip { display: inline-flex; align-items: center; min-height: 2.6rem; padding: .4rem .85rem; border-radius: 999px; border: 1px solid var(--borde); background: var(--fondo); color: var(--texto); font: inherit; font-size: .92rem; font-weight: 600; cursor: pointer; }
.em-chip input:checked + span, button.em-chip.is-on { background: var(--texto); color: var(--fondo); border-color: var(--texto); }
.em-chip.ok input:checked + span, button.em-chip.ok.is-on { background: var(--ok); border-color: var(--ok); color: #04130a; }
.em-chip.aviso input:checked + span, button.em-chip.aviso.is-on { background: var(--aviso); border-color: var(--aviso); color: #1a1200; }
.em-chip.peligro input:checked + span, button.em-chip.peligro.is-on { background: var(--peligro); border-color: var(--peligro); color: #fff; }
.em-chip input:focus-visible + span { outline: 3px solid var(--primario); outline-offset: 2px; }
.em-chips-mini button.em-chip { min-height: 2.3rem; padding: .25rem .6rem; font-size: .8rem; }
.em-seg { display: inline-flex; border: 1px solid var(--borde); border-radius: 10px; overflow: hidden; }
.em-seg button { min-height: 2.6rem; padding: .4rem .9rem; border: 0; background: var(--fondo); color: var(--tenue); font: inherit; font-weight: 600; cursor: pointer; }
.em-seg button + button { border-left: 1px solid var(--borde); }
.em-seg button.is-on { background: var(--texto); color: var(--fondo); }
.em-seg-ancho { display: flex; }
.em-seg-ancho button { flex: 1; }

/* Etiquetas de estado */
.em-pill { display: inline-block; padding: .1rem .55rem; border-radius: 999px; font-size: .78rem; font-weight: 700; border: 1px solid currentColor; white-space: nowrap; vertical-align: middle; }
.em-pill.ok { color: var(--ok); } .em-pill.aviso { color: var(--aviso); } .em-pill.peligro { color: var(--peligro); } .em-pill.apagado { color: var(--tenue); }
.em-borde-ok { border-left: 5px solid var(--ok) !important; }
.em-borde-aviso { border-left: 5px solid var(--aviso) !important; }
.em-borde-peligro { border-left: 5px solid var(--peligro) !important; }
.em-borde-apagado { border-left: 5px solid var(--apagado) !important; }

/* Listas */
.em-lista { display: grid; gap: .5rem; }
.em-fila { display: flex; align-items: center; justify-content: space-between; gap: .75rem; padding: .65rem .8rem; border-radius: 10px; border: 1px solid var(--borde); background: var(--fondo); color: var(--texto); font: inherit; text-align: left; }
.em-fila > span:first-child { min-width: 0; display: flex; flex-direction: column; align-items: flex-start; gap: .15rem; }
.em-fila small { display: block; }
.em-fila em { color: var(--texto); font-size: .9rem; }
.em-fila-btn { width: 100%; cursor: pointer; }
.em-fila-btn:hover { border-color: var(--primario); }
@media (max-width: 640px) { .em-repe, .em-per { flex-direction: column; align-items: stretch; } }
.em-ok-grande { font-size: 1.1rem; font-weight: 700; color: var(--ok); }

/* Resumen del tablero */
.em-resumen { display: grid; gap: .75rem; grid-template-columns: repeat(2, minmax(0, 1fr)); margin-bottom: 1rem; }
@media (min-width: 900px) { .em-resumen { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.em-cifra { display: flex; flex-direction: column; align-items: flex-start; gap: .1rem; padding: .85rem 1rem; border-radius: var(--radio); border: 1px solid var(--borde); background: var(--tarjeta); color: var(--texto); font: inherit; text-align: left; cursor: pointer; }
.em-cifra strong { font-family: var(--mono); font-size: 2rem; line-height: 1.1; }
.em-cifra span { font-weight: 700; }
.em-cifra small { font-size: .8rem; }
.em-cifra.peligro { border: 2px solid var(--peligro); } .em-cifra.peligro strong { color: var(--peligro); }
.em-cifra.aviso { border: 2px solid var(--aviso); } .em-cifra.aviso strong { color: var(--aviso); }
.em-atencion { border-color: var(--aviso); }

/* Estaciones */
.em-estaciones { display: grid; gap: .75rem; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 760px) { .em-estaciones { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (min-width: 1300px) { .em-estaciones { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.em-est { padding: .8rem .9rem; border-radius: var(--radio); border: 1px solid var(--borde); background: var(--tarjeta); }
.em-est.is-lista { outline: 3px solid var(--primario); }
.em-est p { margin: .3rem 0; }
.em-est-cab { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem; }
.em-ind { font-size: 1.35rem; margin-right: .2rem; }
.em-nota-est { font-style: italic; }
.em-edad { font-weight: 700; font-size: .9rem; }
.em-est-acc { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .4rem; margin-top: .5rem; }
.em-est-acc .em-btn { padding: .4rem .5rem; font-size: .9rem; }

/* Mensajes */
.em-msg { display: flex; flex-direction: column; gap: .25rem; width: 100%; padding: .75rem .9rem; border-radius: 10px; border: 1px solid var(--borde); background: var(--tarjeta); color: var(--texto); font: inherit; text-align: left; cursor: pointer; }
.em-msg:hover { border-color: var(--primario); }
.em-msg-cab { display: flex; flex-wrap: wrap; align-items: center; gap: .35rem; font-size: .92rem; }
.em-msg-est { margin-left: auto; font-size: .8rem; font-weight: 700; color: var(--tenue); text-transform: uppercase; letter-spacing: .05em; }
.em-msg-para { font-weight: 600; }
.em-msg-txt { font-family: var(--mono); font-size: .9rem; color: var(--tenue); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.em-leer { margin: .75rem 0; padding: 1rem; border-radius: 10px; background: var(--fondo); border: 1px solid var(--borde); white-space: pre-wrap; word-break: break-word; font: 1.05rem/1.6 var(--mono); }
.em-dictar { font-size: 1.1rem; text-align: center; }
.em-dictar strong { font-size: 2.2rem; letter-spacing: .08em; }

/* Bitácora */
.em-bit { list-style: none; margin: 0; padding: 0; display: grid; }
.em-bit li { display: grid; grid-template-columns: 3.4rem 5.6rem minmax(0, 1fr) auto; gap: .5rem; padding: .45rem 0; border-bottom: 1px solid var(--borde); font-size: .92rem; }
.em-bit time { font-family: var(--mono); color: var(--tenue); }
.em-autor { font-family: var(--mono); color: var(--primario); overflow: hidden; text-overflow: ellipsis; }
.em-pend { color: var(--aviso); font-style: normal; font-size: .7rem; }
.em-tipo-nota { font-weight: 700; text-transform: uppercase; font-size: .78rem; letter-spacing: .05em; color: var(--aviso); }
@media (max-width: 560px) { .em-bit li { grid-template-columns: 3.2rem minmax(0, 1fr) auto; } .em-autor { grid-column: 2; } .em-bit li > span:not(.em-autor) { grid-column: 1 / 3; } }

/* Tablas */
.em-tabla { width: 100%; border-collapse: collapse; font-size: .92rem; }
.em-tabla th { text-align: left; color: var(--tenue); font-weight: 600; font-size: .8rem; padding: .35rem .5rem; border-bottom: 1px solid var(--borde); }
.em-tabla td { padding: .5rem; border-bottom: 1px solid var(--borde); vertical-align: top; }
.em-f { font-family: var(--mono); font-weight: 800; font-size: 1.1rem; color: var(--primario); white-space: nowrap; }
@media (max-width: 560px) { .em-tabla td:nth-child(3) { font-size: .85rem; } }

/* Teléfonos */
.em-tels { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .5rem; }
.em-tels a { display: flex; flex-direction: column; padding: .7rem .9rem; border-radius: 10px; border: 1px solid var(--borde); background: var(--fondo); color: var(--texto); text-decoration: none; font-size: .85rem; }
.em-tels strong { font-family: var(--mono); font-size: 1.5rem; color: var(--peligro); }
.em-tel strong { color: var(--peligro); font-family: var(--mono); }

/* Preparación */
.em-prep { border-top: 1px solid var(--borde); padding: .5rem 0; }
.em-prep summary { cursor: pointer; font-weight: 700; min-height: 2.5rem; display: flex; align-items: center; }
.em-prep ul { list-style: none; margin: .25rem 0 .5rem; padding: 0; display: grid; gap: .5rem; }

/* Herramientas */
.em-resultado { margin-top: .75rem; font-size: 1.05rem; }
input[type="range"] { width: 100%; accent-color: var(--primario); }

/* Modal y avisos */
.em-modal { position: fixed; inset: 0; z-index: 50; display: flex; align-items: flex-end; justify-content: center; background: rgb(0 0 0 / .6); }
.em-modal-caja { width: 100%; max-width: 40rem; max-height: 92vh; overflow-y: auto; padding: 1rem 1rem calc(1.25rem + env(safe-area-inset-bottom)); border-radius: 16px 16px 0 0; background: var(--tarjeta); border: 1px solid var(--borde); }
@media (min-width: 700px) { .em-modal { align-items: center; } .em-modal-caja { border-radius: 16px; padding: 1.25rem 1.5rem 1.5rem; } }
.em-modal-cab { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: .75rem; }
.em-modal-cab h2 { margin: 0; font-size: 1.2rem; }
body.em-con-modal { overflow: hidden; }
.em-copia { font-family: var(--mono); font-size: .85rem; }
.em-toast { position: fixed; left: 50%; bottom: 5rem; z-index: 60; max-width: min(92vw, 34rem); padding: .75rem 1rem; border-radius: 10px; background: var(--texto); color: var(--fondo); font-weight: 600; transform: translate(-50%, 1rem); opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; }
.em-toast.is-on { opacity: 1; transform: translate(-50%, 0); }
.em-toast.peligro { background: var(--peligro); color: #fff; }
.em-toast.aviso { background: var(--aviso); color: #1a1200; }
@media (min-width: 900px) { .em-toast { bottom: 1.5rem; } }

/* Impresión: el plan de frecuencias y la bitácora en papel, para la cartelera del puesto de mando */
@media print {
	:root { --fondo: #fff; --tarjeta: #fff; --borde: #999; --texto: #000; --tenue: #333; --primario: #000; }
	.em-nav, .em-sync, .em-acciones, .em-btn, .em-x, .em-link, .em-toast, .em-chips-mini, .em-buscar { display: none !important; }
	.em-cab { position: static; }
	.em-main { padding: 0; }
	.em-tarjeta { break-inside: avoid; border-color: #999; }
}

/* ══ Centro de mando integral (19.53.0) ══════════════════════════════════════════════════ */
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
.em-saltar { position: absolute; left: -999px; top: 0; z-index: 99; padding: .6rem 1rem; background: var(--primario); color: var(--primario-t); font-weight: 700; }
.em-saltar:focus { left: .5rem; top: .5rem; }
.em-main:focus { outline: none; }
.em-error { color: var(--peligro); font-weight: 600; min-height: 1em; }
.em-error:empty { display: none; }
.em-tenue { opacity: .55; }
.em-bloque { display: block; }
.em-act { display: block; margin-top: .25rem; font-family: var(--mono); font-size: .72rem; color: var(--tenue); }
.em-lista-txt { margin: .25rem 0 .75rem; padding-left: 1.2rem; }
.em-lista-txt li { margin: .25rem 0; }
.em-marca-r { color: var(--peligro); font-style: normal; font-size: .72rem; font-weight: 700; text-transform: uppercase; }
.em-pend { font-size: .72rem; text-transform: uppercase; letter-spacing: .03em; }
.em-ancho { grid-column: 1 / -1; }
.em-tabla-c { overflow-x: auto; }

/* Cabecera: búsqueda */
.em-buscar-cab { flex: 0 1 16rem; }
.em-buscar-cab input { width: 100%; min-height: 2.4rem; padding: .35rem .7rem; border-radius: 8px; border: 1px solid var(--borde); background: var(--tarjeta); color: var(--texto); font: inherit; font-size: .9rem; }
@media (max-width: 900px) { .em-buscar-cab { display: none; } }

/* Navegación agrupada */
.em-nav-g { display: none; }
@media (min-width: 900px) {
	.em-nav-g { display: block; margin: .9rem .75rem .25rem; font-family: var(--mono); font-size: .68rem; text-transform: uppercase; letter-spacing: .14em; color: var(--tenue); }
	.em-nav-g:first-child { margin-top: .2rem; }
	.em-nav-b { min-height: 2.5rem; padding: .4rem .75rem; font-size: .92rem; }
}
.em-mas { flex-direction: column; }
.em-mas .em-btn { justify-content: flex-start; }

/* Tablero: filtros, cifras y rejilla con mapa */
.em-filtros-d { margin-bottom: .75rem; }
.em-filtros-d summary { cursor: pointer; min-height: 2.4rem; display: inline-flex; align-items: center; font-weight: 600; color: var(--primario); }
.em-filtros-t { display: grid; gap: .5rem .75rem; grid-template-columns: repeat(auto-fill, minmax(11rem, 1fr)); align-items: end; padding: .75rem; border: 1px solid var(--borde); border-radius: var(--radio); background: var(--tarjeta); }
.em-filtros-t label { display: grid; gap: .2rem; font-size: .82rem; font-weight: 600; color: var(--tenue); }
.em-filtros-t .em-campo { min-height: 2.4rem; padding: .3rem .55rem; }
.em-tablero { display: block; }
.em-tablero-g { display: grid; gap: 0 1rem; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 1100px) {
	.em-tablero-g { grid-template-columns: repeat(2, minmax(0, 1fr)); }
	.em-tablero-mapa { grid-row: span 2; }
}
@media (min-width: 1500px) { .em-tablero-g { grid-template-columns: repeat(3, minmax(0, 1fr)); } .em-tablero-mapa { grid-column: span 2; } }
.em-solo-ancho-b { display: none; }
@media (min-width: 1100px) { .em-solo-ancho-b { display: block; } }
.em-cifra small br + * { display: block; }

/* Mapa */
.em-mapa-mini { height: 22rem; border-radius: 10px; overflow: hidden; border: 1px solid var(--borde); }
.em-vista-mapa .em-mapa-g { display: grid; gap: 1rem; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 1000px) { .em-vista-mapa .em-mapa-g { grid-template-columns: 19rem minmax(0, 1fr); } }
.em-mapa { height: calc(100vh - 13rem); min-height: 24rem; border-radius: var(--radio); overflow: hidden; border: 1px solid var(--borde); }
@media (max-width: 999px) { .em-mapa { height: 62vh; } .em-mapa-panel { order: 2; } }
.em-mapa-panel { display: grid; gap: .75rem; align-content: start; }
.em-capas { border: 1px solid var(--borde); border-radius: 10px; padding: .5rem .75rem; display: grid; gap: .1rem; }
.em-capas legend { font-weight: 700; padding: 0 .3rem; }
.em-capas .em-check { font-size: .88rem; min-height: 2rem; align-items: center; }
.em-leyenda { font-size: .82rem; color: var(--tenue); }
.em-leyenda i { display: inline-block; width: .7rem; height: .7rem; border-radius: 50%; margin: 0 .2rem 0 .4rem; vertical-align: middle; }
.em-mapa-carga { padding: 1rem; }
.em-mk { background: none; border: 0; }
.em-mk span { display: block; width: 14px; height: 14px; border: 2px solid #0b0f17; }
.em-mk-rombo { transform: rotate(45deg) scale(.8); }
.em-pop { font: 13px/1.45 system-ui, sans-serif; min-width: 12rem; }
.em-pop .em-link { padding: .2rem 0; font-size: 13px; }
.em-pop-q { color: #555; font-size: 12px; }
/* Leaflet usa z-index de 400 a 1000: el mapa forma su propio contexto para no tapar cabecera, barra ni modales. */
.em-mapa, .em-mapa-mini, .em-mapa-sala { position: relative; z-index: 0; isolation: isolate; }
.leaflet-container { background: #0e1520; font: inherit; }
.leaflet-popup-content-wrapper, .leaflet-popup-tip { background: #f8fafc; color: #0b0f17; }
.leaflet-control-layers { background: var(--tarjeta) !important; color: var(--texto) !important; border: 1px solid var(--borde) !important; }
.leaflet-control-attribution { font-size: 10px !important; }

/* Incidentes */
.em-inc { display: flex; flex-direction: column; gap: .3rem; width: 100%; padding: .75rem .9rem; border-radius: 10px; border: 1px solid var(--borde); background: var(--tarjeta); color: var(--texto); font: inherit; text-align: left; cursor: pointer; }
.em-inc:hover { border-color: var(--primario); }
.em-inc strong { font-size: 1.02rem; }
.em-inc-cab { display: flex; flex-wrap: wrap; gap: .3rem; align-items: center; margin-bottom: .3rem; }
.em-detalle h1 { margin-top: .2rem; }
.em-dl { display: grid; grid-template-columns: minmax(8rem, 12rem) minmax(0, 1fr); gap: .35rem .9rem; margin: 0; font-size: .92rem; }
.em-dl dt { color: var(--tenue); font-weight: 600; }
.em-dl dd { margin: 0; overflow-wrap: anywhere; }
@media (max-width: 560px) { .em-dl { grid-template-columns: minmax(0, 1fr); } .em-dl dd { margin-bottom: .4rem; } }
.em-dup .em-acciones { flex-wrap: nowrap; }
@media (max-width: 640px) { .em-dup, .em-rec { flex-direction: column; align-items: stretch; } .em-dup .em-acciones { flex-wrap: wrap; } }

/* Pestañas */
.em-seg-tabs { display: flex; flex-wrap: wrap; margin-bottom: 1rem; }
.em-seg-tabs button { flex: 1 1 auto; }
@media (max-width: 640px) { .em-seg-tabs { overflow-x: auto; flex-wrap: nowrap; } .em-seg-tabs button { flex: 0 0 auto; white-space: nowrap; } }

/* Recursos */
.em-rec-sel { width: auto; min-width: 12rem; }

/* Informes y simulador */
.em-informe { max-height: 70vh; overflow: auto; font-size: .88rem; }
.em-sim-msg { font-family: var(--mono); font-size: 1.05rem; padding: .9rem 1rem; border-radius: 10px; border: 2px dashed var(--aviso); background: var(--fondo); }
.em-modal-caja.ancho { max-width: 56rem; }

/* Modo compacto (campo): solo lo esencial, botones grandes */
.em-compacto body { font-size: 18px; }
.em-compacto .em-btn { min-height: 3.25rem; font-size: 1.05rem; }
.em-compacto .em-tablero-g > section:not(.em-atencion), .em-compacto .em-filtros-d, .em-compacto .em-buscar-cab { display: none !important; }
.em-compacto .em-nota { font-size: .95rem; }
.em-compacto .em-est details, .em-compacto .em-est .em-nota { display: none; }

/* Modo sol: más contraste en lo que usa colores de estado */
:root[data-tema="sol"] .em-franja.simulacro span { border: 2px solid #111; }
:root[data-tema="sol"] .leaflet-container { background: #e2e8f0; }

@media print {
	.em-buscar-cab, .em-filtros-d, .em-seg, .em-est-acc, .em-mapa-panel, .em-saltar { display: none !important; }
	.em-informe { max-height: none; overflow: visible; }
}

/* ══ Sala de mando y control de red (19.54.0) ═══════════════════════════════
   Más densa que el resto: paneles con cabecera de consola, cifras en monoespaciada,
   luces de estado y temporizadores que cambian de color al acercarse al límite. */
.em-main:has(> .em-sala), .em-main:has(> .em-red) { max-width: none; }
.em-alarmas-b { display: inline-flex; align-items: center; gap: .35rem; min-height: 2.4rem; padding: .3rem .75rem; border-radius: 8px; border: 1px solid var(--borde); background: var(--tarjeta); color: var(--ok); font: 700 .8rem var(--mono); cursor: pointer; white-space: nowrap; }
.em-alarmas-b.n-critica { color: #fff; background: #7f1d1d; border-color: var(--peligro); }
.em-alarmas-b.n-alta { color: var(--aviso); border-color: var(--aviso); }
.em-alarmas-b.n-media { color: var(--texto); }
.em-alarmas-b.sin-ver.n-critica { animation: em-latido 1.2s ease-in-out infinite; }
.em-mudo { font-size: .75rem; opacity: .75; }
@keyframes em-latido { 50% { box-shadow: 0 0 0 4px rgb(248 113 113 / .35); } }
@media (prefers-reduced-motion: reduce) { .em-alarmas-b.sin-ver.n-critica { animation: none; } }
@media (max-width: 640px) {
	/* Segunda fila de la cabecera: alarmas y sincronización, una al lado de la otra */
	.em-titulo { flex: 1 1 0; min-width: 48%; }
	.em-sync, .em-alarmas-b { order: 5; flex: 1 1 40%; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; justify-content: center; }
	.em-est-c strong { font-size: 1rem; white-space: normal; }
}

/* Franja de estado: siete indicadores con etiqueta de consola */
.em-estado { display: grid; gap: .5rem; grid-template-columns: repeat(2, minmax(0, 1fr)); margin-bottom: .75rem; }
@media (min-width: 700px) { .em-estado { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
@media (min-width: 1250px) { .em-estado { grid-template-columns: 1.4fr repeat(6, minmax(0, 1fr)); } }
.em-est-c { display: flex; flex-direction: column; align-items: flex-start; gap: .1rem; min-width: 0; padding: .55rem .7rem; border: 1px solid var(--borde); border-left: 4px solid var(--primario); border-radius: 8px; background: var(--tarjeta); color: var(--texto); text-align: left; cursor: pointer; font: inherit; }
.em-est-c:hover { border-color: var(--primario); }
.em-est-c strong { font: 700 1.2rem/1.2 var(--mono); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.em-est-c small { font-size: .74rem; line-height: 1.3; }
.em-est-e { font: 700 .66rem var(--mono); letter-spacing: .12em; text-transform: uppercase; color: var(--tenue); }
.em-est-c.ok { border-left-color: var(--ok); } .em-est-c.aviso { border-left-color: var(--aviso); } .em-est-c.peligro { border-left-color: var(--peligro); background: color-mix(in srgb, var(--peligro) 10%, var(--tarjeta)); } .em-est-c.apagado { border-left-color: var(--apagado); }

/* Línea de comandos */
.em-cmd { display: grid; grid-template-columns: auto minmax(0, 1fr) auto auto; gap: .4rem; align-items: center; margin-bottom: .75rem; padding: .4rem; border: 1px solid var(--primario); border-radius: 10px; background: #060a11; }
:root[data-tema="sol"] .em-cmd { background: var(--tarjeta); }
.em-cmd-p { padding: 0 .3rem 0 .45rem; color: var(--primario); font: 700 1.3rem var(--mono); }
.em-cmd .em-campo { border: 0; background: transparent; min-height: 2.6rem; font-size: 1rem; }
.em-cmd .em-campo:focus { outline: none; box-shadow: none; }
.em-cmd:focus-within { box-shadow: 0 0 0 3px rgb(56 189 248 / .25); }
.em-cmd-o { grid-column: 1 / -1; min-height: 1.2rem; padding: 0 .5rem; font: .82rem var(--mono); color: var(--primario); }
.em-cmd-o.error { color: var(--aviso); }
.em-cmd-o:empty { display: none; }
@media (max-width: 560px) { .em-cmd { grid-template-columns: auto minmax(0, 1fr) auto; } .em-cmd [data-cmd-ayuda] { display: none; } }
.em-ayuda-cmd td:first-child { white-space: nowrap; color: var(--primario); }

/* Rejilla de la sala: red | situación | alarmas y tráfico; abajo incidentes, registro y período */
.em-sala-g { display: grid; gap: .75rem; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 900px) {
	.em-sala-g { grid-template-columns: repeat(2, minmax(0, 1fr)); }
	.em-p-mapa { grid-column: 1 / -1; }
}
@media (min-width: 1250px) {
	.em-sala-g { grid-template-columns: minmax(17rem, 1fr) minmax(0, 2fr) minmax(19rem, 1.15fr); grid-template-areas: "red mapa alarmas" "red mapa trafico" "inc log periodo"; }
	.em-p-red { grid-area: red; } .em-p-mapa { grid-area: mapa; grid-column: auto; } .em-p-alarmas { grid-area: alarmas; } .em-p-trafico { grid-area: trafico; }
	.em-p-inc { grid-area: inc; } .em-p-log { grid-area: log; } .em-p-periodo { grid-area: periodo; }
}
.em-panel { min-width: 0; display: flex; flex-direction: column; border: 1px solid var(--borde); border-radius: 10px; background: var(--tarjeta); overflow: hidden; }
.em-panel > header { display: flex; align-items: center; justify-content: space-between; gap: .5rem; padding: .45rem .75rem; border-bottom: 1px solid var(--borde); background: color-mix(in srgb, var(--fondo) 55%, var(--tarjeta)); }
.em-panel > header h2 { margin: 0; font: 700 .72rem var(--mono); letter-spacing: .14em; text-transform: uppercase; color: var(--tenue); }
.em-panel > header .em-link { font-size: .8rem; }
.em-panel > div { padding: .6rem; overflow: auto; max-height: 28rem; }
.em-p-mapa > div { padding: 0; max-height: none; }
.em-mapa-sala { height: 26rem; }
@media (min-width: 1250px) { .em-mapa-sala { height: 100%; min-height: 30rem; } }
.em-sub { margin: .25rem 0 .4rem; font: 700 .68rem var(--mono); letter-spacing: .12em; text-transform: uppercase; color: var(--tenue); }
.em-ok-txt { color: var(--ok); font-weight: 700; margin: .25rem; }
.em-pre { white-space: pre-wrap; }
.em-sala-acc { margin-top: .75rem; }
.em-bit-vivo li { padding-top: .3rem; padding-bottom: .3rem; font-size: .88rem; }

/* Filas de la red: luz, indicativo, temporizador y acciones a un toque */
.em-red-l { display: grid; gap: .35rem; }
.em-red-f { display: flex; align-items: center; gap: .55rem; min-width: 0; padding: .4rem .5rem; border: 1px solid var(--borde); border-radius: 8px; background: var(--fondo); }
.em-red-f.urgente { border-color: var(--peligro); background: color-mix(in srgb, var(--peligro) 14%, var(--fondo)); }
.em-led { flex: 0 0 auto; width: .7rem; height: .7rem; border-radius: 50%; background: var(--ok); box-shadow: 0 0 6px var(--ok); }
.n-ambar .em-led { background: var(--aviso); box-shadow: 0 0 6px var(--aviso); }
.n-rojo .em-led { background: var(--peligro); box-shadow: 0 0 6px var(--peligro); }
.em-red-i { flex: 1; min-width: 0; display: flex; flex-wrap: wrap; align-items: center; gap: .15rem .45rem; }
.em-red-i strong { font-size: 1rem; }
.em-red-i small { flex-basis: 100%; font-size: .76rem; }
.n-ambar .em-red-i small { color: var(--aviso); } .n-rojo .em-red-i small { color: var(--peligro); }
.em-red-b { display: flex; gap: .3rem; flex-shrink: 0; }
.em-red-b .em-btn { min-height: 2.5rem; min-width: 2.5rem; padding: .3rem .55rem; }
.em-red-l-ancha { grid-template-columns: 2rem minmax(0, 1fr); align-items: center; }
.em-red-orden { font: 700 .9rem var(--mono); color: var(--tenue); text-align: right; }
@media (max-width: 560px) { .em-red-l-ancha .em-red-f { flex-wrap: wrap; } .em-red-l-ancha .em-red-b { flex-basis: 100%; justify-content: flex-end; } }
.em-red-estado { display: flex; flex-direction: column; gap: .15rem; margin-bottom: .75rem; padding: .75rem 1rem; border: 1px solid var(--borde); border-left: 5px solid var(--apagado); border-radius: 10px; background: var(--tarjeta); }
.em-red-estado strong { font: 700 1.5rem var(--mono); text-transform: uppercase; }
.em-red-estado.n-dirigida { border-left-color: var(--aviso); } .em-red-estado.n-abierta { border-left-color: var(--ok); }
.em-guion { margin-bottom: 1rem; }
.em-voz { font-size: 1.05rem; padding: .75rem; border-left: 3px solid var(--primario); background: var(--fondo); border-radius: 6px; }

/* Alarmas */
.em-alarmas { display: grid; gap: .35rem; }
.em-alarma { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: .25rem .6rem; align-items: start; padding: .45rem .55rem; border: 1px solid var(--borde); border-left: 4px solid var(--apagado); border-radius: 8px; background: var(--fondo); }
.em-alarma.n-critica { border-left-color: var(--peligro); background: color-mix(in srgb, var(--peligro) 12%, var(--fondo)); }
.em-alarma.n-alta { border-left-color: var(--aviso); }
.em-alarma.enterada { opacity: .6; }
.em-al-n { font: 700 .66rem var(--mono); letter-spacing: .1em; text-transform: uppercase; padding-top: .2rem; }
.n-critica .em-al-n { color: var(--peligro); } .n-alta .em-al-n { color: var(--aviso); } .n-media .em-al-n { color: var(--tenue); }
.em-al-t { font-size: .9rem; } .em-al-t small { display: block; font-family: var(--mono); }
.em-al-b { grid-column: 2; display: flex; gap: .35rem; }
.em-al-b .em-btn { min-height: 2.2rem; padding: .2rem .7rem; font-size: .85rem; }
.em-informe { max-height: 55vh; overflow: auto; padding: .75rem; background: var(--fondo); border: 1px solid var(--borde); border-radius: 8px; font: .85rem/1.45 var(--mono); }
.em-tabla-c { max-height: 60vh; overflow: auto; }

/* Pantalla de sala: sin menú ni distracciones, todo más grande */
body.em-modo-sala .em-nav, body.em-modo-sala .em-buscar-cab, body.em-modo-sala .em-marca { display: none !important; }
body.em-modo-sala .em-main { padding: .75rem 1rem; }
body.em-modo-sala { font-size: 17px; }
body.em-modo-sala .em-est-c strong { font-size: 1.5rem; }
@media (min-width: 1250px) { body.em-modo-sala .em-panel > div { max-height: 34vh; } body.em-modo-sala .em-mapa-sala { min-height: 52vh; } }
body.em-modo-sala .em-sala-acc { justify-content: flex-end; }
body.em-modo-sala .em-sala-acc > :not(#sl-pant) { display: none; }

/* Fondo de consola: retícula tenue solo en la sala */
.em-sala { background-image: linear-gradient(rgb(56 189 248 / .035) 1px, transparent 1px), linear-gradient(90deg, rgb(56 189 248 / .035) 1px, transparent 1px); background-size: 28px 28px; }
:root[data-tema="sol"] .em-sala { background-image: none; }
@media print { .em-cmd, .em-red-b, .em-al-b, #em-alarmas { display: none !important; } .em-panel > div { max-height: none; overflow: visible; } }

/* Herramientas (19.54.0): perfil de enlace, lluvia, tablero de tráfico, paquetes */
@media (min-width: 1100px) { .em-ancho-2 { grid-column: 1 / -1; } }
.em-campo-n { display: block; min-height: 1.1rem; font-family: var(--mono); }
.em-perfil, .em-lluvia { width: 100%; height: auto; margin: .5rem 0; background: var(--fondo); border: 1px solid var(--borde); border-radius: 8px; }
.em-pf-g { stroke: var(--borde); stroke-width: 1; }
.em-pf-t { fill: var(--tenue); font: 10px var(--mono); }
.em-pf-suelo { fill: #5b4a2f; stroke: #a07c48; stroke-width: 1.2; }
.em-pf-fresnel { fill: none; stroke: var(--aviso); stroke-width: 1.2; stroke-dasharray: 4 3; }
.em-pf-linea { stroke: var(--primario); stroke-width: 2; }
.em-pf-linea.obstruido { stroke: var(--peligro); }
.em-pf-peor { fill: var(--peligro); stroke: #fff; stroke-width: 1.5; }
.em-ll-pasado { fill: var(--apagado); } .em-ll-futuro { fill: var(--primario); }
.em-ll-ahora { stroke: var(--aviso); stroke-width: 1.5; stroke-dasharray: 3 2; }
.em-kanban { display: grid; gap: .75rem; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 760px) { .em-kanban { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (min-width: 1200px) { .em-kanban { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.em-kb-col { min-width: 0; padding: .6rem; border: 1px solid var(--borde); border-radius: 10px; background: var(--tarjeta); }
.em-kb-col h3 { margin: 0 0 .5rem; display: flex; justify-content: space-between; font: 700 .72rem var(--mono); letter-spacing: .1em; text-transform: uppercase; }
.em-kb-t { display: flex; flex-wrap: wrap; align-items: center; gap: .25rem .45rem; width: 100%; margin-bottom: .4rem; padding: .5rem .6rem; border: 1px solid var(--borde); border-left-width: 4px; border-radius: 8px; background: var(--fondo); color: var(--texto); font: inherit; text-align: left; cursor: pointer; }
.em-kb-t:hover { border-color: var(--primario); }
.em-kb-t small, .em-kb-t .em-mono { flex-basis: 100%; font-size: .78rem; }
.em-qr { display: flex; justify-content: center; padding: .75rem; background: #fff; border-radius: 8px; }
.em-qr svg { width: min(100%, 22rem); height: auto; }
.em-qr-v { width: 100%; max-height: 50vh; background: #000; border-radius: 8px; }
.em-notas { margin: .4rem 0 0; padding-left: 1.4rem; font-size: .78rem; color: var(--tenue); }
.em-notas li { margin-bottom: .2rem; }
.em-tabla-compacta sup { color: var(--tenue); margin-left: .15rem; }
.em-real { border-color: var(--primario); }
.em-dos > .em-form { align-self: start; align-content: start; }
.em-dos > .em-form h3 { margin-top: 0; }
