/**
 * ============================================================================
 * MANUTSYS — SISTEMA GLOBAL DE TEMAS (CLARO / ESCURO)
 * Design Tokens, Variáveis CSS, Componentes e Regras Globais
 * Compatível com Bootstrap 5.3+ (data-bs-theme) e Data-Theme (data-theme)
 * ============================================================================
 */

/* ----------------------------------------------------------------------------
   1. VARIÁVEIS / DESIGN TOKENS GLOBAIS
   ---------------------------------------------------------------------------- */
:root,
html,
:root[data-bs-theme="light"],
:root[data-theme="light"],
html[data-bs-theme="light"],
html[data-theme="light"] {
  /* Tokens Padronizados ManutSys (--ms-*) */
  --ms-bg: #f5f7fb;
  --ms-surface: #ffffff;
  --ms-surface-2: #f8fafc;
  --ms-surface-3: #f1f5f9;

  --ms-text: #1e293b;
  --ms-text-secondary: #64748b;
  --ms-text-muted: #94a3b8;

  --ms-border: #e2e8f0;
  --ms-border-subtle: #f1f5f9;
  --ms-border-focus: #3b82f6;

  --ms-input-bg: #ffffff;
  --ms-input-border: #cbd5e1;
  --ms-input-color: #0f172a;

  --ms-table-header: #f8fafc;

  /* Mapeamento para os Tokens Legados (--manutsys-*) */
  --manutsys-theme: light;
  --manutsys-bg: var(--ms-bg);
  --manutsys-bg-alt: var(--ms-surface-3);
  --manutsys-surface: var(--ms-surface);
  --manutsys-surface-elevated: var(--ms-surface-2);
  --manutsys-surface-hover: var(--ms-surface-3);
  --manutsys-surface-active: #e2e8f0;

  --manutsys-border: var(--ms-border);
  --manutsys-border-subtle: var(--ms-border-subtle);
  --manutsys-border-focus: var(--ms-border-focus);

  --manutsys-text: var(--ms-text);
  --manutsys-text-muted: var(--ms-text-secondary);
  --manutsys-text-dim: var(--ms-text-muted);
  --manutsys-text-inverse: #ffffff;
  --manutsys-muted: var(--ms-text-secondary);

  --manutsys-sidebar-bg: #ffffff;
  --manutsys-sidebar-border: #e2e8f0;
  --manutsys-sidebar-hover: #f8fafc;
  --manutsys-sidebar-active: #eff6ff;
  --manutsys-sidebar-active-text: #2563eb;

  --manutsys-primary: #2563eb;
  --manutsys-primary-hover: #1d4ed8;
  --manutsys-primary-bg: #eff6ff;
  --manutsys-primary-border: #bfdbfe;

  --manutsys-success: #16a34a;
  --manutsys-success-bg: #f0fdf4;
  --manutsys-success-border: #bbf7d0;

  --manutsys-warning: #f59e0b;
  --manutsys-warning-bg: #fefce8;
  --manutsys-warning-border: #fef08a;

  --manutsys-danger: #dc2626;
  --manutsys-danger-bg: #fef2f2;
  --manutsys-danger-border: #fecaca;

  --manutsys-purple: #7c3aed;
  --manutsys-purple-bg: #f5f3ff;
  --manutsys-purple-border: #ddd6fe;

  --manutsys-shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.05);
  --manutsys-shadow: 0 4px 16px rgba(0, 0, 0, 0.06);
  --manutsys-shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.08);

  --manutsys-input-bg: var(--ms-input-bg);
  --manutsys-input-border: var(--ms-input-border);
  --manutsys-input-color: var(--ms-input-color);
  --manutsys-input-placeholder: #94a3b8;
  --manutsys-table-header: var(--ms-table-header);
  --manutsys-radius: 12px;

  /* Bootstrap 5.3 Native overrides (Light) */
  --bs-body-bg: var(--ms-bg);
  --bs-body-color: var(--ms-text);
  --bs-border-color: var(--ms-border);
  --bs-card-bg: var(--ms-surface);
  --bs-modal-bg: var(--ms-surface);
  --bs-tertiary-bg: var(--ms-surface-2);
  --bs-secondary-bg: var(--ms-surface-2);
}

/* ----------------------------------------------------------------------------
   MODO ESCURO — DESIGN TOKENS COM !IMPORTANT PARA PREVENIR SOBREPOSIÇÃO LOCAL
   ---------------------------------------------------------------------------- */
:root[data-bs-theme="dark"],
:root[data-theme="dark"],
html[data-bs-theme="dark"],
html[data-theme="dark"] {
  /* Tokens Padronizados ManutSys (--ms-*) */
  --ms-bg: #0b111d !important;
  --ms-surface: #111a2b !important;
  --ms-surface-2: #162033 !important;
  --ms-surface-3: #1b263a !important;

  --ms-text: #f1f5f9 !important;
  --ms-text-secondary: #cbd5e1 !important;
  --ms-text-muted: #94a3b8 !important;

  --ms-border: #283750 !important;
  --ms-border-subtle: #1e2a3f !important;
  --ms-border-focus: #3b82f6 !important;

  --ms-input-bg: #121c2e !important;
  --ms-input-border: #283750 !important;
  --ms-input-color: #f1f5f9 !important;

  --ms-table-header: #101827 !important;

  /* Mapeamento para os Tokens Legados (--manutsys-*) */
  --manutsys-theme: dark !important;
  --manutsys-bg: var(--ms-bg) !important;
  --manutsys-bg-alt: var(--ms-surface-2) !important;
  --manutsys-surface: var(--ms-surface) !important;
  --manutsys-surface-elevated: var(--ms-surface-2) !important;
  --manutsys-surface-hover: var(--ms-surface-3) !important;
  --manutsys-surface-active: #223049 !important;

  --manutsys-border: var(--ms-border) !important;
  --manutsys-border-subtle: var(--ms-border-subtle) !important;
  --manutsys-border-focus: var(--ms-border-focus) !important;

  --manutsys-text: var(--ms-text) !important;
  --manutsys-text-muted: var(--ms-text-muted) !important;
  --manutsys-text-dim: var(--ms-text-secondary) !important;
  --manutsys-text-inverse: #0f172a !important;
  --manutsys-muted: var(--ms-text-muted) !important;

  --manutsys-sidebar-bg: #0d1524 !important;
  --manutsys-sidebar-border: #1e2a3f !important;
  --manutsys-sidebar-hover: #162033 !important;
  --manutsys-sidebar-active: rgba(37, 99, 235, 0.25) !important;
  --manutsys-sidebar-active-text: #60a5fa !important;

  --manutsys-primary: #3b82f6 !important;
  --manutsys-primary-hover: #60a5fa !important;
  --manutsys-primary-bg: rgba(59, 130, 246, 0.16) !important;
  --manutsys-primary-border: rgba(59, 130, 246, 0.35) !important;

  --manutsys-success: #10b981 !important;
  --manutsys-success-bg: rgba(16, 185, 129, 0.16) !important;
  --manutsys-success-border: rgba(16, 185, 129, 0.35) !important;

  --manutsys-warning: #f59e0b !important;
  --manutsys-warning-bg: rgba(245, 158, 11, 0.16) !important;
  --manutsys-warning-border: rgba(245, 158, 11, 0.35) !important;

  --manutsys-danger: #ef4444 !important;
  --manutsys-danger-bg: rgba(239, 68, 68, 0.16) !important;
  --manutsys-danger-border: rgba(239, 68, 68, 0.35) !important;

  --manutsys-purple: #8b5cf6 !important;
  --manutsys-purple-bg: rgba(139, 92, 246, 0.16) !important;
  --manutsys-purple-border: rgba(139, 92, 246, 0.35) !important;

  --manutsys-shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.4) !important;
  --manutsys-shadow: 0 4px 20px rgba(0, 0, 0, 0.45) !important;
  --manutsys-shadow-lg: 0 12px 40px rgba(0, 0, 0, 0.6) !important;

  --manutsys-input-bg: var(--ms-input-bg) !important;
  --manutsys-input-border: var(--ms-input-border) !important;
  --manutsys-input-color: var(--ms-input-color) !important;
  --manutsys-input-placeholder: #64748b !important;
  --manutsys-table-header: var(--ms-table-header) !important;
  --manutsys-radius: 12px !important;

  /* Bootstrap 5.3 Native Variables (Dark) */
  --bs-body-bg: var(--ms-bg) !important;
  --bs-body-color: var(--ms-text) !important;
  --bs-border-color: var(--ms-border) !important;
  --bs-card-bg: var(--ms-surface) !important;
  --bs-card-color: var(--ms-text) !important;
  --bs-modal-bg: var(--ms-surface) !important;
  --bs-modal-color: var(--ms-text) !important;
  --bs-tertiary-bg: var(--ms-surface-3) !important;
  --bs-secondary-bg: var(--ms-surface-2) !important;
  --bs-emphasis-color: #ffffff !important;
  --bs-table-bg: var(--ms-surface) !important;
  --bs-table-color: var(--ms-text) !important;
  --bs-table-border-color: var(--ms-border) !important;
  --bs-table-striped-bg: var(--ms-surface-2) !important;
  --bs-table-striped-color: var(--ms-text) !important;
  --bs-table-hover-bg: var(--ms-surface-3) !important;
  --bs-table-hover-color: #ffffff !important;
  --bs-table-accent-bg: transparent !important;
  --bs-table-bg-type: transparent !important;

  /* Mapeamento de variáveis legadas de style.css para herdar a paleta Dark */
  --bg-sidebar: var(--ms-surface) !important;
  --bg-body: var(--ms-bg) !important;
  --border: var(--ms-border) !important;
  --text-main: var(--ms-text) !important;
  --text-muted: var(--ms-text-muted) !important;
  --primary-light: rgba(59, 130, 246, 0.18) !important;
}

/* ----------------------------------------------------------------------------
   2. TRANSIÇÃO SUAVE ENTRE TEMAS
   ---------------------------------------------------------------------------- */
body,
aside,
.sidebar,
.card,
.stat-card,
.mini-card,
.ordem-card,
.ocorrencia-card,
.documento-card,
.item-card,
.view-card,
.table,
.custom-select-trigger,
.modal-content,
.filters-section {
  transition: background-color 180ms ease, color 180ms ease, border-color 180ms ease;
}

/* ----------------------------------------------------------------------------
   2.1 CONSUMO DE TOKENS PELO BODY (SEM REDECLARAR VARIÁVEIS NO BODY)
   ---------------------------------------------------------------------------- */
body {
  background-color: var(--ms-bg);
  color: var(--ms-text);
}

html[data-bs-theme="dark"] body,
html[data-theme="dark"] body {
  background-color: var(--ms-bg) !important;
  color: var(--ms-text) !important;
}

/* Proteção contra animação indesejada em mídias, gráficos, canvas e QR Codes */
img,
svg,
canvas,
iframe,
video,
.qr-code-container,
.qrcode-container {
  transition: none !important;
}

/* ----------------------------------------------------------------------------
   3. LAYOUT GERAL & ELEMENTOS ESTRUTURAIS
   ---------------------------------------------------------------------------- */
