:root {
  /* Paleta monocromática basada en RGB: 31, 93, 117 (#1F5D75) */
  --primary: #1F5D75;
  --primary-hover: #164355;
  --primary-active: #0f303d;
  --primary-light: #eaf2f5;
  --primary-lighter: #f3f7f9;
  --primary-tint: #2e7a98;
  
  --text-main: #102630;
  --text-muted: #53717d;
  --border: #d4e2e7;
  --border-focus: #1F5D75;
  
  --bg-main: #f5f8f9;
  --bg-card: #ffffff;
  
  --sidebar-bg: #122933;
  --sidebar-text: #f0f6f8;
  --sidebar-muted: #8ea8b3;
  --sidebar-hover: #1b3d4b;
  --sidebar-active: #1F5D75;
  --sidebar-border: #1d404f;

  /* Estados semánticos armónicos con tono monocromático */
  --success: #1e7558;
  --success-bg: #ebf6f2;
  --warning: #a16207;
  --warning-bg: #fefce8;
  --danger: #b91c1c;
  --danger-bg: #fef2f2;

  --radius: 12px;
  --shadow: 0 4px 6px -1px rgba(31, 93, 117, 0.08), 0 2px 4px -2px rgba(31, 93, 117, 0.06);
  --shadow-lg: 0 10px 18px -3px rgba(31, 93, 117, 0.12), 0 4px 8px -4px rgba(31, 93, 117, 0.08);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

body {
  background-color: var(--bg-main);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Utilitarios */
.flex { display: flex; }
.flex-col { display: flex; flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.justify-center { justify-content: center; }
.gap-2 { gap: 0.5rem; }
.gap-4 { gap: 1rem; }
.gap-6 { gap: 1.5rem; }

/* Contenedor de Login */
.login-container {
  flex: 1 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding: 2.5rem 1.5rem;
  background: radial-gradient(circle at 10% 20%, #eaf2f5 0%, #f4f8fa 90%);
  box-sizing: border-box;
}

.login-card {
  width: 100%;
  max-width: 440px;
  background: var(--bg-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border);
  padding: 2.5rem;
  position: relative;
  box-sizing: border-box;
}

.brand-header {
  text-align: center;
  margin-bottom: 2rem;
}

.brand-logo {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 56px;
  background: linear-gradient(135deg, #1F5D75, #2e7a98);
  color: #fff;
  border-radius: 14px;
  margin-bottom: 1rem;
  box-shadow: 0 4px 12px rgba(31, 93, 117, 0.25);
}

.brand-title {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--text-main);
  letter-spacing: -0.025em;
}

.brand-subtitle {
  font-size: 0.875rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
}

/* Badges monocromáticos */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.25rem 0.65rem;
  border-radius: 9999px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.badge-demo {
  background: #fdf5e6;
  color: #8c5716;
  border: 1px solid #fae6c6;
}

.badge-prod {
  background: #e6f1f4;
  color: #164355;
  border: 1px solid #bfd8e0;
}

.badge-success {
  background: var(--success-bg);
  color: #134e3a;
  border: 1px solid #b6e2d3;
}

.badge-warning {
  background: var(--warning-bg);
  color: #854d0e;
  border: 1px solid #fef08a;
}

.badge-danger {
  background: var(--danger-bg);
  color: #991b1b;
  border: 1px solid #fecaca;
}

/* Formularios y Cajas de Texto perfectamente alineadas */
.form-group {
  margin-bottom: 1.25rem;
  width: 100%;
  box-sizing: border-box;
  text-align: left;
}

.form-label {
  display: block;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-main);
  margin-bottom: 0.5rem;
  text-align: left;
}

.form-input {
  display: block;
  width: 100%;
  height: 44px;
  padding: 0 1rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.95rem;
  color: var(--text-main);
  background-color: #fff;
  transition: border-color 0.2s, box-shadow 0.2s;
  box-sizing: border-box;
  text-align: left;
}

.form-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(31, 93, 117, 0.18);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem 1.25rem;
  font-size: 0.95rem;
  font-weight: 600;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  transition: all 0.2s ease;
  text-decoration: none;
}

.btn-primary {
  background-color: var(--primary);
  color: #fff;
  width: 100%;
}

.btn-primary:hover {
  background-color: var(--primary-hover);
  box-shadow: 0 4px 12px rgba(31, 93, 117, 0.3);
}

.btn-primary:active {
  background-color: var(--primary-active);
  transform: translateY(1px);
}

.btn-secondary {
  background-color: #ffffff;
  color: #334155;
  border: 1px solid #cbd5e1;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
  transition: all 0.15s ease-in-out;
}

.btn-secondary:hover {
  background-color: #f8fafc;
  border-color: #94a3b8;
  color: #0f172a;
}

.btn-secondary:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(31, 93, 117, 0.2);
  border-color: var(--primary);
}

.btn-secondary:active {
  background-color: #e2e8f0;
  border-color: #64748b;
  transform: translateY(1px);
  box-shadow: none;
}

.btn-modal-cancel {
  background-color: #ffffff;
  color: #475569;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  font-weight: 500;
  padding: 0.65rem 1.25rem;
  font-size: 0.9rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
  transition: all 0.15s ease-in-out;
}

.btn-modal-cancel:hover {
  background-color: #f3f4f6;
  border-color: #9ca3af;
  color: #111827;
}

.btn-modal-cancel:focus,
.btn-modal-cancel:focus-visible {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(31, 93, 117, 0.2);
}

.btn-modal-cancel:active {
  background-color: #e5e7eb;
  border-color: #6b7280;
  transform: translateY(1px);
  box-shadow: none;
}

.btn-success {
  background-color: var(--primary);
  color: #fff;
}

.btn-success:hover {
  background-color: var(--primary-hover);
  box-shadow: 0 4px 12px rgba(31, 93, 117, 0.3);
}

/* Alertas */
.alert {
  padding: 0.85rem 1rem;
  border-radius: 8px;
  font-size: 0.875rem;
  line-height: 1.4;
  margin-bottom: 1.25rem;
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
}

.alert-danger {
  background-color: var(--danger-bg);
  border: 1px solid #fecaca;
  color: #b91c1c;
}

.alert-warning {
  background-color: var(--warning-bg);
  border: 1px solid #fef08a;
  color: #854d0e;
}

.alert-success {
  background-color: #eaf4f7;
  border: 1px solid #c2dbe4;
  color: #164355;
}

/* Selector de Idioma (Desplegable) */
.lang-select-wrapper {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  background-color: #fff;
  border: 1px solid var(--border);
  padding: 0.35rem 0.65rem;
  border-radius: 8px;
  box-shadow: 0 1px 2px rgba(31, 93, 117, 0.05);
  transition: all 0.2s ease;
}

.lang-select-wrapper:hover,
.lang-select-wrapper:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(31, 93, 117, 0.15);
}

.lang-select {
  border: none;
  background: transparent;
  color: var(--text-main);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  outline: none;
  font-family: inherit;
  padding: 0.1rem 0;
}

.lang-select option {
  background: #fff;
  color: var(--text-main);
  font-size: 0.9rem;
}

.sidebar .lang-select-wrapper {
  background-color: #173542;
  border-color: #244d5f;
  color: #f0f6f8;
  width: 100%;
  justify-content: space-between;
}

.sidebar .lang-select-wrapper svg {
  color: #8ea8b3 !important;
}

.sidebar .lang-select {
  color: #f0f6f8;
  width: 100%;
}

.sidebar .lang-select option {
  background: #122933;
  color: #f0f6f8;
}

/* Selector de Idioma (Botones legacy/fallback) */
.lang-selector {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  background: #eaf1f4;
  padding: 0.25rem 0.5rem;
  border-radius: 8px;
  font-size: 0.8rem;
}

.lang-btn {
  text-decoration: none;
  padding: 0.25rem 0.5rem;
  border-radius: 6px;
  color: var(--text-muted);
  font-weight: 500;
  transition: all 0.15s;
  cursor: pointer;
  border: none;
  background: transparent;
}

.lang-btn:hover {
  color: var(--primary);
}

.lang-btn.active {
  background: #fff;
  color: var(--primary);
  font-weight: 700;
  box-shadow: 0 1px 3px rgba(31, 93, 117, 0.15);
}

/* Layout con Menú Principal a la Izquierda */
.app-layout {
  display: flex;
  min-height: 100vh;
  position: relative;
  align-items: stretch;
}

.sidebar {
  width: 260px;
  min-width: 260px;
  height: 100vh;
  max-height: 100vh;
  position: sticky;
  top: 0;
  left: 0;
  align-self: flex-start;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  background-color: var(--sidebar-bg);
  color: var(--sidebar-text);
  border-right: 1px solid var(--sidebar-border);
  z-index: 100;
  overflow: hidden;
  box-sizing: border-box;
}

.sidebar-brand,
.sidebar-header {
  flex-shrink: 0;
}

.sidebar-brand {
  padding: 1.25rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  border-bottom: 1px solid var(--sidebar-border);
}

.sidebar-brand-icon {
  width: 36px;
  height: 36px;
  background: var(--primary);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  font-weight: bold;
  font-size: 1.1rem;
}

.sidebar-brand-name {
  font-weight: 700;
  font-size: 1.15rem;
  color: #fff;
}

.sidebar-menu-title {
  flex-shrink: 0;
  padding: 1rem 1.25rem 0.35rem 1.25rem;
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--sidebar-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.sidebar-nav {
  list-style: none;
  padding: 0.35rem 0.75rem 0.5rem 0.75rem;
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
}

.sidebar-nav::-webkit-scrollbar {
  width: 4px;
}
.sidebar-nav::-webkit-scrollbar-track {
  background: transparent;
}
.sidebar-nav::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.18);
  border-radius: 4px;
}
.sidebar-nav::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.35);
}

.sidebar-nav-item {
  margin-bottom: 0.35rem;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 0.75rem 1rem;
  border-radius: 8px;
  color: var(--sidebar-muted);
  text-decoration: none;
  font-weight: 500;
  font-size: 0.92rem;
  transition: all 0.2s ease;
  cursor: pointer;
}

.sidebar-link:hover {
  background-color: var(--sidebar-hover);
  color: #fff;
}

.sidebar-link.active {
  background-color: var(--sidebar-active);
  color: #fff;
  font-weight: 600;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

/* Submenús en barra lateral */
.sidebar-link {
  position: relative;
}

.submenu-chevron {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 4px;
  cursor: pointer;
  color: var(--sidebar-muted);
  transition: transform 0.2s ease, color 0.2s ease, background 0.2s ease;
}

.submenu-chevron:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.12);
}

.sidebar-nav-item.has-submenu.open .submenu-chevron svg,
.sidebar-nav-item.has-submenu.open .sidebar-submenu-chevron {
  transform: rotate(180deg);
}

.sidebar-submenu-chevron {
  transition: transform 0.2s ease;
}

.sidebar-submenu {
  list-style: none;
  padding: 0.25rem 0 0.25rem 0.5rem;
  margin: 0.15rem 0 0.35rem 1.15rem;
  border-left: 2px solid rgba(255, 255, 255, 0.14);
  display: none;
  flex-direction: column;
  gap: 0.2rem;
}

.sidebar-nav-item.has-submenu.open > .sidebar-submenu {
  display: flex;
}

.sidebar-sublink {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.42rem 0.75rem;
  border-radius: 6px;
  color: var(--sidebar-muted);
  text-decoration: none;
  font-size: 0.83rem;
  font-weight: 500;
  transition: all 0.15s ease;
}

.sidebar-sublink:hover {
  background-color: var(--sidebar-hover);
  color: #fff;
}

.sidebar-sublink.active {
  background-color: var(--sidebar-active);
  color: #fff;
  font-weight: 600;
}

.sublink-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background-color: currentColor;
  opacity: 0.45;
  flex-shrink: 0;
  transition: opacity 0.15s, background-color 0.15s;
}

.sidebar-sublink:hover .sublink-dot {
  opacity: 0.9;
  background-color: #38bdf8;
}

.sidebar-sublink.active .sublink-dot {
  opacity: 1;
  background-color: #38bdf8;
  box-shadow: 0 0 6px #38bdf8;
}

/* Pie fijo del menú lateral (siempre visible en la parte inferior de la pantalla) */
.sidebar-footer {
  flex-shrink: 0;
  margin-top: auto;
  background-color: var(--sidebar-bg);
  border-top: 1px solid var(--sidebar-border);
  display: flex;
  flex-direction: column;
  z-index: 10;
  box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.15);
}

.sidebar-footer-nav {
  padding: 0.5rem 0.75rem 0.25rem 0.75rem;
}

.sidebar-footer-nav .sidebar-link {
  color: #60a5fa;
  font-weight: 600;
}

.sidebar-footer-nav .sidebar-link:hover {
  background-color: var(--sidebar-hover);
  color: #93c5fd;
}

.sidebar-footer-nav .sidebar-link.active {
  background-color: var(--sidebar-active);
  color: #fff;
}

.sidebar-user {
  padding: 0.75rem 1rem 1rem 1rem;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  flex-shrink: 0;
  margin-top: auto;
}

.user-info {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.user-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: #1c4150;
  color: #eaf2f5;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  border: 1px solid #2e596c;
}

.user-details {
  overflow: hidden;
}

.user-name {
  font-size: 0.9rem;
  font-weight: 600;
  color: #f0f6f8;
  white-space: nowrap;
  text-overflow: ellipsis;
  overflow: hidden;
}

.user-role-badge {
  font-size: 0.72rem;
  color: var(--sidebar-muted);
}

/* Área de Contenido Principal */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 100vh;
  background-color: var(--bg-main);
}

.top-navbar {
  height: 64px;
  background-color: #fff;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 2rem;
}

.page-body {
  padding: 2rem;
  flex: 1;
}

/* Banner de Actualización */
.update-banner {
  background: linear-gradient(90deg, #143745, #1F5D75);
  color: #fff;
  padding: 1rem 1.5rem;
  border-radius: var(--radius);
  margin-bottom: 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: var(--shadow);
  animation: slideDown 0.3s ease;
}

@keyframes slideDown {
  from { opacity: 0; transform: translateY(-10px); }
  to { opacity: 1; transform: translateY(0); }
}

.update-banner-content {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.update-icon {
  background: rgba(255, 255, 255, 0.18);
  width: 42px;
  height: 42px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  flex-shrink: 0;
}

.update-title {
  font-weight: 700;
  font-size: 1rem;
}

.update-desc {
  font-size: 0.85rem;
  color: #d6e8ef;
  margin-top: 0.15rem;
}

/* Cards del Dashboard */
.grid-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1.5rem;
  margin-bottom: 2rem;
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow);
}

.card-title {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.5rem;
}

.card-value {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--text-main);
}

.card-subtext {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 0.35rem;
}

/* Tablas */
.table-container {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}

.table-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #fafcfd;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}

.data-table th {
  background: #f2f7f9;
  padding: 0.85rem 1.5rem;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid var(--border);
}

.data-table td {
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
  color: var(--text-main);
}

.data-table tr:hover {
  background-color: #f7fafb;
}

/* Tarjeta de Configuración SQL */
.config-card {
  width: 100%;
  max-width: 620px;
  margin: 0 auto;
  background: #fff;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  padding: 2.5rem;
  box-sizing: border-box;
}

.spinner {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255,255,255,0.3);
  border-radius: 50%;
  border-top-color: #fff;
  animation: spin 0.8s ease-in-out infinite;
  display: inline-block;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Pie de página (abajo de todo, compacto sin forzar scroll) */
.site-footer {
  flex-shrink: 0;
  width: 100%;
  padding: 0.35rem 1rem;
  text-align: center;
  font-size: 0.76rem;
  color: var(--text-muted);
  line-height: 1.3;
  background-color: #f7fafb;
  border-top: 1px solid var(--border);
  margin-top: auto !important;
  box-sizing: border-box;
}

.site-footer a {
  color: var(--primary);
  text-decoration: none;
  font-weight: 500;
  transition: color 0.15s;
}

.site-footer a:hover {
  text-decoration: underline;
  color: var(--primary-hover);
}

.footer-bullet {
  margin: 0 0.45rem;
  color: var(--border);
}

/* ============================================================
   MODAL Y VENTANAS DIÁLOGO
   ============================================================ */
.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(15, 23, 42, 0.65);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  padding: 1.25rem;
  animation: modalFadeIn 0.2s ease-out;
}

.modal-dialog {
  background: #ffffff;
  border-radius: 16px;
  max-width: 580px;
  width: 100%;
  max-height: calc(100vh - 2.5rem);
  max-height: calc(100dvh - 2.5rem);
  box-shadow: 0 25px 50px -12px rgba(15, 23, 42, 0.25), 0 0 0 1px rgba(15, 23, 42, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.8);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  animation: modalSlideUp 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-dialog > form {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
  margin: 0;
}

@keyframes modalFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes modalSlideUp {
  from { transform: translateY(18px) scale(0.97); opacity: 0; }
  to { transform: translateY(0) scale(1); opacity: 1; }
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid #f1f5f9;
  background: #ffffff;
  flex-shrink: 0;
}

.modal-header-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: linear-gradient(135deg, rgba(31, 93, 117, 0.12), rgba(31, 93, 117, 0.05));
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  border: 1px solid rgba(31, 93, 117, 0.15);
}

.modal-title {
  font-size: 1.18rem;
  font-weight: 700;
  color: #0f172a;
  line-height: 1.25;
}

.modal-close {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: #64748b;
  line-height: 1;
  transition: all 0.15s ease;
  padding: 0;
}

.modal-close:hover {
  background: #fee2e2;
  color: #ef4444;
  border-color: #fca5a5;
  transform: rotate(90deg);
}

.modal-body {
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  flex: 1 1 auto;
  min-height: 0;
  max-height: 75vh;
  overflow-y: auto;
  background: #fafbfc;
}

.modal-section-title {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #64748b;
  margin-bottom: 0.75rem;
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.modal-section-title::after {
  content: '';
  flex: 1;
  height: 1px;
  background: #e2e8f0;
}

.input-icon-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
}

.input-icon-wrapper .input-icon {
  position: absolute;
  left: 0.85rem;
  color: #94a3b8;
  pointer-events: none;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.2s ease;
  z-index: 2;
}

.input-icon-wrapper .form-control {
  padding-left: 2.5rem !important;
  height: 42px;
  border-radius: 8px;
  border: 1px solid #cbd5e1;
  background-color: #ffffff;
  font-size: 0.88rem;
  color: #0f172a;
  transition: all 0.2s ease;
  width: 100%;
  box-sizing: border-box;
}

.input-icon-wrapper select.form-control {
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.85rem center;
  padding-right: 2.2rem;
  cursor: pointer;
}

.input-icon-wrapper .form-control:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(31, 93, 117, 0.16);
  background-color: #ffffff;
  outline: none;
}

.input-icon-wrapper:focus-within .input-icon {
  color: var(--primary);
}

.btn-password-toggle {
  position: absolute;
  right: 0.65rem;
  background: transparent;
  border: none;
  color: #94a3b8;
  cursor: pointer;
  padding: 5px 6px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
  z-index: 2;
}

.btn-password-toggle:hover {
  background: #f1f5f9;
  color: #334155;
}

.form-hint {
  font-size: 0.74rem;
  color: #64748b;
  margin-top: 0.35rem;
  display: flex;
  align-items: center;
  gap: 5px;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 0.75rem;
  padding: 1.15rem 1.5rem;
  border-top: 1px solid #f1f5f9;
  background: #ffffff;
  flex-shrink: 0;
}

.modal-footer .btn {
  height: 42px;
  padding: 0 1.35rem;
  font-size: 0.88rem;
  font-weight: 600;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  transition: all 0.15s ease;
}

.btn-modal-cancel {
  background-color: #ffffff;
  color: #475569;
  border: 1px solid #cbd5e1;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.btn-modal-cancel:hover {
  background-color: #f8fafc;
  border-color: #94a3b8;
  color: #0f172a;
}

.btn-modal-cancel:active {
  background-color: #e2e8f0;
  transform: translateY(1px);
}

/* Tarjeta de módulo bloqueado / no contratado */
.locked-module-card {
  background: #ffffff;
  border: 1px solid #fed7aa;
  border-radius: var(--radius);
  padding: 3rem 2rem;
  text-align: center;
  max-width: 640px;
  margin: 2rem auto;
  box-shadow: 0 10px 25px -5px rgba(234, 88, 12, 0.08);
}

.locked-icon-wrapper {
  width: 76px;
  height: 76px;
  background: #ffedd5;
  color: #ea580c;
  border-radius: 20px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 2.25rem;
  margin-bottom: 1.5rem;
  box-shadow: 0 4px 12px rgba(234, 88, 12, 0.15);
}

