/* ==========================================================================
   JurisAI — Folha de estilo única. CSS puro, sem framework.

   O menu lateral (estrutura, medidas, accordion, flyout do modo recolhido e
   gaveta no celular) é o mesmo do AutoAgenda — mesma família de produto.
   A paleta muda: azul jurídico no lugar do laranja.
   ========================================================================== */

:root {
  --bg:          #0f1115;
  --surface:     #171a21;
  --surface-2:   #1f232c;
  --border:      #2a2f3a;
  --text:        #e6e8ee;
  --text-muted:  #9aa3b2;
  --brand:       #3b82f6;
  --brand-soft:  rgba(59, 130, 246, .14);
  --brand-dark:  #1d4ed8;
  --ok:          #22c55e;
  --ok-soft:     rgba(34, 197, 94, .14);
  --warn:        #f59e0b;
  --warn-soft:   rgba(245, 158, 11, .14);
  --danger:      #ef4444;
  --danger-soft: rgba(239, 68, 68, .14);
  --radius:      10px;
  --shadow:      0 6px 24px rgba(0, 0, 0, .35);
  --font:        system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
}

* { box-sizing: border-box; }

/**
 * Barra de rolagem padrão do sistema inteiro — era só do card de
 * compromissos do dia (.day-cards-grid), aplicada aqui em '*' pra valer em
 * qualquer scroll: sidebar, tabelas largas, modais, a página toda etc.
 */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--border) var(--surface-2);
}
*::-webkit-scrollbar { width: 6px; height: 6px; }
*::-webkit-scrollbar-track { background: var(--surface-2); border-radius: 10px; }
*::-webkit-scrollbar-thumb { background: var(--border); border-radius: 10px; }
*::-webkit-scrollbar-thumb:hover { background: var(--brand); }

/**
 * Sem isso, qualquer elemento com [hidden] E uma classe que define "display"
 * (ex.: .toolbar { display: flex }) fica visível mesmo escondido — regra de
 * autor sempre vence o estilo padrão do navegador pro atributo, mesmo com
 * especificidade "igual". Foi o caso da barra de seleção em massa aparecendo
 * com "0 selecionado(s)" antes de qualquer checkbox marcado.
 */
[hidden] { display: none !important; }

body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
}

a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3, h4 { line-height: 1.25; }

/* ==========================================================================
   Layout administrativo + sidebar recolhível
   ========================================================================== */
:root { --sidebar-w: 248px; --sidebar-w-collapsed: 68px; }

.layout {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
}
/* Recolhido: só os ícones. A classe vive no <html>, aplicada antes da pintura. */
html.is-collapsed .layout { grid-template-columns: var(--sidebar-w-collapsed) 1fr; }

.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 14px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-x: hidden;
  overflow-y: auto;
  scrollbar-width: thin;
}

/* ---------- Marca ---------- */
.sidebar-head { padding: 4px 6px 16px; }
.logo {
  display: flex; align-items: center; gap: 10px;
  color: var(--text); text-decoration: none;
}
.logo:hover { text-decoration: none; }
.logo-mark {
  width: 32px; height: 32px; flex-shrink: 0;
  display: grid; place-items: center; border-radius: 9px;
  background: var(--brand); color: #fff; font-weight: 800; font-size: 17px;
}
.logo-text { font-size: 18px; font-weight: 700; letter-spacing: -.4px; white-space: nowrap; }
.logo-text span { color: var(--brand); }

/* ---------- Itens ---------- */
.nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }

.nav-link {
  display: flex; align-items: center; gap: 11px;
  width: 100%; padding: 9px 11px; border-radius: 9px;
  color: var(--text-muted); font-size: 14px; font-family: inherit;
  background: none; border: 0; cursor: pointer; text-align: left;
  text-decoration: none; position: relative;
  transition: background .12s, color .12s;
}
.nav-link:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }

/* Ícones herdam a cor do item — nenhum tem cor própria. */
.nav-link .icon { flex-shrink: 0; opacity: .85; }
.nav-link:hover .icon,
.nav-link.active .icon { opacity: 1; }

.nav-link.active { background: var(--brand-soft); color: var(--brand); font-weight: 600; }
/* Barra de destaque do item ativo */
.nav-link.active::before {
  content: ''; position: absolute; left: -10px; top: 50%;
  transform: translateY(-50%);
  width: 3px; height: 20px; border-radius: 0 3px 3px 0;
  background: var(--brand);
}

