: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); }
.nav-group-items {
  max-height: 0; overflow: hidden;
  transition: max-height .28s ease;
}
.nav-group.open .nav-group-items { max-height: 520px; }
.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; }

/* ── 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); }
  #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;
}

.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; }

.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);
}

/* ── 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; }