.btn-sm {
  padding: 0.35rem 0.75rem;
  font-size: 0.8rem;
  border-radius: 6px;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  cursor: pointer;
  text-decoration: none;
  border: 1px solid transparent;
  transition: all 0.15s;
}

.btn-sm-edit {
  background: #f0fdf4;
  color: #166534;
  border-color: #bbf7d0;
}

.btn-sm-edit:hover {
  background: #dcfce7;
  border-color: #86efac;
}

.btn-sm-delete {
  background: #fef2f2;
  color: #991b1b;
  border-color: #fecaca;
}

.btn-sm-delete:hover {
  background: #fee2e2;
  border-color: #fca5a5;
}

.search-input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.search-input-wrapper svg {
  position: absolute;
  left: 0.85rem;
  color: #94a3b8;
  pointer-events: none;
}

.search-input-wrapper input {
  padding-left: 2.35rem;
  height: 40px;
  font-size: 0.875rem;
  border-radius: 8px;
  border: 1px solid #cbd5e1;
  background-color: #f8fafc;
  transition: all 0.2s ease;
}

.search-input-wrapper input:focus {
  background-color: #ffffff;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(31, 93, 117, 0.15);
}

/* Mejoras de diseño para gestión de empleados */
.emp-stats-card {
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.1rem 1.25rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.emp-stats-icon {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  flex-shrink: 0;
}

.emp-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: linear-gradient(135deg, #1F5D75, #143745);
  color: #ffffff;
  font-weight: 700;
  font-size: 0.8rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 2px 4px rgba(31, 93, 117, 0.2);
}

.emp-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
  margin-right: 6px;
}

.status-dot-active {
  background-color: #10b981;
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.2);
}

.status-dot-inactive {
  background-color: #ef4444;
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.2);
}

/* Submenú Navegación AMFE / Referencias / Control */
.amfe-subnav-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 1.25rem;
}

.amfe-tab-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 700;
  color: #64748b;
  background: #ffffff;
  border: 1px solid #cbd5e1;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.2s ease;
}

.amfe-tab-btn:hover {
  background: #f8fafc;
  color: #0f172a;
  border-color: #94a3b8;
}

.amfe-tab-btn.active {
  background: #ea580c;
  color: #ffffff !important;
  border-color: #c2410c;
  box-shadow: 0 2px 4px rgba(234, 88, 12, 0.25);
}

.amfe-tab-btn.active svg {
  stroke: #ffffff;
}

/* ==========================================================================
   ORDENACIÓN DE COLUMNAS (TABLE SORTER)
   ========================================================================== */
th.sortable-th {
  cursor: pointer !important;
  user-select: none;
  position: relative;
  transition: background-color 0.15s ease, color 0.15s ease;
}

th.sortable-th:hover {
  background-color: #f1f5f9 !important;
  color: #0f172a !important;
}

th.sortable-th .table-sort-arrow {
  margin-left: 6px;
  font-size: 0.82rem;
  line-height: 1;
  display: inline-block;
  opacity: 0.5;
  transition: transform 0.15s ease, color 0.15s ease, opacity 0.15s ease;
  vertical-align: middle;
}

th.sortable-th:hover .table-sort-arrow {
  opacity: 0.9;
  color: #0f172a;
}

th.sortable-th.sorted-desc {
  background-color: #fff7ed !important;
  color: #c2410c !important;
}

th.sortable-th.sorted-desc .table-sort-arrow {
  color: #ea580c !important;
  opacity: 1 !important;
}

th.sortable-th.sorted-asc {
  background-color: #f0f9ff !important;
  color: #0369a1 !important;
}

th.sortable-th.sorted-asc .table-sort-arrow {
  color: #0284c7 !important;
  opacity: 1 !important;
}





/* ==========================================================================
   SISTEMA DE DISEÑO RESPONSIVO Y SOPORTE MÓVIL / TABLET (ACR DIGI)
   ========================================================================== */

/* Estilos base del drawer móvil (oculto en escritorio) */
.mobile-nav-toggle {
  display: none;
}

.mobile-floating-toggle {
  display: none;
}

.sidebar-close-btn {
  display: none;
}

.sidebar-overlay {
  display: none;
}

.table-swipe-hint {
  display: none;
}

/* --------------------------------------------------------------------------
   TABLETS Y PANTALLAS MEDIANAS (<= 1024px)
   -------------------------------------------------------------------------- */
@media (max-width: 1024px) {
  /* Layout general: flujo vertical, sin ancho fijo */
  .app-layout {
    flex-direction: column !important;
    min-height: 100vh !important;
    width: 100% !important;
    overflow-x: hidden !important;
    position: relative !important;
  }

  /* Menú lateral (Sidebar) convertido en Drawer Deslizable (Off-canvas) */
  .sidebar {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    bottom: 0 !important;
    width: 280px !important;
    max-width: 86vw !important;
    height: 100vh !important;
    max-height: 100vh !important;
    z-index: 9999 !important;
    transform: translateX(-100%) !important;
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.3s ease !important;
    box-shadow: none !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch !important;
  }

  .sidebar.mobile-open,
  body.sidebar-open .sidebar {
    transform: translateX(0) !important;
    box-shadow: 0 0 50px rgba(0, 0, 0, 0.5) !important;
  }

  /* Fondo oscurecido (Overlay) al abrir el menú */
  .sidebar-overlay {
    display: block !important;
    position: fixed !important;
    inset: 0 !important;
    background: rgba(15, 23, 42, 0.6) !important;
    backdrop-filter: blur(3px) !important;
    -webkit-backdrop-filter: blur(3px) !important;
    z-index: 9998 !important;
    opacity: 0 !important;
    pointer-events: none !important;
    transition: opacity 0.3s ease !important;
  }

  body.sidebar-open .sidebar-overlay,
  .sidebar-overlay.active {
    opacity: 1 !important;
    pointer-events: auto !important;
  }

  /* Botón de cierre en la cabecera del drawer */
  .sidebar-close-btn {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.12);
    color: #f8fafc;
    border: 1px solid rgba(255, 255, 255, 0.2);
    font-size: 1.3rem;
    line-height: 1;
    cursor: pointer;
    margin-left: auto;
    transition: background 0.15s ease;
  }

  .sidebar-close-btn:hover {
    background: rgba(255, 255, 255, 0.25);
  }

  /* Botón hamburguesa en barra superior */
  .mobile-nav-toggle {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 8px;
    background: #ffffff;
    border: 1px solid #cbd5e1;
    color: #1e293b;
    cursor: pointer;
    flex-shrink: 0;
    margin-right: 0.5rem;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
    transition: all 0.15s ease;
  }

  .mobile-nav-toggle:hover {
    background: #f8fafc;
    border-color: #94a3b8;
  }

  .mobile-nav-toggle:active {
    transform: scale(0.96);
  }

  /* Área principal ocupa todo el ancho */
  .main-content {
    width: 100% !important;
    min-width: 0 !important;
    flex: 1 1 auto !important;
  }

  /* Tablas en tablets: contenedor scrollable */
  .table-responsive,
  div[style*="overflow-x: auto"],
  div[style*="overflow-x:auto"] {
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch !important;
    width: 100% !important;
    max-width: 100% !important;
    display: block !important;
    border-radius: 8px !important;
  }

  /* Malla de módulos en Dashboard */
  .module-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 14px !important;
  }
}

/* --------------------------------------------------------------------------
   MÓVILES Y PANTALLAS PEQUEÑAS (<= 768px)
   -------------------------------------------------------------------------- */
@media (max-width: 768px) {
  /* Evitar scroll horizontal global involuntario */
  html, body {
    overflow-x: hidden !important;
    width: 100% !important;
    -webkit-text-size-adjust: 100%;
  }

  /* Inputs y selects con tamaño mínimo para evitar zoom en iOS */
  input[type="text"],
  input[type="search"],
  input[type="number"],
  input[type="email"],
  input[type="password"],
  select,
  textarea {
    font-size: 16px !important;
  }

  /* Top Navbar compacta */
  .top-navbar {
    height: auto !important;
    min-height: 56px !important;
    padding: 0.5rem 0.75rem !important;
    flex-wrap: wrap !important;
    gap: 0.5rem !important;
    position: sticky !important;
    top: 0 !important;
    z-index: 900 !important;
    background: #ffffff !important;
    border-bottom: 1px solid #e2e8f0 !important;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04) !important;
  }

  .top-navbar > div:first-child {
    display: flex !important;
    align-items: center !important;
    gap: 0.4rem !important;
    flex: 1 1 auto !important;
    min-width: 0 !important;
  }

  .top-navbar h2,
  #top-navbar-title {
    font-size: 1.05rem !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    margin: 0 !important;
  }

  .breadcrumb {
    display: none !important;
  }

  .top-navbar > div:last-child {
    display: flex !important;
    align-items: center !important;
    gap: 0.35rem !important;
    flex-shrink: 0 !important;
  }

  /* En móviles, ocultar el texto descriptivo del selector de idioma de contenido */
  .content-lang-control {
    padding: 3px 6px !important;
    border-radius: 6px !important;
  }

  .content-lang-control label span[data-i18n="lbl_show_content_lang"],
  .content-lang-control label span:not(.sr-only) {
    display: none !important;
  }

  .content-lang-select {
    padding: 4px 6px !important;
    font-size: 0.76rem !important;
    max-width: 105px !important;
  }

  /* Relleno del cuerpo de página optimizado para pantallas táctiles */
  .page-body,
  .content-body,
  .main-content > div[style*="padding: 1.5rem"],
  .main-content > div[style*="padding:1.5rem"] {
    padding: 0.75rem 0.65rem 2rem 0.65rem !important;
    width: 100% !important;
    box-sizing: border-box !important;
  }

  /* Cabeceras de página y botones de acción (Nuevo, Exportar, etc.) */
  .page-header,
  .page-body > div[style*="justify-content: space-between"],
  .page-body > div[style*="justify-content:space-between"] {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 0.75rem !important;
    margin-bottom: 1rem !important;
  }

  .page-header h1,
  .page-body h1,
  .page-body div[style*="font-size: 1.5rem"],
  .page-body div[style*="font-size: 1.4rem"],
  .page-body div[style*="font-size: 1.25rem"] {
    font-size: 1.3rem !important;
    line-height: 1.25 !important;
  }

  .page-header p,
  .page-body p {
    font-size: 0.8rem !important;
  }

  .page-header-actions,
  .page-body > div[style*="justify-content: space-between"] > div:last-child,
  .page-body > div[style*="justify-content:space-between"] > div:last-child {
    display: flex !important;
    flex-wrap: wrap !important;
    gap: 0.5rem !important;
    width: 100% !important;
  }

  .page-header-actions .btn,
  .page-body > div[style*="justify-content: space-between"] > div:last-child .btn,
  .page-body > div[style*="justify-content:space-between"] > div:last-child .btn {
    flex: 1 1 auto !important;
    justify-content: center !important;
    text-align: center !important;
    min-height: 42px !important;
    font-size: 0.84rem !important;
  }

  /* Banners de aviso en columna */
  .update-banner,
  .alert {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 0.75rem !important;
    padding: 0.85rem 1rem !important;
    text-align: left !important;
  }

  .update-banner .btn,
  .alert .btn {
    align-self: flex-start !important;
    width: 100% !important;
    text-align: center !important;
  }

  /* Grids de tarjetas y KPIs a 2 columnas */
  .grid-cards,
  .kpi-grid,
  div[style*="grid-template-columns: repeat(auto-fit, minmax(220px, 1fr))"],
  div[style*="grid-template-columns:repeat(auto-fit,minmax(220px,1fr))"] {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 8px !important;
    margin-bottom: 1rem !important;
  }

  .card,
  .kpi-card {
    padding: 0.75rem 0.85rem !important;
  }

  .card-value,
  .kpi-value {
    font-size: 1.35rem !important;
    line-height: 1.2 !important;
  }

  .card-title,
  .kpi-title {
    font-size: 0.72rem !important;
    margin-bottom: 0.25rem !important;
  }

  .card-subtext {
    font-size: 0.7rem !important;
  }

  /* Barras de filtros y búsqueda responsivas */
  .filter-bar,
  .search-toolbar,
  div[style*="padding: 14px 18px"][style*="display: flex"],
  div[style*="padding:14px 18px"][style*="display:flex"],
  .content-body > div[style*="display: flex"][style*="flex-wrap: wrap"],
  .content-body > div[style*="display:flex"][style*="flex-wrap:wrap"],
  .page-body > div[style*="display: flex"][style*="flex-wrap: wrap"],
  .page-body > div[style*="display:flex"][style*="flex-wrap:wrap"] {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 0.65rem !important;
    padding: 0.85rem !important;
  }

  .filter-bar > div,
  .search-toolbar > div,
  div[style*="flex: 1 1 340px"],
  div[style*="flex:1 1 340px"] {
    width: 100% !important;
    max-width: 100% !important;
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 0.5rem !important;
  }

  .filter-bar input,
  .filter-bar select,
  .search-toolbar input,
  .search-toolbar select,
  div[style*="flex: 1 1 340px"] input,
  div[style*="flex: 1 1 340px"] select,
  div[style*="flex: 1 1 340px"] > div {
    width: 100% !important;
    max-width: 100% !important;
    min-height: 42px !important;
  }

  .filter-bar .btn,
  .search-toolbar .btn,
  div[style*="flex-wrap: wrap"] > div.flex.items-center.gap-2,
  div[style*="flex-wrap: wrap"] > div.flex.items-center.gap-2 button,
  div[style*="flex-wrap: wrap"] > div.flex.items-center.gap-2 .btn {
    width: 100% !important;
    min-height: 40px !important;
    justify-content: center !important;
  }

  /* Pestañas de módulos con scroll táctil horizontal */
  .amfe-tabs-bar,
  .amfe-subnav-tabs,
  .config-tabs-nav,
  .qlab-tabs,
  div[style*="display: flex"][style*="gap: 8px; margin-bottom: 1.5rem"],
  div[style*="display:flex"][style*="gap:8px;margin-bottom:1.5rem"] {
    display: flex !important;
    overflow-x: auto !important;
    white-space: nowrap !important;
    -webkit-overflow-scrolling: touch !important;
    scrollbar-width: none !important;
    padding-bottom: 6px !important;
    gap: 6px !important;
    width: 100% !important;
  }

  .amfe-tabs-bar::-webkit-scrollbar,
  .config-tabs-nav::-webkit-scrollbar,
  .qlab-tabs::-webkit-scrollbar {
    display: none !important;
  }

  .amfe-tab-btn,
  .config-tab-btn,
  .qlab-tab-btn {
    flex: 0 0 auto !important;
    padding: 0.5rem 0.85rem !important;
    font-size: 0.82rem !important;
  }

  /* Barra de herramientas estilo Access en Listado Controles AMFE */
  .ctrl-top-bar {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 0.65rem !important;
    padding: 0.65rem !important;
  }

  .ctrl-actions-group {
    display: flex !important;
    flex-wrap: wrap !important;
    gap: 4px !important;
    width: 100% !important;
  }

  .btn-ctrl-toolbar {
    flex: 1 1 calc(33.333% - 4px) !important;
    min-height: 38px !important;
    justify-content: center !important;
    font-size: 0.68rem !important;
    padding: 4px 6px !important;
  }

  /* Tablas responsivas con desplazamiento suave */
  .data-table,
  table:not(.ui-datepicker-calendar) {
    min-width: 650px;
  }

  .controles-table {
    min-width: 1350px !important;
  }

  #amfe-matriz-table {
    min-width: 1200px !important;
  }

  .data-table th,
  .data-table td,
  table:not(.ui-datepicker-calendar) th,
  table:not(.ui-datepicker-calendar) td {
    padding: 8px 8px !important;
    font-size: 0.78rem !important;
  }

  /* Paginación bajo tabla en columna */
  .table-pagination,
  div[style*="display: flex"][style*="justify-content: space-between"][style*="border-top"],
  div[style*="display:flex"][style*="justify-content:space-between"][style*="border-top"] {
    flex-direction: column !important;
    gap: 0.75rem !important;
    align-items: center !important;
    text-align: center !important;
    padding: 0.85rem 0.5rem !important;
  }

  /* Indicador visual de desplazamiento táctil */
  .table-swipe-hint {
    display: flex !important;
    align-items: center;
    justify-content: center;
    gap: 6px;
    font-size: 0.72rem;
    font-weight: 600;
    color: #475569;
    background: #f1f5f9;
    border: 1px dashed #cbd5e1;
    border-radius: 6px;
    padding: 5px 10px;
    margin-bottom: 6px;
    animation: pulseHint 2s infinite ease-in-out;
  }

  @keyframes pulseHint {
    0%, 100% { opacity: 0.85; }
    50% { opacity: 1; }
  }

  /* Modales tipo Bottom-Sheet en móvil */
  .modal,
  .modal-backdrop,
  div[style*="position: fixed"][style*="inset: 0"],
  div[style*="position:fixed"][style*="inset:0"] {
    padding: 0 !important;
    align-items: flex-end !important;
    justify-content: center !important;
  }

  .modal-dialog,
  .modal-content,
  div[style*="position: fixed"] > div[style*="background: #ffffff"],
  div[style*="position:fixed"] > div[style*="background:#ffffff"],
  div[style*="position: fixed"] > div[style*="background: rgb(255, 255, 255)"],
  div[style*="position:fixed"] > div[style*="background:rgb(255, 255, 255)"] {
    width: 100% !important;
    max-width: 100vw !important;
    max-height: 92vh !important;
    border-radius: 16px 16px 0 0 !important;
    margin: 0 !important;
    display: flex !important;
    flex-direction: column !important;
    box-sizing: border-box !important;
    animation: slideUpModal 0.25s cubic-bezier(0.16, 1, 0.3, 1) !important;
  }

  @keyframes slideUpModal {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
  }

  .modal-dialog > form,
  .modal-content > form {
    display: flex !important;
    flex-direction: column !important;
    flex: 1 1 auto !important;
    min-height: 0 !important;
    overflow: hidden !important;
    margin: 0 !important;
  }

  .modal-header {
    flex-shrink: 0 !important;
  }

  .modal-body {
    flex: 1 1 auto !important;
    min-height: 0 !important;
    max-height: none !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch !important;
    padding: 1rem !important;
  }

  div[style*="position: fixed"] form,
  div[style*="position:fixed"] form {
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch !important;
    padding: 1rem !important;
    max-height: calc(92dvh - 120px) !important;
  }

  .modal-body div[style*="grid-template-columns"]:not(#modal-module-perms),
  div[style*="position: fixed"] form div[style*="grid-template-columns"] {
    grid-template-columns: 1fr !important;
    gap: 0.65rem !important;
  }

  .modal-footer,
  div[style*="position: fixed"] form > div:last-child[style*="display: flex"],
  div[style*="position: fixed"] form > div:last-child[style*="display:flex"] {
    display: flex !important;
    flex-direction: column-reverse !important;
    flex-shrink: 0 !important;
    gap: 0.5rem !important;
    padding: 0.75rem 1rem calc(0.75rem + env(safe-area-inset-bottom, 0px)) 1rem !important;
    width: 100% !important;
    box-sizing: border-box !important;
  }

  .modal-footer .btn,
  div[style*="position: fixed"] form > div:last-child .btn {
    width: 100% !important;
    min-height: 44px !important;
    font-size: 0.95rem !important;
    font-weight: 700 !important;
    justify-content: center !important;
  }

  /* Tarjeta de configuración en móvil */
  .config-layout-card {
    padding: 1.15rem 0.85rem !important;
    border-radius: 14px !important;
    max-width: 100% !important;
  }

  /* Tarjeta de Login y Recuperar contraseña en móvil */
  .login-container {
    padding: 1.25rem 0.85rem !important;
  }

  .login-card {
    padding: 1.65rem 1.15rem !important;
    border-radius: 14px !important;
    max-width: 100% !important;
  }
}

/* --------------------------------------------------------------------------
   PANTALLAS MUY PEQUEÑAS / SMARTPHONES COMPACTOS (<= 480px)
   -------------------------------------------------------------------------- */
@media (max-width: 480px) {
  .top-navbar {
    padding: 0.4rem 0.5rem !important;
  }

  #top-navbar-title {
    font-size: 0.95rem !important;
  }

  .page-body {
    padding: 0.5rem 0.4rem 2rem 0.4rem !important;
  }

  /* En móviles muy estrechos, KPIs a 2 columnas compactas */
  .grid-cards,
  .kpi-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 6px !important;
  }

  .card-value,
  .kpi-value {
    font-size: 1.2rem !important;
  }

  /* Módulos de inicio en Dashboard a 1 columna o 2 compactas */
  .module-grid {
    grid-template-columns: 1fr !important;
    gap: 8px !important;
  }

  .btn-ctrl-toolbar {
    flex: 1 1 calc(50% - 4px) !important;
  }

  .kpi-card > div:last-child {
    width: 36px !important;
    height: 36px !important;
    font-size: 1rem !important;
    flex-shrink: 0 !important;
  }
}


