:root {
    --navy: #16283a;
    --navy-2: #1f3b53;
    --blue: #0f6fb5;
    --blue-dark: #0b578f;
    --sky: #eaf3fa;
    --amber: #e0a800;
    --red: #d15b5b;
    --green: #1f9d6b;
    --ink: #21313f;
    --muted: #6a7883;
    --line: #dfe6ec;
    --background: #f4f7f9;
    --white: #fff;
    --shadow: 0 8px 30px rgba(16, 40, 58, .07);
    --radius: 14px;
}

* { box-sizing: border-box; }
body { margin: 0; color: var(--ink); background: var(--background); font: 14px/1.5 'Segoe UI', system-ui, -apple-system, sans-serif; }
button, input, select, textarea { font: inherit; }
a { color: inherit; text-decoration: none; }
h1, h2, p { margin-top: 0; }
code { padding: 2px 6px; background: #eef3f7; border-radius: 5px; font: 13px/1.4 'Consolas', monospace; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.center { text-align: center; }
.right { text-align: right; }
.warn { color: #a15c00; font-weight: 600; }

/* ------------------------------------------------------------------ shell -- */
.app-shell { min-height: 100vh; display: grid; grid-template-columns: 246px minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; padding: 24px 16px 18px; color: #d6e4ef; background: linear-gradient(178deg, #16283a 0%, #0e1c29 100%); overflow-y: auto; z-index: 20; }
.brand { display: flex; align-items: center; gap: 12px; padding: 0 8px 26px; color: #fff; }
.brand-mark { width: 40px; height: 40px; display: inline-grid; place-items: center; flex: 0 0 auto; border-radius: 11px; color: #fff; background: var(--blue); font-weight: 800; letter-spacing: .06em; box-shadow: 0 7px 18px rgba(15, 111, 181, .32); }
.brand-mark.large { width: 58px; height: 58px; border-radius: 16px; font-size: 19px; }
.brand-logo { height: 46px; width: auto; max-width: 94px; flex: 0 0 auto; object-fit: contain; }
.brand strong, .sidebar-user strong { display: block; font-size: 15px; }
.brand > span:last-child { min-width: 0; }
.brand > span:last-child strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.brand small, .sidebar-user small { display: block; color: #8ba5ba; font-size: 11px; }
.sidebar nav { display: flex; flex-direction: column; gap: 4px; }
.sidebar nav > a { display: flex; align-items: center; gap: 11px; padding: 10px 12px; border-radius: 9px; color: #b3c6d5; font-weight: 600; transition: .18s ease; }
.sidebar nav > a:hover { background: rgba(255, 255, 255, .06); color: #fff; }
.sidebar nav > a.active { color: #fff; background: rgba(15, 111, 181, .28); box-shadow: inset 3px 0 var(--blue); }
.nav-icon { width: 19px; text-align: center; font-size: 16px; }
.nav-label { margin: 18px 12px 6px; color: #62819a; font-size: 10px; letter-spacing: .13em; text-transform: uppercase; }
.sidebar-user { margin-top: auto; padding: 13px 8px 0; border-top: 1px solid rgba(255, 255, 255, .09); display: grid; grid-template-columns: 34px 1fr auto; align-items: center; gap: 9px; }
.avatar { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 50%; background: #294c67; color: #fff; font-weight: 700; }
.sidebar-user strong { font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user > a { color: #8ba5ba; font-size: 18px; }

.main { min-width: 0; }
.topbar { min-height: 92px; display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 18px 30px; background: #fff; border-bottom: 1px solid var(--line); }
.topbar h1 { margin: 2px 0 0; color: var(--navy); font-size: 24px; line-height: 1.15; }
.eyebrow { display: block; color: var(--blue); font-size: 10px; font-weight: 700; letter-spacing: .13em; text-transform: uppercase; }
.topbar-date { color: var(--muted); font-size: 13px; }
.menu-button { display: none; border: 0; background: transparent; font-size: 22px; color: var(--navy); }
.content { max-width: 1580px; margin: 0 auto; padding: 24px 30px 44px; }
.page-actions { min-height: 42px; display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.page-actions > div { display: flex; gap: 8px; flex-wrap: wrap; }
.page-intro { margin: 0; color: var(--muted); }

/* ---------------------------------------------------------------- botones -- */
.btn { min-height: 38px; display: inline-flex; align-items: center; justify-content: center; padding: 8px 15px; border: 1px solid transparent; border-radius: 9px; cursor: pointer; font-weight: 700; font-size: 13px; transition: .18s; }
.btn-primary { color: #fff; background: var(--blue); box-shadow: 0 6px 14px rgba(15, 111, 181, .18); }
.btn-primary:hover { background: var(--blue-dark); transform: translateY(-1px); }
.btn-secondary { color: var(--navy); background: #fff; border-color: #cbd8e2; }
.btn-secondary:hover { border-color: var(--blue); color: var(--blue); }
.btn-ghost { color: #4f6b80; background: transparent; border-color: #d7e0e7; }
.btn-ghost:hover { background: #fff; }
.btn-danger { color: #fff; background: var(--red); margin-right: auto; }
.btn-wide { width: 100%; }
.btn.disabled { opacity: .45; pointer-events: none; }
.link-button { padding: 0; border: 0; background: none; color: var(--blue); cursor: pointer; font-weight: 600; }

/* --------------------------------------------------------------- avisos ---- */
.alert { margin-bottom: 16px; padding: 11px 14px; border-radius: 9px; font-weight: 600; }
.alert-success { color: #10614a; background: #e4f5ee; border: 1px solid #bfe4d6; }
.alert-error { color: #963232; background: #fdf0f0; border: 1px solid #f0c8c8; }
.alert-info { color: #14507d; background: var(--sky); border: 1px solid #c5ddf0; }
.contingency-banner { margin-bottom: 16px; padding: 12px 15px; border-radius: 9px; background: #fff6e0; border: 1px solid #f0dcae; color: #7a5800; }
.contingency-banner strong { display: block; }

/* --------------------------------------------------------------- paneles --- */
.panel { margin-bottom: 20px; padding: 20px 22px; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.panel h2 { margin: 3px 0 0; color: var(--navy); font-size: 18px; }
.panel-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; margin-bottom: 14px; flex-wrap: wrap; }
.table-panel { padding: 20px 0 6px; }
.table-panel .panel-head, .table-panel > .form-footer { padding: 0 22px; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 11px 14px; text-align: left; vertical-align: top; border-bottom: 1px solid var(--line); }
thead th { position: sticky; top: 0; background: #f7fafc; color: var(--muted); font-size: 11px; letter-spacing: .07em; text-transform: uppercase; white-space: nowrap; z-index: 2; }
tbody tr:hover { background: #fafcfe; }
td small { display: block; color: var(--muted); font-size: 11.5px; }
.strong-link { color: var(--blue); font-weight: 700; }
.assignment { font-size: 12.5px; line-height: 1.7; }
.actions { white-space: nowrap; text-align: right; }
.actions form { display: inline; }
.table-action { display: inline-block; margin-left: 9px; color: var(--muted); font-size: 12px; font-weight: 600; }
.table-action:hover { color: var(--blue); }
.edit-action { color: var(--blue); }
.empty-state { padding: 26px 22px; color: var(--muted); text-align: center; }

/* ------------------------------------------------------------- distintivos - */
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; background: #eef2f6; color: #4a5b6a; font-size: 11.5px; font-weight: 700; white-space: nowrap; }
.badge i { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.badge-borrador { background: #eef2f6; color: #62727f; }
.badge-confirmada, .badge-programado { background: var(--sky); color: #14507d; }
.badge-asignada { background: #e7f3ec; color: #1a6d4c; }
.badge-en_ruta { background: #fff3d9; color: #8a6100; }
.badge-cerrada, .badge-realizado { background: #e4f5ee; color: #10614a; }
.badge-anulada, .badge-anulado { background: #fdeeee; color: #9b3838; }

/* --------------------------------------------------------------- métricas -- */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; margin-bottom: 20px; }
.kpi { padding: 16px 18px; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.kpi-label { display: block; color: var(--muted); font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.kpi-value { display: block; margin: 6px 0 2px; color: var(--navy); font-size: 27px; font-weight: 800; line-height: 1.1; }
.kpi-hint { color: var(--muted); font-size: 12px; }
.kpi.tone-good .kpi-value { color: var(--green); }
.kpi.tone-warn .kpi-value { color: #b07500; }
.kpi.tone-muted .kpi-value { color: var(--muted); }

/* --------------------------------------------------------------- gráficos -- */
.chart-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; margin-bottom: 4px; }
.chart-grid > .panel { margin-bottom: 0; }
.chart-grid .span-2 { grid-column: span 2; }
.chart-panel canvas { width: 100%; display: block; }
.legend { list-style: none; margin: 12px 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 12px; color: var(--muted); }
.legend li { display: flex; align-items: center; gap: 6px; }
.legend strong { color: var(--ink); }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--blue); }
.dot-0 { background: #0f6fb5; } .dot-1 { background: #1f9d6b; } .dot-2 { background: #e0a800; }
.dot-3 { background: #d15b5b; } .dot-4 { background: #7b61a8; } .dot-5 { background: #2fa4b8; }

/* ---------------------------------------------------------------- filtros -- */
.filter-panel { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px; margin-bottom: 18px; padding: 16px 18px; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.filter-panel label, .form-grid label, .inline-form label { display: flex; flex-direction: column; gap: 5px; font-size: 12px; color: var(--muted); font-weight: 600; }
.filter-panel label { min-width: 140px; }
.filter-panel label.grow { flex: 1 1 220px; }
.filter-actions { display: flex; gap: 8px; margin-left: auto; }
input, select, textarea { padding: 9px 11px; border: 1px solid #cdd8e1; border-radius: 8px; background: #fff; color: var(--ink); }
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(15, 111, 181, .25); border-color: var(--blue); }
input[type="file"] { padding: 7px; background: #f8fafc; }
textarea { resize: vertical; }

/* ----------------------------------------------------------- formularios -- */
/* El formulario de alta/edición vive sobre la tabla; los enlaces «Editar» apuntan a
   #editor para que el navegador salte hasta él en listas largas, donde antes quedaba
   fuera de pantalla y parecía que el clic no había hecho nada. */
#editor { scroll-margin-top: 16px; }
#editor:target { border-color: #b8d6ec; box-shadow: 0 0 0 3px rgba(15, 111, 181, .14), var(--shadow); }
.form-card { max-width: 1180px; }
.form-card.compact { max-width: 860px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 14px; margin: 12px 0 6px; }
.form-grid .span-2 { grid-column: 1 / -1; }
.form-footer { display: flex; align-items: center; justify-content: flex-end; gap: 10px; margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--line); }
.form-hint { margin: 4px 0 0; color: var(--muted); font-size: 12px; margin-right: auto; }
.form-table td { padding: 6px 10px; }
.form-table select, .form-table input { width: 100%; }
.form-table input.mini { width: 70px; text-align: center; }
.inline-form { display: flex; align-items: flex-end; gap: 8px; margin-top: 12px; }
.logo-row { display: flex; align-items: center; gap: 18px; margin: 10px 0; }
.logo-row .grow { flex: 1; }
.logo-preview { max-width: 180px; max-height: 80px; object-fit: contain; padding: 8px; background: #f7fafc; border: 1px solid var(--line); border-radius: 10px; }
.file-list { list-style: none; margin: 10px 0 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.file-list li { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 11px 13px; background: #f8fafc; border: 1px solid var(--line); border-radius: 10px; flex-wrap: wrap; }
.file-list form { display: flex; gap: 8px; align-items: center; }
.file-list small { display: block; color: var(--muted); font-size: 11.5px; }

/* ---------------------------------------------------------------- detalle -- */
.detail-grid { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 18px; align-items: start; }
.detail-side { display: flex; flex-direction: column; }
.data-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 10px 18px; margin: 12px 0 16px; }
.data-list > div { padding-bottom: 8px; border-bottom: 1px dashed var(--line); }
.data-list dt { color: var(--muted); font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; }
.data-list dd { margin: 3px 0 0; font-weight: 600; }
.data-list .destacado dd { color: var(--navy); font-size: 17px; }
.detalle-servicio { margin: 8px 0 16px; padding: 14px 16px; background: #f8fafc; border: 1px solid var(--line); border-left: 3px solid var(--blue); border-radius: 8px; white-space: pre-wrap; word-break: break-word; font: 13px/1.7 'Segoe UI', system-ui, sans-serif; }
.nota { margin: 6px 0 0; padding: 11px 14px; background: #fff8e6; border-left: 3px solid var(--amber); border-radius: 8px; }
.timeline { list-style: none; margin: 10px 0 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.timeline li { padding-left: 14px; border-left: 2px solid var(--line); }
.timeline li.overdue { border-left-color: var(--red); }
.timeline small { display: block; color: var(--muted); font-size: 12px; }
/* Lista de pendientes: cifra en pastilla, texto y acción siempre en la misma columna, para
   que números de uno y de tres dígitos no desalineen las filas entre sí. */
.gap-list { list-style: none; margin: 0; padding: 0; }
.gap { display: grid; grid-template-columns: 56px minmax(0, 1fr) auto; align-items: center; gap: 14px; padding: 11px 0; border-top: 1px solid var(--line); }
.gap:first-child { border-top: 0; padding-top: 2px; }
.gap-count { height: 32px; display: grid; place-items: center; padding: 0 6px; border-radius: 9px; background: #fff4e2; color: #8a5b00; font-size: 15px; font-weight: 800; font-variant-numeric: tabular-nums; }
.gap.done .gap-count { background: #e4f5ee; color: var(--green); }
.gap-text strong { display: block; color: var(--ink); font-size: 13.5px; font-weight: 600; }
.gap-text small { display: block; margin-top: 1px; color: var(--muted); font-size: 11.5px; }
.gap.done .gap-text strong { color: var(--muted); font-weight: 500; }
.gap-action { color: var(--blue); font-size: 12px; font-weight: 700; white-space: nowrap; }
.gap-action:hover { text-decoration: underline; }
.bar-cell { min-width: 170px; }
.bar-cell .bar { display: block; height: 8px; margin-bottom: 4px; border-radius: 999px; background: linear-gradient(90deg, var(--blue), #4aa3dd); }
.bar-cell small { color: var(--muted); }

/* ---------------------------------------------------------------- matriz --- */
.matrix th, .matrix td { padding: 6px 7px; text-align: center; font-size: 12px; }
.matrix .sticky-col { position: sticky; left: 0; background: #fff; text-align: left; min-width: 190px; z-index: 3; }
.matrix thead .sticky-col { background: #f7fafc; }
.matrix th small { display: block; color: #9aa8b4; font-size: 9px; font-weight: 500; }
.matrix th.weekend { color: #b07500; }
.matrix-cell.has-value { background: var(--sky); color: #14507d; font-weight: 700; border-radius: 4px; }
.weekend-row { background: #fbfcfd; }
.filled-row { background: #f6fbff; }
.day-cell { white-space: nowrap; }
.day-cell small { display: inline; margin-left: 5px; color: var(--muted); }

/* ------------------------------------------------------------- calendario -- */
.calendar { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; }
.calendar-head { padding: 6px 4px; color: var(--muted); font-size: 11px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; text-align: center; }
.calendar-cell { min-height: 104px; padding: 7px; background: #fbfdfe; border: 1px solid var(--line); border-radius: 9px; display: flex; flex-direction: column; gap: 4px; }
.calendar-cell.empty { background: transparent; border: 0; }
.calendar-cell.today { border-color: var(--blue); box-shadow: 0 0 0 2px rgba(15, 111, 181, .12); }
.calendar-day { color: var(--muted); font-size: 12px; font-weight: 700; }
.calendar-chip { padding: 3px 6px; border-radius: 6px; background: var(--sky); color: #14507d; font-size: 10.5px; line-height: 1.35; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.calendar-chip.contrato { background: #eef7f2; color: #17694c; }
.calendar-chip.estado-anulada { background: #fdeeee; color: #9b3838; }
.calendar-chip.estado-cerrada { background: #e4f5ee; color: #10614a; }
.calendar-more { color: var(--muted); font-size: 10.5px; }

/* ----------------------------------------------------------- paginación --- */
.pager { display: flex; align-items: center; justify-content: center; gap: 14px; margin: 6px 0 24px; }
.pager-info { color: var(--muted); font-size: 12px; }

/* ------------------------------------------------------------------ login -- */
.login-page { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1.08fr) minmax(0, .92fr); }

/* --- mitad izquierda: el vídeo de la flota como fondo --------------------- */
.login-stage { position: relative; display: flex; flex-direction: column; justify-content: flex-end; padding: 44px 52px 66px; overflow: hidden; background: #0b1a26; color: #eaf1f7; }
/* El vídeo es vertical (720×1280): 'cover' lo recorta arriba y abajo, y el desplazamiento
   al 42 % mantiene a la vista los buses y la cordillera en vez del cielo. */
.stage-video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: center 50%; animation: stage-drift 30s ease-in-out infinite alternate; }
.stage-scrim { position: absolute; inset: 0; background:
    linear-gradient(to top, rgba(6, 15, 23, .95) 0%, rgba(7, 19, 29, .74) 27%, rgba(9, 23, 35, .3) 58%, rgba(11, 27, 41, .12) 100%),
    linear-gradient(to right, rgba(6, 15, 23, .58) 0%, rgba(6, 15, 23, 0) 66%),
    radial-gradient(120% 88% at 50% 32%, rgba(0, 0, 0, 0) 42%, rgba(3, 9, 15, .5) 100%); }
.stage-sheen { position: absolute; inset: -25% -45%; background: linear-gradient(103deg, transparent 40%, rgba(255, 216, 168, .14) 47%, rgba(255, 255, 255, .07) 51%, transparent 59%); animation: sheen 11s ease-in-out infinite; }

.stage-top { position: relative; z-index: 3; display: flex; align-items: center; gap: 13px; margin-bottom: auto; animation: fade-down .9s .1s both cubic-bezier(.2, .7, .3, 1); }
.stage-logo { height: 74px; width: auto; max-width: 156px; flex: 0 0 auto; object-fit: contain; filter: drop-shadow(0 10px 24px rgba(0, 0, 0, .55)); }
.stage-brand { display: flex; flex-direction: column; justify-content: center; min-height: 44px; padding-left: 17px; border-left: 1px solid rgba(255, 255, 255, .32); }
.stage-brand strong { display: block; color: #fff; font-size: 15px; text-shadow: 0 2px 14px rgba(0, 0, 0, .55); }
.stage-brand small { display: block; margin-top: 2px; color: rgba(230, 241, 250, .82); font-size: 10.5px; font-weight: 700; letter-spacing: .16em; text-transform: uppercase; text-shadow: 0 2px 10px rgba(0, 0, 0, .6); }

.stage-content { position: relative; z-index: 3; max-width: 540px; }
.stage-eyebrow { display: flex; align-items: center; gap: 13px; margin: 0 0 14px; color: #ffc98d; font-size: 10.5px; font-weight: 800; letter-spacing: .2em; text-transform: uppercase; }
.stage-eyebrow::before { content: ''; width: 0; height: 2px; flex: 0 0 auto; border-radius: 2px; background: linear-gradient(90deg, #ff9d4d, rgba(255, 157, 77, 0)); animation: rule-draw 1.1s .3s cubic-bezier(.2, .7, .3, 1) forwards; }
.stage-eyebrow span { opacity: 0; animation: fade-in .9s .5s forwards; }
.stage-title { margin: 0 0 20px; color: #fff; font-size: clamp(34px, 4.2vw, 58px); line-height: 1.03; letter-spacing: -.025em; text-shadow: 0 8px 34px rgba(0, 0, 0, .5); }
.stage-title > span { display: block; }
.stage-title .accent { color: #ffc98d; }
/* Las palabras las separa assets/app.js; sin JavaScript el titular sale entero y quieto. */
.stage-title .w { display: inline-block; opacity: 0; transform: translateY(.4em) scale(.96); filter: blur(12px); animation: word-in .85s cubic-bezier(.16, .84, .34, 1) forwards; }
.stage-rotator { position: relative; min-height: 54px; margin-bottom: 30px; }
.stage-rotator span { position: absolute; left: 0; top: 0; right: 0; color: rgba(226, 239, 250, .88); font-size: 16px; line-height: 1.55; opacity: 0; transform: translateY(16px); filter: blur(7px); transition: opacity .75s, transform .75s cubic-bezier(.2, .7, .3, 1), filter .75s; }
.stage-rotator span.is-active { opacity: 1; transform: none; filter: blur(0); }
.stage-rotator span.is-leaving { opacity: 0; transform: translateY(-16px); filter: blur(7px); }
.stage-live { display: flex; align-items: center; gap: 11px; margin: 0; color: rgba(212, 228, 242, .72); font-size: 12.5px; animation: fade-up 1s 1.1s both; }
.stage-live time { color: #fff; font-weight: 600; font-variant-numeric: tabular-nums; letter-spacing: .04em; }
.stage-live em { font-style: normal; }
.stage-live em::before { content: '·'; margin-right: 11px; }
.live-dot { width: 8px; height: 8px; flex: 0 0 auto; border-radius: 50%; background: #4ade9b; animation: pulse-green 2.3s ease-out infinite; }

.stage-ticker { position: absolute; z-index: 3; left: 0; right: 0; bottom: 0; padding: 12px 0; overflow: hidden; border-top: 1px solid rgba(255, 255, 255, .1); background: linear-gradient(to top, rgba(4, 11, 18, .72), rgba(4, 11, 18, .16));
    -webkit-mask-image: linear-gradient(90deg, transparent, #000 7%, #000 93%, transparent); mask-image: linear-gradient(90deg, transparent, #000 7%, #000 93%, transparent); }
.ticker-track { display: flex; width: max-content; animation: ticker 44s linear infinite; }
.ticker-track span { display: flex; align-items: center; gap: 24px; padding-right: 24px; color: rgba(204, 223, 240, .62); font-size: 10.5px; font-weight: 700; letter-spacing: .19em; text-transform: uppercase; white-space: nowrap; }
.ticker-track span::after { content: '◆'; color: rgba(255, 157, 77, .6); font-size: 7px; letter-spacing: 0; }

/* --- mitad derecha: el formulario ---------------------------------------- */
.login-form-panel { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 44px 40px; overflow: hidden; background: linear-gradient(152deg, #edf2f7 0%, #e4ecf4 52%, #eef1f4 100%); }
.login-form-panel::before { content: ''; position: absolute; inset: -25%; background:
    radial-gradient(44% 40% at 24% 16%, rgba(15, 111, 181, .18), transparent 72%),
    radial-gradient(40% 38% at 80% 82%, rgba(224, 152, 40, .17), transparent 72%);
    animation: aura 20s ease-in-out infinite alternate; }
.login-card { position: relative; z-index: 1; width: 100%; max-width: 402px; padding: 34px 32px; background: rgba(255, 255, 255, .88); backdrop-filter: blur(14px) saturate(1.25); -webkit-backdrop-filter: blur(14px) saturate(1.25); border: 1px solid rgba(255, 255, 255, .9); border-radius: 20px; box-shadow: 0 30px 64px -26px rgba(11, 32, 52, .38), 0 2px 8px rgba(11, 32, 52, .05); display: flex; flex-direction: column; gap: 13px; animation: card-in .9s cubic-bezier(.16, .84, .34, 1) both; }
.login-card > *:nth-child(n+2) { animation: field-in .6s cubic-bezier(.2, .7, .3, 1) both; }
.login-card > *:nth-child(2) { animation-delay: .2s; }
.login-card > *:nth-child(3) { animation-delay: .26s; }
.login-card > *:nth-child(4) { animation-delay: .32s; }
.login-card > *:nth-child(5) { animation-delay: .38s; }
.login-card > *:nth-child(6) { animation-delay: .44s; }
.login-card > *:nth-child(7) { animation-delay: .5s; }
.login-card > *:nth-child(n+8) { animation-delay: .56s; }
.card-badge { display: inline-flex; align-self: flex-start; align-items: center; gap: 8px; margin: 0; padding: 5px 13px 5px 10px; border-radius: 999px; background: var(--sky); color: var(--blue); font-size: 10px; font-weight: 800; letter-spacing: .13em; text-transform: uppercase; }
.badge-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--blue); animation: pulse-blue 2.3s ease-out infinite; }
.login-card h2 { margin: 2px 0 0; color: var(--navy); font-size: 29px; letter-spacing: -.02em; }
.login-card > p { margin: 0; color: var(--muted); font-size: 13px; }
.login-card label { display: flex; flex-direction: column; gap: 6px; font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.login-card input { padding: 12px 14px; border-radius: 11px; border-color: #d3dee7; background: rgba(255, 255, 255, .92); font-size: 14.5px; transition: border-color .18s, box-shadow .18s, background .18s; }
.login-card input:focus { outline: 0; border-color: var(--blue); background: #fff; box-shadow: 0 0 0 4px rgba(15, 111, 181, .15); }
.login-card .btn-primary { position: relative; overflow: hidden; min-height: 47px; margin-top: 5px; border-radius: 12px; font-size: 14px; background: linear-gradient(135deg, #1683d3, #0b578f); box-shadow: 0 15px 28px -13px rgba(15, 111, 181, .8); }
.login-card .btn-primary::after { content: ''; position: absolute; top: 0; left: -60%; width: 42%; height: 100%; background: linear-gradient(100deg, transparent, rgba(255, 255, 255, .4), transparent); transform: skewX(-18deg); animation: btn-sheen 5.4s 1.8s ease-in-out infinite; }
.login-card .btn-primary:hover { transform: translateY(-2px); box-shadow: 0 20px 32px -13px rgba(15, 111, 181, .9); }
.login-card small { color: var(--muted); font-size: 12px; text-align: center; }
.login-card .otp-input { padding: 15px 10px; font-size: 30px; font-weight: 700; letter-spacing: .42em; text-indent: .42em; text-align: center; }
.auth-link { font-size: 12px; }
.auth-credit { position: relative; z-index: 1; margin: 20px 0 0; color: #9aa8b4; font-size: 11px; text-align: center; animation: fade-in 1s .85s both; }
.auth-credit a { color: #9aa8b4; }
/* El aviso flota sobre la pantalla: si empujara la rejilla, el vídeo dejaría de llenar el alto. */
.login-alert { position: fixed; z-index: 40; top: 20px; left: 50%; width: min(520px, calc(100% - 36px)); margin: 0; transform: translateX(-50%); box-shadow: 0 20px 44px -20px rgba(11, 32, 52, .55); animation: toast-in .6s cubic-bezier(.2, .7, .3, 1) both; }

/* --- variante de contingencia: el mismo montaje, en ámbar ---------------- */
.is-emergency .stage-scrim { background:
    linear-gradient(to top, rgba(22, 12, 6, .95) 0%, rgba(26, 15, 8, .74) 27%, rgba(22, 16, 10, .32) 58%, rgba(20, 16, 12, .14) 100%),
    linear-gradient(to right, rgba(20, 11, 5, .6) 0%, rgba(20, 11, 5, 0) 66%),
    radial-gradient(120% 88% at 50% 32%, rgba(0, 0, 0, 0) 42%, rgba(12, 6, 2, .55) 100%); }
.is-emergency .stage-eyebrow, .is-emergency .stage-title .accent { color: #ffb877; }
.is-emergency .live-dot { background: #f0b429; animation-name: pulse-amber; }
.is-emergency .card-badge { background: #fdf2e3; color: #96591a; }
.is-emergency .badge-dot { background: #d98324; animation-name: pulse-amber; }
.is-emergency .login-card .btn-primary { background: linear-gradient(135deg, #c9762b, #9a5312); box-shadow: 0 15px 28px -13px rgba(154, 83, 18, .8); }
.is-emergency .login-card input:focus { border-color: #c9762b; box-shadow: 0 0 0 4px rgba(201, 118, 43, .16); }

@keyframes stage-drift { from { transform: scale(1.05); } to { transform: scale(1.15) translate3d(-1.6%, -1.2%, 0); } }
@keyframes sheen { 0%, 64% { transform: translateX(-34%); opacity: 0; } 72% { opacity: 1; } 100% { transform: translateX(34%); opacity: 0; } }
@keyframes rule-draw { to { width: 56px; } }
@keyframes word-in { to { opacity: 1; transform: none; filter: blur(0); } }
@keyframes ticker { to { transform: translateX(-50%); } }
@keyframes pulse-green { 0% { box-shadow: 0 0 0 0 rgba(74, 222, 155, .6); } 100% { box-shadow: 0 0 0 13px rgba(74, 222, 155, 0); } }
@keyframes pulse-blue { 0% { box-shadow: 0 0 0 0 rgba(15, 111, 181, .55); } 100% { box-shadow: 0 0 0 9px rgba(15, 111, 181, 0); } }
@keyframes pulse-amber { 0% { box-shadow: 0 0 0 0 rgba(217, 131, 36, .55); } 100% { box-shadow: 0 0 0 11px rgba(217, 131, 36, 0); } }
@keyframes aura { to { transform: translate3d(3%, -3%, 0) scale(1.09); } }
@keyframes card-in { from { opacity: 0; transform: translateY(28px) scale(.985); } }
@keyframes field-in { from { opacity: 0; transform: translateY(12px); } }
@keyframes btn-sheen { 0%, 74% { left: -60%; } 100% { left: 132%; } }
@keyframes fade-in { to { opacity: 1; } }
@keyframes fade-up { from { opacity: 0; transform: translateY(14px); } }
@keyframes fade-down { from { opacity: 0; transform: translateY(-14px); } }
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, -20px); } to { opacity: 1; transform: translate(-50%, 0); } }

/* ----------------------------------------------------------- instalación --- */
.install-body { display: grid; place-items: center; min-height: 100vh; padding: 30px; }
.install-card { max-width: 560px; padding: 34px 32px; background: #fff; border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow); }
.install-card h1 { margin: 8px 0 12px; color: var(--navy); }
.install-card ol { margin: 16px 0; padding-left: 20px; display: flex; flex-direction: column; gap: 10px; }

/* --------------------------------------------------------------- pie ------- */
.system-company-footer { margin-top: 26px; padding-top: 16px; border-top: 1px solid var(--line); color: var(--muted); font-size: 12px; display: flex; flex-wrap: wrap; gap: 4px 14px; align-items: baseline; }
.system-company-footer strong { color: var(--navy); }
.system-credit { margin-left: auto; color: #9aa8b4; }
.system-credit a { color: #9aa8b4; }

/* ------------------------------------------------------------ itinerario -- */
.print-body { background: #eef2f5; padding: 20px; }
.print-toolbar { max-width: 820px; margin: 0 auto 16px; display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.print-toolbar > div { display: flex; gap: 8px; align-items: center; }
.itinerary-sheet { max-width: 820px; margin: 0 auto; padding: 34px 38px; background: #fff; border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow); }
.itinerary-head { display: flex; align-items: center; gap: 18px; padding-bottom: 16px; border-bottom: 3px solid var(--blue); }
.itinerary-head h1 { margin: 0; color: var(--navy); font-size: 22px; text-transform: uppercase; letter-spacing: .02em; }
.itinerary-head p { margin: 3px 0 0; color: var(--muted); font-size: 13px; }
.itinerary-logo { max-width: 120px; max-height: 62px; object-fit: contain; }
.itinerary-ot { margin-left: auto; padding: 8px 16px; background: var(--sky); border-radius: 9px; text-align: center; }
.itinerary-ot span { display: block; color: var(--blue); font-size: 10px; font-weight: 700; letter-spacing: .14em; }
.itinerary-ot strong { color: var(--navy); font-size: 20px; }
.itinerary-table { margin-top: 18px; }
.itinerary-table th { width: 34%; background: #f7fafc; color: var(--navy); font-size: 11.5px; letter-spacing: .04em; text-transform: uppercase; border: 1px solid var(--line); position: static; }
.itinerary-table td { border: 1px solid var(--line); font-size: 13.5px; }
.itinerary-table td.detalle { white-space: normal; line-height: 1.7; }
.itinerary-foot { margin-top: 34px; display: flex; gap: 40px; align-items: flex-end; flex-wrap: wrap; }
.sign { flex: 1 1 200px; text-align: center; }
.sign span { display: block; height: 40px; border-bottom: 1px solid var(--navy); }
.sign small { display: block; margin-top: 6px; color: var(--muted); font-size: 11.5px; }
.print-date { width: 100%; margin: 18px 0 0; color: #9aa8b4; font-size: 11px; }

@media print {
    body.print-body { background: #fff; padding: 0; }
    .print-toolbar { display: none; }
    .itinerary-sheet { max-width: none; margin: 0; padding: 0; border: 0; box-shadow: none; }
    .itinerary-table { page-break-inside: auto; }
}

/* ------------------------------------------------------------ responsive -- */
@media (max-width: 1200px) {
    .chart-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .chart-grid .span-2 { grid-column: span 2; }
    .detail-grid { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 900px) {
    .app-shell { grid-template-columns: minmax(0, 1fr); }
    .sidebar { position: fixed; top: 0; left: 0; width: 246px; transform: translateX(-100%); transition: transform .2s ease; }
    .sidebar.open { transform: none; box-shadow: 0 0 40px rgba(0, 0, 0, .3); }
    .menu-button { display: block; }
    .content, .topbar { padding-left: 18px; padding-right: 18px; }
    .chart-grid { grid-template-columns: minmax(0, 1fr); }
    .chart-grid .span-2 { grid-column: span 1; }
    .login-page { grid-template-columns: minmax(0, 1fr); }
    .calendar { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .calendar-head { display: none; }
}

/* En vertical el vídeo pasa a ser una portada: sigue en pantalla, pero el formulario
   queda debajo sobre fondo sólido en vez de competir con las imágenes. */
@media (max-width: 900px) {
    .login-stage { min-height: 62vh; padding: 26px 24px 58px; }
    .stage-content { max-width: none; }
    .stage-title { font-size: clamp(30px, 8.5vw, 42px); }
    .stage-rotator { min-height: 50px; margin-bottom: 24px; }
    .stage-rotator span { font-size: 14.5px; }
    .login-form-panel { padding: 34px 20px 40px; }
}

@media (max-width: 520px) {
    .login-stage { min-height: 56vh; }
    .stage-ticker { display: none; }
    .login-card { padding: 28px 22px; }
}

/* Quien pide menos movimiento ve la misma pantalla quieta: el vídeo lo pausa app.js. */
@media (prefers-reduced-motion: reduce) {
    .stage-video, .stage-sheen, .ticker-track, .live-dot, .badge-dot, .stage-top, .stage-live,
    .login-form-panel::before, .login-card, .login-card > *, .login-card .btn-primary::after,
    .auth-credit, .login-alert { animation: none; }
    .stage-eyebrow::before { width: 56px; animation: none; }
    .stage-eyebrow span { opacity: 1; animation: none; }
    .stage-title .w { opacity: 1; transform: none; filter: none; animation: none; }
    .stage-rotator span { transition: opacity .3s; }
    .login-card .btn-primary:hover { transform: none; }
}
