:root {
  /* Azul-marinho refinado: uma família só. Marinho no menu, um único azul
     para ação (botões, links, foco, item ativo) e cinzas neutros. Os
     gráficos do Resumo Executivo têm paleta própria, validada para
     daltonismo (templates/index.html). */
  --radius: 0.75rem;
  --background: #f6f7f9;
  --foreground: #111827;
  --card: #ffffff;
  --card-foreground: #111827;
  --popover: #ffffff;
  --popover-foreground: #111827;
  --primary: #1e4fae;
  --primary-foreground: #ffffff;
  --secondary: #f1f3f7;
  --secondary-foreground: #1f2937;
  --muted: #f3f4f6;
  --muted-foreground: #6b7280;
  --accent: #eef2f9;
  --accent-foreground: #14213d;
  --destructive: oklch(0.58 0.22 27);
  --destructive-foreground: #ffffff;
  --success: oklch(0.62 0.16 155);
  --success-foreground: #ffffff;
  --warning: oklch(0.78 0.16 75);
  --warning-foreground: oklch(0.25 0.1 60);
  --border: #e5e7eb;
  --input: #e5e7eb;
  --ring: #1e4fae;
  --sidebar-bg: #14213d;
  --sidebar-foreground: #d6dbe6;
  --sidebar-primary: #2f5fc4;
  --sidebar-primary-foreground: #ffffff;
  --sidebar-accent: #1f2f52;
  --sidebar-accent-foreground: #ffffff;
  --sidebar-border: #24314f;
}

* { border-color: var(--border); }

body {
  background-color: var(--background);
  color: var(--foreground);
  font-family: "Inter", ui-sans-serif, system-ui, sans-serif;
  font-feature-settings: "cv11", "ss01";
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 {
  font-family: "Sora", "Inter", system-ui, sans-serif;
  letter-spacing: -0.02em;
}

.font-mono, .tabular-nums {
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-variant-numeric: tabular-nums;
}

/* Sidebar */
.sidebar {
  background-color: var(--sidebar-bg);
  color: var(--sidebar-foreground);
}
.sidebar a {
  color: var(--sidebar-foreground);
  opacity: 0.8;
}
.sidebar a:hover, .sidebar a.active {
  background-color: var(--sidebar-accent);
  color: var(--sidebar-accent-foreground);
  opacity: 1;
}
.sidebar .brand-icon {
  background-color: var(--sidebar-primary);
  color: var(--sidebar-primary-foreground);
}

/* Cards */
.card {
  background-color: var(--card);
  color: var(--card-foreground);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

/* Buttons */
.btn-primary {
  background-color: var(--primary);
  color: var(--primary-foreground);
}
.btn-primary:hover { opacity: 0.9; }

.btn-outline {
  border: 1px solid var(--input);
  background-color: var(--card);
  color: var(--foreground);
}
.btn-outline:hover { background-color: var(--accent); }

.btn-ghost { background: transparent; color: var(--foreground); }
.btn-ghost:hover { background-color: var(--accent); }

.btn-destructive {
  background-color: var(--destructive);
  color: var(--destructive-foreground);
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.125rem 0.5rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 500;
  line-height: 1.25rem;
}
.badge-default { background-color: var(--primary); color: var(--primary-foreground); }
.badge-secondary { background-color: var(--secondary); color: var(--secondary-foreground); }
.badge-outline { border: 1px solid var(--border); color: var(--foreground); background: transparent; }
.badge-destructive { background-color: var(--destructive); color: var(--destructive-foreground); }

/* KPI card highlight */
.kpi-highlight {
  background-color: var(--primary);
  color: var(--primary-foreground);
  border-color: var(--primary);
}
.kpi-highlight .kpi-label { color: var(--primary-foreground); opacity: 0.8; }

/* Text utilities */
.text-muted { color: var(--muted-foreground); }
.text-success { color: var(--success); }
.text-warning { color: var(--warning); }
.text-destructive { color: var(--destructive); }
.text-primary-theme { color: var(--primary); }

/* Inputs */
input[type="text"], input[type="number"], input[type="date"], input[type="month"],
input[type="file"], select, textarea {
  border: 1px solid var(--input);
  border-radius: calc(var(--radius) - 2px);
  background-color: var(--card);
}
input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--ring);
  outline-offset: 2px;
}

/* Table stripe */
.table-row-alt:nth-child(even) { background-color: var(--muted); }

/* Tabelas largas: rolagem horizontal dentro do cartão (ver base.html) */
.tabela-rolavel {
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* Celular (< 768px, abaixo do "md" do Tailwind). Ajustes globais para não
   repetir variantes em cada tela: cabeçalho de página com menos margem e
   quebrando ações para a linha de baixo. */
@media (max-width: 767.98px) {
  body main > header > div[class] {
    padding: 1rem;
    flex-wrap: wrap;
    row-gap: 0.75rem;
  }
  body main > header h1 { font-size: 1.25rem; line-height: 1.75rem; }
  /* Selects com opções longas não empurram a página para os lados, e
     formulários em linha (campo + botão) quebram o botão para baixo. */
  body main select { max-width: 100%; min-width: 0; }
  body main form.flex { flex-wrap: wrap; }
  body main form, body main form.flex > * { min-width: 0; max-width: 100%; }
}