/* ==========================================================================
   REGLAS ESPECÍFICAS DE MÓDULOS PARA MÓVILES (ACR DIGI)
   ========================================================================== */

/* Q-Lab Responsive */
@media (max-width: 1024px) {
  .mobile-floating-toggle {
    display: inline-flex !important;
    position: fixed !important;
    top: 12px !important;
    left: 12px !important;
    z-index: 950 !important;
    width: 42px !important;
    height: 42px !important;
    border-radius: 10px !important;
    background: #ffffff !important;
    border: 1px solid #cbd5e1 !important;
    color: #1e293b !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15) !important;
    cursor: pointer !important;
    align-items: center !important;
    justify-content: center !important;
  }
}

@media (max-width: 768px) {
  .qlab-container {
    padding: 1rem 0.5rem !important;
    max-width: 100% !important;
  }

  .qlab-header {
    justify-content: center !important;
    margin-bottom: 1.5rem !important;
    padding-top: 2rem !important; /* Espacio para botón flotante */
  }

  .qlab-title-text {
    font-size: 1.4rem !important;
  }

  .qlab-grid {
    grid-template-columns: 1fr !important;
    gap: 1.5rem !important;
  }

  .qlab-card-label {
    font-size: 1.15rem !important;
  }

  .qlab-card-btn {
    width: 100% !important;
    max-width: 240px !important;
    height: 150px !important;
  }

  .qlab-card-btn svg {
    width: 80px !important;
    height: 80px !important;
  }

  .qlab-utils-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 0.75rem 1rem !important;
  }

  .qlab-util-btn {
    width: 68px !important;
    height: 62px !important;
  }

  .qlab-footer-bar {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 1rem !important;
    margin-top: 1.5rem !important;
    padding-top: 1rem !important;
  }

  .qlab-actions {
    justify-content: center !important;
  }

  .equipos-med-table {
    min-width: 1100px !important;
  }

  /* Control de Producción Responsive */
  .cp-stats-grid,
  .cp-kpi-bar {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 8px !important;
  }

  .cp-process-flow {
    overflow-x: auto !important;
    white-space: nowrap !important;
    -webkit-overflow-scrolling: touch !important;
    padding-bottom: 8px !important;
  }
}

/* ==========================================================================
   CONTROL DE MENÚ PRINCIPAL: EXPANDIR, OCULTAR Y MODO FIJO / AUTO (ESCRITORIO)
   ========================================================================== */

.sidebar-menu-title.has-sidebar-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.75rem 0.9rem 0.45rem 1.25rem;
}

.sidebar-header-controls {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-left: auto;
}

.sidebar-header-controls .sidebar-theme-btn,
.q-theme-toggle-btn.sidebar-theme-btn,
.sidebar-theme-btn,
.sidebar-pin-btn,
.sidebar-hide-btn {
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  width: 26px !important;
  height: 26px !important;
  min-width: 26px !important;
  min-height: 26px !important;
  padding: 0 !important;
  gap: 0 !important;
  border-radius: 6px !important;
  border: 1px solid rgba(255, 255, 255, 0.18) !important;
  background: rgba(255, 255, 255, 0.08) !important;
  color: #cbd5e1 !important;
  cursor: pointer;
  transition: all 0.18s ease;
  line-height: 1;
  box-shadow: none !important;
}

.sidebar-theme-btn svg,
.sidebar-pin-btn svg,
.sidebar-hide-btn svg {
  width: 15px !important;
  height: 15px !important;
  min-width: 15px !important;
  min-height: 15px !important;
  flex-shrink: 0 !important;
  display: block !important;
  pointer-events: none;
}

.sidebar-header-controls .sidebar-theme-btn,
.q-theme-toggle-btn.sidebar-theme-btn {
  background: rgba(56, 189, 248, 0.12) !important;
  border-color: rgba(125, 211, 252, 0.35) !important;
  color: #fde047 !important;
}

.sidebar-header-controls .sidebar-theme-btn:hover,
.q-theme-toggle-btn.sidebar-theme-btn:hover,
.sidebar-theme-btn:hover,
.sidebar-pin-btn:hover,
.sidebar-hide-btn:hover {
  background: rgba(255, 255, 255, 0.18) !important;
  color: #ffffff !important;
  border-color: rgba(255, 255, 255, 0.35) !important;
  transform: none !important;
}

.sidebar-header-controls .sidebar-theme-btn[data-theme-state="dark"],
.q-theme-toggle-btn.sidebar-theme-btn[data-theme-state="dark"],
.sidebar-theme-btn[data-theme-state="dark"] {
  background: rgba(251, 191, 36, 0.18) !important;
  border-color: rgba(251, 191, 36, 0.5) !important;
  color: #fbbf24 !important;
  box-shadow: 0 0 8px rgba(251, 191, 36, 0.18) !important;
}

.sidebar-header-controls .sidebar-theme-btn[data-theme-state="dark"]:hover,
.q-theme-toggle-btn.sidebar-theme-btn[data-theme-state="dark"]:hover,
.sidebar-theme-btn[data-theme-state="dark"]:hover {
  background: rgba(251, 191, 36, 0.28) !important;
  color: #fde68a !important;
  border-color: rgba(251, 191, 36, 0.7) !important;
}

.sidebar-pin-btn.is-pinned {
  background: rgba(56, 189, 248, 0.16);
  border-color: rgba(56, 189, 248, 0.45);
  color: #38bdf8;
  box-shadow: 0 0 8px rgba(56, 189, 248, 0.15);
}

.sidebar-pin-btn.is-pinned:hover {
  background: rgba(56, 189, 248, 0.26);
  color: #7dd3fc;
}

/* Pestaña acoplada al borde izquierdo para expandir cuando está oculto */
.sidebar-edge-handle {
  position: fixed;
  left: 0;
  top: 22px;
  z-index: 1040;
  display: none;
  align-items: center;
  gap: 7px;
  height: 40px;
  padding: 0 11px 0 9px;
  background: linear-gradient(135deg, #122933 0%, #1F5D75 100%);
  color: #f8fafc;
  border: 1px solid rgba(56, 189, 248, 0.38);
  border-left: none;
  border-radius: 0 10px 10px 0;
  box-shadow: 4px 4px 16px rgba(15, 23, 42, 0.25);
  cursor: pointer;
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  transition: all 0.22s cubic-bezier(0.16, 1, 0.3, 1);
}

body.has-top-navbar .sidebar-edge-handle {
  top: 76px;
}

.sidebar-edge-handle .handle-label {
  max-width: 0;
  overflow: hidden;
  opacity: 0;
  white-space: nowrap;
  transition: max-width 0.22s ease, opacity 0.18s ease, margin 0.18s ease;
}

.sidebar-edge-handle:hover {
  padding-right: 14px;
  background: linear-gradient(135deg, #163542 0%, #256f8c 100%);
  box-shadow: 6px 6px 20px rgba(15, 23, 42, 0.32);
}

.sidebar-edge-handle:hover .handle-label {
  max-width: 120px;
  opacity: 1;
  margin-left: 2px;
}

/* Franja sensora en el borde izquierdo para auto-expandir en modo Auto */
.sidebar-hover-zone {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: 12px;
  z-index: 1035;
  display: none;
  background: transparent;
}

@media (min-width: 1025px) {
  .sidebar {
    transition: margin-left 0.28s cubic-bezier(0.16, 1, 0.3, 1),
                transform 0.28s cubic-bezier(0.16, 1, 0.3, 1),
                box-shadow 0.28s ease,
                opacity 0.22s ease;
  }

  /* 1. Estado Oculto en modo Fijo (el usuario pulsó Ocultar) */
  body.sidebar-collapsed:not(.sidebar-unpinned) .sidebar {
    margin-left: -260px;
    opacity: 0;
    pointer-events: none;
  }

  /* 2. Modo Auto-ocultable (Desfijado): el menú flota y se oculta al salir */
  body.sidebar-unpinned .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    height: 100vh;
    max-height: 100vh;
    z-index: 1060;
    margin-left: 0;
    transform: translateX(-100%);
    box-shadow: none;
    opacity: 0;
    pointer-events: none;
  }

  /* Cuando se expande temporalmente en Modo Auto (hover o clic) */
  body.sidebar-unpinned.sidebar-peek-open .sidebar {
    transform: translateX(0);
    box-shadow: 12px 0 36px rgba(15, 23, 42, 0.38);
    opacity: 1;
    pointer-events: auto;
  }

  /* Mostrar la pestaña de expandir cuando el menú está oculto */
  body.sidebar-collapsed:not(.sidebar-unpinned) .sidebar-edge-handle,
  body.sidebar-unpinned:not(.sidebar-peek-open) .sidebar-edge-handle {
    display: inline-flex;
  }

  /* Activar zona sensora de borde izquierdo cuando está en Modo Auto y oculto */
  body.sidebar-unpinned:not(.sidebar-peek-open) .sidebar-hover-zone {
    display: block;
  }

  /* Mostrar también el botón de menú en top-navbar si el sidebar está oculto */
  body.sidebar-collapsed:not(.sidebar-unpinned) .mobile-nav-toggle,
  body.sidebar-unpinned:not(.sidebar-peek-open) .mobile-nav-toggle {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border-radius: 8px;
    background: #f8fafc;
    border: 1px solid #cbd5e1;
    color: #1e293b;
    cursor: pointer;
    margin-right: 0.65rem;
    transition: all 0.15s ease;
  }

  body.sidebar-collapsed:not(.sidebar-unpinned) .mobile-nav-toggle:hover,
  body.sidebar-unpinned:not(.sidebar-peek-open) .mobile-nav-toggle:hover {
    background: #e2e8f0;
    border-color: #94a3b8;
  }

  /* Ligero margen izquierdo cuando el menú está oculto en páginas sin top-navbar para que la pestaña nunca tape contenido */
  body:not(.has-top-navbar).sidebar-collapsed:not(.sidebar-unpinned) .main-content,
  body:not(.has-top-navbar).sidebar-unpinned .main-content {
    padding-left: 18px;
    transition: padding-left 0.25s ease;
  }
}

@media (max-width: 1024px) {
  .sidebar-header-controls {
    display: none !important;
  }
}

/* ==========================================================================
   CABECERA CORPORATIVA UNIFICADA DE MÓDULOS (Q NUEVA + TEXTO GRIS #58595A)
   ========================================================================== */
.qmodule-q-icon,
.apqp-q-symbol,
.acc-q-symbol,
.aud-q-symbol,
.qdoc-q-symbol,
.qlab-q-symbol,
.qpro-q-symbol,
.amfe-q-symbol,
.rrhh-q-symbol {
  width: 82px;
  height: 82px;
  object-fit: contain;
  display: block;
  flex-shrink: 0;
  transform-origin: 48% 50%;
  animation: qSubtleFadeIn 0.55s ease-out forwards,
             qSubtleBreathe 6.5s ease-in-out 0.65s infinite;
  filter: drop-shadow(0 3px 8px rgba(38, 96, 139, 0.16));
  transition: transform 0.35s ease, filter 0.35s ease;
}

.qmodule-q-icon:hover,
.apqp-header-logo:hover .apqp-q-symbol,
.acc-header-logo:hover .acc-q-symbol,
.aud-header-logo:hover .aud-q-symbol,
.qdoc-header-logo:hover .qdoc-q-symbol,
.qlab-header:hover .qlab-q-symbol,
.qpro-header-logo:hover .qpro-q-symbol,
.amfe-header-logo:hover .amfe-q-symbol,
.rrhh-header-logo:hover .rrhh-q-symbol {
  transform: scale(1.03) rotate(-3deg);
  filter: drop-shadow(0 4px 10px rgba(38, 96, 139, 0.24));
}

.qmodule-mini-q-icon {
  width: 19px;
  height: 19px;
  object-fit: contain;
  display: inline-block;
  vertical-align: middle;
  flex-shrink: 0;
}

@keyframes qSubtleFadeIn {
  0% {
    opacity: 0;
    transform: scale(0.95) rotate(-5deg);
  }
  100% {
    opacity: 1;
    transform: scale(1) rotate(0deg);
  }
}

@keyframes qSubtleBreathe {
  0%, 100% {
    transform: translateY(0px) scale(1);
  }
  50% {
    transform: translateY(-1.5px) scale(1.012);
  }
}

/* ==========================================================================
   OPTIMIZACIÓN INTEGRAL PARA MÓVILES Y TABLETS (TODOS LOS MÓDULOS Y VISTAS)
   ========================================================================== */

/* 1. TABLET Y MÓVIL (<= 1024px) */
@media (max-width: 1024px) {
  /* Evitar que el botón hamburguesa flotante tape el icono Q en cabeceras sin top-navbar */
  body:not(.has-top-navbar) .apqp-header-logo,
  body:not(.has-top-navbar) .acc-header-logo,
  body:not(.has-top-navbar) .aud-header-logo,
  body:not(.has-top-navbar) .qdoc-header-logo,
  body:not(.has-top-navbar) .qlab-header,
  body:not(.has-top-navbar) .rrhh-header-logo,
  body:not(.has-top-navbar) .qdesktop-header-logo {
    padding-left: 48px !important;
    margin-left: 0 !important;
  }

  /* Escalado proporcional del icono Q corporativo y títulos de módulo en tablet */
  .qmodule-q-icon,
  .apqp-q-symbol,
  .acc-q-symbol,
  .aud-q-symbol,
  .qdoc-q-symbol,
  .qlab-q-symbol,
  .qpro-q-symbol,
  .amfe-q-symbol,
  .rrhh-q-symbol {
    width: 66px !important;
    height: 66px !important;
  }

  .apqp-header-title,
  .acc-header-title,
  .aud-header-title,
  .qdoc-header-title,
  .qlab-title-text,
  .qpro-header-title,
  .amfe-header-title,
  .rrhh-header-title {
    font-size: clamp(1.8rem, 4.2vw, 2.55rem) !important;
    line-height: 1.1 !important;
  }

  /* Tablas densas de AMFE y Controles: permitir desplazamiento táctil horizontal en tablet/móvil */
  #amfe-matriz-table,
  .controles-table {
    min-width: 1020px !important;
  }

  /* Hoja oficial de Pauta de Control en modal (control_produccion.html / realizacion_control_produccion.html) */
  .pauta-modal-scroll {
    justify-content: flex-start !important;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch !important;
    padding: 10px !important;
  }

  .pauta-doc-sheet {
    min-width: 740px !important;
    padding: 16px !important;
  }

  .pauta-mid-grid {
    grid-template-columns: 1fr !important;
    gap: 12px !important;
  }

  /* Filtros de Histórico de Control en Producción y CCC en 2 columnas en tablet */
  .hist-filter-grid {
    grid-template-columns: repeat(2, 1fr) !important;
  }
}

/* 2. MÓVIL Y TABLET VERTICAL (<= 768px) */
@media (max-width: 768px) {
  /* Escalado del icono Q corporativo y títulos de módulo en móvil */
  .qmodule-q-icon,
  .apqp-q-symbol,
  .acc-q-symbol,
  .aud-q-symbol,
  .qdoc-q-symbol,
  .qlab-q-symbol,
  .qpro-q-symbol,
  .amfe-q-symbol,
  .rrhh-q-symbol {
    width: 50px !important;
    height: 50px !important;
  }

  .apqp-header-title,
  .acc-header-title,
  .aud-header-title,
  .qdoc-header-title,
  .qlab-title-text,
  .qpro-header-title,
  .amfe-header-title,
  .rrhh-header-title {
    font-size: clamp(1.35rem, 5.2vw, 1.85rem) !important;
    line-height: 1.15 !important;
    word-break: break-word;
  }

  /* Cabecera Q-DESKTOP WEB en Dashboard */
  .qdesktop-header-logo {
    max-width: 100%;
    overflow: hidden;
  }

  .qdesktop-q-wrap,
  .qdesktop-q-symbol,
  .qdesktop-web-text-img {
    height: clamp(38px, 11vw, 56px) !important;
    max-width: calc(100vw - 96px);
    object-fit: contain;
  }

  /* Modal Configurador de Datos en Dashboard */
  .qd-config-body {
    padding: 14px 12px 18px 12px !important;
  }

  .qd-config-row {
    flex-wrap: wrap !important;
    justify-content: center !important;
    gap: 8px !important;
  }

  .qd-menu-arrow-empty {
    display: none !important;
  }

  .qd-subform-colbar-wrap {
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch;
  }

  .qd-form-header {
    padding: 8px 12px !important;
    flex-wrap: wrap !important;
    gap: 8px !important;
  }

  .qd-form-header-title {
    font-size: 1.2rem !important;
  }

  /* Lienzos y pies de página de módulos (Q-DOC, Q-LAB, Q-PRO, Q-ACC, Q-APQP, Q-AUD, RRHH) */
  .qdoc-main-canvas,
  .acc-main-canvas,
  .apqp-main-canvas,
  .aud-main-canvas,
  .rrhh-main-canvas,
  .qlab-container {
    padding: 1rem 0.9rem 1.5rem 0.9rem !important;
  }

  .qdoc-footer-bar,
  .acc-footer-bar,
  .apqp-footer-bar,
  .aud-footer-bar,
  .rrhh-footer-bar,
  .qlab-footer-bar {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 1rem !important;
  }

  .qdoc-user-lang-box,
  .acc-user-lang-box,
  .apqp-user-lang-box,
  .aud-user-lang-box,
  .rrhh-user-lang-box {
    grid-template-columns: 1fr !important;
    width: 100% !important;
    max-width: 100% !important;
  }

  .qlab-input-row {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 4px !important;
  }

  .qlab-input-row label {
    width: auto !important;
  }

  .qlab-input-field {
    width: 100% !important;
    min-width: 0 !important;
  }

  .qdoc-bottom-actions,
  .acc-bottom-actions,
  .apqp-bottom-actions,
  .aud-bottom-actions,
  .rrhh-bottom-actions {
    justify-content: center !important;
  }

  /* Mapa de Procesos en Q-DOC */
  .mp-layout {
    grid-template-columns: 1fr !important;
    padding: 12px !important;
    gap: 12px !important;
  }

  .mp-side-pillar {
    writing-mode: horizontal-tb !important;
    transform: none !important;
    padding: 10px 14px !important;
    width: 100% !important;
    font-size: 0.9rem !important;
    box-sizing: border-box;
  }

  .qdoc-subview {
    padding: 0.75rem 0.65rem !important;
  }

  /* Cabeceras de ventanas estilo Q-Desktop (Referencias, AMFE, Q-PRO, Q-LAB) */
  .qdesktop-header-bar,
  .ctrl-top-bar,
  .med-top-bar,
  .amfe-cfg-header,
  .pauta-guideline-header,
  .flow-top-bar,
  .pauta-modal-toolbar {
    flex-wrap: wrap !important;
    gap: 8px !important;
    padding: 8px 12px !important;
    min-height: 0 !important;
  }

  .qdesktop-header-title,
  .ctrl-top-title,
  .amfe-cfg-header-title,
  .pauta-guideline-main-title,
  .flow-main-title {
    font-size: 1.15rem !important;
  }

  .qdesktop-toolbar-group,
  .pauta-guideline-toolbar,
  .flow-toolbar-right,
  .amfe-cfg-header-actions {
    flex-wrap: wrap !important;
    gap: 8px !important;
    margin-right: 0 !important;
  }

  .pauta-guideline-header-left {
    gap: 12px !important;
  }

  .pauta-guideline-ref-code {
    font-size: 1.15rem !important;
  }

  /* Modal Ficha AMFE y Flow Proceso en Referencias */
  .informes-grid {
    grid-template-columns: 1fr !important;
    gap: 12px !important;
  }

  .flow-top-area {
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch;
  }

  .flow-col-headers,
  .flow-row-item {
    min-width: 640px !important;
  }

  .amfe-cfg-body {
    padding: 14px !important;
  }

  .amfe-cfg-split-row {
    gap: 16px !important;
  }

  .ficha-field-row,
  .ficha-field-row.col3 {
    grid-template-columns: 95px 1fr !important;
  }

  /* Q-OF (Órdenes de Fabricación), Control en Producción, Histórico y CCC */
  .of-container {
    padding: 1rem 0.85rem 2rem 0.85rem !important;
    gap: 1.15rem !important;
  }

  .of-title-text {
    font-size: 1.35rem !important;
    flex-wrap: wrap;
  }

  .of-search-hero {
    padding: 1.1rem 1rem !important;
  }

  .of-kpi-grid {
    grid-template-columns: 1fr !important;
    gap: 0.85rem !important;
  }

  .of-module-card {
    padding: 1.25rem !important;
  }

  .hist-filter-grid {
    grid-template-columns: 1fr !important;
  }

  .cp-view-switcher {
    padding: 10px 12px !important;
    flex-direction: column !important;
    align-items: stretch !important;
  }

  .cp-view-tab-group {
    width: 100%;
    display: flex;
  }

  .cp-view-tab {
    flex: 1 1 auto;
    justify-content: center;
    padding: 7px 10px !important;
    font-size: 0.78rem !important;
  }

  .pagination-bar {
    flex-direction: column !important;
    gap: 8px !important;
    align-items: center !important;
    text-align: center;
  }

  .pagination-buttons {
    flex-wrap: wrap;
    justify-content: center;
  }

  .pieza-suggestions-dropdown {
    min-width: 0 !important;
    width: 100% !important;
    max-width: calc(100vw - 32px) !important;
  }

  /* Login, Restablecer Contraseña y Configuración */
  .login-hero-header {
    padding: 1.25rem 1.15rem 1.4rem 1.15rem !important;
  }

  .login-form-body {
    padding: 1.25rem 1.15rem 1.5rem 1.15rem !important;
  }

  .config-hero-banner {
    padding: 1.2rem 1.1rem !important;
  }

  .config-body-wrap {
    padding: 1.1rem 0.9rem 1.5rem 0.9rem !important;
  }

  .config-section-card {
    padding: 1.15rem 1rem !important;
  }

  .config-tab-btn {
    font-size: 0.78rem !important;
    padding: 0.55rem 0.75rem !important;
  }
}

/* 3. MÓVILES COMPACTOS (<= 480px) */
@media (max-width: 480px) {
  .qmodule-q-icon,
  .apqp-q-symbol,
  .acc-q-symbol,
  .aud-q-symbol,
  .qdoc-q-symbol,
  .qlab-q-symbol,
  .qpro-q-symbol,
  .amfe-q-symbol,
  .rrhh-q-symbol {
    width: 42px !important;
    height: 42px !important;
  }

  .ficha-field-row,
  .ficha-field-row.col3 {
    grid-template-columns: 1fr !important;
    gap: 3px !important;
  }

  .kpi-strip {
    grid-template-columns: 1fr !important;
  }
}

/* ==========================================================================
   SISTEMA GLOBAL DE TEMA: MODO CLARO / MODO OSCURO (TODA LA WEB)
   ========================================================================== */

/* Botón conmutador Modo Claro / Modo Oscuro */
.q-theme-toggle-btn:not(.sidebar-theme-btn) {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  padding: 0.4rem 0.8rem;
  border-radius: 8px;
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-main);
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.08);
  transition: all 0.2s ease;
  white-space: nowrap;
  user-select: none;
}

