/* ======================= Tema (escuro e claro) =======================
   As cores do site vêm destas variáveis (em "R G B", para o Tailwind aplicar transparência).
   O tema é escolhido em <html data-theme="dark|light"> por js/tailwind-config.js (preferência salva
   no navegador; sem escolha, segue o tema do aparelho). Para trocar uma cor, mude-a aqui. */
:root, html[data-theme="dark"] {
  color-scheme: dark;
  --c-canvas: 22 32 19;     /* fundo da página */
  --c-surface: 33 48 28;    /* cartões e campos */
  --c-field: 46 67 40;      /* botões secundários, barras */
  --c-edge: 66 96 57;       /* bordas */
  --c-muted: 162 195 152;   /* texto secundário */
  --c-accent: 83 210 44;    /* ação principal (fundo de botão) */
  --c-mint: 140 210 121;    /* destaque suave (texto) */
  --c-rail: 27 41 23;       /* menu lateral */
  --c-ink: 255 255 255;     /* texto principal */
  --c-onaccent: 22 32 19;   /* texto sobre a cor de ação */
  --focus: #8cd279;
  --tip-shadow: 0 4px 16px rgba(0, 0, 0, 0.45);
}
html[data-theme="light"] {
  color-scheme: light;
  --c-canvas: 238 243 234;
  --c-surface: 255 255 255;
  --c-field: 221 232 214;
  --c-edge: 180 199 171;
  --c-muted: 74 97 66;
  --c-accent: 83 210 44;
  --c-mint: 38 112 15;
  --c-rail: 247 250 245;
  --c-ink: 20 33 15;
  --c-onaccent: 20 33 15;
  --focus: #26700f;
  --tip-shadow: 0 4px 16px rgba(20, 33, 15, 0.18);
}

