/**
 * GLOBAL THEME CSS - ERP Milhas
 * Sistema de tema com CSS Variables
 *
 * ARQUITETURA:
 * - Variaveis definidas no :root (tema claro) e html.dark-mode (tema escuro)
 * - Estilos base usam variaveis (aplicam em ambos os modos)
 * - Overrides de Tailwind usam prefixo body.dark-mode (so aplicam em dark)
 *
 * ANTI-FOUC (Flash of Unstyled Content):
 * - Incluir theme-early-apply.js ANTES deste CSS
 * - Isso adiciona classe dark-mode ao <html> antes do CSS carregar
 *
 * COMO USAR:
 * 1. Incluir theme-early-apply.js no <head> (PRIMEIRO!)
 * 2. Incluir este CSS no <head>
 * 3. Incluir global-settings-manager.js
 * 4. O tema sera aplicado automaticamente via classe no <html>
 */

/* Fonte global do app (identidade tipográfica unificada). Ver bloco "SKIN GLOBAL" no fim. */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

/* ============================================
   ANTI-FOUC: Prevencao de Flash Branco
   Estas regras aplicam ANTES do JavaScript
   usando apenas html.dark-mode como seletor
   ============================================ */
html.dark-mode {
    background-color: #0f0f0f !important;
}

html.dark-mode body {
    background-color: #0f0f0f !important;
    color: #f5f5f5 !important;
}

/* Forcando cores escuras em elementos comuns ANTES do JS */
html.dark-mode .bg-white,
html.dark-mode .bg-gray-50,
html.dark-mode .bg-gray-100,
html.dark-mode .bg-slate-50,
html.dark-mode .bg-slate-100 {
    background-color: #1f1f1f !important;
}

html.dark-mode [class*="bg-white"]:not(.sidebar *):not(.modern-sidebar *) {
    background-color: #1f1f1f !important;
}

/* ANTI-FOUC: Botoes coloridos (bg-*-50) - aplicar ANTES do body existir */
html.dark-mode .bg-red-50,
html.dark-mode [class*="bg-red-50"] {
    background-color: rgba(239, 68, 68, 0.15) !important;
}

html.dark-mode .bg-green-50,
html.dark-mode [class*="bg-green-50"] {
    background-color: rgba(34, 197, 94, 0.15) !important;
}

html.dark-mode .bg-blue-50,
html.dark-mode [class*="bg-blue-50"] {
    background-color: rgba(59, 130, 246, 0.15) !important;
}

html.dark-mode .bg-orange-50,
html.dark-mode [class*="bg-orange-50"] {
    background-color: rgba(249, 115, 22, 0.15) !important;
}

html.dark-mode .bg-purple-50,
html.dark-mode [class*="bg-purple-50"] {
    background-color: rgba(168, 85, 247, 0.15) !important;
}

html.dark-mode .bg-cyan-50,
html.dark-mode [class*="bg-cyan-50"] {
    background-color: rgba(6, 182, 212, 0.15) !important;
}

html.dark-mode .bg-yellow-50,
html.dark-mode [class*="bg-yellow-50"] {
    background-color: rgba(234, 179, 8, 0.15) !important;
}

html.dark-mode .bg-teal-50,
html.dark-mode [class*="bg-teal-50"] {
    background-color: rgba(20, 184, 166, 0.15) !important;
}

html.dark-mode .bg-indigo-50,
html.dark-mode [class*="bg-indigo-50"] {
    background-color: rgba(99, 102, 241, 0.15) !important;
}

html.dark-mode .bg-pink-50,
html.dark-mode [class*="bg-pink-50"] {
    background-color: rgba(236, 72, 153, 0.15) !important;
}

/* ANTI-FOUC: Botoes coloridos (bg-*-100) */
html.dark-mode .bg-red-100,
html.dark-mode [class*="bg-red-100"] {
    background-color: rgba(239, 68, 68, 0.25) !important;
}

html.dark-mode .bg-green-100,
html.dark-mode [class*="bg-green-100"] {
    background-color: rgba(34, 197, 94, 0.25) !important;
}

html.dark-mode .bg-blue-100,
html.dark-mode [class*="bg-blue-100"] {
    background-color: rgba(59, 130, 246, 0.25) !important;
}

html.dark-mode .bg-orange-100,
html.dark-mode [class*="bg-orange-100"] {
    background-color: rgba(249, 115, 22, 0.25) !important;
}

html.dark-mode .bg-purple-100,
html.dark-mode [class*="bg-purple-100"] {
    background-color: rgba(168, 85, 247, 0.25) !important;
}

html.dark-mode .bg-cyan-100,
html.dark-mode [class*="bg-cyan-100"] {
    background-color: rgba(6, 182, 212, 0.25) !important;
}

/* ANTI-FOUC: Bordas coloridas */
html.dark-mode .border-red-200,
html.dark-mode [class*="border-red-200"] {
    border-color: rgba(239, 68, 68, 0.4) !important;
}

html.dark-mode .border-green-200,
html.dark-mode [class*="border-green-200"] {
    border-color: rgba(34, 197, 94, 0.4) !important;
}

html.dark-mode .border-blue-200,
html.dark-mode [class*="border-blue-200"] {
    border-color: rgba(59, 130, 246, 0.4) !important;
}

html.dark-mode .border-orange-200,
html.dark-mode [class*="border-orange-200"] {
    border-color: rgba(249, 115, 22, 0.4) !important;
}

html.dark-mode .border-purple-200,
html.dark-mode [class*="border-purple-200"] {
    border-color: rgba(168, 85, 247, 0.4) !important;
}

html.dark-mode .border-cyan-200,
html.dark-mode [class*="border-cyan-200"] {
    border-color: rgba(6, 182, 212, 0.4) !important;
}

/* ANTI-FOUC: Gradientes de botoes (como o de despesa/milhas) */
html.dark-mode .bg-gradient-to-r.from-red-50.to-purple-50,
html.dark-mode [class*="from-red-50"][class*="to-purple-50"] {
    background: linear-gradient(to right, rgba(239, 68, 68, 0.15), rgba(168, 85, 247, 0.15)) !important;
}

/* ANTI-FOUC: Cards de Personalizacao e Integracoes */
html.dark-mode .personalization-card,
html.dark-mode .integration-card,
html.dark-mode .config-card {
    background-color: #1f1f1f !important;
    border-color: #333333 !important;
}

html.dark-mode .personalization-card .card-title,
html.dark-mode .integration-card h3,
html.dark-mode .config-card h2,
html.dark-mode .config-card h3 {
    color: #f5f5f5 !important;
}

html.dark-mode .personalization-card .card-description,
html.dark-mode .personalization-card .card-features li,
html.dark-mode .integration-card p,
html.dark-mode .integration-card span,
html.dark-mode .config-card p {
    color: #a3a3a3 !important;
}

html.dark-mode .personalization-card .card-icon {
    background: linear-gradient(135deg, #262626 0%, #1f1f1f 100%) !important;
}

/* ANTI-FOUC: Image Uploader Component */
html.dark-mode .image-uploader__dropzone {
    background-color: #262626 !important;
    border-color: #333333 !important;
}

html.dark-mode .image-uploader__placeholder {
    color: #a3a3a3 !important;
}

html.dark-mode .image-uploader__placeholder i,
html.dark-mode .image-uploader__placeholder p {
    color: #a3a3a3 !important;
}

/* ANTI-FOUC: Remover seta extra dos selects */
html.dark-mode select {
    -webkit-appearance: none !important;
    -moz-appearance: none !important;
    appearance: none !important;
}

/* ANTI-FOUC: Fluxo de Caixa (fluxo-caixa-conta.html) */
html.dark-mode .balance-card {
    background-color: #1f1f1f !important;
    border-color: #333333 !important;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3) !important;
}

html.dark-mode .balance-card .text-gray-600,
html.dark-mode .balance-card .text-sm {
    color: #a3a3a3 !important;
}

html.dark-mode .balance-card .text-gray-900,
html.dark-mode .balance-card .text-xl {
    color: #f5f5f5 !important;
}

html.dark-mode .month-selector {
    background-color: #1f1f1f !important;
    border-color: #333333 !important;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3) !important;
}

html.dark-mode .month-display {
    color: #f5f5f5 !important;
}

html.dark-mode .month-button {
    background-color: #262626 !important;
    color: #a3a3a3 !important;
}

html.dark-mode .month-button:hover {
    background-color: #333333 !important;
    color: #f5f5f5 !important;
}

html.dark-mode .transaction-header {
    background-color: #1a1a1a !important;
    border-color: #333333 !important;
    color: #a3a3a3 !important;
}

html.dark-mode .transaction-row {
    border-color: #262626 !important;
}

html.dark-mode .transaction-row:hover {
    background-color: #262626 !important;
}

/* ANTI-FOUC: Stats cards em personalizacao.html */
html.dark-mode .bg-white.rounded-lg.p-6.border,
html.dark-mode .bg-white.rounded-lg.p-6.border-gray-200 {
    background-color: #1f1f1f !important;
    border-color: #333333 !important;
}

/* ANTI-FOUC: Log de atividades em integracoes.html */
html.dark-mode .space-y-3 .bg-gray-50,
html.dark-mode .p-3.bg-gray-50 {
    background-color: #262626 !important;
}

html.dark-mode .bg-red-50.border-red-200 {
    background-color: rgba(239, 68, 68, 0.15) !important;
    border-color: rgba(239, 68, 68, 0.4) !important;
}

html.dark-mode .text-red-800 {
    color: #fca5a5 !important;
}

html.dark-mode .text-red-600 {
    color: #f87171 !important;
}

/* ANTI-FOUC: Development notice em integracoes.html */
html.dark-mode .config-card.bg-blue-50,
html.dark-mode .bg-blue-50.border-blue-200 {
    background-color: rgba(59, 130, 246, 0.15) !important;
    border-color: rgba(59, 130, 246, 0.3) !important;
}

html.dark-mode .text-blue-900 {
    color: #93c5fd !important;
}

html.dark-mode .text-blue-700 {
    color: #60a5fa !important;
}

/* ============================================
   VARIAVEIS CSS - TEMA CLARO (PADRAO)
   ============================================ */
:root {
    /* Backgrounds */
    --bg-primary: #f8fafc;
    --bg-secondary: #ffffff;
    --bg-card: #ffffff;
    --bg-input: #ffffff;
    --bg-hover: #f1f5f9;
    --bg-modal: rgba(0, 0, 0, 0.5);
    --bg-table-header: #f8fafc;
    --bg-table-row-hover: #f1f5f9;

    /* Textos */
    --text-primary: #111827;
    --text-secondary: #374151;
    --text-muted: #6b7280;
    --text-light: #9ca3af;
    --text-inverse: #ffffff;

    /* Bordas */
    --border-color: #e2e8f0;
    --border-light: #f1f5f9;
    --border-focus: #3b82f6;

    /* Sombras */
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.1);

    /* Cores de Feedback */
    --color-success: #10b981;
    --color-success-bg: #ecfdf5;
    --color-success-border: #10b981;
    --color-error: #ef4444;
    --color-error-bg: #fef2f2;
    --color-error-border: #ef4444;
    --color-warning: #f59e0b;
    --color-warning-bg: #fffbeb;
    --color-warning-border: #f59e0b;
    --color-info: #3b82f6;
    --color-info-bg: #eff6ff;
    --color-info-border: #3b82f6;

    /* Cores Primarias */
    --color-primary: #3b82f6;
    --color-primary-hover: #2563eb;
    --color-primary-light: #dbeafe;

    /* Sidebar - Sempre escura em ambos os modos */
    --sidebar-bg: linear-gradient(180deg, #1e293b 0%, #0f172a 100%);
    --sidebar-text: #94a3b8;
    --sidebar-text-hover: #ffffff;
    --sidebar-border: rgba(148, 163, 184, 0.1);

    /* Scrollbar — FONTE ÚNICA: mude aqui e vale para TODO o sistema */
    --scrollbar-track: #f1f5f9;
    --scrollbar-thumb: #cbd5e1;
    --scrollbar-thumb-hover: #94a3b8;
    --scrollbar-width: 14px;   /* largura/altura da barra em todo o sistema */
    --scrollbar-radius: 7px;   /* arredondamento do thumb/track */

    /* Select arrow */
    --select-arrow: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3e%3c/svg%3e");

    /* Feedbacks/valores aplicados via inline-style por JS (#35).
       Como inline style vence CSS, expomos como variáveis: o JS seta
       style.background='var(--task-done-bg)' e a cor segue o tema. */
    --task-flash-warning: #fef3c7;
    --task-done-bg: #dcfce7;
    --task-done-flash: #bbf7d0;
    --task-reschedule-bg: #dbeafe;
    --val-positive: #059669;   /* verde de valor (estimado, a receber) */
    --val-accent: #7c3aed;     /* roxo de valor (milheiro) */
}

/* ============================================
   VARIAVEIS CSS - TEMA ESCURO
   Baseado em Google Material Design Dark Theme
   WCAG AA Contrast Guidelines (4.5:1 minimo)
   ============================================ */
html.dark-mode {
    color-scheme: dark !important;

    /* Backgrounds - Tons mais escuros para contraste real */
    --bg-primary: #0f0f0f;
    --bg-secondary: #171717;
    --bg-card: #1f1f1f;
    --bg-input: #262626;
    --bg-hover: #2a2a2a;
    --bg-modal: rgba(0, 0, 0, 0.85);
    --bg-table-header: #171717;
    --bg-table-row-hover: #2a2a2a;

    /* Textos - Contraste adequado */
    --text-primary: #f5f5f5;
    --text-secondary: #d4d4d4;
    --text-muted: #a3a3a3;
    --text-light: #737373;
    --text-inverse: #0f0f0f;

    /* Bordas */
    --border-color: #333333;
    --border-light: #404040;
    --border-focus: #60a5fa;

    /* Sombras */
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.5);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.6);
    --shadow-lg: 0 10px 20px rgba(0, 0, 0, 0.7);

    /* Cores de Feedback */
    --color-success: #4ade80;
    --color-success-bg: rgba(34, 197, 94, 0.15);
    --color-success-border: #22c55e;
    --color-error: #f87171;
    --color-error-bg: rgba(239, 68, 68, 0.15);
    --color-error-border: #ef4444;
    --color-warning: #fbbf24;
    --color-warning-bg: rgba(245, 158, 11, 0.15);
    --color-warning-border: #f59e0b;
    --color-info: #60a5fa;
    --color-info-bg: rgba(59, 130, 246, 0.15);
    --color-info-border: #3b82f6;

    /* Cores Primarias */
    --color-primary: #60a5fa;
    --color-primary-hover: #3b82f6;
    --color-primary-light: rgba(59, 130, 246, 0.2);

    /* Sidebar - Manter escura */
    --sidebar-bg: linear-gradient(180deg, #0f0f0f 0%, #000000 100%);
    --sidebar-text: #a3a3a3;
    --sidebar-text-hover: #ffffff;
    --sidebar-border: #262626;

    /* Scrollbar */
    --scrollbar-track: #171717;
    --scrollbar-thumb: #404040;
    --scrollbar-thumb-hover: #525252;

    /* Select arrow */
    --select-arrow: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%23a3a3a3' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3e%3c/svg%3e");

    /* Feedbacks/valores inline-style por JS — variantes escuras (#35) */
    --task-flash-warning: rgba(245, 158, 11, 0.22);
    --task-done-bg: rgba(34, 197, 94, 0.20);
    --task-done-flash: rgba(34, 197, 94, 0.32);
    --task-reschedule-bg: rgba(59, 130, 246, 0.22);
    --val-positive: #4ade80;
    --val-accent: #a78bfa;
}