.nav-label { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- Submenus (accordion) ---------- */
.nav-caret {
  flex-shrink: 0; opacity: .6;
  transition: transform .18s ease;
}
.nav-section.open > .nav-toggle .nav-caret { transform: rotate(90deg); }
.nav-section.open > .nav-toggle { color: var(--text); }

.nav-sub {
  display: grid;
  grid-template-rows: 0fr;            /* animação de altura sem JS medir nada */
  transition: grid-template-rows .2s ease;
  margin-left: 21px;
  border-left: 1px solid var(--border);
  padding-left: 7px;
}
.nav-section.open > .nav-sub { grid-template-rows: 1fr; }

/**
 * Filho ÚNICO, obrigatoriamente. `grid-template-rows: 0fr` dimensiona só a
 * primeira linha; qualquer irmão vira linha implícita `auto` e o submenu não
 * fecha nunca.
 */
.nav-sub-inner {
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-sub-title { display: none; }     /* só aparece no flyout do modo recolhido */

/* Navegadores que não animam 0fr: alterna display, sem transição. */
@supports not (grid-template-rows: 0fr) {
  .nav-sub { display: none; }
  .nav-section.open > .nav-sub { display: block; }
}

.nav-child { font-size: 13.5px; padding: 8px 10px; }
.nav-child.active::before { left: -8px; height: 16px; }

/* ---------- Botão de recolher ---------- */
.sidebar-collapse { margin-top: 8px; flex-shrink: 0; }
html.is-collapsed .sidebar-collapse .icon { transform: scaleX(-1); }

.topbar-burger {
  display: none;
  background: none; border: 0; cursor: pointer;
  color: var(--text-muted); padding: 6px; border-radius: 8px;
}
.topbar-burger:hover { background: var(--surface-2); color: var(--text); }

/* ---------- Estado recolhido ---------- */
/**
 * `overflow: visible` é obrigatório aqui. Com o overflow-y:auto do estado
 * expandido, tooltips e flyouts posicionados em `left: 100%` são recortados
 * pela própria sidebar e nunca aparecem.
 */
html.is-collapsed .sidebar { padding: 14px 10px; overflow: visible; z-index: 9999; }
html.is-collapsed .logo-text,
html.is-collapsed .nav-label,
html.is-collapsed .nav-caret { display: none; }
html.is-collapsed .nav-link { justify-content: center; padding: 10px; }
html.is-collapsed .nav-link.active::before { left: -10px; }

/* Recolhido, o submenu vira flyout no hover — não empurra o layout. */
html.is-collapsed .nav-sub {
  position: absolute; left: 100%; top: 0; z-index: 60;
  display: block; grid-template-rows: none;
  min-width: 208px; margin-left: 6px; padding: 8px;
  background: var(--surface-2);
  border: 1px solid var(--border); border-radius: 10px;
  box-shadow: var(--shadow);
  opacity: 0; visibility: hidden; transform: translateX(-6px);
  transition: opacity .14s, transform .14s, visibility .14s;
}
/* No flyout a altura é livre: o wrapper não pode mais cortar o conteúdo. */
html.is-collapsed .nav-sub-inner { overflow: visible; min-height: auto; }
html.is-collapsed .nav-section { position: relative; }

/**
 * Ponte invisível sobre o vão de 6px entre o ícone e o flyout. Sem ela o mouse
 * sai do .nav-section ao atravessar o espaço, o hover cai e o menu pisca.
 * pointer-events só no hover — do contrário esta faixa ficaria permanentemente
 * sobre o conteúdo, engolindo cliques ao lado do menu.
 */
html.is-collapsed .nav-section::after {
  content: '';
  position: absolute;
  top: 0; bottom: 0; left: 100%;
  width: 12px;
  pointer-events: none;
}
html.is-collapsed .nav-section:hover::after,
html.is-collapsed .nav-section:focus-within::after { pointer-events: auto; }

html.is-collapsed .nav-section:hover > .nav-sub,
html.is-collapsed .nav-section:focus-within > .nav-sub {
  opacity: 1; visibility: visible; transform: translateX(0);
}

/* Grupo do rodapé não pode empurrar o flyout para fora da tela. */
html.is-collapsed .nav-sub {
  max-height: calc(100vh - 24px);
  overflow-y: auto;
  scrollbar-width: thin;
}
html.is-collapsed .nav-sub-title {
  display: block; padding: 4px 10px 8px;
  font-size: 11px; text-transform: uppercase; letter-spacing: .08em;
  color: var(--text-muted); border-bottom: 1px solid var(--border); margin-bottom: 6px;
}
html.is-collapsed .nav-child { justify-content: flex-start; padding: 8px 10px; }
html.is-collapsed .nav-child .nav-label { display: block; }

/* Tooltip dos itens simples quando recolhido. Os grupos ficam de fora: neles
   o próprio flyout já mostra o nome no título. */
html.is-collapsed .nav-link[data-tip]:not(.nav-toggle)::after {
  content: attr(data-tip);
  position: absolute; left: 100%; top: 50%; transform: translate(-6px, -50%);
  margin-left: 10px; padding: 6px 10px; z-index: 70;
  background: var(--surface-2); color: var(--text);
  border: 1px solid var(--border); border-radius: 7px;
  font-size: 12.5px; font-weight: 400; white-space: nowrap;
  box-shadow: var(--shadow); pointer-events: none;
  opacity: 0; visibility: hidden;
  transition: opacity .12s, transform .12s, visibility .12s;
  transition-delay: 0s;
}
html.is-collapsed .nav-link[data-tip]:not(.nav-toggle):hover::after,
html.is-collapsed .nav-link[data-tip]:not(.nav-toggle):focus-visible::after {
  opacity: 1; visibility: visible; transform: translate(0, -50%);
  transition-delay: .35s;
}

.sidebar-backdrop { display: none; }

/* ---------- Conteúdo ---------- */
.main { display: flex; flex-direction: column; min-width: 0; }

.topbar {
  display: flex; align-items: center; gap: 16px;
  padding: 14px 24px; border-bottom: 1px solid var(--border); background: var(--surface);
  position: sticky; top: 0; z-index: 40;
}
.topbar h1 { font-size: 18px; margin: 0; flex: 1; }
.topbar-user {
  display: flex; align-items: center; gap: 8px;
  color: var(--text-muted); font-size: 13px; text-decoration: none;
}
.topbar-user:hover { color: var(--text); text-decoration: none; }
/**
 * min-width: 0 é o que falta pra um item de grid poder encolher abaixo da
 * largura natural do próprio conteúdo — sem isso, .content (a coluna "1fr"
 * do .layout) nunca cede espaço de verdade: com o menu expandido (--sidebar-w
 * maior, menos espaço sobrando), o conteúdo empurra pra fora da viewport em
 * vez de encolher. overflow-x é o cinto de segurança pro que ainda assim
 * ultrapassar (ex.: uma tabela larga sem seu próprio scroll interno).
 */
.content { padding: 24px; flex: 1; min-width: 0; overflow-x: auto; }

/* ---------- Contador no menu ---------- */
.nav-badge {
  margin-left: auto; background: var(--danger); color: #fff;
  font-size: 11px; font-weight: 700; line-height: 1;
  padding: 3px 7px; border-radius: 999px;
}

/* ==========================================================================
   Componentes
   ========================================================================== */

/* ---------- Grades e cartões ---------- */
.grid { display: grid; gap: 14px; }
.grid.cols-2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.grid.cols-4 { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }

.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px; margin-top: 20px;
  /* Sem isso um item de grid não encolhe abaixo do min-content do conteúdo:
     uma tabela larga empurraria o card (e a página) pra fora da tela em vez
     de rolar dentro do próprio .table-wrap. */
  min-width: 0;
}
.card + .card { margin-top: 14px; }
.card h2, .card h3 { margin: 0 0 14px; font-size: 15px; font-weight: 600; }
.card-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin-bottom: 14px; flex-wrap: wrap;
}
.card-head h2, .card-head h3 { margin: 0; }
.card-sub { font-size: 13px; color: var(--text-muted); margin: -8px 0 14px; }

