/* ==========================================================================
   BIBLIOTECA DIGITAL - TEMA GLOBAL MULTIPALETA CENTRALIZADO
   ========================================================================== */
:root {
  color-scheme: light;
  --fs-theme-bg: #f5f8fc;
  --fs-theme-surface: #ffffff;
  --fs-theme-surface-alt: #edf3fa;
  --fs-theme-text: #26384d;
  --fs-theme-muted: #617187;
  --fs-theme-border: #d5e0ec;
  --fs-theme-accent: #145374;
  --fs-theme-accent-hover: #0f425d;
  --fs-theme-accent-soft: #dce8fa;
  --fs-theme-accent-text: #ffffff;
  --fs-theme-focus: #2f78a0;
    --fs-theme-shadow: 0 8px 24px rgba(27,54,79,.09);
  --fs-success: #17a65a;
  --fs-warning: #f59e0b;
  --fs-danger: #ef4444;
  --fs-info: #06b6d4;
  --fs-theme-success: #16834a;
  --fs-theme-success-soft: #e9f6ee;
  --fs-theme-success-text: #17613a;
  --fs-theme-warning: #9a6700;
  --fs-theme-warning-soft: #fff5db;
  --fs-theme-warning-text: #704b00;
  --fs-theme-danger: #b42332;
  --fs-theme-danger-soft: #fdebed;
  --fs-theme-danger-text: #8f1d29;
  --fs-theme-info: #2563a6;
  --fs-theme-info-soft: #eaf2fb;
  --fs-theme-info-text: #1e4d7c;
  --fs-theme-surface-hover: #e9eff6;
  --fs-theme-overlay: rgb(15 23 42 / .56);
  --fs-theme-danger-contrast: #ffffff;
  --fs-font: 'Inter', system-ui, -apple-system, sans-serif;
  --fs-font-size: 14px;

  /* Mapeo predeterminado de compatibilidad */
  --fs-bg-main: var(--fs-theme-bg);
  --fs-bg-card: var(--fs-theme-surface);
  --fs-text-main: var(--fs-theme-text);
  --fs-text-muted: var(--fs-theme-muted);
  --fs-border: var(--fs-theme-border);
  --fs-primary: var(--fs-theme-accent);
  --fs-primary-hover: var(--fs-theme-accent-hover);
  --fs-secondary: var(--fs-theme-muted);
  --fs-shadow: var(--fs-theme-shadow);
  --ink: var(--fs-theme-text);
  --muted: var(--fs-theme-muted);
  --line: var(--fs-theme-border);
  --surface: var(--fs-theme-surface);
  --bg: var(--fs-theme-bg);
  --surface-bg: var(--fs-theme-surface);
  --page-bg: var(--fs-theme-bg);
  --background-color: var(--fs-theme-bg);
  --soft: var(--fs-theme-accent-soft);
  --brand: var(--fs-theme-accent);
  --brand-dark: var(--fs-theme-accent-hover);
}

