/* ============================================================
   Prontus-SAS • Dark Mode (modo escuro)
   Ativado via <html class="dark"> — ver public/js/theme.js
   Estratégia: overrides globais das classes claras mais usadas,
   sem reescrever as centenas de views existentes.
   ============================================================ */

/* ---------- Base ---------- */
html.dark {
    color-scheme: dark;
}
html.dark body {
    background: #0b1220 !important;
    background-color: #0b1220 !important;
    color: #e2e8f0 !important;
}
html.dark main {
    background: transparent !important;
}
html.dark header[class*="bg-white"],
html.dark header.bg-white\/50 {
    background: rgba(15, 23, 42, 0.85) !important;
    border-color: #1e293b !important;
    backdrop-filter: blur(12px);
}

/* ---------- Superfícies claras mais comuns ---------- */
html.dark .bg-white { background-color: #111c30 !important; }
html.dark .bg-slate-50 { background-color: #0f1a2e !important; }
html.dark .bg-slate-100 { background-color: #16233c !important; }
html.dark .bg-gray-50 { background-color: #0f1a2e !important; }
html.dark .bg-gray-100 { background-color: #16233c !important; }
html.dark .bg-slate-200 { background-color: #1e2e4d !important; }
html.dark .hover\:bg-slate-50:hover { background-color: #16233c !important; }
html.dark .hover\:bg-gray-50:hover { background-color: #16233c !important; }
html.dark .hover\:bg-slate-100:hover { background-color: #1e2e4d !important; }
/* Brancos translúcidos (bg-white/40 … /95): sobre fundo escuro viram
   faixa acinzentada — mapeia para superfície dark. Classes exatas
   (não substring) para não afetar tokens hover:bg-white/*.
   Opacidades baixas (/5–/30, overlays intencionais) ficam intactas. */
html.dark .bg-white\/40,
html.dark .bg-white\/50,
html.dark .bg-white\/60,
html.dark .bg-white\/70,
html.dark .bg-white\/75,
html.dark .bg-white\/80,
html.dark .bg-white\/90,
html.dark .bg-white\/95 { background-color: #101b31 !important; }
/* Slate/gray translúcidos (tr de thead, faixas, dropzones): mesma lógica.
   Exatos para não tocar tokens hover:. */
html.dark .bg-slate-50\/40,
html.dark .bg-slate-50\/50,
html.dark .bg-slate-50\/60,
html.dark .bg-slate-50\/70,
html.dark .bg-slate-50\/80,
html.dark .bg-slate-100\/50,
html.dark .bg-gray-50\/50,
html.dark .bg-gray-100\/50 { background-color: #101b31 !important; }
/* Hover das linhas em tabelas claras */
html.dark .hover\:bg-slate-50\/40:hover,
html.dark .hover\:bg-slate-50\/60:hover,
html.dark .hover\:bg-gray-50\/60:hover { background-color: #16233c !important; }
/* Slate médios sólidos e variantes (badges, divisores, tracks, botões) */
html.dark .bg-slate-300 { background-color: #3b4c68 !important; }
html.dark .bg-slate-400 { background-color: #4b5f7d !important; }
html.dark .bg-slate-200\/60,
html.dark .bg-slate-200\/70,
html.dark .bg-slate-200\/80 { background-color: #26395c !important; }
html.dark .hover\:bg-slate-300:hover { background-color: #334155 !important; }
/* Paradas de gradiente claras (from-/to-): viram equivalentes dark */
html.dark .from-slate-50,
html.dark .from-slate-50\/50 {
    --tw-gradient-from: #101b31 var(--tw-gradient-from-position) !important;
    --tw-gradient-to: rgb(16 27 49 / 0) var(--tw-gradient-to-position) !important;
    --tw-gradient-stops: var(--tw-gradient-from), var(--tw-gradient-to) !important;
}
html.dark .from-amber-50,
html.dark .from-amber-50\/90 {
    --tw-gradient-from: rgba(120, 84, 16, 0.5) var(--tw-gradient-from-position) !important;
    --tw-gradient-to: rgb(120 84 16 / 0) var(--tw-gradient-to-position) !important;
    --tw-gradient-stops: var(--tw-gradient-from), var(--tw-gradient-to) !important;
}
html.dark .to-white { --tw-gradient-to: #111c30 var(--tw-gradient-to-position) !important; }
html.dark .to-amber-100\/50 { --tw-gradient-to: rgba(245, 158, 11, 0.14) var(--tw-gradient-to-position) !important; }
html.dark .to-orange-50\/70 { --tw-gradient-to: rgba(124, 45, 18, 0.5) var(--tw-gradient-to-position) !important; }

/* Painéis de vidro / cards padrão */
html.dark .glass-panel {
    background: rgba(17, 28, 48, 0.92) !important;
    border-color: #1e293b !important;
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.45) !important;
}
html.dark .glass-card {
    background: #111c30 !important;
    box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.5) !important;
    border: 1px solid #1e293b !important;
}
html.dark .list-item {
    background: #111c30 !important;
    border-color: #1e293b !important;
}
html.dark .list-item:hover { background: #16233c !important; }

/* ---------- Texto ---------- */
html.dark .text-slate-900, html.dark .text-slate-800 { color: #f1f5f9 !important; }
html.dark .text-slate-700 { color: #e2e8f0 !important; }
html.dark .text-slate-600 { color: #cbd5e1 !important; }
html.dark .text-slate-500 { color: #94a3b8 !important; }
html.dark .text-slate-400 { color: #7d8aa0 !important; }
html.dark .text-gray-900, html.dark .text-gray-800 { color: #f1f5f9 !important; }
html.dark .text-gray-700 { color: #e2e8f0 !important; }
html.dark .text-gray-600 { color: #cbd5e1 !important; }
html.dark .text-gray-500 { color: #94a3b8 !important; }
html.dark .text-black { color: #f1f5f9 !important; }

/* ---------- Bordas e divisórias ---------- */
html.dark .border-slate-100 { border-color: #1a2742 !important; }
html.dark .border-slate-200, html.dark .border-slate-300 { border-color: #24365a !important; }
html.dark .border-gray-100 { border-color: #1a2742 !important; }
html.dark .border-gray-200, html.dark .border-gray-300 { border-color: #24365a !important; }
html.dark .border { border-color: #24365a !important; }
html.dark .divide-slate-100 > * + *, html.dark .divide-slate-200 > * + * { border-color: #1e293b !important; }
html.dark .ring-slate-100, html.dark .ring-sky-100 { --tw-ring-color: #24365a !important; }

/* ---------- Tabelas padrão ---------- */
html.dark .table-list { border-color: #24365a !important; }
html.dark .table-list th { background: #0f1a2e !important; color: #7d8aa0 !important; border-color: #24365a !important; }
html.dark .table-list td { border-color: #1a2742 !important; color: #cbd5e1 !important; }
html.dark .table-list tr:hover td { background: #16233c !important; }

/* ---------- Formulários ---------- */
html.dark input:not([type="checkbox"]):not([type="radio"]),
html.dark select,
html.dark textarea {
    background-color: #0f1a2e !important;
    border-color: #2b3f63 !important;
    color: #e2e8f0 !important;
}
html.dark input::placeholder, html.dark textarea::placeholder { color: #5b6b87 !important; }
html.dark input:focus, html.dark select:focus, html.dark textarea:focus {
    border-color: #339AF0 !important;
    box-shadow: 0 0 0 3px rgba(51, 154, 240, 0.22) !important;
    outline: none !important;
}
html.dark input:disabled, html.dark select:disabled, html.dark textarea:disabled {
    background-color: #131f36 !important;
    color: #64748b !important;
}
html.dark .input-field { background: #0f1a2e !important; border-color: #2b3f63 !important; }
html.dark .input-field:focus-within { background: #111c30 !important; }
html.dark .input-field input, html.dark input.bg-transparent, html.dark select.bg-transparent {
    background-color: transparent !important;
}

/* ---------- Modais ---------- */
html.dark .modal-container { background: #111c30 !important; border-color: #24365a !important; color: #e2e8f0 !important; }
html.dark .modal-body { background: transparent !important; color: #cbd5e1 !important; }
html.dark .modal-footer { border-color: #1e293b !important; background: #0f1a2e !important; }
html.dark .modal-subtitle { color: rgba(255, 255, 255, 0.75) !important; }

/* ---------- Sidebar: pill do item selecionado no dark ----------
   (seletores exatos por token — o coringa [class*="bg-"] casava com
   hover:bg-* e pintava TODOS os links, não só o ativo) */
html.dark #sidebar .nav-link.bg-sky-50,
html.dark #sidebar .nav-link.bg-violet-50,
html.dark #sidebar .nav-link.bg-amber-50,
html.dark #sidebar .nav-link.bg-emerald-50,
html.dark #sidebar .nav-link.bg-indigo-50,
html.dark #sidebar .nav-link.bg-orange-50,
html.dark #sidebar .nav-link.bg-purple-50,
html.dark #sidebar .nav-link.bg-teal-50,
html.dark #sidebar .nav-link.bg-red-50,
html.dark #sidebar .nav-link.spa-active-click {
    background: #1b2f55 !important;
    color: #9cccf9 !important;
    box-shadow: 0 4px 16px rgba(0,0,0,0.4), inset 0 0 0 1px rgba(140,200,250,0.22) !important;
}
html.dark #sidebar .nav-link.bg-sky-50 i,
html.dark #sidebar .nav-link.bg-violet-50 i,
html.dark #sidebar .nav-link.bg-amber-50 i,
html.dark #sidebar .nav-link.bg-emerald-50 i,
html.dark #sidebar .nav-link.bg-indigo-50 i,
html.dark #sidebar .nav-link.bg-orange-50 i,
html.dark #sidebar .nav-link.bg-purple-50 i,
html.dark #sidebar .nav-link.bg-teal-50 i,
html.dark #sidebar .nav-link.bg-red-50 i,
html.dark #sidebar .nav-link.spa-active-click i { color: #9cccf9 !important; }

/* ---------- Topbar / botões neutros ---------- */
html.dark #sidebar-toggle,
html.dark #notifications-bell,
html.dark #switch-profile-btn {
    background: #111c30 !important;
    border-color: #24365a !important;
    color: #cbd5e1 !important;
}

/* ---------- Skeleton do SPA ---------- */
html.dark .spa-skeleton .sk-line,
html.dark .spa-skeleton .sk-card,
html.dark .spa-skeleton .sk-row {
    background: linear-gradient(90deg, #16233c 25%, #1e2e4d 50%, #16233c 75%) !important;
    background-size: 200% 100% !important;
}

/* ---------- Quill / Select2 / SweetAlert2 ---------- */
html.dark .ql-toolbar.ql-snow { background: #0f1a2e !important; border-color: #24365a !important; }
html.dark .ql-container.ql-snow { border-color: #24365a !important; }
html.dark .ql-editor { background: #0f1a2e !important; color: #e2e8f0 !important; }
html.dark .ql-editor.ql-blank::before { color: #5b6b87 !important; }
html.dark .select2-container--default .select2-selection--single,
html.dark .select2-container--default .select2-selection--multiple {
    background-color: #0f1a2e !important;
    border-color: #2b3f63 !important;
    color: #e2e8f0 !important;
}
html.dark .select2-dropdown { background-color: #111c30 !important; border-color: #24365a !important; }
html.dark .select2-container--default .select2-results__option { color: #cbd5e1 !important; }
html.dark .select2-container--default .select2-results__option--highlighted { background-color: #1e3a5f !important; }
html.dark .select2-container--default .select2-selection--single .select2-selection__rendered { color: #e2e8f0 !important; }
html.dark div:where(.swal2-container) div:where(.swal2-popup) { background: #111c30 !important; color: #e2e8f0 !important; }
html.dark .swal2-popup.prontus-toast { background: rgba(17, 28, 48, 0.95) !important; border-color: #24365a !important; }
html.dark .swal2-popup.prontus-toast .swal2-title.prontus-toast-title { color: #f1f5f9 !important; }

/* ---------- Sombras claras viram escuras ---------- */
html.dark .shadow-lg, html.dark .shadow-xl, html.dark .shadow-2xl,
html.dark .shadow-sm, html.dark .shadow {
    --tw-shadow-color: rgba(0, 0, 0, 0.5) !important;
}

/* ---------- Login: card escuro ---------- */
html.dark .login-card {
    background: rgba(15, 23, 42, 0.94) !important;
    border-color: #24365a !important;
    color: #e2e8f0 !important;
}

/* ============================================================
   Listas por classificação de risco (triagem/fila/internação)
   As views forçam fundo pastel via <style> com seletor por ID
   (#finished-list tr.bg-red-50 td { background:#fef2f2 ... }),
   então o override precisa do mesmo ID prefixado por html.dark.
   ============================================================ */
/* --- Vermelho --- */
html.dark #triage-queue-list tr.bg-red-50 td,
html.dark #finished-list tr.bg-red-50 td,
html.dark #waiting-doctor-list tr.bg-red-50 td,
html.dark #attendedListContainer tr.bg-red-50 td,
html.dark #inpatientsListContainer tr.bg-red-50 td,
html.dark #queueListContainer tr.bg-red-50 td { background: #2e1418 !important; }
/* --- Laranja --- */
html.dark #triage-queue-list tr.bg-orange-50 td,
html.dark #finished-list tr.bg-orange-50 td,
html.dark #waiting-doctor-list tr.bg-orange-50 td,
html.dark #attendedListContainer tr.bg-orange-50 td,
html.dark #inpatientsListContainer tr.bg-orange-50 td,
html.dark #queueListContainer tr.bg-orange-50 td { background: #2e1c10 !important; }
/* --- Amarelo / Âmbar --- */
html.dark #triage-queue-list tr.bg-amber-50 td,
html.dark #finished-list tr.bg-amber-50 td,
html.dark #finished-list tr.bg-yellow-50 td,
html.dark #waiting-doctor-list tr.bg-amber-50 td,
html.dark #waiting-doctor-list tr.bg-yellow-50 td,
html.dark #attendedListContainer tr.bg-amber-50 td,
html.dark #inpatientsListContainer tr.bg-amber-50 td,
html.dark #queueListContainer tr.bg-amber-50 td { background: #2c2312 !important; }
/* --- Verde --- */
html.dark #triage-queue-list tr.bg-emerald-50 td,
html.dark #finished-list tr.bg-emerald-50 td,
html.dark #waiting-doctor-list tr.bg-emerald-50 td,
html.dark #attendedListContainer tr.bg-emerald-50 td,
html.dark #inpatientsListContainer tr.bg-emerald-50 td,
html.dark #queueListContainer tr.bg-emerald-50 td { background: #0c2620 !important; }
/* --- Azul --- */
html.dark #triage-queue-list tr.bg-blue-50 td,
html.dark #finished-list tr.bg-blue-50 td,
html.dark #waiting-doctor-list tr.bg-blue-50 td,
html.dark #attendedListContainer tr.bg-blue-50 td,
html.dark #inpatientsListContainer tr.bg-blue-50 td,
html.dark #queueListContainer tr.bg-blue-50 td { background: #122540 !important; }
/* Hover: clareia no dark (as views escurecem com brightness(0.98)) */
html.dark #triage-queue-list tr[class*="bg-"]:hover td,
html.dark #finished-list tr[class*="bg-"]:hover td,
html.dark #waiting-doctor-list tr[class*="bg-"]:hover td,
html.dark #attendedListContainer tr[class*="bg-"]:hover td,
html.dark #inpatientsListContainer tr[class*="bg-"]:hover td,
html.dark #queueListContainer tr[class*="bg-"]:hover td { filter: brightness(1.35) !important; }
/* Borda lateral de classificação: mantém o acento colorido */
html.dark #finished-list tr.q-risk-bar,
html.dark #waiting-doctor-list tr.q-risk-bar { border-left-width: 0 !important; }

/* --- Fundos pastéis fora de tabelas (cards de estatística,
       chips de ícone, botões claras, variantes /40 /20) --- */
html.dark [class*="bg-red-50"]:not([class*="bg-red-500"]):not([class*="hover:bg-red-50"]) { background-color: rgba(127, 29, 29, 0.45) !important; }
html.dark [class*="bg-rose-50"]:not([class*="bg-rose-500"]):not([class*="hover:bg-rose-50"]) { background-color: rgba(136, 19, 55, 0.45) !important; }
html.dark [class*="bg-orange-50"]:not([class*="bg-orange-500"]):not([class*="hover:bg-orange-50"]) { background-color: rgba(124, 45, 18, 0.5) !important; }
html.dark [class*="bg-amber-50"]:not([class*="bg-amber-500"]):not([class*="hover:bg-amber-50"]) { background-color: rgba(120, 84, 16, 0.45) !important; }
html.dark [class*="bg-yellow-50"]:not([class*="bg-yellow-500"]):not([class*="hover:bg-yellow-50"]) { background-color: rgba(113, 96, 20, 0.45) !important; }
html.dark [class*="bg-emerald-50"]:not([class*="bg-emerald-500"]):not([class*="hover:bg-emerald-50"]) { background-color: rgba(6, 78, 59, 0.5) !important; }
html.dark [class*="bg-green-50"]:not([class*="bg-green-500"]):not([class*="hover:bg-green-50"]) { background-color: rgba(20, 83, 45, 0.5) !important; }
html.dark [class*="bg-blue-50"]:not([class*="bg-blue-500"]):not([class*="hover:bg-blue-50"]) { background-color: rgba(30, 58, 95, 0.6) !important; }
html.dark [class*="bg-indigo-50"]:not([class*="bg-indigo-500"]):not([class*="hover:bg-indigo-50"]) { background-color: rgba(49, 46, 129, 0.55) !important; }
html.dark [class*="bg-violet-50"]:not([class*="bg-violet-500"]):not([class*="hover:bg-violet-50"]), html.dark [class*="bg-purple-50"]:not([class*="bg-purple-500"]):not([class*="hover:bg-purple-50"]) { background-color: rgba(76, 29, 149, 0.5) !important; }
html.dark [class*="bg-teal-50"]:not([class*="bg-teal-500"]):not([class*="hover:bg-teal-50"]) { background-color: rgba(19, 78, 74, 0.5) !important; }
html.dark [class*="bg-sky-50"]:not([class*="bg-sky-500"]):not([class*="hover:bg-sky-50"]), html.dark [class*="bg-cyan-50"]:not([class*="bg-cyan-500"]):not([class*="hover:bg-cyan-50"]) { background-color: rgba(12, 74, 110, 0.55) !important; }
/* --- Badges *-100 sobre esses fundos --- */
html.dark [class*="bg-red-100"]:not([class*="hover:bg-red-100"]) { background-color: rgba(239, 68, 68, 0.18) !important; }
html.dark [class*="bg-rose-100"]:not([class*="hover:bg-rose-100"]) { background-color: rgba(244, 63, 94, 0.18) !important; }
html.dark [class*="bg-orange-100"]:not([class*="hover:bg-orange-100"]) { background-color: rgba(249, 115, 22, 0.18) !important; }
html.dark [class*="bg-amber-100"]:not([class*="hover:bg-amber-100"]) { background-color: rgba(245, 158, 11, 0.18) !important; }
html.dark [class*="bg-yellow-100"]:not([class*="hover:bg-yellow-100"]) { background-color: rgba(234, 179, 8, 0.18) !important; }
html.dark [class*="bg-emerald-100"]:not([class*="hover:bg-emerald-100"]), html.dark [class*="bg-green-100"]:not([class*="hover:bg-green-100"]) { background-color: rgba(16, 185, 129, 0.16) !important; }
html.dark [class*="bg-blue-100"]:not([class*="hover:bg-blue-100"]) { background-color: rgba(59, 130, 246, 0.2) !important; }
html.dark [class*="bg-indigo-100"]:not([class*="hover:bg-indigo-100"]) { background-color: rgba(99, 102, 241, 0.22) !important; }
html.dark [class*="bg-violet-100"]:not([class*="hover:bg-violet-100"]), html.dark [class*="bg-purple-100"]:not([class*="hover:bg-purple-100"]) { background-color: rgba(139, 92, 246, 0.2) !important; }
html.dark [class*="bg-teal-100"]:not([class*="hover:bg-teal-100"]) { background-color: rgba(20, 184, 166, 0.16) !important; }
html.dark [class*="bg-sky-100"]:not([class*="hover:bg-sky-100"]), html.dark [class*="bg-cyan-100"]:not([class*="hover:bg-cyan-100"]) { background-color: rgba(14, 165, 233, 0.18) !important; }
/* --- Textos escuros sobre pastel → tons claros legíveis --- */
html.dark .text-red-900, html.dark .text-red-800, html.dark .text-red-700, html.dark .text-red-600 { color: #fca5a5 !important; }
html.dark .text-rose-900, html.dark .text-rose-800, html.dark .text-rose-700, html.dark .text-rose-600 { color: #fda4af !important; }
html.dark .text-orange-900, html.dark .text-orange-800, html.dark .text-orange-700, html.dark .text-orange-600 { color: #fdba74 !important; }
html.dark .text-amber-900, html.dark .text-amber-800, html.dark .text-amber-700, html.dark .text-amber-600 { color: #fcd34d !important; }
html.dark .text-yellow-800, html.dark .text-yellow-700, html.dark .text-yellow-600 { color: #fde047 !important; }
html.dark .text-emerald-900, html.dark .text-emerald-800, html.dark .text-emerald-700, html.dark .text-emerald-600,
html.dark .text-green-800, html.dark .text-green-700, html.dark .text-green-600 { color: #6ee7b7 !important; }
html.dark .text-blue-900, html.dark .text-blue-800, html.dark .text-blue-700, html.dark .text-blue-600 { color: #93c5fd !important; }
html.dark .text-indigo-800, html.dark .text-indigo-700, html.dark .text-indigo-600 { color: #a5b4fc !important; }
html.dark .text-violet-700, html.dark .text-violet-600, html.dark .text-purple-700, html.dark .text-purple-600 { color: #c4b5fd !important; }
html.dark .text-teal-800, html.dark .text-teal-700, html.dark .text-teal-600 { color: #5eead4 !important; }
html.dark .text-sky-800, html.dark .text-sky-700, html.dark .text-sky-600, html.dark .text-cyan-700, html.dark .text-cyan-600 { color: #7dd3fc !important; }
/* --- Bordas pastéis + rings --- */
html.dark [class*="border-red-200"]:not([class*="hover:border-red-200"]):not([class*="hover:border-red-300"]), html.dark [class*="border-red-300"]:not([class*="hover:border-red-200"]):not([class*="hover:border-red-300"]) { border-color: #7f2d35 !important; }
html.dark [class*="border-rose-200"]:not([class*="hover:border-rose-200"]):not([class*="hover:border-rose-300"]), html.dark [class*="border-rose-300"]:not([class*="hover:border-rose-200"]):not([class*="hover:border-rose-300"]) { border-color: #7c2d42 !important; }
html.dark [class*="border-orange-200"]:not([class*="hover:border-orange-200"]):not([class*="hover:border-orange-300"]), html.dark [class*="border-orange-300"]:not([class*="hover:border-orange-200"]):not([class*="hover:border-orange-300"]) { border-color: #7c3f16 !important; }
html.dark [class*="border-amber-200"]:not([class*="hover:border-amber-200"]):not([class*="hover:border-amber-300"]), html.dark [class*="border-amber-300"]:not([class*="hover:border-amber-200"]):not([class*="hover:border-amber-300"]) { border-color: #715c1f !important; }
html.dark [class*="border-yellow-200"]:not([class*="hover:border-yellow-200"]):not([class*="hover:border-yellow-300"]), html.dark [class*="border-yellow-300"]:not([class*="hover:border-yellow-200"]):not([class*="hover:border-yellow-300"]) { border-color: #6b611c !important; }
html.dark [class*="border-emerald-200"]:not([class*="hover:border-emerald-200"]):not([class*="hover:border-emerald-300"]),
html.dark [class*="border-emerald-300"]:not([class*="hover:border-emerald-200"]):not([class*="hover:border-emerald-300"]),
html.dark [class*="border-green-200"]:not([class*="hover:border-green-200"]):not([class*="hover:border-green-300"]),
html.dark [class*="border-green-300"]:not([class*="hover:border-green-200"]):not([class*="hover:border-green-300"]) { border-color: #14584a !important; }
html.dark [class*="border-blue-200"]:not([class*="hover:border-blue-200"]):not([class*="hover:border-blue-300"]), html.dark [class*="border-blue-300"]:not([class*="hover:border-blue-200"]):not([class*="hover:border-blue-300"]) { border-color: #2a4a7f !important; }
html.dark [class*="border-indigo-200"]:not([class*="hover:border-indigo-200"]):not([class*="hover:border-indigo-300"]), html.dark [class*="border-indigo-300"]:not([class*="hover:border-indigo-200"]):not([class*="hover:border-indigo-300"]) { border-color: #3b3fa3 !important; }
html.dark [class*="border-violet-200"]:not([class*="hover:border-violet-200"]), html.dark [class*="border-purple-200"]:not([class*="hover:border-purple-200"]) { border-color: #4c2f8f !important; }
html.dark [class*="border-teal-200"]:not([class*="hover:border-teal-200"]) { border-color: #134e4a !important; }
html.dark [class*="border-sky-200"]:not([class*="hover:border-sky-200"]):not([class*="hover:border-sky-300"]), html.dark [class*="border-cyan-200"]:not([class*="hover:border-cyan-200"]) { border-color: #0c4a6e !important; }
html.dark [class*="ring-red-"] { --tw-ring-color: #7f2d35 !important; }
html.dark [class*="ring-indigo-"] { --tw-ring-color: #3b3fa3 !important; }
html.dark [class*="ring-amber-"] { --tw-ring-color: #715c1f !important; }

/* ---------- Sidebar escura ---------- */
html.dark #sidebar { background: #0e1c34 !important; border-color: #1e293b !important; }
html.dark #sidebar > div:first-child { background: rgba(255, 255, 255, 0.04) !important; border-color: #1e293b !important; }
html.dark #sidebar .sidebar-section-title { color: #5b6b87 !important; }
html.dark #sidebar .sidebar-footer { border-color: #1e293b !important; }
html.dark #sidebar .sidebar-footer a.bg-white,
html.dark #sidebar .sidebar-footer a.bg-white:hover { background: #16233c !important; color: #cbd5e1 !important; border-color: #24365a !important; }
html.dark #sidebar-backdrop { background: rgba(2, 6, 23, 0.7) !important; }
/* ---------- Separação no dark: bordas azul-acinzentadas ---------- */
html.dark #sidebar { border-right: 1px solid #2f4e7d !important; }
html.dark #sidebar > div:first-child { border-bottom: 1px solid #2f4e7d !important; }
html.dark #sidebar .sidebar-footer { border-top: 1px solid #2f4e7d !important; }
html.dark main > header[class*="bg-white"] { border-bottom: 1px solid #2f4e7d !important; }
html.dark #sidebar-toggle,
html.dark [data-theme-toggle],
html.dark #notifications-bell,
html.dark #switch-profile-btn,
html.dark button[onclick*="toggleProfileModal"] { border-color: #2f4e7d !important; }
/* Logo da unidade na topbar: gradiente claro → escuro */
html.dark .from-white {
    --tw-gradient-from: #16233c var(--tw-gradient-from-position) !important;
    --tw-gradient-to: rgb(22 35 60 / 0) var(--tw-gradient-to-position) !important;
    --tw-gradient-stops: var(--tw-gradient-from), var(--tw-gradient-to) !important;
}
html.dark .to-sky-50 { --tw-gradient-to: #16233c var(--tw-gradient-to-position) !important; }

/* ---------- Splash "Abrindo PEP": fundo inline branco → dark ---------- */
html.dark #pep-global-loader {
    background: radial-gradient(1000px 520px at 50% -8%, #16233c 0%, #0b1220 58%, #0b1220 100%) !important;
}
/* ---------- PEP: cabeçalho + workspace (fundos hardcoded na view) ---------- */
html.dark #medicalWorkspace { background: #0b1220 !important; }
html.dark .pep-meta-bar { border-top-color: #1e293b !important; }
html.dark .pep-meta-card { background: #101b31 !important; border-color: #24365a !important; }
html.dark .pep-meta-card--vitals { background: #101b31 !important; }
html.dark #allergyBadge { background: rgba(127, 29, 29, 0.45) !important; color: #fca5a5 !important; border-color: #7f2d35 !important; }
html.dark #allergyBadge i { color: #f87171 !important; }
html.dark #allergyBadge #allergyList { color: #fca5a5 !important; }
/* Select2 dentro do PEP (a view força claro com !important) */
html.dark #medicalWorkspace .select2-container--default .select2-selection--single .select2-selection__rendered { color: #e2e8f0 !important; }
html.dark #medicalWorkspace .select2-dropdown { background: rgba(17, 28, 48, 0.98) !important; border-color: #24365a !important; }
html.dark #medicalWorkspace .select2-results__option { color: #cbd5e1 !important; }
html.dark #medicalWorkspace .select2-results__option--highlighted[aria-selected] { background: #1e2e4d !important; color: #a5b4fc !important; }
html.dark #medicalWorkspace .select2-search--dropdown .select2-search__field { background: #0f1a2e !important; border-color: #2b3f63 !important; color: #e2e8f0 !important; }

/* ---------- Impressão / PDF: sempre claro ---------- */
@media print {
    html.dark body { background: #fff !important; color: #000 !important; }
    html.dark .bg-white, html.dark .bg-slate-50, html.dark .bg-slate-100,
    html.dark .bg-gray-50, html.dark .bg-gray-100 { background-color: #fff !important; }
    html.dark .text-slate-900, html.dark .text-slate-800, html.dark .text-slate-700,
    html.dark .text-slate-600, html.dark .text-gray-900, html.dark .text-gray-800,
    html.dark .text-gray-700 { color: #000 !important; }
}
