:root {
  --bg: #f6f7f9; --panel: #ffffff; --text: #1d2330; --muted: #5d6677; --line: #e1e4ea;
  --accent: #2f6fb8; --marino: #0c1626; --celeste: #7cc0ef; --accent-text: #ffffff; --ok-bg: #e7f5ec; --ok: #1d6b3a; --err-bg: #fdecec; --err: #a12626;
  --warn-bg: #fff6e0; --warn: #8a5a00; --new: #1d6b3a; --mod: #8a5a00; --del: #a12626; --chip: #eef1f6;
  --serie-1: #2a78d6; --serie-2: #eb6834; --grilla: #eceef2; --eje: #c9ced8; --hover: rgba(31,95,191,.07); --punto-mapa: #0d366b;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #12151b; --panel: #1b1f27; --text: #e6e9ef; --muted: #9aa3b2; --line: #2c323d;
    --accent: #7cc0ef; --marino: #0a121f; --celeste: #7cc0ef; --accent-text: #0b1220; --ok-bg: #12301f; --ok: #7fd6a0; --err-bg: #3a1717; --err: #ff9b9b;
    --warn-bg: #3a2d10; --warn: #f3c66b; --new: #7fd6a0; --mod: #f3c66b; --del: #ff9b9b; --chip: #262c36;
    --serie-1: #3987e5; --serie-2: #d95926; --grilla: #262c36; --eje: #3a414e; --hover: rgba(124,192,239,.08); --punto-mapa: #7cc0ef;
  }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
