@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

:root {
  color-scheme: light;
  --page:        #f6f7f3;
  --surface:     #ffffff;
  --surface-2:   #eef1e9;
  --surface-hover: #e5e9dd;
  --text-primary:   #10140f;
  --text-secondary: #49523f;
  --text-muted:     #838d78;
  --border:    rgba(16,20,15,0.10);
  --border-2:  rgba(16,20,15,0.06);
  --brand:      #16a34a;
  --brand-ink:  #0f7a37;
  --brand-wash: rgba(22,163,74,0.11);
  --good:       #16a34a;
  --good-text:  #0f7a37;
  --good-wash:  rgba(22,163,74,0.11);
  --critical:      #dc2626;
  --critical-text: #dc2626;
  --critical-wash: rgba(220,38,38,0.10);
  --shadow-sm: 0 1px 2px rgba(16,20,15,0.05);
  --shadow-md: 0 4px 16px -4px rgba(16,20,15,0.10), 0 1px 3px rgba(16,20,15,0.06);
  --shadow-lg: 0 20px 48px -14px rgba(16,20,15,0.20);
  --radius-md: 12px;
  --radius-lg: 18px;
  --radius-xl: 22px;
  --radius-full: 999px;
  --font: 'Inter', system-ui, -apple-system, "Segoe UI", sans-serif;
  --baseline:   #c7cabb;
  --slot-parto:     #2a78d6;
  --slot-preparto:  #eb6834;
  --slot-secagem:   #7c5cd6;
  --sidebar-w: 248px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --page:        #0a0f0c;
    --surface:     #131a14;
    --surface-2:   #1b241c;
    --surface-hover: #232f24;
    --text-primary:   #f4f7f1;
    --text-secondary: #b7c2ac;
    --text-muted:     #7c8874;
    --border:    rgba(255,255,255,0.10);
    --border-2:  rgba(255,255,255,0.06);
    --brand:      #22c55e;
    --brand-ink:  #7fe3a3;
    --brand-wash: rgba(34,197,94,0.16);
    --good:       #22c55e;
    --good-text:  #34d979;
    --good-wash:  rgba(34,197,94,0.16);
    --critical:      #f87171;
    --critical-text: #f87171;
    --critical-wash: rgba(248,113,113,0.14);
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.35);
    --shadow-md: 0 4px 20px -4px rgba(0,0,0,0.55), 0 1px 3px rgba(0,0,0,0.4);
    --shadow-lg: 0 24px 56px -16px rgba(0,0,0,0.65);
    --baseline:   #253226;
    --slot-parto:     #4c95ec;
    --slot-preparto:  #e2792f;
    --slot-secagem:   #9c86ec;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0a0f0c; --surface: #131a14; --surface-2: #1b241c; --surface-hover: #232f24;
  --text-primary: #f4f7f1; --text-secondary: #b7c2ac; --text-muted: #7c8874;
  --border: rgba(255,255,255,0.10); --border-2: rgba(255,255,255,0.06);
  --brand: #22c55e; --brand-ink: #7fe3a3; --brand-wash: rgba(34,197,94,0.16);
  --good: #22c55e; --good-text: #34d979; --good-wash: rgba(34,197,94,0.16);
  --critical: #f87171; --critical-text: #f87171; --critical-wash: rgba(248,113,113,0.14);
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.35);
  --shadow-md: 0 4px 20px -4px rgba(0,0,0,0.55), 0 1px 3px rgba(0,0,0,0.4);
  --shadow-lg: 0 24px 56px -16px rgba(0,0,0,0.65);
  --baseline:   #253226;
  --slot-parto:     #4c95ec;
  --slot-preparto:  #e2792f;
  --slot-secagem:   #9c86ec;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0;
  font-family: var(--font);
  background: var(--page);
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
}

/* ---------- Login ---------- */

