/* ==========================================================================
   Tema escuro do portal.
   
   O portal foi escrito inteiro em utilitários claros do Tailwind (bg-white,
   text-gray-900, border-gray-200...). Reescrever cada template com variantes
   `dark:` seriam milhares de edições espalhadas por dezenas de módulos, com
   risco alto de esquecer telas.
   
   Aqui a abordagem é outra: uma camada que remapeia os utilitários usados no
   projeto quando o <html> tem a classe `dark`. Um arquivo, todas as telas.
   
   Especificidade: `html.dark .bg-white` (0,2,1) ganha de `.bg-white` (0,1,0)
   do Tailwind sem precisar de !important — exceto onde o próprio Tailwind usa
   variantes (hover:, focus:), que também ficam cobertas por serem prefixadas
   pelo mesmo seletor.
   ========================================================================== */

html.dark {
    /* Superfícies, da mais funda para a mais alta */
    --tema-fundo:        #12161f;   /* fundo da página */
    --tema-superficie:   #1b2130;   /* cartões, tabelas, modais */
    --tema-superficie-2: #232a3b;   /* zebra, cabeçalho de tabela, hover */
    --tema-superficie-3: #2b3346;   /* campos e realces */

    /* Texto */
    --tema-texto:        #e7eaf0;
    --tema-texto-2:      #b6bdcc;
    --tema-texto-3:      #8b93a5;

    --tema-borda:        #313a4f;
    --tema-borda-suave:  #262e40;

    color-scheme: dark;
}

/* --------------------------------------------------------------------------
   Base
   -------------------------------------------------------------------------- */
/* O body carrega `bg-gray-100` no template. Sem repetir a classe aqui, aquela
   regra (mais específica) venceria e o fundo da página ficaria mais claro que
   os cartões — o contrário do que se espera. */
html.dark body,
html.dark body.bg-gray-100,
html.dark body.bg-gray-50,
html.dark body.bg-white { background-color: var(--tema-fundo); color: var(--tema-texto); }

html.dark .bg-white,
html.dark .bg-gray-50\/50,
html.dark .bg-white\/90 { background-color: var(--tema-superficie); }

/* Variantes com opacidade (bg-white/90, bg-gray-50/80...). O Tailwind gera uma
   classe por combinação; o seletor por atributo pega todas de uma vez. */
html.dark [class*="bg-white/"]   { background-color: var(--tema-superficie); }
html.dark [class*="bg-gray-50/"],
html.dark [class*="bg-gray-100/"] { background-color: var(--tema-superficie-2); }

html.dark .bg-gray-50  { background-color: var(--tema-superficie-2); }
html.dark .bg-gray-100 { background-color: var(--tema-superficie-2); }
html.dark .bg-gray-200 { background-color: var(--tema-superficie-3); }

/* O fundo da página vem do body; um main com bg-gray-100 não pode ficar mais
   claro que os cartões que ele carrega. */
html.dark main.bg-gray-100,
html.dark main.bg-gray-50 { background-color: var(--tema-fundo); }

/* --------------------------------------------------------------------------
   Texto
   -------------------------------------------------------------------------- */
html.dark .text-gray-900,
html.dark .text-gray-800,
html.dark .text-black    { color: var(--tema-texto); }
html.dark .text-gray-700,
html.dark .text-gray-600 { color: var(--tema-texto-2); }
html.dark .text-gray-500,
html.dark .text-gray-400,
html.dark .text-gray-300 { color: var(--tema-texto-3); }