/* ============================================
   ESTILOS BASE - APLICAM EM AMBOS OS MODOS
   Usam variaveis que mudam conforme o tema
   ============================================ */
body {
    background-color: var(--bg-primary);
    color: var(--text-primary);
    transition: background-color 0.2s ease, color 0.2s ease;
}

/* Forcamos o fundo do body em dark mode pois algumas paginas tem bg-gray-50 inline */
body.dark-mode {
    background-color: var(--bg-primary) !important;
    color: var(--text-primary) !important;
}

/* ============================================
   SIDEBAR - Estilos fixos (sempre escura)
   ============================================ */
.modern-sidebar,
.sidebar,
nav.modern-sidebar {
    background: var(--sidebar-bg) !important;
}

.modern-sidebar .nav-item,
.sidebar .nav-item,
.nav-link {
    color: var(--sidebar-text) !important;
}

.modern-sidebar .nav-item:hover,
.sidebar .nav-item:hover,
.nav-link:hover,
.modern-sidebar .nav-item.active,
.sidebar .nav-item.active,
.nav-link.active {
    color: var(--sidebar-text-hover) !important;
}

/* ============================================
   SCROLLBARS - Base com variaveis
   ============================================ */
::-webkit-scrollbar {
    width: var(--scrollbar-width);
    height: var(--scrollbar-width);
}

::-webkit-scrollbar-track {
    background: var(--scrollbar-track);
}

::-webkit-scrollbar-thumb {
    background: var(--scrollbar-thumb);
    border-radius: var(--scrollbar-radius);
}

::-webkit-scrollbar-thumb:hover {
    background: var(--scrollbar-thumb-hover);
}

/* ============================================
   ESTILOS DARK MODE - Overrides de Tailwind
   Estes so aplicam quando body.dark-mode
   ============================================ */

/* Cards e Containers */
body.dark-mode .config-card,
body.dark-mode .card,
body.dark-mode .panel,
body.dark-mode .module-card,
body.dark-mode [class*="bg-white"]:not(.sidebar *):not(.modern-sidebar *) {
    background-color: var(--bg-card) !important;
    border-color: var(--border-color) !important;
    box-shadow: var(--shadow-sm);
}

body.dark-mode .config-card:hover,
body.dark-mode .card:hover {
    box-shadow: var(--shadow-md);
    border-color: var(--border-light) !important;
}

/* Cards de Personalizacao (personalizacao.html) */
body.dark-mode .personalization-card {
    background-color: var(--bg-card) !important;
    border-color: var(--border-color) !important;
}

body.dark-mode .personalization-card:hover {
    box-shadow: var(--shadow-md);
    border-color: var(--border-light) !important;
}

body.dark-mode .personalization-card .card-title {
    color: var(--text-primary) !important;
}

body.dark-mode .personalization-card:hover .card-title {
    color: #60a5fa !important;
}

body.dark-mode .personalization-card .card-description {
    color: var(--text-muted) !important;
}

body.dark-mode .personalization-card .card-features li {
    color: var(--text-secondary) !important;
}