.tela-login {
  position: relative;
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 20px;
  overflow: hidden;
  background: var(--page);
}
.tela-login::before {
  content: "";
  position: absolute;
  top: -220px; left: 50%;
  width: 620px; height: 620px;
  transform: translateX(-50%);
  border-radius: 50%;
  background: radial-gradient(circle, var(--brand), transparent 70%);
  opacity: .16;
  filter: blur(10px);
  pointer-events: none;
}
.cartao-login {
  position: relative;
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--border-2);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  padding: 36px 30px;
}
.cartao-login .icone {
  width: 50px; height: 50px;
  border-radius: 16px;
  display: grid; place-items: center;
  background: linear-gradient(135deg, var(--brand), var(--brand-ink));
  color: #fff;
  margin: 0 auto 18px;
  box-shadow: 0 8px 20px -6px color-mix(in srgb, var(--brand) 60%, transparent);
}
.cartao-login .icone svg { width: 26px; height: 26px; }
.cartao-login h1 {
  font-size: 19px; font-weight: 800; text-align: center; margin: 0 0 4px; letter-spacing: -0.01em;
}
.cartao-login p.sub {
  text-align: center; color: var(--text-muted); font-size: 13px; margin: 0 0 26px;
}
.btn-link {
  display: block; width: 100%; margin-top: 16px; padding: 0; border: none; background: none;
  color: var(--brand-ink); font-size: 13px; font-weight: 600; text-align: center; cursor: pointer;
}
.btn-link:hover { text-decoration: underline; }

/* ---------- Forms ---------- */

