/* Paleta semántica común. Los originales y el contenido de los visores no se recolorean. */
:root {
--fd-ui-bg: #f5f7fa;
    --fd-ui-surface: #ffffff;
    --fd-ui-soft: #f0f3f7;
    --fd-ui-text: #203247;
    --fd-ui-muted: #536478;
    --fd-ui-on-solid: #ffffff;
    --fd-ui-border: #dce3ec;
    --fd-ui-primary: #1a4b84;
    --fd-ui-primary-hover: #163f70;
    --fd-ui-link: #1857a0;
    --fd-ui-info-soft: #eaf2ff;
    --fd-ui-info-ink: #205792;
    --fd-ui-info-solid: #087990;
    --fd-ui-success-soft: #e7f5ed;
    --fd-ui-success-ink: #14633d;
    --fd-ui-success-solid: #137947;
    --fd-ui-warning-soft: #fff3dc;
    --fd-ui-warning-ink: #875200;
    --fd-ui-warning-solid: #955700;
    --fd-ui-danger-soft: #fff0ee;
    --fd-ui-danger-ink: #b42332;
    --fd-ui-danger-solid: #b42332;
    --fd-ui-violet-soft: #f0ecff;
    --fd-ui-violet-ink: #6346a5;
    --fd-ui-violet-solid: #694bb3;
    --fd-ui-neutral-solid: #526477;
    --fd-ui-surface-rgb: 255, 255, 255;
    --fd-ui-soft-rgb: 240, 243, 247;
    --fd-ui-text-rgb: 32, 50, 71;
    --fd-ui-primary-rgb: 26, 75, 132;
    --fd-ui-on-solid-rgb: 255, 255, 255;
    --fd-ui-border-rgb: 220, 227, 236;
    --fd-ui-success-solid-rgb: 19, 121, 71;
    --fd-ui-warning-solid-rgb: 149, 87, 0;
    --fd-ui-danger-solid-rgb: 180, 35, 50;
    --fd-ui-violet-solid-rgb: 105, 75, 179;
    --fd-ui-neutral-solid-rgb: 82, 100, 119;
    --fd-ui-info-solid-rgb: 8, 121, 144;
    --fd-ui-shadow-rgb: 20, 38, 62;
    --fd-ui-overlay-rgb: 12, 22, 37;
    --fd-ui-bg-rgb: 245, 247, 250;
    --fd-ui-muted-rgb: 83, 100, 120;
    --fd-ui-primary-hover-rgb: 22, 63, 112;
    --fd-ui-link-rgb: 24, 87, 160;
    --fd-ui-info-soft-rgb: 234, 242, 255;
    --fd-ui-info-ink-rgb: 32, 87, 146;
    --fd-ui-success-soft-rgb: 231, 245, 237;
    --fd-ui-success-ink-rgb: 20, 99, 61;
    --fd-ui-warning-soft-rgb: 255, 243, 220;
    --fd-ui-warning-ink-rgb: 135, 82, 0;
    --fd-ui-danger-soft-rgb: 255, 240, 238;
    --fd-ui-danger-ink-rgb: 180, 35, 50;
    --fd-ui-violet-soft-rgb: 240, 236, 255;
    --fd-ui-violet-ink-rgb: 99, 70, 165;
}
html[data-fd-theme="dark"] {
--fd-ui-bg: #111923;
    --fd-ui-surface: #1a2532;
    --fd-ui-soft: #243243;
    --fd-ui-text: #e8eef6;
    --fd-ui-muted: #b2c0d0;
    --fd-ui-border: #3b4d62;
    --fd-ui-primary: #2868b2;
    --fd-ui-primary-hover: #3379c7;
    --fd-ui-link: #9fc9ff;
    --fd-ui-info-soft: #223b57;
    --fd-ui-info-ink: #b6d7ff;
    --fd-ui-success-soft: #203e32;
    --fd-ui-success-ink: #a0e2bc;
    --fd-ui-warning-soft: #493821;
    --fd-ui-warning-ink: #ffda91;
    --fd-ui-danger-soft: #4a2831;
    --fd-ui-danger-ink: #ffb7c0;
    --fd-ui-violet-soft: #352d50;
    --fd-ui-violet-ink: #d0bfff;
    --fd-ui-surface-rgb: 26, 37, 50;
    --fd-ui-soft-rgb: 36, 50, 67;
    --fd-ui-text-rgb: 232, 238, 246;
    --fd-ui-primary-rgb: 40, 104, 178;
    --fd-ui-border-rgb: 59, 77, 98;
    --fd-ui-shadow-rgb: 0, 0, 0;
    --fd-ui-bg-rgb: 17, 25, 35;
    --fd-ui-muted-rgb: 178, 192, 208;
    --fd-ui-primary-hover-rgb: 51, 121, 199;
    --fd-ui-link-rgb: 159, 201, 255;
    --fd-ui-info-soft-rgb: 34, 59, 87;
    --fd-ui-info-ink-rgb: 182, 215, 255;
    --fd-ui-success-soft-rgb: 32, 62, 50;
    --fd-ui-success-ink-rgb: 160, 226, 188;
    --fd-ui-warning-soft-rgb: 73, 56, 33;
    --fd-ui-warning-ink-rgb: 255, 218, 145;
    --fd-ui-danger-soft-rgb: 74, 40, 49;
    --fd-ui-danger-ink-rgb: 255, 183, 192;
    --fd-ui-violet-soft-rgb: 53, 45, 80;
    --fd-ui-violet-ink-rgb: 208, 191, 255;
}
/* Alias para componentes migrados con diferentes nombres de variables. */
html[data-fd-theme] {
    --shell-bg: var(--fd-ui-bg);
    --panel-bg: var(--fd-ui-surface);
    --panel-background: var(--fd-ui-surface);
    --panel-border: var(--fd-ui-border);
    --text: var(--fd-ui-text);
    --primary: var(--fd-ui-primary);
    --accent: var(--fd-ui-link);
    --topbar-bg: var(--fd-ui-surface);
    --topbar-border: var(--fd-ui-border);
    --topbar-muted: var(--fd-ui-muted);
    --shell-text: var(--fd-ui-text);
    --text-primary: var(--fd-ui-text);
    --text-secondary: var(--fd-ui-muted);
    --text-muted: var(--fd-ui-muted);
    --shell-muted: var(--fd-ui-muted);
    --shell-border: var(--fd-ui-border);
    --surface: var(--fd-ui-surface);
    --surface-muted: var(--fd-ui-soft);
    --muted: var(--fd-ui-muted);
    --border: var(--fd-ui-border);
    --action-icon-bg: var(--fd-ui-surface);
    --action-icon-bg-hover: var(--fd-ui-soft);
    --action-icon-bg-active: var(--fd-ui-info-soft);
    --action-icon-border: var(--fd-ui-border);
    --action-icon-border-hover: var(--fd-ui-link);
    --action-icon-border-active: var(--fd-ui-link);
    --action-icon-color: var(--fd-ui-link);
    --action-icon-color-active: var(--fd-ui-link);
    --action-icon-favorite-color: var(--fd-ui-warning-ink);
    --sidebar-bg: #193b69;
    --sidebar-text: #edf3ff;
    background: var(--fd-ui-bg);
    color: var(--fd-ui-text);
}
html[data-fd-theme="dark"] {
--sidebar-bg: #142337;
}
html[data-fd-theme] body { color: var(--fd-ui-text); }
.fd-theme-picker { display: inline-flex; align-items: center; gap: .4rem; min-width: 0; font-size: .8rem; color: var(--fd-ui-muted); }
/* Solo durante el cambio de paleta, sin interrumpir animaciones de carga ni operaciones. */
html[data-fd-theme-changing] *,
html[data-fd-theme-changing] *::before,
html[data-fd-theme-changing] *::after { transition: none !important; }
.fd-theme-picker select { font: inherit; color: var(--fd-ui-text); background: var(--fd-ui-surface); border: 1px solid var(--fd-ui-border); border-radius: 8px; min-height: 36px; padding: .45rem .55rem; max-width: 100%; }
/* En login flota sobre la esquina superior derecha, sin ocupar una franja propia que empuje el layout. */
.fd-theme-picker--login { position: fixed; top: 14px; right: 24px; z-index: 5; display: flex; justify-content: flex-end; }
.fd-theme-picker--login .fd-theme-picker select { min-height: 32px; padding: .3rem .5rem; font-size: .75rem; box-shadow: 0 1px 4px rgba(var(--fd-ui-shadow-rgb), .12); }
@media (max-width: 960px) {
    .fd-theme-picker--login { top: 8px; right: 12px; }
}
.fd-theme-picker--viewer { position: relative; display: flex; justify-content: flex-end; padding: 8px 14px; background: var(--fd-ui-surface); border-bottom: 1px solid var(--fd-ui-border); }
html[data-fd-theme] .main { min-width: 0; }
html[data-fd-theme] .topbar { grid-template-columns: minmax(0, .7fr) minmax(12rem, 1fr) auto; padding: 12px 20px; gap: 12px; }
html[data-fd-theme] .topbar--no-title { grid-template-columns: minmax(12rem, 1fr) auto; }
html[data-fd-theme] .topbar__right { flex-wrap: wrap; gap: 8px; min-width: 0; }
html[data-fd-theme] .topbar-user { min-width: 0; }
html[data-fd-theme] .topbar-user__summary { overflow-wrap: anywhere; }
html[data-fd-theme] .topbar-search { min-width: 0; border-radius: 8px; background: var(--fd-ui-soft); }
html[data-fd-theme] .topbar-language select { padding: 8px 10px; border-radius: 8px; }
html[data-fd-theme] .panel { border-radius: 12px; box-shadow: 0 3px 14px rgba(var(--fd-ui-shadow-rgb), .05); }
html[data-fd-theme] .sidebar { box-shadow: none; }
html[data-fd-theme] .sidebar-link--active { box-shadow: none; border-radius: 8px; }
html[data-fd-theme] .content { min-width: 0; padding: 22px; }
html[data-fd-theme] .panel { min-width: 0; }
html[data-fd-theme] .native-viewer { background: var(--fd-ui-bg); }
html[data-fd-theme] .native-viewer__bar { background: var(--fd-ui-surface); color: var(--fd-ui-text); border-bottom: 1px solid var(--fd-ui-border); }
html[data-fd-theme] .shipment-table th { background: var(--fd-ui-soft); color: var(--fd-ui-text); text-transform: none; border-bottom: 1px solid var(--fd-ui-border); }
html[data-fd-theme] .shipment-subtitle { color: var(--fd-ui-text); text-transform: none; font-weight: 600; }
html[data-fd-theme] .fd-confirm-dialog__panel { background: var(--fd-ui-surface); color: var(--fd-ui-text); border-radius: 12px; }
html[data-fd-theme] .fd-confirm-dialog__button { border-radius: 8px; }
html[data-fd-theme] :where(button, a, input, select, textarea, summary):focus-visible { outline: 2px solid var(--fd-ui-link); outline-offset: 3px; }
html[data-fd-theme] :where(input, select, textarea) { accent-color: var(--fd-ui-primary); }
@media (max-width: 1180px) {
    html[data-fd-theme] .topbar,
    html[data-fd-theme] .shell--sidebar-collapsed .topbar,
    html[data-fd-theme] .shell--sidebar-collapsed .topbar--no-title { grid-template-columns: minmax(0, 1fr); }
    html[data-fd-theme] .topbar__right { justify-content: flex-start; }
}
@media (max-width: 960px) {
    html[data-fd-theme] .dbm-stage,
    html[data-fd-theme] .dbm-stage--collapsed { grid-template-columns: minmax(0, 1fr); }
    html[data-fd-theme] .sidebar { height: auto; max-height: none; position: relative; }
    html[data-fd-theme] .content { padding: 14px; }
    html[data-fd-theme] .topbar { position: relative; padding: 12px 14px; }
    html[data-fd-theme] .topbar-quick-links,
    html[data-fd-theme] .topbar-language,
    html[data-fd-theme] .topbar-user { width: auto; }
    html[data-fd-theme] .topbar-quick-links { justify-content: flex-start; }
    html[data-fd-theme] .topbar-alerts__panel,
    html[data-fd-theme] .topbar-user__panel { width: min(320px, calc(100vw - 32px)); }
}
@media (prefers-reduced-motion: reduce) {
    html[data-fd-theme] .module-card,
    html[data-fd-theme] .fd-confirm-dialog__button { transition: none; }
}
/* La impresión usa el aspecto claro sin modificar la preferencia guardada. */
@media print {
    html[data-fd-theme] { color-scheme: light; }
    html[data-fd-theme] body { background: #ffffff; color: #111111; }
    .fd-theme-picker { display: none; }
}

html[data-fd-theme] .dmsi-shell { background: var(--fd-ui-bg); }
html[data-fd-theme] .legacy-properties { font-family: "Nunito", "Segoe UI", sans-serif; }

/* Paleta clara para impresión */
@media print {
    html[data-fd-theme] {
--fd-ui-bg: #f5f7fa;
    --fd-ui-surface: #ffffff;
    --fd-ui-soft: #f0f3f7;
    --fd-ui-text: #203247;
    --fd-ui-muted: #536478;
    --fd-ui-on-solid: #ffffff;
    --fd-ui-border: #dce3ec;
    --fd-ui-primary: #1a4b84;
    --fd-ui-primary-hover: #163f70;
    --fd-ui-link: #1857a0;
    --fd-ui-info-soft: #eaf2ff;
    --fd-ui-info-ink: #205792;
    --fd-ui-info-solid: #087990;
    --fd-ui-success-soft: #e7f5ed;
    --fd-ui-success-ink: #14633d;
    --fd-ui-success-solid: #137947;
    --fd-ui-warning-soft: #fff3dc;
    --fd-ui-warning-ink: #875200;
    --fd-ui-warning-solid: #955700;
    --fd-ui-danger-soft: #fff0ee;
    --fd-ui-danger-ink: #b42332;
    --fd-ui-danger-solid: #b42332;
    --fd-ui-violet-soft: #f0ecff;
    --fd-ui-violet-ink: #6346a5;
    --fd-ui-violet-solid: #694bb3;
    --fd-ui-neutral-solid: #526477;
    --fd-ui-surface-rgb: 255, 255, 255;
    --fd-ui-soft-rgb: 240, 243, 247;
    --fd-ui-text-rgb: 32, 50, 71;
    --fd-ui-primary-rgb: 26, 75, 132;
    --fd-ui-on-solid-rgb: 255, 255, 255;
    --fd-ui-border-rgb: 220, 227, 236;
    --fd-ui-success-solid-rgb: 19, 121, 71;
    --fd-ui-warning-solid-rgb: 149, 87, 0;
    --fd-ui-danger-solid-rgb: 180, 35, 50;
    --fd-ui-violet-solid-rgb: 105, 75, 179;
    --fd-ui-neutral-solid-rgb: 82, 100, 119;
    --fd-ui-info-solid-rgb: 8, 121, 144;
    --fd-ui-shadow-rgb: 20, 38, 62;
    --fd-ui-overlay-rgb: 12, 22, 37;
    --fd-ui-bg-rgb: 245, 247, 250;
    --fd-ui-muted-rgb: 83, 100, 120;
    --fd-ui-primary-hover-rgb: 22, 63, 112;
    --fd-ui-link-rgb: 24, 87, 160;
    --fd-ui-info-soft-rgb: 234, 242, 255;
    --fd-ui-info-ink-rgb: 32, 87, 146;
    --fd-ui-success-soft-rgb: 231, 245, 237;
    --fd-ui-success-ink-rgb: 20, 99, 61;
    --fd-ui-warning-soft-rgb: 255, 243, 220;
    --fd-ui-warning-ink-rgb: 135, 82, 0;
    --fd-ui-danger-soft-rgb: 255, 240, 238;
    --fd-ui-danger-ink-rgb: 180, 35, 50;
    --fd-ui-violet-soft-rgb: 240, 236, 255;
    --fd-ui-violet-ink-rgb: 99, 70, 165;
    }
}