/* Paletas temáticas */
html[data-fs-palette="azul-petroleo"] {
  --fs-theme-accent: #145374;
  --fs-theme-accent-hover: #0f425d;
  --fs-theme-accent-soft: #dce8fa;
  --fs-theme-accent-text: #ffffff;
  --fs-theme-focus: #2f78a0;
  --fs-gradient: linear-gradient(135deg, #145374 0%, #236f91 100%);
}
html[data-fs-palette="menta-bosque"] {
  --fs-theme-accent: #176b50;
  --fs-theme-accent-hover: #10533d;
  --fs-theme-accent-soft: #d9eee5;
  --fs-theme-accent-text: #ffffff;
  --fs-theme-focus: #258568;
  --fs-gradient: linear-gradient(135deg, #176b50 0%, #238365 100%);
}
html[data-fs-palette="lavanda-violeta"] {
  --fs-theme-accent: #5b3a91;
  --fs-theme-accent-hover: #452b72;
  --fs-theme-accent-soft: #e9dff7;
  --fs-theme-accent-text: #ffffff;
  --fs-theme-focus: #7853ad;
  --fs-gradient: linear-gradient(135deg, #5b3a91 0%, #7954ad 100%);
}
html[data-fs-palette="durazno-terracota"] {
  --fs-theme-accent: #a7472d;
  --fs-theme-accent-hover: #853821;
  --fs-theme-accent-soft: #f8e5d8;
  --fs-theme-accent-text: #ffffff;
  --fs-theme-focus: #c46648;
  --fs-gradient: linear-gradient(135deg, #a7472d 0%, #c46648 100%);
}
html[data-fs-palette="crema-azul-noche"] {
  --fs-theme-accent: #243b64;
  --fs-theme-accent-hover: #182b4b;
  --fs-theme-accent-soft: #f6efcf;
  --fs-theme-accent-text: #ffffff;
  --fs-theme-focus: #486ca4;
  --fs-gradient: linear-gradient(135deg, #243b64 0%, #355889 100%);
}
html[data-fs-palette="perla-electrico"] {
  --fs-theme-accent: #2457c5;
  --fs-theme-accent-hover: #19439c;
  --fs-theme-accent-soft: #e7eaf0;
  --fs-theme-accent-text: #ffffff;
  --fs-theme-focus: #4778df;
  --fs-gradient: linear-gradient(135deg, #2457c5 0%, #4778df 100%);
}

/* Modo Claro Explícito */
html[data-fs-theme="light"] {
  color-scheme: light;
  --fs-theme-bg: #f5f8fc;
  --fs-theme-surface: #ffffff;
  --fs-theme-surface-alt: #edf3fa;
  --fs-theme-text: #26384d;
  --fs-theme-muted: #617187;
  --fs-theme-border: #d5e0ec;
    --fs-theme-shadow: 0 8px 24px rgba(27,54,79,.09);
  --fs-success: #17a65a;
  --fs-warning: #f59e0b;
  --fs-danger: #ef4444;
  --fs-info: #06b6d4;
  --fs-theme-success-soft: #e9f6ee;
  --fs-theme-success-text: #17613a;
  --fs-theme-warning-soft: #fff5db;
  --fs-theme-warning-text: #704b00;
  --fs-theme-danger-soft: #fdebed;
  --fs-theme-danger-text: #8f1d29;
  --fs-theme-info-soft: #eaf2fb;
  --fs-theme-info-text: #1e4d7c;
  --fs-theme-surface-hover: #e9eff6;
  --fs-theme-overlay: rgb(15 23 42 / .56);
  --fs-theme-danger-contrast: #ffffff;
}

/* Modo Oscuro Global - Sincronizado por Atributo o Clases */
html[data-fs-theme="dark"],
html.fs-dark-mode,
body.fs-dark-mode,
html.dark,
body.dark {
  color-scheme: dark;
  --fs-theme-bg: #111827;
  --fs-theme-surface: #1e293b;
  --fs-theme-surface-alt: #162032;
  --fs-theme-text: #edf2f8;
  --fs-theme-muted: #94a3b8;
  --fs-theme-border: #334155;
  --fs-theme-shadow: 0 10px 28px rgba(0,0,0,.35);
  --fs-theme-success: #65d391;
  --fs-theme-success-soft: #183b2a;
  --fs-theme-success-text: #a7edc1;
  --fs-theme-warning: #f4c15d;
  --fs-theme-warning-soft: #3b3019;
  --fs-theme-warning-text: #f8d98d;
  --fs-theme-danger: #ff8791;
  --fs-theme-danger-soft: #44242b;
  --fs-theme-danger-text: #ffb2b8;
  --fs-theme-info: #83b9f2;
  --fs-theme-info-soft: #1d344d;
  --fs-theme-info-text: #b2d5fb;
  --fs-theme-surface-hover: #28384e;
  --fs-theme-overlay: rgb(0 0 0 / .72);
  --fs-theme-danger-contrast: #351217;

  --fs-bg-main: var(--fs-theme-bg);
  --fs-bg-card: var(--fs-theme-surface);
  --fs-text-main: var(--fs-theme-text);
  --fs-text-muted: var(--fs-theme-muted);
  --fs-border: var(--fs-theme-border);
  --fs-shadow: var(--fs-theme-shadow);
  --ink: var(--fs-theme-text);
  --muted: var(--fs-theme-muted);
  --line: var(--fs-theme-border);
  --surface: var(--fs-theme-surface);
  --bg: var(--fs-theme-bg);
  --surface-bg: var(--fs-theme-surface);
  --page-bg: var(--fs-theme-bg);
  --background-color: var(--fs-theme-bg);
  --soft: var(--fs-theme-accent-soft);
}

/* Ajustes de Acento en Modo Oscuro */
html[data-fs-theme="dark"][data-fs-palette="azul-petroleo"],
html.fs-dark-mode[data-fs-palette="azul-petroleo"],
body.fs-dark-mode[data-fs-palette="azul-petroleo"] {
  --fs-theme-accent: #77b8d7; --fs-theme-accent-hover: #9bcfe7;
  --fs-theme-accent-soft: #263f53; --fs-theme-accent-text: #102735;
  --fs-theme-focus: #9bcfe7; --fs-gradient: linear-gradient(135deg,#17445d,#245f7c);
}
html[data-fs-theme="dark"][data-fs-palette="menta-bosque"],
html.fs-dark-mode[data-fs-palette="menta-bosque"],
body.fs-dark-mode[data-fs-palette="menta-bosque"] {
  --fs-theme-accent: #78d5b0; --fs-theme-accent-hover: #9ae5c8;
  --fs-theme-accent-soft: #23483d; --fs-theme-accent-text: #102d23;
  --fs-theme-focus: #9ae5c8; --fs-gradient: linear-gradient(135deg,#205844,#2b7559);
}
html[data-fs-theme="dark"][data-fs-palette="lavanda-violeta"],
html.fs-dark-mode[data-fs-palette="lavanda-violeta"],
body.fs-dark-mode[data-fs-palette="lavanda-violeta"] {
  --fs-theme-accent: #c3a5f2; --fs-theme-accent-hover: #d5c0fa;
  --fs-theme-accent-soft: #403451; --fs-theme-accent-text: #291b3b;
  --fs-theme-focus: #d5c0fa; --fs-gradient: linear-gradient(135deg,#493367,#67478f);
}
html[data-fs-theme="dark"][data-fs-palette="durazno-terracota"],
html.fs-dark-mode[data-fs-palette="durazno-terracota"],
body.fs-dark-mode[data-fs-palette="durazno-terracota"] {
  --fs-theme-accent: #f0a58c; --fs-theme-accent-hover: #ffc0aa;
  --fs-theme-accent-soft: #50372f; --fs-theme-accent-text: #3c2118;
  --fs-theme-focus: #ffc0aa; --fs-gradient: linear-gradient(135deg,#713d31,#96513d);
}
html[data-fs-theme="dark"][data-fs-palette="crema-azul-noche"],
html.fs-dark-mode[data-fs-palette="crema-azul-noche"],
body.fs-dark-mode[data-fs-palette="crema-azul-noche"] {
  --fs-theme-accent: #a8c5ff; --fs-theme-accent-hover: #c2d5ff;
  --fs-theme-accent-soft: #35415a; --fs-theme-accent-text: #1a2944;
  --fs-theme-focus: #c2d5ff; --fs-gradient: linear-gradient(135deg,#273e65,#3a5683);
}
html[data-fs-theme="dark"][data-fs-palette="perla-electrico"],
html.fs-dark-mode[data-fs-palette="perla-electrico"],
body.fs-dark-mode[data-fs-palette="perla-electrico"] {
  --fs-theme-accent: #9db8ff; --fs-theme-accent-hover: #bfd0ff;
  --fs-theme-accent-soft: #303d5b; --fs-theme-accent-text: #1b2a4a;
  --fs-theme-focus: #bfd0ff; --fs-gradient: linear-gradient(135deg,#2e4d91,#4267b2);
}

/* Aplicación estructural unificada */
html[data-fs-theme] body,
html.fs-dark-mode body,
body.fs-dark-mode {
  background-color: var(--fs-theme-bg);
  color: var(--fs-theme-text);
  font-family: var(--fs-font);
  font-size: var(--fs-font-size);
}

html[data-fs-theme] :where(button, input, select, textarea),
html.fs-dark-mode :where(button, input, select, textarea),
body.fs-dark-mode :where(button, input, select, textarea) {
  accent-color: var(--fs-theme-accent);
  border-color: var(--fs-theme-border);
  color: var(--fs-theme-text);
}

html[data-fs-theme] :where(button, a, input, select, textarea, summary):focus-visible,
html.fs-dark-mode :where(button, a, input, select, textarea, summary):focus-visible,
body.fs-dark-mode :where(button, a, input, select, textarea, summary):focus-visible {
  outline-color: var(--fs-theme-focus);
  outline-offset: 2px;
}

/* Sincronización con Bootstrap */
html[data-fs-theme],
html.fs-dark-mode,
body.fs-dark-mode {
  --bs-primary: var(--fs-theme-accent);
  --bs-body-color: var(--fs-theme-text);
  --bs-body-bg: var(--fs-theme-bg);
  --bs-border-color: var(--fs-theme-border);
  --bs-link-color: var(--fs-theme-accent);
  --bs-link-hover-color: var(--fs-theme-accent-hover);
}

:where(.card, .modal-content, .dropdown-menu, .popover, .list-group-item, .accordion-item) {
  background-color: var(--fs-theme-surface);
  color: var(--fs-theme-text);
  border-color: var(--fs-theme-border);
}

/* Botones de Administración de Normativas: estilo unificado y multitema. */
html[data-fs-theme] .bs-btn,
html.fs-dark-mode .bs-btn,
body.fs-dark-mode .bs-btn {
  background: var(--fs-theme-accent);
  border: 1px solid var(--fs-theme-accent);
  color: var(--fs-theme-accent-text);
  -webkit-text-fill-color: var(--fs-theme-accent-text);
}
html[data-fs-theme] .bs-btn:hover:not(:disabled),
html.fs-dark-mode .bs-btn:hover:not(:disabled),
body.fs-dark-mode .bs-btn:hover:not(:disabled) {
  background: var(--fs-theme-accent-hover);
  border-color: var(--fs-theme-accent-hover);
  color: var(--fs-theme-accent-text);
  -webkit-text-fill-color: var(--fs-theme-accent-text);
}
html[data-fs-theme] .bs-tabs a:hover,
html.fs-dark-mode .bs-tabs a:hover,
body.fs-dark-mode .bs-tabs a:hover {
  border-color: var(--fs-theme-accent);
  background: var(--fs-theme-accent-soft);
  color: var(--fs-theme-text);
}
html[data-fs-theme] .bs-tabs a.active,
html.fs-dark-mode .bs-tabs a.active,
body.fs-dark-mode .bs-tabs a.active {
  background: var(--fs-theme-accent);
  border-color: var(--fs-theme-accent);
  color: var(--fs-theme-accent-text);
  -webkit-text-fill-color: var(--fs-theme-accent-text);
  box-shadow: var(--fs-theme-shadow);
}

/* Botones principales: color y contraste centralizados para todas las pantallas y temas. */
html[data-fs-theme] :where(.btn-primary, .btn.btn-primary, .bib-btn:not(.is-light), .pf-btn-primary),
html.fs-dark-mode :where(.btn-primary, .btn.btn-primary, .bib-btn:not(.is-light), .pf-btn-primary),
body.fs-dark-mode :where(.btn-primary, .btn.btn-primary, .bib-btn:not(.is-light), .pf-btn-primary) {
  background: var(--fs-theme-accent);
  border-color: var(--fs-theme-accent);
  color: var(--fs-theme-accent-text);
}

html[data-fs-theme] :where(.btn-primary, .btn.btn-primary, .bib-btn:not(.is-light), .pf-btn-primary):hover,
html.fs-dark-mode :where(.btn-primary, .btn.btn-primary, .bib-btn:not(.is-light), .pf-btn-primary):hover,
body.fs-dark-mode :where(.btn-primary, .btn.btn-primary, .bib-btn:not(.is-light), .pf-btn-primary):hover {
  background: var(--fs-theme-accent-hover);
  border-color: var(--fs-theme-accent-hover);
  color: var(--fs-theme-accent-text);
}

/* Botón del selector flotante: el color del texto sigue la paleta activa. */
html[data-fs-theme] .fs-theme-dock-trigger,
html.fs-dark-mode .fs-theme-dock-trigger,
body.fs-dark-mode .fs-theme-dock-trigger {
  color: var(--fs-theme-accent-text);
}

/* Dock selector de temas */
.fs-theme-dock {
  position: fixed !important;
  z-index: 1090;
  top: 50%;
  right: 0;
  transform: translateY(-50%);
  display: flex;
  flex-direction: row-reverse;
  align-items: center;
  max-width: 100vw;
  font: 13px/1.4 var(--fs-font);
  color: var(--fs-theme-text);
}
.fs-theme-dock[hidden] { display: none !important; }
.fs-theme-dock-trigger {
  flex: 0 0 38px;
  align-self: center;
  width: 38px;
  min-height: 48px;
  padding: 0;
  border: 1px solid var(--fs-theme-border);
  border-left: 0;
  border-radius: 0 12px 12px 0;
  background: var(--fs-theme-accent);
  color: var(--fs-theme-accent-text);
  box-shadow: var(--fs-theme-shadow);
  cursor: pointer;
  font: 18px/1 var(--fs-font);
}
.fs-theme-dock-panel {
  display: none;
  box-sizing: border-box;
  width: 258px;
  max-width: calc(100vw - 40px);
  padding: 12px;
  border: 1px solid var(--fs-theme-border);
  border-right: 0;
  border-radius: 12px 0 0 12px;
  background: var(--fs-theme-surface);
  color: var(--fs-theme-text);
  box-shadow: var(--fs-theme-shadow);
  font: 13px/1.4 var(--fs-font);
}
.fs-theme-dock:not([data-user-closed="true"]):hover .fs-theme-dock-panel,
.fs-theme-dock:not([data-user-closed="true"]):focus-within .fs-theme-dock-panel,
.fs-theme-dock.is-open .fs-theme-dock-panel { display: block; }
.fs-theme-dock-head {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  margin-bottom: 8px; font-weight: 700;
}
.fs-theme-dock-close {
  flex: 0 0 28px; width: 28px; height: 28px; padding: 0;
  border: 1px solid var(--fs-theme-border); border-radius: 7px;
  background: var(--fs-theme-surface-alt); color: var(--fs-theme-text); cursor: pointer;
}
.fs-theme-dock-label {
  display: block; margin: 8px 0 4px; color: var(--fs-theme-muted);
  font-size: 10px; font-weight: 700; letter-spacing: .03em; text-transform: uppercase;
}
.fs-theme-palette-select {
  box-sizing: border-box; width: 100%; min-height: 34px; padding: 5px 8px;
  border: 1px solid var(--fs-theme-border); border-radius: 7px;
  background: var(--fs-theme-surface); color: var(--fs-theme-text);
  font: 12px/1.3 var(--fs-font);
}
.fs-theme-preview { display: flex; gap: 5px; margin-top: 8px; }
.fs-theme-swatch { width: 21px; height: 21px; border: 1px solid rgba(80,90,105,.25); border-radius: 6px; }
.fs-theme-palette-description { margin: 6px 0 0; color: var(--fs-theme-muted); font-size: 10px; line-height: 1.4; }
@media(max-width:560px) {
  .fs-theme-dock-trigger { flex-basis: 34px; width: 34px; min-height: 44px; }
  .fs-theme-dock-panel { width: min(248px, calc(100vw - 38px)); padding: 10px; }
}
@media(prefers-reduced-motion:reduce) {
  .fs-theme-dock *, .fs-theme-dock *::before, .fs-theme-dock *::after {
    transition-duration: .01ms !important; animation-duration: .01ms !important;
  }
}

html[data-fs-theme] .bib-bar i, html.fs-dark-mode .bib-bar i { background: var(--fs-gradient) !important; }

html[data-fs-theme] .pub-progress-bar, html.fs-dark-mode .pub-progress-bar { background: var(--fs-gradient) !important; }
html[data-fs-theme] .pub-progress, html.fs-dark-mode .pub-progress { background: var(--fs-theme-border) !important; }

/* Sincronización explícita de la suite de reportes */
html[data-fs-theme] .rep-hero, html.fs-dark-mode .rep-hero {
  background: var(--fs-theme-surface-alt) !important;
  border-color: var(--fs-theme-border) !important;
}
html[data-fs-theme] .rep-tabs button.is-on, html[data-fs-theme] .rep-tabs button.active,
html.fs-dark-mode .rep-tabs button.is-on, html.fs-dark-mode .rep-tabs button.active {
  background: var(--fs-theme-accent) !important;
  border-color: var(--fs-theme-accent) !important;
  color: var(--fs-theme-accent-text) !important;
}
html[data-fs-theme] .rep-bar, html.fs-dark-mode .rep-bar {
  background: var(--fs-theme-border) !important;
}
html[data-fs-theme] .rep-link, html.fs-dark-mode .rep-link {
  color: var(--fs-theme-accent) !important;
}
html[data-fs-theme] .rep-ring .rep-ring-bg, html.fs-dark-mode .rep-ring .rep-ring-bg {
  stroke: var(--fs-theme-border) !important;
}


/* ==========================================================================
   ARMONIZACIÓN INTEGRAL DE COMPONENTES EN MODO OSCURO
   ========================================================================== */
html[data-fs-theme="dark"],
html.fs-dark-mode,
body.fs-dark-mode,
html.dark,
body.dark {
  color-scheme: dark;

  /* Menú desplegable de usuario */
  .fs-drop-header {
    background: var(--fs-theme-surface-alt) !important;
    border-color: var(--fs-theme-border) !important;
  }
  .fs-drop-username {
    color: var(--fs-theme-text) !important;
  }
  .fs-company-switcher {
    background: var(--fs-theme-surface) !important;
    border-color: var(--fs-theme-border) !important;
  }
  .fs-company-select {
    background: var(--fs-theme-surface-alt) !important;
    color: var(--fs-theme-text) !important;
    border-color: var(--fs-theme-border) !important;
  }
  .fs-drop-link {
    color: var(--fs-theme-text) !important;
  }
  .fs-drop-link:hover {
    background: var(--fs-theme-surface-alt) !important;
    color: var(--fs-theme-accent) !important;
  }
  .fs-drop-link.active {
    background: var(--fs-theme-accent-soft) !important;
    color: var(--fs-theme-accent-text) !important;
  }
  .fs-drop-footer {
    border-color: var(--fs-theme-border) !important;
  }

  /* Visor y artículos normativos */
  .bib-article th,
  .fs-document-content table th,
  .fs-table-norma th {
    background: var(--fs-theme-surface-alt) !important;
    color: var(--fs-theme-text) !important;
    border-color: var(--fs-theme-border) !important;
  }
  .bib-article td,
  .fs-document-content table td,
  .fs-table-norma td {
    background: var(--fs-theme-surface) !important;
    color: var(--fs-theme-text) !important;
    border-color: var(--fs-theme-border) !important;
  }
  .bib-article tr:nth-child(even) td,
  .fs-document-content table tr:nth-child(even) td,
  .fs-table-norma tr:nth-child(even) td {
    background: var(--fs-theme-surface-alt) !important;
  }

  /* Formularios y edición */
  .form-grid input[readonly] {
    background: var(--fs-theme-surface-alt) !important;
    color: var(--fs-theme-muted) !important;
    border-color: var(--fs-theme-border) !important;
  }
  .form-notice {
    background: var(--fs-theme-surface-alt) !important;
    color: var(--fs-theme-text) !important;
    border: 1px solid var(--fs-theme-border);
  }
  .edit-file-row {
    background: var(--fs-theme-surface-alt) !important;
    border-color: var(--fs-theme-border) !important;
  }
  .edit-file-row.is-marked-for-removal {
    border-color: rgba(220, 38, 38, 0.4) !important;
    background: rgba(220, 38, 38, 0.15) !important;
  }

  /* Módulo de publicación y estados */
  .pub-banner {
    border-color: rgba(59, 130, 246, 0.4) !important;
    background: rgba(59, 130, 246, 0.15) !important;
    color: #93c5fd !important;
  }
  .pub-selection {
    background: var(--fs-theme-surface-alt) !important;
    border-color: var(--fs-theme-border) !important;
  }
  .pub-codes li,
  .pub-steps li {
    background: var(--fs-theme-surface) !important;
    border-color: var(--fs-theme-border) !important;
    color: var(--fs-theme-text) !important;
  }
  .pub-stage {
    background: rgba(59, 130, 246, 0.18) !important;
    color: #93c5fd !important;
  }
  .pub-state.al_dia,
  .pub-state.PASS,
  .pub-state.COMMITTED,
  .pub-state.ok {
    background: rgba(23, 166, 90, 0.2) !important;
    color: #4ade80 !important;
  }
  .pub-state.preparado,
  .pub-state.RUNNING,
  .pub-state.ejecutando,
  .pub-state.PENDING {
    background: rgba(59, 130, 246, 0.2) !important;
    color: #93c5fd !important;
  }
  .pub-state.sin_publicar,
  .pub-state.pendiente,
  .pub-state.INTERRUPTED,
  .pub-state.RECOVERY_REQUIRED {
    background: rgba(245, 158, 11, 0.2) !important;
    color: #fcd34d !important;
  }
  .pub-state.sin_docx,
  .pub-state.ABORTED,
  .pub-state.pendiente-cola {
    background: var(--fs-theme-surface-alt) !important;
    color: var(--fs-theme-muted) !important;
  }
  .pub-state.FAIL,
  .pub-state.ERROR,
  .pub-state.error {
    background: rgba(239, 68, 68, 0.2) !important;
    color: #fca5a5 !important;
  }

  /* Menú de filas en gestión de normativas */
  .row-menu-list {
    background: var(--fs-theme-surface) !important;
    border-color: var(--fs-theme-border) !important;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.45) !important;
  }
  .row-menu-list button {
    color: var(--fs-theme-text) !important;
  }
  .row-menu-list button:hover {
    background: var(--fs-theme-surface-alt) !important;
  }

  /* Timeline de ficha técnica */
  .bib-timeline-filter {
    background: var(--fs-theme-surface-alt) !important;
    border-color: var(--fs-theme-border) !important;
  }
  .bib-timeline-count,
  .bib-timeline-label {
    background: var(--fs-theme-surface) !important;
    border-color: var(--fs-theme-border) !important;
    color: var(--fs-theme-muted) !important;
  }
}

/* Botón principal de acceso: colores sincronizados con la paleta activa. */
body.fs-login-split .login-pane-form .btn-login-submit {
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  box-sizing: border-box;
  width: 100%;
  min-height: 48px;
  padding: 12px 18px;
  border: 1px solid var(--fs-theme-accent);
  border-radius: 12px;
  background: var(--fs-gradient, var(--fs-theme-accent));
  color: var(--fs-theme-accent-text, #ffffff);
  -webkit-text-fill-color: var(--fs-theme-accent-text, #ffffff);
  font: 700 1rem/1.25 var(--fs-font, system-ui, sans-serif);
  text-decoration: none;
  cursor: pointer;
  box-shadow: var(--fs-theme-shadow, 0 8px 24px rgba(15, 76, 129, .25));
  transition: transform .15s ease, box-shadow .15s ease, filter .2s ease,
              background-color .2s ease, border-color .2s ease;
}
body.fs-login-split .login-pane-form .btn-login-submit:link,
body.fs-login-split .login-pane-form .btn-login-submit:visited {
  color: var(--fs-theme-accent-text, #ffffff);
  -webkit-text-fill-color: var(--fs-theme-accent-text, #ffffff);
}
body.fs-login-split .login-pane-form .btn-login-submit:hover,
body.fs-login-split .login-pane-form .btn-login-submit:focus-visible {
  border-color: var(--fs-theme-accent-hover);
  background: var(--fs-theme-accent-hover);
  color: var(--fs-theme-accent-text, #ffffff);
  -webkit-text-fill-color: var(--fs-theme-accent-text, #ffffff);
}
body.fs-login-split .login-pane-form .btn-login-submit:hover {
  transform: translateY(-2px);
  box-shadow: var(--fs-theme-shadow, 0 12px 30px rgba(15, 76, 129, .3));
  filter: brightness(1.03);
}
body.fs-login-split .login-pane-form .btn-login-submit:active {
  transform: translateY(0);
}
body.fs-login-split .login-pane-form .btn-login-submit:focus-visible {
  outline: 3px solid var(--fs-theme-focus, #2f78a0);
  outline-offset: 3px;
}
body.fs-login-split .login-pane-form .btn-login-submit:disabled {
  color: var(--fs-theme-accent-text, #ffffff);
  -webkit-text-fill-color: var(--fs-theme-accent-text, #ffffff);
  opacity: .85;
  cursor: wait;
  transform: none;
}
@media (prefers-reduced-motion: reduce) {
  body.fs-login-split .login-pane-form .btn-login-submit { transition: none; }
}



/* ==========================================================================
   COBERTURA GLOBAL COMPLEMENTARIA - MODO OSCURO
   Esta capa complementa las paletas existentes. No reemplaza los colores
   semánticos de estado (éxito, advertencia, error) cuando estos son necesarios.
   ========================================================================== */
:root,
html[data-fs-theme="light"],
html[data-bs-theme="light"] {
  --bs-body-bg: var(--fs-theme-bg);
  --bs-body-color: var(--fs-theme-text);
  --bs-border-color: var(--fs-theme-border);
  --bs-tertiary-bg: var(--fs-theme-surface-alt);
  --bs-secondary-bg: var(--fs-theme-surface-alt);
  --bs-emphasis-color: var(--fs-theme-text);
  --bs-link-color: var(--fs-theme-accent);
  --bs-link-hover-color: var(--fs-theme-accent-hover);
}

html[data-fs-theme="dark"],
html[data-bs-theme="dark"],
html.fs-dark-mode,
html.dark,
body.fs-dark-mode,
body.dark {
  color-scheme: dark;
  --bs-body-bg: var(--fs-theme-bg);
  --bs-body-color: var(--fs-theme-text);
  --bs-border-color: var(--fs-theme-border);
  --bs-tertiary-bg: var(--fs-theme-surface-alt);
  --bs-secondary-bg: var(--fs-theme-surface-alt);
  --bs-emphasis-color: var(--fs-theme-text);
  --bs-link-color: var(--fs-theme-accent);
  --bs-link-hover-color: var(--fs-theme-accent-hover);
  --bs-card-bg: var(--fs-theme-surface);
  --bs-modal-bg: var(--fs-theme-surface);
  --bs-dropdown-bg: var(--fs-theme-surface);
  --bs-table-bg: var(--fs-theme-surface);
  --bs-form-control-bg: var(--fs-theme-surface);
}

/* Superficies frecuentes de Bootstrap y componentes de módulos. */
html[data-fs-theme="dark"] :where(
  .card, .modal-content, .dropdown-menu, .offcanvas, .popover, .toast,
  .list-group-item, .accordion-item, .accordion-button:not(.collapsed),
  .table, .table-responsive, .pagination, .page-link,
  .form-control, .form-select, .input-group-text, .form-floating > label,
  .nav-tabs, .tab-content, .alert-light, .bg-white, .text-bg-light,
  .breadcrumb, .progress, .carousel-caption
),
html[data-bs-theme="dark"] :where(
  .card, .modal-content, .dropdown-menu, .offcanvas, .popover, .toast,
  .list-group-item, .accordion-item, .accordion-button:not(.collapsed),
  .table, .table-responsive, .pagination, .page-link,
  .form-control, .form-select, .input-group-text, .form-floating > label,
  .nav-tabs, .tab-content, .alert-light, .bg-white, .text-bg-light,
  .breadcrumb, .progress, .carousel-caption
),
html.fs-dark-mode :where(
  .card, .modal-content, .dropdown-menu, .offcanvas, .popover, .toast,
  .list-group-item, .accordion-item, .accordion-button:not(.collapsed),
  .table, .table-responsive, .pagination, .page-link,
  .form-control, .form-select, .input-group-text, .form-floating > label,
  .nav-tabs, .tab-content, .alert-light, .bg-white, .text-bg-light,
  .breadcrumb, .progress, .carousel-caption
),
body.fs-dark-mode :where(
  .card, .modal-content, .dropdown-menu, .offcanvas, .popover, .toast,
  .list-group-item, .accordion-item, .accordion-button:not(.collapsed),
  .table, .table-responsive, .pagination, .page-link,
  .form-control, .form-select, .input-group-text, .form-floating > label,
  .nav-tabs, .tab-content, .alert-light, .bg-white, .text-bg-light,
  .breadcrumb, .progress, .carousel-caption
) {
  color: var(--fs-theme-text);
  background-color: var(--fs-theme-surface);
  border-color: var(--fs-theme-border);
}

html[data-fs-theme="dark"] :where(input:not([type="checkbox"]):not([type="radio"]):not([type="range"]), select, textarea),
html[data-bs-theme="dark"] :where(input:not([type="checkbox"]):not([type="radio"]):not([type="range"]), select, textarea),
html.fs-dark-mode :where(input:not([type="checkbox"]):not([type="radio"]):not([type="range"]), select, textarea),
body.fs-dark-mode :where(input:not([type="checkbox"]):not([type="radio"]):not([type="range"]), select, textarea) {
  color: var(--fs-theme-text);
  background-color: var(--fs-theme-surface);
  border-color: var(--fs-theme-border);
}

html[data-fs-theme="dark"] :where(input, textarea, select)::placeholder,
html[data-bs-theme="dark"] :where(input, textarea, select)::placeholder,
html.fs-dark-mode :where(input, textarea, select)::placeholder,
body.fs-dark-mode :where(input, textarea, select)::placeholder {
  color: var(--fs-theme-muted);
  opacity: 1;
}

html[data-fs-theme="dark"] :where(.table, table) > :not(caption) > * > *,
html[data-bs-theme="dark"] :where(.table, table) > :not(caption) > * > *,
html.fs-dark-mode :where(.table, table) > :not(caption) > * > *,
body.fs-dark-mode :where(.table, table) > :not(caption) > * > * {
  color: var(--fs-theme-text);
  background-color: var(--fs-theme-surface);
  border-color: var(--fs-theme-border);
}

html[data-fs-theme="dark"] :where(.text-dark, .link-dark),
html[data-bs-theme="dark"] :where(.text-dark, .link-dark),
html.fs-dark-mode :where(.text-dark, .link-dark),
body.fs-dark-mode :where(.text-dark, .link-dark) {
  color: var(--fs-theme-text) !important;
}

html[data-fs-theme="dark"] :where(.bg-white, .bg-light),
html[data-bs-theme="dark"] :where(.bg-white, .bg-light),
html.fs-dark-mode :where(.bg-white, .bg-light),
body.fs-dark-mode :where(.bg-white, .bg-light) {
  background-color: var(--fs-theme-surface) !important;
}

html[data-fs-theme="dark"] :where(hr, .dropdown-divider),
html[data-bs-theme="dark"] :where(hr, .dropdown-divider),
html.fs-dark-mode :where(hr, .dropdown-divider),
body.fs-dark-mode :where(hr, .dropdown-divider) {
  border-color: var(--fs-theme-border);
  opacity: 1;
}

@media (prefers-reduced-motion: reduce) {
  html[data-fs-theme], html[data-fs-theme] *,
  html[data-bs-theme], html[data-bs-theme] * {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}


/* ==========================================================================
   AJUSTE ESPECÍFICO: ADMINISTRACIÓN DE NORMATIVAS (seguridad.php)
   Evita paneles blancos dentro de una página en modo oscuro.
   ========================================================================== */
html[data-fs-theme="dark"],
html[data-bs-theme="dark"],
html.fs-dark-mode,
body.fs-dark-mode {
  --card-bg: var(--fs-theme-surface);
  --border-color: var(--fs-theme-border);
  --muted-color: var(--fs-theme-muted);
  --ink-color: var(--fs-theme-text);
  --surface-color: var(--fs-theme-surface);
}

html[data-fs-theme="dark"] .bs-head,
html[data-fs-theme="dark"] .bs-panel,
html[data-bs-theme="dark"] .bs-head,
html[data-bs-theme="dark"] .bs-panel,
html.fs-dark-mode .bs-head,
html.fs-dark-mode .bs-panel,
body.fs-dark-mode .bs-head,
body.fs-dark-mode .bs-panel {
  color: var(--fs-theme-text) !important;
  background: var(--fs-theme-surface) !important;
  border-color: var(--fs-theme-border) !important;
  box-shadow: var(--fs-theme-shadow);
}

html[data-fs-theme="dark"] .bs-head h1,
html[data-fs-theme="dark"] .bs-panel h2,
html[data-fs-theme="dark"] .bs-panel h3,
html[data-bs-theme="dark"] .bs-head h1,
html[data-bs-theme="dark"] .bs-panel h2,
html[data-bs-theme="dark"] .bs-panel h3,
html.fs-dark-mode .bs-head h1,
html.fs-dark-mode .bs-panel h2,
html.fs-dark-mode .bs-panel h3,
body.fs-dark-mode .bs-head h1,
body.fs-dark-mode .bs-panel h2,
body.fs-dark-mode .bs-panel h3 {
  color: var(--fs-theme-text) !important;
}

html[data-fs-theme="dark"] .bs-company,
html[data-bs-theme="dark"] .bs-company,
html.fs-dark-mode .bs-company,
body.fs-dark-mode .bs-company {
  color: var(--fs-theme-accent-text, var(--fs-theme-text)) !important;
  background: var(--fs-theme-accent-soft) !important;
  border-color: var(--fs-theme-border) !important;
}

html[data-fs-theme="dark"] .bs-tabs a,
html[data-bs-theme="dark"] .bs-tabs a,
html.fs-dark-mode .bs-tabs a,
body.fs-dark-mode .bs-tabs a {
  color: var(--fs-theme-text) !important;
  background: var(--fs-theme-surface) !important;
  border-color: var(--fs-theme-border) !important;
}

html[data-fs-theme="dark"] .bs-tabs a.active,
html[data-bs-theme="dark"] .bs-tabs a.active,
html.fs-dark-mode .bs-tabs a.active,
body.fs-dark-mode .bs-tabs a.active {
  color: var(--fs-theme-accent-text, #fff) !important;
  background: var(--fs-theme-accent) !important;
  border-color: var(--fs-theme-accent) !important;
}

html[data-fs-theme="dark"] .bs-panel :where(input, select, textarea),
html[data-bs-theme="dark"] .bs-panel :where(input, select, textarea),
html.fs-dark-mode .bs-panel :where(input, select, textarea),
body.fs-dark-mode .bs-panel :where(input, select, textarea) {
  color: var(--fs-theme-text) !important;
  background: var(--fs-theme-surface-alt) !important;
  border-color: var(--fs-theme-border) !important;
}

html[data-fs-theme="dark"] .bs-panel :where(input, select, textarea)::placeholder,
html[data-bs-theme="dark"] .bs-panel :where(input, select, textarea)::placeholder,
html.fs-dark-mode .bs-panel :where(input, select, textarea)::placeholder,
body.fs-dark-mode .bs-panel :where(input, select, textarea)::placeholder {
  color: var(--fs-theme-muted) !important;
  opacity: 1;
}

html[data-fs-theme="dark"] .bs-table,
html[data-fs-theme="dark"] .bs-table :where(th, td),
html[data-bs-theme="dark"] .bs-table,
html[data-bs-theme="dark"] .bs-table :where(th, td),
html.fs-dark-mode .bs-table,
html.fs-dark-mode .bs-table :where(th, td),
body.fs-dark-mode .bs-table,
body.fs-dark-mode .bs-table :where(th, td) {
  color: var(--fs-theme-text) !important;
  background-color: var(--fs-theme-surface) !important;
  border-color: var(--fs-theme-border) !important;
}

html[data-fs-theme="dark"] .bs-muted,
html[data-bs-theme="dark"] .bs-muted,
html.fs-dark-mode .bs-muted,
body.fs-dark-mode .bs-muted {
  color: var(--fs-theme-muted) !important;
}

/* Semántica central para avisos, estados y controles de los módulos propios. */
html[data-fs-theme] :is(.alert, .bs-alert, .notice, [role="alert"]:not(.bd-toast), [role="status"].is-message:not(.bd-toast)),
html.fs-dark-mode :is(.alert, .bs-alert, .notice, [role="alert"]:not(.bd-toast), [role="status"].is-message:not(.bd-toast)),
body.fs-dark-mode :is(.alert, .bs-alert, .notice, [role="alert"]:not(.bd-toast), [role="status"].is-message:not(.bd-toast)) {
  color: var(--fs-theme-text);
  background-color: var(--fs-theme-surface-alt);
  border-color: var(--fs-theme-border);
}
html[data-fs-theme] :is(.alert-success, .bs-alert.success, .notice.success, .notice.is-success),
html.fs-dark-mode :is(.alert-success, .bs-alert.success, .notice.success, .notice.is-success),
body.fs-dark-mode :is(.alert-success, .bs-alert.success, .notice.success, .notice.is-success) {
  color: var(--fs-theme-success-text);
  background-color: var(--fs-theme-success-soft);
  border-color: color-mix(in srgb, var(--fs-theme-success) 35%, var(--fs-theme-border));
}
html[data-fs-theme] :is(.alert-warning, .bs-alert.warning, .notice.warning, .notice.is-warning),
html.fs-dark-mode :is(.alert-warning, .bs-alert.warning, .notice.warning, .notice.is-warning),
body.fs-dark-mode :is(.alert-warning, .bs-alert.warning, .notice.warning, .notice.is-warning) {
  color: var(--fs-theme-warning-text);
  background-color: var(--fs-theme-warning-soft);
  border-color: color-mix(in srgb, var(--fs-theme-warning) 35%, var(--fs-theme-border));
}
html[data-fs-theme] :is(.alert-danger, .alert-error, .bs-alert.danger, .notice.error, .notice.is-error),
html.fs-dark-mode :is(.alert-danger, .alert-error, .bs-alert.danger, .notice.error, .notice.is-error),
body.fs-dark-mode :is(.alert-danger, .alert-error, .bs-alert.danger, .notice.error, .notice.is-error) {
  color: var(--fs-theme-danger-text);
  background-color: var(--fs-theme-danger-soft);
  border-color: color-mix(in srgb, var(--fs-theme-danger) 38%, var(--fs-theme-border));
}
html[data-fs-theme] :is(.alert-info, .bs-alert.info, .notice.info, .notice.is-info),
html.fs-dark-mode :is(.alert-info, .bs-alert.info, .notice.info, .notice.is-info),
body.fs-dark-mode :is(.alert-info, .bs-alert.info, .notice.info, .notice.is-info) {
  color: var(--fs-theme-info-text);
  background-color: var(--fs-theme-info-soft);
  border-color: color-mix(in srgb, var(--fs-theme-info) 35%, var(--fs-theme-border));
}

/* Alias que consumen hojas históricas del constructor/editor técnico. */
html[data-fs-theme], html.fs-dark-mode, body.fs-dark-mode {
  --text: var(--fs-theme-text);
  --text-color: var(--fs-theme-text);
  --muted: var(--fs-theme-muted);
  --muted-color: var(--fs-theme-muted);
  --line: var(--fs-theme-border);
  --border-color: var(--fs-theme-border);
  --surface: var(--fs-theme-surface);
  --surface-color: var(--fs-theme-surface);
  --surface-bg: var(--fs-theme-surface);
  --page-bg: var(--fs-theme-bg);
  --background-color: var(--fs-theme-bg);
  --surface-secondary: var(--fs-theme-surface-alt);
  --soft: var(--fs-theme-accent-soft);
  --input-bg: var(--fs-theme-surface-alt);
  --primary-color: var(--fs-theme-accent);
  --accent: var(--fs-theme-accent);
  --accent-hover: var(--fs-theme-accent-hover);
  --red: var(--fs-theme-danger);
  --green: var(--fs-theme-success);
}

html[data-fs-theme="dark"] :where(.mtc-shell, .mte-browser-panel, .chromium-remote-dialog, .chromium-remote-toolbar, .reference-card, .reference-head, .reference-body, .preview-item, .preview-image-wrap, .sheet-item),
html.fs-dark-mode :where(.mtc-shell, .mte-browser-panel, .chromium-remote-dialog, .chromium-remote-toolbar, .reference-card, .reference-head, .reference-body, .preview-item, .preview-image-wrap, .sheet-item),
body.fs-dark-mode :where(.mtc-shell, .mte-browser-panel, .chromium-remote-dialog, .chromium-remote-toolbar, .reference-card, .reference-head, .reference-body, .preview-item, .preview-image-wrap, .sheet-item) {
  color: var(--fs-theme-text);
  background-color: var(--fs-theme-surface);
  border-color: var(--fs-theme-border);
}
html[data-fs-theme="dark"] :where(.mtc-shell, .mte-browser-panel, .chromium-remote-dialog, .chromium-remote-toolbar, .reference-card, .reference-head, .reference-body, .preview-item, .preview-image-wrap, .sheet-item) :where(input, select, textarea),
html.fs-dark-mode :where(.mtc-shell, .mte-browser-panel, .chromium-remote-dialog, .chromium-remote-toolbar, .reference-card, .reference-head, .reference-body, .preview-item, .preview-image-wrap, .sheet-item) :where(input, select, textarea),
body.fs-dark-mode :where(.mtc-shell, .mte-browser-panel, .chromium-remote-dialog, .chromium-remote-toolbar, .reference-card, .reference-head, .reference-body, .preview-item, .preview-image-wrap, .sheet-item) :where(input, select, textarea) {
  color: var(--fs-theme-text);
  background-color: var(--fs-theme-surface-alt);
  border-color: var(--fs-theme-border);
}
html[data-fs-theme="dark"] .mtc-modal-backdrop { background: color-mix(in srgb, var(--fs-theme-bg) 84%, transparent); }
html[data-fs-theme="dark"] :where(.mte-player-toolbar, .mte-player-toolbar select, .mte-player-progress, .mte-player-image-wrap, .preview-dynamic-reference, .mte-player-timeline-item, .mte-player-timeline-item > span),
html.fs-dark-mode :where(.mte-player-toolbar, .mte-player-toolbar select, .mte-player-progress, .mte-player-image-wrap, .preview-dynamic-reference, .mte-player-timeline-item, .mte-player-timeline-item > span),
body.fs-dark-mode :where(.mte-player-toolbar, .mte-player-toolbar select, .mte-player-progress, .mte-player-image-wrap, .preview-dynamic-reference, .mte-player-timeline-item, .mte-player-timeline-item > span) {
  color: var(--fs-theme-text);
  background-color: var(--fs-theme-surface-alt);
  border-color: var(--fs-theme-border);
}
html[data-fs-theme="dark"] :where(.mte-player-toolbar label, .mte-player-references-head span, .preview-general-rich),
html.fs-dark-mode :where(.mte-player-toolbar label, .mte-player-references-head span, .preview-general-rich),
body.fs-dark-mode :where(.mte-player-toolbar label, .mte-player-references-head span, .preview-general-rich) { color: var(--fs-theme-muted); }