.q-theme-toggle-btn:not(.sidebar-theme-btn):hover {
  border-color: var(--primary);
  background: var(--primary-light);
  transform: translateY(-1px);
}

.q-theme-btn-sidebar {
  width: 100%;
  background-color: #173542;
  border-color: #244d5f;
  color: #f0f6f8;
  padding: 0.45rem 0.75rem;
  justify-content: center;
}

.q-theme-btn-sidebar:hover {
  background-color: #1f4657;
  border-color: #38bdf8;
  color: #ffffff;
}

.login-hero-header .q-theme-btn-login {
  background: rgba(255, 255, 255, 0.14) !important;
  border: 1px solid rgba(255, 255, 255, 0.26) !important;
  color: #ffffff !important;
  border-radius: 999px !important;
  padding: 0.26rem 0.68rem !important;
  font-size: 0.74rem !important;
  white-space: nowrap !important;
  flex-shrink: 0;
  backdrop-filter: blur(6px);
}

.login-hero-header .q-theme-btn-login:hover {
  background: rgba(255, 255, 255, 0.24) !important;
  border-color: rgba(255, 255, 255, 0.45) !important;
}

/* Variables raíz en Modo Oscuro */
html[data-theme="dark"],
body.dark-mode {
  color-scheme: dark;
  --primary: #38bdf8;
  --primary-hover: #0284c7;
  --primary-active: #0369a1;
  --primary-light: #1e293b;
  --primary-lighter: #0f172a;
  --primary-tint: #7dd3fc;

  --text-main: #f1f5f9;
  --text-muted: #94a3b8;
  --border: #334155;
  --border-focus: #38bdf8;

  --bg-main: #0b1120;
  --bg-card: #1e293b;

  --sidebar-bg: #09131c;
  --sidebar-text: #f1f5f9;
  --sidebar-muted: #94a3b8;
  --sidebar-hover: #132838;
  --sidebar-active: #0284c7;
  --sidebar-border: #1e293b;

  --success: #34d399;
  --success-bg: rgba(16, 185, 129, 0.16);
  --warning: #fbbf24;
  --warning-bg: rgba(245, 158, 11, 0.16);
  --danger: #f87171;
  --danger-bg: rgba(239, 68, 68, 0.16);

  --shadow: 0 4px 12px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 12px 28px rgba(0, 0, 0, 0.5);
}

/* ==========================================================================
   LOGOTIPOS E IMÁGENES DE MARCA EN MODO OSCURO
   ========================================================================== */
html[data-theme="dark"] body .sidebar-brand > div:first-child,
html[data-theme="dark"] body .login-logo-box,
html[data-theme="dark"] body .config-hero-logo-box,
html[data-theme="dark"] body .logo-showcase-box {
  background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%) !important;
  border: 1px solid #334155 !important;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06), 0 4px 12px rgba(0, 0, 0, 0.35) !important;
}

html[data-theme="dark"] body .company-logo,
html[data-theme="dark"] body #company-logo-preview {
  background: transparent !important;
  filter: brightness(1.16) contrast(1.06) drop-shadow(0 1px 3px rgba(0, 0, 0, 0.55));
}

html[data-theme="dark"] body .qdesktop-web-text-img {
  filter: brightness(0) invert(1) opacity(0.92) !important;
}

html[data-theme="dark"] body .qdesktop-q-symbol,
html[data-theme="dark"] body .qdesktop-q-rig,
html[data-theme="dark"] body .acc-q-symbol,
html[data-theme="dark"] body .amfe-q-symbol,
html[data-theme="dark"] body .apqp-q-symbol,
html[data-theme="dark"] body .aud-q-symbol,
html[data-theme="dark"] body .qdoc-q-symbol,
html[data-theme="dark"] body .qlab-q-symbol,
html[data-theme="dark"] body .qpro-q-symbol,
html[data-theme="dark"] body .rrhh-q-symbol,
html[data-theme="dark"] body .qmodule-mini-q-icon {
  filter: brightness(1.35) saturate(1.15) drop-shadow(0 2px 6px rgba(56, 189, 248, 0.25));
}

/* ==========================================================================
   ESTRUCTURA GENERAL, BARRAS DE NAVEGACIÓN Y LIENZOS
   ========================================================================== */
html[data-theme="dark"] body,
html[data-theme="dark"] body .app-layout,
html[data-theme="dark"] body .main-content,
html[data-theme="dark"] body .page-body,
html[data-theme="dark"] body .page-content {
  background: var(--bg-main) !important;
  background-color: var(--bg-main) !important;
  color: var(--text-main) !important;
}

html[data-theme="dark"] body .top-navbar {
  background: #0f172a !important;
  background-color: #0f172a !important;
  border-bottom-color: #1e293b !important;
  color: #f1f5f9 !important;
}

html[data-theme="dark"] body .site-footer,
html[data-theme="dark"] body .qlab-footer-bar,
html[data-theme="dark"] body .apqp-footer-bar,
html[data-theme="dark"] body .acc-footer-bar,
html[data-theme="dark"] body .qdoc-footer-bar,
html[data-theme="dark"] body .aud-footer-bar,
html[data-theme="dark"] body .rrhh-footer-bar {
  background: #0f172a !important;
  background-color: #0f172a !important;
  border-color: #1e293b !important;
  color: #94a3b8 !important;
}

/* Sub-barra de navegación Q-PRO (of.html, ccc.html, control_produccion.html, realizacion, historico) */
html[data-theme="dark"] body .qpro-subnav-bar,
html[data-theme="dark"] body .config-tabs-nav,
html[data-theme="dark"] body .modern-view-subbar {
  background: #0f172a !important;
  border-color: #334155 !important;
  color: #f1f5f9 !important;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3) !important;
}

html[data-theme="dark"] body .qpro-subnav-pill,
html[data-theme="dark"] body .config-tab-btn,
html[data-theme="dark"] body .modern-chip-btn {
  background: #1e293b !important;
  border-color: #334155 !important;
  color: #cbd5e1 !important;
}

html[data-theme="dark"] body .qpro-subnav-pill:hover,
html[data-theme="dark"] body .config-tab-btn:hover,
html[data-theme="dark"] body .modern-chip-btn:hover {
  background: #334155 !important;
  color: #ffffff !important;
}