/* ---------- KPIs ---------- */
.dashboard-kpis { display: grid; grid-template-columns: 1fr; gap: 14px; margin-bottom: 16px; }
@media (min-width: 480px) { .dashboard-kpis { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 900px) { .dashboard-kpis { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 1200px) { .dashboard-kpis { grid-template-columns: repeat(4, 1fr); } }

.kpi { position: relative; }
.kpi .label { font-size: 12px; color: var(--text-muted); text-transform: uppercase;
  letter-spacing: .05em; }
.kpi .value { font-size: 30px; font-weight: 700; line-height: 1.15; margin-top: 6px; }
.kpi .hint  { font-size: 12px; color: var(--text-muted); margin-top: 4px; }
.kpi .icon-badge {
  position: absolute; top: 16px; right: 16px;
  width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center;
  background: var(--brand-soft); color: var(--brand);
}
.kpi.ok     .value { color: var(--ok); }
.kpi.ok     .icon-badge { background: var(--ok-soft); color: var(--ok); }
.kpi.warn   .value { color: var(--warn); }
.kpi.warn   .icon-badge { background: var(--warn-soft); color: var(--warn); }
.kpi.danger .value { color: var(--danger); }
.kpi.danger .icon-badge { background: var(--danger-soft); color: var(--danger); }

/* ---------- Abas ---------- */
.tabs {
  display: flex; gap: 4px; border-bottom: 1px solid var(--border);
  margin-bottom: 20px; flex-wrap: wrap;
}
.tab-btn {
  display: flex; align-items: center; gap: 6px;
  padding: 10px 16px; background: none; border: 0; border-bottom: 2px solid transparent;
  color: var(--text-muted); font-size: 14px; font-weight: 600;
  cursor: pointer; font-family: inherit;
}
.tab-btn:hover { color: var(--text); }
.tab-btn.active { color: var(--brand); border-bottom-color: var(--brand); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ---------- Barra de busca / ações no topo de listas ---------- */
.toolbar {
  display: flex; align-items: flex-start; justify-content: space-between;
  flex-wrap: wrap; gap: 12px; margin-bottom: 16px;
}
.toolbar-form { display: flex; flex-wrap: wrap; gap: 8px; flex: 1 1 320px; min-width: 0; max-width: 100%; }
/* O item flex é o .field que envolve o input, não o <input>: sem isso o campo
   de busca encolhe pro min-content (quase zero) ao lado dos selects. */
.toolbar-form .field { margin-bottom: 0; }
.toolbar-form .field:has(> input[type="search"]) { flex: 1 1 200px; min-width: 140px; }
.toolbar-form input[type="search"] { min-width: 0; }
.toolbar-form select { flex: 0 0 auto; width: auto; }
.toolbar-form input[type="date"] { flex: 0 0 auto; width: auto; }
.toolbar-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.toolbar-hint {    font-size: 12px;
    color: #ffffff;
    background: #2b3243;
    padding: 10px;
    border-radius: 10px; }

/* ---------- Tabelas ---------- */
.table-wrap { overflow-x: auto; max-height: 550px; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--border); }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--text-muted); }
tbody tr:hover { background: var(--surface-2); }
tbody tr.row-clickable { cursor: pointer; }
td.right, th.right { text-align: right; }
td.nowrap { white-space: nowrap; }
.row-actions { display: flex; gap: 6px; justify-content: flex-end; }
.row-actions .btn { padding: 5px 9px; }

.empty { padding: 40px 24px; text-align: center; color: var(--text-muted); }
.empty .icon { opacity: .4; margin-bottom: 10px; }
.empty p { margin: 0 0 14px; }

/* ---------- Badges ---------- */
.badge {
  display: inline-block; padding: 3px 9px; border-radius: 999px;
  font-size: 11px; font-weight: 600;
}
.badge.ok     { background: var(--ok-soft);     color: var(--ok); }
.badge.warn   { background: var(--warn-soft);   color: var(--warn); }
.badge.danger { background: var(--danger-soft); color: var(--danger); }
.badge.muted  { background: var(--surface-2);   color: var(--text-muted); }
.badge.brand  { background: var(--brand-soft);  color: var(--brand); }

/* ---------- Formulários ---------- */
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; color: var(--text-muted); margin-bottom: 5px; }
.field .hint { font-size: 12px; color: var(--text-muted); margin-top: 4px; display: block; }
input, select, textarea {
  width: 100%; padding: 10px 12px; font-family: inherit; font-size: 14px;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 8px; color: var(--text);
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft);
}
textarea { min-height: 96px; resize: vertical; }
select option { background: var(--surface-2); }
.field .error { color: var(--danger); font-size: 12px; margin-top: 4px; display: block; }
input.invalid, select.invalid, textarea.invalid { border-color: var(--danger); }

.form-grid { display: grid; gap: 0 14px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.form-grid .full { grid-column: 1 / -1; }
.form-actions {
  display: flex; gap: 10px; justify-content: flex-end;
  margin-top: 8px; padding-top: 16px; border-top: 1px solid var(--border);
  flex-wrap: wrap;
}
fieldset { border: 0; padding: 0; margin: 0 0 8px; }
legend {
  font-size: 12px; text-transform: uppercase; letter-spacing: .06em;
  color: var(--text-muted); font-weight: 700; padding: 0 0 10px;
}

/* Checkbox alinhado com o rótulo (aceite LGPD, filtros) */
.check {
  display: flex; align-items: flex-start; gap: 10px;
  font-size: 13.5px; color: var(--text); cursor: pointer;
}
.check input[type="checkbox"] { width: 16px; height: 16px; margin-top: 2px; flex-shrink: 0; }

/* ---------- Toggle switch ---------- */
label.toggle-switch,
.toggle-switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; user-select: none; }
.toggle-switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.toggle-switch .track {
  width: 42px; height: 24px; border-radius: 999px; flex-shrink: 0;
  background: var(--surface-2); border: 1px solid var(--border); position: relative;
  transition: background .15s ease, border-color .15s ease;
}
.toggle-switch .track::after {
  content: ''; position: absolute; top: 2px; left: 2px;
  width: 18px; height: 18px; border-radius: 50%; background: var(--text-muted);
  transition: transform .15s ease, background .15s ease;
}
.toggle-switch input:checked + .track { background: var(--brand-soft); border-color: var(--brand); }
.toggle-switch input:checked + .track::after { transform: translateX(18px); background: var(--brand); }
.toggle-switch .toggle-label { font-size: 14px; }

