/* F6 (15/11/2026): traduce el vocabulario de lightning al sistema del perfil.
   Los tokens legacy conservan el valor claro y adoptan el oscuro del perfil.
   Se carga DESPUÉS de lightning y de los tokens. Reversa del puente: quitar
   este link de las tres páginas; lightning.css permanece intacto.
   Sin data-theme se usa claro, independientemente del tema del sistema. */
html[data-theme="light"],
html[data-theme="dark"],
:root:not([data-theme]) {
    --font-ui: var(--sx-font);
    --bg: var(--sx-legacy-bg);
    --bg-app: var(--sx-legacy-bg);
    --panel: var(--sx-surface);
    --bg-panel: var(--sx-surface);
    --ink: var(--sx-legacy-ink);
    --text: var(--sx-legacy-ink);
    --ink-2: var(--sx-legacy-ink-2);
    --ink-3: var(--sx-legacy-ink-3);
    --muted: var(--sx-legacy-muted);
    --line: var(--sx-legacy-border);
    --border: var(--sx-legacy-border);
    --brand: var(--sx-accent);
    --brand-dark: var(--sx-accent-hover);
    --head: var(--sx-legacy-head);
    --bg-surface: var(--sx-surface-2);
    --card-bg: var(--sx-surface);
    --text-primary: var(--sx-legacy-ink);
    --border-color: var(--sx-border);
}

/* En body solo se fuerza Inter: los alias claros de lightning conservan su cascada. */
html[data-theme] body:not(.force-dark),
html:not([data-theme]) body:not(.force-dark),
html[data-theme] body.force-dark {
    font-family: var(--sx-font);
}

html[data-theme="dark"] {
    --bg-deep: var(--sx-bg);
    --bg-elevated: var(--sx-surface-2);
    --border-light: var(--sx-border);
    --line-strong: var(--sx-border);
    --stat-card-bg: var(--sx-surface);
    --filter-bar-bg: var(--sx-surface);
    --filter-input-bg: var(--sx-surface);
    --table-bg: var(--sx-surface);
    --table-header-bg: var(--sx-surface-2);
}

/* Ventana estándar (rediseño visual, 02/12/2026) */
.io-modal.sx-win { max-height: 90vh; }
.io-modal.sx-win-s {
    width: min(480px, 92vw);
    max-width: min(480px, 92vw);
}
.io-modal.sx-win-m {
    width: min(760px, 92vw);
    max-width: min(760px, 92vw);
}
.io-modal.sx-win-l {
    width: min(92vw, clamp(900px, 64vw, 1280px));
    max-width: min(92vw, clamp(900px, 64vw, 1280px));
}
.io-modal.sx-win-xl {
    width: min(92vw, clamp(1040px, 80vw, 1680px));
    max-width: min(92vw, clamp(1040px, 80vw, 1680px));
}

/* F3: las mismas tallas para cualquier otra ventana (Stock, Movimientos, Carga, Logística…): se añade la clase
   `sx-win sx-win-<talla>` a la caja de la ventana (no al fondo). `.io-modal` sigue con sus reglas de arriba. */
.sx-win:not(.io-modal) { max-height: 90vh; overflow: auto; box-sizing: border-box; }
.sx-win-s:not(.io-modal) { width: min(480px, 92vw); max-width: min(480px, 92vw); }
.sx-win-m:not(.io-modal) { width: min(760px, 92vw); max-width: min(760px, 92vw); }
.sx-win-l:not(.io-modal) { width: min(92vw, clamp(900px, 64vw, 1280px)); max-width: min(92vw, clamp(900px, 64vw, 1280px)); }
.sx-win-xl:not(.io-modal) { width: min(92vw, clamp(1040px, 80vw, 1680px)); max-width: min(92vw, clamp(1040px, 80vw, 1680px)); }

@media (max-width: 768px) {
    .sx-win:not(.io-modal) { max-height: calc(100vh - 20px); }
    .sx-win-s:not(.io-modal), .sx-win-m:not(.io-modal),
    .sx-win-l:not(.io-modal), .sx-win-xl:not(.io-modal) { width: 100%; max-width: 100%; }
    .io-modal.sx-win { max-height: calc(100vh - 20px); }
    .io-modal.sx-win-s, .io-modal.sx-win-m,
    .io-modal.sx-win-l, .io-modal.sx-win-xl {
        width: 100%;
        max-width: 100%;
    }
}