[data-bs-theme="dark"] body,
[data-theme="dark"] body {
  background-color: var(--manutsys-bg, #0b111d) !important;
  color: var(--manutsys-text, #f1f5f9) !important;
}

[data-bs-theme="dark"] main,
[data-theme="dark"] main,
[data-bs-theme="dark"] main.flex-grow-1,
[data-theme="dark"] main.flex-grow-1,
[data-bs-theme="dark"] .dashboard-main,
[data-theme="dark"] .dashboard-main,
[data-bs-theme="dark"] .locais-main,
[data-theme="dark"] .locais-main,
[data-bs-theme="dark"] .sublocais-main,
[data-theme="dark"] .sublocais-main,
[data-bs-theme="dark"] .equipamentos-main,
[data-theme="dark"] .equipamentos-main,
[data-bs-theme="dark"] .main-with-sidebar,
[data-theme="dark"] .main-with-sidebar,
[data-bs-theme="dark"] .content,
[data-theme="dark"] .content,
[data-bs-theme="dark"] .content-wrapper,
[data-theme="dark"] .content-wrapper,
[data-bs-theme="dark"] .main-content,
[data-theme="dark"] .main-content,
[data-bs-theme="dark"] .page-content,
[data-theme="dark"] .page-content,
[data-bs-theme="dark"] .container-fluid,
[data-theme="dark"] .container-fluid {
  background-color: var(--manutsys-bg, #0b111d) !important;
  color: var(--manutsys-text, #f1f5f9) !important;
}

[data-bs-theme="dark"] h1,
[data-theme="dark"] h1,
[data-bs-theme="dark"] h2,
[data-theme="dark"] h2,
[data-bs-theme="dark"] h3,
[data-theme="dark"] h3,
[data-bs-theme="dark"] h4,
[data-theme="dark"] h4,
[data-bs-theme="dark"] h5,
[data-theme="dark"] h5,
[data-bs-theme="dark"] h6,
[data-theme="dark"] h6 {
  color: #f8fafc !important;
}

[data-bs-theme="dark"] .text-dark,
[data-theme="dark"] .text-dark {
  color: #f1f5f9 !important;
}

[data-bs-theme="dark"] .text-muted,
[data-theme="dark"] .text-muted,
[data-bs-theme="dark"] .text-secondary,
[data-theme="dark"] .text-secondary {
  color: var(--manutsys-text-muted, #94a3b8) !important;
}

[data-bs-theme="dark"] .border,
[data-theme="dark"] .border,
[data-bs-theme="dark"] .border-top,
[data-theme="dark"] .border-top,
[data-bs-theme="dark"] .border-bottom,
[data-theme="dark"] .border-bottom,
[data-bs-theme="dark"] .border-start,
[data-theme="dark"] .border-start,
[data-bs-theme="dark"] .border-end,
[data-theme="dark"] .border-end {
  border-color: var(--manutsys-border, #283750) !important;
}

/* ----------------------------------------------------------------------------
   4. SIDEBAR / BARRA LATERAL
   ---------------------------------------------------------------------------- */
[data-bs-theme="dark"] .sidebar,
[data-theme="dark"] .sidebar,
[data-bs-theme="dark"] aside,
[data-theme="dark"] aside,
[data-bs-theme="dark"] aside.bg-white,
[data-theme="dark"] aside.bg-white,
[data-bs-theme="dark"] .sidebar aside,
[data-theme="dark"] .sidebar aside,
[data-bs-theme="dark"] #mainSidebar,
[data-theme="dark"] #mainSidebar,
[data-bs-theme="dark"] #mainSidebar aside,
[data-theme="dark"] #mainSidebar aside {
  background-color: var(--manutsys-sidebar-bg, #0d1524) !important;
  background: var(--manutsys-sidebar-bg, #0d1524) !important;
  border-right-color: var(--manutsys-sidebar-border, #1e2a3f) !important;
  color: var(--manutsys-text, #f1f5f9) !important;
}

[data-bs-theme="dark"] .sidebar .border-bottom,
[data-theme="dark"] .sidebar .border-bottom,
[data-bs-theme="dark"] .sidebar .border-top,
[data-theme="dark"] .sidebar .border-top,
[data-bs-theme="dark"] aside .border-bottom,
[data-theme="dark"] aside .border-bottom,
[data-bs-theme="dark"] aside .border-top,
[data-theme="dark"] aside .border-top {
  border-color: var(--manutsys-sidebar-border, #1e2a3f) !important;
}

[data-bs-theme="dark"] .sidebar a.nav-link,
[data-theme="dark"] .sidebar a.nav-link,
[data-bs-theme="dark"] aside a.nav-link,
[data-theme="dark"] aside a.nav-link,
[data-bs-theme="dark"] .sidebar .nav-link.text-dark,
[data-theme="dark"] .sidebar .nav-link.text-dark,
[data-bs-theme="dark"] aside .nav-link.text-dark,
[data-theme="dark"] aside .nav-link.text-dark {
  color: #cbd5e1 !important;
}

[data-bs-theme="dark"] .sidebar a.nav-link svg,
[data-theme="dark"] .sidebar a.nav-link svg,
[data-bs-theme="dark"] .sidebar a.nav-link i,
[data-theme="dark"] .sidebar a.nav-link i,
[data-bs-theme="dark"] aside a.nav-link svg,
[data-theme="dark"] aside a.nav-link svg,
[data-bs-theme="dark"] aside a.nav-link i,
[data-theme="dark"] aside a.nav-link i {
  color: inherit !important;
}

[data-bs-theme="dark"] .sidebar a.nav-link:hover,
[data-theme="dark"] .sidebar a.nav-link:hover,
[data-bs-theme="dark"] aside a.nav-link:hover,
[data-theme="dark"] aside a.nav-link:hover {
  background-color: var(--manutsys-sidebar-hover, #162033) !important;
  color: #ffffff !important;
}

[data-bs-theme="dark"] .sidebar a.nav-link.active_page,
[data-theme="dark"] .sidebar a.nav-link.active_page,
[data-bs-theme="dark"] .sidebar a.nav-link.active,
[data-theme="dark"] .sidebar a.nav-link.active,
[data-bs-theme="dark"] aside a.nav-link.active_page,
[data-theme="dark"] aside a.nav-link.active_page,
[data-bs-theme="dark"] aside a.nav-link.active,
[data-theme="dark"] aside a.nav-link.active,
[data-bs-theme="dark"] .active_page,
[data-theme="dark"] .active_page {
  background-color: var(--manutsys-sidebar-active, rgba(37, 99, 235, 0.25)) !important;
  background: var(--manutsys-sidebar-active, rgba(37, 99, 235, 0.25)) !important;
  color: var(--manutsys-sidebar-active-text, #60a5fa) !important;
  font-weight: 600 !important;
}

[data-bs-theme="dark"] .sidebar-collapse-btn,
[data-theme="dark"] .sidebar-collapse-btn {
  background-color: #162033 !important;
  border-color: #283750 !important;
  color: #94a3b8 !important;
}

[data-bs-theme="dark"] .sidebar-collapse-btn:hover,
[data-theme="dark"] .sidebar-collapse-btn:hover {
  background-color: #283750 !important;
  color: #ffffff !important;
}

[data-bs-theme="dark"] .btn-menu-mobile,
[data-theme="dark"] .btn-menu-mobile {
  background-color: #111a2b !important;
  border-color: #283750 !important;
  color: #f1f5f9 !important;
}

[data-bs-theme="dark"] .sidebar-user-text,
[data-theme="dark"] .sidebar-user-text {
  color: var(--manutsys-text, #f1f5f9) !important;
}

/* Painel de escopo, seletores e dropdowns da sidebar */
[data-bs-theme="dark"] .escopo-sidebar-panel,
[data-theme="dark"] .escopo-sidebar-panel {
  background: var(--manutsys-surface, #111a2b) !important;
  border-color: var(--manutsys-border, #283750) !important;
  color: var(--manutsys-text, #f1f5f9) !important;
}

[data-bs-theme="dark"] .escopo-sidebar-header,
[data-theme="dark"] .escopo-sidebar-header {
  border-bottom-color: var(--manutsys-border, #283750) !important;
}

[data-bs-theme="dark"] .escopo-sidebar-title,
[data-theme="dark"] .escopo-sidebar-title {
  color: var(--manutsys-text, #f1f5f9) !important;
}

[data-bs-theme="dark"] .escopo-sidebar-header small,
[data-theme="dark"] .escopo-sidebar-header small,
[data-bs-theme="dark"] .escopo-campo-label,
[data-theme="dark"] .escopo-campo-label {
  color: var(--manutsys-text-muted, #94a3b8) !important;
}

[data-bs-theme="dark"] .condominio-selector,
[data-theme="dark"] .condominio-selector {
  background: var(--manutsys-surface-elevated, #162033) !important;
  border-color: var(--manutsys-border, #283750) !important;
  color: var(--manutsys-text, #f1f5f9) !important;
}

[data-bs-theme="dark"] .condominio-selector:hover,
[data-theme="dark"] .condominio-selector:hover,
[data-bs-theme="dark"] .condominio-selector:focus-visible,
[data-theme="dark"] .condominio-selector:focus-visible,
[data-bs-theme="dark"] .condominio-selector.is-open,
[data-theme="dark"] .condominio-selector.is-open {
  background: var(--manutsys-surface-hover, #1b263a) !important;
  border-color: #6366f1 !important;
  color: #ffffff !important;
}

[data-bs-theme="dark"] .condominio-selector.is-all,
[data-theme="dark"] .condominio-selector.is-all {
  background: rgba(99, 102, 241, 0.12) !important;
  border-color: rgba(99, 102, 241, 0.35) !important;
}

[data-bs-theme="dark"] .condominio-selector .logo-container,
[data-theme="dark"] .condominio-selector .logo-container {
  background: #ffffff !important;
  border-color: var(--manutsys-border, #283750) !important;
}

[data-bs-theme="dark"] .condominio-selector .info .nome,
[data-theme="dark"] .condominio-selector .info .nome {
  color: var(--manutsys-text, #f1f5f9) !important;
}

[data-bs-theme="dark"] .condominio-selector .info .cliente,
[data-theme="dark"] .condominio-selector .info .cliente {
  color: var(--manutsys-text-muted, #94a3b8) !important;
}

[data-bs-theme="dark"] .condominio-selector .icone-seta,
[data-theme="dark"] .condominio-selector .icone-seta {
  background: var(--manutsys-surface-3, #1b263a) !important;
  color: var(--manutsys-text-secondary, #cbd5e1) !important;
}

[data-bs-theme="dark"] .condominio-dropdown-menu,
[data-theme="dark"] .condominio-dropdown-menu {
  background: var(--manutsys-surface, #111a2b) !important;
  border-color: var(--manutsys-border, #283750) !important;
  box-shadow: 0 -12px 35px rgba(0, 0, 0, 0.5) !important;
}

[data-bs-theme="dark"] .condominio-dropdown-header,
[data-theme="dark"] .condominio-dropdown-header {
  background: var(--manutsys-surface-elevated, #162033) !important;
  border-bottom-color: var(--manutsys-border, #283750) !important;
}

[data-bs-theme="dark"] .condominio-dropdown-header strong,
[data-theme="dark"] .condominio-dropdown-header strong {
  color: var(--manutsys-text, #f1f5f9) !important;
}

[data-bs-theme="dark"] .condominio-dropdown-item,
[data-theme="dark"] .condominio-dropdown-item {
  border-bottom-color: var(--manutsys-border, #283750) !important;
  color: var(--manutsys-text, #f1f5f9) !important;
}

[data-bs-theme="dark"] .condominio-dropdown-item:hover,
[data-theme="dark"] .condominio-dropdown-item:hover {
  background: var(--manutsys-surface-hover, #1b263a) !important;
}

[data-bs-theme="dark"] .condominio-dropdown-item.active,
[data-theme="dark"] .condominio-dropdown-item.active {
  background: rgba(37, 99, 235, 0.22) !important;
}

[data-bs-theme="dark"] .condominio-dropdown-item .mini-logo,
[data-theme="dark"] .condominio-dropdown-item .mini-logo {
  background: #ffffff !important;
  border-color: var(--manutsys-border, #283750) !important;
}

[data-bs-theme="dark"] .condominio-dropdown-item .item-info .nome,
[data-theme="dark"] .condominio-dropdown-item .item-info .nome {
  color: var(--manutsys-text, #f1f5f9) !important;
}

[data-bs-theme="dark"] .condominio-dropdown-item .item-info .cliente,
[data-theme="dark"] .condominio-dropdown-item .item-info .cliente {
  color: var(--manutsys-text-muted, #94a3b8) !important;
}

[data-bs-theme="dark"] .condominio-dropdown-item .item-tipo,
[data-theme="dark"] .condominio-dropdown-item .item-tipo {
  background: var(--manutsys-surface-elevated, #162033) !important;
  color: var(--manutsys-text-secondary, #cbd5e1) !important;
}

[data-bs-theme="dark"] .avatar-container,
[data-theme="dark"] .avatar-container {
  border-color: var(--manutsys-border, #283750) !important;
}

[data-bs-theme="dark"] .avatar-container.has-photo,
[data-theme="dark"] .avatar-container.has-photo {
  background-color: var(--manutsys-surface-elevated, #162033) !important;
}

[data-bs-theme="dark"] .avatar-container img,
[data-theme="dark"] .avatar-container img {
  background: var(--manutsys-surface-elevated, #162033) !important;
}


/* ----------------------------------------------------------------------------
   5. CABEÇALHO, FILTROS & AÇÕES
   ---------------------------------------------------------------------------- */
[data-bs-theme="dark"] .header-main,
[data-theme="dark"] .header-main {
  color: var(--manutsys-text, #f1f5f9) !important;
}

[data-bs-theme="dark"] .filters-section,
[data-theme="dark"] .filters-section,
[data-bs-theme="dark"] .filter-card,
[data-theme="dark"] .filter-card,
[data-bs-theme="dark"] .filter-container,
[data-theme="dark"] .filter-container,
[data-bs-theme="dark"] .filters-container,
[data-theme="dark"] .filters-container {
  background-color: var(--manutsys-surface, #111a2b) !important;
  background: var(--manutsys-surface, #111a2b) !important;
  border: 1px solid var(--manutsys-border, #283750) !important;
  box-shadow: var(--manutsys-shadow-sm) !important;
  color: var(--manutsys-text, #f1f5f9) !important;
}

[data-bs-theme="dark"] .filters-section .form-label,
[data-theme="dark"] .filters-section .form-label,
[data-bs-theme="dark"] .filter-card .form-label,
[data-theme="dark"] .filter-card .form-label,
[data-theme="dark"] .locais-scope-row .form-label,
[data-bs-theme="dark"] .locais-scope-row .form-label {
  color: var(--manutsys-text-secondary, #cbd5e1) !important;
}

[data-bs-theme="dark"] .btn-limpar-filtros,
[data-theme="dark"] .btn-limpar-filtros {
  background-color: var(--manutsys-surface-elevated, #162033) !important;
  border-color: var(--manutsys-border, #283750) !important;
  color: var(--manutsys-text-muted, #94a3b8) !important;
}

[data-bs-theme="dark"] .btn-limpar-filtros:hover,
[data-theme="dark"] .btn-limpar-filtros:hover {
  background-color: var(--manutsys-surface-hover, #1b263a) !important;
  border-color: #3b82f6 !important;
  color: #ffffff !important;
}

[data-bs-theme="dark"] .custom-select-wrapper.filtro-ativo .custom-select-trigger,
[data-theme="dark"] .custom-select-wrapper.filtro-ativo .custom-select-trigger {
  border-color: #3b82f6 !important;
  background-color: rgba(37, 99, 235, 0.18) !important;
}

/* ----------------------------------------------------------------------------
   6. CARDS, STAT-CARDS, VIEW-CARDS E CONTADORES
   ---------------------------------------------------------------------------- */
[data-bs-theme="dark"] .card,
[data-theme="dark"] .card,
[data-bs-theme="dark"] .card-body,
[data-theme="dark"] .card-body,
[data-bs-theme="dark"] .stat-card,
[data-theme="dark"] .stat-card,
[data-bs-theme="dark"] .mini-card,
[data-theme="dark"] .mini-card,
[data-bs-theme="dark"] .ordem-card,
[data-theme="dark"] .ordem-card,
[data-bs-theme="dark"] .ocorrencia-card,
[data-theme="dark"] .ocorrencia-card,
[data-bs-theme="dark"] .documento-card,
[data-theme="dark"] .documento-card,
[data-bs-theme="dark"] .item-card,
[data-theme="dark"] .item-card,
[data-bs-theme="dark"] .view-card,
[data-theme="dark"] .view-card,
[data-bs-theme="dark"] .counter-card:not(.primary):not(.warning):not(.success),
[data-theme="dark"] .counter-card:not(.primary):not(.warning):not(.success),
[data-bs-theme="dark"] .bg-white:not(.qr-preserve):not(.swal2-container *):not(.badge):not(.qr-code-container *),
[data-theme="dark"] .bg-white:not(.qr-preserve):not(.swal2-container *):not(.badge):not(.qr-code-container *) {
  background-color: var(--manutsys-surface, #111a2b) !important;
  background: var(--manutsys-surface, #111a2b) !important;
  border-color: var(--manutsys-border, #283750) !important;
  color: var(--manutsys-text, #f1f5f9) !important;
  box-shadow: var(--manutsys-shadow-sm) !important;
}

[data-bs-theme="dark"] .card-header,
[data-theme="dark"] .card-header,
[data-bs-theme="dark"] .card-footer,
[data-theme="dark"] .card-footer,
[data-bs-theme="dark"] .view-card-header,
[data-theme="dark"] .view-card-header,
[data-bs-theme="dark"] .view-card-footer,
[data-theme="dark"] .view-card-footer {
  background-color: var(--manutsys-surface-elevated, #162033) !important;
  border-color: var(--manutsys-border, #283750) !important;
  color: var(--manutsys-text, #f1f5f9) !important;
}

[data-bs-theme="dark"] .view-card-title,
[data-theme="dark"] .view-card-title {
  color: var(--manutsys-text, #f1f5f9) !important;
}

[data-bs-theme="dark"] .view-card-row,
[data-theme="dark"] .view-card-row {
  color: var(--manutsys-text-secondary, #cbd5e1) !important;
}

[data-bs-theme="dark"] .view-card-row i,
[data-theme="dark"] .view-card-row i {
  color: var(--manutsys-text-muted, #94a3b8) !important;
}

/* Indicador do condomínio no Dashboard */
[data-bs-theme="dark"] .condominio-indicator,
[data-theme="dark"] .condominio-indicator {
  background-color: rgba(37, 99, 235, 0.14) !important;
  border-color: rgba(59, 130, 246, 0.3) !important;
  color: #93c5fd !important;
}

[data-bs-theme="dark"] .periodo-info,
[data-theme="dark"] .periodo-info,
[data-bs-theme="dark"] .periodo-info p,
[data-theme="dark"] .periodo-info p {
  background: rgba(37, 99, 235, 0.14) !important;
  color: #93c5fd !important;
}

/* ----------------------------------------------------------------------------
   7. MÉTRICAS E VALORES NUMÉRICOS — ALTO CONTRASTE GARANTIDO
   Resolve o problema de números quase pretos em cards escuros (ex: Documentos)
   ---------------------------------------------------------------------------- */
[data-bs-theme="dark"] .stat-card .stat-number,
[data-theme="dark"] .stat-card .stat-number,
[data-bs-theme="dark"] .stat-number,
[data-theme="dark"] .stat-number,
[data-bs-theme="dark"] .stat-value,
[data-theme="dark"] .stat-value,
[data-bs-theme="dark"] .metric-value,
[data-theme="dark"] .metric-value,
[data-bs-theme="dark"] .card-value,
[data-theme="dark"] .card-value,
[data-bs-theme="dark"] .dashboard-value,
[data-theme="dark"] .dashboard-value,
[data-bs-theme="dark"] .counter-value,
[data-theme="dark"] .counter-value,
[data-bs-theme="dark"] .notificacoes-stat-value,
[data-theme="dark"] .notificacoes-stat-value,
[data-bs-theme="dark"] .stat-num,
[data-theme="dark"] .stat-num {
  color: #f1f5f9 !important;
  font-weight: 700;
}

[data-bs-theme="dark"] .stat-card .stat-title,
[data-theme="dark"] .stat-card .stat-title,
[data-bs-theme="dark"] .stat-title,
[data-theme="dark"] .stat-title,
[data-bs-theme="dark"] .counter-label,
[data-theme="dark"] .counter-label,
[data-bs-theme="dark"] .notificacoes-stat-label,
[data-theme="dark"] .notificacoes-stat-label {
  color: #94a3b8 !important;
}

/* ----------------------------------------------------------------------------
   8. TABELAS & DATATABLES
   Elimina qualquer tbody branco em modo escuro e neutraliza box-shadow do DataTables
   ---------------------------------------------------------------------------- */
[data-bs-theme="dark"] .table,
[data-theme="dark"] .table,
[data-bs-theme="dark"] table.dataTable,
[data-theme="dark"] table.dataTable {
  --bs-table-bg: var(--manutsys-surface, #111a2b) !important;
  --bs-table-color: var(--manutsys-text, #f1f5f9) !important;
  --bs-table-border-color: var(--manutsys-border, #283750) !important;
  --bs-table-striped-bg: #162033 !important;
  --bs-table-striped-color: var(--manutsys-text, #f1f5f9) !important;
  --bs-table-hover-bg: #1b263a !important;
  --bs-table-hover-color: #ffffff !important;
  --bs-table-accent-bg: transparent !important;
  --bs-table-bg-type: transparent !important;
  color: var(--manutsys-text, #f1f5f9) !important;
  border-color: var(--manutsys-border, #283750) !important;
  background-color: var(--manutsys-surface, #111a2b) !important;
}

/* Reset obrigatório de box-shadow inset do DataTables e Bootstrap */
[data-bs-theme="dark"] table.dataTable,
[data-theme="dark"] table.dataTable,
[data-bs-theme="dark"] table.dataTable tbody,
[data-theme="dark"] table.dataTable tbody,
[data-bs-theme="dark"] table.dataTable tbody tr,
[data-theme="dark"] table.dataTable tbody tr,
[data-bs-theme="dark"] table.dataTable tbody td,
[data-theme="dark"] table.dataTable tbody td,
[data-bs-theme="dark"] table.dataTable tbody th,
[data-theme="dark"] table.dataTable tbody th,
[data-bs-theme="dark"] table.dataTable.table-striped > tbody > tr > *,
[data-theme="dark"] table.dataTable.table-striped > tbody > tr > *,
[data-bs-theme="dark"] table.dataTable.table-striped > tbody > tr.odd > *,
[data-theme="dark"] table.dataTable.table-striped > tbody > tr.odd > *,
[data-bs-theme="dark"] table.dataTable.table-striped > tbody > tr.even > *,
[data-theme="dark"] table.dataTable.table-striped > tbody > tr.even > *,
[data-bs-theme="dark"] table.dataTable.table-hover > tbody > tr:hover > *,
[data-theme="dark"] table.dataTable.table-hover > tbody > tr:hover > * {
  box-shadow: none !important;
}

[data-bs-theme="dark"] .table > :not(caption) > * > *,
[data-theme="dark"] .table > :not(caption) > * > *,
[data-bs-theme="dark"] table.dataTable > :not(caption) > * > *,
[data-theme="dark"] table.dataTable > :not(caption) > * > * {
  background-color: var(--manutsys-surface, #111a2b) !important;
  color: var(--manutsys-text, #f1f5f9) !important;
  border-bottom-color: var(--manutsys-border, #283750) !important;
}

[data-bs-theme="dark"] .table-striped > tbody > tr:nth-of-type(odd) > *,
[data-theme="dark"] .table-striped > tbody > tr:nth-of-type(odd) > *,
[data-bs-theme="dark"] table.dataTable.table-striped > tbody > tr.odd > *,
[data-theme="dark"] table.dataTable.table-striped > tbody > tr.odd > *,
[data-bs-theme="dark"] table.dataTable.table-striped tbody tr:nth-of-type(odd) td,
[data-theme="dark"] table.dataTable.table-striped tbody tr:nth-of-type(odd) td {
  background-color: var(--manutsys-surface-elevated, #162033) !important;
  color: var(--manutsys-text, #f1f5f9) !important;
}

[data-bs-theme="dark"] .table-hover > tbody > tr:hover > *,
[data-theme="dark"] .table-hover > tbody > tr:hover > *,
[data-bs-theme="dark"] table.dataTable.table-hover > tbody > tr:hover > *,
[data-theme="dark"] table.dataTable.table-hover > tbody > tr:hover > *,
[data-bs-theme="dark"] table.dataTable.table-hover tbody tr:hover td,
[data-theme="dark"] table.dataTable.table-hover tbody tr:hover td {
  background-color: var(--manutsys-surface-hover, #1b263a) !important;
  color: #ffffff !important;
}

[data-bs-theme="dark"] .table thead,
[data-theme="dark"] .table thead,
[data-bs-theme="dark"] .table thead th,
[data-theme="dark"] .table thead th,
[data-bs-theme="dark"] .table-light,
[data-theme="dark"] .table-light,
[data-bs-theme="dark"] thead.table-light,
[data-theme="dark"] thead.table-light,
[data-bs-theme="dark"] thead.table-light th,
[data-theme="dark"] thead.table-light th,
[data-bs-theme="dark"] table.dataTable thead th,
[data-theme="dark"] table.dataTable thead th {
  --bs-table-bg: var(--manutsys-table-header, #101827) !important;
  --bs-table-color: #cbd5e1 !important;
  background-color: var(--manutsys-table-header, #101827) !important;
  background: var(--manutsys-table-header, #101827) !important;
  color: #94a3b8 !important;
  border-bottom: 1px solid var(--manutsys-border, #283750) !important;
  border-bottom-color: var(--manutsys-border, #283750) !important;
}

[data-bs-theme="dark"] .table tbody td,
[data-theme="dark"] .table tbody td,
[data-bs-theme="dark"] table.dataTable tbody td,
[data-theme="dark"] table.dataTable tbody td {
  color: #e2e8f0 !important;
  border-top-color: var(--manutsys-border, #283750) !important;
  border-bottom-color: var(--manutsys-border, #283750) !important;
}

[data-bs-theme="dark"] .table-container,
[data-theme="dark"] .table-container,
[data-bs-theme="dark"] .table-responsive,
[data-theme="dark"] .table-responsive {
  background-color: var(--manutsys-surface, #111a2b) !important;
  border-color: var(--manutsys-border, #283750) !important;
}

/* DataTables Controls */
[data-bs-theme="dark"] .dataTables_wrapper,
[data-theme="dark"] .dataTables_wrapper {
  color: var(--manutsys-text, #f1f5f9) !important;
}

[data-bs-theme="dark"] .dataTables_info,
[data-theme="dark"] .dataTables_info,
[data-bs-theme="dark"] .dataTables_length label,
[data-theme="dark"] .dataTables_length label {
  color: var(--manutsys-text-muted, #94a3b8) !important;
}

[data-bs-theme="dark"] .dataTables_filter input,
[data-theme="dark"] .dataTables_filter input {
  background-color: var(--manutsys-input-bg, #121c2e) !important;
  border: 1px solid var(--manutsys-input-border, #283750) !important;
  color: var(--manutsys-input-color, #f1f5f9) !important;
}

[data-bs-theme="dark"] .dataTables_paginate .paginate_button,
[data-theme="dark"] .dataTables_paginate .paginate_button {
  background: transparent !important;
  color: var(--manutsys-text, #f1f5f9) !important;
  border: 1px solid var(--manutsys-border, #283750) !important;
}

[data-bs-theme="dark"] .dataTables_paginate .paginate_button.current,
[data-theme="dark"] .dataTables_paginate .paginate_button.current,
[data-bs-theme="dark"] .dataTables_paginate .paginate_button.current:hover,
[data-theme="dark"] .dataTables_paginate .paginate_button.current:hover {
  background: var(--manutsys-primary, #2563eb) !important;
  color: #ffffff !important;
  border-color: var(--manutsys-primary, #2563eb) !important;
}

[data-bs-theme="dark"] .dataTables_paginate .paginate_button:hover:not(.current):not(.disabled),
[data-theme="dark"] .dataTables_paginate .paginate_button:hover:not(.current):not(.disabled) {
  background: var(--manutsys-surface-hover, #1b263a) !important;
  color: #ffffff !important;
}

[data-bs-theme="dark"] .dataTables_paginate .paginate_button.disabled,
[data-theme="dark"] .dataTables_paginate .paginate_button.disabled {
  color: var(--manutsys-text-dim, #64748b) !important;
  border-color: transparent !important;
}

/* ----------------------------------------------------------------------------
   9. TABS & ABAS DE NAVEGAÇÃO
   ---------------------------------------------------------------------------- */
[data-bs-theme="dark"] .custom-tabs,
[data-theme="dark"] .custom-tabs {
  border-bottom-color: var(--manutsys-border, #283750) !important;
}

[data-bs-theme="dark"] .custom-tab,
[data-theme="dark"] .custom-tab,
[data-bs-theme="dark"] .custom-tabs a.custom-tab,
[data-theme="dark"] .custom-tabs a.custom-tab,
[data-bs-theme="dark"] .custom-tabs button.custom-tab,
[data-theme="dark"] .custom-tabs button.custom-tab {
  background-color: var(--manutsys-surface, #111a2b) !important;
  background: var(--manutsys-surface, #111a2b) !important;
  color: var(--manutsys-text-secondary, #cbd5e1) !important;
  border: 1px solid var(--manutsys-border, #283750) !important;
}

[data-bs-theme="dark"] .custom-tab:hover,
[data-theme="dark"] .custom-tab:hover,
[data-bs-theme="dark"] .custom-tabs a.custom-tab:hover,
[data-theme="dark"] .custom-tabs a.custom-tab:hover,
[data-bs-theme="dark"] .custom-tabs button.custom-tab:hover,
[data-theme="dark"] .custom-tabs button.custom-tab:hover {
  background-color: var(--manutsys-surface-hover, #1b263a) !important;
  background: var(--manutsys-surface-hover, #1b263a) !important;
  color: #ffffff !important;
  border-color: #3b82f6 !important;
}

[data-bs-theme="dark"] .custom-tab.active,
[data-theme="dark"] .custom-tab.active,
[data-bs-theme="dark"] .custom-tabs a.custom-tab.active,
[data-theme="dark"] .custom-tabs a.custom-tab.active,
[data-bs-theme="dark"] .custom-tabs button.custom-tab.active,
[data-theme="dark"] .custom-tabs button.custom-tab.active {
  background-color: var(--manutsys-primary, #2563eb) !important;
  background: var(--manutsys-primary, #2563eb) !important;
  color: #ffffff !important;
  border-color: var(--manutsys-primary, #2563eb) !important;
}

[data-bs-theme="dark"] .nav-tabs,
[data-theme="dark"] .nav-tabs {
  border-bottom-color: var(--manutsys-border, #283750) !important;
}

[data-bs-theme="dark"] .nav-tabs .nav-link,
[data-theme="dark"] .nav-tabs .nav-link {
  color: var(--manutsys-text-muted, #94a3b8) !important;
}

[data-bs-theme="dark"] .nav-tabs .nav-link.active,
[data-theme="dark"] .nav-tabs .nav-link.active {
  color: #60a5fa !important;
  background-color: var(--manutsys-surface, #111a2b) !important;
  border-color: var(--manutsys-border, #283750) var(--manutsys-border, #283750) var(--manutsys-surface, #111a2b) !important;
}

[data-bs-theme="dark"] .tab-filter-btn,
[data-theme="dark"] .tab-filter-btn {
  background: var(--manutsys-surface, #111a2b) !important;
  border: 1px solid var(--manutsys-border, #283750) !important;
  color: var(--manutsys-text-secondary, #cbd5e1) !important;
}

[data-bs-theme="dark"] .tab-filter-btn.active,
[data-theme="dark"] .tab-filter-btn.active {
  background: var(--manutsys-primary, #2563eb) !important;
  color: #ffffff !important;
  border-color: var(--manutsys-primary, #2563eb) !important;
}

/* ----------------------------------------------------------------------------
   10. MATRIZ DE PERMISSÕES (permissoes.php)
   Corrige containers brancos e textos quase invisíveis
   ---------------------------------------------------------------------------- */
[data-bs-theme="dark"] .perm-section,
[data-theme="dark"] .perm-section {
  background-color: var(--manutsys-surface, #111a2b) !important;
  background: var(--manutsys-surface, #111a2b) !important;
  border: 1px solid var(--manutsys-border, #283750) !important;
  box-shadow: var(--manutsys-shadow-sm) !important;
  color: var(--manutsys-text, #f1f5f9) !important;
}

[data-bs-theme="dark"] .perm-section .perm-title,
[data-theme="dark"] .perm-section .perm-title,
[data-bs-theme="dark"] .perm-title,
[data-theme="dark"] .perm-title {
  color: #f1f5f9 !important;
}

[data-bs-theme="dark"] .perm-item,
[data-theme="dark"] .perm-item {
  color: var(--manutsys-text, #f1f5f9) !important;
}

[data-bs-theme="dark"] .perm-item:hover,
[data-theme="dark"] .perm-item:hover {
  background-color: var(--manutsys-surface-hover, #1b263a) !important;
}

[data-bs-theme="dark"] .tab-perfil .perfil-btn,
[data-theme="dark"] .tab-perfil .perfil-btn {
  background: var(--manutsys-surface, #111a2b) !important;
  border-color: var(--manutsys-border, #283750) !important;
  color: var(--manutsys-text, #f1f5f9) !important;
}

[data-bs-theme="dark"] .tab-perfil .perfil-btn:hover,
[data-theme="dark"] .tab-perfil .perfil-btn:hover {
  border-color: #3b82f6 !important;
  background: var(--manutsys-surface-hover, #1b263a) !important;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.3) !important;
}

[data-bs-theme="dark"] .tab-perfil .perfil-btn.active,
[data-theme="dark"] .tab-perfil .perfil-btn.active {
  background: #2563eb !important;
  color: #ffffff !important;
  border-color: #2563eb !important;
}

[data-bs-theme="dark"] .perfil-btn-origem,
[data-theme="dark"] .perfil-btn-origem,
[data-bs-theme="dark"] .perfil-origem-detalhe,
[data-theme="dark"] .perfil-origem-detalhe {
  color: var(--manutsys-text-muted, #94a3b8) !important;
}

[data-bs-theme="dark"] .perfil-origem-detalhe span,
[data-theme="dark"] .perfil-origem-detalhe span {
  background: var(--manutsys-surface-elevated, #162033) !important;
  border-color: var(--manutsys-border, #283750) !important;
  color: var(--manutsys-text-secondary, #cbd5e1) !important;
}

[data-bs-theme="dark"] .perfil-label,
[data-theme="dark"] .perfil-label {
  background: rgba(139, 92, 246, 0.22) !important;
  color: #c4b5fd !important;
}

[data-bs-theme="dark"] #perfilDescricaoAtual,
[data-theme="dark"] #perfilDescricaoAtual,
[data-bs-theme="dark"] #perfilDescricaoAtual[readonly],
[data-theme="dark"] #perfilDescricaoAtual[readonly] {
  background-color: var(--manutsys-input-bg, #121c2e) !important;
  border-color: var(--manutsys-border, #283750) !important;
  color: var(--manutsys-text, #f1f5f9) !important;
}

[data-bs-theme="dark"] .permissoes-save-bar,
[data-theme="dark"] .permissoes-save-bar {
  background: rgba(17, 26, 43, 0.95) !important;
  border-color: var(--manutsys-border, #283750) !important;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.5) !important;
}

/* Switches de Permissão */
[data-bs-theme="dark"] .switch .slider,
[data-theme="dark"] .switch .slider {
  background-color: #283750 !important;
}

[data-bs-theme="dark"] .switch input:checked + .slider,
[data-theme="dark"] .switch input:checked + .slider {
  background-color: #2563eb !important;
}

/* ----------------------------------------------------------------------------
   11. FORMULÁRIOS & CUSTOM SELECTS
   ---------------------------------------------------------------------------- */
[data-bs-theme="dark"] .form-label,
[data-theme="dark"] .form-label {
  color: #cbd5e1 !important;
}

[data-bs-theme="dark"] .form-control,
[data-theme="dark"] .form-control,
[data-bs-theme="dark"] .form-select,
[data-theme="dark"] .form-select {
  background-color: var(--manutsys-input-bg, #121c2e) !important;
  border-color: var(--manutsys-input-border, #283750) !important;
  color: var(--manutsys-input-color, #f1f5f9) !important;
}

[data-bs-theme="dark"] .form-control:focus,
[data-theme="dark"] .form-control:focus,
[data-bs-theme="dark"] .form-select:focus,
[data-theme="dark"] .form-select:focus {
  background-color: #172338 !important;
  border-color: var(--manutsys-border-focus, #3b82f6) !important;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.25) !important;
  color: #ffffff !important;
}

[data-bs-theme="dark"] .form-control:disabled,
[data-theme="dark"] .form-control:disabled,
[data-bs-theme="dark"] .form-control[readonly]:not(#perfilDescricaoAtual),
[data-theme="dark"] .form-control[readonly]:not(#perfilDescricaoAtual) {
  background-color: #0b111d !important;
  color: var(--manutsys-text-dim, #64748b) !important;
  border-color: var(--manutsys-border-subtle, #1e2a3f) !important;
}

[data-bs-theme="dark"] .input-group-text,
[data-theme="dark"] .input-group-text {
  background-color: var(--manutsys-surface-elevated, #162033) !important;
  border-color: var(--manutsys-border, #283750) !important;
  color: var(--manutsys-text-muted, #94a3b8) !important;
}

/* Custom Selects ManutSys */
[data-bs-theme="dark"] .custom-select-trigger,
[data-theme="dark"] .custom-select-trigger {
  background-color: var(--manutsys-input-bg, #121c2e) !important;
  border-color: var(--manutsys-input-border, #283750) !important;
  color: var(--manutsys-input-color, #f1f5f9) !important;
}

[data-bs-theme="dark"] .custom-select-trigger:hover,
[data-theme="dark"] .custom-select-trigger:hover,
[data-bs-theme="dark"] .custom-select-trigger.active,
[data-theme="dark"] .custom-select-trigger.active {
  border-color: var(--manutsys-border-focus, #3b82f6) !important;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2) !important;
}

[data-bs-theme="dark"] .custom-select-dropdown,
[data-theme="dark"] .custom-select-dropdown {
  background-color: var(--manutsys-surface, #111a2b) !important;
  border-color: var(--manutsys-border, #283750) !important;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.6) !important;
}

[data-bs-theme="dark"] .custom-select-search,
[data-theme="dark"] .custom-select-search {
  background-color: var(--manutsys-bg-alt, #162033) !important;
  border-bottom-color: var(--manutsys-border, #283750) !important;
}

[data-bs-theme="dark"] .custom-select-search input,
[data-theme="dark"] .custom-select-search input {
  background-color: var(--manutsys-input-bg, #121c2e) !important;
  border-color: var(--manutsys-input-border, #283750) !important;
  color: var(--manutsys-input-color, #f1f5f9) !important;
}

[data-bs-theme="dark"] .custom-select-options,
[data-theme="dark"] .custom-select-options {
  background-color: var(--manutsys-surface, #111a2b) !important;
}

[data-bs-theme="dark"] .custom-select-option,
[data-theme="dark"] .custom-select-option {
  background-color: var(--manutsys-surface, #111a2b) !important;
  color: var(--manutsys-text, #f1f5f9) !important;
}

[data-bs-theme="dark"] .custom-select-option:hover,
[data-theme="dark"] .custom-select-option:hover {
  background-color: var(--manutsys-surface-hover, #1b263a) !important;
  color: #ffffff !important;
  border-left-color: var(--manutsys-primary, #2563eb) !important;
}

[data-bs-theme="dark"] .custom-select-option.selected,
[data-theme="dark"] .custom-select-option.selected {
  background-color: var(--manutsys-primary-bg, rgba(59, 130, 246, 0.16)) !important;
  color: #93c5fd !important;
  border-left-color: var(--manutsys-primary, #2563eb) !important;
}

/* Select2 */
[data-bs-theme="dark"] .select2-container--bootstrap-5 .select2-selection,
[data-theme="dark"] .select2-container--bootstrap-5 .select2-selection,
[data-bs-theme="dark"] .select2-container .select2-selection,
[data-theme="dark"] .select2-container .select2-selection {
  background-color: var(--manutsys-input-bg, #121c2e) !important;
  border-color: var(--manutsys-input-border, #283750) !important;
  color: var(--manutsys-input-color, #f1f5f9) !important;
}

[data-bs-theme="dark"] .select2-dropdown,
[data-theme="dark"] .select2-dropdown {
  background-color: var(--manutsys-surface, #111a2b) !important;
  border-color: var(--manutsys-border, #283750) !important;
  color: var(--manutsys-text, #f1f5f9) !important;
}

[data-bs-theme="dark"] .select2-results__option,
[data-theme="dark"] .select2-results__option {
  color: var(--manutsys-text, #f1f5f9) !important;
}

[data-bs-theme="dark"] .select2-results__option--highlighted,
[data-theme="dark"] .select2-results__option--highlighted {
  background-color: var(--manutsys-surface-hover, #1b263a) !important;
  color: #ffffff !important;
}

[data-bs-theme="dark"] .select2-search__field,
[data-theme="dark"] .select2-search__field {
  background-color: var(--manutsys-input-bg, #121c2e) !important;
  border-color: var(--manutsys-input-border, #283750) !important;
  color: var(--manutsys-input-color, #f1f5f9) !important;
}

[data-bs-theme="dark"] .select2-container--bootstrap-5 .select2-selection--multiple .select2-selection__choice,
[data-theme="dark"] .select2-container--bootstrap-5 .select2-selection--multiple .select2-selection__choice,
[data-bs-theme="dark"] .select2-selection__choice,
[data-theme="dark"] .select2-selection__choice {
  background-color: var(--manutsys-surface-hover, #1b263a) !important;
  border: 1px solid var(--manutsys-border, #283750) !important;
  color: var(--manutsys-text, #f1f5f9) !important;
  border-radius: 0.375rem !important;
}

[data-bs-theme="dark"] .select2-selection__choice__remove,
[data-theme="dark"] .select2-selection__choice__remove {
  color: var(--manutsys-text-muted, #94a3b8) !important;
}

[data-bs-theme="dark"] .select2-selection__choice__remove:hover,
[data-theme="dark"] .select2-selection__choice__remove:hover {
  color: #ef4444 !important;
}

/* ----------------------------------------------------------------------------
   12. MODAIS (Preservando z-index e FocusTrap)
   ---------------------------------------------------------------------------- */
[data-bs-theme="dark"] .modal-content,
[data-theme="dark"] .modal-content {
  background-color: var(--manutsys-surface, #111a2b) !important;
  background: var(--manutsys-surface, #111a2b) !important;
  border: 1px solid var(--manutsys-border, #283750) !important;
  color: var(--manutsys-text, #f1f5f9) !important;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.6) !important;
}

[data-bs-theme="dark"] .modal-header,
[data-theme="dark"] .modal-header {
  background-color: var(--manutsys-surface-elevated, #162033) !important;
  background: var(--manutsys-surface-elevated, #162033) !important;
  border-bottom: 1px solid var(--manutsys-border, #283750) !important;
  color: var(--manutsys-text, #f1f5f9) !important;
}

[data-bs-theme="dark"] .modal-title,
[data-theme="dark"] .modal-title {
  color: #ffffff !important;
}

[data-bs-theme="dark"] .modal-body,
[data-theme="dark"] .modal-body {
  background-color: var(--manutsys-surface, #111a2b) !important;
  background: var(--manutsys-surface, #111a2b) !important;
  color: var(--manutsys-text, #f1f5f9) !important;
}

[data-bs-theme="dark"] .modal-footer,
[data-theme="dark"] .modal-footer {
  background-color: var(--manutsys-surface-elevated, #162033) !important;
  background: var(--manutsys-surface-elevated, #162033) !important;
  border-top: 1px solid var(--manutsys-border, #283750) !important;
  color: var(--manutsys-text, #f1f5f9) !important;
}

[data-bs-theme="dark"] .btn-close,
[data-theme="dark"] .btn-close {
  filter: invert(1) grayscale(100%) brightness(200%) !important;
}

/* ----------------------------------------------------------------------------
   13. SWEETALERT2
   ---------------------------------------------------------------------------- */
[data-bs-theme="dark"] .swal2-popup,
[data-theme="dark"] .swal2-popup {
  background: var(--manutsys-surface, #111a2b) !important;
  color: var(--manutsys-text, #f1f5f9) !important;
  border: 1px solid var(--manutsys-border, #283750) !important;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6) !important;
}

[data-bs-theme="dark"] .swal2-title,
[data-theme="dark"] .swal2-title {
  color: #f1f5f9 !important;
}

[data-bs-theme="dark"] .swal2-html-container,
[data-theme="dark"] .swal2-html-container {
  color: var(--manutsys-text, #f1f5f9) !important;
}

[data-bs-theme="dark"] .swal2-close,
[data-theme="dark"] .swal2-close {
  color: var(--manutsys-text-muted, #94a3b8) !important;
}

/* ----------------------------------------------------------------------------
   14. BOTÕES SECUNDÁRIOS & VIEW TOGGLE
   ---------------------------------------------------------------------------- */
[data-bs-theme="dark"] .btn-outline-secondary,
[data-theme="dark"] .btn-outline-secondary {
  border-color: var(--manutsys-border, #283750) !important;
  color: #cbd5e1 !important;
  background-color: transparent !important;
}

[data-bs-theme="dark"] .btn-outline-secondary:hover,
[data-theme="dark"] .btn-outline-secondary:hover {
  background-color: var(--manutsys-surface-hover, #1b263a) !important;
  border-color: #475569 !important;
  color: #ffffff !important;
}

[data-bs-theme="dark"] .btn-filter,
[data-theme="dark"] .btn-filter {
  background-color: var(--manutsys-surface-elevated, #162033) !important;
  color: #cbd5e1 !important;
}

[data-bs-theme="dark"] .btn-filter:hover,
[data-theme="dark"] .btn-filter:hover {
  background-color: var(--manutsys-surface-hover, #1b263a) !important;
  color: #ffffff !important;
}

[data-bs-theme="dark"] .view-toggle-group .view-toggle-btn,
[data-theme="dark"] .view-toggle-group .view-toggle-btn {
  background-color: var(--manutsys-surface, #111a2b) !important;
  border-color: var(--manutsys-border, #283750) !important;
  color: var(--manutsys-text-muted, #94a3b8) !important;
}

[data-bs-theme="dark"] .view-toggle-group .view-toggle-btn.active,
[data-theme="dark"] .view-toggle-group .view-toggle-btn.active {
  background-color: var(--manutsys-primary, #2563eb) !important;
  color: #ffffff !important;
  border-color: var(--manutsys-primary, #2563eb) !important;
}

/* Botões Light nativos do Bootstrap no Dark Mode (ex: Permissões) */
[data-bs-theme="dark"] .btn-light,
[data-theme="dark"] .btn-light {
  background-color: var(--manutsys-surface-elevated, #162033) !important;
  border-color: var(--manutsys-border, #283750) !important;
  color: var(--manutsys-text, #f1f5f9) !important;
}

[data-bs-theme="dark"] .btn-light:hover,
[data-theme="dark"] .btn-light:hover {
  background-color: var(--manutsys-surface-hover, #1b263a) !important;
  border-color: #475569 !important;
  color: #ffffff !important;
}

/* Dropdowns Nativos Bootstrap */
[data-bs-theme="dark"] .dropdown-menu,
[data-theme="dark"] .dropdown-menu {
  background-color: var(--manutsys-surface, #111a2b) !important;
  border: 1px solid var(--manutsys-border, #283750) !important;
  color: var(--manutsys-text, #f1f5f9) !important;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45) !important;
}

[data-bs-theme="dark"] .dropdown-item,
[data-theme="dark"] .dropdown-item {
  color: var(--manutsys-text, #f1f5f9) !important;
}

[data-bs-theme="dark"] .dropdown-item:hover,
[data-theme="dark"] .dropdown-item:hover,
[data-bs-theme="dark"] .dropdown-item:focus,
[data-theme="dark"] .dropdown-item:focus {
  background-color: var(--manutsys-surface-hover, #1b263a) !important;
  color: #ffffff !important;
}

[data-bs-theme="dark"] .dropdown-item.active,
[data-theme="dark"] .dropdown-item.active {
  background-color: var(--manutsys-primary, #2563eb) !important;
  color: #ffffff !important;
}

[data-bs-theme="dark"] .dropdown-divider,
[data-theme="dark"] .dropdown-divider {
  border-top-color: var(--manutsys-border, #283750) !important;
}

/* Paginação Nativa Bootstrap */
[data-bs-theme="dark"] .pagination .page-item .page-link,
[data-theme="dark"] .pagination .page-item .page-link {
  background-color: var(--manutsys-surface, #111a2b) !important;
  border-color: var(--manutsys-border, #283750) !important;
  color: var(--manutsys-text, #f1f5f9) !important;
}

[data-bs-theme="dark"] .pagination .page-item:hover .page-link,
[data-theme="dark"] .pagination .page-item:hover .page-link {
  background-color: var(--manutsys-surface-hover, #1b263a) !important;
  border-color: #3b82f6 !important;
  color: #ffffff !important;
}

[data-bs-theme="dark"] .pagination .page-item.active .page-link,
[data-theme="dark"] .pagination .page-item.active .page-link {
  background-color: var(--manutsys-primary, #2563eb) !important;
  border-color: var(--manutsys-primary, #2563eb) !important;
  color: #ffffff !important;
}

[data-bs-theme="dark"] .pagination .page-item.disabled .page-link,
[data-theme="dark"] .pagination .page-item.disabled .page-link {
  background-color: var(--manutsys-surface-elevated, #162033) !important;
  border-color: var(--manutsys-border, #283750) !important;
  color: var(--manutsys-text-dim, #64748b) !important;
}

/* Accordion Nativo Bootstrap */
[data-bs-theme="dark"] .accordion,
[data-theme="dark"] .accordion,
[data-bs-theme="dark"] .accordion-item,
[data-theme="dark"] .accordion-item {
  background-color: var(--manutsys-surface, #111a2b) !important;
  border-color: var(--manutsys-border, #283750) !important;
  color: var(--manutsys-text, #f1f5f9) !important;
}

[data-bs-theme="dark"] .accordion-button,
[data-theme="dark"] .accordion-button {
  background-color: var(--manutsys-surface-elevated, #162033) !important;
  border-color: var(--manutsys-border, #283750) !important;
  color: var(--manutsys-text, #f1f5f9) !important;
}

[data-bs-theme="dark"] .accordion-button:not(.collapsed),
[data-theme="dark"] .accordion-button:not(.collapsed) {
  background-color: var(--manutsys-surface-hover, #1b263a) !important;
  color: #60a5fa !important;
  box-shadow: none !important;
}

[data-bs-theme="dark"] .accordion-body,
[data-theme="dark"] .accordion-body {
  background-color: var(--manutsys-surface, #111a2b) !important;
  color: var(--manutsys-text, #f1f5f9) !important;
}

/* List Group Nativo Bootstrap */
[data-bs-theme="dark"] .list-group-item,
[data-theme="dark"] .list-group-item {
  background-color: var(--manutsys-surface, #111a2b) !important;
  border-color: var(--manutsys-border, #283750) !important;
  color: var(--manutsys-text, #f1f5f9) !important;
}

[data-bs-theme="dark"] .list-group-item:hover,
[data-theme="dark"] .list-group-item:hover {
  background-color: var(--manutsys-surface-hover, #1b263a) !important;
  color: #ffffff !important;
}

[data-bs-theme="dark"] .list-group-item.active,
[data-theme="dark"] .list-group-item.active {
  background-color: var(--manutsys-primary, #2563eb) !important;
  border-color: var(--manutsys-primary, #2563eb) !important;
  color: #ffffff !important;
}


/* ----------------------------------------------------------------------------
   15. CARDS DE INDICADORES DO DASHBOARD (PRESERVAÇÃO SEMÂNTICA)
   Tempo Médio Aprovação -> Verde, Execução -> Roxo, Total -> Azul
   ---------------------------------------------------------------------------- */
.bg-green,
[data-bs-theme="dark"] .bg-green,
[data-theme="dark"] .bg-green {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%) !important;
  color: #ffffff !important;
}

.bg-purple,
[data-bs-theme="dark"] .bg-purple,
[data-theme="dark"] .bg-purple {
  background: linear-gradient(135deg, #8b5cf6 0%, #6d28d9 100%) !important;
  color: #ffffff !important;
}

.bg-blue,
[data-bs-theme="dark"] .bg-blue,
[data-theme="dark"] .bg-blue {
  background: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%) !important;
  color: #ffffff !important;
}

.bg-indigo,
[data-bs-theme="dark"] .bg-indigo,
[data-theme="dark"] .bg-indigo {
  background: linear-gradient(135deg, #6366f1 0%, #4f46e5 100%) !important;
  color: #ffffff !important;
}

.bg-orange,
[data-bs-theme="dark"] .bg-orange,
[data-theme="dark"] .bg-orange {
  background: linear-gradient(135deg, #f97316 0%, #ea580c 100%) !important;
  color: #ffffff !important;
}

/* ----------------------------------------------------------------------------
   16. MÓDULO: NOTIFICAÇÕES (notificacoes.php)
   ---------------------------------------------------------------------------- */
[data-bs-theme="dark"] .notificacoes-stat-card,
[data-theme="dark"] .notificacoes-stat-card {
  background: var(--manutsys-surface, #111a2b) !important;
  border-color: var(--manutsys-border, #283750) !important;
}

[data-bs-theme="dark"] .notification-card,
[data-theme="dark"] .notification-card {
  background: var(--manutsys-surface, #111a2b) !important;
  border-color: var(--manutsys-border, #283750) !important;
  border-left: 4px solid #334155 !important;
}

[data-bs-theme="dark"] .notification-card:hover,
[data-theme="dark"] .notification-card:hover {
  border-color: #475569 !important;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.4) !important;
}

[data-bs-theme="dark"] .notification-card.unread,
[data-theme="dark"] .notification-card.unread {
  background: #172338 !important;
  border-left-color: #3b82f6 !important;
}

[data-bs-theme="dark"] .notification-title,
[data-theme="dark"] .notification-title {
  color: var(--manutsys-text, #f1f5f9) !important;
}

[data-bs-theme="dark"] .notification-description,
[data-theme="dark"] .notification-description {
  color: var(--manutsys-text-muted, #94a3b8) !important;
}

[data-bs-theme="dark"] .notification-module,
[data-theme="dark"] .notification-module {
  background: #1e293b !important;
  color: #94a3b8 !important;
}

/* ----------------------------------------------------------------------------
   17. MÓDULO: ORDENS DE SERVIÇO (ordens_servicos.php)
   ---------------------------------------------------------------------------- */
[data-bs-theme="dark"] .os-journey-wrapper,
[data-theme="dark"] .os-journey-wrapper {
  background: var(--manutsys-surface, #111a2b) !important;
  border-color: var(--manutsys-border, #283750) !important;
}

[data-bs-theme="dark"] .os-journey-title,
[data-theme="dark"] .os-journey-title {
  color: var(--manutsys-text, #f1f5f9) !important;
}

[data-bs-theme="dark"] .os-journey-hint,
[data-theme="dark"] .os-journey-hint {
  background: var(--manutsys-surface-elevated, #162033) !important;
  border-color: var(--manutsys-border, #283750) !important;
  color: var(--manutsys-text-muted, #94a3b8) !important;
}

[data-bs-theme="dark"] .os-journey-line,
[data-theme="dark"] .os-journey-line {
  background: #24334d !important;
}

[data-bs-theme="dark"] .os-filter-bar,
[data-theme="dark"] .os-filter-bar {
  background: var(--manutsys-surface, #111a2b) !important;
  border-color: var(--manutsys-border, #283750) !important;
}

[data-bs-theme="dark"] .os-prio-label,
[data-theme="dark"] .os-prio-label {
  color: var(--manutsys-text-muted, #94a3b8) !important;
}

/* Priority Chips */
[data-bs-theme="dark"] .os-prio-chip.prio-baixa,
[data-theme="dark"] .os-prio-chip.prio-baixa {
  background: rgba(16, 185, 129, 0.15) !important;
  color: #34d399 !important;
  border-color: rgba(16, 185, 129, 0.3) !important;
}

[data-bs-theme="dark"] .os-prio-chip.prio-baixa.active,
[data-theme="dark"] .os-prio-chip.prio-baixa.active {
  background: #10b981 !important;
  color: #ffffff !important;
  border-color: #059669 !important;
}

[data-bs-theme="dark"] .os-prio-chip.prio-media,
[data-theme="dark"] .os-prio-chip.prio-media {
  background: rgba(59, 130, 246, 0.15) !important;
  color: #60a5fa !important;
  border-color: rgba(59, 130, 246, 0.3) !important;
}

[data-bs-theme="dark"] .os-prio-chip.prio-media.active,
[data-theme="dark"] .os-prio-chip.prio-media.active {
  background: #2563eb !important;
  color: #ffffff !important;
  border-color: #1d4ed8 !important;
}

[data-bs-theme="dark"] .os-prio-chip.prio-alta,
[data-theme="dark"] .os-prio-chip.prio-alta {
  background: rgba(245, 158, 11, 0.15) !important;
  color: #fbbf24 !important;
  border-color: rgba(245, 158, 11, 0.3) !important;
}

[data-bs-theme="dark"] .os-prio-chip.prio-alta.active,
[data-theme="dark"] .os-prio-chip.prio-alta.active {
  background: #f59e0b !important;
  color: #ffffff !important;
  border-color: #d97706 !important;
}

[data-bs-theme="dark"] .os-prio-chip.prio-urgente,
[data-theme="dark"] .os-prio-chip.prio-urgente {
  background: rgba(239, 68, 68, 0.15) !important;
  color: #f87171 !important;
  border-color: rgba(239, 68, 68, 0.3) !important;
}

[data-bs-theme="dark"] .os-prio-chip.prio-urgente.active,
[data-theme="dark"] .os-prio-chip.prio-urgente.active {
  background: #ef4444 !important;
  color: #ffffff !important;
  border-color: #dc2626 !important;
}

/* Stepper circles */
[data-bs-theme="dark"] .os-step-circle,
[data-theme="dark"] .os-step-circle {
  background: #141d2f !important;
  border-color: #24334d !important;
  color: #94a3b8 !important;
}

[data-bs-theme="dark"] .os-step-label,
[data-theme="dark"] .os-step-label {
  color: #94a3b8 !important;
}

[data-bs-theme="dark"] .os-step-btn.active .os-step-label,
[data-theme="dark"] .os-step-btn.active .os-step-label {
  color: #ffffff !important;
}

/* ----------------------------------------------------------------------------
   18. MÓDULOS: LOCAIS, SUBLOCAIS & DOCUMENTOS
   ---------------------------------------------------------------------------- */
[data-bs-theme="dark"] .locais-scope-row,
[data-theme="dark"] .locais-scope-row {
  background: var(--manutsys-surface-elevated, #162033) !important;
  border-color: var(--manutsys-border, #283750) !important;
}

[data-bs-theme="dark"] .local-documentos-tabela-wrapper,
[data-theme="dark"] .local-documentos-tabela-wrapper {
  background: var(--manutsys-surface, #111a2b) !important;
  border-color: var(--manutsys-border, #283750) !important;
}

[data-bs-theme="dark"] .local-documentos-table thead th,
[data-theme="dark"] .local-documentos-table thead th {
  background: var(--manutsys-surface-elevated, #162033) !important;
  color: var(--manutsys-text-muted, #94a3b8) !important;
  border-color: var(--manutsys-border, #283750) !important;
}

[data-bs-theme="dark"] .local-documentos-table tbody td,
[data-theme="dark"] .local-documentos-table tbody td {
  color: var(--manutsys-text, #f1f5f9) !important;
  border-color: var(--manutsys-border, #283750) !important;
}

[data-bs-theme="dark"] .local-documentos-table tbody tr:hover,
[data-theme="dark"] .local-documentos-table tbody tr:hover {
  background: var(--manutsys-surface-hover, #1b263a) !important;
}

[data-bs-theme="dark"] .local-documentos-container .local-documento-icone,
[data-theme="dark"] .local-documentos-container .local-documento-icone {
  background: rgba(37, 99, 235, 0.2) !important;
  color: #60a5fa !important;
}

/* Modal de Visualização de Documento em Locais */
[data-bs-theme="dark"] #visualizarDocumentoLocalModal .modal-body,
[data-theme="dark"] #visualizarDocumentoLocalModal .modal-body {
  background: var(--manutsys-surface-elevated, #162033) !important;
  color: var(--manutsys-text, #f1f5f9) !important;
}

[data-bs-theme="dark"] #visualizarDocumentoLocalModal .documento-preview-container,
[data-theme="dark"] #visualizarDocumentoLocalModal .documento-preview-container {
  background: var(--manutsys-surface, #111a2b) !important;
  border-color: var(--manutsys-border, #283750) !important;
}

[data-bs-theme="dark"] #visualizarDocumentoLocalModal .documento-preview-meta,
[data-theme="dark"] #visualizarDocumentoLocalModal .documento-preview-meta {
  color: var(--manutsys-text-muted, #94a3b8) !important;
}

[data-bs-theme="dark"] #visualizarDocumentoLocalModal .documento-preview-indisponivel,
[data-theme="dark"] #visualizarDocumentoLocalModal .documento-preview-indisponivel {
  color: var(--manutsys-text-muted, #94a3b8) !important;
}

/* Dropzone e Itens de Arquivo em Documentos (documentos.php) */
[data-bs-theme="dark"] .document-dropzone,
[data-theme="dark"] .document-dropzone {
  background: var(--manutsys-surface-elevated, #162033) !important;
  border-color: var(--manutsys-border, #283750) !important;
  color: var(--manutsys-text, #f1f5f9) !important;
}

[data-bs-theme="dark"] .document-dropzone:hover,
[data-theme="dark"] .document-dropzone:hover,
[data-bs-theme="dark"] .document-dropzone:focus-visible,
[data-theme="dark"] .document-dropzone:focus-visible {
  border-color: #6366f1 !important;
  background: #1b263a !important;
}

[data-bs-theme="dark"] .document-dropzone .dropzone-title,
[data-theme="dark"] .document-dropzone .dropzone-title {
  color: #ffffff !important;
}

[data-bs-theme="dark"] .document-dropzone .dropzone-help,
[data-theme="dark"] .document-dropzone .dropzone-help {
  color: var(--manutsys-text-muted, #94a3b8) !important;
}

[data-bs-theme="dark"] .file-item,
[data-theme="dark"] .file-item {
  background: var(--manutsys-surface, #111a2b) !important;
  border: 1px solid var(--manutsys-border, #283750) !important;
  color: var(--manutsys-text, #f1f5f9) !important;
}

[data-bs-theme="dark"] .document-upload-preview,
[data-theme="dark"] .document-upload-preview {
  background: var(--manutsys-surface, #111a2b) !important;
  border-color: var(--manutsys-border, #283750) !important;
}

[data-bs-theme="dark"] .stat-card .stat-number,
[data-theme="dark"] .stat-card .stat-number,
[data-bs-theme="dark"] #totalDocumentos,
[data-theme="dark"] #totalDocumentos,
[data-bs-theme="dark"] #totalProximoVencer,
[data-theme="dark"] #totalProximoVencer,
[data-bs-theme="dark"] #totalVencidos,
[data-theme="dark"] #totalVencidos {
  color: #ffffff !important;
  font-weight: 700 !important;
}


/* ----------------------------------------------------------------------------
   19. QR CODES & PREVIEWS DE DOCUMENTOS (PROTEÇÃO ABSOLUTA DE CONTRASTE)
   NÃO inverter QR Codes ou renderizações de documentos!
   ---------------------------------------------------------------------------- */
.qr-code-container,
.qrcode-container,
.qr-container,
.qrcode-card,
.qrcode-wrapper,
#qrCodeModal img,
.qr-preview,
.pdf-preview,
.doc-preview-container img,
.doc-preview-container iframe,
.qr-preserve {
  background-color: #ffffff !important;
  color: #000000 !important;
  filter: none !important;
  -webkit-filter: none !important;
  border-radius: 8px;
  padding: 8px;
  display: inline-block;
}

/* ----------------------------------------------------------------------------
   20. PRELOADERS & LOADINGS GLOBAIS
   ---------------------------------------------------------------------------- */
[data-bs-theme="dark"] #page-preloader,
[data-theme="dark"] #page-preloader {
  background: var(--manutsys-bg, #0b111d) !important;
}

[data-bs-theme="dark"] #page-preloader circle:first-child,
[data-theme="dark"] #page-preloader circle:first-child {
  stroke: #1e2a3f !important;
}

[data-bs-theme="dark"] .manutsys-global-loading-box,
[data-theme="dark"] .manutsys-global-loading-box {
  background: var(--manutsys-surface, #111a2b) !important;
  border: 1px solid var(--manutsys-border, #283750) !important;
}

[data-bs-theme="dark"] .manutsys-global-loading-titulo,
[data-theme="dark"] .manutsys-global-loading-titulo {
  color: #f1f5f9 !important;
}

[data-bs-theme="dark"] .manutsys-global-loading-texto,
[data-theme="dark"] .manutsys-global-loading-texto {
  color: var(--ms-text-muted, #cbd5e1) !important;
}

[data-bs-theme="dark"] .manutsys-global-loading-spinner,
[data-theme="dark"] .manutsys-global-loading-spinner {
  border-color: #24334d !important;
  border-top-color: #3b82f6 !important;
}

/* ----------------------------------------------------------------------------
   21. BOTÕES DO SISTEMA DE TEMA (DESKTOP & HEADER & SIDEBAR)
   ---------------------------------------------------------------------------- */
.manutsys-header-theme-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  padding: 0;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 1.05rem;
}

.manutsys-sidebar-theme-btn {
  background: transparent;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 6px 10px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: all 0.2s ease;
  color: var(--manutsys-text-muted, #94a3b8);
}

.manutsys-sidebar-theme-btn:hover {
  background: var(--manutsys-surface-hover, #162033);
  color: var(--manutsys-text, #f1f5f9);
}

[data-bs-theme="dark"] .manutsys-sidebar-theme-btn:hover,
[data-theme="dark"] .manutsys-sidebar-theme-btn:hover {
  background: #1e293b;
  color: #ffffff;
}

/* Botão de Tema no Login */
.login-theme-btn {
  position: absolute;
  top: 20px;
  right: 20px;
  z-index: 1000;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid var(--manutsys-border, #e2e8f0);
  background: var(--manutsys-surface, #ffffff);
  color: var(--manutsys-text, #0f172a);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 1.1rem;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  transition: all 0.2s ease;
}

.login-theme-btn:hover {
  transform: scale(1.06);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
}

/* ----------------------------------------------------------------------------
   22. TELA DE LOGIN (login.php)
   ---------------------------------------------------------------------------- */
[data-bs-theme="dark"] body.login-body,
[data-theme="dark"] body.login-body,
[data-bs-theme="dark"] .page,
[data-theme="dark"] .page {
  background: #0b111d !important;
  color: #f1f5f9 !important;
}

[data-bs-theme="dark"] .right,
[data-theme="dark"] .right {
  background: #111a2b !important;
  border-left-color: #283750 !important;
}

[data-bs-theme="dark"] .field-input,
[data-theme="dark"] .field-input {
  background: #121c2e !important;
  border-color: #283750 !important;
  color: #f1f5f9 !important;
}

[data-bs-theme="dark"] .field-input:focus,
[data-theme="dark"] .field-input:focus {
  background: #172338 !important;
  border-color: #3b82f6 !important;
  color: #ffffff !important;
}

[data-bs-theme="dark"] .login-tab,
[data-theme="dark"] .login-tab {
  background: #162033 !important;
  color: #94a3b8 !important;
}

[data-bs-theme="dark"] .login-tab.active,
[data-theme="dark"] .login-tab.active {
  background: #2563eb !important;
  color: #ffffff !important;
}

[data-bs-theme="dark"] .left-pill,
[data-theme="dark"] .left-pill {
  background: rgba(37, 99, 235, 0.15) !important;
  border-color: rgba(37, 99, 235, 0.3) !important;
}

[data-bs-theme="dark"] .feat-icon,
[data-theme="dark"] .feat-icon {
  background: rgba(37, 99, 235, 0.15) !important;
  border-color: rgba(37, 99, 235, 0.3) !important;
  color: #60a5fa !important;
}

[data-bs-theme="dark"] .feat-item,
[data-theme="dark"] .feat-item {
  color: #cbd5e1 !important;
}

[data-bs-theme="dark"] .stat-div,
[data-theme="dark"] .stat-div {
  background: #24334d !important;
}

[data-bs-theme="dark"] .bg-dots,
[data-theme="dark"] .bg-dots {
  opacity: 0.12 !important;
}

[data-bs-theme="dark"] #preloader,
[data-theme="dark"] #preloader {
  background: #0b111d !important;
}

[data-bs-theme="dark"] .pre-label,
[data-theme="dark"] .pre-label {
  color: #94a3b8 !important;
}

/* ----------------------------------------------------------------------------
   23. SCROLLBARS CUSTOMIZADAS EM TEMA ESCURO
   ---------------------------------------------------------------------------- */
[data-bs-theme="dark"] ::-webkit-scrollbar,
[data-theme="dark"] ::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

[data-bs-theme="dark"] ::-webkit-scrollbar-track,
[data-theme="dark"] ::-webkit-scrollbar-track {
  background: #0b111d;
}

[data-bs-theme="dark"] ::-webkit-scrollbar-thumb,
[data-theme="dark"] ::-webkit-scrollbar-thumb {
  background: #24334d;
  border-radius: 4px;
}

[data-bs-theme="dark"] ::-webkit-scrollbar-thumb:hover,
[data-theme="dark"] ::-webkit-scrollbar-thumb:hover {
  background: #3b82f6;
}

/* ----------------------------------------------------------------------------
   24. ALERTAS SEMÂNTICOS & AVISOS DE PRÉ-REQUISITOS (FASE 2)
   ---------------------------------------------------------------------------- */
/* Alertas de Aviso / Amarelo / Âmbar */
[data-bs-theme="dark"] .alert-warning,
[data-theme="dark"] .alert-warning,
[data-bs-theme="dark"] .sublocais-prerequisito-aviso,
[data-theme="dark"] .sublocais-prerequisito-aviso,
[data-bs-theme="dark"] .locais-prerequisito-aviso,
[data-theme="dark"] .locais-prerequisito-aviso,
[data-bs-theme="dark"] .tipos-locais-prerequisito-aviso,
[data-theme="dark"] .tipos-locais-prerequisito-aviso,
[data-bs-theme="dark"] .subtipos-prerequisito-aviso,
[data-theme="dark"] .subtipos-prerequisito-aviso,
[data-bs-theme="dark"] .ocorrencias-prerequisito-aviso,
[data-theme="dark"] .ocorrencias-prerequisito-aviso,
[data-bs-theme="dark"] .tarefa-prerequisito-aviso,
[data-theme="dark"] .tarefa-prerequisito-aviso,
[data-bs-theme="dark"] .manut-prerequisito-aviso,
[data-theme="dark"] .manut-prerequisito-aviso,
[data-bs-theme="dark"] .cluster-prereq-alert,
[data-theme="dark"] .cluster-prereq-alert,
[data-bs-theme="dark"] .documentos-prerequisito-aviso,
[data-theme="dark"] .documentos-prerequisito-aviso,
[data-bs-theme="dark"] .tipo-equip-prereq,
[data-theme="dark"] .tipo-equip-prereq,
[data-bs-theme="dark"] .categoria-equip-prereq,
[data-theme="dark"] .categoria-equip-prereq,
[data-bs-theme="dark"] .tipo-doc-prereq,
[data-theme="dark"] .tipo-doc-prereq {
  background-color: rgba(245, 158, 11, 0.16) !important;
  border-color: rgba(245, 158, 11, 0.38) !important;
  color: #fef08a !important;
}

[data-bs-theme="dark"] .sublocais-prerequisito-aviso a,
[data-theme="dark"] .sublocais-prerequisito-aviso a,
[data-bs-theme="dark"] .tipos-locais-prerequisito-aviso a,
[data-theme="dark"] .tipos-locais-prerequisito-aviso a,
[data-bs-theme="dark"] .subtipos-prerequisito-aviso a,
[data-theme="dark"] .subtipos-prerequisito-aviso a,
[data-bs-theme="dark"] .ocorrencias-prerequisito-aviso a,
[data-theme="dark"] .ocorrencias-prerequisito-aviso a,
[data-bs-theme="dark"] .tarefa-prerequisito-aviso a,
[data-theme="dark"] .tarefa-prerequisito-aviso a,
[data-bs-theme="dark"] .manut-prerequisito-aviso a,
[data-theme="dark"] .manut-prerequisito-aviso a {
  color: #fde047 !important;
  font-weight: 700 !important;
}

[data-bs-theme="dark"] .sublocais-prerequisito-aviso i,
[data-theme="dark"] .sublocais-prerequisito-aviso i,
[data-bs-theme="dark"] .tipos-locais-prerequisito-aviso i,
[data-theme="dark"] .tipos-locais-prerequisito-aviso i,
[data-bs-theme="dark"] .subtipos-prerequisito-aviso i,
[data-theme="dark"] .subtipos-prerequisito-aviso i,
[data-bs-theme="dark"] .ocorrencias-prerequisito-aviso i,
[data-theme="dark"] .ocorrencias-prerequisito-aviso i,
[data-theme="dark"] .tarefa-prerequisito-aviso i,
[data-bs-theme="dark"] .tarefa-prerequisito-aviso i,
[data-bs-theme="dark"] .manut-prerequisito-aviso i,
[data-theme="dark"] .manut-prerequisito-aviso i {
  color: #f59e0b !important;
}

/* Alertas de Perigo / Erro / Vermelho */
[data-bs-theme="dark"] .alert-danger,
[data-theme="dark"] .alert-danger {
  background-color: rgba(239, 68, 68, 0.16) !important;
  border-color: rgba(239, 68, 68, 0.38) !important;
  color: #fca5a5 !important;
}

[data-bs-theme="dark"] .alert-danger a,
[data-theme="dark"] .alert-danger a {
  color: #f87171 !important;
}

/* Alertas de Sucesso / Verde */
[data-bs-theme="dark"] .alert-success,
[data-theme="dark"] .alert-success {
  background-color: rgba(16, 185, 129, 0.16) !important;
  border-color: rgba(16, 185, 129, 0.38) !important;
  color: #86efac !important;
}

[data-bs-theme="dark"] .alert-success a,
[data-theme="dark"] .alert-success a {
  color: #4ade80 !important;
}

/* Alertas Informativos / Azul */
[data-bs-theme="dark"] .alert-info,
[data-theme="dark"] .alert-info,
[data-bs-theme="dark"] .etapas-scope-note,
[data-theme="dark"] .etapas-scope-note {
  background-color: rgba(59, 130, 246, 0.16) !important;
  border-color: rgba(59, 130, 246, 0.38) !important;
  color: #93c5fd !important;
}

[data-bs-theme="dark"] .alert-info a,
[data-theme="dark"] .alert-info a {
  color: #60a5fa !important;
}

/* Alertas Neutros / Light / Secundários */
[data-bs-theme="dark"] .alert-light,
[data-theme="dark"] .alert-light,
[data-bs-theme="dark"] .alert-secondary,
[data-theme="dark"] .alert-secondary,
[data-bs-theme="dark"] .relatorio-scope-note,
[data-theme="dark"] .relatorio-scope-note {
  background-color: var(--ms-surface-2, #162033) !important;
  border-color: var(--ms-border, #283750) !important;
  color: var(--ms-text, #f1f5f9) !important;
}

/* ----------------------------------------------------------------------------
   25. BOTÕES ESPECIAIS EM DARK MODE (.btn-light, .btn-outline-dark/secondary)
   ---------------------------------------------------------------------------- */
[data-bs-theme="dark"] .btn-light,
[data-theme="dark"] .btn-light {
  background-color: #1e293b !important;
  border-color: #334155 !important;
  color: #f1f5f9 !important;
}

[data-bs-theme="dark"] .btn-light:hover,
[data-theme="dark"] .btn-light:hover,
[data-bs-theme="dark"] .btn-light:focus,
[data-theme="dark"] .btn-light:focus {
  background-color: #334155 !important;
  border-color: #475569 !important;
  color: #ffffff !important;
}

[data-bs-theme="dark"] .btn-outline-dark,
[data-theme="dark"] .btn-outline-dark {
  border-color: #475569 !important;
  color: #cbd5e1 !important;
}

[data-bs-theme="dark"] .btn-outline-dark:hover,
[data-theme="dark"] .btn-outline-dark:hover,
[data-bs-theme="dark"] .btn-outline-dark:focus,
[data-theme="dark"] .btn-outline-dark:focus {
  background-color: #1e293b !important;
  border-color: #64748b !important;
  color: #ffffff !important;
}

[data-bs-theme="dark"] .btn-outline-secondary,
[data-theme="dark"] .btn-outline-secondary {
  border-color: #334155 !important;
  color: #cbd5e1 !important;
}

[data-bs-theme="dark"] .btn-outline-secondary:hover,
[data-theme="dark"] .btn-outline-secondary:hover,
[data-bs-theme="dark"] .btn-outline-secondary:focus,
[data-theme="dark"] .btn-outline-secondary:focus {
  background-color: #1e293b !important;
  border-color: #475569 !important;
  color: #ffffff !important;
}

/* ----------------------------------------------------------------------------
   26. CORREÇÃO GLOBAL PARA thead.table-light E .bg-light NO DARK MODE
   ---------------------------------------------------------------------------- */
[data-bs-theme="dark"] .table-light,
[data-theme="dark"] .table-light,
[data-bs-theme="dark"] thead.table-light,
[data-theme="dark"] thead.table-light,
[data-bs-theme="dark"] thead.table-light th,
[data-theme="dark"] thead.table-light th {
  background-color: var(--ms-table-header, #101827) !important;
  color: var(--ms-text, #f1f5f9) !important;
  border-color: var(--ms-border, #283750) !important;
}

[data-bs-theme="dark"] .bg-light:not(.qr-preserve):not(.qr-preserve-container),
[data-theme="dark"] .bg-light:not(.qr-preserve):not(.qr-preserve-container) {
  background-color: var(--ms-surface-2, #162033) !important;
  color: var(--ms-text, #f1f5f9) !important;
}

[data-bs-theme="dark"] .badge.bg-light.text-dark,
[data-theme="dark"] .badge.bg-light.text-dark {
  background-color: var(--ms-surface-3, #1b263a) !important;
  color: var(--ms-text, #f1f5f9) !important;
  border-color: var(--ms-border, #283750) !important;
}

/* ----------------------------------------------------------------------------
   27. ESCOPO BOXES, STEPPERS E MODAIS ESPECÍFICOS (FASE 2)
   ---------------------------------------------------------------------------- */
/* Scope rows compartilhadas em cadastros */
[data-bs-theme="dark"] .sublocais-scope-row,
[data-theme="dark"] .sublocais-scope-row,
[data-bs-theme="dark"] .tarefa-scope-row,
[data-theme="dark"] .tarefa-scope-row,
[data-bs-theme="dark"] .checklist-scope-row,
[data-theme="dark"] .checklist-scope-row,
[data-bs-theme="dark"] .manut-scope-row,
[data-theme="dark"] .manut-scope-row,
[data-bs-theme="dark"] .cluster-scope-row,
[data-theme="dark"] .cluster-scope-row,
[data-bs-theme="dark"] .etapas-scope-row,
[data-theme="dark"] .etapas-scope-row,
[data-bs-theme="dark"] .departamento-scope-box,
[data-theme="dark"] .departamento-scope-box,
[data-bs-theme="dark"] .cargo-scope-box,
[data-theme="dark"] .cargo-scope-box,
[data-bs-theme="dark"] .setor-scope-box,
[data-theme="dark"] .setor-scope-box,
[data-bs-theme="dark"] .nivel-scope-box,
[data-theme="dark"] .nivel-scope-box,
[data-bs-theme="dark"] .tipo-equip-scope-box,
[data-theme="dark"] .tipo-equip-scope-box,
[data-bs-theme="dark"] .categoria-equip-scope-box,
[data-theme="dark"] .categoria-equip-scope-box,
[data-bs-theme="dark"] .tipo-doc-scope-row,
[data-theme="dark"] .tipo-doc-scope-row {
  background-color: var(--ms-surface-2, #162033) !important;
  border-color: var(--ms-border, #283750) !important;
  color: var(--ms-text, #f1f5f9) !important;
}

/* ORDENS DE SERVIÇO: Stepper / Jornada */
[data-bs-theme="dark"] .os-journey-wrapper,
[data-theme="dark"] .os-journey-wrapper {
  background-color: var(--ms-surface, #111a2b) !important;
  border-color: var(--ms-border, #283750) !important;
}

[data-bs-theme="dark"] .os-journey-title,
[data-theme="dark"] .os-journey-title {
  color: var(--ms-text, #f1f5f9) !important;
}

[data-bs-theme="dark"] .os-journey-hint,
[data-theme="dark"] .os-journey-hint {
  background-color: var(--ms-surface-2, #162033) !important;
  border-color: var(--ms-border, #283750) !important;
  color: var(--ms-text-muted, #94a3b8) !important;
}

[data-bs-theme="dark"] .os-journey-line,
[data-theme="dark"] .os-journey-line {
  background-color: var(--ms-border, #283750) !important;
}

[data-bs-theme="dark"] .os-step-circle,
[data-theme="dark"] .os-step-circle {
  background-color: var(--ms-surface-2, #162033) !important;
  border-color: var(--ms-border, #283750) !important;
  color: var(--ms-text-muted, #94a3b8) !important;
}

[data-bs-theme="dark"] .os-step-label,
[data-theme="dark"] .os-step-label {
  color: var(--ms-text-secondary, #cbd5e1) !important;
}

/* Modal Reprovação OS */
[data-bs-theme="dark"] #modalReprovacaoOS .modal-header,
[data-theme="dark"] #modalReprovacaoOS .modal-header {
  background: rgba(239, 68, 68, 0.22) !important;
  border-bottom: 1px solid rgba(239, 68, 68, 0.42) !important;
}

[data-bs-theme="dark"] #modalReprovacaoOS .modal-title,
[data-theme="dark"] #modalReprovacaoOS .modal-title {
  color: #fca5a5 !important;
}

/* Documentos preview chips / wrappers */
[data-bs-theme="dark"] .documento-equip-preview-meta .preview-meta-chip,
[data-theme="dark"] .documento-equip-preview-meta .preview-meta-chip {
  background-color: var(--ms-surface-2, #162033) !important;
  border-color: var(--ms-border, #283750) !important;
  color: var(--ms-text, #f1f5f9) !important;
}

[data-bs-theme="dark"] .documento-equip-preview-container,
[data-theme="dark"] .documento-equip-preview-container {
  background: var(--ms-surface, #111a2b) !important;
  border-color: var(--ms-border, #283750) !important;
}

/* Ocorrências: Upload boxes, Dropzone e Preview */
[data-bs-theme="dark"] .ocorrencia-upload-box,
[data-theme="dark"] .ocorrencia-upload-box {
  background-color: var(--ms-surface-2, #162033) !important;
  border-color: var(--ms-border, #283750) !important;
}

[data-bs-theme="dark"] .ocorrencia-dropzone,
[data-theme="dark"] .ocorrencia-dropzone,
[data-bs-theme="dark"] .ocorrencia-camera-btn,
[data-theme="dark"] .ocorrencia-camera-btn,
[data-bs-theme="dark"] .ocorrencia-foto-card,
[data-theme="dark"] .ocorrencia-foto-card,
[data-bs-theme="dark"] .ocorrencia-empty-photos,
[data-theme="dark"] .ocorrencia-empty-photos {
  background-color: var(--ms-surface, #111a2b) !important;
  border-color: var(--ms-border, #283750) !important;
  color: var(--ms-text, #f1f5f9) !important;
}

[data-bs-theme="dark"] .ocorrencia-dropzone:hover,
[data-theme="dark"] .ocorrencia-dropzone:hover,
[data-bs-theme="dark"] .ocorrencia-camera-btn:hover,
[data-theme="dark"] .ocorrencia-camera-btn:hover {
  background-color: var(--ms-surface-2, #162033) !important;
  border-color: #3b82f6 !important;
}

[data-bs-theme="dark"] .ocorrencia-dropzone-icon,
[data-theme="dark"] .ocorrencia-dropzone-icon {
  background-color: rgba(59, 130, 246, 0.18) !important;
}

[data-bs-theme="dark"] .ocorrencia-modal-loading,
[data-theme="dark"] .ocorrencia-modal-loading,
[data-bs-theme="dark"] .manut-edicao-loading,
[data-theme="dark"] .manut-edicao-loading {
  background: rgba(11, 17, 29, 0.9) !important;
}

[data-bs-theme="dark"] .ocorrencia-modal-loading-title,
[data-theme="dark"] .ocorrencia-modal-loading-title,
[data-bs-theme="dark"] .manut-edicao-loading-title,
[data-theme="dark"] .manut-edicao-loading-title {
  color: var(--ms-text, #f1f5f9) !important;
}

[data-bs-theme="dark"] #visualizarImagemOcorrenciaModal .modal-body,
[data-theme="dark"] #visualizarImagemOcorrenciaModal .modal-body {
  background-color: var(--ms-surface-2, #162033) !important;
}

[data-bs-theme="dark"] #visualizarImagemOcorrenciaModal .modal-header,
[data-theme="dark"] #visualizarImagemOcorrenciaModal .modal-header,
[data-bs-theme="dark"] #visualizarImagemOcorrenciaModal .modal-footer,
[data-theme="dark"] #visualizarImagemOcorrenciaModal .modal-footer {
  background-color: var(--ms-surface, #111a2b) !important;
  border-color: var(--ms-border, #283750) !important;
}

/* Checklists: Itens e Badges */
[data-bs-theme="dark"] .checklist-item,
[data-theme="dark"] .checklist-item,
[data-bs-theme="dark"] .checklist-item-edit,
[data-theme="dark"] .checklist-item-edit {
  background-color: var(--ms-surface-2, #162033) !important;
  border-color: var(--ms-border, #283750) !important;
  color: var(--ms-text, #f1f5f9) !important;
}

[data-bs-theme="dark"] .badge.bg-white.text-primary,
[data-theme="dark"] .badge.bg-white.text-primary {
  background-color: rgba(59, 130, 246, 0.2) !important;
  color: #93c5fd !important;
}

/* Clusterizações: Itens e Etapas */
[data-bs-theme="dark"] .etapa-item,
[data-theme="dark"] .etapa-item {
  background-color: var(--ms-surface, #111a2b) !important;
  border-color: var(--ms-border, #283750) !important;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35) !important;
}

[data-bs-theme="dark"] .etapa-header,
[data-theme="dark"] .etapa-header {
  background-color: var(--ms-surface-2, #162033) !important;
  border-bottom-color: var(--ms-border, #283750) !important;
}

[data-bs-theme="dark"] .cluster-page-loading-box,
[data-theme="dark"] .cluster-page-loading-box {
  background-color: var(--ms-surface-2, #162033) !important;
  border: 1px solid var(--ms-border, #283750) !important;
  box-shadow: 0 20px 60px rgba(0, 0, 0, .55) !important;
  color: var(--ms-text, #f1f5f9) !important;
}

[data-bs-theme="dark"] .cluster-page-loading-title,
[data-theme="dark"] .cluster-page-loading-title {
  color: var(--ms-text, #f1f5f9) !important;
}

[data-bs-theme="dark"] .cluster-page-loading-text,
[data-theme="dark"] .cluster-page-loading-text {
  color: var(--ms-text-muted, #cbd5e1) !important;
}

[data-bs-theme="dark"] .cluster-page-loading-spinner,
[data-theme="dark"] .cluster-page-loading-spinner {
  border-color: var(--ms-border, #24334d) !important;
  border-top-color: var(--ms-primary, #3b82f6) !important;
}

[data-bs-theme="dark"] .etapas-origem-pill,
[data-theme="dark"] .etapas-origem-pill {
  background-color: var(--ms-surface-2, #162033) !important;
  color: var(--ms-text, #cbd5e1) !important;
}

[data-bs-theme="dark"] .weight-bar-wrap,
[data-theme="dark"] .weight-bar-wrap {
  background-color: var(--ms-surface-3, #1b263a) !important;
}

/* Notificações: Cards e Estados Lida/Não Lida */
[data-bs-theme="dark"] .notificacoes-stat-card,
[data-theme="dark"] .notificacoes-stat-card,
[data-bs-theme="dark"] .notification-card,
[data-theme="dark"] .notification-card,
[data-bs-theme="dark"] .notificacoes-empty,
[data-theme="dark"] .notificacoes-empty,
[data-bs-theme="dark"] .notificacoes-error,
[data-theme="dark"] .notificacoes-error {
  background-color: var(--ms-surface, #111a2b) !important;
  border-color: var(--ms-border, #283750) !important;
  color: var(--ms-text, #f1f5f9) !important;
}

[data-bs-theme="dark"] .notificacoes-stat-value,
[data-theme="dark"] .notificacoes-stat-value,
[data-bs-theme="dark"] .notification-title,
[data-theme="dark"] .notification-title {
  color: var(--ms-text, #f1f5f9) !important;
}

[data-bs-theme="dark"] .notificacoes-stat-label,
[data-theme="dark"] .notificacoes-stat-label,
[data-bs-theme="dark"] .notification-description,
[data-theme="dark"] .notification-description {
  color: var(--ms-text-secondary, #cbd5e1) !important;
}

[data-bs-theme="dark"] .notification-card.unread,
[data-theme="dark"] .notification-card.unread {
  background-color: var(--ms-surface-2, #162033) !important;
  border-left-color: #3b82f6 !important;
}

[data-bs-theme="dark"] .notification-module,
[data-theme="dark"] .notification-module {
  background-color: var(--ms-surface-3, #1b263a) !important;
  color: var(--ms-text-secondary, #cbd5e1) !important;
}

[data-bs-theme="dark"] .notificacoes-stat-icon.unread,
[data-theme="dark"] .notificacoes-stat-icon.unread {
  background-color: rgba(37, 99, 235, 0.2) !important;
  color: #60a5fa !important;
}

[data-bs-theme="dark"] .notificacoes-stat-icon.read,
[data-theme="dark"] .notificacoes-stat-icon.read {
  background-color: rgba(16, 185, 129, 0.2) !important;
  color: #34d399 !important;
}

[data-bs-theme="dark"] .notification-icon.success,
[data-theme="dark"] .notification-icon.success {
  background-color: rgba(16, 185, 129, 0.2) !important;
  color: #34d399 !important;
}

[data-bs-theme="dark"] .notification-icon.info,
[data-theme="dark"] .notification-icon.info {
  background-color: rgba(37, 99, 235, 0.2) !important;
  color: #60a5fa !important;
}

[data-bs-theme="dark"] .notification-icon.warning,
[data-theme="dark"] .notification-icon.warning {
  background-color: rgba(245, 158, 11, 0.2) !important;
  color: #fbbf24 !important;
}

[data-bs-theme="dark"] .notification-icon.danger,
[data-theme="dark"] .notification-icon.danger {
  background-color: rgba(239, 68, 68, 0.2) !important;
  color: #f87171 !important;
}

/* Status Badges OS & style.css */
[data-bs-theme="dark"] .badge-status-em-execucao,
[data-theme="dark"] .badge-status-em-execucao {
  background-color: rgba(245, 158, 11, 0.2) !important;
  color: #fef08a !important;
}

[data-bs-theme="dark"] .badge-status-validacao,
[data-theme="dark"] .badge-status-validacao {
  background-color: rgba(6, 182, 212, 0.2) !important;
  color: #a5f3fc !important;
}

/* ----------------------------------------------------------------------------
   28. PRESERVAÇÃO RIGOROSA DE QR CODES (FUNDO BRANCO + QR PRETO)
   ---------------------------------------------------------------------------- */
.qr-preserve,
.qr-preserve-container,
[data-bs-theme="dark"] .qr-preserve,
[data-theme="dark"] .qr-preserve,
[data-bs-theme="dark"] .qr-preserve-container,
[data-theme="dark"] .qr-preserve-container,
[data-bs-theme="dark"] #qrcodeEquipamentoModal .bg-light,
[data-theme="dark"] #qrcodeEquipamentoModal .bg-light,
[data-bs-theme="dark"] #qrcodeModalSublocal .bg-light,
[data-theme="dark"] #qrcodeModalSublocal .bg-light,
[data-bs-theme="dark"] #qrcodeModal .bg-light,
[data-theme="dark"] #qrcodeModal .bg-light,
[data-bs-theme="dark"] .qrcode-preview-image,
[data-theme="dark"] .qrcode-preview-image,
[data-bs-theme="dark"] #qrcodeEquipamentoImage,
[data-theme="dark"] #qrcodeEquipamentoImage,
[data-bs-theme="dark"] #qrcodeImageSublocal,
[data-theme="dark"] #qrcodeImageSublocal {
  background-color: #ffffff !important;
  color: #000000 !important;
}