/* Ícones decorativos muito apagados sumiriam no escuro. */
html.dark .text-gray-200,
html.dark .text-gray-100 { color: #4a5468; }

/* --------------------------------------------------------------------------
   Bordas e divisórias
   -------------------------------------------------------------------------- */
html.dark .border-gray-100,
html.dark .border-gray-200,
html.dark .border-gray-300,
html.dark .border          { border-color: var(--tema-borda); }
html.dark .border-gray-50  { border-color: var(--tema-borda-suave); }

html.dark .divide-gray-100 > :not([hidden]) ~ :not([hidden]),
html.dark .divide-gray-200 > :not([hidden]) ~ :not([hidden]),
html.dark .divide-gray-50  > :not([hidden]) ~ :not([hidden]) {
    border-color: var(--tema-borda);
}

/* Borda só com o lado e sem cor (border-b, border-t…): o Tailwind usa a cor do
   preflight (#e5e7eb), e no escuro sobra uma linha branca brilhando entre o
   cabeçalho e o corpo de painéis e modais. O `:where()` zera a especificidade
   do `html.dark` e o `:is()` conta como um elemento (0,0,1): ganha do preflight
   (0,0,0) e perde de qualquer cor explícita (`border-orange-500`, 0,1,0), então
   borda de destaque continua colorida. */
:where(html.dark) :is(div, section, article, aside, header, footer, main, nav, span, p, a, button,
    label, ul, ol, li, dl, dt, dd, table, thead, tbody, tfoot, tr, th, td, form, fieldset,
    hr, h1, h2, h3, h4, h5, h6, details, summary, figure, img, i) { border-color: var(--tema-borda); }

/* Divisórias pastel (divide-amber-50, divide-rose-50…) viram fios quase
   brancos entre os itens; no escuro todas usam a borda do tema. */
html.dark [class*="divide-"] > :not([hidden]) ~ :not([hidden]) { border-color: var(--tema-borda); }

/* --------------------------------------------------------------------------
   Interação
   -------------------------------------------------------------------------- */
html.dark .hover\:bg-gray-50:hover,
html.dark .hover\:bg-gray-100:hover { background-color: var(--tema-superficie-2); }
html.dark .hover\:bg-gray-200:hover { background-color: var(--tema-superficie-3); }
html.dark .hover\:bg-white:hover    { background-color: var(--tema-superficie-2); }
html.dark .hover\:text-gray-900:hover,
html.dark .hover\:text-gray-800:hover { color: var(--tema-texto); }
html.dark .hover\:text-gray-700:hover { color: var(--tema-texto-2); }
html.dark .hover\:text-gray-600:hover,
html.dark .hover\:text-gray-500:hover { color: var(--tema-texto); }

/* Hover pastel (hover:bg-orange-50…): no claro o fundo clareia sob texto
   escuro; no escuro o texto já foi clareado, e o pastel o apagava. Vira o
   mesmo translúcido das etiquetas, um pouco mais forte que o repouso. */
html.dark .hover\:bg-red-50:hover, html.dark .hover\:bg-red-100:hover { background-color: rgba(239, 68, 68, .22); }
html.dark .hover\:bg-red-200:hover { background-color: rgba(239, 68, 68, .30); }
html.dark [class*="hover:bg-red-50/"]:hover { background-color: rgba(239, 68, 68, .12); }
html.dark .hover\:bg-rose-50:hover, html.dark .hover\:bg-rose-100:hover { background-color: rgba(244, 63, 94, .22); }
html.dark .hover\:bg-rose-200:hover { background-color: rgba(244, 63, 94, .30); }
html.dark [class*="hover:bg-rose-50/"]:hover { background-color: rgba(244, 63, 94, .12); }
html.dark .hover\:bg-orange-50:hover, html.dark .hover\:bg-orange-100:hover { background-color: rgba(249, 115, 22, .22); }
html.dark .hover\:bg-orange-200:hover { background-color: rgba(249, 115, 22, .30); }
html.dark [class*="hover:bg-orange-50/"]:hover { background-color: rgba(249, 115, 22, .12); }
html.dark .hover\:bg-amber-50:hover, html.dark .hover\:bg-amber-100:hover { background-color: rgba(245, 158, 11, .22); }
html.dark .hover\:bg-amber-200:hover { background-color: rgba(245, 158, 11, .30); }
html.dark [class*="hover:bg-amber-50/"]:hover { background-color: rgba(245, 158, 11, .12); }
html.dark .hover\:bg-yellow-50:hover, html.dark .hover\:bg-yellow-100:hover { background-color: rgba(234, 179, 8, .22); }
html.dark .hover\:bg-yellow-200:hover { background-color: rgba(234, 179, 8, .30); }
html.dark [class*="hover:bg-yellow-50/"]:hover { background-color: rgba(234, 179, 8, .12); }
html.dark .hover\:bg-green-50:hover, html.dark .hover\:bg-green-100:hover { background-color: rgba(34, 197, 94, .22); }
html.dark .hover\:bg-green-200:hover { background-color: rgba(34, 197, 94, .30); }
html.dark [class*="hover:bg-green-50/"]:hover { background-color: rgba(34, 197, 94, .12); }
html.dark .hover\:bg-emerald-50:hover, html.dark .hover\:bg-emerald-100:hover { background-color: rgba(16, 185, 129, .22); }
html.dark .hover\:bg-emerald-200:hover { background-color: rgba(16, 185, 129, .30); }
html.dark [class*="hover:bg-emerald-50/"]:hover { background-color: rgba(16, 185, 129, .12); }
html.dark .hover\:bg-teal-50:hover, html.dark .hover\:bg-teal-100:hover { background-color: rgba(20, 184, 166, .22); }
html.dark .hover\:bg-teal-200:hover { background-color: rgba(20, 184, 166, .30); }
html.dark [class*="hover:bg-teal-50/"]:hover { background-color: rgba(20, 184, 166, .12); }
html.dark .hover\:bg-cyan-50:hover, html.dark .hover\:bg-cyan-100:hover { background-color: rgba(6, 182, 212, .22); }
html.dark .hover\:bg-cyan-200:hover { background-color: rgba(6, 182, 212, .30); }
html.dark [class*="hover:bg-cyan-50/"]:hover { background-color: rgba(6, 182, 212, .12); }
html.dark .hover\:bg-sky-50:hover, html.dark .hover\:bg-sky-100:hover { background-color: rgba(14, 165, 233, .22); }
html.dark .hover\:bg-sky-200:hover { background-color: rgba(14, 165, 233, .30); }
html.dark [class*="hover:bg-sky-50/"]:hover { background-color: rgba(14, 165, 233, .12); }
html.dark .hover\:bg-blue-50:hover, html.dark .hover\:bg-blue-100:hover { background-color: rgba(59, 130, 246, .22); }
html.dark .hover\:bg-blue-200:hover { background-color: rgba(59, 130, 246, .30); }
html.dark [class*="hover:bg-blue-50/"]:hover { background-color: rgba(59, 130, 246, .12); }
html.dark .hover\:bg-indigo-50:hover, html.dark .hover\:bg-indigo-100:hover { background-color: rgba(99, 102, 241, .22); }
html.dark .hover\:bg-indigo-200:hover { background-color: rgba(99, 102, 241, .30); }
html.dark [class*="hover:bg-indigo-50/"]:hover { background-color: rgba(99, 102, 241, .12); }
html.dark .hover\:bg-violet-50:hover, html.dark .hover\:bg-violet-100:hover { background-color: rgba(139, 92, 246, .22); }
html.dark .hover\:bg-violet-200:hover { background-color: rgba(139, 92, 246, .30); }
html.dark [class*="hover:bg-violet-50/"]:hover { background-color: rgba(139, 92, 246, .12); }
html.dark .hover\:bg-purple-50:hover, html.dark .hover\:bg-purple-100:hover { background-color: rgba(168, 85, 247, .22); }
html.dark .hover\:bg-purple-200:hover { background-color: rgba(168, 85, 247, .30); }
html.dark [class*="hover:bg-purple-50/"]:hover { background-color: rgba(168, 85, 247, .12); }
html.dark .hover\:bg-pink-50:hover, html.dark .hover\:bg-pink-100:hover { background-color: rgba(236, 72, 153, .22); }
html.dark .hover\:bg-pink-200:hover { background-color: rgba(236, 72, 153, .30); }
html.dark [class*="hover:bg-pink-50/"]:hover { background-color: rgba(236, 72, 153, .12); }

/* --------------------------------------------------------------------------
   Formulários — o ponto onde tema escuro costuma falhar: campo branco com
   texto branco. Cor de fundo e de texto vão juntas, sempre.
   -------------------------------------------------------------------------- */
html.dark input[type="text"], html.dark input[type="email"], html.dark input[type="password"],
html.dark input[type="number"], html.dark input[type="search"], html.dark input[type="tel"],
html.dark input[type="url"], html.dark input[type="date"], html.dark input[type="time"],
html.dark input[type="datetime-local"], html.dark input[type="month"], html.dark input[type="file"],
html.dark textarea, html.dark select {
    background-color: var(--tema-superficie-3);
    color: var(--tema-texto);
    border-color: var(--tema-borda);
}
html.dark input::placeholder, html.dark textarea::placeholder { color: var(--tema-texto-3); }
html.dark option { background-color: var(--tema-superficie-3); color: var(--tema-texto); }
html.dark input[type="file"]::file-selector-button {
    background-color: var(--tema-superficie-2);
    color: var(--tema-texto-2);
    border: 0;
}
html.dark input:disabled, html.dark textarea:disabled, html.dark select:disabled {
    background-color: var(--tema-superficie-2);
    color: var(--tema-texto-3);
}

/* --------------------------------------------------------------------------
   Etiquetas coloridas (bg-*-50 / bg-*-100 com texto escuro).
   No claro são pastéis; no escuro viram fundo translúcido da mesma cor, com o
   texto puxado para o tom claro — a informação da cor se mantém.
   -------------------------------------------------------------------------- */
html.dark .bg-red-50,    html.dark .bg-red-100    { background-color: rgba(239, 68, 68, .16); }
html.dark .bg-rose-50,   html.dark .bg-rose-100   { background-color: rgba(244, 63, 94, .16); }
html.dark .bg-orange-50, html.dark .bg-orange-100 { background-color: rgba(249, 115, 22, .16); }
html.dark .bg-amber-50,  html.dark .bg-amber-100  { background-color: rgba(245, 158, 11, .16); }
html.dark .bg-yellow-50, html.dark .bg-yellow-100 { background-color: rgba(234, 179, 8, .16); }
html.dark .bg-green-50,  html.dark .bg-green-100  { background-color: rgba(34, 197, 94, .16); }
html.dark .bg-emerald-50,html.dark .bg-emerald-100{ background-color: rgba(16, 185, 129, .16); }
html.dark .bg-teal-50,   html.dark .bg-teal-100   { background-color: rgba(20, 184, 166, .16); }
html.dark .bg-cyan-50,   html.dark .bg-cyan-100   { background-color: rgba(6, 182, 212, .16); }
html.dark .bg-sky-50,    html.dark .bg-sky-100    { background-color: rgba(14, 165, 233, .16); }
html.dark .bg-blue-50,   html.dark .bg-blue-100   { background-color: rgba(59, 130, 246, .16); }
html.dark .bg-indigo-50, html.dark .bg-indigo-100 { background-color: rgba(99, 102, 241, .16); }
html.dark .bg-violet-50, html.dark .bg-violet-100 { background-color: rgba(139, 92, 246, .16); }
html.dark .bg-purple-50, html.dark .bg-purple-100 { background-color: rgba(168, 85, 247, .16); }
html.dark .bg-pink-50,   html.dark .bg-pink-100   { background-color: rgba(236, 72, 153, .16); }
html.dark .bg-slate-50,  html.dark .bg-slate-100  { background-color: var(--tema-superficie-2); }

html.dark .text-red-600,     html.dark .text-red-700,     html.dark .text-red-800     { color: #f87171; }
html.dark .text-rose-600,    html.dark .text-rose-700,    html.dark .text-rose-800    { color: #fb7185; }
html.dark .text-orange-600,  html.dark .text-orange-700,  html.dark .text-orange-800  { color: #fb923c; }
html.dark .text-amber-600,   html.dark .text-amber-700,   html.dark .text-amber-800,
html.dark .text-amber-900 { color: #fbbf24; }
html.dark .text-yellow-600,  html.dark .text-yellow-700,  html.dark .text-yellow-800  { color: #facc15; }
html.dark .text-green-600,   html.dark .text-green-700,   html.dark .text-green-800   { color: #4ade80; }
html.dark .text-emerald-600, html.dark .text-emerald-700, html.dark .text-emerald-800,
html.dark .text-emerald-900 { color: #34d399; }
html.dark .text-teal-600,    html.dark .text-teal-700,    html.dark .text-teal-800    { color: #2dd4bf; }
html.dark .text-cyan-600,    html.dark .text-cyan-700,    html.dark .text-cyan-800    { color: #22d3ee; }
html.dark .text-sky-600,     html.dark .text-sky-700,     html.dark .text-sky-800,
html.dark .text-sky-900 { color: #38bdf8; }
html.dark .text-blue-600,    html.dark .text-blue-700,    html.dark .text-blue-800    { color: #60a5fa; }
html.dark .text-indigo-600,  html.dark .text-indigo-700,  html.dark .text-indigo-800  { color: #818cf8; }
html.dark .text-violet-600,  html.dark .text-violet-700,  html.dark .text-violet-800  { color: #a78bfa; }
html.dark .text-purple-600,  html.dark .text-purple-700,  html.dark .text-purple-800  { color: #c084fc; }
html.dark .text-pink-600,    html.dark .text-pink-700,    html.dark .text-pink-800    { color: #f472b6; }
html.dark .text-slate-700,   html.dark .text-slate-800,   html.dark .text-slate-900   { color: var(--tema-texto); }
html.dark .text-slate-500,   html.dark .text-slate-600    { color: var(--tema-texto-2); }
html.dark .text-orange-900 { color: #fdba74; }
html.dark .text-rose-900   { color: #fda4af; }

/* Bordas claras das mesmas etiquetas */
html.dark .border-red-100,     html.dark .border-red-200     { border-color: rgba(239, 68, 68, .3); }
html.dark .border-orange-100,  html.dark .border-orange-200  { border-color: rgba(249, 115, 22, .3); }
html.dark .border-amber-100,   html.dark .border-amber-200   { border-color: rgba(245, 158, 11, .3); }
html.dark .border-green-100,   html.dark .border-green-200   { border-color: rgba(34, 197, 94, .3); }
html.dark .border-emerald-100, html.dark .border-emerald-200 { border-color: rgba(16, 185, 129, .3); }
html.dark .border-sky-100,     html.dark .border-sky-200     { border-color: rgba(14, 165, 233, .3); }
html.dark .border-blue-100,    html.dark .border-blue-200    { border-color: rgba(59, 130, 246, .3); }
html.dark .border-teal-100,    html.dark .border-teal-200    { border-color: rgba(20, 184, 166, .3); }
html.dark .border-rose-100,    html.dark .border-rose-200    { border-color: rgba(244, 63, 94, .3); }
html.dark .border-purple-100,  html.dark .border-purple-200  { border-color: rgba(168, 85, 247, .3); }

/* --------------------------------------------------------------------------
   Degradês claros (bg-gradient-to-* com paradas -50/-100).
   O Tailwind os desenha como background-image, então as regras de cor de fundo
   acima não os alcançam: sem isto, esses cartões continuariam brancos e
   brilhando no meio de uma tela escura.
   -------------------------------------------------------------------------- */
html.dark [class*="bg-gradient-to-"].from-red-50,    html.dark [class*="bg-gradient-to-"].from-red-100,
html.dark [class*="bg-gradient-to-"].from-orange-50, html.dark [class*="bg-gradient-to-"].from-orange-100,
html.dark [class*="bg-gradient-to-"].from-amber-50,  html.dark [class*="bg-gradient-to-"].from-amber-100,
html.dark [class*="bg-gradient-to-"].from-yellow-50, html.dark [class*="bg-gradient-to-"].from-yellow-100,
html.dark [class*="bg-gradient-to-"].from-green-50,  html.dark [class*="bg-gradient-to-"].from-green-100,
html.dark [class*="bg-gradient-to-"].from-emerald-50,html.dark [class*="bg-gradient-to-"].from-emerald-100,
html.dark [class*="bg-gradient-to-"].from-teal-50,   html.dark [class*="bg-gradient-to-"].from-cyan-50,
html.dark [class*="bg-gradient-to-"].from-sky-50,    html.dark [class*="bg-gradient-to-"].from-sky-100,
html.dark [class*="bg-gradient-to-"].from-blue-50,   html.dark [class*="bg-gradient-to-"].from-blue-100,
html.dark [class*="bg-gradient-to-"].from-indigo-50, html.dark [class*="bg-gradient-to-"].from-violet-50,
html.dark [class*="bg-gradient-to-"].from-purple-50, html.dark [class*="bg-gradient-to-"].from-purple-100,
html.dark [class*="bg-gradient-to-"].from-pink-50,   html.dark [class*="bg-gradient-to-"].from-gray-50,
html.dark [class*="bg-gradient-to-"].from-rose-50,   html.dark [class*="bg-gradient-to-"].from-rose-100,
html.dark [class*="bg-gradient-to-"].from-orange-200,html.dark [class*="bg-gradient-to-"].from-amber-200,
html.dark [class*="bg-gradient-to-"].from-slate-50 {
    background-image: none;
    background-color: var(--tema-superficie-2);
}

/* --------------------------------------------------------------------------
   Conteúdo escrito pelas pessoas (comunicados, descrições ricas).
   
   Esse HTML vem com cor embutida no próprio texto — inclusive a cor que o
   autor escolheu no editor. Estilo embutido ganha de qualquer folha, então
   tentar clarear esse texto seria inútil e ainda destruiria a escolha de quem
   escreveu. A saída é dar a ele o fundo claro para o qual foi escrito: vira
   uma folha de papel dentro da tela escura, e continua legível.
   -------------------------------------------------------------------------- */
html.dark .prose {
    background-color: #f6f7f9;
    color: #1f2937;
    border-radius: .5rem;
    padding: .75rem 1rem;
}
html.dark .prose a { color: #1d4ed8; }

/* --------------------------------------------------------------------------
   Sombras: no escuro, sombra preta não separa nada de um fundo preto.
   Trocadas por um contorno sutil, que é o que dá o relevo.
   -------------------------------------------------------------------------- */
html.dark .shadow-sm { box-shadow: 0 0 0 1px var(--tema-borda-suave); }
html.dark .shadow,
html.dark .shadow-md { box-shadow: 0 1px 3px rgba(0,0,0,.5), 0 0 0 1px var(--tema-borda-suave); }
html.dark .shadow-lg,
html.dark .shadow-xl,
html.dark .shadow-2xl { box-shadow: 0 8px 24px rgba(0,0,0,.6), 0 0 0 1px var(--tema-borda); }

/* --------------------------------------------------------------------------
   Detalhes
   -------------------------------------------------------------------------- */
/* O menu lateral já é escuro no tema claro: fica como está. */
html.dark #sidebar { background-color: #0b0e15; }

/* Barras de rolagem acompanham, senão viram duas faixas brancas na tela. */
html.dark ::-webkit-scrollbar { width: 10px; height: 10px; }
html.dark ::-webkit-scrollbar-track { background: var(--tema-fundo); }
html.dark ::-webkit-scrollbar-thumb { background: #3a4358; border-radius: 6px; }
html.dark ::-webkit-scrollbar-thumb:hover { background: #4a5470; }

/* Imagens e gráficos ficam intocados de propósito: inverter foto de pessoa ou
   logo produz resultado pior que deixar como está. */
html.dark img, html.dark canvas, html.dark svg image { filter: none; }

/* Impressão sai sempre no claro: papel é branco. */
@media print {
    html.dark, html.dark body { background: #fff !important; color: #000 !important; }
    html.dark .bg-white, html.dark .bg-gray-50, html.dark .bg-gray-100 { background: #fff !important; }
}

/* ==========================================================================
   Classes próprias dos módulos.

   Vários módulos definem o próprio cartão em <style> no template (.imp-card,
   .cx-card, .vl-card, .tg-card...) com branco fixo, em vez de usar utilitário
   do Tailwind. A camada acima não alcança nenhuma delas — por isso a tela
   ficava escura com cartões brancos no meio.

   Estas regras vêm depois na folha e usam !important porque o estilo do módulo
   está num <style> dentro do <head> da própria página, e num empate de
   especificidade quem aparece por último no documento vence.
   ========================================================================== */

/* Cartões e superfícies */
html.dark .imp-card,
html.dark .tg-card,
html.dark .cx-card,
html.dark .vd-card,
html.dark .vl-card,
html.dark .mp-card,
html.dark .vd-secao,
html.dark .cx-data {
    background: var(--tema-superficie) !important;
    border-color: var(--tema-borda) !important;
    color: var(--tema-texto);
}

/* Cabeçalhos de seção e faixas de topo (degradês claros) */
html.dark .imp-hero,
html.dark .tg-hero,
html.dark .cx-hero {
    background: linear-gradient(180deg, #1e2534 0%, #1a202d 100%) !important;
    border-color: var(--tema-borda) !important;
}
html.dark .vd-secao-cabeca {
    background: var(--tema-superficie-2) !important;
    border-bottom-color: var(--tema-borda) !important;
}

/* Aba ativa: no claro é um pastel; no escuro, o mesmo destaque translúcido */
html.dark .imp-tab-active { background: rgba(234, 88, 12, .18) !important; color: #fb923c !important; }
html.dark .cx-tab-active  { background: rgba(139, 92, 246, .18) !important; color: #c4b5fd !important; }
html.dark .tg-tab-active  { background: rgba(6, 182, 212, .18) !important;  color: #67e8f9 !important; }
html.dark .vd-tab-ativa   { background: rgba(234, 88, 12, .18) !important;  color: #fb923c !important; }

/* Trilhos de barra de progresso */
html.dark .imp-bar-track,
html.dark .vd-barra { background: var(--tema-superficie-3) !important; }

/* Etiquetas de estado da contagem de caixa */
html.dark .cx-ok       { background: rgba(34, 197, 94, .18) !important;  color: #4ade80 !important; }
html.dark .cx-pendente { background: rgba(59, 130, 246, .18) !important; color: #60a5fa !important; }
html.dark .cx-atencao  { background: rgba(245, 158, 11, .18) !important; color: #fbbf24 !important; }
html.dark .cx-negativo { color: #f87171 !important; }

/* Campos e botões próprios dos módulos */
html.dark .vd-campo,
html.dark .cx-entrada {
    background: var(--tema-superficie-3) !important;
    border-color: var(--tema-borda) !important;
    color: var(--tema-texto) !important;
}
html.dark .vd-ajuda { color: var(--tema-texto-3) !important; }
html.dark .btn-back {
    background: var(--tema-superficie-2) !important;
    color: var(--tema-texto-2) !important;
    border-color: var(--tema-borda) !important;
}
html.dark .btn-back:hover { background: var(--tema-superficie-3) !important; }

/* Linha destacada da contestação de valores */
html.dark .vl-diverge { background: rgba(249, 115, 22, .10) !important; }
html.dark .vl-diverge:hover { background: rgba(249, 115, 22, .16) !important; }

/* Linha clicável do mapa */
html.dark .mp-pessoa:hover     { background: var(--tema-superficie-2) !important; }
html.dark .mp-pessoa.selecionada { background: rgba(139, 92, 246, .18) !important; }

/* --------------------------------------------------------------------------
   A folha A4 da folha de ponto continua branca de propósito: é a
   representação de um documento impresso, e escurecê-la só confundiria quem
   confere antes de imprimir.
   -------------------------------------------------------------------------- */
html.dark .sheet { background: #fff !important; color: #111827 !important; }
html.dark .sheet * { border-color: #d1d5db !important; }

/* --------------------------------------------------------------------------
   Agenda: painel próprio + FullCalendar.

   O FullCalendar 6 desenha tudo a partir de variáveis CSS próprias; redefini-las
   é mais confiável do que perseguir cada uma das dezenas de classes `.fc-*`, e
   sobrevive a uma atualização da biblioteca.
   -------------------------------------------------------------------------- */
html.dark .agenda-panel {
    background: var(--tema-superficie) !important;
    border-color: var(--tema-borda) !important;
    box-shadow: 0 0 0 1px var(--tema-borda-suave) !important;
}

html.dark .fc {
    --fc-page-bg-color: var(--tema-superficie);
    --fc-neutral-bg-color: var(--tema-superficie-2);
    --fc-neutral-text-color: var(--tema-texto-2);
    --fc-border-color: var(--tema-borda);
    --fc-today-bg-color: rgba(234, 88, 12, .14);
    --fc-list-event-hover-bg-color: var(--tema-superficie-2);
    --fc-highlight-color: rgba(59, 130, 246, .18);
    color: var(--tema-texto);
}
html.dark .fc .fc-daygrid-day-number,
html.dark .fc .fc-col-header-cell-cushion,
html.dark .fc .fc-list-day-text,
html.dark .fc .fc-list-day-side-text,
html.dark .fc .fc-timegrid-slot-label-cushion,
html.dark .fc .fc-toolbar-title { color: var(--tema-texto) !important; }

html.dark .fc .fc-day-other .fc-daygrid-day-number { color: var(--tema-texto-3) !important; }
html.dark .fc-theme-standard td,
html.dark .fc-theme-standard th,
html.dark .fc-theme-standard .fc-scrollgrid { border-color: var(--tema-borda) !important; }
html.dark .fc-theme-standard .fc-list { border-color: var(--tema-borda) !important; }
html.dark .fc .fc-list-empty { background-color: var(--tema-superficie-2) !important; }

/* O template da agenda pinta o dia de hoje com uma variável própria
   (--agenda-brand-soft), um laranja bem claro. Redefinimos a variável em vez
   de sobrescrever a regra: assim o realce continua sendo "laranja da marca",
   só que na versão que funciona no escuro. */
html.dark { --agenda-brand-soft: rgba(234, 88, 12, .16) !important; }

/* Botões da barra do calendário */
html.dark .fc .fc-button-primary {
    background-color: var(--tema-superficie-3);
    border-color: var(--tema-borda);
    color: var(--tema-texto);
}
html.dark .fc .fc-button-primary:not(:disabled):hover { background-color: #3a4358; }
html.dark .fc .fc-button-primary:disabled { background-color: var(--tema-superficie-2); color: var(--tema-texto-3); }
/* O botão de visão ativa (Mês, Semana…) segue laranja no escuro, de propósito. */
html.dark .fc .fc-button-primary:not(:disabled).fc-button-active,
html.dark .fc .fc-button-primary:not(:disabled):active { background-color: #c2410c; border-color: #c2410c; color: #fff; }

/* Eventos "com bolinha" e o "+N mais": o hover do FullCalendar é preto
   translúcido, invisível sobre superfície escura. */
html.dark .fc .fc-daygrid-dot-event:hover,
html.dark .fc .fc-daygrid-dot-event.fc-event-mirror,
html.dark .fc .fc-daygrid-more-link:hover { background: rgba(255, 255, 255, .08); }

/* Cor escolhida no modal de evento: o anel escuro do claro some no escuro. */
html.dark .color-option.selected { border-color: #fff; box-shadow: 0 0 0 2px var(--tema-superficie), 0 0 0 4px #fff; }

/* --------------------------------------------------------------------------
   Agenda e transcrições (/agenda/, /agenda/transcricoes/…).

   As molduras e cartões dessas telas são classes próprias com degradê quase
   branco e borda rosa-claro no <style> do template: no escuro ficavam painéis
   escuros flutuando num retângulo branco, com o texto já clareado por cima.
   -------------------------------------------------------------------------- */
html.dark .agenda-shell,
html.dark .trans-detail-shell {
    background: var(--tema-fundo) !important;
    border-color: var(--tema-borda) !important;
    box-shadow: none !important;
}
html.dark .trans-list-shell,
html.dark .trans-shell,
html.dark .grav-shell {
    background: var(--tema-superficie) !important;
    border-color: var(--tema-borda) !important;
    box-shadow: 0 0 0 1px var(--tema-borda-suave) !important;
}
html.dark .trans-list-card,
html.dark .trans-panel {
    border-color: var(--tema-borda) !important;
    box-shadow: 0 0 0 1px var(--tema-borda-suave) !important;
}
html.dark .trans-card,
html.dark .grav-card {
    background: var(--tema-superficie-2) !important;
    border-color: var(--tema-borda) !important;
    box-shadow: none !important;
}
html.dark .section-card:hover { border-color: rgba(249, 115, 22, .45) !important; }

/* Método de entrada escolhido e as pílulas de papel */
html.dark .mode-card-active {
    background: rgba(234, 88, 12, .18) !important;
    border-color: #fb923c !important;
    box-shadow: none !important;
}
html.dark .role-pill {
    background: rgba(249, 115, 22, .16) !important;
    border-color: rgba(249, 115, 22, .35) !important;
    color: #fb923c !important;
}

/* Status das transcrições na lista */
html.dark .status-completed  { background: rgba(34, 197, 94, .18) !important;  color: #4ade80 !important; }
html.dark .status-processing { background: rgba(249, 115, 22, .18) !important; color: #fb923c !important; }
html.dark .status-recording,
html.dark .status-error      { background: rgba(239, 68, 68, .18) !important;  color: #f87171 !important; }

/* Chips translúcidos sobre os cabeçalhos laranja. A regra geral de
   `bg-white/NN` os pintaria de superfície escura sólida — viravam remendos
   pretos sobre o laranja, que continua laranja no escuro. */
html.dark .trans-header [class*="bg-white/"],
html.dark .trans-shell > .bg-gradient-to-r [class*="bg-white/"],
html.dark #share-modal .bg-gradient-to-r [class*="bg-white/"] {
    background-color: rgba(255, 255, 255, .16) !important;
    border-color: rgba(255, 255, 255, .3) !important;
}
html.dark .trans-header [class*="hover:bg-white/"]:hover,
html.dark #share-modal .bg-gradient-to-r [class*="hover:bg-white/"]:hover {
    background-color: rgba(255, 255, 255, .26) !important;
}
/* O botão "Compartilhar" é o destaque branco do cabeçalho: segue branco. */
html.dark .trans-header .bg-white { background-color: #fff !important; color: #c2410c !important; }
html.dark .trans-header .bg-white:hover { background-color: #ffedd5 !important; }

/* Etiqueta de status "gravando" no cabeçalho: cinza-claro com texto já clareado. */
html.dark .trans-header .bg-gray-300 { background-color: var(--tema-superficie-3) !important; }

html.dark .nice-scroll::-webkit-scrollbar-thumb { background: #3a4358; }
html.dark .nice-scroll::-webkit-scrollbar-thumb:hover { background: #4a5470; }

/* --------------------------------------------------------------------------
   Contestação — lista de exclusões e de valores.

   Aqui a tela não estava só "sem regra": o template pinta a zebra da tabela,
   o painel do carrinho e o balão do motivo com branco fixo e `!important`
   dentro do próprio <style>. Empate de importância se decide pela
   especificidade, e por isso cada seletor abaixo começa com `html.dark` —
   é o que faz a regra do tema ganhar do branco cravado no template.
   -------------------------------------------------------------------------- */

/* As variáveis que o template usa no cabeçalho, nas bordas e — depois de
   trocarmos as cores fixas por `var()` — nos estilos inline. Trocar a variável
   é o único caminho que alcança um `style="... !important"` no HTML: nenhuma
   folha de estilo ganha de um inline com !important. */
html.dark {
    --light-gray: var(--tema-superficie-2);
    --border-gray: var(--tema-borda);

    --ct-superficie: var(--tema-superficie);
    --ct-campo: var(--tema-superficie-3);
    --ct-borda: var(--tema-borda);
    --ct-borda-campo: var(--tema-borda);
    --ct-texto: var(--tema-texto);
    --ct-texto-2: var(--tema-texto-2);
    --ct-texto-3: var(--tema-texto-3);
    --ct-zebra: var(--tema-superficie-2);
    --ct-hover: var(--tema-superficie-3);
    /* O carrinho continua sendo o realce laranja, mas na versão que funciona
       sobre fundo escuro — creme com texto claro seria ilegível. */
    --ct-carrinho: var(--tema-superficie);
    --ct-carrinho-borda: #b45309;
    --ct-carrinho-borda-2: #92400e;
}

/* Zebra da tabela e hover da linha */
html.dark .line-white > td      { background-color: var(--tema-superficie) !important; }
html.dark .line-light-gray > td { background-color: var(--tema-superficie-2) !important; }
html.dark .data-row:hover > td  { background-color: var(--tema-superficie-3) !important; }
html.dark .data-row > td        { color: var(--tema-texto); }

/* Cartões da versão em lista (celular) — o template crava a borda cinza-claro
   num style inline, então a cor vem daqui. */
html.dark #cardsContainer > div[id^="card-"] {
    background-color: var(--tema-superficie) !important;
    border-color: var(--tema-borda) !important;
    color: var(--tema-texto);
}
html.dark div[id^="reason-card-"] { border-top-color: var(--tema-borda) !important; }

/* Balão do motivo da exclusão */
html.dark .reason-content {
    background: var(--tema-superficie-2) !important;
    border-color: var(--primary) !important;
    color: var(--tema-texto);
    box-shadow: 0 14px 34px rgba(0, 0, 0, .45), 0 0 0 4px rgba(255, 107, 53, .18) !important;
}

/* Carrinho de contestação em lote: no claro é um creme alaranjado; no escuro
   mantemos o laranja como realce, mas sobre superfície escura — creme com
   texto claro ficaria ilegível. */
html.dark #bulkBar { background: rgba(120, 53, 15, .35) !important; }
html.dark #bulkBar .bulk-panel {
    background: var(--tema-superficie) !important;
    border-color: #b45309 !important;
    box-shadow: 0 24px 50px rgba(0, 0, 0, .55), 0 0 0 6px rgba(180, 83, 9, .25) !important;
}
html.dark #bulkBar .bulk-details {
    background-color: var(--tema-superficie-2) !important;
    border-top-color: #b45309 !important;
}
html.dark #bulkBar .bulk-detail-item {
    background-color: var(--tema-superficie) !important;
    border-color: #b45309 !important;
    color: var(--tema-texto) !important;
}

/* Divisores das tabelas da contestação */
html.dark .divide-gray-400 > :not([hidden]) ~ :not([hidden]) {
    border-color: var(--tema-borda) !important;
}

/* --------------------------------------------------------------------------
   Escala (/ponto/escala/).

   A grade define as próprias cores num <style> do template: borda clara,
   cabeçalho branco e — o que mais atrapalha — a coluna do nome com `background:
   #fff` fixo, porque ela é sticky e precisa tapar as células que passam por
   baixo. No escuro isso virava uma faixa branca atravessando a tabela.
   -------------------------------------------------------------------------- */
html.dark .esc-grid th,
html.dark .esc-grid td { border-color: var(--tema-borda) !important; }

html.dark .esc-grid thead th { background: var(--tema-superficie-2) !important; }

/* A coluna fixa do nome: mesma superfície do cartão, senão a rolagem
   horizontal mostra o texto passando por baixo. */
html.dark .esc-nome { background: var(--tema-superficie) !important; }
html.dark .esc-grid thead .esc-nome { background: var(--tema-superficie-2) !important; }

/* Campos de horário */
html.dark .esc-time {
    background-color: var(--tema-superficie-3) !important;
    border-color: var(--tema-borda) !important;
    color: var(--tema-texto) !important;
}
html.dark .esc-time::-webkit-calendar-picker-indicator { filter: invert(0.8); }

/* Dia de hoje: o azul do realce continua, sobre fundo escuro */
html.dark .esc-hoje { box-shadow: inset 0 2px 0 #22d3ee !important; }

/* Linha da grade no hover */
html.dark .esc-grid tbody tr:hover .esc-nome { background: var(--tema-superficie-2) !important; }