.campo { margin-bottom: 14px; }
.campo label {
  display: block; font-size: 12.5px; font-weight: 600; color: var(--text-secondary);
  margin-bottom: 6px;
}
.campo input, .campo select {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--text-primary);
  font-family: var(--font);
  font-size: 13.5px;
  transition: border-color .15s ease, background-color .15s ease, box-shadow .15s ease;
}
.campo input:focus, .campo select:focus {
  outline: none;
  border-color: var(--brand);
  background: var(--surface);
  box-shadow: 0 0 0 3px var(--brand-wash);
}
.campo .erro-campo {
  color: var(--critical-text);
  font-size: 12px;
  margin-top: 4px;
  display: none;
}

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px 18px;
  border-radius: var(--radius-full);
  border: 1px solid transparent;
  font-family: var(--font);
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  transition: transform .1s ease, box-shadow .15s ease, background-color .15s ease, opacity .15s ease;
}
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primario { background: var(--brand); color: #fff; }
.btn-primario:hover:not(:disabled) { box-shadow: var(--shadow-md); opacity: .94; }
.btn-secundario { background: var(--surface-2); color: var(--text-primary); border-color: var(--border); }
.btn-secundario:hover:not(:disabled) { background: var(--surface-hover); }
.btn-perigo { background: var(--critical-wash); color: var(--critical-text); }
.btn-perigo:hover:not(:disabled) { background: var(--critical); color: #fff; }
.btn-bloco { width: 100%; }

.msg-erro {
  background: var(--critical-wash);
  color: var(--critical-text);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 13px;
  margin-bottom: 14px;
  display: none;
}
.msg-erro.visivel { display: block; }

/* ---------- App shell: sidebar + área de conteúdo ---------- */

.app-shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  position: sticky; top: 0;
  width: var(--sidebar-w); flex: none; height: 100vh;
  display: flex; flex-direction: column;
  background: var(--surface);
  border-right: 1px solid var(--border-2);
}
.sidebar-marca {
  display: flex; align-items: center; gap: 10px;
  padding: 20px 18px;
}
.sidebar-icone {
  width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; flex: none;
  background: linear-gradient(135deg, var(--brand), var(--brand-ink)); color: #fff;
}
.sidebar-icone svg { width: 18px; height: 18px; }
.sidebar-marca .nome { font-size: 14.5px; font-weight: 800; letter-spacing: -0.01em; line-height: 1.2; }
.sidebar-marca .status { font-size: 11px; color: var(--text-muted); }

.sidebar-fazenda {
  display: flex; align-items: center; gap: 9px;
  margin: 0 14px 14px; padding: 9px 10px;
  border-radius: 12px;
  background: var(--surface-2);
}
.sidebar-fazenda img {
  width: 26px; height: 26px; border-radius: 8px; flex: none;
  object-fit: cover; background: var(--surface); border: 1px solid var(--border-2);
}
.sidebar-fazenda span#sidebarFazendaNome {
  font-size: 12.5px; font-weight: 600; color: var(--text-secondary);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.sidebar-nav { flex: 1; overflow-y: auto; padding: 6px 12px; display: flex; flex-direction: column; gap: 2px; }
.sidebar-nav a {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 12px;
  border-radius: 10px;
  font-size: 13.5px; font-weight: 500;
  color: var(--text-secondary);
  text-decoration: none;
  transition: background-color .12s ease, color .12s ease;
}
.sidebar-nav a svg { width: 17px; height: 17px; flex: none; }
.sidebar-nav a:hover { background: var(--surface-2); color: var(--text-primary); }
.sidebar-nav a.ativo { background: var(--brand-wash); color: var(--brand-ink); font-weight: 700; }

.sidebar-rodape {
  border-top: 1px solid var(--border-2);
  padding: 12px;
  display: flex; align-items: center; gap: 6px;
}
.sidebar-rodape .btn-icone { flex: none; }
.sidebar-rodape .rotulo { flex: 1; font-size: 12px; color: var(--text-muted); padding-left: 4px; }

.area-conteudo { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar-mobile {
  display: none;
  position: sticky; top: 0; z-index: 40;
  align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 16px;
  background: color-mix(in srgb, var(--surface) 90%, transparent);
  backdrop-filter: blur(14px) saturate(1.4);
  border-bottom: 1px solid var(--border-2);
}
.topbar-mobile .marca { display: flex; align-items: center; gap: 9px; font-size: 14px; font-weight: 800; min-width: 0; }
.topbar-mobile .marca .sidebar-icone { width: 28px; height: 28px; border-radius: 9px; }
.topbar-mobile .marca .sidebar-icone svg { width: 15px; height: 15px; }
.topbar-mobile-acoes { display: flex; align-items: center; gap: 6px; }

.fazenda-mobile {
  display: flex; align-items: center; gap: 6px; min-width: 0;
  font-size: 14px; font-weight: 800; color: var(--text-primary);
}
.fazenda-mobile img { width: 20px; height: 20px; border-radius: 6px; object-fit: cover; flex: none; }
.fazenda-mobile span#fazendaMobileNome { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.btn-icone {
  display: grid; place-items: center; width: 34px; height: 34px;
  border-radius: var(--radius-full); border: 1px solid var(--border);
  background: var(--surface-2); color: var(--text-secondary); cursor: pointer;
  flex: none;
}
.btn-icone:hover { background: var(--surface-hover); color: var(--text-primary); }
.btn-icone svg { width: 16px; height: 16px; }
.icone-lua { display: none; }
:root[data-theme="dark"] .icone-sol { display: none; }
:root[data-theme="dark"] .icone-lua { display: block; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .icone-sol { display: none; }
  :root:not([data-theme="light"]) .icone-lua { display: block; }
}

.menu-mobile-overlay {
  display: none;
  position: fixed; inset: 0; top: 57px; z-index: 45;
  background: color-mix(in srgb, var(--page) 96%, transparent);
  backdrop-filter: blur(6px);
  flex-direction: column;
}
.menu-mobile-overlay.aberto { display: flex; }
.menu-mobile-overlay .sidebar-nav { flex: 1; padding: 14px; }
.menu-mobile-overlay .sidebar-nav a { padding: 12px 14px; font-size: 14.5px; }

@media (max-width: 960px) {
  .sidebar { display: none; }
  .topbar-mobile { display: flex; }
}

main { flex: 1; max-width: 1200px; width: 100%; margin: 0 auto; padding: clamp(16px, 4vw, 28px); }

.abas {
  display: inline-flex; padding: 4px; gap: 4px;
  background: var(--surface-2); border-radius: var(--radius-full);
  margin-bottom: 20px;
  max-width: 100%;
  overflow-x: auto;
}
.aba { flex: none; }
.aba {
  padding: 8px 18px; border-radius: var(--radius-full); border: none;
  background: transparent; color: var(--text-secondary);
  font-family: var(--font); font-size: 13.5px; font-weight: 600; cursor: pointer;
}
.aba.ativa { background: var(--surface); color: var(--brand-ink); box-shadow: var(--shadow-sm); }

.cartao {
  background: var(--surface); border: 1px solid var(--border-2); border-radius: var(--radius-lg);
  padding: 20px; box-shadow: var(--shadow-sm); margin-bottom: 16px;
}

.filtros { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px; margin-bottom: 4px; }
.filtros .campo { margin-bottom: 0; min-width: 130px; flex: 1; }
.filtros .campo-historico { flex: 2; min-width: 200px; }
.filtros-botoes { display: flex; gap: 8px; flex-wrap: wrap; }

.resumo-total {
  display: flex; align-items: baseline; gap: 8px; margin: 16px 0 4px;
}
.resumo-total .valor { font-size: 22px; font-weight: 800; letter-spacing: -0.01em; }
.resumo-total .rotulo { font-size: 12.5px; color: var(--text-muted); }

/* overflow-x: auto sozinho já basta pra virar "container de rolagem" pro
   CSS (mesmo sem nunca precisar rolar verticalmente) - e o cabeçalho
   sticky gruda no topo DESSE container, não da janela. Sem altura
   nenhuma definida aqui, o container só cresce pra caber a tabela
   inteira e nunca chega a rolar de verdade - o "sticky" ficava sem
   efeito nenhum na prática (cabeçalho sumia ladeira abaixo junto com o
   resto). max-height + overflow-y:auto faz o container rolar de
   verdade quando a tabela é mais alta que isso, e aí o cabeçalho gruda
   no topo dele enquanto só as linhas passam por baixo - filtros/total
   acima da tabela continuam sempre visíveis também. */
.tabela-scroll { overflow-x: auto; overflow-y: auto; max-height: 65vh; border-radius: 10px; border: 1px solid var(--border-2); margin-top: 14px; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { padding: 10px 12px; border-bottom: 1px solid var(--border-2); text-align: left; white-space: nowrap; }
th.num, td.num { text-align: right; font-variant-numeric: tabular-nums; }
thead th {
  font-size: 11.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em;
  color: var(--text-muted); background: var(--surface-2);
  position: sticky; top: 0; z-index: 1;
}
tbody tr { transition: background-color .1s ease; cursor: pointer; }
tbody tr:hover { background: var(--surface-2); }
tbody tr:last-child td { border-bottom: none; }
td.acoes { white-space: nowrap; }
.btn-linha {
  border: none; background: transparent; cursor: pointer; color: var(--text-muted);
  padding: 6px; border-radius: 8px;
}
.btn-linha:hover { background: var(--surface-hover); color: var(--text-primary); }
.btn-linha.perigo:hover { background: var(--critical-wash); color: var(--critical-text); }
.btn-linha svg { width: 15px; height: 15px; }

.sem-dados { color: var(--text-muted); font-style: italic; padding: 20px; text-align: center; font-size: 13px; }

/* ---------- Painel de edição (drawer) ---------- */

.overlay {
  position: fixed; inset: 0; background: rgba(8,10,7,0.45);
  display: none; align-items: flex-start; justify-content: flex-end;
  z-index: 100;
}
.overlay.aberto { display: flex; }
.drawer {
  width: min(420px, 100%); height: 100%; background: var(--surface);
  box-shadow: var(--shadow-lg); padding: 24px; overflow-y: auto;
  animation: entrarDrawer .22s cubic-bezier(.16,.8,.34,1) both;
}
@keyframes entrarDrawer { from { transform: translateX(24px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
.drawer-topo { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.drawer-topo h2 { margin: 0; font-size: 16px; font-weight: 700; }
.drawer-fechar { border: none; background: var(--surface-2); border-radius: var(--radius-full); width: 30px; height: 30px; display: grid; place-items: center; cursor: pointer; color: var(--text-secondary); }
.drawer-fechar:hover { background: var(--surface-hover); }
.drawer-botoes { display: flex; gap: 8px; margin-top: 20px; }

.toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: var(--text-primary); color: var(--page);
  padding: 12px 18px; border-radius: 10px; font-size: 13.5px;
  box-shadow: var(--shadow-lg); opacity: 0; pointer-events: none;
  transition: opacity .2s ease, transform .2s ease;
  z-index: 200;
}
.toast.visivel { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.erro { background: var(--critical); color: #fff; }

@media (max-width: 640px) {
  .filtros .campo { min-width: 100%; }
}

/* ---------- Dashboard ---------- */

.kpis {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 12px;
  margin-bottom: 28px;
}
@media (max-width: 1080px) { .kpis { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 680px) { .kpis { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 420px) { .kpis { grid-template-columns: 1fr; } }

.kpi-card {
  position: relative;
  min-width: 0;
  background: var(--surface);
  border: 1px solid var(--border-2);
  border-radius: var(--radius-lg);
  padding: 16px;
  box-shadow: var(--shadow-sm);
  transition: transform .18s cubic-bezier(.16,.8,.34,1), box-shadow .18s ease, border-color .18s ease;
}
.kpi-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); border-color: var(--border); }
.kpi-icone {
  display: grid; place-items: center; width: 34px; height: 34px; border-radius: 10px;
  margin-bottom: 14px; background: var(--icone-bg, var(--brand-wash)); color: var(--icone-cor, var(--brand));
}
.kpi-icone svg { width: 18px; height: 18px; }
.kpi-titulo { font-size: 12.5px; font-weight: 500; color: var(--text-muted); margin-bottom: 6px; }
.kpi-valor { font-size: clamp(18px, 2.1vw, 22px); font-weight: 700; letter-spacing: -0.01em; color: var(--text-primary); font-variant-numeric: proportional-nums; }
.cor-neutra { color: var(--text-primary); }
.cor-receita { color: var(--good-text); }
.cor-despesa { color: var(--critical-text); }
.cor-positivo { color: var(--good-text); }
.cor-negativo { color: var(--critical-text); }

.painel-central { display: grid; grid-template-columns: 1.6fr 1fr; gap: 16px; margin-bottom: 16px; align-items: stretch; }
.painel-central > div { min-width: 0; }
@media (max-width: 960px) { .painel-central { grid-template-columns: 1fr; } }

.bloco-grafico, .bloco-alertas, .bloco-balancete, .bloco-lacto {
  background: var(--surface); border: 1px solid var(--border-2); border-radius: var(--radius-lg);
  padding: 20px; box-shadow: var(--shadow-sm); margin-bottom: 16px;
}
.painel-central .bloco-grafico, .painel-central .bloco-alertas { margin-bottom: 0; }

.secao-titulo { display: flex; align-items: center; gap: 10px; margin: 0 0 14px 0; }
.secao-titulo .icone-secao { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 9px; background: var(--brand-wash); color: var(--brand-ink); flex: none; }
.secao-titulo .icone-secao svg { width: 16px; height: 16px; }
.secao-titulo h2 { margin: 0; font-size: 15px; font-weight: 700; letter-spacing: -0.01em; color: var(--text-primary); }

.grafico-legenda-valor { display: flex; align-items: baseline; gap: 8px; margin: -4px 0 14px 40px; }
.grafico-legenda-valor .valor-hoje { font-size: 26px; font-weight: 800; letter-spacing: -0.02em; color: var(--text-primary); }
.grafico-legenda-valor .valor-hoje-rotulo { font-size: 12.5px; color: var(--text-muted); }

.grafico-wrap { position: relative; }
.grafico-svg { width: 100%; min-width: 0; height: auto; display: block; overflow: visible; }
.grafico-crosshair { pointer-events: none; }
.grafico-crosshair line { stroke: var(--baseline); stroke-width: 1; }
.grafico-crosshair circle { stroke: var(--surface); stroke-width: 2; }

.grafico-tooltip {
  position: absolute; pointer-events: none; background: var(--text-primary); color: var(--page);
  border-radius: 10px; padding: 8px 10px; font-size: 12px; line-height: 1.5; box-shadow: var(--shadow-md);
  transform: translate(-50%, -115%); white-space: nowrap; opacity: 0; transition: opacity .1s ease; z-index: 5;
}
.grafico-tooltip.visivel { opacity: 1; }
.grafico-tooltip .tt-data { color: color-mix(in srgb, var(--page) 65%, transparent); font-size: 11px; margin-bottom: 2px; }
.grafico-tooltip .tt-valor { font-weight: 700; font-variant-numeric: tabular-nums; }

.filtro-alertas { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: -4px 0 14px 40px; font-size: 13px; color: var(--text-secondary); }

.badge-alerta { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 500; }
.badge-alerta .ponto { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.ponto-parto { background: var(--slot-parto); }
.ponto-preparto { background: var(--slot-preparto); }
.ponto-secagem { background: var(--slot-secagem); }

.pilula-dias {
  display: inline-flex; align-items: center; justify-content: center; min-width: 26px; padding: 2px 8px;
  border-radius: var(--radius-full); font-size: 11.5px; font-weight: 600; font-variant-numeric: tabular-nums;
  background: var(--surface-2); color: var(--text-secondary);
}
.pilula-dias.urgente { background: var(--critical-wash); color: var(--critical-text); }

.balancete-titulo { font-weight: 700; font-size: 13px; letter-spacing: 0.01em; color: var(--brand-ink); margin: -4px 0 14px 40px; }

.pilula-status { display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px 3px 7px; border-radius: var(--radius-full); font-size: 12px; font-weight: 600; }
.pilula-status svg { width: 12px; height: 12px; }
.pilula-status.status-sim { background: var(--good-wash); color: var(--good-text); }
.pilula-status.status-nao { background: var(--critical-wash); color: var(--critical-text); }

.lacto-totais { display: flex; gap: 18px; margin: -4px 0 14px 40px; font-size: 13px; color: var(--text-secondary); }
.lacto-totais strong { color: var(--text-primary); font-variant-numeric: tabular-nums; }

.erro-carregamento {
  margin: 40px auto; max-width: 480px; padding: 24px; border-radius: var(--radius-lg);
  background: var(--critical-wash); color: var(--critical-text); text-align: center; font-size: 14px;
}

/* Modo de pré-visualização de impressão dos relatórios (equivalente web do
   TFrmPreviewImpressao do desktop): ao clicar em "Visualizar/Imprimir", o
   body ganha a classe .preview-ativo, que esconde os mesmos elementos
   .no-print JÁ NA TELA (não só na hora de imprimir de verdade) - mostrando
   o relatório como vai sair impresso, com a barra de Voltar/Imprimir por
   cima. Nenhuma tabela duplicada: é a mesma tela, só com filtros escondidos. */
.barra-preview {
  display: none; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 14px; margin-bottom: 16px; border-radius: var(--radius-lg);
  background: var(--brand-wash); border: 1px solid var(--brand);
}
.barra-preview span { font-size: 13px; font-weight: 600; color: var(--brand-ink); }
.chk-preto-branco { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--brand-ink); cursor: pointer; user-select: none; }
.chk-preto-branco input { cursor: pointer; }
body.preview-ativo .barra-preview { display: flex; }
body.preview-ativo .no-print { display: none !important; }
/* Pré-visualização precisa mostrar o relatório INTEIRO, do mesmo jeito
   que vai sair impresso (sem scroll - impressão não rola) - sem isso, a
   altura máxima do cabeçalho fixo (ver .tabela-scroll) cortaria
   relatórios com muitas linhas também aqui na tela, antes de imprimir
   de verdade. */
body.preview-ativo .tabela-scroll { max-height: none !important; overflow: visible !important; }

/* Usado pelo botão "Visualizar/Imprimir" dos relatórios: esconde nav,
   ações de topo, controles de filtro e botões na hora de imprimir,
   deixando só o título, o resumo e a tabela (equivalente web do preview
   de impressão do desktop, sem paginação/logo). */
.only-print { display: none; }
body.preview-ativo .only-print { display: block; }
@media print {
  .no-print { display: none !important; }
  .only-print { display: block !important; }
  .barra-preview { display: none !important; }
  .tabela-scroll { max-height: none !important; overflow: visible !important; }
  body { background: #fff !important; }
  .cartao { box-shadow: none !important; border: none !important; }
  .sidebar, .topbar-mobile { display: none !important; }
}

/* Opção "Imprimir em preto e branco" dos relatórios financeiros: quando
   ativa, o body ganha .impressao-pb, que neutraliza as cores de
   Receita/Despesa (verde/vermelho) de volta pro texto padrão - vale tanto
   na pré-visualização em tela quanto na impressão de verdade (a mesma
   classe fica ligada nos dois casos, então o preview já mostra exatamente
   o que vai sair no papel). O sinal negativo das despesas continua
   aparecendo mesmo em preto e branco - só a COR muda, não o formato do
   número. */
.impressao-pb .cor-receita,
.impressao-pb .cor-despesa,
.impressao-pb .cor-positivo,
.impressao-pb .cor-negativo {
  color: var(--text-primary) !important;
}

/* Cabeçalho com logotipo + nome da fazenda no topo de todo relatório
   impresso/pré-visualizado - espelha o ACaminhoLogo que o desktop já
   manda pro TFrmPreviewImpressao. Injetado por app-shell.js (.only-print,
   por isso as regras de display acima já cuidam de quando aparece). */
.cabecalho-impressao {
  display: none;
  align-items: center; gap: 12px;
  padding-bottom: 14px; margin-bottom: 14px;
  border-bottom: 1px solid var(--border-2);
}
body.preview-ativo .cabecalho-impressao { display: flex; }
@media print { .cabecalho-impressao { display: flex !important; } }
.cabecalho-impressao img { height: 40px; width: auto; max-width: 120px; object-fit: contain; border-radius: 6px; }
.cabecalho-impressao span { font-size: 15px; font-weight: 800; letter-spacing: -0.01em; color: var(--text-primary); }