/* Cores de estado (verde/vermelho/amarelo/azul) pensadas para fundo escuro: versões para o tema claro */
html[data-theme="light"] .text-red-300 { color: #b42318; }
html[data-theme="light"] .text-red-200 { color: #912018; }
html[data-theme="light"] .text-green-300 { color: #1a7f37; }
html[data-theme="light"] .text-yellow-300 { color: #8a5a00; }
html[data-theme="light"] .text-yellow-200 { color: #7a4f00; }
html[data-theme="light"] .text-blue-300 { color: #1d4ed8; }
html[data-theme="light"] .text-accent { color: rgb(var(--c-mint)); } /* mint do tema claro = #26700f por padrão; a retaguarda pode trocar */
html[data-theme="light"] .bg-green-900\/60 { background-color: #d5efcc; }
html[data-theme="light"] .bg-red-900\/60 { background-color: #fbd9d4; }
html[data-theme="light"] .bg-red-900\/40 { background-color: #fde4e0; }
html[data-theme="light"] .bg-yellow-900\/60 { background-color: #fbeab8; }
html[data-theme="light"] .bg-yellow-900\/40 { background-color: #fcf0cc; }
html[data-theme="light"] .bg-yellow-900\/30 { background-color: #fdf3d6; }
html[data-theme="light"] .bg-yellow-900\/20 { background-color: #fef7e3; }
html[data-theme="light"] .bg-blue-900\/60 { background-color: #d9e5fb; }
html[data-theme="light"] .border-yellow-600 { border-color: #c79200; }
html[data-theme="light"] .hover\:bg-red-900:hover { background-color: #f7c2bb; }
html[data-theme="light"] .hover\:bg-green-900:hover { background-color: #bfe5b2; }

/* Estilos globais mínimos. O resto é Tailwind. */

/* Foco visível e consistente para quem navega pelo teclado */
:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

/* O plugin @tailwindcss/forms aplica um anel azul; troca pelo verde do tema */
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--focus) !important;
  outline-offset: 1px !important;
  box-shadow: none !important;
  border-color: var(--focus) !important;
}

/* Controles nativos (calendário, listas) seguem o tema pelo color-scheme definido acima */

/* Respeita quem prefere menos animação */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* Impressão (termo de empréstimo): A4 sem menu, cabeçalho nem rodapé */
@page {
  size: A4;
  margin: 15mm;
}
@media print {
  html,
  body {
    background: #fff !important;
    color: #000 !important;
  }
}

/* Documentos montados a partir de modelos (termo, recibo, balancete): independente do Tailwind */
.doc-body, .doc-editor { font-size: 13px; line-height: 1.5; color: #000; }
.doc-body h1, .doc-editor h1 { font-size: 18px; font-weight: 800; text-transform: uppercase; margin: 12px 0 2px; }
.doc-body h2, .doc-editor h2 { font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; border-bottom: 1px solid #000; padding-bottom: 2px; margin: 18px 0 6px; break-after: avoid; }
.doc-body h3, .doc-editor h3 { font-size: 13px; font-weight: 700; margin: 12px 0 4px; }
.doc-body p, .doc-body div, .doc-editor p, .doc-body div { margin: 0 0 4px; }
.doc-body ul, .doc-editor ul { list-style: disc; padding-left: 20px; margin: 4px 0; }
.doc-body ol, .doc-editor ol { list-style: decimal; padding-left: 20px; margin: 4px 0; text-align: justify; }
.doc-body li, .doc-editor li { margin: 0 0 4px; }
.doc-body b, .doc-body strong, .doc-editor b, .doc-body strong { font-weight: 700; }
.doc-body i, .doc-body em, .doc-editor i, .doc-body em { font-style: italic; }
.doc-body u, .doc-editor u { text-decoration: underline; }
.doc-body hr, .doc-editor hr { border: 0; border-top: 1px solid #000; margin: 10px 0; }
.doc-body blockquote, .doc-editor blockquote { border-left: 3px solid #000; padding-left: 10px; margin: 6px 0; }
.doc-body table, .doc-editor table { width: 100%; border-collapse: collapse; margin: 6px 0; }
.doc-body td, .doc-body th, .doc-editor td, .doc-body th { border: 1px solid #000; padding: 3px 6px; vertical-align: top; }
.doc-body p:empty, .doc-body div:empty, .doc-editor p:empty, .doc-body div:empty { display: none; }
.doc-editor { background: #fff; padding: 24px; min-height: 420px; border-radius: 8px; outline: none; }
.doc-editor:focus-visible { outline: 2px solid #8cd279; outline-offset: 2px; }
.doc-editor p:empty, .doc-editor div:empty { display: block; min-height: 1em; }

/* ---- Gráficos (dashboard). Azul/laranja: seguros para daltonismo e com contraste de gráfico (3:1) nos dois temas. ---- */
.viz { --series-1: #3987e5; --series-2: #d95926; }
.viz-s1 { fill: var(--series-1); background: var(--series-1); }
.viz-s2 { fill: var(--series-2); background: var(--series-2); }
.viz-wrap { position: relative; }
.viz-svg { display: block; width: 100%; height: auto; overflow: visible; }
.viz-grid { stroke: rgb(var(--c-edge)); stroke-opacity: 0.55; stroke-width: 1; }
.viz-tick { fill: rgb(var(--c-muted)); font-size: 11px; font-family: inherit; }
.viz-hit { fill: transparent; }
.viz-group { outline: none; cursor: default; }
.viz-group:hover .viz-hit, .viz-group:focus .viz-hit { fill: rgb(var(--c-ink) / 0.07); }
.viz-group:focus-visible .viz-hit { stroke: var(--focus); stroke-width: 2; }
.viz-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.75rem; margin-bottom: 0.75rem; }
.viz-legend { display: flex; flex-wrap: wrap; gap: 1rem; font-size: 0.875rem; }
.viz-legend li { display: flex; align-items: center; gap: 0.5rem; }
.viz-swatch { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
.viz-key { width: 14px; height: 3px; border-radius: 2px; display: inline-block; margin-right: 0.5rem; vertical-align: middle; }
.viz-toggle { border-radius: 9999px; background: rgb(var(--c-field)); padding: 0.25rem 0.9rem; font-size: 0.75rem; font-weight: 700; }
.viz-toggle:hover { background: rgb(var(--c-edge)); }
.viz-tip { position: absolute; top: 0; transform: translateX(-50%); z-index: 5; pointer-events: none; min-width: 11rem; border: 1px solid rgb(var(--c-edge)); border-radius: 0.5rem; background: rgb(var(--c-canvas)); padding: 0.5rem 0.75rem; font-size: 0.8125rem; box-shadow: var(--tip-shadow); }
.viz-tip-title { margin-bottom: 0.25rem; color: rgb(var(--c-muted)); text-transform: capitalize; }
.viz-tip-name { color: rgb(var(--c-muted)); }
.viz-track { height: 12px; width: 100%; overflow: hidden; border-radius: 9999px; background: rgb(var(--c-field)); }
.viz-fill { height: 100%; border-radius: 9999px; }
.viz-hrow + .viz-hrow { margin-top: 1rem; }
.viz-bar.viz-s1, .viz-bar.viz-s2 { background: none; }
@media (forced-colors: active) { .viz-bar { stroke: CanvasText; } }
