:root {
  --sidebar-w: 250px;
  --sidebar-bg: #16191e;
  --sidebar-hover: #1f2329;
  --sidebar-active: #0d6efd;
  --topbar-h: 56px;
  --body-bg: #f0f2f5;
  --card-bg: #fff;
  --text-muted: #6c757d;
  --border: #dee2e6;
}

* { box-sizing: border-box; }

body {
  font-family: 'Segoe UI', system-ui, sans-serif;
  background: var(--body-bg);
  margin: 0;
  font-size: 14px;
}

/* ── LOGIN ────────────────────────────────────────────── */
#login-screen {
  min-height: 100vh;
  background: linear-gradient(135deg, #0f1923 0%, #1a2d4a 100%);
  display: flex; align-items: center; justify-content: center;
}
.login-card {
  background: #fff;
  border-radius: 12px;
  padding: 40px 36px;
  width: 100%; max-width: 380px;
  box-shadow: 0 20px 60px rgba(0,0,0,.4);
}
.login-logo { text-align: center; margin-bottom: 28px; }
.login-logo h2 { font-size: 1.3rem; font-weight: 700; color: #1a2d4a; margin: 8px 0 2px; }
.login-logo small { color: var(--text-muted); font-size: .8rem; }

/* ── LAYOUT ───────────────────────────────────────────── */
#app { display: flex; min-height: 100vh; }

#sidebar {
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  color: #cdd3db;
  display: flex; flex-direction: column;
  position: fixed; top: 0; left: 0; bottom: 0;
  z-index: 1040;
  transition: transform .25s;
}
.sidebar-brand {
  padding: 18px 20px 14px;
  border-bottom: 1px solid #232830;
  display: flex; align-items: center; gap: 10px;
}
.sidebar-brand .brand-home {
  display: flex; align-items: center; gap: 10px;
  text-decoration: none; border-radius: 8px;
  padding: 4px; margin: -4px; transition: background .15s;
}
.sidebar-brand .brand-home:hover { background: var(--sidebar-hover); }
.sidebar-brand .brand-icon {
  width: 34px; height: 34px; border-radius: 8px;
  background: var(--sidebar-active);
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 1rem;
}
.sidebar-brand .brand-text { font-size: .82rem; font-weight: 600; color: #e8ecf0; }
.sidebar-brand .brand-sub  { font-size: .68rem; color: #6c7580; }

.sidebar-nav { flex: 1; overflow-y: auto; padding-bottom: 16px; }

/* ── Grupos toggle (accordion) ─────────────────────────────────────────── */
.nav-group-header {
  width: 100%; background: none; border: 0; cursor: pointer;
  display: flex; align-items: center; justify-content: space-between;
  font-size: .65rem; text-transform: uppercase; letter-spacing: 1px;
  color: #4a5260; padding: 14px 20px 8px; margin-top: 4px;
  transition: color .15s;
}
.nav-group-header:hover { color: #8a93a0; }
.nav-group-caret { font-size: .7rem; transition: transform .25s; }
.nav-group.open > .nav-group-header { color: #6c7580; }
.nav-group.open .nav-group-caret { transform: rotate(180deg); }
/* Total de pendências do grupo (some quando o grupo está aberto — os filhos aparecem). */
.nav-group-badge { font-size: .62rem; letter-spacing: 0; text-transform: none; padding: .2em .45em; vertical-align: middle; }
.nav-group-items {
  display: grid; grid-template-rows: 0fr; overflow: hidden;
  transition: grid-template-rows .28s ease;
}
.nav-group-items-inner { min-height: 0; overflow: hidden; }
.nav-group.open .nav-group-items { grid-template-rows: 1fr; }
.sidebar-nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 20px; color: #9aa3ae; text-decoration: none;
  font-size: .82rem; transition: all .15s;
  border-left: 3px solid transparent;
}
.sidebar-nav a:hover { background: var(--sidebar-hover); color: #e0e5ec; }
.sidebar-nav a.active { background: rgba(13,110,253,.12); color: #4d9aff; border-left-color: var(--sidebar-active); font-weight: 600; }
.sidebar-nav a i { width: 18px; text-align: center; font-size: .9rem; }
.sidebar-nav a.nav-item-standalone { margin-top: 8px; padding-top: 12px; border-top: 1px solid #3a424d; }

/* Estrela de favorito = tela inicial (a marcada carrega ao entrar no sistema) */
.nav-fav {
  margin-left: auto; flex-shrink: 0; line-height: 1;
  opacity: .18; color: #9aa3ae;
  transition: opacity .15s, color .15s, transform .1s;
}
.nav-fav i { width: auto; font-size: .82rem; }         /* não herda o width:18px dos ícones do menu */
.sidebar-nav a:hover .nav-fav { opacity: .6; }         /* realça ao passar o mouse na linha */
.nav-fav:hover { color: #f5c518; opacity: 1 !important; transform: scale(1.2); }
.sidebar-nav a.is-fav .nav-fav { opacity: 1; color: #f5c518; }  /* favorito atual: dourado fixo */

.sidebar-footer {
  padding: 14px 20px;
  border-top: 1px solid #232830;
  font-size: .75rem; color: #4a5260;
  display: flex; align-items: center; justify-content: space-between;
}
.sidebar-footer .user-info { display: flex; flex-direction: column; }
.sidebar-footer .user-name { color: #9aa3ae; font-weight: 600; font-size: .78rem; }
.sidebar-footer .user-role { font-size: .65rem; color: #4a5260; }

#main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex; flex-direction: column;
  min-height: 100vh;
  /* Item de flex tem min-width:auto por padrão: o conteúdo mais largo (o trilho do
     board, uma tabela grande) empurraria o layout inteiro para fora da tela em vez de
     rolar dentro do próprio contêiner. min-width:0 devolve a rolagem a quem a pediu. */
  min-width: 0;
}

#topbar {
  height: var(--topbar-h);
  background: #fff;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center;
  padding: 0 24px; gap: 12px;
  position: sticky; top: 0; z-index: 100;
  box-shadow: 0 1px 4px rgba(0,0,0,.06);
}
#topbar h5 { margin: 0; font-size: .95rem; font-weight: 700; flex: 1; }

#page-content { padding: 24px; flex: 1; min-width: 0; }

/* ── CARDS ────────────────────────────────────────────── */
.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 1px 4px rgba(0,0,0,.06);
}
.card-header {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  font-weight: 600; font-size: .88rem;
  display: flex; align-items: center; justify-content: space-between;
  background: transparent;
}
.card-body { padding: 18px; }

/* ── STAT CARDS ───────────────────────────────────────── */
.stat-card {
  border-radius: 10px; padding: 20px;
  color: #fff; display: flex; align-items: center; gap: 16px;
}
.stat-card .stat-icon {
  width: 48px; height: 48px; border-radius: 10px;
  background: rgba(255,255,255,.2);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.3rem;
}
.stat-card .stat-val { font-size: 1.5rem; font-weight: 700; }
.stat-card .stat-lbl { font-size: .75rem; opacity: .85; }
.stat-blue   { background: linear-gradient(135deg, #0d6efd, #0a58ca); }
.stat-green  { background: linear-gradient(135deg, #198754, #146c43); }
.stat-orange { background: linear-gradient(135deg, #fd7e14, #dc6012); }
.stat-teal   { background: linear-gradient(135deg, #20c997, #1aa179); }
.stat-purple { background: linear-gradient(135deg, #6f42c1, #5a36a8); }
.stat-red    { background: linear-gradient(135deg, #dc3545, #b02a37); }

/* ── BADGES DE STATUS ─────────────────────────────────── */
.badge-status {
  display: inline-block;
  padding: 3px 10px; border-radius: 20px;
  font-size: .7rem; font-weight: 600;
  white-space: nowrap;
}

/* ── DATATABLES ───────────────────────────────────────── */
.dataTables_wrapper .dataTables_length select,
.dataTables_wrapper .dataTables_filter input {
  border: 1px solid var(--border); border-radius: 6px;
  padding: 4px 8px; font-size: .82rem;
}
.dataTables_wrapper .dataTables_filter input { padding: 5px 10px; }
table.dataTable thead th {
  background: #f8f9fa;
  font-size: .78rem; text-transform: uppercase;
  letter-spacing: .5px; color: var(--text-muted);
  border-bottom: 2px solid var(--border) !important;
  font-weight: 600;
}
table.dataTable tbody td { font-size: .83rem; vertical-align: middle; }
table.dataTable tbody tr:hover { background: #f8f9ff; }
.dataTables_wrapper .dataTables_info,
.dataTables_wrapper .dataTables_paginate { font-size: .78rem; }
.dataTables_wrapper .paginate_button { border-radius: 6px !important; }
.dataTables_wrapper .paginate_button.current {
  background: var(--sidebar-active) !important;
  border-color: var(--sidebar-active) !important;
  color: #fff !important;
}

/* ── MODALS ───────────────────────────────────────────── */
.modal-header { border-bottom: 1px solid var(--border); }
.modal-footer { border-top: 1px solid var(--border); }
.modal-title  { font-size: .95rem; font-weight: 700; }

/* ── FORMS ────────────────────────────────────────────── */
.form-label { font-size: .8rem; font-weight: 600; color: #374151; margin-bottom: 4px; }
.form-control, .form-select {
  font-size: .83rem; border-radius: 6px;
  border: 1px solid #d1d5db;
}
.form-control:focus, .form-select:focus {
  border-color: var(--sidebar-active);
  box-shadow: 0 0 0 3px rgba(13,110,253,.12);
}
.form-text { font-size: .72rem; }

/* ── COLLABORATORS TABLE ──────────────────────────────── */
.colabs-table { font-size: .8rem; }
.colabs-table td, .colabs-table th { padding: 6px 10px; }

/* ── RECEIBIMENTOS ────────────────────────────────────── */
.recebimento-item {
  border: 1px solid var(--border); border-radius: 8px;
  padding: 12px 16px; margin-bottom: 10px;
  background: #fafbfc;
}
.recebimento-item .rec-valor { font-size: 1.05rem; font-weight: 700; color: #198754; }
.recebimento-item .rec-meta  { font-size: .75rem; color: var(--text-muted); }

/* ── TAGS / PILLS ─────────────────────────────────────── */
.pill-pj { background: #cfe2ff; color: #084298; }
.pill-pf { background: #fff3cd; color: #856404; }

/* ── FECHAMENTO ───────────────────────────────────────── */
.fechamento-bloco {
  border: 1px solid var(--border); border-radius: 8px;
  overflow: hidden; margin-bottom: 16px;
}
.fechamento-bloco .bloco-header {
  background: #f8f9fa; padding: 10px 16px;
  font-size: .8rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .5px; color: var(--text-muted);
  border-bottom: 1px solid var(--border);
}
.fechamento-bloco .bloco-body { padding: 14px 16px; }
.fechamento-linha {
  display: flex; justify-content: space-between; align-items: center;
  padding: 5px 0;
  border-bottom: 1px dashed #eee;
  font-size: .83rem;
}
.fechamento-linha:last-child { border-bottom: none; }
.fechamento-linha .fl-lbl { color: #374151; }
.fechamento-linha .fl-val { font-weight: 600; }
.fechamento-linha.deducao .fl-val { color: #dc3545; }
.fechamento-linha.lucro   .fl-val { color: #198754; font-size: 1rem; }
.fechamento-linha.total   { background: #f0f7ff; padding: 8px 0; margin: 4px 0; border-radius: 4px; }
/* Índice da linha (A…G) e a fórmula do resultado. Existem para conferir a tela de
   olho: cada crédito/débito tem letra, e a linha do resultado diz quais entram nela.
   Monoespaçada de propósito — em coluna, letra e sinal alinham e a conta se lê.
   Seletor SEM o .fechamento-linha na frente: as mesmas classes são usadas dentro do
   modal "Composição do Lucro", que é uma <table> — e a conferência cruzada entre os
   dois só funciona se as letras tiverem a mesma aparência nos dois lugares. */
.fl-idx {
  display: inline-block; min-width: 1.2rem; margin-right: .4rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: .68rem; font-weight: 700; text-align: center; line-height: 1.35;
  color: #495057; background: #f1f3f5; border: 1px solid #dee2e6; border-radius: 3px;
}
.fl-formula {
  margin-left: .4rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: .7rem; font-weight: 400; color: var(--text-muted); white-space: nowrap;
}

/* ── DRAG-TO-REORDER ──────────────────────────────────── */
.sortable-ghost { opacity: .4; }
.drag-handle { cursor: grab; color: #bbb; padding: 0 6px; }
.drag-handle:active { cursor: grabbing; }

/* ── DONAÇÕES ─────────────────────────────────────────── */
.doacao-row { background: #f8fffe; border-radius: 6px; padding: 8px 12px; margin-bottom: 6px; }

/* ── RESPONSIVE ───────────────────────────────────────── */
@media (max-width: 768px) {
  #sidebar { transform: translateX(-100%); }
  #sidebar.show { transform: translateX(0); }
  #sidebar.show ~ #sidebarBackdrop { display: block; }
  #main-content { margin-left: 0; }
  #page-content { padding: 16px; }
}

/* ── MISC ─────────────────────────────────────────────── */
.page-section { display: none; }
.page-section.active { display: block; }

.btn-icon { padding: 4px 8px; font-size: .78rem; }
.table-actions { white-space: nowrap; }

.cnj-valid   { border-color: #198754 !important; }
.cnj-invalid { border-color: #dc3545 !important; }
.cnj-feedback { font-size: .72rem; margin-top: 2px; }

.comarca-detected {
  background: #f0f7ff; border: 1px solid #cfe2ff;
  border-radius: 6px; padding: 8px 12px;
  font-size: .8rem; color: #084298; margin-top: 6px;
}

.pettro-mini-block { background: #f0f4ff; }

.progress-thin { height: 6px; border-radius: 4px; }

.text-money { font-weight: 600; font-family: 'Courier New', monospace; }

.val-money { font-weight: 600; font-family: 'Courier New', monospace; display: inline-block; }

.alert-sm { padding: 8px 14px; font-size: .8rem; }

/* ── PRIVACY MODE (ocultar valores) ──────────────────────── */
.val-money,
.text-money,
.priv-money {
  transition: filter .2s ease;
}

body.privacy-mode .val-money,
body.privacy-mode .text-money,
body.privacy-mode .priv-money {
  filter: blur(8px) !important;
  user-select: none !important;
}

body.privacy-mode .stat-val {
  filter: blur(8px) !important;
}

/* Google Drive aposentado: some com toda a UI de Drive quando o projeto não o religou.
   `!important` vence o display inline que o jQuery .show() injeta em botões de modal. */
body.drive-off .drive-only {
  display: none !important;
}

/* Menu: recurso que ainda precisa de configuração no projeto (fica cinza + 🚫). */
.sidebar-nav a.requer-config { opacity: .5; }
.sidebar-nav a.requer-config .cfg-flag { font-size: .78em; margin-left: .15rem; }
/* bloqueia=true (ex.: Laudos por IA sem chave da API): item DESATIVADO de verdade —
   sem clique. A estrela de favorito segue clicável (pointer-events reabilitado). */
.sidebar-nav a.config-bloqueado { pointer-events: none; cursor: not-allowed; }
.sidebar-nav a.config-bloqueado .nav-fav { pointer-events: auto; }

.btn-privacy-toggle {
  background: transparent;
  border: 1px solid #3a404a;
  color: #6c757d;
  border-radius: 6px;
  padding: 4px 7px;
  font-size: .85rem;
  cursor: pointer;
  transition: color .15s, border-color .15s, background .15s;
  flex-shrink: 0;
}
.btn-privacy-toggle:hover {
  color: #cdd3db;
  border-color: #6c757d;
  background: #1f2329;
}
.btn-privacy-toggle.active {
  color: #fff;
  border-color: #0d6efd;
  background: rgba(13,110,253,.25);
}

/* Botão "recolher menu" (só no mobile — some no desktop via .d-md-none) */
.btn-sidebar-close {
  background: transparent;
  border: 1px solid #3a404a;
  color: #9aa3ae;
  border-radius: 6px;
  padding: 4px 8px;
  font-size: .9rem;
  cursor: pointer;
  transition: color .15s, border-color .15s, background .15s;
  flex-shrink: 0;
}
.btn-sidebar-close:hover { color: #fff; border-color: #6c757d; background: #1f2329; }

/* Fundo escuro atrás do menu aberto no mobile */
#sidebarBackdrop {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 1039; /* logo abaixo do #sidebar (1040) */
}

/* ── SCROLLBAR ────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #ccc; border-radius: 3px; }

/* ── ACERTOS ──────────────────────────────────────────── */
.acerto-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 6px 10px; background: #fff8e1; border-radius: 6px;
  margin-bottom: 4px; font-size: .8rem;
}

/* ── RELATÓRIOS ───────────────────────────────────────── */
.relatorio-filtros {
  background: #fff; border: 1px solid var(--border);
  border-radius: 10px; padding: 16px 20px; margin-bottom: 20px;
}
.chart-container { position: relative; min-height: 280px; }

@keyframes spin { to { transform: rotate(360deg); } }
.spin { animation: spin .7s linear infinite; display:inline-block; }

/* Lista de perícias: o seletor "X por página" precisa de largura p/ o nº de 2 dígitos
   não ficar sob o caret do dropdown; e o campo de busca um pouco maior. */
#tblPericias_length select { min-width: 4.75rem; padding-right: 1.9rem; }
#tblPericias_filter input  { min-width: 18rem; max-width: 100%; }

/* Corte Trello→Pettro fase 2b: esconde os pontos de entrada do trello.com da interface
   (usuários não acessam), mas a conexão continua VIVA no backend para uma revisão futura
   contra os cards online. !important vence o .show()/.toggle() do jQuery. */
.trello-oculto { display: none !important; }

/* ── AGENDA: calendário do mês ────────────────────────────
   Grade 7×N (dom→sáb) que responde "em que dias estou livre?". As cores dos
   pontinhos são as das próprias agendas do Google; o verde marca o dia sem
   compromisso e o azul, o dia aberto. */
.ag-cal-grid {
  display: grid; grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 4px;
}
.ag-cal-hd {
  text-align: center; font-size: .72rem; text-transform: uppercase;
  letter-spacing: .04em; color: var(--text-muted); padding: 2px 0;
}
.ag-cal-dia {
  min-height: 92px; border: 1px solid var(--border); border-radius: 8px;
  background: var(--card-bg); padding: 4px 5px; cursor: pointer;
  overflow: hidden; transition: box-shadow .12s, border-color .12s;
}
.ag-cal-dia:hover     { border-color: #9ec5fe; box-shadow: 0 1px 6px rgba(13,110,253,.15); }
.ag-cal-dia.fds       { background: #fafbfc; }
.ag-cal-dia.fora      { opacity: .45; }
.ag-cal-dia.livre     { background: #f2fbf5; border-color: #c8e9d4; }
.ag-cal-dia.hoje      { border-color: #0d6efd; box-shadow: inset 0 0 0 1px #0d6efd; }
.ag-cal-dia.sel       { border-color: #0d6efd; background: #eaf2ff; }
.ag-cal-num {
  display: flex; align-items: center; gap: 4px;
  font-size: .78rem; font-weight: 600; margin-bottom: 2px;
}
.ag-cal-livre {
  font-size: .6rem; font-weight: 500; text-transform: uppercase;
  letter-spacing: .03em; color: #157347; margin-left: auto;
}
.ag-cal-ev {
  display: flex; align-items: center; gap: 3px;
  font-size: .68rem; line-height: 1.25; padding: 1px 3px;
  border-radius: 4px; background: #f1f3f5; margin-bottom: 2px;
  white-space: nowrap; overflow: hidden;
}
.ag-cal-ev.per  { background: #e7f1ff; }        /* agenda PERICIAS: o que o sistema marcou */
.ag-cal-ev.vago { opacity: .6; }                /* marcado como "Disponível" na agenda */
/* Diligência PROPOSTA, ainda sem decisão: tracejada, para não se confundir com o que já
   está marcado de verdade. Não existe evento no Google até alguém aprovar. */
.ag-cal-ev.proposta {
  background: #fff4e6; border: 1px dashed #fd7e14; padding: 0 2px;
}
.ag-cal-ev .ag-cal-hora { color: var(--text-muted); flex-shrink: 0; }
.ag-cal-ev .ag-cal-tit  { overflow: hidden; text-overflow: ellipsis; }
.ag-cal-mais {
  font-size: .65rem; color: var(--text-muted); padding-left: 3px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.ag-cal-dot {
  display: inline-block; width: .5rem; height: .5rem;
  border-radius: 50%; flex-shrink: 0;
}
.ag-cal-quad-livre {
  display: inline-block; width: .6rem; height: .6rem; border-radius: 3px;
  background: #f2fbf5; border: 1px solid #c8e9d4;
}
.ag-cal-quad-proposta {
  display: inline-block; width: .6rem; height: .6rem; border-radius: 3px;
  background: #fff4e6; border: 1px dashed #fd7e14;
}
@media (max-width: 767.98px) {
  .ag-cal-dia { min-height: 68px; padding: 3px; }
  .ag-cal-ev .ag-cal-tit { display: none; }     /* no celular fica só hora + cor da agenda */
  .ag-cal-mais-lbl       { display: none; }     /* "+2" basta; o rótulo não cabe */
}

/* ── FILTRO APLICADO (assets/js/filtros.js) ──────────────────────────────────
   Os filtros sobrevivem à troca de tela — então a tela precisa dizer que o que
   está sendo mostrado é RESULTADO DE FILTRO, e qual campo o causou. Sem isso,
   lista vazia por filtro antigo se lê como dado que sumiu. */
.is-filtered,
.is-filtered:focus {
  border-color: #0d6efd !important;
  background-color: #f0f6ff !important;
  color: inherit;
}
.is-filtered-label { color: #0d6efd; font-weight: 600; }
/* Grupo de botões (btn-check) e dropdowns: a moldura acende, não o campo. */
.btn-group.is-filtered, [role="group"].is-filtered, .dropdown.is-filtered {
  background-color: transparent !important;
  border: 0 !important;
  box-shadow: 0 0 0 2px rgba(13, 110, 253, .45);
  border-radius: .375rem;
}
/* Resultado VAZIO com filtro: o mesmo destaque vira âmbar, no tom da faixa. */
.filtros-vazio .is-filtered,
.filtros-vazio .is-filtered:focus {
  border-color: #ffc107 !important;
  background-color: #fff8e1 !important;
}
.filtros-vazio .is-filtered-label { color: #997404; }
.filtros-vazio .btn-group.is-filtered,
.filtros-vazio [role="group"].is-filtered,
.filtros-vazio .dropdown.is-filtered { box-shadow: 0 0 0 2px rgba(255, 193, 7, .65); }

/* Seletor de competência das Despesas: quem filtra é o <input type="month"> escondido
   (data-filtro-rotulo nele, o motor único acha sozinho) — o botão visível não é
   varrido por _fltAtivos, então acende pelo estado da BARRA, não pelo próprio .is-filtered. */
[data-filtros="despesas"].filtros-ativos #despCompTrigger {
  border-color: #0d6efd; background-color: #f0f6ff; color: #0d6efd;
}
[data-filtros="despesas"].filtros-vazio #despCompTrigger {
  border-color: #ffc107; background-color: #fff8e1; color: #997404;
}

.filtros-aviso { font-size: .84rem; }
.filtros-chips { display: inline-flex; flex-wrap: wrap; gap: .25rem .5rem; }
.filtros-chip {
  background: rgba(0, 0, 0, .05);
  border-radius: .35rem;
  padding: .05rem .35rem;
  white-space: nowrap;
}

/* ══════════════════════════════════════════════════════════════════════════════
   TEMA ESCURO
   ══════════════════════════════════════════════════════════════════════════════
   Ligado pelo atributo `data-bs-theme="dark"` no <html> — o Bootstrap 5.3 vira
   sozinho (cards, modais, tabelas, dropdowns, formulários). O que está aqui é o
   que é NOSSO e o Bootstrap não conhece: as cores fixas espalhadas por este
   arquivo. O menu lateral já nasceu escuro e não muda.

   REGRA DE COR: só hex e rgba(). Nada de oklch() ou color-mix() — o html2canvas
   ABORTA a captura ao encontrar cor moderna em QUALQUER elemento da página, e é
   ele quem tira o print do "Relatar problema" e do card do caso.

   Quem escolhe o tema: assets/js/tema.js (automático pelo sistema operacional,
   claro ou escuro) + o <script> no <head> do index.php, que pinta antes da
   primeira renderização para a tela não piscar branca.
   ══════════════════════════════════════════════════════════════════════════════ */

[data-bs-theme="dark"] {
  --body-bg: #14171c;
  --card-bg: #1b1f26;
  --border: #333a45;
  --text-muted: #98a1ad;
}

[data-bs-theme="dark"] #topbar { background: #1b1f26; box-shadow: 0 1px 4px rgba(0,0,0,.35); }
[data-bs-theme="dark"] .card   { box-shadow: 0 1px 4px rgba(0,0,0,.35); }

/* A tela de login já tinha fundo escuro; o cartão branco no meio é que destoava. */
[data-bs-theme="dark"] .login-card    { background: #1b1f26; }
[data-bs-theme="dark"] .login-logo h2 { color: #cdd3db; }

/* Formulário: o cinza do rótulo e a borda clara do campo somem no escuro. */
[data-bs-theme="dark"] .form-label { color: #b6bec9; }
[data-bs-theme="dark"] .form-control,
[data-bs-theme="dark"] .form-select { border-color: #3d4552; }

/* DataTables tem cor própria no cabeçalho e no hover — não segue variável do Bootstrap. */
[data-bs-theme="dark"] table.dataTable thead th       { background: #232833; }
[data-bs-theme="dark"] table.dataTable tbody tr:hover { background: #232a36; }

/* .table-light/.table-warning do Bootstrap fixam hex direto (não var()) e o build vendorizado
   não traz override de dark mode pra elas — thead e linha "NOVA" ficavam claras/lavadas em
   cima do tema escuro em toda tabela da casa (Intimações, Fechamento, Relatórios...). */
[data-bs-theme="dark"] .table-light {
  --bs-table-color: #cdd3db;
  --bs-table-bg: #232833;
  --bs-table-border-color: #333a45;
  --bs-table-striped-bg: #262c38;
  --bs-table-striped-color: #cdd3db;
  --bs-table-active-bg: #2a313d;
  --bs-table-active-color: #cdd3db;
  --bs-table-hover-bg: #2a313d;
  --bs-table-hover-color: #cdd3db;
}
[data-bs-theme="dark"] .table-warning {
  --bs-table-color: #ffda6a;
  --bs-table-bg: #332701;
  --bs-table-border-color: #997404;
  --bs-table-striped-bg: #3a2c07;
  --bs-table-striped-color: #ffda6a;
  --bs-table-active-bg: #46350a;
  --bs-table-active-color: #ffda6a;
  --bs-table-hover-bg: #46350a;
  --bs-table-hover-color: #ffda6a;
}

[data-bs-theme="dark"] .recebimento-item { background: #1f242c; }
[data-bs-theme="dark"] .recebimento-item .rec-valor { color: #5dd39e; }
[data-bs-theme="dark"] .pill-pj { background: #123262; color: #a8c7fa; }
[data-bs-theme="dark"] .pill-pf { background: #4a3a10; color: #f0d48a; }

[data-bs-theme="dark"] .fechamento-bloco .bloco-header   { background: #232833; }
[data-bs-theme="dark"] .fechamento-linha                 { border-bottom-color: #2c323c; }
[data-bs-theme="dark"] .fechamento-linha .fl-lbl         { color: #b6bec9; }
[data-bs-theme="dark"] .fechamento-linha.total           { background: #1c2735; }
[data-bs-theme="dark"] .fechamento-linha.deducao .fl-val { color: #f5808d; }
[data-bs-theme="dark"] .fechamento-linha.lucro   .fl-val { color: #5dd39e; }
[data-bs-theme="dark"] .fl-idx { color: #cdd3db; background: #2a303a; border-color: #3d4552; }

[data-bs-theme="dark"] .doacao-row        { background: #1a2620; }
[data-bs-theme="dark"] .acerto-item       { background: #33290d; }
[data-bs-theme="dark"] .relatorio-filtros { background: #1b1f26; }
[data-bs-theme="dark"] .comarca-detected  { background: #17253a; border-color: #2b4c7e; color: #a8c7fa; }
[data-bs-theme="dark"] .pettro-mini-block { background: #17253a; }
[data-bs-theme="dark"] .cnj-valid   { border-color: #5dd39e !important; }
[data-bs-theme="dark"] .cnj-invalid { border-color: #f5808d !important; }
[data-bs-theme="dark"] .drag-handle { color: #6c757d; }
[data-bs-theme="dark"] ::-webkit-scrollbar-thumb { background: #454d5a; }

/* Agenda: a grade do mês é pintada à mão, tom sobre tom de branco. */
[data-bs-theme="dark"] .ag-cal-dia:hover     { border-color: #4d7fd4; box-shadow: 0 1px 6px rgba(13,110,253,.28); }
[data-bs-theme="dark"] .ag-cal-dia.fds       { background: #191d24; }
[data-bs-theme="dark"] .ag-cal-dia.livre     { background: #16261d; border-color: #2f5a41; }
[data-bs-theme="dark"] .ag-cal-dia.sel       { background: #1c2b42; }
[data-bs-theme="dark"] .ag-cal-livre         { color: #5dd39e; }
[data-bs-theme="dark"] .ag-cal-ev            { background: #262c36; }
[data-bs-theme="dark"] .ag-cal-ev.per        { background: #1c2b42; }
[data-bs-theme="dark"] .ag-cal-ev.proposta   { background: #33290d; border-color: #b06a1a; }
[data-bs-theme="dark"] .ag-cal-quad-livre    { background: #16261d; border-color: #2f5a41; }
[data-bs-theme="dark"] .ag-cal-quad-proposta { background: #33290d; border-color: #b06a1a; }

/* Sinalização de filtro: o azul e o âmbar claros viram fundo, não iluminação. */
[data-bs-theme="dark"] .is-filtered,
[data-bs-theme="dark"] .is-filtered:focus                { background-color: #17253a !important; }
[data-bs-theme="dark"] .is-filtered-label                { color: #6ea8fe; }
[data-bs-theme="dark"] .filtros-vazio .is-filtered,
[data-bs-theme="dark"] .filtros-vazio .is-filtered:focus { background-color: #33290d !important; }
[data-bs-theme="dark"] .filtros-vazio .is-filtered-label { color: #f0d48a; }
[data-bs-theme="dark"] [data-filtros="despesas"].filtros-ativos #despCompTrigger {
  background-color: #17253a; color: #6ea8fe;
}
[data-bs-theme="dark"] [data-filtros="despesas"].filtros-vazio #despCompTrigger {
  background-color: #33290d; color: #f0d48a;
}
[data-bs-theme="dark"] .filtros-chip { background: rgba(255, 255, 255, .08); }

/* ── WhatsApp — fio da conversa ───────────────────────────────────────────────
   Tingidos por custom property com valor para os DOIS temas (tests/tema_escuro.js);
   neutros pelas variáveis do Bootstrap. */
:root { --wa-out-bg: #d9fdd3; --wa-out-fg: #0b3d1a; }
[data-bs-theme="dark"] { --wa-out-bg: #144d37; --wa-out-fg: #e4f5ea; }
.wa-fio { max-height: 58vh; overflow: auto; background: var(--bs-tertiary-bg);
          /* Textura sutil só para lembrar o papel de parede do WhatsApp (#112) — hatch em
             rgba(), nunca oklch()/color-mix(): o print do FAB de Issues (html2canvas) aborta
             nessas funções (ver CLAUDE.md do projeto). */
          background-image: repeating-linear-gradient(45deg, rgba(0,0,0,.025) 0, rgba(0,0,0,.025) 1px, transparent 1px, transparent 13px); }
[data-bs-theme="dark"] .wa-fio { background-image: repeating-linear-gradient(45deg, rgba(255,255,255,.035) 0, rgba(255,255,255,.035) 1px, transparent 1px, transparent 13px); }
.wa-data-sep { text-align: center; margin: .5rem 0; }
.wa-data-sep span { background: var(--bs-tertiary-bg); border: 1px solid var(--bs-border-color);
                     border-radius: 1rem; padding: .1rem .6rem; font-size: .72rem; color: var(--bs-secondary-color); }
.wa-avatar { width: 34px; height: 34px; border-radius: 50%; flex: 0 0 auto;
             background: var(--bs-secondary-bg); color: var(--bs-secondary-color);
             display: inline-flex; align-items: center; justify-content: center;
             font-weight: 600; font-size: .85rem; text-transform: uppercase; }
.wa-balao { max-width: 78%; padding: .45rem .7rem; border-radius: .75rem; margin-bottom: .4rem;
            white-space: pre-wrap; word-break: break-word; font-size: .92rem; }
.wa-balao.in  { background: var(--bs-body-bg); color: var(--bs-body-color); margin-right: auto; border-bottom-left-radius: .2rem; }
.wa-balao.out { background: var(--wa-out-bg); color: var(--wa-out-fg); margin-left: auto; border-bottom-right-radius: .2rem; }
.wa-balao .wa-meta { font-size: .72rem; opacity: .75; text-align: right; margin-top: .15rem; }
.wa-balao.falhou { outline: 2px solid var(--bs-danger); }
.wa-conv.active .text-body-secondary { color: inherit !important; opacity: .85; }
.wa-dest mark { padding: 0 .15em; }
.wa-feed .wa-balao { max-width: 88%; }
.wa-feed .wa-remetente { font-weight: 600; font-size: .8rem; opacity: .85; margin-bottom: .1rem; }
.wa-feed .wa-balao.historico { opacity: .7; }

/* ── Segmento (perícia × advocacia) ───────────────────────────────────────────
   Bloco marcado com data-segmento="X" só existe no segmento X. O <body> leva
   seg-<segmento> (index.php); CSS, não JS: vale antes do primeiro paint e para
   conteúdo de modal que o JS ainda não tocou. */
.seg-advocacia [data-segmento="pericia"],
.seg-pericia   [data-segmento="advocacia"] { display: none !important; }