header { background: var(--marino); border-bottom: 1px solid #1d2a40; }
header nav a { color: #a9b6c9; }
header nav a.activo, header nav a:hover { background: #1a2740; color: #fff; }
header .usuario { color: #a9b6c9; }
header .usuario a { color: var(--celeste); }
.logo { display: flex; align-items: center; gap: 10px; text-decoration: none !important; margin-right: 10px; }
.logo img { width: 46px; height: 29px; }
.logo .nombre { font-size: 22px; line-height: 1; letter-spacing: .2px; }
.logo .wing { color: #fff; font-weight: 750; }
.logo .log { color: var(--celeste); font-weight: 300; }
.logo .sub { display: block; font-size: 8.5px; letter-spacing: 3.2px; color: var(--celeste); margin-top: 3px; }
.logo-grande { justify-content: center; background: var(--marino); padding: 22px; border-radius: 12px; margin-bottom: 18px; }
.logo-grande img { width: 70px; height: 44px; }
.logo-grande .nombre { font-size: 32px; }
.logo-grande .sub { font-size: 11px; }
.barra { max-width: 1200px; margin: 0 auto; padding: 10px 16px; display: flex; gap: 18px; align-items: center; flex-wrap: wrap; }
.marca { font-weight: 700; color: var(--text); margin-right: 8px; }
nav { display: flex; gap: 4px; flex-wrap: wrap; flex: 1; }
nav a { padding: 6px 10px; border-radius: 6px; color: var(--muted); }
nav a.activo, nav a:hover { background: var(--chip); color: var(--text); text-decoration: none; }
.usuario { color: var(--muted); font-size: 13px; }
main { max-width: 1200px; margin: 0 auto; padding: 20px 16px 60px; }
h1 { font-size: 22px; margin: 4px 0 16px; }
h2 { font-size: 16px; margin: 0 0 12px; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 16px; margin-bottom: 16px; }
.grilla { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.dato { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; }
.dato .v { font-size: 22px; font-weight: 650; font-variant-numeric: tabular-nums; }
.dato .k { color: var(--muted); font-size: 13px; }
.dos { display: grid; gap: 16px; grid-template-columns: 1fr 1fr; }
@media (max-width: 800px) { .dos { grid-template-columns: 1fr; } }
table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
th, td { padding: 6px 8px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
th { color: var(--muted); font-weight: 600; font-size: 13px; }
td.n, th.n { text-align: right; }
.tabla { overflow-x: auto; }
tr.total td { font-weight: 650; border-top: 2px solid var(--line); }
.chip { display: inline-block; padding: 1px 8px; border-radius: 99px; background: var(--chip); font-size: 12px; color: var(--muted); }
.chip.lock { background: var(--warn-bg); color: var(--warn); }
.chip.ok { background: var(--ok-bg); color: var(--ok); }
.chip.err { background: var(--err-bg); color: var(--err); }
.flash { padding: 10px 14px; border-radius: 8px; margin-bottom: 14px; }
.flash.ok { background: var(--ok-bg); color: var(--ok); }
.flash.error { background: var(--err-bg); color: var(--err); }
.aviso { background: var(--warn-bg); color: var(--warn); padding: 10px 14px; border-radius: 8px; margin-bottom: 14px; }
form.linea { display: flex; gap: 8px; flex-wrap: wrap; align-items: end; }
label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 4px; }
input, select { font: inherit; color: var(--text); background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: 6px 8px; }
input[type=checkbox] { width: 16px; height: 16px; }
.campos { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); margin-bottom: 14px; }
.campos input, .campos select { width: 100%; }
button, .boton { font: inherit; display: inline-block; border: 1px solid var(--accent); background: var(--accent); color: var(--accent-text);
  padding: 7px 14px; border-radius: 6px; cursor: pointer; }
button.sec, .boton.sec { background: transparent; color: var(--accent); }
button.peligro { background: transparent; border-color: var(--err); color: var(--err); }
.boton:hover { text-decoration: none; }
.acciones { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.muted { color: var(--muted); }
.chico { font-size: 13px; }
.dif-viejo { color: var(--del); text-decoration: line-through; }
.dif-nuevo { color: var(--new); font-weight: 600; }
.centro { max-width: 380px; margin: 60px auto; }
.centro input { width: 100%; margin-bottom: 12px; }
.filtros { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.filtros a { padding: 4px 10px; border-radius: 99px; background: var(--chip); color: var(--text); font-size: 13px; }
.filtros a.activo { background: var(--accent); color: var(--accent-text); }

/* ---- estadisticas ---- */
.grafico { position: relative; width: 100%; }
.grafico svg { display: block; overflow: visible; }
.marcas { pointer-events: none; }
.eje-txt { font-size: 11px; fill: var(--muted); font-variant-numeric: tabular-nums; }
.eje-txt.fuerte { fill: var(--text); font-size: 12px; }
.tip { position: absolute; display: none; pointer-events: none; z-index: 5; background: var(--panel); color: var(--text);
  border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; font-size: 12px; box-shadow: 0 4px 14px rgba(0,0,0,.12); white-space: nowrap; }
.tip .muted { color: var(--muted); }
.clave { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.leyenda { display: flex; gap: 14px; font-size: 13px; color: var(--muted); margin: -4px 0 8px; }
.cabeza { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; flex-wrap: wrap; }
details.tabla-datos { margin-top: 10px; font-size: 13px; }
details.tabla-datos summary { cursor: pointer; color: var(--muted); }
#mapa { height: 480px; border-radius: 8px; overflow: hidden; background: var(--bg); }
@media (max-width: 700px) { #mapa { height: 340px; } }
.etiqueta-apt { font: 600 11px system-ui, sans-serif; color: var(--text); text-shadow: 0 0 3px var(--panel), 0 0 3px var(--panel), 0 0 3px var(--panel); white-space: nowrap; }
.records { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.record { border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; }
.record .k { color: var(--muted); font-size: 13px; }
.record .v { font-size: 18px; font-weight: 650; margin: 2px 0; }
.record .d { color: var(--muted); font-size: 13px; }
.leaflet-container { font: inherit; }

/* ---- medidores de limites (color de estado + icono y texto) ---- */
.medidor { margin-bottom: 14px; }
.medidor .cabeza { margin-bottom: 6px; }
.pista { height: 10px; border-radius: 99px; background: #dff3df; overflow: hidden; }
.pista:has(.aviso) { background: #fdeccb; }
.pista:has(.critico) { background: #f6d5d5; }
.relleno { height: 100%; border-radius: 99px; background: #0ca30c; }
.relleno.aviso { background: #fab219; }
.relleno.critico { background: #d03b3b; }
@media (prefers-color-scheme: dark) {
  .pista { background: #183a1c; } .pista:has(.aviso) { background: #3f3115; } .pista:has(.critico) { background: #3d1a1a; }
}
.alerta-doc { display: flex; justify-content: space-between; gap: 8px; padding: 6px 0; border-bottom: 1px solid var(--line); }
.alerta-doc:last-child { border-bottom: 0; }

/* ---- menu de usuario ---- */
.menu-usuario { position: relative; }
.menu-usuario summary { list-style: none; cursor: pointer; color: #a9b6c9; padding: 6px 10px; border-radius: 6px; font-size: 14px; }
.menu-usuario summary::-webkit-details-marker { display: none; }
.menu-usuario summary:hover, .menu-usuario summary.activo, .menu-usuario[open] summary { background: #1a2740; color: #fff; }
.desplegable { position: absolute; right: 0; top: calc(100% + 6px); z-index: 1000; min-width: 200px; background: var(--panel);
  border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,.18); padding: 6px; }
.desplegable a { display: block; padding: 7px 10px; border-radius: 6px; color: var(--text); }
.desplegable a:hover, .desplegable a.activo { background: var(--chip); text-decoration: none; }
.desplegable hr { border: 0; border-top: 1px solid var(--line); margin: 5px 4px; }
nav { align-items: center; }
nav .sep { width: 1px; height: 18px; background: #2a3a55; margin: 0 6px; }
@media (max-width: 800px) { nav .sep { display: none; } }

/* ---- adjuntos de documentacion ---- */
.adjuntos { display: flex; gap: 6px; flex-wrap: wrap; }
.adjunto { display: inline-flex; align-items: center; gap: 8px; text-decoration: none !important; }
.adjunto img, .adjunto .pdf { width: 40px; height: 40px; border-radius: 6px; border: 1px solid var(--line); object-fit: cover; background: var(--bg); }
.adjunto .pdf { display: inline-flex; align-items: center; justify-content: center; font: 700 11px system-ui, sans-serif; color: #d03b3b; }
.adjunto:hover img, .adjunto:hover .pdf { outline: 2px solid var(--accent); }
.subir { border: 1px dashed var(--line); border-radius: 10px; padding: 12px; margin-bottom: 14px; }
.lista-adjuntos { display: grid; gap: 8px; margin-bottom: 10px; }
.fila-adjunto { display: flex; align-items: center; gap: 10px; }
.fila-adjunto .adjunto img, .fila-adjunto .adjunto .pdf { width: 56px; height: 56px; }
.info-adj { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.info-adj a:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chico-btn { padding: 4px 10px; font-size: 13px; }

/* ---- avisos cerrables ---- */
.aviso.cerrable { display: flex; align-items: flex-start; gap: 12px; }
.aviso.cerrable > span { flex: 1; }
.aviso.cerrable form { margin: 0; }
.aviso .cerrar { background: transparent; border: 0; color: inherit; opacity: .6; padding: 0 4px; font-size: 15px; line-height: 1.4; cursor: pointer; }
.aviso .cerrar:hover { opacity: 1; }

/* ---- hojas de vuelo ---- */
button.enlace { background: none; border: 0; padding: 0 0 0 6px; color: var(--accent); cursor: pointer; }
button.enlace:hover { text-decoration: underline; }
.estado-hoja { display: flex; align-items: center; gap: 4px; margin: 0; }
.acciones-fila a { margin-right: 10px; }
.hoja-panel { padding: 12px; }
.hoja-scroll { overflow-x: auto; background: #fff; border-radius: 6px; }
/* la hoja se ve siempre como papel blanco, también en modo oscuro */
table.hoja-anac { border-collapse: collapse; table-layout: fixed; width: max-content; background: #fff; color: #111;
  font: 12px Arial, Helvetica, sans-serif; font-variant-numeric: normal; }
table.hoja-anac td { padding: 1px 3px; border: 0; white-space: nowrap; overflow: hidden; vertical-align: middle;
  text-align: left; line-height: 1.15; }
table.hoja-anac td .vertical { display: inline-block; writing-mode: vertical-rl; transform: rotate(180deg); white-space: normal; font-size: 9.5px; line-height: 1.05; }
table.hoja-anac td:has(.vertical) { overflow: visible; text-align: center; }

table.hoja-anac img.firma-prev { position: absolute; left: 50%; bottom: -3px; transform: translateX(-50%);
  max-width: 85%; max-height: 80px; pointer-events: none; mix-blend-mode: multiply; }

/* ---- firma: subir, dibujar o escribir ---- */
@font-face { font-family: "FirmaEscrita"; src: url("fuentes/firma-escrita.ttf") format("truetype"); font-display: block; }
.pestanas { display: inline-flex; gap: 2px; background: var(--chip); padding: 3px; border-radius: 8px; margin: 4px 0 12px; }
.pestanas button { background: transparent; border: 0; color: var(--muted); padding: 6px 14px; border-radius: 6px; cursor: pointer; }
.pestanas button.activa { background: var(--panel); color: var(--text); box-shadow: 0 1px 3px rgba(0,0,0,.12); }
.firma-actual { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; }
.firma-actual img { max-height: 56px; max-width: 260px; background: #fff; border: 1px solid var(--line); border-radius: 6px; padding: 4px 8px; }
.panel-firma { border: 1px dashed var(--line); border-radius: 10px; padding: 12px; margin-bottom: 14px; }
/* el lienzo es siempre "papel blanco", también en modo oscuro */
.lienzo { display: block; width: 100%; max-width: 640px; height: 200px; background: #fff; border: 1px solid var(--line);
  border-radius: 8px; margin-bottom: 10px; touch-action: none; cursor: crosshair;
  background-image: linear-gradient(transparent 150px, #c9ced8 150px, #c9ced8 151px, transparent 151px); }
.color-firma { display: inline-flex; align-items: center; gap: 4px; color: var(--text); font-size: 14px; margin: 0 8px 0 0; }

/* ---- configuracion: hoja base y reglas ---- */
.ayuda { display: block; font-size: 12px; color: var(--muted); margin-top: 4px; line-height: 1.35; }
.lista-ayuda { margin: 4px 0 12px; padding-left: 20px; }
.lista-ayuda li { margin: 3px 0; }
.estado-base { background: var(--chip); border-radius: 8px; padding: 10px 12px; margin-bottom: 12px; font-size: 14px; }
.opcion-base { border: 1px solid var(--line); border-radius: 8px; padding: 10px 14px; margin-top: 10px; }
.opcion-base summary { cursor: pointer; }
.opcion-base[open] summary { margin-bottom: 10px; }
.grupo-totales { border: 0; border-top: 1px solid var(--line); padding: 8px 0 0; margin: 0 0 6px; }
.grupo-totales legend { font-weight: 600; font-size: 13px; padding-right: 8px; }
.campos { align-items: start; }

/* ---- hojas: hoja base aparte y selección para descargar ---- */
.tarjeta-base { display: flex; gap: 16px; align-items: center; justify-content: space-between; border-left: 4px solid var(--accent); }
.tarjeta-base h2 { margin-top: 0; }
.tarjeta-base .boton { white-space: nowrap; }
.tarjeta-base p { margin: 4px 0; }
@media (max-width: 700px) { .tarjeta-base { flex-direction: column; align-items: stretch; } }
.barra-seleccion { align-items: center; margin-bottom: 8px; }
.col-check { width: 32px; text-align: center; }
.pasos { background: var(--chip); border-radius: 8px; padding: 10px 14px; margin-bottom: 12px; }
.pasos p { margin: 2px 0 6px; }
.pasos ol { margin: 0; padding-left: 20px; }
.pasos li { margin: 3px 0; }
.barra-base { grid-template-columns: minmax(220px, 320px) auto; align-items: start; }
.total-base-caja { display: flex; flex-direction: column; gap: 2px; justify-self: end; text-align: right; }
.total-base-caja b { font-size: 22px; }
@media (max-width: 700px) { .barra-base { grid-template-columns: 1fr; } .total-base-caja { justify-self: start; text-align: left; } }
table.hoja-anac td:has(.celda-campo) { background: #fff4c2; padding: 0; }
table.hoja-anac .celda-campo { width: 100%; height: 100%; min-height: 18px; border: 0; background: transparent; padding: 0 2px;
  font: inherit; font-size: 11px; text-align: center; color: #111; }
table.hoja-anac .celda-campo:focus { outline: 2px solid var(--accent); background: #fff; }
table.hoja-anac .celda-campo::placeholder { color: #b9a868; }
.explica-base { max-width: 820px; }

/* ---- cuenta: registro, contraseñas ---- */
.centro-ancho { max-width: 620px; }
.dos-col { grid-template-columns: 1fr 1fr; }
.dos-col .ancho, .campos .ancho { grid-column: 1 / -1; }
@media (max-width: 560px) { .dos-col { grid-template-columns: 1fr; } }
.obl { color: var(--err); }
.con-ojo { position: relative; display: block; }
.con-ojo input { width: 100%; padding-right: 38px; margin-bottom: 0 !important; }
.centro .con-ojo { margin-bottom: 12px; }            /* el margen del campo va afuera: así el ojito queda centrado */
.centro .campos .con-ojo { margin-bottom: 0; }
.valor-fijo { padding: 6px 8px; border: 1px dashed var(--line); border-radius: 6px; color: var(--muted); }
.con-ojo .ojo { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); background: none; border: 0;
  color: var(--muted); padding: 4px 6px; cursor: pointer; line-height: 0; }
.con-ojo .ojo:hover { color: var(--text); background: none; }
.reglas-clave { list-style: none; padding: 0; margin: 0; font-size: 12.5px; color: var(--muted);
  display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 2px 12px; }
.reglas-clave li::before { content: "○"; display: inline-block; width: 16px; }
.reglas-clave li.ok { color: var(--ok); }
.reglas-clave li.ok::before { content: "✓"; }
.aviso-perfil { background: var(--warn-bg); color: var(--warn); }
.aviso-perfil a { color: inherit; text-decoration: underline; }
.centro .campos input, .centro .campos select { margin-bottom: 0; width: 100%; }

/* ---- buscador de vuelos ---- */
.buscador-campos { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.buscador-campos .buscar-texto { grid-column: 1 / -1; }
.buscador .acciones { align-items: center; }
.zona-peligro { border: 1px solid var(--err); margin-top: 16px; }
.zona-peligro h2 { color: var(--err); }
.correo-texto { white-space: pre-wrap; font: 13px/1.5 ui-monospace, Consolas, monospace; margin: 8px 0 0; word-break: break-all; }
.aviso-perfil .enlace { padding: 0 4px; color: inherit; text-decoration: underline; }

/* ---- administración ---- */
.altas-semana { display: flex; align-items: flex-end; gap: 6px; height: 150px; padding-top: 8px; }
.altas-semana .col { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; min-width: 0; }
.altas-semana .barra-alta { width: 100%; max-width: 34px; background: var(--serie-1); border-radius: 4px 4px 0 0; min-height: 0; }
.altas-semana .n { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.altas-semana .et { font-size: 11px; color: var(--muted); margin-top: 4px; white-space: nowrap; }
form.en-linea { display: inline; margin: 0; }
.peligro-texto { color: var(--err) !important; }
.barra-disco { height: 12px; background: var(--chip); border-radius: 99px; overflow: hidden; margin: 4px 0 8px; }
.barra-disco span { display: block; height: 100%; background: var(--serie-1); border-radius: 99px; }
.barra-disco.aviso span { background: var(--warn); }
.barra-disco.critico span { background: var(--err); }