body.dark-mode .personalization-card .card-icon {
    background: linear-gradient(135deg, #262626 0%, #1f1f1f 100%) !important;
}

body.dark-mode .personalization-card:hover .card-icon {
    background: linear-gradient(135deg, #3b82f6 0%, #06b6d4 100%) !important;
}

/* Cards de Integracoes (integracoes.html) */
body.dark-mode .integration-card {
    background-color: var(--bg-card) !important;
    border-color: var(--border-color) !important;
}

body.dark-mode .integration-card:hover {
    box-shadow: var(--shadow-md);
    border-color: var(--border-light) !important;
}

body.dark-mode .integration-card h3 {
    color: var(--text-primary) !important;
}

body.dark-mode .integration-card p {
    color: var(--text-muted) !important;
}

body.dark-mode .integration-card span {
    color: var(--text-muted) !important;
}

/* Status badges das integracoes */
body.dark-mode .status-badge.status-connected {
    background-color: rgba(34, 197, 94, 0.2) !important;
    color: #4ade80 !important;
}

body.dark-mode .status-badge.status-available {
    background-color: rgba(59, 130, 246, 0.2) !important;
    color: #60a5fa !important;
}

body.dark-mode .status-badge.status-disconnected {
    background-color: rgba(239, 68, 68, 0.2) !important;
    color: #f87171 !important;
}

/* Log de atividades nas integracoes */
body.dark-mode .integration-card + .space-y-3 .bg-gray-50,
body.dark-mode [class*="bg-gray-50"]:not(.sidebar *) {
    background-color: var(--bg-hover) !important;
}

body.dark-mode .bg-red-50 {
    background-color: rgba(239, 68, 68, 0.15) !important;
}

body.dark-mode .text-red-800 {
    color: #fca5a5 !important;
}

body.dark-mode .text-red-600 {
    color: #f87171 !important;
}

/* Toggle switches nas integracoes */
body.dark-mode .toggle-slider {
    background-color: #404040 !important;
}

body.dark-mode input:checked + .toggle-slider {
    background-color: #3b82f6 !important;
}

/* Image Uploader Component (modais de instituicoes, etc) */
body.dark-mode .image-uploader__dropzone {
    background-color: var(--bg-input) !important;
    border-color: var(--border-color) !important;
}

body.dark-mode .image-uploader__dropzone:hover {
    background-color: var(--bg-hover) !important;
    border-color: var(--border-focus) !important;
}

body.dark-mode .image-uploader__dropzone.drag-over {
    background-color: rgba(59, 130, 246, 0.15) !important;
    border-color: var(--border-focus) !important;
}

body.dark-mode .image-uploader__placeholder {
    color: var(--text-muted) !important;
}

body.dark-mode .image-uploader__placeholder i {
    color: var(--text-muted) !important;
}

body.dark-mode .image-uploader__placeholder p {
    color: var(--text-muted) !important;
}

body.dark-mode .image-uploader__error {
    background-color: rgba(239, 68, 68, 0.15) !important;
    color: #f87171 !important;
}

/* SELECT no dark: usar o controle NATIVO (appearance:auto) + color-scheme:dark.
   appearance:none força o Chrome/Windows a usar o popup "custom", cujo item DESTACADO
   cai na cor de seleção cinza-clara do SO (ilegível — filtro "Todas as contas"). Com
   appearance:auto o popup é 100% nativo e o color-scheme:dark o desenha escuro, COM o
   highlight escuro nativo. A seta nativa volta -> remover a SVG p/ não duplicar. */
body.dark-mode select {
    -webkit-appearance: auto !important;
    -moz-appearance: auto !important;
    appearance: auto !important;
    color-scheme: dark !important;
    background-image: none !important;
}

/* Fluxo de Caixa (fluxo-caixa-conta.html) */
body.dark-mode .balance-card {
    background-color: var(--bg-card) !important;
    border-color: var(--border-color) !important;
    box-shadow: var(--shadow-sm);
}

body.dark-mode .balance-card .text-gray-600,
body.dark-mode .balance-card .text-sm.text-gray-600 {
    color: var(--text-muted) !important;
}

body.dark-mode .balance-card .text-gray-900,
body.dark-mode .balance-card .text-xl.font-bold {
    color: var(--text-primary) !important;
}

body.dark-mode .month-selector {
    background-color: var(--bg-card) !important;
    border-color: var(--border-color) !important;
    box-shadow: var(--shadow-sm);
}

body.dark-mode .month-display {
    color: var(--text-primary) !important;
}

body.dark-mode .month-button {
    background-color: var(--bg-hover) !important;
    color: var(--text-muted) !important;
}

body.dark-mode .month-button:hover {
    background-color: #333333 !important;
    color: var(--text-primary) !important;
}

body.dark-mode .transaction-header {
    background-color: #1a1a1a !important;
    border-color: var(--border-color) !important;
    color: var(--text-muted) !important;
}

body.dark-mode .transaction-row {
    border-color: var(--border-color) !important;
}

body.dark-mode .transaction-row:hover {
    background-color: var(--bg-hover) !important;
}

body.dark-mode .transaction-row .text-gray-600 {
    color: var(--text-muted) !important;
}

body.dark-mode .transaction-row .text-gray-900,
body.dark-mode .transaction-row .font-medium {
    color: var(--text-primary) !important;
}

/* Textos e Titulos */
body.dark-mode h1,
body.dark-mode h2,
body.dark-mode h3,
body.dark-mode h4,
body.dark-mode h5,
body.dark-mode h6 {
    color: var(--text-primary);
}

/* Classes de texto Tailwind */
body.dark-mode .text-gray-900 { color: var(--text-primary) !important; }
body.dark-mode .text-gray-800 { color: var(--text-primary) !important; }
body.dark-mode .text-gray-700 { color: var(--text-secondary) !important; }
body.dark-mode .text-gray-600 { color: var(--text-muted) !important; }
body.dark-mode .text-gray-500 { color: var(--text-muted) !important; }
body.dark-mode .text-gray-400 { color: var(--text-light) !important; }

/* Cores de texto para stats */
body.dark-mode .text-blue-600 { color: #60a5fa !important; }
body.dark-mode .text-green-600 { color: #34d399 !important; }
body.dark-mode .text-purple-600 { color: #a78bfa !important; }
body.dark-mode .text-orange-600 { color: #fb923c !important; }
body.dark-mode .text-red-600 { color: #f87171 !important; }
body.dark-mode .text-yellow-600 { color: #fbbf24 !important; }

/* AMARRAÇÃO GLOBAL — texto de MARCA em tom escuro (-700/-800/-900) é ilegível no
   dark (texto escuro sobre fundo escuro/translúcido: badges roxos "Milhas", números
   text-green-900 dos cards de stat, etc.). Mapeia toda a paleta Tailwind escura para
   o tom -300 (claro) da MESMA cor. Cobre qualquer badge/stat criado depois. */
body.dark-mode .text-red-700, body.dark-mode .text-red-800, body.dark-mode .text-red-900 { color: #fca5a5 !important; }
body.dark-mode .text-orange-700, body.dark-mode .text-orange-800, body.dark-mode .text-orange-900 { color: #fdba74 !important; }
body.dark-mode .text-amber-700, body.dark-mode .text-amber-800, body.dark-mode .text-amber-900 { color: #fcd34d !important; }
body.dark-mode .text-yellow-700, body.dark-mode .text-yellow-800, body.dark-mode .text-yellow-900 { color: #fde047 !important; }
body.dark-mode .text-lime-700, body.dark-mode .text-lime-800, body.dark-mode .text-lime-900 { color: #bef264 !important; }
body.dark-mode .text-green-700, body.dark-mode .text-green-800, body.dark-mode .text-green-900 { color: #86efac !important; }
body.dark-mode .text-emerald-700, body.dark-mode .text-emerald-800, body.dark-mode .text-emerald-900 { color: #6ee7b7 !important; }
body.dark-mode .text-teal-700, body.dark-mode .text-teal-800, body.dark-mode .text-teal-900 { color: #5eead4 !important; }
body.dark-mode .text-cyan-700, body.dark-mode .text-cyan-800, body.dark-mode .text-cyan-900 { color: #67e8f9 !important; }
body.dark-mode .text-sky-700, body.dark-mode .text-sky-800, body.dark-mode .text-sky-900 { color: #7dd3fc !important; }
body.dark-mode .text-blue-700, body.dark-mode .text-blue-800, body.dark-mode .text-blue-900 { color: #93c5fd !important; }
body.dark-mode .text-indigo-700, body.dark-mode .text-indigo-800, body.dark-mode .text-indigo-900 { color: #a5b4fc !important; }
body.dark-mode .text-violet-700, body.dark-mode .text-violet-800, body.dark-mode .text-violet-900 { color: #c4b5fd !important; }
body.dark-mode .text-purple-700, body.dark-mode .text-purple-800, body.dark-mode .text-purple-900 { color: #d8b4fe !important; }
body.dark-mode .text-fuchsia-700, body.dark-mode .text-fuchsia-800, body.dark-mode .text-fuchsia-900 { color: #f0abfc !important; }
body.dark-mode .text-pink-700, body.dark-mode .text-pink-800, body.dark-mode .text-pink-900 { color: #f9a8d4 !important; }
body.dark-mode .text-rose-700, body.dark-mode .text-rose-800, body.dark-mode .text-rose-900 { color: #fda4af !important; }

/* Inputs e Formularios */
body.dark-mode input,
body.dark-mode select,
body.dark-mode textarea,
body.dark-mode .form-control,
body.dark-mode .select-styled {
    background-color: var(--bg-input) !important;
    border-color: var(--border-color) !important;
    color: var(--text-primary) !important;
}

body.dark-mode input:focus,
body.dark-mode select:focus,
body.dark-mode textarea:focus {
    border-color: var(--border-focus) !important;
    box-shadow: 0 0 0 3px rgba(96, 165, 250, 0.25);
}

body.dark-mode input::placeholder,
body.dark-mode textarea::placeholder {
    color: var(--text-light) !important;
}

body.dark-mode input:disabled,
body.dark-mode select:disabled,
body.dark-mode textarea:disabled {
    background-color: var(--bg-hover) !important;
    color: var(--text-light) !important;
    cursor: not-allowed;
}

/* Select dropdown arrow — SÓ p/ dropdowns custom (.select-styled). O <select> real
   usa appearance:auto no dark (seta nativa), então NÃO recebe a SVG (evita 2 setas). */
body.dark-mode .select-styled {
    background-image: var(--select-arrow) !important;
    background-position: right 0.5rem center;
    background-repeat: no-repeat;
    background-size: 1.5em 1.5em;
}

/* NÃO estilizar <option> no dark.
   Estilizar option (background-color) faz o Chrome/Windows trocar o popup NATIVO
   pelo popup "custom", cujo item DESTACADO cai na cor de seleção cinza-clara do SO
   (ilegível — bug do filtro "Todas as contas" de Transações). Deixando os options
   SEM estilo, o `color-scheme: dark` (definido em body.dark-mode select acima) faz o
   navegador desenhar o popup inteiro em escuro nativo, COM o highlight escuro nativo.
   O bg-white do <select> fechado já é vencido por body.dark-mode select { background }. */

/* Labels */
body.dark-mode label {
    color: var(--text-secondary);
}

/* Botoes */
body.dark-mode button.bg-gray-100,
body.dark-mode button.bg-gray-50,
body.dark-mode .btn-secondary {
    background-color: var(--bg-input) !important;
    border-color: var(--border-color) !important;
    color: var(--text-secondary) !important;
}

body.dark-mode button.bg-gray-100:hover,
body.dark-mode button.bg-gray-50:hover,
body.dark-mode .btn-secondary:hover {
    background-color: var(--bg-hover) !important;
}

body.dark-mode button.bg-red-50,
body.dark-mode .btn-danger-light {
    background-color: var(--color-error-bg) !important;
    border-color: var(--color-error-border) !important;
    color: var(--color-error) !important;
}

/* Tabelas */
body.dark-mode table,
body.dark-mode .table {
    background-color: var(--bg-card);
    border-color: var(--border-color);
}

body.dark-mode thead,
body.dark-mode th {
    background-color: var(--bg-table-header) !important;
    color: var(--text-primary) !important;
    border-color: var(--border-color) !important;
}

body.dark-mode tbody tr {
    background-color: var(--bg-card);
    border-color: var(--border-color);
}

body.dark-mode tbody tr:hover {
    background-color: var(--bg-table-row-hover) !important;
}

body.dark-mode td {
    border-color: var(--border-color) !important;
    color: var(--text-secondary);
}

/* Tailwind: a classe `bg-opacity-40` NÃO foi gerada no tailwind.css tokenizado (só existem
   bg-opacity-30 e bg-opacity-50). Sem ela, `bg-black bg-opacity-40` caía no fallback
   --tw-bg-opacity:1 → PRETO OPACO 100%, fazendo o overlay de ~42 modais "pretejar tudo"
   em light mode. Reidratamos a classe aqui (sem rebuildar o tailwind, que regride o tema). */
.bg-opacity-40 { --tw-bg-opacity: 0.4; }

/* Modais - Alta especificidade para sobrescrever inline styles */
body.dark-mode .modal-backdrop,
body.dark-mode .modal-overlay {
    background-color: var(--bg-modal);
}

html.dark-mode body.dark-mode .modal-content,
html.dark-mode body.dark-mode .modal-dialog,
html.dark-mode .modal-content,
html.dark-mode .modal-dialog,
body.dark-mode .modal-content,
body.dark-mode .modal-dialog,
.dark-mode .modal-content,
.dark-mode .modal-dialog,
body.dark-mode .modal > div[class*="bg-white"],
body.dark-mode .modal .bg-white {
    background-color: var(--bg-card) !important;
    border-color: var(--border-color) !important;
    color: var(--text-primary) !important;
}

body.dark-mode .modal-header,
body.dark-mode .modal-footer {
    border-color: var(--border-color) !important;
}

/* Dropdowns */
body.dark-mode .dropdown-menu,
body.dark-mode [class*="dropdown"] > ul,
body.dark-mode .autocomplete-results,
body.dark-mode .autocomplete-dropdown,
body.dark-mode .location-autocomplete-dropdown {
    background-color: var(--bg-card) !important;
    border-color: var(--border-color) !important;
    box-shadow: var(--shadow-lg);
}

body.dark-mode .dropdown-item,
body.dark-mode .dropdown-menu li,
body.dark-mode .autocomplete-item {
    color: var(--text-secondary) !important;
}

body.dark-mode .dropdown-item:hover,
body.dark-mode .dropdown-menu li:hover,
body.dark-mode .autocomplete-item:hover {
    background-color: var(--bg-hover) !important;
    color: var(--text-primary) !important;
}

/* Bordas e Divisores */
body.dark-mode .border,
body.dark-mode .border-t,
body.dark-mode .border-b,
body.dark-mode .border-l,
body.dark-mode .border-r,
body.dark-mode [class*="border-gray"],
body.dark-mode [class*="border-slate"] {
    border-color: var(--border-color) !important;
}

body.dark-mode hr,
body.dark-mode .divider {
    border-color: var(--border-color) !important;
}

/* Backgrounds Tailwind - Cores neutras */
body.dark-mode .bg-gray-50,
body.dark-mode .bg-gray-100,
body.dark-mode .bg-slate-50,
body.dark-mode .bg-slate-100 {
    background-color: var(--bg-input) !important;
}

body.dark-mode .bg-gray-200 {
    background-color: var(--bg-hover) !important;
}

/* Backgrounds Tailwind - Cores *-50 (containers claros) */
body.dark-mode .bg-blue-50 {
    background-color: rgba(59, 130, 246, 0.15) !important;
}

body.dark-mode .bg-green-50 {
    background-color: rgba(34, 197, 94, 0.15) !important;
}

body.dark-mode .bg-yellow-50 {
    background-color: rgba(234, 179, 8, 0.15) !important;
}

body.dark-mode .bg-purple-50 {
    background-color: rgba(168, 85, 247, 0.15) !important;
}

body.dark-mode .bg-indigo-50 {
    background-color: rgba(99, 102, 241, 0.15) !important;
}

body.dark-mode .bg-pink-50 {
    background-color: rgba(236, 72, 153, 0.15) !important;
}

body.dark-mode .bg-orange-50 {
    background-color: rgba(249, 115, 22, 0.15) !important;
}

body.dark-mode .bg-red-50 {
    background-color: rgba(239, 68, 68, 0.15) !important;
}

body.dark-mode .bg-cyan-50 {
    background-color: rgba(6, 182, 212, 0.15) !important;
}

body.dark-mode .bg-teal-50 {
    background-color: rgba(20, 184, 166, 0.15) !important;
}

/* Backgrounds Tailwind - Cores *-100 (icones/badges) */
body.dark-mode .bg-blue-100 {
    background-color: rgba(59, 130, 246, 0.25) !important;
}

body.dark-mode .bg-green-100 {
    background-color: rgba(34, 197, 94, 0.25) !important;
}

body.dark-mode .bg-yellow-100 {
    background-color: rgba(234, 179, 8, 0.25) !important;
}

body.dark-mode .bg-purple-100 {
    background-color: rgba(168, 85, 247, 0.25) !important;
}

body.dark-mode .bg-indigo-100 {
    background-color: rgba(99, 102, 241, 0.25) !important;
}

body.dark-mode .bg-pink-100 {
    background-color: rgba(236, 72, 153, 0.25) !important;
}

body.dark-mode .bg-orange-100 {
    background-color: rgba(249, 115, 22, 0.25) !important;
}

body.dark-mode .bg-red-100 {
    background-color: rgba(239, 68, 68, 0.25) !important;
}

body.dark-mode .bg-cyan-100 {
    background-color: rgba(6, 182, 212, 0.25) !important;
}

body.dark-mode .bg-teal-100 {
    background-color: rgba(20, 184, 166, 0.25) !important;
}

/* Gradientes de Stats/Cards */
body.dark-mode .bg-gradient-to-br.from-blue-50,
body.dark-mode [class*="from-blue-50"] {
    background: linear-gradient(to bottom right, #1e3a5f, #1e40af) !important;
    border-color: #3b82f6 !important;
}

body.dark-mode .bg-gradient-to-br.from-green-50,
body.dark-mode [class*="from-green-50"] {
    background: linear-gradient(to bottom right, #064e3b, #065f46) !important;
    border-color: #10b981 !important;
}

body.dark-mode .bg-gradient-to-br.from-purple-50,
body.dark-mode [class*="from-purple-50"] {
    background: linear-gradient(to bottom right, #4c1d95, #5b21b6) !important;
    border-color: #8b5cf6 !important;
}

body.dark-mode .bg-gradient-to-br.from-orange-50,
body.dark-mode [class*="from-orange-50"] {
    background: linear-gradient(to bottom right, #7c2d12, #9a3412) !important;
    border-color: #f97316 !important;
}

body.dark-mode .bg-gradient-to-br.from-red-50,
body.dark-mode [class*="from-red-50"] {
    background: linear-gradient(to bottom right, #7f1d1d, #991b1b) !important;
    border-color: #ef4444 !important;
}

body.dark-mode .bg-gradient-to-br.from-yellow-50,
body.dark-mode [class*="from-yellow-50"] {
    background: linear-gradient(to bottom right, #78350f, #92400e) !important;
    border-color: #f59e0b !important;
}

/* Badges e Tags */
body.dark-mode .badge,
body.dark-mode .tag {
    background-color: var(--bg-hover);
    color: var(--text-secondary);
    border-color: var(--border-color);
}

body.dark-mode .badge-success {
    background-color: var(--color-success-bg) !important;
    color: var(--color-success) !important;
}

body.dark-mode .badge-error {
    background-color: var(--color-error-bg) !important;
    color: var(--color-error) !important;
}

body.dark-mode .badge-warning {
    background-color: var(--color-warning-bg) !important;
    color: var(--color-warning) !important;
}

body.dark-mode .badge-info {
    background-color: var(--color-info-bg) !important;
    color: var(--color-info) !important;
}

/* Badges de papel/role */
body.dark-mode .papel-cliente {
    background-color: rgba(59, 130, 246, 0.2) !important;
    color: #93c5fd !important;
}

body.dark-mode .papel-fornecedor {
    background-color: rgba(245, 158, 11, 0.2) !important;
    color: #fcd34d !important;
}

body.dark-mode .papel-colaborador {
    background-color: rgba(16, 185, 129, 0.2) !important;
    color: #6ee7b7 !important;
}

body.dark-mode .papel-cpf-gerenciado {
    background-color: rgba(139, 92, 246, 0.2) !important;
    color: #c4b5fd !important;
}

body.dark-mode .papel-passageiro {
    background-color: rgba(6, 182, 212, 0.2) !important;
    color: #67e8f9 !important;
}

/* Loading Overlay */
body.dark-mode .loading-overlay {
    background: var(--bg-modal);
}

body.dark-mode .loading-overlay p,
body.dark-mode .loading-overlay span {
    color: var(--text-secondary);
}

/* Paginacao */
body.dark-mode .pagination,
body.dark-mode .page-link {
    background-color: var(--bg-card);
    border-color: var(--border-color);
    color: var(--text-secondary);
}

body.dark-mode .page-link:hover {
    background-color: var(--bg-hover);
    color: var(--text-primary);
}

body.dark-mode .page-item.active .page-link {
    background-color: var(--color-primary);
    border-color: var(--color-primary);
    color: var(--text-inverse);
}

/* Toggle Switch */
body.dark-mode .toggle-slider {
    background-color: var(--scrollbar-thumb);
}

body.dark-mode input:checked + .toggle-slider {
    background-color: var(--color-primary);
}

/* Alertas e Notificacoes */
body.dark-mode .alert-success {
    background-color: var(--color-success-bg) !important;
    border-color: var(--color-success-border) !important;
    color: var(--color-success) !important;
}

body.dark-mode .alert-error,
body.dark-mode .alert-danger {
    background-color: var(--color-error-bg) !important;
    border-color: var(--color-error-border) !important;
    color: var(--color-error) !important;
}

body.dark-mode .alert-warning {
    background-color: var(--color-warning-bg) !important;
    border-color: var(--color-warning-border) !important;
    color: var(--color-warning) !important;
}

body.dark-mode .alert-info {
    background-color: var(--color-info-bg) !important;
    border-color: var(--color-info-border) !important;
    color: var(--color-info) !important;
}

/* Tooltips */
body.dark-mode .tooltip,
body.dark-mode [role="tooltip"] {
    background-color: var(--bg-card) !important;
    color: var(--text-primary) !important;
    border-color: var(--border-color) !important;
    box-shadow: var(--shadow-md);
}

/* Tabs */
body.dark-mode .tab-active {
    border-bottom-color: var(--color-primary);
    color: var(--color-primary);
}

body.dark-mode .nav-tabs .nav-link {
    color: var(--text-secondary);
}

body.dark-mode .nav-tabs .nav-link:hover {
    color: var(--text-primary);
}

body.dark-mode .nav-tabs .nav-link.active {
    background-color: var(--bg-card);
    color: var(--color-primary);
    border-color: var(--border-color) var(--border-color) var(--bg-card);
}

/* Toasts / Notifications */
body.dark-mode .toast {
    background-color: var(--bg-card);
    border-color: var(--border-color);
    box-shadow: var(--shadow-lg);
}

body.dark-mode .toast-body {
    color: var(--text-primary);
}

/* Accordions / Collapsibles */
body.dark-mode .accordion-item {
    background-color: var(--bg-card);
    border-color: var(--border-color);
}

body.dark-mode .accordion-header,
body.dark-mode .accordion-button {
    background-color: var(--bg-secondary);
    color: var(--text-primary);
}

body.dark-mode .accordion-button:not(.collapsed) {
    background-color: var(--color-primary-light);
    color: var(--color-primary);
}

/* Progress Bars */
body.dark-mode .progress {
    background-color: var(--bg-hover);
}

body.dark-mode .progress-bar {
    background-color: var(--color-primary);
}

/* Form Groups e Labels */
body.dark-mode .form-group label,
body.dark-mode .input-group-text {
    color: var(--text-secondary);
    background-color: var(--bg-input);
    border-color: var(--border-color);
}

/* Checkbox e Radio */
body.dark-mode input[type="checkbox"],
body.dark-mode input[type="radio"] {
    accent-color: var(--color-primary);
}

/* Labels com radio/checkbox selecionados - corrigir fundo branco */
body.dark-mode label:has(input[type="radio"]:checked),
body.dark-mode label:has(input[type="checkbox"]:checked) {
    background-color: rgba(6, 182, 212, 0.15) !important;
    border-color: #06b6d4 !important;
}

body.dark-mode label:has(input[type="radio"]):not(:has(input:checked)),
body.dark-mode label:has(input[type="checkbox"]):not(:has(input:checked)) {
    background-color: var(--bg-card) !important;
    border-color: var(--border-color) !important;
}

body.dark-mode label:has(input[type="radio"]):hover,
body.dark-mode label:has(input[type="checkbox"]):hover {
    border-color: #0891b2 !important;
    background-color: rgba(6, 182, 212, 0.1) !important;
}

/* Links */
body.dark-mode a:not(.nav-item):not(.nav-link) {
    color: var(--color-primary);
}

body.dark-mode a:not(.nav-item):not(.nav-link):hover {
    color: var(--color-primary-hover);
}

/* Code e Pre */
body.dark-mode code,
body.dark-mode pre {
    background-color: var(--bg-input);
    color: var(--text-primary);
    border-color: var(--border-color);
}

/* Empty State / No Data */
body.dark-mode .empty-state,
body.dark-mode .no-data {
    color: var(--text-muted);
}

/* Filtros e Search */
body.dark-mode .search-box,
body.dark-mode .filter-box {
    background-color: var(--bg-input);
    border-color: var(--border-color);
}

body.dark-mode .search-box:focus-within,
body.dark-mode .filter-box:focus-within {
    border-color: var(--border-focus);
}

/* Chips / Tags Inline */
body.dark-mode .chip,
body.dark-mode .tag-inline {
    background-color: var(--bg-hover);
    color: var(--text-secondary);
}

body.dark-mode .chip:hover,
body.dark-mode .tag-inline:hover {
    background-color: var(--border-light);
}

/* Container de cartoes de credito */
body.dark-mode .cartoes-container,
body.dark-mode .cards-grid {
    background-color: var(--bg-secondary);
}

/* Container de cartoes arrastavel (pagina cartoes) */
body.dark-mode .draggable-credit-card-container {
    background-color: var(--bg-card) !important;
    border-color: var(--border-color) !important;
}

/* Calendario */
body.dark-mode .calendar-cell,
body.dark-mode .calendar-day {
    background-color: var(--bg-card);
    color: var(--text-secondary);
}

body.dark-mode .calendar-day-today {
    background-color: rgba(59, 130, 246, 0.3) !important;
    color: var(--text-primary) !important;
}

body.dark-mode .calendar-day:hover {
    background-color: var(--bg-hover);
}

/* Bank logo em cartoes */
body.dark-mode .bank-logo {
    background-color: rgba(255, 255, 255, 0.15) !important;
}

/* ============================================
   SUMMARY CARDS - Usados em Contas a Pagar/Receber, Cartoes
   (Classes definidas em inline <style> com background: white)
   Alta especificidade para sobrescrever inline styles
   ============================================ */
html.dark-mode body.dark-mode .summary-card,
html.dark-mode .summary-card,
body.dark-mode .summary-card,
.dark-mode .summary-card {
    background-color: var(--bg-card) !important;
    border-color: var(--border-color) !important;
    box-shadow: var(--shadow-sm) !important;
}

body.dark-mode .summary-card-label {
    color: var(--text-muted) !important;
}

body.dark-mode .summary-card-value {
    color: var(--text-primary) !important;
}

/* Manter cores especificas dos valores em summary cards */
body.dark-mode .summary-card .text-red-600 { color: #f87171 !important; }
body.dark-mode .summary-card .text-yellow-600 { color: #fbbf24 !important; }
body.dark-mode .summary-card .text-green-600 { color: #4ade80 !important; }
body.dark-mode .summary-card .text-blue-600,
body.dark-mode .summary-card .text-blue-700 { color: #60a5fa !important; }
body.dark-mode .summary-card .text-gray-700 { color: var(--text-secondary) !important; }

/* ============================================
   BANK CARDS - Pagina de Bancos/Contas
   Alta especificidade para sobrescrever inline styles
   ============================================ */
html.dark-mode body.dark-mode .bank-card,
html.dark-mode .bank-card,
body.dark-mode .bank-card,
.dark-mode .bank-card {
    background-color: var(--bg-card) !important;
    border-color: var(--border-color) !important;
    box-shadow: var(--shadow-sm) !important;
}

html.dark-mode body.dark-mode .bank-card:hover,
html.dark-mode .bank-card:hover,
body.dark-mode .bank-card:hover,
.dark-mode .bank-card:hover {
    box-shadow: var(--shadow-md) !important;
}

body.dark-mode .archived-account {
    background-color: var(--bg-secondary) !important;
    border-color: var(--border-color) !important;
    opacity: 0.7;
}

body.dark-mode .archived-badge {
    background-color: var(--bg-hover) !important;
    color: var(--text-muted) !important;
}

/* ============================================
   MONTH NAVIGATION - Navegacao de mes
   ============================================ */
body.dark-mode .month-navigation {
    background-color: var(--bg-card) !important;
    border-color: var(--border-color) !important;
    box-shadow: var(--shadow-sm) !important;
}

body.dark-mode .month-display {
    color: var(--text-primary) !important;
}

body.dark-mode .month-nav-button {
    color: var(--color-primary) !important;
}

body.dark-mode .month-nav-button:hover {
    background-color: var(--bg-hover) !important;
}

body.dark-mode .month-totals-header {
    background-color: var(--bg-card) !important;
    border-color: var(--border-color) !important;
    box-shadow: var(--shadow-sm) !important;
}

body.dark-mode .month-total-label {
    color: var(--text-muted) !important;
}

body.dark-mode .month-total-value {
    color: var(--text-primary) !important;
}

/* ============================================
   SEARCH SELECT - Inputs de busca customizados
   Alta especificidade para sobrescrever inline styles
   ============================================ */
html.dark-mode body.dark-mode .search-select-container input,
html.dark-mode body.dark-mode .search-select-input,
html.dark-mode .search-select-container input,
html.dark-mode .search-select-input,
body.dark-mode .search-select-container input,
body.dark-mode .search-select-input,
.dark-mode .search-select-container input,
.dark-mode .search-select-input {
    background-color: var(--bg-input) !important;
    border-color: var(--border-color) !important;
    color: var(--text-primary) !important;
}

html.dark-mode body.dark-mode .search-select-input:focus,
html.dark-mode .search-select-input:focus,
body.dark-mode .search-select-input:focus,
.dark-mode .search-select-input:focus {
    border-color: var(--border-focus) !important;
    box-shadow: 0 0 0 2px rgba(96, 165, 250, 0.25) !important;
}

html.dark-mode body.dark-mode .search-select-dropdown,
html.dark-mode .search-select-dropdown,
body.dark-mode .search-select-dropdown,
.dark-mode .search-select-dropdown {
    background-color: var(--bg-card) !important;
    border-color: var(--border-color) !important;
    box-shadow: var(--shadow-lg) !important;
}

body.dark-mode .search-select-option {
    color: var(--text-secondary) !important;
    border-bottom-color: var(--border-color) !important;
}

body.dark-mode .search-select-option:hover {
    background-color: var(--bg-hover) !important;
    color: var(--text-primary) !important;
}

body.dark-mode .search-select-option.selected {
    background-color: rgba(59, 130, 246, 0.2) !important;
    color: var(--color-primary) !important;
}

body.dark-mode .search-select-no-results {
    color: var(--text-muted) !important;
}

/* ============================================
   STAT CARDS - Dashboard, CRM, Relatorios
   ============================================ */
body.dark-mode .stat-card {
    background-color: var(--bg-card) !important;
    border-color: var(--border-color) !important;
    box-shadow: var(--shadow-sm) !important;
}

body.dark-mode .stat-card:hover {
    box-shadow: var(--shadow-md) !important;
}

/* ============================================
   CONTA CARD - Cards de contas bancarias
   ============================================ */
body.dark-mode .conta-card {
    background-color: var(--bg-card) !important;
    border-color: var(--border-color) !important;
}

/* ============================================
   CREDIT CARD PREVIEW - Preview do cartao de credito
   ============================================ */
body.dark-mode .credit-card-preview,
body.dark-mode .card-preview,
body.dark-mode .cartao-preview {
    background-color: var(--bg-secondary) !important;
    border-color: var(--border-color) !important;
}

/* ============================================
   DETAILS PANEL - Painel de detalhes
   ============================================ */
body.dark-mode .details-panel,
body.dark-mode .detail-panel,
body.dark-mode .card-details {
    background-color: var(--bg-card) !important;
    border-color: var(--border-color) !important;
}

/* ============================================
   TRANSACTION ITEMS - Itens de transacao expandidos
   ============================================ */
body.dark-mode .transaction-item,
body.dark-mode .transacao-item {
    background-color: var(--bg-card) !important;
    border-color: var(--border-color) !important;
}

body.dark-mode .transaction-item:hover,
body.dark-mode .transacao-item:hover {
    background-color: var(--bg-hover) !important;
}

body.dark-mode .transaction-details,
body.dark-mode .transacao-detalhes {
    background-color: var(--bg-secondary) !important;
    border-color: var(--border-color) !important;
}

/* ============================================
   TRANSACTION CARDS — estilo UNIFICADO (claro + escuro) em transacoes.html,
   usando var(--bg-card)/var(--border-color). Removidas as regras-espelho
   `body.dark-mode .transaction-card[...]` daqui: eram duplicação e a fonte do
   bug do card branco (tipo novo sem espelho no dark). Agora é impossível.
   ============================================ */

/* ============================================
   CARTAO ADICIONAL CARD - Cards de cartao adicional
   ============================================ */
body.dark-mode .cartao-adicional-card {
    background-color: var(--bg-card) !important;
    border-color: var(--border-color) !important;
    box-shadow: var(--shadow-sm) !important;
}

body.dark-mode .cartao-adicional-card:hover {
    box-shadow: var(--shadow-md) !important;
    border-color: var(--color-primary) !important;
}

body.dark-mode .cartao-adicional-card.arquivado {
    background-color: var(--bg-secondary) !important;
    opacity: 0.7;
}

/* ============================================
   TABS - Navegacao por abas
   ============================================ */
body.dark-mode .tab-button {
    color: var(--text-muted) !important;
}

body.dark-mode .tab-button:hover {
    color: var(--color-primary) !important;
}

body.dark-mode .tab-button.active {
    color: var(--color-primary) !important;
    border-bottom-color: var(--color-primary) !important;
}

body.dark-mode .tab-content {
    background-color: var(--bg-card) !important;
}

/* ============================================
   STATUS BADGES - Badges de status
   ============================================ */
body.dark-mode .status-ativo {
    background-color: rgba(34, 197, 94, 0.2) !important;
    color: #4ade80 !important;
}

body.dark-mode .status-inativo {
    background-color: var(--bg-hover) !important;
    color: var(--text-muted) !important;
}

body.dark-mode .status-bloqueado {
    background-color: rgba(239, 68, 68, 0.2) !important;
    color: #f87171 !important;
}

body.dark-mode .status-pendente {
    background-color: rgba(245, 158, 11, 0.2) !important;
    color: #fbbf24 !important;
}

body.dark-mode .status-confirmado,
body.dark-mode .status-pago {
    background-color: rgba(34, 197, 94, 0.2) !important;
    color: #4ade80 !important;
}

body.dark-mode .status-em-aberto,
body.dark-mode .status-vencido {
    background-color: rgba(239, 68, 68, 0.2) !important;
    color: #f87171 !important;
}

/* ============================================
   VALOR NEGATIVO - Sempre vermelho (light + dark)
   Aplicado pelo scanner global js/libraries/valor-negativo-global.js:
   todo número exibido < 0 ganha .valor-negativo. var(--color-error) é
   vermelho nos dois temas (#ef4444 claro / #f87171 dark).
   ============================================ */
.valor-negativo,
.valor-negativo * {
    color: var(--color-error) !important;
}

/* ============================================
   ACTION BUTTONS - Botoes de acao
   ============================================ */
body.dark-mode .action-button {
    color: var(--text-muted) !important;
}

body.dark-mode .action-button:hover {
    background-color: var(--bg-hover) !important;
    color: var(--text-primary) !important;
}

body.dark-mode .action-button-pay {
    background-color: rgba(34, 197, 94, 0.2) !important;
    color: #4ade80 !important;
}

body.dark-mode .action-button-pay:hover {
    background-color: rgba(34, 197, 94, 0.3) !important;
}

/* ============================================
   OVERRIDE PARA INLINE STYLES
   Muitos arquivos HTML usam cor de fundo literal via style=
   Precisamos sobrescrever com alta especificidade
   ============================================ */

/* Headers de pagina com bg-white */
body.dark-mode header.bg-white,
body.dark-mode header[class*="bg-white"],
body.dark-mode .bg-white {
    background-color: var(--bg-card) !important;
    border-color: var(--border-color) !important;
}

/* Divs com style inline - usar atributo selector */
body.dark-mode div[style*="background: white"],
body.dark-mode div[style*="background:#fff"],
body.dark-mode div[style*="background: #fff"],
body.dark-mode div[style*="background:#ffffff"],
body.dark-mode div[style*="background: #ffffff"],
body.dark-mode section[style*="background: white"],
body.dark-mode article[style*="background: white"],
body.dark-mode main[style*="background: white"],
body.dark-mode aside[style*="background: white"],
body.dark-mode header[style*="background: white"],
body.dark-mode footer[style*="background: white"],
body.dark-mode form[style*="background: white"],
body.dark-mode [style*="background: white"],
body.dark-mode [style*="background:#fff"],
body.dark-mode [style*="background: #fff"],
body.dark-mode [style*="background:#ffffff"],
body.dark-mode [style*="background: #ffffff"] {
    background-color: var(--bg-card) !important;
}

/* Modais com inline style */
body.dark-mode div[style*="position: fixed"][style*="background: white"],
body.dark-mode div[style*="position:fixed"][style*="background: white"],
body.dark-mode .modal-content[style*="background"],
body.dark-mode [class*="modal"][style*="background: white"] {
    background-color: var(--bg-card) !important;
    border-color: var(--border-color) !important;
    color: var(--text-primary) !important;
}

/* Cards e containers gerados por CSS interno */
body.dark-mode .contato-item,
body.dark-mode .location-autocomplete-dropdown,
body.dark-mode .autocomplete-dropdown,
body.dark-mode .dropdown-content {
    background-color: var(--bg-card) !important;
    border-color: var(--border-color) !important;
}

/* Badges de papel/role com cores claras */
body.dark-mode .papel-badge,
body.dark-mode .papel-cliente,
body.dark-mode .papel-fornecedor,
body.dark-mode .papel-colaborador,
body.dark-mode .papel-cpf-gerenciado,
body.dark-mode .papel-passageiro {
    border: 1px solid currentColor !important;
}

/* Celulas de tabela e headers - sobrescrever inline styles */
body.dark-mode thead[style],
body.dark-mode th[style],
body.dark-mode thead th[style*="background"] {
    background-color: var(--bg-table-header) !important;
    color: var(--text-secondary) !important;
}

body.dark-mode tbody tr[style*="background"],
body.dark-mode td[style*="background"] {
    background-color: var(--bg-card) !important;
}

/* Container principal de conteudo */
body.dark-mode .content-area,
body.dark-mode .main-content,
body.dark-mode .page-content,
body.dark-mode #content {
    background-color: var(--bg-primary) !important;
}

/* ============================================
   TRANSICAO SUAVE (so para cores, nao layout)
   ============================================ */
body.dark-mode *,
body.dark-mode *::before,
body.dark-mode *::after {
    transition-property: background-color, border-color, color;
    transition-duration: 0.15s;
    transition-timing-function: ease-out;
}

/* Desativar transicao em animacoes especificas */
body.dark-mode .no-transition,
body.dark-mode .animate-spin,
body.dark-mode .animate-pulse,
body.dark-mode .animate-bounce {
    transition: none !important;
}

/* ============================================
   OVERRIDES FINAIS DE ALTA PRIORIDADE
   Estes seletores devem sobrescrever inline styles
   que definem background: white em <style> tags
   ============================================ */

/* Summary Cards - Força dark mode mesmo com inline styles */
html.dark-mode body .summary-card,
html.dark-mode .summary-card,
body.dark-mode .summary-card {
    background-color: #1f1f1f !important;
    border-color: #333333 !important;
}

/* Bank Cards - Força dark mode */
html.dark-mode body .bank-card,
html.dark-mode .bank-card,
body.dark-mode .bank-card {
    background-color: #1f1f1f !important;
    border-color: #333333 !important;
}

/* Modal Content - Força dark mode */
html.dark-mode body .modal-content,
html.dark-mode .modal-content,
body.dark-mode .modal-content {
    background-color: #1f1f1f !important;
    border-color: #333333 !important;
}

/* Search Select - Força dark mode */
html.dark-mode body .search-select-input,
html.dark-mode .search-select-input,
body.dark-mode .search-select-input {
    background-color: #262626 !important;
    border-color: #333333 !important;
    color: #f5f5f5 !important;
}

html.dark-mode body .search-select-dropdown,
html.dark-mode .search-select-dropdown,
body.dark-mode .search-select-dropdown {
    background-color: #1f1f1f !important;
    border-color: #333333 !important;
}

/* Classe bg-white do Tailwind em dark mode */
html.dark-mode body .bg-white:not(.sidebar *):not(.modern-sidebar *):not([data-no-dark]),
html.dark-mode .bg-white:not(.sidebar *):not(.modern-sidebar *):not([data-no-dark]),
body.dark-mode .bg-white:not(.sidebar *):not(.modern-sidebar *):not([data-no-dark]) {
    background-color: #1f1f1f !important;
}

/* ============================================
   CHART.JS - Gráficos
   Configuração de cores para dark mode
   ============================================ */
body.dark-mode canvas {
    /* Canvas não precisa de background, mas garantir que não tenha branco */
    background-color: transparent !important;
}

/* Container de gráficos */
body.dark-mode .chart-container,
body.dark-mode .chart-wrapper,
body.dark-mode [class*="chart-"] {
    background-color: var(--bg-card) !important;
    border-color: var(--border-color) !important;
}

/* ============================================
   LOADING OVERLAYS - Indicadores de carregamento
   ============================================ */
body.dark-mode .loading-overlay,
body.dark-mode .loading-indicator,
body.dark-mode [class*="loading"] > div,
body.dark-mode #loadingIndicator > div {
    background-color: var(--bg-card) !important;
    color: var(--text-primary) !important;
    border-color: var(--border-color) !important;
}

body.dark-mode .loading-spinner {
    border-color: var(--border-color) !important;
    border-top-color: var(--color-primary) !important;
}

/* ============================================
   CALENDAR - Calendário
   ============================================ */
body.dark-mode .calendar-grid,
body.dark-mode .calendar-body,
body.dark-mode #calendar-body {
    background-color: transparent;
}

body.dark-mode .calendar-cell {
    background-color: var(--bg-card);
    color: var(--text-secondary);
}

body.dark-mode .calendar-day {
    color: var(--text-secondary) !important;
}

body.dark-mode .calendar-day-header {
    color: var(--text-muted) !important;
}

body.dark-mode .calendar-day-today {
    background-color: rgba(59, 130, 246, 0.3) !important;
    color: #93c5fd !important;
}

body.dark-mode .calendar-day-other-month {
    color: var(--text-light) !important;
}

body.dark-mode .calendar-day-checkin {
    background-color: rgba(34, 197, 94, 0.3) !important;
    color: #6ee7b7 !important;
}

body.dark-mode .calendar-day-checkin::after {
    background-color: #4ade80 !important;
}

body.dark-mode #calendar-header {
    color: var(--text-primary) !important;
}

/* ============================================
   PERIOD SELECTOR - Seletor de período
   ============================================ */
body.dark-mode .period-selector {
    background-color: var(--bg-card) !important;
    border-color: var(--border-color) !important;
}

body.dark-mode .period-btn {
    color: var(--text-secondary) !important;
    background-color: transparent !important;
}

body.dark-mode .period-btn:hover {
    background-color: var(--bg-hover) !important;
    color: var(--text-primary) !important;
}

body.dark-mode .period-btn.active {
    background-color: var(--color-primary) !important;
    color: white !important;
}

/* ============================================
   TAGS - Sistema de tags
   ============================================ */
body.dark-mode .tag-option {
    /* Tags mantêm sua cor de fundo própria */
}

body.dark-mode .tag-badge {
    /* Fundo/borda/bolinha mantêm a cor da tag (inline). Só a FONTE vira branca p/
       contraste sobre o fundo translúcido escuro — em vez de ficar na cor da tag. */
    color: #fff !important;
}
/* "x" de remover: branco e SEM o círculo escuro no hover (o hover:bg-gray-200 era
   invertido p/ cinza-escuro no dark). Hover vira um realce branco sutil. */
body.dark-mode .tag-badge .remove-tag,
body.dark-mode .tag-badge .remove-tag i {
    color: #fff !important;
}
body.dark-mode .tag-badge .remove-tag:hover {
    background-color: rgba(255, 255, 255, 0.22) !important;
}

body.dark-mode #tagSelectorModal > div,
body.dark-mode .tag-selector-modal {
    background-color: var(--bg-card) !important;
    border-color: var(--border-color) !important;
    color: var(--text-primary) !important;
}

body.dark-mode #tagsContainer,
body.dark-mode #tagsGrid {
    background-color: transparent !important;
}

/* ============================================
   PROGRAM CARDS - Cards de programas de fidelidade
   ============================================ */
body.dark-mode .program-card {
    background-color: var(--bg-card) !important;
    border-color: var(--border-color) !important;
    color: var(--text-primary) !important;
}

body.dark-mode .program-card:hover {
    border-color: var(--border-light) !important;
    box-shadow: var(--shadow-md) !important;
}

body.dark-mode .program-logo {
    /* Mantém cor do programa */
}

/* ============================================
   DATA BADGES - Badges de métricas
   ============================================ */
body.dark-mode .data-badge {
    border: 1px solid currentColor;
}

body.dark-mode .badge-success {
    background-color: rgba(34, 197, 94, 0.2) !important;
    color: #4ade80 !important;
}

body.dark-mode .badge-warning {
    background-color: rgba(245, 158, 11, 0.2) !important;
    color: #fbbf24 !important;
}

body.dark-mode .badge-danger {
    background-color: rgba(239, 68, 68, 0.2) !important;
    color: #f87171 !important;
}

body.dark-mode .badge-info {
    background-color: rgba(59, 130, 246, 0.2) !important;
    color: #60a5fa !important;
}

/* ============================================
   METRIC VALUES - Valores de métricas
   ============================================ */
body.dark-mode .metric-value {
    background: linear-gradient(135deg, #93c5fd 0%, #c4b5fd 100%) !important;
    -webkit-background-clip: text !important;
    -webkit-text-fill-color: transparent !important;
}

/* ============================================
   FILTER CONTAINERS - Containers de filtros
   ============================================ */
body.dark-mode .filter-container,
body.dark-mode .filters-row,
body.dark-mode [class*="filter-box"] {
    background-color: var(--bg-card) !important;
    border-color: var(--border-color) !important;
}

/* ============================================
   EMISSOES PAGE - Página de emissões (103 bg-white)
   ============================================ */
body.dark-mode .emissao-card,
body.dark-mode .emissao-item,
body.dark-mode .emissao-detalhes {
    background-color: var(--bg-card) !important;
    border-color: var(--border-color) !important;
    color: var(--text-primary) !important;
}

body.dark-mode .emissao-header {
    background-color: var(--bg-secondary) !important;
    border-color: var(--border-color) !important;
}

/* ============================================
   PASSAGEIRO CARDS - Cards de passageiros
   ============================================ */
body.dark-mode .passageiro-card,
body.dark-mode .passageiro-item {
    background-color: var(--bg-card) !important;
    border-color: var(--border-color) !important;
}

/* ============================================
   VOOS / FLIGHT INFO - Informações de voo
   ============================================ */
body.dark-mode .voo-card,
body.dark-mode .flight-info,
body.dark-mode .voo-item {
    background-color: var(--bg-card) !important;
    border-color: var(--border-color) !important;
}

body.dark-mode .voo-header {
    background-color: var(--bg-secondary) !important;
}

/* ============================================
   LOCALIZADOR - Badge de localizador
   ============================================ */
body.dark-mode .localizador-badge {
    background-color: var(--bg-hover) !important;
    color: var(--text-primary) !important;
    border-color: var(--border-color) !important;
}

/* ============================================
   QUICK ACCESS - Menu de acesso rápido
   ============================================ */
body.dark-mode .quick-access-card,
body.dark-mode [class*="quick-access"] {
    background-color: var(--bg-card) !important;
    border-color: var(--border-color) !important;
}

/* Links de acesso rápido com bg-*-50 */
body.dark-mode a.bg-blue-50,
body.dark-mode a.bg-green-50,
body.dark-mode a.bg-purple-50,
body.dark-mode a.bg-orange-50 {
    /* Usar cores semi-transparentes */
}

body.dark-mode a.bg-blue-50:hover,
body.dark-mode a[class*="bg-blue-50"]:hover {
    background-color: rgba(59, 130, 246, 0.25) !important;
}

body.dark-mode a.bg-green-50:hover,
body.dark-mode a[class*="bg-green-50"]:hover {
    background-color: rgba(34, 197, 94, 0.25) !important;
}

body.dark-mode a.bg-purple-50:hover,
body.dark-mode a[class*="bg-purple-50"]:hover {
    background-color: rgba(168, 85, 247, 0.25) !important;
}

body.dark-mode a.bg-orange-50:hover,
body.dark-mode a[class*="bg-orange-50"]:hover {
    background-color: rgba(249, 115, 22, 0.25) !important;
}

/* ============================================
   RESUMO FINANCEIRO - Seção de resumo
   ============================================ */
body.dark-mode .resumo-financeiro,
body.dark-mode .financial-summary {
    background-color: var(--bg-card) !important;
    border-color: var(--border-color) !important;
}

/* ============================================
   TAREFAS / TASKS - Lista de tarefas
   ============================================ */
body.dark-mode .tarefa-item,
body.dark-mode .task-item,
body.dark-mode li[class*="bg-red-50"],
body.dark-mode li[class*="bg-green-50"],
body.dark-mode li[class*="bg-blue-50"] {
    background-color: var(--bg-secondary) !important;
    border-color: var(--border-color) !important;
}

/* ============================================
   FORÇAR DARK MODE EM ELEMENTOS ESPECÍFICOS
   Alta especificidade para sobrescrever tudo
   ============================================ */

/* Containers com shadow dentro de body.dark-mode — EXCLUI button: um botão
   (ex.: bg-indigo-600 rounded-lg shadow-sm) NÃO é card e não deve virar #1f1f1f.
   (Causa do bug do "Novo Lançamento" sem fundo — ver docs/design-system/ESTUDO.md) */
html.dark-mode body .rounded-lg.shadow:not(button),
html.dark-mode body .rounded-lg.shadow-sm:not(button),
html.dark-mode body .rounded-lg.shadow-md:not(button),
html.dark-mode body .rounded-lg.shadow-lg:not(button) {
    background-color: var(--bg-card) !important;
    border-color: var(--border-color) !important;
}

/* Elementos p-4/p-5/p-6 com bg-white (cards genéricos) */
html.dark-mode body div.p-4.bg-white,
html.dark-mode body div.p-5.bg-white,
html.dark-mode body div.p-6.bg-white,
html.dark-mode body div[class*="p-4"][class*="bg-white"],
html.dark-mode body div[class*="p-5"][class*="bg-white"],
html.dark-mode body div[class*="p-6"][class*="bg-white"] {
    background-color: var(--bg-card) !important;
}

/* ============================================
   TAILWIND GRAY BACKGROUNDS - bg-gray-50, bg-gray-100
   Muito usados em cards, modais e containers
   ============================================ */
body.dark-mode .bg-gray-50,
body.dark-mode [class*="bg-gray-50"] {
    background-color: #2a2a2a !important;
}

body.dark-mode .bg-gray-100,
body.dark-mode [class*="bg-gray-100"] {
    background-color: #262626 !important;
}

/* ============================================
   GRADIENTES CLAROS - from-*-50 to-*-50
   Usados em seletores de tipo de transação, etc
   ============================================ */
/* :not(button): ATENÇÃO — [class*="from-yellow-50"] casa TAMBÉM "from-yellow-500" (o 500
   contém "...50"). Sem excluir button, os botões de status com gradiente from-X-500
   (vermelho/amarelo/verde) escureciam p/ #2a2a2a perdendo a cor. Excluir button preserva
   as cores semânticas dos botões no dark; os cards/avisos claros (from-X-50) seguem escuros. */
body.dark-mode [class*="from-cyan-50"]:not(button),
body.dark-mode [class*="from-blue-50"]:not(button),
body.dark-mode [class*="from-green-50"]:not(button),
body.dark-mode [class*="from-purple-50"]:not(button),
body.dark-mode [class*="from-orange-50"]:not(button),
body.dark-mode [class*="from-red-50"]:not(button),
body.dark-mode [class*="from-yellow-50"]:not(button),
body.dark-mode [class*="from-pink-50"]:not(button),
body.dark-mode [class*="from-indigo-50"]:not(button) {
    background: #2a2a2a !important;
}

body.dark-mode .bg-gradient-to-r[class*="from-cyan-50"],
body.dark-mode .bg-gradient-to-r[class*="from-blue-50"],
body.dark-mode .bg-gradient-to-r[class*="from-green-50"] {
    background: linear-gradient(to right, rgba(0, 100, 150, 0.2), rgba(0, 50, 100, 0.2)) !important;
}

/* ============================================
   BOTÕES CANCELAR - bg-white com text-gray-700
   Ficavam ilegíveis no dark mode
   ============================================ */
body.dark-mode button.bg-white,
body.dark-mode button[class*="bg-white"],
body.dark-mode .btn.bg-white {
    background-color: #2a2a2a !important;
    color: #e5e5e5 !important;
    border-color: #404040 !important;
}

body.dark-mode button.bg-white:hover,
body.dark-mode button[class*="bg-white"]:hover {
    background-color: #333333 !important;
}

/* ============================================
   FOOTER DE MODAIS - div com bg-gray-50 border-t
   Contém botões de ação (Cancelar, Salvar)
   ============================================ */
body.dark-mode .border-t.bg-gray-50,
body.dark-mode div[class*="border-t"][class*="bg-gray-50"],
body.dark-mode .flex.justify-end.space-x-3[class*="bg-gray-50"] {
    background-color: #1a1a1a !important;
    border-color: #333333 !important;
}

/* ============================================
   CARDS DE RESUMO DO DASHBOARD
   (Saldo, Receitas, Despesas, Milhas Expiradas)
   ============================================ */
body.dark-mode .stat-card,
body.dark-mode .summary-card,
body.dark-mode .metric-card,
body.dark-mode [class*="rounded-lg"][class*="shadow"][class*="p-4"],
body.dark-mode [class*="rounded-lg"][class*="shadow"][class*="p-5"],
body.dark-mode [class*="rounded-lg"][class*="shadow"][class*="p-6"] {
    background-color: #1f1f1f !important;
    border-color: #333333 !important;
}

/* ============================================
   CONFIGURAÇÃO DE REPETIÇÃO/PARCELAMENTO
   Container bg-gray-50 dentro dos modais
   ============================================ */
body.dark-mode .repetition-config .bg-gray-50,
body.dark-mode .repetition-config > div,
body.dark-mode #repeticaoDespesaConfig .bg-gray-50,
body.dark-mode #repeticaoReceitaConfig .bg-gray-50,
body.dark-mode #repeticaoTransferenciaConfig .bg-gray-50 {
    background-color: #262626 !important;
    border-color: #404040 !important;
}

/* ============================================
   SEÇÃO TITULAR/PROGRAMA - bg-blue-50
   Container azul claro para seleção de titular
   ============================================ */
body.dark-mode [id*="secao-titular-programa"],
body.dark-mode .bg-blue-50 {
    background-color: rgba(59, 130, 246, 0.15) !important;
    border-color: rgba(59, 130, 246, 0.4) !important;
}

body.dark-mode [id*="secao-titular-programa"] label,
body.dark-mode .bg-blue-50 label {
    color: #93c5fd !important;
}

/* ============================================
   CASHBACK SECTION - bg-green-50, bg-green-100
   Container verde para configuração de cashback
   ============================================ */
body.dark-mode .bg-green-50,
body.dark-mode [class*="bg-green-50"] {
    background-color: rgba(34, 197, 94, 0.15) !important;
    border-color: rgba(34, 197, 94, 0.4) !important;
}

body.dark-mode .bg-green-100,
body.dark-mode [class*="bg-green-100"] {
    background-color: rgba(34, 197, 94, 0.2) !important;
}

/* ============================================
   LABELS E TEXTOS DENTRO DE CONTAINERS
   text-gray-700, text-gray-600, text-gray-500
   ============================================ */
body.dark-mode .text-gray-700 {
    color: #d4d4d4 !important;
}

body.dark-mode .text-gray-600 {
    color: #a3a3a3 !important;
}

body.dark-mode .text-gray-500 {
    color: #737373 !important;
}

body.dark-mode .text-gray-900 {
    color: #f5f5f5 !important;
}

/* ============================================
   HOVER STATES - hover:bg-gray-50, hover:bg-gray-100
   ============================================ */
body.dark-mode [class*="hover\\:bg-gray-50"]:hover {
    background-color: #333333 !important;
}

body.dark-mode [class*="hover\\:bg-gray-100"]:hover {
    background-color: #2a2a2a !important;
}

/* ============================================
   BORDER COLORS - border-gray-*
   ============================================ */
body.dark-mode .border-gray-100 {
    border-color: #333333 !important;
}

body.dark-mode .border-gray-200 {
    border-color: #404040 !important;
}

body.dark-mode .border-gray-300 {
    border-color: #525252 !important;
}

/* ============================================
   AUTOCOMPLETE DROPDOWN ITEMS
   Itens de resultado com hover:bg-gray-50
   ============================================ */
body.dark-mode .p-3.hover\\:bg-gray-50,
body.dark-mode [class*="hover:bg-gray-50"].cursor-pointer {
    background-color: transparent !important;
}

body.dark-mode .p-3.hover\\:bg-gray-50:hover,
body.dark-mode [class*="hover:bg-gray-50"].cursor-pointer:hover {
    background-color: #333333 !important;
}

/* ============================================
   TRANSACTION DETAIL ROW - Item expandido
   bg-gray-50 com detalhes da transação
   ============================================ */
body.dark-mode .transaction-detail,
body.dark-mode .transacao-detalhe,
body.dark-mode tr.bg-gray-50,
body.dark-mode .bg-gray-50.p-3.rounded-lg {
    background-color: #262626 !important;
    border-color: #404040 !important;
}

/* ============================================
   HISTORY CHANGES - Alterações em histórico
   ============================================ */
body.dark-mode .bg-gray-50.rounded.p-3 {
    background-color: #262626 !important;
}

/* ============================================
   INPUT CONTAINERS - Labels e campos
   ============================================ */
body.dark-mode .block.text-sm.font-medium.text-gray-700 {
    color: #d4d4d4 !important;
}

body.dark-mode label.flex.items-center {
    color: #d4d4d4 !important;
}

/* ============================================
   MODAL CONTENT GENERAL - Forçar fundo escuro
   ============================================ */
body.dark-mode .modal-content {
    background-color: #1f1f1f !important;
}

body.dark-mode .modal-content form {
    background-color: transparent !important;
}

/* ============================================
   BLUE BACKGROUNDS - bg-blue-100, bg-blue-200
   ============================================ */
body.dark-mode .bg-blue-100 {
    background-color: rgba(59, 130, 246, 0.2) !important;
}

body.dark-mode .bg-blue-200 {
    background-color: rgba(59, 130, 246, 0.3) !important;
}

/* ============================================
   CYAN BACKGROUNDS - bg-cyan-50, bg-cyan-100
   ============================================ */
body.dark-mode .bg-cyan-50 {
    background-color: rgba(14, 165, 233, 0.15) !important;
}

body.dark-mode .bg-cyan-100 {
    background-color: rgba(14, 165, 233, 0.2) !important;
}

/* ============================================
   PURPLE/VIOLET BACKGROUNDS
   ============================================ */
body.dark-mode .bg-purple-50 {
    background-color: rgba(168, 85, 247, 0.15) !important;
}

body.dark-mode .bg-purple-100 {
    background-color: rgba(168, 85, 247, 0.2) !important;
}

/* ============================================
   ORANGE/AMBER BACKGROUNDS
   ============================================ */
body.dark-mode .bg-orange-50 {
    background-color: rgba(249, 115, 22, 0.15) !important;
}

body.dark-mode .bg-orange-100 {
    background-color: rgba(249, 115, 22, 0.2) !important;
}

/* ============================================
   RED/ROSE BACKGROUNDS
   ============================================ */
body.dark-mode .bg-red-50 {
    background-color: rgba(239, 68, 68, 0.15) !important;
}

body.dark-mode .bg-red-100 {
    background-color: rgba(239, 68, 68, 0.2) !important;
}

/* ============================================
   YELLOW/AMBER BACKGROUNDS
   ============================================ */
body.dark-mode .bg-yellow-50 {
    background-color: rgba(234, 179, 8, 0.15) !important;
}

body.dark-mode .bg-yellow-100 {
    background-color: rgba(234, 179, 8, 0.2) !important;
}

/* ============================================
   EMISSION CARDS - Cards de emissao de milhas
   ============================================ */
body.dark-mode .emission-card {
    background-color: #1f1f1f !important;
    border-color: #404040 !important;
    color: #e5e5e5 !important;
}

body.dark-mode .emission-card:hover {
    background-color: #262626 !important;
    border-color: #525252 !important;
}

body.dark-mode .emission-card .text-gray-500,
body.dark-mode .emission-card .text-gray-600,
body.dark-mode .emission-card .text-gray-700 {
    color: #a3a3a3 !important;
}

body.dark-mode .emission-card .text-gray-800,
body.dark-mode .emission-card .text-gray-900 {
    color: #e5e5e5 !important;
}

/* Program badges - LATAM, SMILES, etc */
body.dark-mode .program-badge {
    background-color: #262626 !important;
    border-color: #404040 !important;
    color: #e5e5e5 !important;
}

body.dark-mode .program-badge.program-latam {
    background-color: rgba(239, 68, 68, 0.2) !important;
    border-color: rgba(239, 68, 68, 0.4) !important;
    color: #fca5a5 !important;
}

body.dark-mode .program-badge.program-smiles {
    background-color: rgba(249, 115, 22, 0.2) !important;
    border-color: rgba(249, 115, 22, 0.4) !important;
    color: #fdba74 !important;
}

body.dark-mode .program-badge.program-azul {
    background-color: rgba(59, 130, 246, 0.2) !important;
    border-color: rgba(59, 130, 246, 0.4) !important;
    color: #93c5fd !important;
}

/* ============================================
   CATEGORIA ITEMS - Itens de categoria
   ============================================ */
body.dark-mode .categoria-item {
    background-color: #1f1f1f !important;
    border-color: #333333 !important;
    color: #e5e5e5 !important;
}

body.dark-mode .categoria-item:hover {
    background-color: #262626 !important;
}

body.dark-mode .categoria-item .text-gray-500,
body.dark-mode .categoria-item .text-gray-600,
body.dark-mode .categoria-item .text-gray-700 {
    color: #a3a3a3 !important;
}

body.dark-mode .categoria-item .text-gray-800,
body.dark-mode .categoria-item .text-gray-900 {
    color: #e5e5e5 !important;
}

/* Subcategorias */
body.dark-mode .subcategoria-item {
    background-color: #262626 !important;
    border-color: #404040 !important;
    color: #d4d4d4 !important;
}

/* ============================================
   GENERAL WHITE BACKGROUNDS - Catch-all
   ============================================ */
body.dark-mode div[class*="bg-white"],
body.dark-mode section[class*="bg-white"],
body.dark-mode article[class*="bg-white"],
body.dark-mode aside[class*="bg-white"],
body.dark-mode main[class*="bg-white"],
body.dark-mode header[class*="bg-white"]:not(.modern-sidebar *),
body.dark-mode footer[class*="bg-white"]:not(.modern-sidebar *) {
    background-color: #1f1f1f !important;
}

/* Cards genericos com rounded e shadow */
body.dark-mode .rounded-lg.shadow:not(button),
body.dark-mode .rounded-xl.shadow:not(button),
body.dark-mode .rounded-2xl.shadow:not(button) {
    background-color: #1f1f1f !important;
    border-color: #333333 !important;
}

/* :not(button) — botões coloridos (ex: gradientes de status) NÃO devem escurecer no dark,
   senão perdem a cor semântica. Alinhado com a regra de .rounded-lg.shadow-md:not(button) acima. */
body.dark-mode .rounded-lg.shadow-md:not(button),
body.dark-mode .rounded-xl.shadow-md:not(button),
body.dark-mode .rounded-2xl.shadow-md:not(button) {
    background-color: #1f1f1f !important;
    border-color: #333333 !important;
}

body.dark-mode .rounded-lg.shadow-lg,
body.dark-mode .rounded-xl.shadow-lg,
body.dark-mode .rounded-2xl.shadow-lg {
    background-color: #1f1f1f !important;
    border-color: #333333 !important;
}

/* ============================================
   GRAY BACKGROUNDS - bg-gray-200, bg-gray-300, bg-gray-400
   Botoes de cancelar, backgrounds secundarios
   ============================================ */
body.dark-mode .bg-gray-200 {
    background-color: #404040 !important;
}

body.dark-mode .bg-gray-300 {
    background-color: #525252 !important;
}

body.dark-mode .bg-gray-400 {
    background-color: #5c5c5c !important;
}

/* Botoes com bg-gray-300 (Cancelar) */
body.dark-mode button.bg-gray-300 {
    background-color: #404040 !important;
    color: #e5e5e5 !important;
    border-color: #525252 !important;
}

body.dark-mode button.bg-gray-300:hover {
    background-color: #525252 !important;
}

/* Texto escuro em botoes cinza deve ficar claro */
body.dark-mode .bg-gray-300.text-gray-700,
body.dark-mode .bg-gray-300 .text-gray-700,
body.dark-mode button.bg-gray-300.text-gray-700 {
    color: #e5e5e5 !important;
}

body.dark-mode .bg-gray-200.text-gray-700,
body.dark-mode .bg-gray-200 .text-gray-700,
body.dark-mode button.bg-gray-200.text-gray-700 {
    color: #e5e5e5 !important;
}

/* Hover states para bg-gray */
body.dark-mode .hover\:bg-gray-400:hover {
    background-color: #5c5c5c !important;
}

body.dark-mode .hover\:bg-gray-300:hover {
    background-color: #525252 !important;
}

/* ============================================
   MODAL FOOTER BUTTONS - Forcar estilo correto
   ============================================ */
body.dark-mode .modal-content button[type="button"]:not(.bg-cyan-600):not(.bg-blue-600):not(.bg-green-600):not(.bg-red-600):not(.bg-orange-600) {
    background-color: #404040 !important;
    color: #e5e5e5 !important;
    border-color: #525252 !important;
}

body.dark-mode .modal-content button[type="button"]:not(.bg-cyan-600):not(.bg-blue-600):not(.bg-green-600):not(.bg-red-600):not(.bg-orange-600):hover {
    background-color: #525252 !important;
}

/* ============================================
   AMBER/YELLOW LIGHT BACKGROUNDS
   ============================================ */
body.dark-mode .bg-amber-50 {
    background-color: rgba(245, 158, 11, 0.15) !important;
    color: #fcd34d !important;
}

body.dark-mode .bg-amber-100 {
    background-color: rgba(245, 158, 11, 0.2) !important;
}

body.dark-mode button.bg-amber-50,
body.dark-mode a.bg-amber-50 {
    background-color: rgba(245, 158, 11, 0.2) !important;
    color: #fcd34d !important;
    border-color: rgba(245, 158, 11, 0.4) !important;
}

body.dark-mode button.bg-amber-50:hover,
body.dark-mode a.bg-amber-50:hover {
    background-color: rgba(245, 158, 11, 0.3) !important;
}

/* User cards and badges */
body.dark-mode .user-card {
    background-color: #1f1f1f !important;
    border-color: #333333 !important;
}

body.dark-mode .permission-badge {
    background-color: #262626 !important;
    border-color: #404040 !important;
    color: #d4d4d4 !important;
}

body.dark-mode .status-badge {
    /* Status badges mantêm cores para indicar status */
}

body.dark-mode .status-badge.status-active {
    background-color: rgba(16, 185, 129, 0.2) !important;
    color: #6ee7b7 !important;
}

body.dark-mode .status-badge.status-inactive {
    background-color: rgba(245, 158, 11, 0.2) !important;
    color: #fcd34d !important;
}

body.dark-mode .status-badge.status-pending {
    background-color: rgba(249, 115, 22, 0.2) !important;
    color: #fdba74 !important;
}

/* ============================================
   PROGRAMA CARD - Cards de programas de fidelidade
   ============================================ */
body.dark-mode .programa-card {
    background-color: #1f1f1f !important;
    border-color: #333333 !important;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.3) !important;
}

body.dark-mode .programa-card:hover {
    background-color: #262626 !important;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.4) !important;
}

body.dark-mode .programa-card .text-gray-500,
body.dark-mode .programa-card .text-gray-600,
body.dark-mode .programa-card .text-gray-700 {
    color: #a3a3a3 !important;
}

body.dark-mode .programa-card h3,
body.dark-mode .programa-card .text-gray-800,
body.dark-mode .programa-card .text-gray-900 {
    color: #e5e5e5 !important;
}

/* Archived programa card */
body.dark-mode .archived-programa {
    background-color: #1a1a1a !important;
    opacity: 0.7;
}

/* ============================================
   MODAL NOVA EMISSAO - Modal de emissao/edicao
   ============================================ */
body.dark-mode #modal-nova-emissao > div:first-child,
body.dark-mode #modal-nova-emissao .modal-content,
body.dark-mode #modal-nova-emissao > div > div {
    background-color: #1f1f1f !important;
    color: #e5e5e5 !important;
}

body.dark-mode #modal-nova-emissao input,
body.dark-mode #modal-nova-emissao select,
body.dark-mode #modal-nova-emissao textarea {
    background-color: #262626 !important;
    border-color: #404040 !important;
    color: #e5e5e5 !important;
}

body.dark-mode #modal-nova-emissao input:focus,
body.dark-mode #modal-nova-emissao select:focus,
body.dark-mode #modal-nova-emissao textarea:focus {
    border-color: #0891b2 !important;
    box-shadow: 0 0 0 2px rgba(8, 145, 178, 0.2) !important;
}

body.dark-mode #modal-nova-emissao label,
body.dark-mode #modal-nova-emissao .text-gray-600,
body.dark-mode #modal-nova-emissao .text-gray-700 {
    color: #a3a3a3 !important;
}

body.dark-mode #modal-nova-emissao h3,
body.dark-mode #modal-nova-emissao .text-gray-800,
body.dark-mode #modal-nova-emissao .text-gray-900 {
    color: #e5e5e5 !important;
}

/* Modal footer */
body.dark-mode #modal-nova-emissao > div > div:last-child {
    background-color: #1a1a1a !important;
    border-top-color: #333333 !important;
}

/* Dropdown suggestions in modal */
body.dark-mode #modal-nova-emissao #cliente-sugestoes,
body.dark-mode #modal-nova-emissao [id*="sugestoes"] {
    background-color: #262626 !important;
    border-color: #404040 !important;
}

body.dark-mode #modal-nova-emissao #cliente-sugestoes li,
body.dark-mode #modal-nova-emissao [id*="sugestoes"] li {
    color: #e5e5e5 !important;
}

body.dark-mode #modal-nova-emissao #cliente-sugestoes li:hover,
body.dark-mode #modal-nova-emissao [id*="sugestoes"] li:hover {
    background-color: #333333 !important;
}

/* ============================================
   CHART.JS - Graficos do Dashboard
   ============================================ */
body.dark-mode canvas {
    /* Canvas geralmente nao precisa de background,
       mas garantir que container tenha fundo escuro */
}

body.dark-mode .chart-container,
body.dark-mode [class*="chart"] {
    background-color: transparent !important;
}

/* Card containers que podem conter graficos */
body.dark-mode .card canvas,
body.dark-mode .bg-white canvas {
    /* Garantir que canvas herda do container */
}

/* ============================================
   DASHBOARD - Componentes especificos
   Alta especificidade para sobrescrever inline styles
   ============================================ */
html.dark-mode body.dark-mode .financeiro-compact-card,
html.dark-mode .financeiro-compact-card,
body.dark-mode .financeiro-compact-card,
.dark-mode .financeiro-compact-card {
    background-color: #1f1f1f !important;
    background: #1f1f1f !important;
    border-color: #333333 !important;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.3) !important;
}

html.dark-mode body.dark-mode .financeiro-compact-card:hover,
body.dark-mode .financeiro-compact-card:hover {
    background-color: #262626 !important;
    background: #262626 !important;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.4) !important;
}

body.dark-mode .financeiro-compact-card .text-gray-500,
body.dark-mode .financeiro-compact-card .text-gray-600,
body.dark-mode .financeiro-compact-card .text-gray-700 {
    color: #a3a3a3 !important;
}

body.dark-mode .financeiro-compact-card h3,
body.dark-mode .financeiro-compact-card h4,
body.dark-mode .financeiro-compact-card .text-gray-800,
body.dark-mode .financeiro-compact-card .text-gray-900 {
    color: #e5e5e5 !important;
}

/* Dashboard section cards - Alta especificidade */
html.dark-mode body.dark-mode .dashboard-section,
html.dark-mode .dashboard-section,
body.dark-mode .dashboard-section,
.dark-mode .dashboard-section {
    background-color: #1f1f1f !important;
    background: #1f1f1f !important;
    border-color: #333333 !important;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.3) !important;
}

body.dark-mode .dashboard-section h2,
body.dark-mode .dashboard-section h3,
body.dark-mode .dashboard-section h4 {
    color: #e5e5e5 !important;
}

body.dark-mode .dashboard-section .text-gray-500,
body.dark-mode .dashboard-section .text-gray-600,
body.dark-mode .dashboard-section .text-gray-700 {
    color: #a3a3a3 !important;
}

/* Task Calendar - Alta especificidade */
html.dark-mode body.dark-mode .task-calendar,
html.dark-mode .task-calendar,
body.dark-mode .task-calendar,
.dark-mode .task-calendar {
    background-color: #1f1f1f !important;
    background: #1f1f1f !important;
    border-color: #333333 !important;
}

body.dark-mode .task-calendar .text-gray-500,
body.dark-mode .task-calendar .text-gray-600 {
    color: #a3a3a3 !important;
}

body.dark-mode .task-calendar .text-gray-800,
body.dark-mode .task-calendar .text-gray-900 {
    color: #e5e5e5 !important;
}

/* Task items in calendar */
body.dark-mode .task-item {
    background-color: #262626 !important;
    border-color: #404040 !important;
}

body.dark-mode .task-item:hover {
    background-color: #333333 !important;
}

/* =================================================================
   DARK MODE — REDE DE SEGURANÇA RAIZ (#35)
   Cobertura abrangente dos shades Tailwind que faltavam, para que
   QUALQUER tela/feature nova (cards do dashboard, mini-cards de
   resumo financeiro, badges geradas por JS, calendário) já herde o
   tema escuro sem precisar de CSS próprio. Mantém a cor semântica
   (verde/vermelho/azul/...) porém legível sobre fundo escuro.
   ================================================================= */

/* --- Textos coloridos: shades -500/-700/-800 (os -600 já existem) --- */
body.dark-mode .text-blue-500,
body.dark-mode .text-blue-700,
body.dark-mode .text-blue-800   { color: #60a5fa !important; }
body.dark-mode .text-green-500,
body.dark-mode .text-green-700,
body.dark-mode .text-green-800,
body.dark-mode .text-emerald-600,
body.dark-mode .text-emerald-700 { color: #4ade80 !important; }
body.dark-mode .text-red-500,
body.dark-mode .text-red-700,
body.dark-mode .text-red-800    { color: #f87171 !important; }
body.dark-mode .text-orange-500,
body.dark-mode .text-orange-700,
body.dark-mode .text-amber-600,
body.dark-mode .text-amber-700  { color: #fb923c !important; }
body.dark-mode .text-purple-500,
body.dark-mode .text-purple-700,
body.dark-mode .text-violet-600,
body.dark-mode .text-indigo-600,
body.dark-mode .text-indigo-700 { color: #a78bfa !important; }
body.dark-mode .text-pink-500,
body.dark-mode .text-pink-600,
body.dark-mode .text-pink-700   { color: #f472b6 !important; }
body.dark-mode .text-yellow-500,
body.dark-mode .text-yellow-700 { color: #fbbf24 !important; }
body.dark-mode .text-teal-600,
body.dark-mode .text-teal-700   { color: #2dd4bf !important; }

/* --- Backgrounds claros -50 que faltavam (containers) --- */
body.dark-mode .bg-pink-50    { background-color: rgba(236, 72, 153, 0.12) !important; }
body.dark-mode .bg-amber-50   { background-color: rgba(245, 158, 11, 0.12) !important; }
body.dark-mode .bg-orange-50  { background-color: rgba(249, 115, 22, 0.12) !important; }
body.dark-mode .bg-indigo-50  { background-color: rgba(99, 102, 241, 0.12) !important; }
body.dark-mode .bg-purple-50  { background-color: rgba(168, 85, 247, 0.12) !important; }
body.dark-mode .bg-teal-50    { background-color: rgba(20, 184, 166, 0.12) !important; }
body.dark-mode .bg-yellow-50  { background-color: rgba(245, 158, 11, 0.12) !important; }

/* --- Backgrounds -100 que faltavam (ícones/badges) --- */
body.dark-mode .bg-red-100    { background-color: rgba(239, 68, 68, 0.18) !important; }
body.dark-mode .bg-green-100  { background-color: rgba(34, 197, 94, 0.18) !important; }
body.dark-mode .bg-purple-100 { background-color: rgba(168, 85, 247, 0.18) !important; }
body.dark-mode .bg-orange-100 { background-color: rgba(249, 115, 22, 0.18) !important; }
body.dark-mode .bg-pink-100   { background-color: rgba(236, 72, 153, 0.18) !important; }
body.dark-mode .bg-amber-100  { background-color: rgba(245, 158, 11, 0.18) !important; }
body.dark-mode .bg-indigo-100 { background-color: rgba(99, 102, 241, 0.18) !important; }

/* --- Bordas claras de badges/cards -200 --- */
body.dark-mode .border-red-200,
body.dark-mode .border-green-200,
body.dark-mode .border-blue-200,
body.dark-mode .border-yellow-200,
body.dark-mode .border-orange-200,
body.dark-mode .border-purple-200,
body.dark-mode .border-pink-200,
body.dark-mode .border-amber-200,
body.dark-mode .border-gray-200,
body.dark-mode .border-gray-100,
body.dark-mode .border-gray-300 { border-color: var(--border-color) !important; }

/* --- Calendário do dashboard (classes inline em dashboard_erp_milhas.html).
       body.dark-mode tem especificidade > a regra inline base, então vence
       mesmo o global-theme.css sendo carregado antes do <style> da página. --- */
body.dark-mode .calendar-day            { color: var(--text-secondary) !important; }
body.dark-mode .calendar-day-header     { color: var(--text-muted) !important; }
body.dark-mode .calendar-day-other-month{ color: var(--text-light) !important; }
body.dark-mode .calendar-day-today {
    background-color: rgba(59, 130, 246, 0.30) !important;
    color: #93c5fd !important;
}
body.dark-mode .calendar-day-checkin {
    background-color: rgba(16, 185, 129, 0.25) !important;
    color: #6ee7b7 !important;
}

/* --- Botões de ação claros (editar/excluir/arquivar) que apareciam
       "negativos": fundo claro vira translúcido da cor, texto legível. --- */
body.dark-mode .btn-edit,
body.dark-mode button.bg-blue-50,
body.dark-mode .action-edit {
    background-color: rgba(59, 130, 246, 0.16) !important;
    color: #60a5fa !important;
}
body.dark-mode .btn-archive,
body.dark-mode button.bg-yellow-50,
body.dark-mode button.bg-amber-50,
body.dark-mode .action-archive {
    background-color: rgba(245, 158, 11, 0.16) !important;
    color: #fbbf24 !important;
}
body.dark-mode .btn-delete,
body.dark-mode .action-delete {
    background-color: rgba(239, 68, 68, 0.16) !important;
    color: #f87171 !important;
}

/* =================================================================
   COBERTURA GLOBAL DEFINITIVA DO DARK MODE (#35)
   Objetivo: o tema GLOBAL prevalece sobre qualquer cor hardcoded
   local (classe custom no <style> da página OU inline style). Assim
   telas novas e existentes ficam consistentes sem precisar de CSS
   próprio. Regras com !important e prefixo body.dark-mode vencem
   tanto o <style> inline (ordem/especificidade) quanto o style="".
   Sidebar é sempre escura por design → sempre excluída.
   ================================================================= */

/* --- 1) FUNDO CLARO via INLINE STYLE → superfície escura do tema.
       Cobre as várias grafias (#fff/#ffffff/white/rgb(255), com e sem
       espaço, background e background-color). Vence o inline porque o
       CSS usa !important. Exclui sidebar e logos (que precisam de fundo
       claro p/ o logo colorido aparecer). --- */
body.dark-mode [style*="background:#fff"]:not(.modern-sidebar *):not(.sidebar *):not([class*="logo"]):not([class*="-logo"]),
body.dark-mode [style*="background: #fff"]:not(.modern-sidebar *):not(.sidebar *):not([class*="logo"]):not([class*="-logo"]),
body.dark-mode [style*="background:white"]:not(.modern-sidebar *):not(.sidebar *):not([class*="logo"]):not([class*="-logo"]),
body.dark-mode [style*="background: white"]:not(.modern-sidebar *):not(.sidebar *):not([class*="logo"]):not([class*="-logo"]),
body.dark-mode [style*="background-color:#fff"]:not(.modern-sidebar *):not(.sidebar *):not([class*="logo"]):not([class*="-logo"]),
body.dark-mode [style*="background-color: #fff"]:not(.modern-sidebar *):not(.sidebar *):not([class*="logo"]):not([class*="-logo"]),
body.dark-mode [style*="background-color:white"]:not(.modern-sidebar *):not(.sidebar *):not([class*="logo"]):not([class*="-logo"]),
body.dark-mode [style*="background-color: white"]:not(.modern-sidebar *):not(.sidebar *):not([class*="logo"]):not([class*="-logo"]),
body.dark-mode [style*="background:rgb(255"]:not(.modern-sidebar *):not(.sidebar *):not([class*="logo"]):not([class*="-logo"]),
body.dark-mode [style*="background-color:rgb(255"]:not(.modern-sidebar *):not(.sidebar *):not([class*="logo"]):not([class*="-logo"]) {
    background-color: var(--bg-card) !important;
    border-color: var(--border-color) !important;
    color: var(--text-primary) !important;
}

/* --- 2) FUNDOS AZUL/VERDE CLARO inline comuns de botões/rodapés
       (ex.: "Cadastrar cliente" #eff6ff) → translúcido legível. --- */
body.dark-mode [style*="background:#eff6ff"]:not(.modern-sidebar *),
body.dark-mode [style*="background: #eff6ff"]:not(.modern-sidebar *),
body.dark-mode [style*="background:#dbeafe"]:not(.modern-sidebar *),
body.dark-mode [style*="background: #dbeafe"]:not(.modern-sidebar *) {
    background-color: rgba(59, 130, 246, 0.18) !important;
    color: #93c5fd !important;
}

/* --- 3) CLASSES CUSTOM de container claro (headers/accordion/inputs/
       dropdowns) descobertas nas telas. Listadas explicitamente, mas o
       padrão geral de "fundo claro" também é pego pela regra 1 quando
       vier inline. --- */
body.dark-mode .grupo-header,
body.dark-mode .busca-input,
body.dark-mode .orcamento-card,
body.dark-mode .suggestions-dropdown,
body.dark-mode .companhia-dropdown,
body.dark-mode .aeroporto-sugestoes,
body.dark-mode .conexao-box,
body.dark-mode .autocomplete-dropdown,
body.dark-mode .os-resp-sug,
body.dark-mode .os-forn-sug,
body.dark-mode .os-navio-sug,
body.dark-mode .os-catforn-sug,
body.dark-mode .os-cabine-sug,
body.dark-mode .os-companhia-sug,
body.dark-mode .os-subcat-sug,
body.dark-mode .os-local-sug {
    background: var(--bg-card) !important;
    border-color: var(--border-color) !important;
    color: var(--text-primary) !important;
}
body.dark-mode .grupo-header:hover,
body.dark-mode .suggestion-item:hover,
body.dark-mode .search-select-option:hover { background: var(--bg-hover) !important; }

/* --- 4) BOTÕES DE AÇÃO com fundo pastel claro (orçamentos). Mantém a
       cor semântica em translúcido + texto claro. --- */
body.dark-mode .edit-button {
    background-color: rgba(59, 130, 246, 0.18) !important;
    color: #60a5fa !important;
}
body.dark-mode .delete-button {
    background-color: rgba(239, 68, 68, 0.18) !important;
    color: #f87171 !important;
}
body.dark-mode .convert-button {
    background-color: rgba(34, 197, 94, 0.18) !important;
    color: #4ade80 !important;
}
body.dark-mode .pdf-button {
    background-color: rgba(245, 158, 11, 0.18) !important;
    color: #fbbf24 !important;
}

/* --- 5) HOVER pastel do Tailwind nos botões de ação dos cards (conta/
       cartão): hover:bg-*-50 mostrava pastel claro ("negativo"). --- */
body.dark-mode .hover\:bg-blue-50:hover   { background-color: rgba(59, 130, 246, 0.20) !important; }
body.dark-mode .hover\:bg-red-50:hover    { background-color: rgba(239, 68, 68, 0.20) !important; }
body.dark-mode .hover\:bg-green-50:hover  { background-color: rgba(34, 197, 94, 0.20) !important; }
body.dark-mode .hover\:bg-orange-50:hover { background-color: rgba(249, 115, 22, 0.20) !important; }
body.dark-mode .hover\:bg-yellow-50:hover { background-color: rgba(245, 158, 11, 0.20) !important; }
body.dark-mode .hover\:bg-purple-50:hover { background-color: rgba(168, 85, 247, 0.20) !important; }
body.dark-mode .hover\:bg-gray-50:hover,
body.dark-mode .hover\:bg-gray-100:hover  { background-color: var(--bg-hover) !important; }

/* --- 6) TEXTO ESCURO via INLINE STYLE → claro. Lista de cinzas/slate
       neutros (Tailwind gray/slate 500–900) que aparecem hardcoded em
       cores de texto. São neutros: clarear no escuro é sempre correto.
       (Não usamos prefixo de hex p/ não pegar cores vivas como #4ade80.) --- */
body.dark-mode [style*="color:#374151"], body.dark-mode [style*="color: #374151"],
body.dark-mode [style*="color:#4b5563"], body.dark-mode [style*="color: #4b5563"],
body.dark-mode [style*="color:#1f2937"], body.dark-mode [style*="color: #1f2937"],
body.dark-mode [style*="color:#111827"], body.dark-mode [style*="color: #111827"],
body.dark-mode [style*="color:#6b7280"], body.dark-mode [style*="color: #6b7280"],
body.dark-mode [style*="color:#0f172a"], body.dark-mode [style*="color: #0f172a"],
body.dark-mode [style*="color:#1e293b"], body.dark-mode [style*="color: #1e293b"],
body.dark-mode [style*="color:#334155"], body.dark-mode [style*="color: #334155"],
body.dark-mode [style*="color:#475569"], body.dark-mode [style*="color: #475569"],
body.dark-mode [style*="color:#64748b"], body.dark-mode [style*="color: #64748b"],
body.dark-mode [style*="color:#374152"], body.dark-mode [style*="color:#0f1729"] {
    color: var(--text-secondary) !important;
}

/* --- 7) CLASSES CUSTOM de texto/subtotal escuro descobertas (relatório
       contábil etc.). Texto claro + subtotal claro vira escuro. --- */
body.dark-mode .contabil-label,
body.dark-mode .contabil-value { color: var(--text-primary) !important; }
body.dark-mode .contabil-subtotal {
    background-color: var(--bg-secondary) !important;
    border-color: var(--border-color) !important;
    color: var(--text-primary) !important;
}

/* ============================================================
   SKIN GLOBAL — identidade unificada (2026-06-11)
   Fonte Inter + campos com cantos arredondados e foco índigo em TODO o app.
   • SEM !important: respeita classes explícitas (rounded-none, etc.).
   • NÃO toca ícones: .fa/.fas têm font-family própria (classe vence herança).
   • Cores ficam por conta do motor de tema acima (claro/escuro), evitando
     incompatibilidades entre os modos.
   ============================================================ */
body {
    font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}
button, input, select, textarea, optgroup {
    font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}
input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="hidden"]):not([type="color"]),
select, textarea {
    border-radius: 9px;
    transition: border-color .15s ease, box-shadow .15s ease;
}
input:not([type="checkbox"]):not([type="radio"]):focus,
select:focus, textarea:focus {
    outline: none;
    border-color: #6366f1;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, .15);
}

/* ============================================================
   COMPONENTE BOTÃO — fonte única (Design System). Ver docs/design-system/ESTUDO.md
   Uso: <button class="btn btn-primary btn-md"> · cor/dark via tokens (correto nos 2 modos).
   Substitui as 454 classes ad-hoc de botão. Migração por tela (Fase 1).
   ============================================================ */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
    font-family: inherit; font-weight: 600; font-size: .875rem; line-height: 1.1;
    border: 1px solid transparent; border-radius: .5rem; cursor: pointer; white-space: nowrap;
    text-decoration: none;
    transition: background-color .15s ease, border-color .15s ease, box-shadow .15s ease, opacity .15s ease;
}
.btn:disabled, .btn[disabled] { opacity: .5; cursor: not-allowed; pointer-events: none; }
/* `.btn` define display:inline-flex e é carregado DEPOIS do tailwind.css, então
   sozinho vencia a utilitária `.hidden{display:none}` por ordem de fonte (mesma
   especificidade) — botões `.btn.hidden` apareciam mesmo "escondidos" (ex.: "Adicionar
   Volta"/"2º Trecho" em Somente Ida). O seletor composto vence por especificidade. */
.btn.hidden { display: none; }
/* tamanhos */
.btn-sm { padding: .375rem .75rem; font-size: .75rem; }
.btn-md { padding: .5rem 1rem; }
.btn-lg { padding: .625rem 1.5rem; }
/* tipos semânticos (cores via token = adaptam claro/escuro) */
/* RFC-009: cor de BOTÃO separável (var(--color-button) com fallback p/ a cor primária). */
.btn-primary   { background: var(--color-button, var(--color-primary)); color: #fff; }
.btn-primary:hover   { background: var(--color-button-hover, var(--color-primary-hover)); }
.btn-secondary { background: transparent; color: var(--text-secondary); border-color: var(--border-color); }
.btn-secondary:hover { background: var(--bg-hover); }
.btn-success   { background: var(--color-success); color: #fff; }
.btn-success:hover   { filter: brightness(.93); }
.btn-danger    { background: var(--color-error); color: #fff; }
.btn-danger:hover    { filter: brightness(.93); }
.btn-danger-ghost { background: transparent; color: var(--color-error); }
.btn-danger-ghost:hover { background: var(--color-error-bg); }
/* ícone-only (sem texto) */
.btn-icon { padding: .4375rem; border-radius: .375rem; background: transparent; color: var(--text-muted); border: none; line-height: 0; }
.btn-icon:hover { background: var(--bg-hover); color: var(--text-primary); }
.btn-icon.danger:hover { background: var(--color-error-bg); color: var(--color-error); }

/* ============================================================
   MODAIS — cantos arredondados PADRÃO e GLOBAL (modelo: modais de lançamento)
   Garante os 4 cantos arredondados em QUALQUER modal do sistema. O overflow:hidden
   faz o header (border-b) e o rodapé (bg-gray-50) respeitarem o raio da caixa,
   eliminando os cantos inferiores "quadrados" quando o rodapé não tem rounded-b.
   Cobre as classes nomeadas de caixa de modal usadas no sistema.
   ============================================================ */
.modal-content,
.modal-dialog {
    border-radius: 18px !important;
    overflow: hidden;
}

/* ============================================================
   MOTOR DE TEMA — WHITELABEL (RFC-009)
   A classe .tema-parceiro (no <html> e no <body>, ligada pelo motor de tema quando há cor de
   parceiro) faz os AZUIS HARDCODED do Tailwind seguirem a cor do parceiro — MESMA mecânica do
   dark mode (override por seletor). O que já usa var(--color-primary) muda sozinho; isto cobre
   o que ficou com classe de cor fixa. DADOS (gráficos, badges de tipo, cor de cartão) são
   inline/JS e ficam de fora deste seletor de propósito.
   ============================================================ */
/* Banner do seletor de mês (componente month-balance-navigation): token de tema p/ TODOS os
   temas — azul no padrão, cor do parceiro no whitelabel, azul-claro no dark. */
.month-nav-bar {
    background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-primary-hover) 100%);
}
/* Fundos azuis fixos → cor do parceiro */
html.tema-parceiro .bg-blue-500,
html.tema-parceiro .bg-blue-600,
html.tema-parceiro .bg-blue-700 { background-color: var(--color-primary) !important; }
html.tema-parceiro .hover\:bg-blue-600:hover,
html.tema-parceiro .hover\:bg-blue-700:hover { background-color: var(--color-primary-hover) !important; }
/* Textos azuis fixos (links, valores em destaque) → cor do parceiro */
html.tema-parceiro .text-blue-500,
html.tema-parceiro .text-blue-600,
html.tema-parceiro .text-blue-700 { color: var(--color-primary) !important; }
html.tema-parceiro .hover\:text-blue-700:hover,
html.tema-parceiro .hover\:text-blue-800:hover { color: var(--color-primary-hover) !important; }
/* Bordas azuis fixas (abas ativas, foco) → cor do parceiro */
html.tema-parceiro .border-blue-500,
html.tema-parceiro .border-blue-600 { border-color: var(--color-primary) !important; }
/* Gradientes azuis (headers de página/card) → cor do parceiro */
html.tema-parceiro .from-blue-500,
html.tema-parceiro .from-blue-600,
html.tema-parceiro .from-cyan-500 { --tw-gradient-from: var(--color-primary) !important; }
html.tema-parceiro .to-blue-600,
html.tema-parceiro .to-blue-700 { --tw-gradient-to: var(--color-primary-hover) !important; }

/* CONTRASTE: com cor de fundo custom, cards/painéis ganham uma DIVISÃO (borda derivada do fundo
   via JS em --border-color) — senão ficam da mesma cor do fundo e "somem". */
html.tema-fundo-custom .stat,
html.tema-fundo-custom .panel,
html.tema-fundo-custom .card,
html.tema-fundo-custom .modern-card,
html.tema-fundo-custom .lanc-secao { border: 1px solid var(--border-color) !important; }