/* ---------- Botões ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px 18px; border: 1px solid var(--border); border-radius: 8px;
  background: var(--surface-2); color: var(--text);
  font-size: 14px; font-weight: 600; cursor: pointer; font-family: inherit;
  text-decoration: none; white-space: nowrap;
}
.btn:hover { border-color: var(--text-muted); text-decoration: none; color: var(--text); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { filter: brightness(1.08); color: #fff; }
.btn.danger  { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.danger:hover { filter: brightness(1.08); color: #fff; }
.btn.success { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn.success:hover { filter: brightness(1.08); color: #fff; }
.btn.ghost { background: transparent; }
.btn.sm { padding: 5px 12px; font-size: 13px; }
.btn.block { width: 100%; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }

.link-btn {
  background: none; border: 0; padding: 0; margin: 0; font: inherit;
  color: var(--brand); cursor: pointer; text-decoration: underline;
}
.link-btn:hover { filter: brightness(1.15); }

/* ---------- Alertas / toasts ---------- */
.alert { padding: 12px 16px; border-radius: 8px; margin-bottom: 16px; font-size: 14px; }
.alert.success { background: var(--ok-soft);     color: var(--ok);     border: 1px solid var(--ok); }
.alert.error   { background: var(--danger-soft); color: var(--danger); border: 1px solid var(--danger); }
.alert.warn    { background: var(--warn-soft);   color: var(--warn);   border: 1px solid var(--warn); }
.alert.info    { background: var(--brand-soft);  color: var(--brand);  border: 1px solid var(--brand); }

#toast-area { position: fixed; top: 18px; right: 18px; z-index: 99999; display: grid; gap: 8px; }
.toast {
  padding: 12px 18px; border-radius: 8px; box-shadow: var(--shadow);
  font-size: 14px; font-weight: 500; background: var(--surface-2);
  border-left: 4px solid var(--brand); animation: slide-in .2s ease;
}
.toast.success { border-left-color: var(--ok); }
.toast.error   { border-left-color: var(--danger); }
@keyframes slide-in { from { opacity: 0; transform: translateX(16px); } }

/* ---------- Avatar ---------- */
.avatar-mini {
  width: 32px; height: 32px; border-radius: 50%; flex-shrink: 0;
  display: grid; place-items: center; overflow: hidden;
  background: var(--brand-soft); color: var(--brand);
  font-size: 12px; font-weight: 700;
}
.avatar-mini img { width: 100%; height: 100%; object-fit: cover; }
.avatar-mini.lg { width: 56px; height: 56px; font-size: 20px; }

/* ---------- Modal ---------- */
.modal-overlay {
  position: fixed; inset: 0; z-index: 1000;
  background: rgba(0, 0, 0, .6);
  display: flex; align-items: center; justify-content: center; padding: 20px;
  opacity: 0; visibility: hidden;
  transition: opacity .18s ease, visibility .18s ease;
}
.modal-overlay.open { opacity: 1; visibility: visible; }
.modal-box {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow);
  width: 100%; max-width: 560px; max-height: 90vh; overflow-y: auto;
  padding: 24px; position: relative;
  transform: translateY(14px) scale(.98);
  transition: transform .18s ease;
}
.modal-overlay.open .modal-box { transform: translateY(0) scale(1); }
.modal-box.wide { max-width: 760px; }
.modal-close {
  position: absolute; top: 14px; right: 14px;
  background: none; border: none; color: var(--text-muted); cursor: pointer;
  padding: 6px; border-radius: 8px; line-height: 0;
}
.modal-close:hover { background: var(--surface-2); color: var(--text); }
.modal-box h2 { margin-top: 0; padding-right: 24px; }

/* ---------- Assinatura manuscrita (canvas) ---------- */
/* Fundo branco fixo, mesmo no tema escuro: a assinatura é exportada como PNG
   e vai para PDF/impressão, onde o fundo precisa ser branco de verdade. */
.signature-pad-wrap {
  border: 1px solid var(--border); border-radius: 10px; background: #fff;
  touch-action: none; overflow: hidden;
}
.signature-pad-wrap canvas { width: 100%; height: 220px; display: block; cursor: crosshair; }
.signature-summary {
  margin: 0 0 12px; padding: 10px 12px; border: 1px solid var(--border);
  border-radius: 8px; background: var(--surface-2); font-size: 13px;
}

/* Assinatura já capturada, exibida na tela (ficha do cliente, proposta, perfil). */
.signature-preview {
  background: #fff; border: 1px solid var(--border); border-radius: 8px;
  padding: 8px 12px; display: inline-block; max-width: 100%;
}
.signature-preview img { display: block; max-width: 260px; max-height: 90px; width: auto; height: auto; }
.signature-meta { font-size: 12px; color: var(--text-muted); margin-top: 6px; }

/* ---------- Listas de detalhe (ficha do cliente/processo) ---------- */
.detail-list { display: grid; gap: 0; }
.detail-row {
  display: flex; gap: 14px; padding: 9px 0;
  border-bottom: 1px solid var(--border); font-size: 14px;
}
.detail-row:last-child { border-bottom: 0; }
.detail-row dt { color: var(--text-muted); min-width: 150px; flex-shrink: 0; margin: 0; font-size: 13px; }
.detail-row dd { margin: 0; flex: 1; min-width: 0; word-break: break-word; }

/* ---------- Linha do tempo (movimentos do processo / auditoria) ---------- */
.timeline { position: relative; padding-left: 22px; }
.timeline::before {
  content: ''; position: absolute; left: 5px; top: 6px; bottom: 6px;
  width: 1px; background: var(--border);
}
.timeline-item { position: relative; padding: 0 0 18px; }
.timeline-item:last-child { padding-bottom: 0; }
.timeline-item::before {
  content: ''; position: absolute; left: -21px; top: 6px;
  width: 11px; height: 11px; border-radius: 50%;
  background: var(--surface); border: 2px solid var(--brand);
}
.timeline-item time { font-size: 12px; color: var(--text-muted); }
.timeline-item strong { display: block; font-size: 14px; margin: 2px 0; }
.timeline-item p { margin: 0; font-size: 13.5px; color: var(--text-muted); }
/* ==========================================================================
   AGENDA - ESTILOS OTIMIZADOS (formato compacto)
   ========================================================================== */

/* ---------- Grid principal ---------- */
.agenda-grid { display: grid; grid-template-columns: 1fr 1.2fr; gap: 20px; align-items: start; }

/* ---------- Card do calendário ---------- */
.calendar-card { min-width: 0; padding: 16px; }

/* ---------- Cabeçalho do calendário ---------- */
.calendar-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; padding: 0 4px; flex-wrap: wrap; gap: 8px; }
.calendar-title { font-size: 14px; color: var(--text-muted); font-weight: 600; }
.calendar-nav { display: flex; gap: 4px; }
.calendar-nav .btn { padding: 4px 10px; font-size: 11px; }

/* ---------- Grade do calendário ---------- */
.calendar { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }

/* ---------- Dias da semana ---------- */
.calendar-dow { text-align: center; font-size: 10px; text-transform: uppercase; letter-spacing: .06em; color: var(--text-muted); padding-bottom: 4px; font-weight: 600; }