html[data-theme="dark"] body .qpro-subnav-pill.active,
html[data-theme="dark"] body .config-tab-btn.active,
html[data-theme="dark"] body .modern-chip-btn.active {
  background: linear-gradient(135deg, #0284c7 0%, #2563eb 100%) !important;
  border-color: #38bdf8 !important;
  color: #ffffff !important;
}

/* ==========================================================================
   TARJETAS, PANELES, MODALES Y CONTENEDORES PRINCIPALES
   ========================================================================== */
html[data-theme="dark"] body .card,
html[data-theme="dark"] body .table-container,
html[data-theme="dark"] body .config-card,
html[data-theme="dark"] body .login-card,
html[data-theme="dark"] body .login-card-body,
html[data-theme="dark"] body .modal-dialog,
html[data-theme="dark"] body .modal-content,
html[data-theme="dark"] body .modal-box-ccc,
html[data-theme="dark"] body .modal-box-hist,
html[data-theme="dark"] body #modal-detalle-control,
html[data-theme="dark"] body .tipo-pauta-modal-card,
html[data-theme="dark"] body .module-card,
html[data-theme="dark"] body .module-status-card,
html[data-theme="dark"] body .license-kpi-card,
html[data-theme="dark"] body .kpi-card,
html[data-theme="dark"] body .kpi-card-hist,
html[data-theme="dark"] body .of-kpi-card,
html[data-theme="dark"] body .of-module-card,
html[data-theme="dark"] body .of-table-box,
html[data-theme="dark"] body .chart-card,
html[data-theme="dark"] body .config-layout-card,
html[data-theme="dark"] body .config-section-card,
html[data-theme="dark"] body .config-form-panel,
html[data-theme="dark"] body .qd-config-menu-window,
html[data-theme="dark"] body .qd-access-window,
html[data-theme="dark"] body .amfe-cfg-window,
html[data-theme="dark"] body .ficha-amfe-modal-window,
html[data-theme="dark"] body .flow-proceso-modal-window,
html[data-theme="dark"] body .ctrl-window-box,
html[data-theme="dark"] body .med-window-box,
html[data-theme="dark"] body .apqp-window-box,
html[data-theme="dark"] body .acc-window-box,
html[data-theme="dark"] body .qdoc-window-box,
html[data-theme="dark"] body .aud-window-box,
html[data-theme="dark"] body .rrhh-window-box,
html[data-theme="dark"] body .apqp-modal-box,
html[data-theme="dark"] body .acc-modal-box,
html[data-theme="dark"] body .qdoc-modal-box,
html[data-theme="dark"] body .qlab-modal-box,
html[data-theme="dark"] body .aud-modal-box,
html[data-theme="dark"] body .rrhh-modal-box,
html[data-theme="dark"] body .qdesktop-panel,
html[data-theme="dark"] body .ref-modern-card,
html[data-theme="dark"] body .ficha-group-box,
html[data-theme="dark"] body .ficha-photo-box {
  background: #1e293b !important;
  border-color: #334155 !important;
  color: #f1f5f9 !important;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35) !important;
}

html[data-theme="dark"] body .kpi-card-hist.kpi-overdue-card {
  background: linear-gradient(180deg, #1e293b 0%, rgba(127, 29, 29, 0.35) 100%) !important;
  border-color: #ef4444 !important;
}

html[data-theme="dark"] body .kpi-progress-track,
html[data-theme="dark"] body .bar-stat-track,
html[data-theme="dark"] body .ccc-time-bar-track,
html[data-theme="dark"] body .fase-step-progress-bar,
html[data-theme="dark"] body .cac-fase-progress-line {
  background: #0f172a !important;
  border-color: #334155 !important;
}

/* Lienzos principales de módulos (APQP, ACC, Q-DOC, Q-LAB, AUD, RRHH, OF, Config, Referencias) */
html[data-theme="dark"] body .apqp-main-canvas,
html[data-theme="dark"] body .acc-main-canvas,
html[data-theme="dark"] body .qdoc-main-canvas,
html[data-theme="dark"] body .aud-main-canvas,
html[data-theme="dark"] body .rrhh-main-canvas,
html[data-theme="dark"] body .qlab-container,
html[data-theme="dark"] body .rrhh-container,
html[data-theme="dark"] body .of-container,
html[data-theme="dark"] body .config-body-wrap,
html[data-theme="dark"] body .apqp-subview,
html[data-theme="dark"] body .acc-subview,
html[data-theme="dark"] body .qdoc-subview,
html[data-theme="dark"] body .aud-subview,
html[data-theme="dark"] body .rrhh-subview,
html[data-theme="dark"] body .ref-modern-grid,
html[data-theme="dark"] body .mp-layout,
html[data-theme="dark"] body .flow-rows-body,
html[data-theme="dark"] body .qd-subform-rows-container {
  background: #0f172a !important;
  color: #f1f5f9 !important;
  border-color: #334155 !important;
}

/* Botones de tarjetas de módulos y utilidades */
html[data-theme="dark"] body .apqp-card-btn,
html[data-theme="dark"] body .acc-card-btn,
html[data-theme="dark"] body .qdoc-card-btn,
html[data-theme="dark"] body .qpro-card-btn,
html[data-theme="dark"] body .amfe-card-btn,
html[data-theme="dark"] body .qlab-card-btn,
html[data-theme="dark"] body .aud-card-btn,
html[data-theme="dark"] body .rrhh-card-btn,
html[data-theme="dark"] body .apqp-util-btn,
html[data-theme="dark"] body .acc-util-btn,
html[data-theme="dark"] body .qdoc-util-btn,
html[data-theme="dark"] body .qlab-util-btn,
html[data-theme="dark"] body .aud-util-btn,
html[data-theme="dark"] body .rrhh-util-btn,
html[data-theme="dark"] body .erp-util-btn,
html[data-theme="dark"] body .apqp-corner-btn,
html[data-theme="dark"] body .acc-corner-btn,
html[data-theme="dark"] body .qdoc-corner-btn,
html[data-theme="dark"] body .aud-corner-btn,
html[data-theme="dark"] body .mp-block,
html[data-theme="dark"] body .mp-proc-btn,
html[data-theme="dark"] body .ficha-action-card,
html[data-theme="dark"] body .qdesktop-config-btn,
html[data-theme="dark"] body .qd-toolbar-btn,
html[data-theme="dark"] body .qd-menu-action-btn,
html[data-theme="dark"] body .qd-clear-filter-btn,
html[data-theme="dark"] body .qd-col-filter-btn,
html[data-theme="dark"] body .qd-rec-nav-btn,
html[data-theme="dark"] body .qd-rec-count-box,
html[data-theme="dark"] body .qdoc-btn,
html[data-theme="dark"] body .btn-med-win,
html[data-theme="dark"] body .btn-ctrl-toolbar,
html[data-theme="dark"] body .btn-ctrl-win,
html[data-theme="dark"] body .amfe-tab-btn,
html[data-theme="dark"] body .amfe-gear-config-btn,
html[data-theme="dark"] body .amfe-cfg-top-btn,
html[data-theme="dark"] body .amfe-cfg-node-btn,
html[data-theme="dark"] body .qdesktop-icon-btn,
html[data-theme="dark"] body .qdesktop-pencil-btn,
html[data-theme="dark"] body .th-filter-btn,
html[data-theme="dark"] body .ref-quick-mod-btn,
html[data-theme="dark"] body .informe-flow-btn,
html[data-theme="dark"] body .flow-hdr-drop-btn,
html[data-theme="dark"] body .amfe-shuttle-btn,
html[data-theme="dark"] body .flow-act-btn,
html[data-theme="dark"] body .flow-maquin-btn,
html[data-theme="dark"] body .pauta-guideline-controls-btn,
html[data-theme="dark"] body .smtp-provider-btn,
html[data-theme="dark"] body .module-toggle-btn {
  background: #1e293b !important;
  border-color: #334155 !important;
  color: #f1f5f9 !important;
}

html[data-theme="dark"] body .apqp-card-btn:hover,
html[data-theme="dark"] body .acc-card-btn:hover,
html[data-theme="dark"] body .qdoc-card-btn:hover,
html[data-theme="dark"] body .qlab-card-btn:hover,
html[data-theme="dark"] body .aud-card-btn:hover,
html[data-theme="dark"] body .rrhh-card-btn:hover,
html[data-theme="dark"] body .qd-menu-action-btn:hover,
html[data-theme="dark"] body .qdoc-btn:hover,
html[data-theme="dark"] body .btn-ctrl-toolbar:hover,
html[data-theme="dark"] body .ref-quick-mod-btn:hover,
html[data-theme="dark"] body .smtp-provider-btn:hover {
  background: #334155 !important;
  border-color: #38bdf8 !important;
  color: #ffffff !important;
}

html[data-theme="dark"] body .apqp-card-label,
html[data-theme="dark"] body .acc-card-label,
html[data-theme="dark"] body .qdoc-card-label,
html[data-theme="dark"] body .qlab-card-label,
html[data-theme="dark"] body .aud-card-label,
html[data-theme="dark"] body .rrhh-card-label,
html[data-theme="dark"] body .apqp-util-label,
html[data-theme="dark"] body .acc-util-label,
html[data-theme="dark"] body .qdoc-util-label,
html[data-theme="dark"] body .qlab-util-label,
html[data-theme="dark"] body .aud-util-label,
html[data-theme="dark"] body .rrhh-util-label,
html[data-theme="dark"] body .apqp-header-title,
html[data-theme="dark"] body .acc-header-title,
html[data-theme="dark"] body .aud-header-title,
html[data-theme="dark"] body .qdoc-header-title,
html[data-theme="dark"] body .qlab-title-text,
html[data-theme="dark"] body .qpro-header-title,
html[data-theme="dark"] body .amfe-header-title,
html[data-theme="dark"] body .rrhh-header-title,
html[data-theme="dark"] body .of-title-text,
html[data-theme="dark"] body .module-title,
html[data-theme="dark"] body .card-value,
html[data-theme="dark"] body .modal-title,
html[data-theme="dark"] body .chart-card-title {
  color: #f8fafc !important;
}

/* Cabeceras de tablas, barras de herramientas y barras de estado */
html[data-theme="dark"] body .table-header,
html[data-theme="dark"] body .of-table-header,
html[data-theme="dark"] body .modal-header,
html[data-theme="dark"] body .qlab-modal-header,
html[data-theme="dark"] body .rrhh-modal-header,
html[data-theme="dark"] body .modal-footer,
html[data-theme="dark"] body .chart-card-header,
html[data-theme="dark"] body .config-section-header,
html[data-theme="dark"] body .pagination-bar,
html[data-theme="dark"] body .qd-window-titlebar,
html[data-theme="dark"] body .qd-access-statusbar,
html[data-theme="dark"] body .qd-access-recordbar,
html[data-theme="dark"] body .qdoc-toolbar,
html[data-theme="dark"] body .pauta-guideline-winbar,
html[data-theme="dark"] body .ref-card-footer,
html[data-theme="dark"] body .amfe-cfg-section,
html[data-theme="dark"] body .sod-input-group {
  background: #0f172a !important;
  border-color: #334155 !important;
  color: #f1f5f9 !important;
}

html[data-theme="dark"] body .modal-body,
html[data-theme="dark"] body .amfe-cfg-body,
html[data-theme="dark"] body .qd-config-body,
html[data-theme="dark"] body .rrhh-modal-body {
  background: #1e293b !important;
  color: #f1f5f9 !important;
}

/* Tablas de datos en toda la web */
html[data-theme="dark"] body .data-table th,
html[data-theme="dark"] body .of-table th,
html[data-theme="dark"] body .controles-table thead th,
html[data-theme="dark"] body .equipos-med-table thead th,
html[data-theme="dark"] body .amfe-list-table thead th,
html[data-theme="dark"] body .amfe-access-table thead th,
html[data-theme="dark"] body #gestion-usuario-table thead th,
html[data-theme="dark"] body table:not(.pauta-sheet-hdr-table):not(.pauta-sheet-main-table):not(.pauta-header-table):not(.pauta-main-table) thead th,
html[data-theme="dark"] body .qd-col-header-cell {
  background: #0f172a !important;
  color: #cbd5e1 !important;
  border-color: #334155 !important;
}

html[data-theme="dark"] body .data-table th.th-sortable:hover,
html[data-theme="dark"] body .data-table th.th-sortable.sort-active {
  background: #1e293b !important;
  color: #38bdf8 !important;
}

html[data-theme="dark"] body .data-table td,
html[data-theme="dark"] body .controles-table tbody td,
html[data-theme="dark"] body .equipos-med-table tbody td,
html[data-theme="dark"] body .amfe-list-table tbody td,
html[data-theme="dark"] body .amfe-list-table tbody td.cell-box,
html[data-theme="dark"] body .amfe-access-table tbody td,
html[data-theme="dark"] body table:not(.pauta-sheet-hdr-table):not(.pauta-sheet-main-table):not(.pauta-header-table):not(.pauta-main-table) tbody td {
  background-color: transparent !important;
  color: #e2e8f0 !important;
  border-color: #334155 !important;
}

html[data-theme="dark"] body .data-table tbody tr,
html[data-theme="dark"] body .controles-table tbody tr,
html[data-theme="dark"] body .equipos-med-table tbody tr,
html[data-theme="dark"] body .amfe-list-table tbody tr,
html[data-theme="dark"] body .amfe-access-table tbody tr,
html[data-theme="dark"] body table:not(.pauta-sheet-hdr-table):not(.pauta-sheet-main-table):not(.pauta-header-table):not(.pauta-main-table) tbody tr {
  background-color: #1e293b !important;
}

html[data-theme="dark"] body .data-table tbody tr:hover,
html[data-theme="dark"] body .data-table tbody tr:hover td,
html[data-theme="dark"] body .amfe-list-table tbody tr:hover td.cell-box,
html[data-theme="dark"] body table:not(.pauta-sheet-hdr-table):not(.pauta-sheet-main-table):not(.pauta-header-table):not(.pauta-main-table) tbody tr:hover {
  background-color: #263548 !important;
}

html[data-theme="dark"] body .data-table tbody tr.row-nok,
html[data-theme="dark"] body .data-table tbody tr.ccc-row-overdue {
  background: rgba(127, 29, 29, 0.32) !important;
}

html[data-theme="dark"] body .data-table tbody tr.ccc-row-warning {
  background: rgba(120, 53, 15, 0.28) !important;
}

/* ==========================================================================
   HISTÓRICO DE CONTROLES Y CCC (FILTROS, AGRUPACIÓN POR FASES, TANDAS)
   ========================================================================== */
html[data-theme="dark"] body .hist-filter-panel,
html[data-theme="dark"] body .hist-fases-toolbar {
  background: linear-gradient(180deg, #1e293b 0%, #0f172a 100%) !important;
  border-color: #334155 !important;
  color: #f1f5f9 !important;
}

html[data-theme="dark"] body .hist-field-card,
html[data-theme="dark"] body .hist-field-card:focus-within,
html[data-theme="dark"] body .hist-field-card.dropdown-open,
html[data-theme="dark"] body .hist-filter-body {
  background: #1e293b !important;
  border-color: #334155 !important;
  color: #f1f5f9 !important;
}

html[data-theme="dark"] body .hist-field-pill,
html[data-theme="dark"] body .pill-of,
html[data-theme="dark"] body .pauta-frec-box,
html[data-theme="dark"] body .med-chip,
html[data-theme="dark"] body .med-pill {
  background: #0f172a !important;
  border-color: #334155 !important;
  color: #cbd5e1 !important;
}

html[data-theme="dark"] body .hist-field-pill.accent,
html[data-theme="dark"] body .oif-link-badge,
html[data-theme="dark"] body .tag-realizar,
html[data-theme="dark"] body .badge-fase-seq,
html[data-theme="dark"] body .pieza-suggestion-badge {
  background: rgba(2, 132, 199, 0.22) !important;
  border-color: #0284c7 !important;
  color: #7dd3fc !important;
}

html[data-theme="dark"] body .med-chip.ok,
html[data-theme="dark"] body .badge-status-active,
html[data-theme="dark"] body .badge-cant-lanzada,
html[data-theme="dark"] body .badge-frecuencia {
  background: rgba(16, 185, 129, 0.18) !important;
  border-color: #059669 !important;
  color: #6ee7b7 !important;
}

html[data-theme="dark"] body .med-chip.nok,
html[data-theme="dark"] body .badge-status-inactive,
html[data-theme="dark"] body .kpi-nok-click-hint,
html[data-theme="dark"] body .ccc-row-overdue .pauta-frec-box {
  background: rgba(239, 68, 68, 0.2) !important;
  border-color: #dc2626 !important;
  color: #fca5a5 !important;
}

html[data-theme="dark"] body .hist-btn-clear {
  background: #0f172a !important;
  border-color: #475569 !important;
  color: #e2e8f0 !important;
}

html[data-theme="dark"] body .hist-submode-switcher,
html[data-theme="dark"] body .cp-view-tab-group,
html[data-theme="dark"] body .tipo-pauta-switch-group {
  background: #0f172a !important;
  border-color: #334155 !important;
}

html[data-theme="dark"] body .hist-submode-btn {
  color: #94a3b8 !important;
}

html[data-theme="dark"] body .hist-submode-btn.active {
  background: #1e293b !important;
  color: #38bdf8 !important;
  border-color: #38bdf8 !important;
}

html[data-theme="dark"] body .hist-fase-summary-pill {
  background: #1e293b !important;
  border-color: #334155 !important;
  color: #e2e8f0 !important;
}

html[data-theme="dark"] body .hist-fase-summary-pill.active-filter {
  background: rgba(2, 132, 199, 0.25) !important;
  border-color: #38bdf8 !important;
  color: #ffffff !important;
}

html[data-theme="dark"] body .hist-fases-groups-wrapper,
html[data-theme="dark"] body .hist-fase-group-body {
  background: #0b1120 !important;
  border-color: #334155 !important;
}

html[data-theme="dark"] body .hist-fase-group-card,
html[data-theme="dark"] body .hist-fase-batch-card {
  background: #1e293b !important;
  border-color: #334155 !important;
  color: #f1f5f9 !important;
}

html[data-theme="dark"] body .hist-fase-batch-header {
  background: linear-gradient(90deg, #0f172a 0%, #1e293b 100%) !important;
  border-color: #334155 !important;
  color: #f1f5f9 !important;
}

html[data-theme="dark"] body .hist-fase-batch-card.batch-has-nok .hist-fase-batch-header {
  background: linear-gradient(90deg, rgba(127, 29, 29, 0.4) 0%, #1e293b 100%) !important;
  border-color: #ef4444 !important;
}

/* ==========================================================================
   REALIZACIÓN CONTROL PRODUCCIÓN (BÚSQUEDA, STEPPER, LISTA Y CONTROL A CONTROL)
   ========================================================================== */
html[data-theme="dark"] body .oif-search-panel,
html[data-theme="dark"] body .page-content.empty-fullscreen-filters .oif-search-panel {
  background: linear-gradient(180deg, #1e293b 0%, #0f172a 100%) !important;
  border-color: #334155 !important;
  color: #f1f5f9 !important;
}

html[data-theme="dark"] body .filter-field-card,
html[data-theme="dark"] body .filter-field-card.primary-filter,
html[data-theme="dark"] body .page-content.empty-fullscreen-filters .filter-field-card.primary-filter,
html[data-theme="dark"] body .operario-context-grid .filter-field-card {
  background: #1e293b !important;
  border-color: #334155 !important;
  color: #f1f5f9 !important;
}

html[data-theme="dark"] body .filter-step-pill,
html[data-theme="dark"] body .fase-step-num,
html[data-theme="dark"] body .cac-meta-icon {
  background: rgba(2, 132, 199, 0.25) !important;
  color: #38bdf8 !important;
  border-color: #0284c7 !important;
}

html[data-theme="dark"] body .oif-resolved-banner,
html[data-theme="dark"] body #oif-resolved-banner,
html[data-theme="dark"] body .cac-top-nav-bar {
  background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%) !important;
  border-color: #334155 !important;
  color: #f1f5f9 !important;
}

html[data-theme="dark"] body .oif-kpi-pill,
html[data-theme="dark"] body .oif-quick-chip,
html[data-theme="dark"] body .pieza-fases-photo-card,
html[data-theme="dark"] body .pieza-fases-photo-frame,
html[data-theme="dark"] body .fases-stepper-container {
  background: #1e293b !important;
  border-color: #334155 !important;
  color: #f1f5f9 !important;
}

html[data-theme="dark"] body .fase-step-card {
  background: #0f172a !important;
  border-color: #334155 !important;
  color: #e2e8f0 !important;
}

html[data-theme="dark"] body .fase-step-card:hover,
html[data-theme="dark"] body .fase-step-card.active {
  background: linear-gradient(180deg, #1e293b 0%, #172554 100%) !important;
  border-color: #38bdf8 !important;
  color: #ffffff !important;
}

html[data-theme="dark"] body .fase-step-card.completed {
  background: linear-gradient(180deg, #1e293b 0%, rgba(6, 78, 59, 0.45) 100%) !important;
  border-color: #10b981 !important;
}

html[data-theme="dark"] body .fase-step-code {
  background: #1e293b !important;
  color: #cbd5e1 !important;
}

html[data-theme="dark"] body .cac-stage-wrapper,
html[data-theme="dark"] body .fase-section-block {
  background: #0f172a !important;
  border-color: #334155 !important;
}

html[data-theme="dark"] body .fase-section-banner,
html[data-theme="dark"] body .hist-fase-group-header {
  background: linear-gradient(135deg, #0f172a 0%, #1e3a5f 60%, #0369a1 100%) !important;
  color: #ffffff !important;
}

html[data-theme="dark"] body .control-step-card,
html[data-theme="dark"] body .control-spec-strip,
html[data-theme="dark"] body .cac-spec-showcase,
html[data-theme="dark"] body .cac-workstation-panel,
html[data-theme="dark"] body .cac-workstation-card,
html[data-theme="dark"] body .cac-med-card,
html[data-theme="dark"] body .cac-meta-item,
html[data-theme="dark"] body .cac-photo-blueprint-card,
html[data-theme="dark"] body .cac-photo-thumb-box,
html[data-theme="dark"] body .cac-steps-strip-box,
html[data-theme="dark"] body .measurements-box,
html[data-theme="dark"] body .spec-item-box,
html[data-theme="dark"] body .spec-item-icon,
html[data-theme="dark"] body .measurement-cell,
html[data-theme="dark"] body .measurement-stats-bar,
html[data-theme="dark"] body .stat-chip,
html[data-theme="dark"] body .tipo-pauta-option-btn,
html[data-theme="dark"] body .cat-def-card {
  background: #1e293b !important;
  border-color: #334155 !important;
  color: #f1f5f9 !important;
}

html[data-theme="dark"] body .control-step-card.is-saved {
  background: linear-gradient(90deg, rgba(22, 163, 74, 0.18) 0%, #1e293b 40%) !important;
  border-left-color: #22c55e !important;
}

html[data-theme="dark"] body .control-step-card.is-nok {
  background: linear-gradient(90deg, rgba(220, 38, 38, 0.18) 0%, #1e293b 40%) !important;
  border-left-color: #ef4444 !important;
}

html[data-theme="dark"] body .control-step-card.is-next-active {
  background: linear-gradient(90deg, rgba(2, 132, 199, 0.2) 0%, #1e293b 40%) !important;
}

html[data-theme="dark"] body .cac-tolerance-dashboard {
  background: linear-gradient(135deg, #0f172a 0%, #172554 100%) !important;
  border-color: #1e3a8a !important;
  color: #f1f5f9 !important;
}

html[data-theme="dark"] body .cac-tol-card {
  background: #1e293b !important;
  border-color: #334155 !important;
  color: #f1f5f9 !important;
}

html[data-theme="dark"] body .cac-tol-card.is-nominal {
  background: rgba(2, 132, 199, 0.22) !important;
  border-color: #38bdf8 !important;
}

html[data-theme="dark"] body .cac-tol-val,
html[data-theme="dark"] body .cac-hero-title,
html[data-theme="dark"] body .spec-item-val,
html[data-theme="dark"] body .cac-step-pill-name {
  color: #f8fafc !important;
}

html[data-theme="dark"] body .cac-tol-lbl,
html[data-theme="dark"] body .spec-item-lbl,
html[data-theme="dark"] body .cac-gauge-header,
html[data-theme="dark"] body .cac-step-pill-top {
  color: #94a3b8 !important;
}

html[data-theme="dark"] body .rcp-view-switcher {
  background: #0f172a !important;
  border-color: #334155 !important;
}

html[data-theme="dark"] body .rcp-view-btn:not(.active) {
  color: #94a3b8 !important;
}

html[data-theme="dark"] body .rcp-view-btn:not(.active):hover {
  background: rgba(255, 255, 255, 0.08) !important;
  color: #f8fafc !important;
}

html[data-theme="dark"] body .cac-step-pill:not(.active):not(.done-ok):not(.done-nok),
html[data-theme="dark"] body .fases-stepper-btn:not(.active),
html[data-theme="dark"] body .decision-pill-btn:not(.active-ok):not(.active-nok),
html[data-theme="dark"] body .cac-decision-big-btn:not(.active-ok):not(.active-nok),
html[data-theme="dark"] body .cac-nav-btn:not(:hover),
html[data-theme="dark"] body .cac-step-counter-pill {
  background: #0f172a !important;
  border-color: #334155 !important;
  color: #e2e8f0 !important;
}

html[data-theme="dark"] body .cac-step-pill.active {
  background: linear-gradient(135deg, #1e3a8a 0%, #0284c7 100%) !important;
  border-color: #38bdf8 !important;
  color: #ffffff !important;
}

html[data-theme="dark"] body .cac-step-pill.done-ok {
  background: rgba(16, 185, 129, 0.2) !important;
  border-color: #10b981 !important;
}

html[data-theme="dark"] body .cac-step-pill.done-nok {
  background: rgba(239, 68, 68, 0.2) !important;
  border-color: #ef4444 !important;
}

/* ==========================================================================
   REFERENCIAS, AMFE Y FLUJO DE PROCESO
   ========================================================================== */
html[data-theme="dark"] body .ref-card-photo-wrap,
html[data-theme="dark"] body .ref-card-photo,
html[data-theme="dark"] body .ref-card-no-photo,
html[data-theme="dark"] body .pauta-guideline-photo-canvas {
  background: #0f172a !important;
  background-image: none !important;
  border-color: #334155 !important;
  color: #cbd5e1 !important;
}

html[data-theme="dark"] body .ref-card-tipo-banner,
html[data-theme="dark"] body .ref-card-ext-code,
html[data-theme="dark"] body .badge-ref,
html[data-theme="dark"] body .badge-equipo,
html[data-theme="dark"] body .badge-client-num,
html[data-theme="dark"] body .badge-pendiente {
  background: #0f172a !important;
  border-color: #334155 !important;
  color: #cbd5e1 !important;
}

html[data-theme="dark"] body .flow-cell-box,
html[data-theme="dark"] body .flow-cell-comentarios,
html[data-theme="dark"] body .flow-comentarios-top,
html[data-theme="dark"] body .flow-maquin-icon-box,
html[data-theme="dark"] body .access-combo-popup,
html[data-theme="dark"] body .equipos-med-table,
html[data-theme="dark"] body .controles-table {
  background: #1e293b !important;
  border-color: #334155 !important;
  color: #f1f5f9 !important;
}

/* ==========================================================================
   FORMULARIOS, INPUTS, SELECTS Y COMBOBOXES
   ========================================================================== */
html[data-theme="dark"] body .form-input,
html[data-theme="dark"] body .form-control,
html[data-theme="dark"] body .measurement-input:not(.med-ok):not(.med-nok),
html[data-theme="dark"] body .col-filter-input,
html[data-theme="dark"] body .qd-cell-input,
html[data-theme="dark"] body .qd-cell-select,
html[data-theme="dark"] body .med-win-input,
html[data-theme="dark"] body .med-win-combo,
html[data-theme="dark"] body .med-win-range-input,
html[data-theme="dark"] body .qpro-cfg-input,
html[data-theme="dark"] body .qdoc-input,
html[data-theme="dark"] body .qdoc-select,
html[data-theme="dark"] body .qdoc-textarea,
html[data-theme="dark"] body .qlab-input-field,
html[data-theme="dark"] body .ficha-input,
html[data-theme="dark"] body .ficha-select,
html[data-theme="dark"] body .ficha-textarea,
html[data-theme="dark"] body .spc-cota-select,
html[data-theme="dark"] body .apqp-footer-input,
html[data-theme="dark"] body .acc-footer-input,
html[data-theme="dark"] body .qdoc-footer-input,
html[data-theme="dark"] body .aud-footer-input,
html[data-theme="dark"] body .apqp-footer-select,
html[data-theme="dark"] body .acc-footer-select,
html[data-theme="dark"] body .qdoc-footer-select,
html[data-theme="dark"] body .aud-footer-select,
html[data-theme="dark"] body .apqp-footer-select-wrap,
html[data-theme="dark"] body .acc-footer-select-wrap,
html[data-theme="dark"] body .aud-footer-select-wrap,
html[data-theme="dark"] body input:not([type="checkbox"]):not([type="radio"]):not([type="button"]):not([type="submit"]):not([type="reset"]):not([type="file"]):not([type="color"]):not([type="range"]),
html[data-theme="dark"] body select:not(.lang-select),
html[data-theme="dark"] body textarea {
  background: #0f172a !important;
  background-color: #0f172a !important;
  color: #f8fafc !important;
  border-color: #334155 !important;
}

html[data-theme="dark"] body .measurement-input.med-ok {
  background: rgba(16, 185, 129, 0.2) !important;
  border-color: #10b981 !important;
  color: #6ee7b7 !important;
}

html[data-theme="dark"] body .measurement-input.med-nok {
  background: rgba(239, 68, 68, 0.22) !important;
  border-color: #ef4444 !important;
  color: #fca5a5 !important;
}

html[data-theme="dark"] body input::placeholder,
html[data-theme="dark"] body textarea::placeholder {
  color: #64748b !important;
}

html[data-theme="dark"] body .lang-select-wrapper:not(.sidebar .lang-select-wrapper) {
  background-color: #1e293b !important;
  border-color: #334155 !important;
  color: #f1f5f9 !important;
}

html[data-theme="dark"] body .lang-select option,
html[data-theme="dark"] body select option {
  background-color: #0f172a !important;
  color: #f1f5f9 !important;
}

html[data-theme="dark"] body .btn-secondary,
html[data-theme="dark"] body .btn-modal-cancel,
html[data-theme="dark"] body .pagination-btn:not(.active),
html[data-theme="dark"] body .modal-close {
  background: #1e293b !important;
  background-color: #1e293b !important;
  color: #e2e8f0 !important;
  border-color: #475569 !important;
}

html[data-theme="dark"] body .btn-secondary:hover,
html[data-theme="dark"] body .btn-modal-cancel:hover,
html[data-theme="dark"] body .pagination-btn:not(.active):hover {
  background: #334155 !important;
  background-color: #334155 !important;
  color: #ffffff !important;
  border-color: #64748b !important;
}

html[data-theme="dark"] body .pieza-suggestions-dropdown {
  background: #1e293b !important;
  border-color: #334155 !important;
  color: #ffffff !important;
  box-shadow: 0 14px 32px rgba(0, 0, 0, 0.55) !important;
}

html[data-theme="dark"] body .pieza-suggestion-item {
  background: #1e293b !important;
  border-color: #334155 !important;
  color: #ffffff !important;
}

html[data-theme="dark"] body .pieza-suggestion-item:hover,
html[data-theme="dark"] body .pieza-suggestion-item.highlighted {
  background: #334155 !important;
  color: #ffffff !important;
}

html[data-theme="dark"] body .pieza-suggestion-item.selected {
  background: rgba(2, 132, 199, 0.28) !important;
  color: #ffffff !important;
}

html[data-theme="dark"] body .pieza-suggestion-code,
html[data-theme="dark"] body .pieza-suggestion-code strong,
html[data-theme="dark"] body .pieza-suggestion-item strong {
  color: #ffffff !important;
}

html[data-theme="dark"] body .pieza-suggestion-code span {
  color: #38bdf8 !important;
}

html[data-theme="dark"] body .pieza-suggestion-desc,
html[data-theme="dark"] body .pieza-suggestions-dropdown > div {
  color: #f8fafc !important;
}

html[data-theme="dark"] body .pieza-suggestions-dropdown strong {
  color: #ffffff !important;
}

html[data-theme="dark"] body .pieza-suggestion-badge.with-pauta {
  background: rgba(16, 185, 129, 0.2) !important;
  color: #6ee7b7 !important;
  border-color: #10b981 !important;
}

html[data-theme="dark"] body .pieza-suggestion-badge.no-pauta {
  background: #0f172a !important;
  color: #cbd5e1 !important;
  border-color: #475569 !important;
}

html[data-theme="dark"] body .pieza-match-hl {
  background: rgba(250, 204, 21, 0.28) !important;
  color: #fef08a !important;
}

html[data-theme="dark"] body .pieza-combobox-btn,
html[data-theme="dark"] body .pieza-combobox-btn:hover,
html[data-theme="dark"] body .oif-quick-chip {
  color: #f8fafc !important;
}

html[data-theme="dark"] body .oif-quick-chip:hover {
  background: #334155 !important;
  border-color: #38bdf8 !important;
  color: #ffffff !important;
}

/* Textos de tarjetas, títulos y etiquetas que tenían color oscuro fijo en páginas */
html[data-theme="dark"] body .kpi-card-hist .kpi-val,
html[data-theme="dark"] body .of-kpi-value,
html[data-theme="dark"] body .bar-stat-label,
html[data-theme="dark"] body .fase-step-title,
html[data-theme="dark"] body .cac-meta-val,
html[data-theme="dark"] body .ref-card-ref-code,
html[data-theme="dark"] body .ref-meta-val,
html[data-theme="dark"] body .qdesktop-header-title,
html[data-theme="dark"] body .qdesktop-tool-label,
html[data-theme="dark"] body .ficha-label,
html[data-theme="dark"] body .ficha-group-title,
html[data-theme="dark"] body .ficha-doc-row,
html[data-theme="dark"] body .flow-main-title,
html[data-theme="dark"] body .flow-col-hdr,
html[data-theme="dark"] body .flow-cell-input,
html[data-theme="dark"] body .pauta-guideline-window,
html[data-theme="dark"] body .pauta-guideline-main-title,
html[data-theme="dark"] body .pauta-guideline-ref-code,
html[data-theme="dark"] body .pauta-guideline-title-lbl,
html[data-theme="dark"] body .pauta-guideline-fase-name,
html[data-theme="dark"] body .pauta-guideline-comment-lbl,
html[data-theme="dark"] body .ctrl-top-title,
html[data-theme="dark"] body .ctrl-action-label,
html[data-theme="dark"] body .ctrl-cell-text,
html[data-theme="dark"] body .ctrl-cell-edit-area,
html[data-theme="dark"] body .ctrl-cell-combo-label,
html[data-theme="dark"] body .ctrl-cell-num-box,
html[data-theme="dark"] body .med-top-title,
html[data-theme="dark"] body .med-action-label,
html[data-theme="dark"] body .med-win-combo-text,
html[data-theme="dark"] body .qlab-submenu-item,
html[data-theme="dark"] body .amfe-cfg-section-title,
html[data-theme="dark"] body .rrhh-top-title,
html[data-theme="dark"] body .acc-window-title,
html[data-theme="dark"] body .apqp-window-title,
html[data-theme="dark"] body .aud-window-title,
html[data-theme="dark"] body .module-card-title,
html[data-theme="dark"] body .smtp-provider-btn .prov-title,
html[data-theme="dark"] body .login-card-body .form-label {
  color: #f8fafc !important;
}

html[data-theme="dark"] body .kpi-subtext,
html[data-theme="dark"] body .bar-stat-counts,
html[data-theme="dark"] body .hist-field-label,
html[data-theme="dark"] body .filter-card-label,
html[data-theme="dark"] body .filter-hero-helper,
html[data-theme="dark"] body .fase-step-meta,
html[data-theme="dark"] body .cac-med-card-top,
html[data-theme="dark"] body .measurement-cell label,
html[data-theme="dark"] body .ref-card-desc,
html[data-theme="dark"] body .ref-card-meta-grid,
html[data-theme="dark"] body .flow-comentarios-bottom,
html[data-theme="dark"] body .qlab-user-inputs,
html[data-theme="dark"] body .qlab-input-row label,
html[data-theme="dark"] body .qpro-cfg-field label,
html[data-theme="dark"] body .sod-input-group label,
html[data-theme="dark"] body .login-card-body .brand-subtitle,
html[data-theme="dark"] body .login-body-subtitle {
  color: #cbd5e1 !important;
}

/* Login y Recuperación de contraseña */
html[data-theme="dark"] body .login-container,
html[data-theme="dark"] body.dark-mode .login-container {
  background: radial-gradient(circle at 15% 15%, #0f172a 0%, #0b1120 60%, #060a12 100%) !important;
}

html[data-theme="dark"] body .bg-white,
html[data-theme="dark"] body .cell-box,
html[data-theme="dark"] body .ficha-panel,
html[data-theme="dark"] body .flow-row-item,
html[data-theme="dark"] body .cp-view-switcher,
html[data-theme="dark"] body .of-route-card,
html[data-theme="dark"] body .of-route-step {
  background: #1e293b !important;
  color: #f1f5f9 !important;
  border-color: #334155 !important;
}

html[data-theme="dark"] body .bg-grey {
  background: #0f172a !important;
  color: #cbd5e1 !important;
  border-color: #334155 !important;
}

/* ==========================================================================
   ADAPTACIÓN AUTOMÁTICA DE ESTILOS INLINE CLAROS (FUERA DE HOJAS IMPRESAS A4)
   ========================================================================== */
@media screen {
  /* Fondos blancos inline (#ffffff, #fff, white) */
  html[data-theme="dark"] body :not(.pauta-sheet-doc):not(.pauta-doc-sheet):not(.pauta-sheet-doc *):not(.pauta-doc-sheet *)[style*="background: #ffffff"],
  html[data-theme="dark"] body :not(.pauta-sheet-doc):not(.pauta-doc-sheet):not(.pauta-sheet-doc *):not(.pauta-doc-sheet *)[style*="background:#ffffff"],
  html[data-theme="dark"] body :not(.pauta-sheet-doc):not(.pauta-doc-sheet):not(.pauta-sheet-doc *):not(.pauta-doc-sheet *)[style*="background: #fff"],
  html[data-theme="dark"] body :not(.pauta-sheet-doc):not(.pauta-doc-sheet):not(.pauta-sheet-doc *):not(.pauta-doc-sheet *)[style*="background:#fff"],
  html[data-theme="dark"] body :not(.pauta-sheet-doc):not(.pauta-doc-sheet):not(.pauta-sheet-doc *):not(.pauta-doc-sheet *)[style*="background: white"],
  html[data-theme="dark"] body :not(.pauta-sheet-doc):not(.pauta-doc-sheet):not(.pauta-sheet-doc *):not(.pauta-doc-sheet *)[style*="background:white"],
  html[data-theme="dark"] body :not(.pauta-sheet-doc):not(.pauta-doc-sheet):not(.pauta-sheet-doc *):not(.pauta-doc-sheet *)[style*="background-color: #ffffff"],
  html[data-theme="dark"] body :not(.pauta-sheet-doc):not(.pauta-doc-sheet):not(.pauta-sheet-doc *):not(.pauta-doc-sheet *)[style*="background-color:#ffffff"],
  html[data-theme="dark"] body :not(.pauta-sheet-doc):not(.pauta-doc-sheet):not(.pauta-sheet-doc *):not(.pauta-doc-sheet *)[style*="background-color: white"],
  html[data-theme="dark"] body :not(.pauta-sheet-doc):not(.pauta-doc-sheet):not(.pauta-sheet-doc *):not(.pauta-doc-sheet *)[style*="rgb(255, 255, 255)"] {
    background: #1e293b !important;
    border-color: #334155 !important;
    color: #f1f5f9 !important;
  }

  /* Fondos grises/azulados claros inline (#f8fafc, #f1f5f9, #e2e8f0, #f0f9ff, #eff6ff, #e0f2fe, #dbeafe, #fcfcfd) */
  html[data-theme="dark"] body :not(.pauta-sheet-doc):not(.pauta-doc-sheet):not(.pauta-sheet-doc *):not(.pauta-doc-sheet *)[style*="background: #f8fafc"],
  html[data-theme="dark"] body :not(.pauta-sheet-doc):not(.pauta-doc-sheet):not(.pauta-sheet-doc *):not(.pauta-doc-sheet *)[style*="background:#f8fafc"],
  html[data-theme="dark"] body :not(.pauta-sheet-doc):not(.pauta-doc-sheet):not(.pauta-sheet-doc *):not(.pauta-doc-sheet *)[style*="background: #f1f5f9"],
  html[data-theme="dark"] body :not(.pauta-sheet-doc):not(.pauta-doc-sheet):not(.pauta-sheet-doc *):not(.pauta-doc-sheet *)[style*="background:#f1f5f9"],
  html[data-theme="dark"] body :not(.pauta-sheet-doc):not(.pauta-doc-sheet):not(.pauta-sheet-doc *):not(.pauta-doc-sheet *)[style*="background: #e2e8f0"],
  html[data-theme="dark"] body :not(.pauta-sheet-doc):not(.pauta-doc-sheet):not(.pauta-sheet-doc *):not(.pauta-doc-sheet *)[style*="background:#e2e8f0"],
  html[data-theme="dark"] body :not(.pauta-sheet-doc):not(.pauta-doc-sheet):not(.pauta-sheet-doc *):not(.pauta-doc-sheet *)[style*="background: #f0f9ff"],
  html[data-theme="dark"] body :not(.pauta-sheet-doc):not(.pauta-doc-sheet):not(.pauta-sheet-doc *):not(.pauta-doc-sheet *)[style*="background:#f0f9ff"],
  html[data-theme="dark"] body :not(.pauta-sheet-doc):not(.pauta-doc-sheet):not(.pauta-sheet-doc *):not(.pauta-doc-sheet *)[style*="background: #eff6ff"],
  html[data-theme="dark"] body :not(.pauta-sheet-doc):not(.pauta-doc-sheet):not(.pauta-sheet-doc *):not(.pauta-doc-sheet *)[style*="background:#eff6ff"],
  html[data-theme="dark"] body :not(.pauta-sheet-doc):not(.pauta-doc-sheet):not(.pauta-sheet-doc *):not(.pauta-doc-sheet *)[style*="background: #e0f2fe"],
  html[data-theme="dark"] body :not(.pauta-sheet-doc):not(.pauta-doc-sheet):not(.pauta-sheet-doc *):not(.pauta-doc-sheet *)[style*="background:#e0f2fe"],
  html[data-theme="dark"] body :not(.pauta-sheet-doc):not(.pauta-doc-sheet):not(.pauta-sheet-doc *):not(.pauta-doc-sheet *)[style*="background: #dbeafe"],
  html[data-theme="dark"] body :not(.pauta-sheet-doc):not(.pauta-doc-sheet):not(.pauta-sheet-doc *):not(.pauta-doc-sheet *)[style*="background:#dbeafe"],
  html[data-theme="dark"] body :not(.pauta-sheet-doc):not(.pauta-doc-sheet):not(.pauta-sheet-doc *):not(.pauta-doc-sheet *)[style*="background: #f5f3ff"],
  html[data-theme="dark"] body :not(.pauta-sheet-doc):not(.pauta-doc-sheet):not(.pauta-sheet-doc *):not(.pauta-doc-sheet *)[style*="rgb(248, 250, 252)"],
  html[data-theme="dark"] body :not(.pauta-sheet-doc):not(.pauta-doc-sheet):not(.pauta-sheet-doc *):not(.pauta-doc-sheet *)[style*="rgb(241, 245, 249)"] {
    background: #0f172a !important;
    border-color: #334155 !important;
    color: #e2e8f0 !important;
  }

  /* Fondos semánticos suaves inline (verde/rojo/ámbar claro) */
  html[data-theme="dark"] body :not(.pauta-sheet-doc):not(.pauta-doc-sheet):not(.pauta-sheet-doc *):not(.pauta-doc-sheet *)[style*="background: #ecfdf5"],
  html[data-theme="dark"] body :not(.pauta-sheet-doc):not(.pauta-doc-sheet):not(.pauta-sheet-doc *):not(.pauta-doc-sheet *)[style*="background:#ecfdf5"],
  html[data-theme="dark"] body :not(.pauta-sheet-doc):not(.pauta-doc-sheet):not(.pauta-sheet-doc *):not(.pauta-doc-sheet *)[style*="background: #f0fdf4"],
  html[data-theme="dark"] body :not(.pauta-sheet-doc):not(.pauta-doc-sheet):not(.pauta-sheet-doc *):not(.pauta-doc-sheet *)[style*="background:#f0fdf4"],
  html[data-theme="dark"] body :not(.pauta-sheet-doc):not(.pauta-doc-sheet):not(.pauta-sheet-doc *):not(.pauta-doc-sheet *)[style*="background: #f0fdfa"] {
    background: rgba(16, 185, 129, 0.16) !important;
    border-color: #059669 !important;
    color: #6ee7b7 !important;
  }

  html[data-theme="dark"] body :not(.pauta-sheet-doc):not(.pauta-doc-sheet):not(.pauta-sheet-doc *):not(.pauta-doc-sheet *)[style*="background: #fef2f2"],
  html[data-theme="dark"] body :not(.pauta-sheet-doc):not(.pauta-doc-sheet):not(.pauta-sheet-doc *):not(.pauta-doc-sheet *)[style*="background:#fef2f2"],
  html[data-theme="dark"] body :not(.pauta-sheet-doc):not(.pauta-doc-sheet):not(.pauta-sheet-doc *):not(.pauta-doc-sheet *)[style*="background: #fff1f2"],
  html[data-theme="dark"] body :not(.pauta-sheet-doc):not(.pauta-doc-sheet):not(.pauta-sheet-doc *):not(.pauta-doc-sheet *)[style*="background:#fff1f2"],
  html[data-theme="dark"] body :not(.pauta-sheet-doc):not(.pauta-doc-sheet):not(.pauta-sheet-doc *):not(.pauta-doc-sheet *)[style*="background: #fff5f5"] {
    background: rgba(239, 68, 68, 0.18) !important;
    border-color: #dc2626 !important;
    color: #fca5a5 !important;
  }

  html[data-theme="dark"] body :not(.pauta-sheet-doc):not(.pauta-doc-sheet):not(.pauta-sheet-doc *):not(.pauta-doc-sheet *)[style*="background: #fffbeb"],
  html[data-theme="dark"] body :not(.pauta-sheet-doc):not(.pauta-doc-sheet):not(.pauta-sheet-doc *):not(.pauta-doc-sheet *)[style*="background:#fffbeb"],
  html[data-theme="dark"] body :not(.pauta-sheet-doc):not(.pauta-doc-sheet):not(.pauta-sheet-doc *):not(.pauta-doc-sheet *)[style*="background: #fef3c7"],
  html[data-theme="dark"] body :not(.pauta-sheet-doc):not(.pauta-doc-sheet):not(.pauta-sheet-doc *):not(.pauta-doc-sheet *)[style*="background:#fef3c7"],
  html[data-theme="dark"] body :not(.pauta-sheet-doc):not(.pauta-doc-sheet):not(.pauta-sheet-doc *):not(.pauta-doc-sheet *)[style*="background: #fef9c3"],
  html[data-theme="dark"] body :not(.pauta-sheet-doc):not(.pauta-doc-sheet):not(.pauta-sheet-doc *):not(.pauta-doc-sheet *)[style*="background: #fefce8"],
  html[data-theme="dark"] body :not(.pauta-sheet-doc):not(.pauta-doc-sheet):not(.pauta-sheet-doc *):not(.pauta-doc-sheet *)[style*="background:#fefce8"],
  html[data-theme="dark"] body :not(.pauta-sheet-doc):not(.pauta-doc-sheet):not(.pauta-sheet-doc *):not(.pauta-doc-sheet *)[style*="background: #fff7ed"],
  html[data-theme="dark"] body :not(.pauta-sheet-doc):not(.pauta-doc-sheet):not(.pauta-sheet-doc *):not(.pauta-doc-sheet *)[style*="background:#fff7ed"],
  html[data-theme="dark"] body :not(.pauta-sheet-doc):not(.pauta-doc-sheet):not(.pauta-sheet-doc *):not(.pauta-doc-sheet *)[style*="background: #fef08a"],
  html[data-theme="dark"] body :not(.pauta-sheet-doc):not(.pauta-doc-sheet):not(.pauta-sheet-doc *):not(.pauta-doc-sheet *)[style*="background:#fef08a"],
  html[data-theme="dark"] body :not(.pauta-sheet-doc):not(.pauta-doc-sheet):not(.pauta-sheet-doc *):not(.pauta-doc-sheet *)[style*="background: #ffffc8"],
  html[data-theme="dark"] body :not(.pauta-sheet-doc):not(.pauta-doc-sheet):not(.pauta-sheet-doc *):not(.pauta-doc-sheet *)[style*="background:#ffffc8"] {
    background: rgba(245, 158, 11, 0.16) !important;
    border-color: #d97706 !important;
    color: #fde68a !important;
  }

  /* Gradientes claros inline */
  html[data-theme="dark"] body :not(.pauta-sheet-doc):not(.pauta-doc-sheet):not(.pauta-sheet-doc *):not(.pauta-doc-sheet *)[style*="linear-gradient"][style*="#ffffff"],
  html[data-theme="dark"] body :not(.pauta-sheet-doc):not(.pauta-doc-sheet):not(.pauta-sheet-doc *):not(.pauta-doc-sheet *)[style*="linear-gradient"][style*="#f8fafc"],
  html[data-theme="dark"] body :not(.pauta-sheet-doc):not(.pauta-doc-sheet):not(.pauta-sheet-doc *):not(.pauta-doc-sheet *)[style*="linear-gradient"][style*="#f1f5f9"],
  html[data-theme="dark"] body :not(.pauta-sheet-doc):not(.pauta-doc-sheet):not(.pauta-sheet-doc *):not(.pauta-doc-sheet *)[style*="linear-gradient"][style*="#eff6ff"],
  html[data-theme="dark"] body :not(.pauta-sheet-doc):not(.pauta-doc-sheet):not(.pauta-sheet-doc *):not(.pauta-doc-sheet *)[style*="linear-gradient"][style*="#fcfcfd"] {
    background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%) !important;
    border-color: #334155 !important;
    color: #f1f5f9 !important;
  }

  html[data-theme="dark"] body :not(.pauta-sheet-doc):not(.pauta-doc-sheet):not(.pauta-sheet-doc *):not(.pauta-doc-sheet *)[style*="linear-gradient"][style*="#fff1f2"] {
    background: linear-gradient(135deg, rgba(127, 29, 29, 0.35) 0%, #1e293b 100%) !important;
    border-color: #ef4444 !important;
    color: #fca5a5 !important;
  }

  html[data-theme="dark"] body :not(.pauta-sheet-doc):not(.pauta-doc-sheet):not(.pauta-sheet-doc *):not(.pauta-doc-sheet *)[style*="linear-gradient"][style*="#fffbeb"] {
    background: linear-gradient(135deg, rgba(120, 53, 15, 0.35) 0%, #1e293b 100%) !important;
    border-color: #f59e0b !important;
    color: #fde68a !important;
  }

  /* Textos oscuros inline */
  html[data-theme="dark"] body :not(.pauta-sheet-doc):not(.pauta-doc-sheet):not(.pauta-sheet-doc *):not(.pauta-doc-sheet *)[style*="color: #0f172a"],
  html[data-theme="dark"] body :not(.pauta-sheet-doc):not(.pauta-doc-sheet):not(.pauta-sheet-doc *):not(.pauta-doc-sheet *)[style*="color:#0f172a"],
  html[data-theme="dark"] body :not(.pauta-sheet-doc):not(.pauta-doc-sheet):not(.pauta-sheet-doc *):not(.pauta-doc-sheet *)[style*="color: #1e293b"],
  html[data-theme="dark"] body :not(.pauta-sheet-doc):not(.pauta-doc-sheet):not(.pauta-sheet-doc *):not(.pauta-doc-sheet *)[style*="color:#1e293b"],
  html[data-theme="dark"] body :not(.pauta-sheet-doc):not(.pauta-doc-sheet):not(.pauta-sheet-doc *):not(.pauta-doc-sheet *)[style*="color: #111827"],
  html[data-theme="dark"] body :not(.pauta-sheet-doc):not(.pauta-doc-sheet):not(.pauta-sheet-doc *):not(.pauta-doc-sheet *)[style*="color: #000"] {
    color: #f1f5f9 !important;
  }

  html[data-theme="dark"] body :not(.pauta-sheet-doc):not(.pauta-doc-sheet):not(.pauta-sheet-doc *):not(.pauta-doc-sheet *)[style*="color: #334155"],
  html[data-theme="dark"] body :not(.pauta-sheet-doc):not(.pauta-doc-sheet):not(.pauta-sheet-doc *):not(.pauta-doc-sheet *)[style*="color:#334155"],
  html[data-theme="dark"] body :not(.pauta-sheet-doc):not(.pauta-doc-sheet):not(.pauta-sheet-doc *):not(.pauta-doc-sheet *)[style*="color: #475569"],
  html[data-theme="dark"] body :not(.pauta-sheet-doc):not(.pauta-doc-sheet):not(.pauta-sheet-doc *):not(.pauta-doc-sheet *)[style*="color:#475569"] {
    color: #cbd5e1 !important;
  }

  html[data-theme="dark"] body :not(.pauta-sheet-doc):not(.pauta-doc-sheet):not(.pauta-sheet-doc *):not(.pauta-doc-sheet *)[style*="color: #0369a1"],
  html[data-theme="dark"] body :not(.pauta-sheet-doc):not(.pauta-doc-sheet):not(.pauta-sheet-doc *):not(.pauta-doc-sheet *)[style*="color:#0369a1"],
  html[data-theme="dark"] body :not(.pauta-sheet-doc):not(.pauta-doc-sheet):not(.pauta-sheet-doc *):not(.pauta-doc-sheet *)[style*="color: #0c4a6e"],
  html[data-theme="dark"] body :not(.pauta-sheet-doc):not(.pauta-doc-sheet):not(.pauta-sheet-doc *):not(.pauta-doc-sheet *)[style*="color:#0c4a6e"],
  html[data-theme="dark"] body :not(.pauta-sheet-doc):not(.pauta-doc-sheet):not(.pauta-sheet-doc *):not(.pauta-doc-sheet *)[style*="color: #1e3a8a"],
  html[data-theme="dark"] body :not(.pauta-sheet-doc):not(.pauta-doc-sheet):not(.pauta-sheet-doc *):not(.pauta-doc-sheet *)[style*="color:#1e3a8a"] {
    color: #38bdf8 !important;
  }
}

@media print {
  .q-theme-toggle-btn {
    display: none !important;
  }
}

/* Selectores de máxima especificidad para sobreescribir reglas locales con !important en páginas */
html[data-theme="dark"] body.dark-mode .login-card-body .form-input,
html[data-theme="dark"] body.dark-mode .login-card-body .form-input:focus,
html[data-theme="dark"] body.dark-mode .config-layout-card .form-input,
html[data-theme="dark"] body.dark-mode .config-layout-card .form-input:focus,
html[data-theme="dark"] body.dark-mode .hist-input-with-icon,
html[data-theme="dark"] body.dark-mode .hist-input-with-icon:focus,
html[data-theme="dark"] body.dark-mode .filter-field-card .form-control,
html[data-theme="dark"] body.dark-mode .filter-field-card.primary-filter .form-control,
html[data-theme="dark"] body.dark-mode .filter-field-card .form-control:focus,
html[data-theme="dark"] body.dark-mode .operario-context-grid .filter-field-card .form-control {
  background: #0f172a !important;
  color: #f8fafc !important;
  border-color: #38bdf8 !important;
}

html[data-theme="dark"] body.dark-mode .config-layout-card .form-label,
html[data-theme="dark"] body.dark-mode .filter-field-label {
  color: #cbd5e1 !important;
}

html[data-theme="dark"] body.dark-mode .col-highlight-control {
  background-color: rgba(245, 158, 11, 0.12) !important;
  color: #f8fafc !important;
}

/* Ajustes adicionales Q-Desktop Header Bar y Pestañas AMFE en Modo Oscuro */
html[data-theme="dark"] body .qdesktop-header-bar,
html[data-theme="dark"] body .flow-top-area {
  background: linear-gradient(180deg, #1e293b 0%, #0f172a 100%) !important;
  border-color: #334155 !important;
  color: #f8fafc !important;
}

html[data-theme="dark"] body .amfe-tab-btn.active {
  background: linear-gradient(135deg, #0284c7 0%, #2563eb 100%) !important;
  border-color: #38bdf8 !important;
  color: #ffffff !important;
  box-shadow: 0 4px 12px rgba(2, 132, 199, 0.35) !important;
}


/* ==========================================================================
   AMFE & CONTROLES (amfe.html?tab=controles y ?tab=modos) EN MODO OSCURO
   ========================================================================== */
html[data-theme="dark"] body .ctrl-top-bar,
html[data-theme="dark"] body .amfe-cfg-header {
  background: linear-gradient(180deg, #1e293b 0%, #0f172a 100%) !important;
  border-color: #334155 !important;
  color: #f8fafc !important;
}

html[data-theme="dark"] body .ctrl-window-box {
  background: #0f172a !important;
  border-color: #334155 !important;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45) !important;
}

html[data-theme="dark"] body .ctrl-top-title,
html[data-theme="dark"] body .amfe-cfg-header-title {
  color: #f8fafc !important;
}

html[data-theme="dark"] body .ctrl-action-label,
html[data-theme="dark"] body .amfe-cfg-top-action-label {
  color: #cbd5e1 !important;
}

html[data-theme="dark"] body .btn-ctrl-win,
html[data-theme="dark"] body .ctrl-access-sq-btn,
html[data-theme="dark"] body .amfe-gear-config-btn,
html[data-theme="dark"] body .amfe-cfg-top-btn {
  background: linear-gradient(180deg, #1e293b 0%, #0f172a 100%) !important;
  border-color: #475569 !important;
  color: #f1f5f9 !important;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.4) !important;
}

html[data-theme="dark"] body .btn-ctrl-win:hover,
html[data-theme="dark"] body .ctrl-access-sq-btn:hover,
html[data-theme="dark"] body .amfe-gear-config-btn:hover,
html[data-theme="dark"] body .amfe-cfg-top-btn:hover {
  background: linear-gradient(180deg, #334155 0%, #1e293b 100%) !important;
  border-color: #38bdf8 !important;
  color: #ffffff !important;
}

/* Iconos SVG con relleno blanco en botones de Controles / AMFE */
html[data-theme="dark"] body .btn-ctrl-win svg rect[fill="#ffffff"],
html[data-theme="dark"] body .ctrl-access-sq-btn svg rect[fill="#ffffff"] {
  fill: #1e293b !important;
  stroke: #7dd3fc !important;
}

html[data-theme="dark"] body .btn-ctrl-win svg circle[fill="#ffffff"],
html[data-theme="dark"] body .amfe-gear-config-btn svg circle[fill="#ffffff"],
html[data-theme="dark"] body .qdesktop-config-btn svg circle[fill="#ffffff"],
html[data-theme="dark"] body .apqp-util-btn svg circle[fill="#ffffff"],
html[data-theme="dark"] body .acc-util-btn svg circle[fill="#ffffff"],
html[data-theme="dark"] body .qdoc-util-btn svg circle[fill="#ffffff"],
html[data-theme="dark"] body .qlab-util-btn svg circle[fill="#ffffff"],
html[data-theme="dark"] body .aud-util-btn svg circle[fill="#ffffff"],
html[data-theme="dark"] body .rrhh-util-btn svg circle[fill="#ffffff"],
html[data-theme="dark"] body .erp-util-btn svg circle[fill="#ffffff"] {
  fill: #1e293b !important;
}

/* Cabecera de tabla Controles1 y botones desplegables ▾ */
html[data-theme="dark"] body .controles-table {
  background: #0f172a !important;
  color: #f1f5f9 !important;
}

html[data-theme="dark"] body .controles-table thead th {
  background: linear-gradient(180deg, #1e293b 0%, #0f172a 100%) !important;
  color: #e2e8f0 !important;
  border-color: #334155 !important;
}

html[data-theme="dark"] body .ctrl-hdr-label {
  color: #e2e8f0 !important;
}

html[data-theme="dark"] body .ctrl-hdr-drop-btn {
  background: linear-gradient(180deg, #334155 0%, #1e293b 100%) !important;
  border-color: #475569 !important;
  color: #f1f5f9 !important;
}

html[data-theme="dark"] body .ctrl-hdr-drop-btn:hover {
  background: #475569 !important;
  border-color: #38bdf8 !important;
  color: #ffffff !important;
}

html[data-theme="dark"] body #ctrl-col-filter-row,
html[data-theme="dark"] body #ctrl-col-filter-row th {
  background: #172033 !important;
  border-color: #334155 !important;
}

/* Celdas y filas de .controles-table */
html[data-theme="dark"] body .controles-table tbody tr {
  background: #1e293b !important;
  background-color: #1e293b !important;
}

html[data-theme="dark"] body .controles-table tbody tr:nth-child(even) {
  background: #172033 !important;
  background-color: #172033 !important;
}

html[data-theme="dark"] body .controles-table tbody td {
  background: transparent !important;
  background-color: transparent !important;
  border-color: #334155 !important;
  color: #f1f5f9 !important;
}

/* Primera columna Nº Control (tiene style="background: #f2f2f2;") */
html[data-theme="dark"] body .controles-table tbody td[style*="background: #f2f2f2"],
html[data-theme="dark"] body .controles-table tbody td[style*="background:#f2f2f2"],
html[data-theme="dark"] body [style*="background: #f2f2f2"],
html[data-theme="dark"] body [style*="background:#f2f2f2"] {
  background: #131c2e !important;
  background-color: #131c2e !important;
  border-color: #334155 !important;
  color: #f1f5f9 !important;
}

/* Caja amarilla de Nº Control (.ctrl-cell-num-box y .ctrl-win-num) */
html[data-theme="dark"] body .ctrl-cell-num-box,
html[data-theme="dark"] body .ctrl-win-num {
  background: rgba(245, 158, 11, 0.22) !important;
  border-color: #b45309 !important;
  border-bottom-color: #b45309 !important;
  color: #fde68a !important;
  font-weight: 800 !important;
}

/* Hover y fila seleccionada en .controles-table */
html[data-theme="dark"] body .controles-table tbody tr:hover,
html[data-theme="dark"] body .controles-table tbody tr:hover td {
  background: #26354d !important;
  background-color: #26354d !important;
}

html[data-theme="dark"] body .controles-table tbody tr:hover td[style*="background: #f2f2f2"] {
  background: #1e2d44 !important;
  background-color: #1e2d44 !important;
}

html[data-theme="dark"] body .controles-table tbody tr.row-selected,
html[data-theme="dark"] body .controles-table tbody tr.row-selected td {
  background: #1e3a5f !important;
  background-color: #1e3a5f !important;
}

html[data-theme="dark"] body .controles-table tbody tr.row-selected td[style*="background: #f2f2f2"] {
  background: #173052 !important;
  background-color: #173052 !important;
}

/* Editores de texto en línea (<textarea class="ctrl-cell-edit-area">) dentro de la tabla */
html[data-theme="dark"] body .controles-table textarea.ctrl-cell-edit-area,
html[data-theme="dark"] body textarea.ctrl-cell-edit-area {
  background: transparent !important;
  background-color: transparent !important;
  color: #f1f5f9 !important;
  border: none !important;
  box-shadow: none !important;
}

html[data-theme="dark"] body .controles-table textarea.ctrl-cell-edit-area:focus,
html[data-theme="dark"] body textarea.ctrl-cell-edit-area:focus {
  background: #0f172a !important;
  background-color: #0f172a !important;
  color: #ffffff !important;
  box-shadow: inset 0 0 0 1.5px #38bdf8 !important;
}

/* Comboboxes en línea (.ctrl-cell-combo y .ctrl-cell-combo-arrow) */
html[data-theme="dark"] body .ctrl-cell-text,
html[data-theme="dark"] body .ctrl-cell-combo,
html[data-theme="dark"] body .ctrl-cell-combo-label,
html[data-theme="dark"] body .ctrl-cell-combo span {
  color: #f1f5f9 !important;
  border-color: #334155 !important;
}

html[data-theme="dark"] body .ctrl-cell-combo:hover {
  background: rgba(56, 189, 248, 0.1) !important;
}

html[data-theme="dark"] body .ctrl-cell-combo-arrow {
  background: linear-gradient(180deg, #1e293b 0%, #0f172a 100%) !important;
  border-left-color: #334155 !important;
  color: #94a3b8 !important;
}

html[data-theme="dark"] body .ctrl-cell-combo:hover .ctrl-cell-combo-arrow {
  background: linear-gradient(180deg, #334155 0%, #1e293b 100%) !important;
  color: #38bdf8 !important;
}

/* Filas anuladas en .controles-table */
html[data-theme="dark"] body .controles-table tbody tr.row-anulado td,
html[data-theme="dark"] body .controles-table tbody tr.row-anulado textarea.ctrl-cell-edit-area,
html[data-theme="dark"] body .controles-table tbody tr.row-anulado .ctrl-cell-combo-label,
html[data-theme="dark"] body .controles-table tbody tr.row-anulado .ctrl-cell-combo span {
  color: #64748b !important;
}

/* Desplegable flotante multi-columna (.access-combo-popup) y menú de filtros */
html[data-theme="dark"] body .access-combo-popup {
  background: #1e293b !important;
  border-color: #475569 !important;
  color: #f1f5f9 !important;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.65) !important;
}

html[data-theme="dark"] body .access-combo-popup thead th {
  background: #0f172a !important;
  color: #cbd5e1 !important;
  border-bottom-color: #334155 !important;
  border-right-color: #334155 !important;
}

html[data-theme="dark"] body .access-combo-popup tbody tr {
  background: #1e293b !important;
  background-color: #1e293b !important;
  border-bottom-color: #334155 !important;
  color: #f1f5f9 !important;
}

html[data-theme="dark"] body .access-combo-popup tbody td {
  border-right-color: #334155 !important;
  color: inherit !important;
}

html[data-theme="dark"] body .access-combo-popup tbody tr:hover,
html[data-theme="dark"] body .access-combo-popup tbody tr:hover td,
html[data-theme="dark"] body .access-combo-popup .access-hdr-val-item:hover {
  background: #334155 !important;
  background-color: #334155 !important;
  color: #38bdf8 !important;
}

html[data-theme="dark"] body .access-combo-popup tbody tr.combo-row-active,
html[data-theme="dark"] body .access-combo-popup tbody tr.combo-row-active td {
  background: #0284c7 !important;
  background-color: #0284c7 !important;
  color: #ffffff !important;
}

/* Cabeceras de modales de Controles y AMFE con gradientes claros en línea */
html[data-theme="dark"] body [style*="linear-gradient(180deg, #9cb3c9"],
html[data-theme="dark"] body [style*="linear-gradient(180deg, #e1ecf8"],
html[data-theme="dark"] body [style*="linear-gradient(180deg, #e1ecf7"],
html[data-theme="dark"] body [style*="linear-gradient(180deg, #fde68a"],
html[data-theme="dark"] body [style*="linear-gradient(180deg, #ddd6fe"] {
  background: linear-gradient(180deg, #1e293b 0%, #0f172a 100%) !important;
  border-color: #334155 !important;
  color: #f8fafc !important;
}

/* Badges amarillos/naranjas en cabeceras y celdas con texto oscuro en línea */
html[data-theme="dark"] body [style*="background: #fef08a"],
html[data-theme="dark"] body [style*="background:#fef08a"],
html[data-theme="dark"] body [style*="background: #fef9c3"],
html[data-theme="dark"] body [style*="background:#fef9c3"] {
  background: rgba(245, 158, 11, 0.22) !important;
  border-color: #d97706 !important;
  color: #fde68a !important;
}

/* Controles internos y SVGs dentro de .ctrl-top-bar (Modos de fallo y Ficha AMFE) */
html[data-theme="dark"] body .ctrl-top-bar #mf-count-badge {
  background: #0f172a !important;
  color: #38bdf8 !important;
  border-color: #334155 !important;
}

html[data-theme="dark"] body .ctrl-top-bar div[style*="background: #ffffff"],
html[data-theme="dark"] body .ctrl-top-bar label[style*="rgba(255,255,255"],
html[data-theme="dark"] body [style*="rgba(255,255,255,0.65)"],
html[data-theme="dark"] body [style*="rgba(255, 255, 255, 0.65)"] {
  background: #0f172a !important;
  border-color: #334155 !important;
  color: #e2e8f0 !important;
}

html[data-theme="dark"] body .ctrl-top-bar label,
html[data-theme="dark"] body .ctrl-top-bar label span {
  color: #e2e8f0 !important;
}

html[data-theme="dark"] body .ctrl-top-bar select {
  background: #1e293b !important;
  color: #f8fafc !important;
  border-color: #475569 !important;
}

html[data-theme="dark"] body .btn-ctrl-win svg[stroke="#475569"],
html[data-theme="dark"] body .btn-ctrl-win svg path[stroke="#475569"] {
  stroke: #cbd5e1 !important;
}

html[data-theme="dark"] body .btn-ctrl-win svg circle[fill="#e2e8f0"] {
  fill: #334155 !important;
  stroke: #cbd5e1 !important;
}

html[data-theme="dark"] body .btn-ctrl-win svg rect[fill="#bae6fd"] {
  fill: rgba(56, 189, 248, 0.22) !important;
  stroke: #38bdf8 !important;
}

html[data-theme="dark"] body .btn-ctrl-win svg path[stroke="#0369a1"],
html[data-theme="dark"] body .btn-ctrl-win svg path[stroke="#0284c7"] {
  stroke: #38bdf8 !important;
}

html[data-theme="dark"] body .btn-ctrl-win svg rect[fill="#fef3c7"] {
  fill: rgba(245, 158, 11, 0.22) !important;
  stroke: #fbbf24 !important;
}

html[data-theme="dark"] body .btn-ctrl-win svg path[stroke="#b45309"] {
  stroke: #fcd34d !important;
}

html[data-theme="dark"] body .btn-ctrl-win svg circle[fill="#f3e8ff"] {
  fill: rgba(168, 85, 247, 0.22) !important;
  stroke: #c084fc !important;
}

html[data-theme="dark"] body .btn-ctrl-win svg path[stroke="#7e22ce"] {
  stroke: #c084fc !important;
}

html[data-theme="dark"] body .btn-ctrl-win svg rect[fill="#e0f2fe"] {
  fill: rgba(56, 189, 248, 0.2) !important;
  stroke: #38bdf8 !important;
}


        html[data-theme="dark"] body [style*="color: #7e22ce"],
        html[data-theme="dark"] body [style*="color:#7e22ce"] {
            color: #c084fc !important;
        }
        html[data-theme="dark"] body [style*="background: #fee2e2"],
        html[data-theme="dark"] body [style*="background:#fee2e2"] {
            background: rgba(239, 68, 68, 0.22) !important;
            border-color: #ef4444 !important;
            color: #fca5a5 !important;
        }
        html[data-theme="dark"] body [style*="background: #dcfce7"],
        html[data-theme="dark"] body [style*="background:#dcfce7"] {
            background: rgba(16, 185, 129, 0.22) !important;
            border-color: #10b981 !important;
            color: #6ee7b7 !important;
        }
        html[data-theme="dark"] body [style*="background: #ffedd5"],
        html[data-theme="dark"] body [style*="background:#ffedd5"] {
            background: rgba(249, 115, 22, 0.2) !important;
            border-color: #f97316 !important;
            color: #fdba74 !important;
        }

/* ==========================================================================
   ADAPTACIÓN INTEGRAL MÓVIL (<= 768px Y <= 480px) — 0% IMPACTO EN ESCRITORIO
   ========================================================================== */
@media (max-width: 768px) {
  /* 1. Cajón lateral (Sidebar) con altura dinámica móvil y área segura inferior */
  .sidebar {
    height: 100dvh !important;
    max-height: 100dvh !important;
    width: min(290px, 86vw) !important;
  }

  .sidebar-footer {
    padding-bottom: calc(0.65rem + env(safe-area-inset-bottom, 0px)) !important;
  }

  /* Controles móviles en Modo Oscuro */
  html[data-theme="dark"] body .mobile-nav-toggle,
  html[data-theme="dark"] body .mobile-floating-toggle {
    background: #1e293b !important;
    border-color: #475569 !important;
    color: #f8fafc !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.45) !important;
  }

  html[data-theme="dark"] body .table-swipe-hint {
    background: #1e293b !important;
    border-color: #475569 !important;
    color: #cbd5e1 !important;
  }

  /* 2. Contenedores de tablas universalmente desplazables en horizontal con toque suave */
  .table-responsive,
  .table-container,
  .table-wrapper,
  .mobile-table-scroll,
  .erp-table-wrap,
  .qdoc-table-wrap,
  #empleados-table-scroll-wrap,
  #classic-view-container,
  #of-csv-preview-container,
  div:has(> .pauta-sheet-doc),
  div:has(> table:not(.ui-datepicker-calendar):not(.pauta-header-table):not(.pauta-main-table):not(.pauta-sheet-hdr-table):not(.pauta-sheet-main-table):not(.pauta-sheet-table)) {
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch !important;
    max-width: 100% !important;
  }

  .ctrl-window-box,
  .med-window-box,
  .qdesktop-panel,
  .qdoc-window-box,
  .erp-panel {
    max-width: 100% !important;
  }

  /* Evitar aplastamiento de columnas en tablas con table-layout: fixed de escritorio */
  #gestion-usuario-table {
    min-width: 960px !important;
    table-layout: auto !important;
  }

  #tabla-modificaciones-empleados {
    min-width: 760px !important;
    table-layout: auto !important;
  }

  #amfe-matriz-table,
  .controles-table {
    min-width: 1020px !important;
  }

  .amfe-list-table,
  .amfe-access-table {
    min-width: 820px !important;
  }

  .erp-table,
  .purchase-table,
  .qdoc-table,
  .acc-table,
  .apqp-table,
  .aud-table,
  .rrhh-table,
  .of-table {
    min-width: 640px !important;
  }

  /* Subtablas anidadas y tablas internas de formato A4 no deben forzar 650px por separado */
  td table,
  .pauta-header-table,
  .pauta-main-table,
  .pauta-sheet-hdr-table,
  .pauta-sheet-main-table,
  .pauta-sheet-table {
    min-width: 0 !important;
  }

  .pauta-sheet-doc {
    min-width: 720px !important;
  }

  /* 3. Cobertura universal de Modales, Ventanas y Lightboxes en móvil */
  .modal,
  .modal-backdrop,
  .modal-overlay,
  .acc-modal-overlay,
  .apqp-modal-overlay,
  .aud-modal-overlay,
  .qdoc-modal-overlay,
  .qlab-modal-overlay,
  .rrhh-modal-overlay,
  .erp-modal-backdrop,
  .qd-modal-backdrop,
  .amfe-cfg-modal-backdrop,
  .tipo-pauta-modal-backdrop {
    padding: 0 !important;
    align-items: flex-end !important;
    justify-content: center !important;
  }

  .modal-dialog,
  .modal-content,
  .modal-box,
  .modal-box-ccc,
  .modal-box-hist,
  .acc-modal-box,
  .apqp-modal-box,
  .aud-modal-box,
  .qdoc-modal-box,
  .qlab-modal-box,
  .rrhh-modal-box,
  .erp-modal-card,
  .qd-access-window,
  .qd-config-menu-window,
  .qd-subform-window,
  .amfe-cfg-window,
  .tipo-pauta-modal-card,
  .pauta-modal-box {
    width: 100% !important;
    max-width: 100vw !important;
    max-height: 92vh !important;
    max-height: 92dvh !important;
    margin: 0 !important;
    border-radius: 16px 16px 0 0 !important;
    box-sizing: border-box !important;
  }

  .modal-dialog > form,
  .modal-content > form {
    display: flex !important;
    flex-direction: column !important;
    flex: 1 1 auto !important;
    min-height: 0 !important;
    overflow: hidden !important;
    margin: 0 !important;
  }

  .modal-dialog .modal-body,
  .modal-content .modal-body {
    flex: 1 1 auto !important;
    min-height: 0 !important;
    max-height: none !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch !important;
  }

  .modal-dialog .modal-header,
  .modal-dialog .modal-footer,
  .modal-content .modal-header,
  .modal-content .modal-footer {
    flex-shrink: 0 !important;
  }

  .acc-modal-box,
  .apqp-modal-box,
  .aud-modal-box,
  .modal-box-ccc,
  .modal-box-hist,
  .qdoc-modal-body,
  .qlab-modal-body,
  .rrhh-modal-body,
  .erp-modal-body,
  .amfe-cfg-body,
  #acc-modal-body,
  #apqp-modal-body,
  #aud-modal-body,
  #modal-ccc-body,
  #modal-hist-body,
  #modal-nok-body {
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
  }

  #modal-ccc-body,
  #modal-hist-body,
  #modal-nok-body,
  #qdoc-report-body {
    padding: 12px 14px !important;
  }

  #modal-foto-pieza > div,
  #modal-zoom-foto-defecto > div {
    width: 100vw !important;
    max-width: 100vw !important;
    height: 94dvh !important;
    max-height: 94dvh !important;
    border-radius: 14px 14px 0 0 !important;
  }

  /* Popovers y desplegables flotantes dentro del ancho de pantalla */
  .of-art-suggestions-dropdown,
  .pieza-suggestions-dropdown,
  .access-combo-popup,
  .ref-hover-popover {
    min-width: 0 !important;
    max-width: calc(100vw - 24px) !important;
    box-sizing: border-box !important;
  }

  /* 4. Sub-barras de navegación con desplazamiento táctil horizontal */
  .qpro-subnav-bar,
  .erp-subnav-bar {
    flex-wrap: nowrap !important;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch !important;
    max-width: 100% !important;
    scrollbar-width: none !important;
  }

  .qpro-subnav-bar::-webkit-scrollbar,
  .erp-subnav-bar::-webkit-scrollbar {
    display: none !important;
  }

  .qpro-subnav-pill,
  .erp-tab-btn {
    flex: 0 0 auto !important;
    white-space: nowrap !important;
  }

  /* 5. Panel Principal (dashboard.html): cabecera logo + engranaje + tarjeta versión sin desborde */
  div[style*="padding: 0 1.5rem"]:has(.qdesktop-header-logo) {
    padding: 0 0.25rem !important;
  }

  .grid-cards:has(.qdesktop-header-logo) {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 0.65rem !important;
  }

  .grid-cards:has(.qdesktop-header-logo) > div:last-child {
    width: 100% !important;
    margin-left: 0 !important;
    justify-content: space-between !important;
    flex-wrap: wrap !important;
    gap: 10px !important;
  }

  .grid-cards:has(.qdesktop-header-logo) > div:last-child > .card {
    flex: 1 1 180px !important;
    width: auto !important;
    max-width: 100% !important;
  }

  .qdesktop-bottom-actions {
    padding-left: 0 !important;
    justify-content: center !important;
  }

  /* 6. Estación de Registros de Calidad (registros_calidad.html) */
  #fases-execution-container.bono-stage-minheight {
    min-height: calc(100dvh - 64px) !important;
  }

  .cac-stage-wrapper,
  .cac-spec-showcase,
  .cac-workstation-card {
    min-width: 0 !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
  }

  .cac-main-grid {
    grid-template-columns: minmax(0, 1fr) !important;
    padding: 10px !important;
    gap: 12px !important;
  }

  .cac-top-nav-bar {
    padding: 10px 12px !important;
    gap: 8px !important;
  }

  .cac-top-nav-bar > div {
    flex-wrap: wrap !important;
    max-width: 100% !important;
  }

  .cac-steps-strip-box {
    padding: 10px 12px 8px 12px !important;
  }

  .rcp-closed-lock-banner {
    margin: 10px 10px 0 10px !important;
    padding: 10px 12px !important;
  }

  .cat-def-cards-grid {
    grid-template-columns: minmax(0, 1fr) !important;
  }

  /* 7. Q-ERP, Referencias, Estadísticas, Histórico y CCC */
  .erp-subviews-wrapper {
    padding: 0.85rem 0.65rem 2rem 0.65rem !important;
  }

  .erp-kpi-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 0.65rem !important;
  }

  .erp-search-box,
  .erp-search-input,
  .erp-filter-select {
    width: 100% !important;
    max-width: 100% !important;
  }

  .acr-card {
    padding: 14px 12px !important;
  }

  .ref-modern-grid {
    grid-template-columns: minmax(0, 1fr) !important;
    padding: 10px !important;
    gap: 12px !important;
  }

  .hist-filter-header {
    flex-wrap: wrap !important;
    padding: 10px 12px !important;
    gap: 8px !important;
  }

  .charts-dashboard-grid,
  .charts-secondary-grid {
    grid-template-columns: minmax(0, 1fr) !important;
    gap: 12px !important;
  }

  .chart-card {
    min-width: 0 !important;
    max-width: 100% !important;
  }

  .spc-cota-select {
    max-width: 100% !important;
    width: 100% !important;
  }

  /* Mantener las 7 columnas del histograma SPC con hueco compacto */
  div[style*="repeat(7, 1fr)"] {
    gap: 3px !important;
  }

  /* 8. Colapso seguro de rejillas multicolumna en línea dentro de modales y subvistas */
  .modal-box div[style*="grid-template-columns"]:not(.qd-subform-colbar):not(.qd-subform-row):not([style*="repeat(7,"]):not([style*="42px 1fr"]):not([style*="34px 1fr"]):not([style*="64px 1fr"]),
  .modal-box-ccc div[style*="grid-template-columns"]:not([style*="repeat(7,"]):not([style*="42px 1fr"]):not([style*="34px 1fr"]),
  .modal-box-hist div[style*="grid-template-columns"]:not([style*="repeat(7,"]):not([style*="42px 1fr"]):not([style*="34px 1fr"]),
  .qdoc-modal-body div[style*="grid-template-columns"]:not([style*="42px 1fr"]):not([style*="34px 1fr"]),
  .qlab-modal-body div[style*="grid-template-columns"]:not([style*="42px 1fr"]):not([style*="34px 1fr"]),
  .erp-modal-body div[style*="grid-template-columns"]:not([style*="42px 1fr"]):not([style*="34px 1fr"]),
  .amfe-cfg-body div[style*="grid-template-columns"]:not([style*="42px 1fr"]):not([style*="34px 1fr"]),
  .qdoc-subview div[style*="grid-template-columns"]:not([style*="76px 1fr 76px"]):not([style*="42px 1fr"]):not([style*="34px 1fr"]),
  .erp-subviews-wrapper div[style*="grid-template-columns"]:not(.erp-kpi-grid):not([style*="42px 1fr"]):not([style*="34px 1fr"]),
  div[style*="position: fixed"] div[style*="grid-template-columns"]:not(.qd-subform-colbar):not(.qd-subform-row):not(.cac-tol-cards-row):not(.cac-measurements-grid):not(.measurements-grid):not([style*="repeat(7,"]):not([style*="42px 1fr"]):not([style*="34px 1fr"]):not([style*="64px 1fr"]) {
    grid-template-columns: minmax(0, 1fr) !important;
    gap: 0.65rem !important;
  }
}

@media (max-width: 480px) {
  .erp-kpi-grid {
    grid-template-columns: minmax(0, 1fr) !important;
  }

  .cac-hero-title {
    font-size: 1.08rem !important;
  }

  .cac-nav-btn {
    flex: 1 1 auto !important;
    justify-content: center !important;
    padding: 7px 10px !important;
    font-size: 0.74rem !important;
  }

  .pauta-sheet-top {
    grid-template-columns: 1fr !important;
    gap: 8px !important;
    text-align: center !important;
  }

  .pauta-sheet-meta {
    grid-template-columns: 1fr !important;
  }
}


/* ==========================================================================
   MODO IMPRESIÓN UNIVERSAL: ELIMINAR BARRAS DE SCROLL Y CORTES DE CONTENIDO
   ========================================================================== */
@media print {
  /* 1. Ocultar cualquier barra de desplazamiento nativa o personalizada */
  *,
  *::before,
  *::after {
    scrollbar-width: none !important;
    -ms-overflow-style: none !important;
  }

  *::-webkit-scrollbar,
  *::-webkit-scrollbar-track,
  *::-webkit-scrollbar-thumb,
  *::-webkit-scrollbar-corner {
    display: none !important;
    width: 0 !important;
    height: 0 !important;
    background: transparent !important;
  }

  /* 2. Liberar altura y overflow de raíz, layout y contenedores con scroll */
  html,
  body,
  .app-layout,
  .main-content,
  .page-body,
  .table-responsive,
  .table-container,
  .table-wrapper,
  .mobile-table-scroll,
  .erp-table-wrap,
  .qdoc-table-wrap,
  .pauta-modal-scroll,
  .pauta-modal-box,
  .qdoc-modal-body,
  .qlab-modal-body,
  .erp-modal-body,
  .rrhh-modal-body,
  .amfe-cfg-body,
  #empleados-table-scroll-wrap,
  #classic-view-container,
  #spc-measurements-table-box,
  #qlab-spc-table,
  #modal-globe-content,
  [style*="overflow: auto"],
  [style*="overflow:auto"],
  [style*="overflow-y: auto"],
  [style*="overflow-y:auto"],
  [style*="overflow-x: auto"],
  [style*="overflow-x:auto"],
  [style*="overflow: scroll"],
  [style*="overflow:scroll"],
  [style*="overflow-y: scroll"],
  [style*="overflow-y:scroll"],
  [style*="overflow-x: scroll"],
  [style*="overflow-x:scroll"] {
    overflow: visible !important;
    overflow-x: visible !important;
    overflow-y: visible !important;
    max-height: none !important;
    height: auto !important;
  }

  /* 3. Ocultar controles flotantes / barra lateral / ayudas táctiles de scroll */
  .sidebar,
  .sidebar-backdrop,
  .mobile-nav-toggle,
  .mobile-floating-toggle,
  .table-swipe-hint,
  .q-theme-toggle-btn,
  .no-print,
  .no-print-bar {
    display: none !important;
  }

  .main-content {
    margin-left: 0 !important;
    width: 100% !important;
    min-height: 0 !important;
    background: #ffffff !important;
  }

  /* 4. Si hay un modal abierto al pulsar Imprimir, imprimir limpio y sin scroll */
  body:has(#modal-menu-impresion[style*="display: flex"]) > *:not(#modal-menu-impresion),
  body:has(#modal-menu-impresion[style*="display: block"]) > *:not(#modal-menu-impresion),
  body:has(#modal-spc-estudio[style*="display: flex"]) > *:not(#modal-spc-estudio),
  body:has(#modal-spc-estudio[style*="display: block"]) > *:not(#modal-spc-estudio),
  body:has(#modal-hoja-pauta-oficial[style*="display: flex"]) > *:not(#modal-hoja-pauta-oficial),
  body:has(#modal-hoja-pauta-oficial[style*="display: block"]) > *:not(#modal-hoja-pauta-oficial),
  body:has(#modal-control-globe[style*="display: flex"]) > *:not(#modal-control-globe),
  body:has(#modal-control-globe[style*="display: block"]) > *:not(#modal-control-globe),
  body:has(.qlab-modal-overlay[style*="display: flex"]) > *:not(.qlab-modal-overlay[style*="display: flex"]),
  body:has(.qlab-modal-overlay[style*="display: block"]) > *:not(.qlab-modal-overlay[style*="display: block"]) {
    display: none !important;
  }

  #modal-menu-impresion[style*="display: flex"],
  #modal-menu-impresion[style*="display: block"],
  #modal-spc-estudio[style*="display: flex"],
  #modal-spc-estudio[style*="display: block"],
  #modal-hoja-pauta-oficial[style*="display: flex"],
  #modal-hoja-pauta-oficial[style*="display: block"],
  #modal-control-globe[style*="display: flex"],
  #modal-control-globe[style*="display: block"],
  .qlab-modal-overlay[style*="display: flex"],
  .qlab-modal-overlay[style*="display: block"] {
    position: static !important;
    inset: auto !important;
    display: block !important;
    background: #ffffff !important;
    backdrop-filter: none !important;
    padding: 0 !important;
    margin: 0 !important;
    width: 100% !important;
    height: auto !important;
    max-height: none !important;
    overflow: visible !important;
  }

  #modal-menu-impresion > div,
  #modal-spc-estudio > div,
  #modal-hoja-pauta-oficial > div,
  #modal-control-globe > div,
  .qlab-modal-overlay > .qlab-modal-box {
    width: 100% !important;
    max-width: 100% !important;
    max-height: none !important;
    height: auto !important;
    border: none !important;
    box-shadow: none !important;
    background: #ffffff !important;
    overflow: visible !important;
  }

  /* Ocultar cabeceras/barras de herramientas de modales de vista previa al imprimir */
  #modal-menu-impresion .qdesktop-header-bar,
  #modal-menu-impresion > div > div:nth-child(2),
  #modal-spc-estudio .qdesktop-header-bar .qdesktop-toolbar-group,
  #modal-hoja-pauta-oficial > div > div:first-child,
  #modal-control-globe > div > div:last-child,
  .qlab-modal-footer {
    display: none !important;
  }

  #modal-menu-impresion > div > div:last-child,
  #modal-hoja-pauta-oficial > div > div:last-child {
    padding: 0 !important;
    background: #ffffff !important;
    overflow: visible !important;
  }

  #menu-impresion-preview-sheet,
  .pauta-sheet-doc {
    max-width: 100% !important;
    min-width: 0 !important;
    border: none !important;
    box-shadow: none !important;
    margin: 0 !important;
  }
}

/* =========================================================
   BOTÓN CERRAR UNIFICADO EN TODOS LOS MODALES (.qd-modal-close-btn)
   Círculo perfecto 34x34 con SVG geométrico centrado y hover moderno
   ========================================================= */
.qd-modal-close-btn,
.modal-close {
  width: 34px !important;
  height: 34px !important;
  min-width: 34px !important;
  min-height: 34px !important;
  max-width: 34px !important;
  max-height: 34px !important;
  padding: 0 !important;
  margin: 0 !important;
  border-radius: 50% !important;
  aspect-ratio: 1 / 1;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  flex-shrink: 0 !important;
  box-sizing: border-box !important;
  line-height: 1 !important;
  font-size: 0 !important;
  cursor: pointer !important;
  transition: background-color 0.18s ease, border-color 0.18s ease, color 0.18s ease, transform 0.18s ease, box-shadow 0.18s ease !important;
}
.qd-modal-close-btn svg,
.modal-close svg {
  width: 16px !important;
  height: 16px !important;
  display: block !important;
  pointer-events: none;
}
.qd-modal-close-btn {
  background: rgba(255, 255, 255, 0.16) !important;
  border: 1.5px solid rgba(255, 255, 255, 0.34) !important;
  color: #ffffff !important;
  box-shadow: 0 2px 6px rgba(15, 23, 42, 0.22) !important;
}
.qd-modal-close-btn:hover {
  background: #ef4444 !important;
  border-color: #fca5a5 !important;
  color: #ffffff !important;
  transform: scale(1.06) rotate(90deg) !important;
  box-shadow: 0 4px 12px rgba(239, 68, 68, 0.42) !important;
}
.qd-modal-close-btn.qd-modal-close-btn--light,
.modal-close {
  background: #f1f5f9 !important;
  border: 1px solid #cbd5e1 !important;
  color: #475569 !important;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.08) !important;
}
.qd-modal-close-btn.qd-modal-close-btn--light:hover,
.modal-close:hover {
  background: #ef4444 !important;
  border-color: #dc2626 !important;
  color: #ffffff !important;
  transform: scale(1.06) rotate(90deg) !important;
  box-shadow: 0 4px 10px rgba(239, 68, 68, 0.35) !important;
}
.qd-modal-close-btn.qd-modal-close-btn--danger {
  background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%) !important;
  border: 1.5px solid #fca5a5 !important;
  color: #ffffff !important;
  box-shadow: 0 2px 8px rgba(220, 38, 38, 0.34) !important;
}
.qd-modal-close-btn.qd-modal-close-btn--danger:hover {
  background: linear-gradient(135deg, #dc2626 0%, #b91c1c 100%) !important;
  border-color: #fecaca !important;
  color: #ffffff !important;
  transform: scale(1.07) rotate(90deg) !important;
  box-shadow: 0 4px 14px rgba(220, 38, 38, 0.48) !important;
}
html[data-theme="dark"] .qd-modal-close-btn.qd-modal-close-btn--light,
html[data-theme="dark"] .modal-close {
  background: #334155 !important;
  border-color: #475569 !important;
  color: #e2e8f0 !important;
}
html[data-theme="dark"] .qd-modal-close-btn.qd-modal-close-btn--light:hover,
html[data-theme="dark"] .modal-close:hover {
  background: #ef4444 !important;
  border-color: #fca5a5 !important;
  color: #ffffff !important;
}
.qd-window-close-x,
.pauta-guideline-winbar-close {
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  padding: 0 !important;
  line-height: 1 !important;
}
.qd-window-close-x svg,
.pauta-guideline-winbar-close svg {
  width: 14px !important;
  height: 14px !important;
  display: block !important;
}