/* ---------- Dias do mês ---------- */
.calendar-day { cursor: pointer; transition: border-color 0.15s, background 0.15s; min-height: 80px; padding: 6px; border-radius: 6px; background: var(--surface-2); border: 1px solid var(--border); display: flex; flex-direction: column; gap: 2px; }
.calendar-day:hover { border-color: var(--brand); }
.calendar-day.selected { border-color: var(--brand) !important; background: var(--brand-soft) !important; }
.calendar-day.outside { opacity: 0.3; min-height: 40px; }

/* ---------- Número do dia ---------- */
.calendar-day .num { font-size: 13px; font-weight: 700; color: var(--text-muted); margin-bottom: 2px; }
.calendar-day.today .num { color: var(--brand); }

/* ---------- Eventos no calendário ---------- */
.calendar-event { font-size: 9px; padding: 2px 5px; border-radius: 4px; background: var(--brand-soft); color: var(--brand); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; line-height: 1.3; }
.calendar-event.deadline { background: var(--danger-soft); color: var(--danger); }
.calendar-event.hearing { background: var(--warn-soft); color: var(--warn); }
.calendar-event.completed { background: var(--ok-soft); color: var(--ok); }

/* ---------- "Mais" eventos ---------- */
.calendar-more { font-size: 9px; color: var(--text-muted); margin-top: 1px; }

/* ---------- Card dos compromissos do dia ---------- */
.day-cards-card { background: var(--surface); border-color: var(--border); padding: 16px; min-width: 0; }

/* ---------- Cabeçalho dos cards ---------- */
.day-cards-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; flex-wrap: wrap; gap: 8px; }
.day-cards-title { margin: 0; font-size: 16px; font-weight: 600; color: var(--text); }

/* ---------- Grid dos cards ---------- */
/**
 * Sempre 3 colunas (pedido explícito) — o "auto" do minmax original media o
 * mínimo pelo conteúdo (botões do rodapé sem quebrar linha), e isso estourava
 * a largura disponível e criava scroll horizontal, principalmente com o menu
 * lateral expandido. minmax(0, 1fr) deixa a coluna encolher até caber;
 * overflow-x: hidden é o cinto de segurança.
 */
.day-cards-grid {
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px; max-height: 650px; overflow-y: auto; overflow-x: hidden;
  padding-right: 6px; align-content: start;
}

/* ---------- Estado vazio ---------- */
.empty-state { padding: 30px; grid-column: 1 / -1; text-align: center; color: var(--text-muted); }
.empty-state svg { opacity: 0.4; margin-bottom: 8px; }
.empty-state p { font-size: 13px; margin: 8px 0 0; }

/* ---------- Card individual ---------- */
.schedule-card { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 14px; min-width: 0; transition: border-color 0.2s, transform 0.15s; display: flex; flex-direction: column; gap: 8px;margin-top: 10px; }
.schedule-card:hover { border-color: var(--brand); transform: translateY(-2px); }

/* ---------- Cabeçalho do card ---------- */
.schedule-card-header { display: flex; justify-content: space-between; align-items: center; padding-bottom: 6px; border-bottom: 1px solid var(--border); }
.schedule-time { font-weight: 600; font-size: 13px; color: var(--text); }

/* ---------- Corpo do card ---------- */
.schedule-card-body { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.schedule-client { font-size: 14px; font-weight: 600; color: var(--text); display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.schedule-whatsapp { font-size: 10px; color: var(--text-muted); font-weight: 400; }
.schedule-contact { font-size: 12px; color: var(--text-muted); }
.schedule-title { font-size: 13px; font-weight: 500; color: var(--text); margin: 2px 0; }
.schedule-lawyer { font-size: 12px; color: var(--brand); margin-bottom: 2px; }
.schedule-address { font-size: 12px; color: var(--text-muted); word-break: break-word; }
.schedule-maps { display: flex; gap: 6px; margin-top: 4px; flex-wrap: wrap; }
.schedule-maps .btn { font-size: 10px; padding: 3px 8px; }

/* ---------- Rodapé do card ---------- */
/* flex-wrap: wrap deixa os botões quebrarem linha quando o card fica
   estreito (menu lateral aberto) em vez de espremer tudo numa linha só
   até o texto ficar colado — o gap sozinho não resolve com nowrap. */
.schedule-card-footer { display: flex; gap: 6px 8px; margin-top: 4px; padding-top: 8px; border-top: 1px solid var(--border); align-items: center; flex-wrap: wrap;justify-content: center; }

.schedule-card-footer .btn { font-size: 10px; padding: 4px 10px; white-space: nowrap; flex: 0 1 auto; min-width: 0; }

/* ---------- Lista de compromissos do mês ---------- */
.month-list-card { margin-top: 14px; }

/* ---------- Scrollbar ---------- */
/* Largura/cor agora vêm do estilo global (topo do arquivo); só o smooth-scroll é específico daqui. */
.day-cards-grid { scroll-behavior: smooth; }

/* ============================================================
   RESPONSIVO
   ============================================================ */

/* ---------- Tablet (até 1024px) ---------- */
@media (max-width: 1024px) {
  .agenda-grid { grid-template-columns: 1fr; }
  .day-cards-grid { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); max-height: 450px; }
  .calendar-day { min-height: 70px; }
}

/* ---------- Mobile (até 640px) ---------- */
@media (max-width: 640px) {
  .toolbar { flex-direction: column; align-items: stretch; gap: 10px; }
  .toolbar > div:first-child { flex-wrap: wrap; justify-content: center; }
  .toolbar-actions { justify-content: center; flex-wrap: wrap; }
  .calendar-header { flex-direction: column; align-items: center; gap: 6px; }
  .calendar { gap: 3px; }
  .calendar-day { min-height: 50px; padding: 3px; gap: 1px; border-radius: 4px; }
  .calendar-day .num { font-size: 11px; margin-bottom: 1px; }
  .calendar-dow { font-size: 8px; padding-bottom: 2px; }
  .calendar-event { font-size: 7px; padding: 1px 3px; border-radius: 3px; line-height: 1.2; }
  .calendar-more { font-size: 7px; margin-top: 0; }
  .calendar-day.outside { min-height: 30px; }
  .day-cards-grid { grid-template-columns: 1fr; max-height: 400px; gap: 10px; }
  .day-cards-header { flex-direction: column; align-items: flex-start; gap: 4px; }
  .day-cards-title { font-size: 14px; }
  .schedule-card { padding: 12px; }
  .schedule-card-header { flex-wrap: wrap; gap: 4px; }
  .schedule-time { font-size: 12px; }
  .schedule-client { font-size: 13px; }
  .schedule-title { font-size: 12px; }
  .schedule-card-footer { flex-direction: column; align-items: stretch; gap: 6px; }
  .schedule-card-footer .btn { width: 100%; justify-content: center; }
  .month-list-card .table-wrap { font-size: 12px; }
  .month-list-card th,
  .month-list-card td { padding: 6px 8px; }
  #monthSelect,
  #yearSelect { padding: 4px 8px; font-size: 13px; }
}

/* ---------- Mobile pequeno (até 400px) ---------- */
@media (max-width: 400px) {
  .calendar { gap: 2px; }
  .calendar-day { min-height: 38px; padding: 2px; border-radius: 3px; }
  .calendar-day .num { font-size: 9px; }
  .calendar-dow { font-size: 7px; padding-bottom: 1px; }
  .calendar-event { font-size: 6px; padding: 1px 2px; }
  .calendar-more { font-size: 6px; }
  .calendar-day.outside { min-height: 24px; }
  .day-cards-grid { max-height: 350px; }
}
/* ---------- Zona de upload (IA / documentos) ---------- */
.dropzone {
  border: 2px dashed var(--border); border-radius: var(--radius);
  padding: 34px 20px; text-align: center; color: var(--text-muted);
  background: var(--surface-2); cursor: pointer;
  transition: border-color .15s, background .15s;
}
.dropzone:hover, .dropzone.dragover { border-color: var(--brand); background: var(--brand-soft); }
.dropzone .icon { color: var(--brand); margin-bottom: 8px; }
.dropzone strong { display: block; color: var(--text); font-size: 15px; }
.dropzone input[type="file"] { display: none; }

/* Resultado da análise da IA */
.ai-result { background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px; }
.ai-result h4 { margin: 0 0 10px; font-size: 13px; text-transform: uppercase;
  letter-spacing: .05em; color: var(--brand); }
.ai-result pre { white-space: pre-wrap; word-break: break-word; margin: 0;
  font-family: inherit; font-size: 14px; line-height: 1.6; }

/* ---------- Combobox de busca em tempo real (processo, cliente...) ---------- */
.search-results {
  position: absolute; z-index: 30; left: 0; right: 0; top: 100%; margin-top: 4px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  max-height: 240px; overflow-y: auto; box-shadow: 0 8px 24px rgba(0,0,0,.25);
}
.search-results button {
  display: block; width: 100%; text-align: left; padding: 8px 12px; background: none;
  border: 0; border-bottom: 1px solid var(--border); color: inherit; cursor: pointer;
  font-size: 13px; font-family: inherit;
}
.search-results button:last-child { border-bottom: 0; }
.search-results button:hover { background: var(--surface-2); }
.search-results .muted { font-size: 12px; color: var(--text-muted); }

/* ---------- Lista de "chips" (multi-seleção por busca, ex.: advogados vinculados) ---------- */
.chip-list { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.chip-list:empty { margin-bottom: 0; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--brand-soft); color: var(--brand);
  border-radius: 999px; padding: 4px 6px 4px 12px; font-size: 13px; font-weight: 600;
}
.chip-remove {
  display: grid; place-items: center; width: 18px; height: 18px; border-radius: 50%;
  background: none; border: 0; color: inherit; cursor: pointer; font-size: 15px; line-height: 1;
  opacity: .7;
}
.chip-remove:hover { opacity: 1; background: rgba(255,255,255,.15); }

/* ---------- Galeria de documentos (modal de seleção) ---------- */
.doc-gallery {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px;
  max-height: 440px; overflow-y: auto; padding: 2px;
}
.doc-card {
  background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px 10px; cursor: pointer; text-align: center; transition: border-color .15s;
}
.doc-card:hover, .doc-card:focus { border-color: var(--brand); outline: none; }
.doc-card .doc-card-icon { color: var(--brand); margin-bottom: 6px; }
.doc-card .doc-card-title {
  font-size: 12.5px; font-weight: 600; margin-bottom: 4px; overflow: hidden;
  text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
}
.doc-card .doc-card-meta { font-size: 11px; color: var(--text-muted); line-height: 1.4; }

/* ---------- Editor de texto rico (negrito, listas...) sobre resultado de IA ---------- */
.rich-toolbar {
  display: flex; align-items: center; gap: 2px; flex-wrap: wrap;
  background: var(--surface-2); border: 1px solid var(--border); border-bottom: 0;
  border-radius: var(--radius) var(--radius) 0 0; padding: 6px;
}
.rich-toolbar button {
  min-width: 30px; height: 30px; padding: 0 8px; border-radius: 6px; border: 0;
  background: transparent; color: var(--text); font-size: 13px; font-family: inherit;
  cursor: pointer;
}
.rich-toolbar button:hover { background: var(--surface); }
.rich-toolbar-sep { width: 1px; height: 20px; background: var(--border); margin: 0 4px; }

.rich-editable {
  min-height: 300px; max-height: 560px; overflow-y: auto;
  border: 1px solid var(--border); border-radius: 0 0 var(--radius) var(--radius);
  padding: 12px 14px; font-size: 14px; line-height: 1.7; background: var(--surface-2);
}
.rich-editable:focus { outline: none; border-color: var(--brand); }
.rich-editable p { margin: 0 0 10px; }
.rich-editable ul, .rich-editable ol { margin: 0 0 10px; padding-left: 22px; }
.rich-editable li { margin-bottom: 4px; }

.spinner {
  width: 18px; height: 18px; border-radius: 50%; display: inline-block;
  border: 2px solid var(--brand-soft); border-top-color: var(--brand);
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Memória de cálculo ---------- */
.calc-summary {
  display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  margin-bottom: 16px;
}
.calc-summary div {
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 8px; padding: 12px;
}
.calc-summary span { display: block; font-size: 12px; color: var(--text-muted); }
.calc-summary strong { font-size: 19px; }
.calc-summary .total strong { color: var(--brand); }

/* ---------- Barra de progresso (limites do plano) ---------- */
.progress { height: 6px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--brand); border-radius: 999px; }
.progress.warn > span { background: var(--warn); }
.progress.danger > span { background: var(--danger); }

/* ---------- Paginação ---------- */
.pagination { display: flex; gap: 6px; justify-content: center; margin-top: 18px; flex-wrap: wrap; }
.pagination a, .pagination span {
  padding: 7px 12px; border-radius: 8px; font-size: 13px; font-weight: 600;
  border: 1px solid var(--border); color: var(--text-muted); text-decoration: none;
}
.pagination a:hover { color: var(--text); border-color: var(--text-muted); text-decoration: none; }
.pagination .current { background: var(--brand); border-color: var(--brand); color: #fff; }

/* ==========================================================================
   Telas sem sidebar (login, instalação)
   ========================================================================== */
.gate {
  min-height: 100vh; display: grid; place-items: center; padding: 24px;
  background: radial-gradient(1000px 480px at 50% -10%, rgba(59,130,246,.12), transparent);
}
.gate-box { width: 100%; max-width: 420px; }
.gate-box.wide { max-width: 720px; }
.gate-brand { text-align: center; margin-bottom: 22px; }
.gate-brand .logo-mark { width: 46px; height: 46px; font-size: 22px; margin: 0 auto 10px; }
.gate-brand h1 { font-size: 22px; margin: 0; }
.gate-brand p { color: var(--text-muted); font-size: 13.5px; margin: 6px 0 0; }
.gate-foot { text-align: center; margin-top: 16px; font-size: 13px; color: var(--text-muted); }

/* ==========================================================================
   Site público (home / captação de leads)
   ========================================================================== */
.site-header {
  position: sticky; top: 0; z-index: 50;
  background: rgba(15, 17, 21, .88); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.site-header-inner {
  max-width: 1140px; margin: 0 auto; padding: 14px 24px;
  display: flex; align-items: center; gap: 24px;
}
.site-nav { display: flex; gap: 20px; margin-left: auto; align-items: center; }
.site-nav a { color: var(--text-muted); font-size: 14px; font-weight: 500; }
.site-nav a:hover { color: var(--text); text-decoration: none; }

.site-section { max-width: 1140px; margin: 0 auto; padding: 72px 24px; }
.site-section > h2 { font-size: 30px; margin: 0 0 10px; letter-spacing: -.6px; }
.site-section > .lead { color: var(--text-muted); font-size: 16px; max-width: 620px; margin: 0 0 36px; }

.hero {
  background: radial-gradient(900px 460px at 12% -10%, rgba(59,130,246,.16), transparent);
  border-bottom: 1px solid var(--border);
}
.hero-inner {
  max-width: 1140px; margin: 0 auto; padding: 88px 24px;
  display: grid; gap: 48px; grid-template-columns: 1.1fr .9fr; align-items: center;
}
.hero h1 { font-size: 46px; line-height: 1.08; letter-spacing: -1.4px; margin: 0 0 18px; }
.hero h1 span { color: var(--brand); }
.hero p { font-size: 17px; color: var(--text-muted); margin: 0 0 28px; max-width: 520px; }
.hero-actions { display: flex; gap: 12px; flex-wrap: wrap; }
.hero-badges { display: flex; gap: 22px; margin-top: 34px; flex-wrap: wrap; }
.hero-badges div strong { display: block; font-size: 24px; color: var(--brand); }
.hero-badges div span { font-size: 12.5px; color: var(--text-muted); }

.area-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 22px;
  transition: border-color .16s, transform .16s;
}
.area-card:hover { border-color: var(--brand); transform: translateY(-3px); }
.area-card .icon-badge {
  width: 40px; height: 40px; border-radius: 11px; display: grid; place-items: center;
  background: var(--brand-soft); color: var(--brand); margin-bottom: 14px;
}

/* ---------- Aviso flutuante de novo lead (painel) ---------- */
:root {
  --lead-gold: #c9a86a;
  --lead-gold-soft: rgba(201, 168, 106, .16);
}

.lead-alert { position: fixed; right: 24px; bottom: 24px; z-index: 9998; }

.lead-alert-bell {
  width: 52px; height: 52px; border-radius: 50%; border: 1px solid var(--border);
  background: linear-gradient(160deg, var(--surface) 0%, var(--surface-2) 100%);
  color: var(--lead-gold); display: grid; place-items: center; position: relative;
  cursor: pointer; box-shadow: var(--shadow); transition: transform .15s, border-color .15s;
}
.lead-alert-bell:hover { transform: translateY(-2px); border-color: var(--lead-gold); }
.lead-alert-bell svg { animation: lead-bell-ring 2.4s ease-in-out infinite; }
@keyframes lead-bell-ring {
  0%, 82%, 100% { transform: rotate(0); }
  85% { transform: rotate(-9deg); }
  88% { transform: rotate(8deg); }
  91% { transform: rotate(-6deg); }
  94% { transform: rotate(3deg); }
  97% { transform: rotate(0); }
}

.lead-alert-count {
  position: absolute; top: -4px; right: -4px; min-width: 20px; height: 20px; padding: 0 5px;
  border-radius: 999px; background: var(--danger); color: #fff; font-size: 11px; font-weight: 700;
  display: grid; place-items: center; border: 2px solid var(--bg); line-height: 1;
}

.lead-alert-panel {
  position: absolute; right: 0; bottom: 64px; width: 320px; max-height: 420px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); overflow: hidden; display: flex; flex-direction: column;
  opacity: 0; visibility: hidden; transform: translateY(8px); transition: opacity .15s, transform .15s;
}
.lead-alert-panel.open { opacity: 1; visibility: visible; transform: translateY(0); }

.lead-alert-panel-head {
  display: flex; align-items: center; gap: 8px; padding: 14px 16px;
  border-bottom: 1px solid var(--border); font-weight: 600; font-size: 13.5px;
  color: var(--lead-gold); background: var(--surface-2);
}

.lead-alert-panel-list { overflow-y: auto; max-height: 300px; }

.lead-alert-item {
  display: flex; align-items: flex-start; gap: 10px; padding: 12px 16px;
  border-bottom: 1px solid var(--border); text-decoration: none; color: var(--text);
  transition: background .12s;
}
.lead-alert-item:last-child { border-bottom: 0; }
.lead-alert-item:hover { background: var(--surface-2); text-decoration: none; }
.lead-alert-item-dot {
  width: 8px; height: 8px; border-radius: 50%; background: var(--lead-gold);
  margin-top: 6px; flex-shrink: 0;
}
.lead-alert-item-body { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.lead-alert-item-name { font-size: 13.5px; font-weight: 600; }
.lead-alert-item-meta { font-size: 12px; color: var(--text-muted); }

.lead-alert-empty { padding: 20px 16px; font-size: 13px; color: var(--text-muted); text-align: center; }

.lead-alert-panel-footer {
  display: block; text-align: center; padding: 11px; font-size: 12.5px; font-weight: 600;
  color: var(--brand); border-top: 1px solid var(--border); text-decoration: none;
  background: var(--surface-2);
}
.lead-alert-panel-footer:hover { text-decoration: underline; }

/* Toast de "nova solicitação" que desliza ao chegar um lead durante a sessão */
.lead-alert-toast {
  position: fixed; right: 24px; bottom: 90px; z-index: 9999; width: 320px;
  display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px;
  background: linear-gradient(160deg, var(--surface) 0%, var(--surface-2) 100%);
  border: 1px solid var(--lead-gold); border-left: 4px solid var(--lead-gold);
  border-radius: var(--radius); box-shadow: var(--shadow); text-decoration: none; color: var(--text);
  opacity: 0; transform: translateX(24px); transition: opacity .3s ease, transform .3s ease;
}
.lead-alert-toast.in { opacity: 1; transform: translateX(0); }
.lead-alert-toast-icon {
  width: 34px; height: 34px; border-radius: 50%; background: var(--lead-gold-soft);
  color: var(--lead-gold); display: grid; place-items: center; flex-shrink: 0;
}
.lead-alert-toast-body { display: flex; flex-direction: column; gap: 3px; font-size: 13px; }
.lead-alert-toast-body strong { font-size: 13.5px; }
.lead-alert-toast-body span { color: var(--text-muted); }

@media (max-width: 640px) {
  .lead-alert { right: 16px; bottom: 16px; }
  .lead-alert-panel, .lead-alert-toast { width: calc(100vw - 32px); right: -8px; }
}
.area-card h3 { margin: 0 0 6px; font-size: 16px; }
.area-card p { margin: 0; font-size: 13.5px; color: var(--text-muted); }

.testimonial { background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 22px; }
.testimonial p { margin: 0 0 14px; font-size: 14.5px; font-style: italic; }
.testimonial footer { display: flex; align-items: center; gap: 10px; }
.testimonial footer strong { font-size: 13.5px; display: block; }
.testimonial footer span { font-size: 12px; color: var(--text-muted); }

.site-footer {
  border-top: 1px solid var(--border); background: var(--surface);
  padding: 34px 24px; text-align: center; color: var(--text-muted); font-size: 13px;
}

/* ==========================================================================
   Responsivo
   ========================================================================== */
@media (max-width: 900px) {
  /* No celular a sidebar vira gaveta sobreposta — coluna fixa comeria a tela. */
  .layout,
  html.is-collapsed .layout { grid-template-columns: 1fr; }

  .sidebar {
    position: fixed; top: 0; left: 0; bottom: 0; z-index: 80;
    width: var(--sidebar-w);
    transform: translateX(-100%);
    transition: transform .22s ease;
    box-shadow: var(--shadow);
  }
  /* A gaveta é sempre "expandida": ícone sozinho não ajuda em tela pequena. */
  body.drawer-open .sidebar { transform: translateX(0); }
  html.is-collapsed .logo-text,
  html.is-collapsed .nav-label,
  html.is-collapsed .nav-caret { display: revert; }
  html.is-collapsed .nav-link { justify-content: flex-start; padding: 9px 11px; }
  html.is-collapsed .nav-sub {
    position: static; opacity: 1; visibility: visible; transform: none;
    background: none; border: 0; box-shadow: none; padding: 0;
    margin-left: 21px; border-left: 1px solid var(--border); padding-left: 7px;
    display: grid; grid-template-rows: 0fr; min-width: 0;
  }
  html.is-collapsed .nav-section.open > .nav-sub { grid-template-rows: 1fr; }
  /* Volta a cortar: na gaveta o accordion é acordeão de novo, não flyout. */
  html.is-collapsed .nav-sub-inner { overflow: hidden; min-height: 0; }
  html.is-collapsed .sidebar { overflow-x: hidden; overflow-y: auto; }
  html.is-collapsed .nav-sub { max-height: none; overflow: visible; }
  /* Sem hover no toque, a ponte só atrapalharia. */
  html.is-collapsed .nav-section::after { content: none; }
  html.is-collapsed .nav-sub-title { display: none; }
  html.is-collapsed .nav-link[data-tip]::after { content: none; }

  .sidebar-collapse { display: none; }   /* fechar é pelo backdrop ou por um link */
  .topbar-burger { display: grid; place-items: center; }

  /* Título embaixo do cabeçalho em vez de espremido na mesma linha do avatar. */
  .topbar { flex-wrap: wrap; row-gap: 10px; padding: 12px 16px; }
  .topbar h1 { order: 10; flex-basis: 100%; font-size: 17px; }
  .content { padding: 16px; }

  .sidebar-backdrop {
    display: block; position: fixed; inset: 0; z-index: 70;
    background: rgba(0, 0, 0, .55);
    opacity: 0; visibility: hidden; transition: opacity .22s, visibility .22s;
  }
  body.drawer-open .sidebar-backdrop { opacity: 1; visibility: visible; }
  body.drawer-open { overflow: hidden; }

  .hero-inner { grid-template-columns: 1fr; padding: 56px 20px; gap: 32px; }
  .hero h1 { font-size: 34px; }
  .site-section { padding: 48px 20px; }
  .site-nav { display: none; }

  /**
   * iOS Safari dá zoom automático ao focar um <input> com font-size < 16px —
   * a página inteira salta de tamanho ao tocar o campo. !important porque
   * vários campos têm font-size menor no próprio atributo style="".
   */
  input, select, textarea { font-size: 16px !important; }

  /**
   * Filtro/busca das listagens (clientes, processos, propostas...): cada
   * campo em largura cheia, empilhado — em vez de vários <select> estreitos
   * lado a lado, difíceis de tocar com precisão numa tela pequena.
   */
  .toolbar-form { flex-direction: column; align-items: stretch; max-width: none; }
  .toolbar-form .field,
  .toolbar-form .field:has(> input[type="search"]) { flex: 1 1 auto; width: 100%; min-width: 0; }
  .toolbar-form select,
  .toolbar-form input[type="date"] { width: 100%; }
  .toolbar-form button[type="submit"] { width: 100%; justify-content: center; }

  .detail-row { flex-direction: column; gap: 2px; }
  .detail-row dt { min-width: 0; }
  .calendar { grid-template-columns: repeat(7, minmax(44px, 1fr)); font-size: 11px; }
  .calendar-day { min-height: 62px; }
}

/* ==========================================================================
   Impressão — some com a navegação, sobra o conteúdo em largura cheia
   ========================================================================== */
@media print {
  .sidebar, .topbar, .sidebar-backdrop, .no-print,
  #toast-area, .form-actions, .toolbar { display: none !important; }
  .layout, html.is-collapsed .layout { display: block; }
  .content { padding: 0; }
  body { background: #fff; color: #000; }
  .card { border-color: #ccc; background: #fff; break-inside: avoid; }
  a { color: #000; }
}
