/* EDR CRM — Paleta idêntica ao EDR System */
/* Tablet-first, responsivo */

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

:root {
  /* ── Mist Valley palette ── */
  --verde: #203b14;
  --verde-hover: #132507;
  --verde-light: #2d5a1e;
  --verde-surface: rgba(32,59,20,0.08);
  --verde-pale: #d9e8cc;

  /* CTA primário — Amber Seed */
  --cta: #4a3212;
  --cta-hover: #5a3e18;

  --sidebar-bg: #ffffff;
  --sidebar-border: #e8eddf;
  --sidebar-width: 240px;

  /* Fundos */
  --bg: #fbfdf6;
  --surface: #ffffff;

  /* Texto */
  --text-primary: #0a1d08;
  --text-secondary: #6b7e62;
  --text-tertiary: #97a98c;

  /* Bordas */
  --border: #d8e0cc;
  --border-light: #e8eddf;

  /* Feedback */
  --success: #059669;
  --vermelho: #dc2626;
  --vermelho-pale: #fee2e2;
  --amarelo: #d97706;
  --amarelo-pale: #fef3c7;
  --azul: #2563eb;
  --azul-pale: #dbeafe;

  /* Alias de compat */
  --preto: #0a1d08;
  --cinza: #6b7e62;
  --cinza-dark: #2e4027;
  --cinza-light: #d8e0cc;
  --branco: #ffffff;

  /* Layout */
  --raio: 8px;
  --raio-lg: 16px;
  --sombra: 0 1px 2px rgba(0,0,0,.04), 0 1px 3px rgba(0,0,0,.06);
  --sombra-md: 0 4px 16px rgba(0,0,0,.08);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; -webkit-text-size-adjust: 100%; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.5;
  letter-spacing: -0.025em;
}

/* ── Layout ── */
.app-shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  color: var(--text-primary);
  display: flex;
  flex-direction: column;
  padding: 0;
  flex-shrink: 0;
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  z-index: 100;
  border-right: 1px solid var(--sidebar-border);
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 16px;
  border-bottom: 1px solid var(--sidebar-border);
}

.brand-logo {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: var(--verde);
  color: #fff;
  display: grid;
  place-items: center;
  font-family: 'Inter', sans-serif;
  font-weight: 700;
  font-size: 14px;
  flex-shrink: 0;
}

.sidebar-logo .logo-title {
  font-family: 'Inter', sans-serif;
  font-size: .95rem;
  font-weight: 700;
  letter-spacing: -.03em;
  color: var(--text-primary);
}

.sidebar-logo .logo-sub {
  font-size: .7rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-top: 2px;
}

.sidebar-nav { flex: 1; padding: 8px 8px; overflow-y: auto; }

.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 12px;
  color: var(--text-secondary);
  text-decoration: none;
  font-size: .875rem;
  font-weight: 500;
  transition: background .15s, color .15s;
  border-radius: 999px;
  margin-bottom: 2px;
}

.sidebar-nav a:hover {
  background: #edf1e5;
  color: var(--text-primary);
}
.sidebar-nav a.active {
  background: var(--verde-surface);
  color: var(--verde);
  font-weight: 600;
}

.sidebar-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--sidebar-border);
  font-size: .82rem;
  color: var(--text-secondary);
}
.crm-versao {
  font-family: 'JetBrains Mono', monospace;
  font-size: .68rem;
  color: var(--text-tertiary);
  margin-top: 4px;
  opacity: .9;
}

.main {
  margin-left: var(--sidebar-width);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 14px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  position: sticky;
  top: 0;
  z-index: 50;
}

.topbar-title {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--preto);
}

.page-content {
  padding: 24px;
  flex: 1;
}

/* ── Tipografia ── */
h1, h2, h3 {
  font-family: 'Inter', -apple-system, sans-serif;
  letter-spacing: -.03em;
}
h1 { font-size: 1.4rem; font-weight: 700; }
h2 { font-size: 1.15rem; font-weight: 700; }
h3 { font-size: 1rem; font-weight: 700; }

/* ── Botões ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 18px;
  border-radius: 999px;
  font-size: .9rem;
  font-weight: 500;
  cursor: pointer;
  border: none;
  text-decoration: none;
  transition: background .15s, transform .1s;
  white-space: nowrap;
  letter-spacing: -0.02em;
}
.btn:active { transform: scale(.97); }
.btn-primary {
  background: var(--cta);
  color: var(--branco);
}
.btn-primary:hover { background: var(--cta-hover); }
.btn-secondary { background: var(--cinza-light); color: var(--preto); }
.btn-secondary:hover { background: #d1d5db; }
.btn-danger { background: var(--vermelho-pale); color: var(--vermelho); }
.btn-danger:hover { background: #fca5a5; }
.btn-whatsapp { background: #22c55e; color: var(--branco); }
.btn-whatsapp:hover { background: #16a34a; }
.btn-ai { background: #7c3aed; color: var(--branco); }
.btn-ai:hover { background: #6d28d9; }
.btn-sm { padding: 6px 12px; font-size: .82rem; }
.btn-icon { padding: 8px; border-radius: var(--raio); }

/* ── Formulários ── */
.form-group { margin-bottom: 16px; }
.form-group label {
  display: block;
  font-size: .85rem;
  font-weight: 500;
  color: var(--cinza-dark);
  margin-bottom: 5px;
}
.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1.5px solid var(--cinza-light);
  border-radius: var(--raio);
  font-size: .92rem;
  color: var(--preto);
  background: var(--branco);
  transition: border-color .15s;
  font-family: inherit;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--verde-light);
  box-shadow: 0 0 0 3px rgba(64,145,108,.15);
}
.form-group textarea { resize: vertical; min-height: 80px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.form-grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 0 16px; }
.form-full { grid-column: 1 / -1; }

/* ── Cards ── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--raio-lg);
  padding: 20px;
  margin-bottom: 16px;
}
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  gap: 8px;
}
.card-title { font-weight: 600; font-size: 1rem; }

/* ── Tabela ── */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; table-layout: auto; }
thead tr { background: #f4f7ee; }

/* Coluna "Próxima ação" — trunca com … quando texto longo, mostra completo no hover */
#tabela-clientes td.col-proxima {
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
#tabela-clientes td.col-proxima > span {
  display: inline-block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  vertical-align: middle;
}
/* Coluna de Ações — sempre ocupa só o mínimo necessário, alinhada à direita */
#tabela-clientes td.col-acoes {
  white-space: nowrap;
  width: 1%;
  text-align: right;
}
#tabela-clientes td.col-acoes .btn { margin-left: 4px; }
th, td {
  padding: 10px 14px;
  text-align: left;
  font-size: .88rem;
  border-bottom: 1px solid var(--cinza-light);
  white-space: nowrap;
}
th { font-weight: 600; color: var(--cinza-dark); }
tbody tr:hover { background: #f4f7ee; }

/* ── Badges ── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: .76rem;
  font-weight: 500;
  white-space: nowrap;
}
.badge-red { background: var(--vermelho-pale); color: var(--vermelho); }
.badge-yellow { background: var(--amarelo-pale); color: #92400e; }
.badge-green { background: var(--verde-pale); color: var(--verde); }
.badge-blue { background: var(--azul-pale); color: var(--azul); }
.badge-gray { background: var(--cinza-light); color: var(--cinza-dark); }

/* Status kanban */
.status-triagem { background: #e0e7ff; color: #3730a3; }
.status-documentacao { background: #fef3c7; color: #92400e; }
.status-correspondente { background: #dbeafe; color: #1e40af; }
.status-aprovado { background: #d1fae5; color: #065f46; }
.status-prefeitura { background: #ede9fe; color: #5b21b6; }
.status-assinatura { background: #fce7f3; color: #9d174d; }
.status-concluido { background: var(--verde-pale); color: var(--verde); }
.status-perdido { background: var(--cinza-light); color: var(--cinza); }

/* ── Kanban ── */
.kanban-wrap {
  display: flex;
  gap: 10px;
  overflow-x: scroll;
  padding-bottom: 8px;
  align-items: flex-start;
  scrollbar-width: thin;
  scrollbar-color: #cbd5e1 transparent;
}
.kanban-wrap::-webkit-scrollbar { height: 10px; }
.kanban-wrap::-webkit-scrollbar-track { background: transparent; }
.kanban-wrap::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 6px; }
.kanban-wrap::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

/* Legenda discreta no topo do board */
.kanban-legenda {
  display: flex;
  gap: 18px;
  padding: 0 0 12px;
  font-size: .72rem;
  color: var(--text-secondary);
  flex-wrap: wrap;
}
.legenda-item { display: flex; align-items: center; gap: 6px; }
.legenda-cor {
  width: 14px;
  height: 14px;
  border-radius: 3px;
  display: inline-block;
  border-left-width: 4px;
  border-left-style: solid;
  border-top: 1px solid rgba(0,0,0,.08);
  border-right: 1px solid rgba(0,0,0,.08);
  border-bottom: 1px solid rgba(0,0,0,.08);
}
.legenda-impedimento { background: #fef2f2; border-left-color: #dc2626; }
.legenda-recusado { background: #fff7ed; border-left-color: #ea580c; }
.legenda-sla { background: #fffbeb; border-left-color: #d97706; }

.kanban-col {
  flex-shrink: 0;
  width: 200px;
  background: #edf1e5;
  border-radius: var(--raio);
  padding: 12px 10px;
  height: calc(100vh - 200px);
  min-height: 480px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}
.kanban-col-empty {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  font-size: .75rem;
  color: #94a3b8;
  font-style: italic;
  padding: 24px 12px;
  border: 2px dashed #cbd5e1;
  border-radius: 8px;
  margin-top: 8px;
}
.kanban-col[data-status="concluido"],
.kanban-col[data-status="perdido"] {
  width: 130px;
  background: #edf1e5;
  opacity: .85;
}
.kanban-col[data-status="perdido"] { border: 1px dashed #d1d5db; }
.kanban-col[data-status="concluido"] .kanban-card-lote,
.kanban-col[data-status="concluido"] .kanban-card-badges,
.kanban-col[data-status="concluido"] .kanban-card-acao,
.kanban-col[data-status="perdido"] .kanban-card-lote,
.kanban-col[data-status="perdido"] .kanban-card-badges,
.kanban-col[data-status="perdido"] .kanban-card-acao {
  display: none;
}

.kanban-col-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
  padding: 0 4px;
}

.kanban-col-title {
  font-size: .72rem;
  font-weight: 700;
  color: #6b7280;
  text-transform: uppercase;
  letter-spacing: .6px;
}

.kanban-count {
  background: #1f2937;
  color: #fff;
  border-radius: 10px;
  padding: 2px 8px;
  font-size: .7rem;
  font-weight: 700;
  min-width: 22px;
  text-align: center;
}

.kanban-card {
  background: var(--branco);
  border-radius: var(--raio);
  padding: 12px;
  margin-bottom: 10px;
  box-shadow: 0 1px 2px rgba(0,0,0,.04), 0 2px 6px rgba(0,0,0,.06);
  cursor: grab;
  border-left: 4px solid transparent;
  transition: box-shadow .15s, transform .1s;
}
.kanban-card:active { cursor: grabbing; }
.kanban-card:hover { box-shadow: 0 2px 4px rgba(0,0,0,.06), 0 4px 12px rgba(0,0,0,.08); transform: translateY(-1px); }

/* Estados com gravidade — fundo tintado + border 4px (impedimento > recusado > sla) */
.kanban-card.sla-yellow { border-left-color: #d97706; background: #fffbeb; }
.kanban-card.sla-red { border-left-color: #dc2626; background: #fef2f2; }
.kanban-card.has-recusado {
  border-left-color: #ea580c;
  background: #fff7ed;
  box-shadow: 0 0 0 1px rgba(234,88,12,.15), 0 1px 3px rgba(0,0,0,.08);
}
.kanban-card.has-impedimento {
  border-left-color: #dc2626;
  background: #fef2f2;
  box-shadow: 0 0 0 1px rgba(220,38,38,.15), 0 1px 3px rgba(0,0,0,.08);
}

.kanban-card-nome {
  font-weight: 700;
  font-size: 1rem;
  line-height: 1.25;
  color: #111827;
  margin-bottom: 8px;
}
.kanban-card-lote {
  font-size: .68rem;
  font-weight: 700;
  color: #9ca3af;
  text-transform: uppercase;
  letter-spacing: .5px;
  margin-bottom: 8px;
}
.kanban-card-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 8px;
}
.kanban-card-acao {
  font-size: .8rem;
  color: #4b5563;
  line-height: 1.4;
  padding-top: 8px;
  border-top: 1px solid #f3f4f6;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.kanban-col.drag-over {
  background: #d9e8cc;
  outline: 2px dashed var(--verde);
  outline-offset: -4px;
}
.kanban-card.dragging {
  opacity: .6;
  transform: rotate(1.5deg) scale(1.02);
  box-shadow: 0 8px 24px rgba(0,0,0,.18);
}

/* ── Checklist docs ── */
.doc-list { display: flex; flex-direction: column; gap: 8px; }
.doc-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--raio);
  background: #f9fafb;
  border: 1px solid var(--cinza-light);
}
.doc-item.status-entregue { background: var(--verde-pale); border-color: #95d5b2; }
.doc-item.status-recusado { background: var(--vermelho-pale); border-color: #fca5a5; }
.doc-item.status-vencido { background: var(--amarelo-pale); border-color: #fcd34d; }
.doc-nome { flex: 1; font-size: .88rem; font-weight: 500; }
.doc-status { font-size: .78rem; }

/* ── Impedimentos ── */
.imp-list { display: flex; flex-direction: column; gap: 6px; }
.imp-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: var(--raio);
  background: var(--vermelho-pale);
  border: 1px solid #fca5a5;
}
.imp-item.resolvido { background: #f9fafb; border-color: var(--cinza-light); opacity: .6; }
.imp-nome { flex: 1; font-size: .88rem; font-weight: 500; color: var(--vermelho); }
.imp-item.resolvido .imp-nome { color: var(--cinza); text-decoration: line-through; }

/* ── Família / composição ── */
.familia-membro {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr auto;
  gap: 8px;
  align-items: end;
  margin-bottom: 8px;
}

/* ── Lotes ── */
.lotes-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 10px;
}

.lote-card {
  background: var(--branco);
  border-radius: var(--raio);
  padding: 14px;
  box-shadow: var(--sombra);
  text-align: center;
  border: 2px solid transparent;
  cursor: pointer;
  transition: border-color .15s, box-shadow .15s;
}
.lote-card:hover { box-shadow: var(--sombra-md); }
.lote-card.disponivel { border-color: var(--verde-light); }
.lote-card.reservado { border-color: var(--amarelo); background: var(--amarelo-pale); }
.lote-card.vendido { border-color: var(--verde); background: var(--verde-pale); }
.lote-card.bloqueado { border-color: var(--vermelho); background: var(--vermelho-pale); }

.lote-numero { font-size: 1.2rem; font-weight: 700; margin-bottom: 2px; }
.lote-quadra { font-size: .75rem; color: var(--cinza); }
.lote-status { font-size: .78rem; font-weight: 600; margin-top: 6px; }

/* ── Histórico ── */
.hist-list { display: flex; flex-direction: column; gap: 8px; }
.hist-item {
  display: flex;
  gap: 10px;
  padding: 10px;
  border-radius: var(--raio);
  background: #f9fafb;
  font-size: .85rem;
}
.hist-icon { font-size: 1rem; flex-shrink: 0; }
.hist-desc { flex: 1; }
.hist-data { font-size: .76rem; color: var(--cinza); white-space: nowrap; }

/* ── Filtros / busca ── */
.filtros-bar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 16px;
  align-items: center;
}
.filtros-bar input[type="search"],
.filtros-bar select {
  padding: 9px 16px;
  border: 1.5px solid var(--cinza-light);
  border-radius: 999px;
  font-size: .88rem;
  background: var(--branco);
  letter-spacing: -0.02em;
}
.filtros-bar input[type="search"] { min-width: 220px; }

/* ── Modal ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.modal {
  background: var(--branco);
  border-radius: var(--raio-lg);
  width: 100%;
  max-width: 600px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--sombra-md);
  display: flex;
  flex-direction: column;
}
.modal-header {
  padding: 18px 20px 12px;
  border-bottom: 1px solid var(--cinza-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal-body { padding: 20px; flex: 1; }
.modal-footer {
  padding: 12px 20px;
  border-top: 1px solid var(--cinza-light);
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}
.modal-close {
  background: none;
  border: none;
  font-size: 1.3rem;
  cursor: pointer;
  color: var(--cinza);
  padding: 2px 6px;
}

/* ── Toast ── */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  padding: 12px 20px;
  border-radius: 999px;
  font-size: .9rem;
  font-weight: 500;
  z-index: 999;
  box-shadow: var(--sombra-md);
  animation: slideUp .25s ease;
}
.toast-info { background: var(--preto); color: var(--branco); }
.toast-success { background: var(--cta); color: var(--branco); }
.toast-error { background: var(--vermelho); color: var(--branco); }
@keyframes slideUp { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

/* ── Loading ── */
#loading {
  position: fixed;
  inset: 0;
  background: rgba(255,255,255,.7);
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
}
#loading.hidden { display: none; }
.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--cinza-light);
  border-top-color: var(--verde);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Login ── */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #0a1d08;
  padding: 16px;
}
.login-box {
  background: var(--branco);
  border-radius: 12px;
  padding: 36px 32px;
  width: 100%;
  max-width: 380px;
  box-shadow: 0 8px 32px rgba(0,0,0,.2);
}
.login-logo {
  text-align: center;
  margin-bottom: 28px;
}
.login-logo h1 { color: var(--verde); font-size: 1.6rem; }
.login-logo p { color: var(--cinza); font-size: .85rem; margin-top: 4px; }
.login-erro {
  background: var(--vermelho-pale);
  color: var(--vermelho);
  border-radius: var(--raio);
  padding: 10px 14px;
  font-size: .85rem;
  margin-bottom: 14px;
}

/* ── Seções ── */
.section { margin-bottom: 24px; }
.section-title {
  font-size: .9rem;
  font-weight: 600;
  color: var(--cinza-dark);
  text-transform: uppercase;
  letter-spacing: .5px;
  margin-bottom: 12px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--cinza-light);
}

/* ── Utilitários ── */
.hidden { display: none !important; }
.flex { display: flex; }
.flex-center { display: flex; align-items: center; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.flex-1 { flex: 1; }
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-sm { font-size: .85rem; }
.text-muted { color: var(--cinza); }
.text-danger { color: var(--vermelho); }
.text-success { color: var(--verde); }
.font-bold { font-weight: 700; }
.mt-4 { margin-top: 4px; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mb-8 { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }

/* ── Botão outline/ghost ── */
.btn-outline {
  background: transparent;
  border: 1.5px solid var(--cinza-light);
  color: var(--cinza-dark);
}
.btn-outline:hover { background: var(--cinza-light); }

/* ── Docs + Impedimentos: 2 colunas → 1 em tela menor ── */
.docs-responsivo {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

/* ── Responsivo tablet (768px+) ── */
@media (max-width: 900px) {
  .form-grid { grid-template-columns: 1fr; }
  .form-grid-3 { grid-template-columns: 1fr 1fr; }
  .kanban-col { width: 180px; }
  .kanban-col[data-status="concluido"],
  .kanban-col[data-status="perdido"] { width: 120px; }
  .docs-responsivo { grid-template-columns: 1fr; }

  /* Tabela clientes — esconde CPF, Telefone e Próxima ação em tablet
     (info disponível na ficha; libera espaço pras colunas operacionais) */
  #tabela-clientes th:nth-child(2), #tabela-clientes td:nth-child(2),
  #tabela-clientes th:nth-child(3), #tabela-clientes td:nth-child(3),
  #tabela-clientes th:nth-child(8), #tabela-clientes td:nth-child(8) {
    display: none;
  }
  #tabela-clientes th, #tabela-clientes td { padding: 8px 10px; }
}

/* ── Mobile (max 640px) ── */
@media (max-width: 640px) {
  .sidebar {
    width: 100%;
    height: auto;
    position: sticky;
    flex-direction: row;
    overflow-x: auto;
    padding: 0;
  }
  .sidebar-nav { flex-direction: row; display: flex; }
  .sidebar-nav a { padding: 10px 14px; font-size: .82rem; white-space: nowrap; }
  .sidebar-logo { padding: 10px 14px; font-size: 1rem; }
  .sidebar-footer { display: none; }
  .main { margin-left: 0; }
  .page-content { padding: 12px; }
  .topbar { padding: 10px 12px; }
  .form-grid-3 { grid-template-columns: 1fr; }
  .familia-membro { grid-template-columns: 1fr 1fr; }

  /* Tabela clientes mobile — vira card vertical (cada linha = bloco) */
  #tabela-clientes, #tabela-clientes thead, #tabela-clientes tbody,
  #tabela-clientes tr, #tabela-clientes td { display: block; width: 100%; }
  #tabela-clientes thead { display: none; }
  #tabela-clientes tr {
    margin-bottom: 10px;
    border: 1px solid var(--border, #e5e7eb);
    border-radius: 10px;
    padding: 10px 12px;
    background: var(--surface, #fff);
    box-shadow: 0 1px 2px rgba(0,0,0,.04);
  }
  #tabela-clientes td {
    padding: 4px 0;
    border: none;
    text-align: left;
  }
  #tabela-clientes td:first-child { font-size: 1rem; font-weight: 700; margin-bottom: 4px; }
  #tabela-clientes td:last-child {
    display: flex;
    gap: 6px;
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid var(--border-light, #f3f4f6);
  }
  #tabela-clientes td:last-child a { flex: 1; text-align: center; }
}
  .modal { max-height: 95vh; }
  .lotes-grid { grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); }
}

/* === TRIAGEM MCMV (Agente 1) === */
.triagem-card {
  background: var(--surface);
  border-radius: 12px;
  padding: 0;
  margin-bottom: 16px;
  overflow: hidden;
  border-left: 5px solid var(--border);
  box-shadow: 0 1px 3px rgba(0,0,0,.04);
}
.triagem-card[data-cor="verde"] { border-left-color: var(--verde); background: linear-gradient(to right, var(--verde-surface) 0%, var(--surface) 30%); }
.triagem-card[data-cor="amarelo"] { border-left-color: var(--amarelo); background: linear-gradient(to right, var(--amarelo-pale) 0%, var(--surface) 30%); }
.triagem-card[data-cor="vermelho"] { border-left-color: var(--vermelho); background: linear-gradient(to right, var(--vermelho-pale) 0%, var(--surface) 30%); }

.triagem-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border-light);
}
.triagem-titulo {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: .95rem;
  color: var(--text-primary);
}
.triagem-icone { font-size: 1.15rem; }
.triagem-status {
  font-size: .78rem;
  font-weight: 700;
  padding: 5px 12px;
  border-radius: 999px;
  letter-spacing: .3px;
}
.triagem-status.status-verde { background: var(--verde); color: #fff; }
.triagem-status.status-amarelo { background: var(--amarelo); color: #fff; }
.triagem-status.status-vermelho { background: var(--vermelho); color: #fff; }

.triagem-body { padding: 14px 18px 16px; }
.triagem-resumo {
  display: flex;
  gap: 24px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}
.triagem-bloco {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.triagem-label {
  font-size: .72rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: .4px;
}
.triagem-bloco strong { font-size: 1rem; color: var(--text-primary); }
.triagem-nota { font-size: .65rem; color: var(--text-tertiary); font-style: italic; }

.triagem-checks {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 12px;
}
.triagem-check {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: .85rem;
  color: var(--text-primary);
  padding: 2px 0;
}
.triagem-check-icone { flex-shrink: 0; font-size: .95rem; line-height: 1.3; }

/* Grupos categorizados por gravidade */
.triagem-grupo {
  border-left: 3px solid var(--border);
  padding: 8px 12px;
  border-radius: 0 6px 6px 0;
  background: rgba(0,0,0,.02);
}
.triagem-grupo[data-tipo="bloqueador"] { border-left-color: var(--vermelho); background: rgba(220,38,38,.05); }
.triagem-grupo[data-tipo="risco"] { border-left-color: var(--amarelo); background: rgba(217,119,6,.05); }
.triagem-grupo[data-tipo="operacional"] { border-left-color: var(--text-tertiary); background: rgba(107,114,128,.04); }
.triagem-grupo[data-tipo="positivo"] { border-left-color: var(--verde); background: rgba(45,106,79,.04); }

.triagem-grupo-titulo {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: .82rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 6px;
}
.triagem-grupo-contagem {
  background: rgba(0,0,0,.08);
  color: var(--text-secondary);
  font-size: .7rem;
  font-weight: 700;
  padding: 1px 7px;
  border-radius: 999px;
}
.triagem-grupo[data-tipo="bloqueador"] .triagem-grupo-contagem { background: var(--vermelho); color: #fff; }
.triagem-grupo[data-tipo="risco"] .triagem-grupo-contagem { background: var(--amarelo); color: #fff; }
.triagem-grupo[data-tipo="positivo"] .triagem-grupo-contagem { background: var(--verde); color: #fff; }

.triagem-grupo-itens {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 2px 12px;
}

/* Input readonly (auto-calculado) */
.input-readonly {
  background: #f3f4f6 !important;
  color: var(--text-secondary) !important;
  cursor: not-allowed;
  border-color: var(--border-light) !important;
}

/* === AUDITORIA DE DOCUMENTOS (Agente 2) === */
.auditoria-card {
  background: var(--surface);
  border-radius: 12px;
  padding: 0;
  margin-bottom: 16px;
  overflow: hidden;
  border-left: 5px solid var(--azul);
  box-shadow: 0 1px 3px rgba(0,0,0,.04);
}
.auditoria-card[data-completo="true"] {
  border-left-color: var(--verde);
  background: linear-gradient(to right, var(--verde-surface) 0%, var(--surface) 30%);
}

.auditoria-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border-light);
  gap: 12px;
  flex-wrap: wrap;
}
.auditoria-titulo {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: .95rem;
  color: var(--text-primary);
}
.auditoria-icone { font-size: 1.15rem; }

.auditoria-completude {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 200px;
}
.auditoria-progresso {
  flex: 1;
  height: 8px;
  background: var(--border-light);
  border-radius: 999px;
  overflow: hidden;
  min-width: 120px;
}
.auditoria-progresso > div {
  height: 100%;
  background: var(--azul);
  transition: width .3s ease;
}
.auditoria-card[data-completo="true"] .auditoria-progresso > div { background: var(--verde); }
#auditoria-percent { font-weight: 700; font-size: .9rem; color: var(--text-primary); min-width: 36px; text-align: right; }
.auditoria-frac { font-size: .75rem; }

.auditoria-body { padding: 14px 18px 16px; }

#auditoria-checks {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.auditoria-na {
  margin-top: 12px;
  padding: 10px 12px;
  background: rgba(107,114,128,.06);
  border-radius: 8px;
  border-left: 3px solid var(--text-tertiary);
}
.auditoria-na-titulo {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: .82rem;
  font-weight: 600;
  color: var(--text-secondary);
  flex-wrap: wrap;
}
.auditoria-na-lista {
  margin-top: 6px;
  font-size: .82rem;
  color: var(--text-secondary);
}
.auditoria-na-item { padding: 1px 0; }

.auditoria-acoes {
  border-top: 1px solid var(--border-light);
  padding-top: 12px;
  margin-top: 12px;
}

/* Selo "Pasta Pronta para Envio ao Correspondente" — quando 100% */
.auditoria-selo {
  background: linear-gradient(135deg, var(--verde) 0%, var(--verde-light) 100%);
  color: #fff;
  padding: 14px 18px;
  border-radius: 10px;
  font-weight: 700;
  font-size: .95rem;
  text-align: center;
  letter-spacing: .3px;
  box-shadow: 0 2px 8px rgba(45,106,79,.25);
  margin-bottom: 4px;
}

@media (max-width: 600px) {
  .auditoria-header { flex-direction: column; align-items: flex-start; }
  .auditoria-completude { width: 100%; }
}

.triagem-acoes {
  border-top: 1px solid var(--border-light);
  padding-top: 10px;
  margin-top: 4px;
}
.triagem-acoes-titulo {
  font-size: .8rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
}
.triagem-acoes ul {
  margin: 0;
  padding-left: 22px;
  font-size: .85rem;
  color: var(--text-primary);
}
.triagem-acoes li { margin-bottom: 3px; }

@media (max-width: 600px) {
  .triagem-header { flex-direction: column; align-items: flex-start; gap: 8px; }
  .triagem-resumo { gap: 14px; }
  .triagem-checks { grid-template-columns: 1fr; }
}

/* CPF mascarado (LGPD) — clicável pra revelar com audit log */
.cpf-masked {
  cursor: pointer;
  border-bottom: 1px dashed var(--text-tertiary);
  transition: all .15s;
  user-select: none;
}
.cpf-masked:hover {
  border-bottom-color: var(--verde);
  color: var(--verde);
}

/* Pill de Faixa MCMV — diferenciada por faixa */
.pill-faixa {
  display: inline-block;
  font-family: 'Plus Jakarta Sans', system-ui, sans-serif;
  font-size: .72rem;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 999px;
  letter-spacing: .02em;
  white-space: nowrap;
  border: 1px solid transparent;
}
.pill-faixa-sm { font-size: .65rem; padding: 2px 7px; }
.pill-faixa-1 { background: #D1FAE5; color: #065F46; border-color: #A7F3D0; }
.pill-faixa-2 { background: #DBEAFE; color: #1E40AF; border-color: #BFDBFE; }
.pill-faixa-3 { background: #EDE9FE; color: #5B21B6; border-color: #DDD6FE; }

/* Undo Toast — sistema reutilizável (UX05) */
.undo-toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: #1A1D23;
  color: #F3F4F6;
  border-radius: 12px;
  box-shadow: 0 12px 32px rgba(0,0,0,.35), 0 4px 8px rgba(0,0,0,.2);
  z-index: 9999;
  min-width: 320px;
  max-width: 540px;
  font-family: 'Inter', system-ui, sans-serif;
  animation: undoToastIn .25s cubic-bezier(.34,1.56,.64,1);
  overflow: hidden;
}
.undo-toast.undo-toast-out {
  animation: undoToastOut .2s ease forwards;
}
@keyframes undoToastIn {
  from { transform: translate(-50%, 20px); opacity: 0; }
  to { transform: translate(-50%, 0); opacity: 1; }
}
@keyframes undoToastOut {
  to { transform: translate(-50%, 20px); opacity: 0; }
}
.undo-toast-content {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
}
.undo-toast-icon {
  font-size: 16px;
  color: #34D399;
  font-weight: 700;
}
.undo-toast-msg {
  flex: 1;
  font-size: 13.5px;
  font-weight: 500;
  line-height: 1.4;
}
.undo-toast-btn {
  background: transparent;
  color: #34D399;
  border: 1px solid #34D399;
  padding: 6px 14px;
  border-radius: 6px;
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  transition: all .15s;
}
.undo-toast-btn:hover {
  background: #34D399;
  color: #1A1D23;
}
.undo-toast-btn:disabled {
  opacity: .5;
  cursor: wait;
}
.undo-toast-close {
  background: transparent;
  border: none;
  color: #9CA3AF;
  font-size: 20px;
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  cursor: pointer;
  border-radius: 4px;
  padding: 0;
  line-height: 1;
}
.undo-toast-close:hover {
  background: rgba(255,255,255,.08);
  color: #fff;
}
.undo-toast-bar {
  height: 3px;
  background: rgba(255,255,255,.08);
  overflow: hidden;
}
.undo-toast-bar-fill {
  height: 100%;
  background: #34D399;
  transform-origin: left;
}

/* Confirm inline na ficha (Aplicar N/A) */
.confirm-inline {
  margin-top: 12px;
  padding: 14px 16px;
  background: var(--verde-surface);
  border: 1px solid var(--verde-pale);
  border-left: 4px solid var(--verde);
  border-radius: 8px;
  font-size: 13px;
  animation: confirmSlide .2s ease;
}
@keyframes confirmSlide {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: translateY(0); }
}
.confirm-inline-title {
  font-weight: 600;
  color: var(--verde-hover);
  margin-bottom: 8px;
}
.confirm-inline-list {
  list-style: none;
  padding: 0;
  margin: 0 0 12px 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.confirm-inline-list li {
  font-size: 13px;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 6px;
}
.confirm-inline-list li::before {
  content: '○';
  color: var(--verde);
  font-weight: 700;
}
.confirm-inline-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

/* Banner terminal (FUNC03 — família perdida/concluída) */
.banner-terminal {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 18px;
  border-radius: 10px;
  margin-bottom: 16px;
  font-size: 14px;
  border-left: 4px solid;
}
.banner-terminal-perdido {
  background: #FEF2F2;
  border-color: var(--vermelho);
  color: #7F1D1D;
}
.banner-terminal-concluido {
  background: #ECFDF5;
  border-color: var(--verde);
  color: #065F46;
}
.banner-terminal-icon {
  font-size: 24px;
  flex-shrink: 0;
}
.banner-terminal-body { flex: 1; }
.banner-terminal-titulo {
  font-weight: 600;
  margin-bottom: 2px;
}
.banner-terminal-sub {
  font-size: 12.5px;
  opacity: .85;
  line-height: 1.4;
}
.banner-terminal-btn {
  background: white;
  border: 1px solid currentColor;
  color: inherit;
  padding: 8px 14px;
  border-radius: 6px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: all .15s;
}
.banner-terminal-btn:hover {
  background: currentColor;
  color: white;
}

/* Form seção numerada (UX02 — Nova Família) */
.form-secao {
  position: relative;
}
.form-secao .card-header {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.form-secao .card-title {
  display: flex;
  align-items: center;
  gap: 10px;
}
.form-secao-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  background: var(--verde);
  color: white;
  border-radius: 50%;
  font-family: 'Plus Jakarta Sans', system-ui, sans-serif;
  font-size: 13px;
  font-weight: 700;
  flex-shrink: 0;
  letter-spacing: 0;
}
.form-secao-extra .form-secao-num {
  background: var(--text-tertiary);
  opacity: .7;
}

/* Sort por coluna na tabela (P2-05) */
.th-sort {
  cursor: pointer;
  user-select: none;
  transition: background-color .12s;
  position: relative;
}
.th-sort:hover {
  background: var(--verde-surface);
  color: var(--verde-hover);
}
.th-sort-active {
  color: var(--verde);
  font-weight: 700;
}
.sort-ind {
  display: inline-block;
  margin-left: 2px;
  font-family: 'JetBrains Mono', monospace;
  font-size: .85rem;
  color: var(--verde);
  min-width: 12px;
}

/* Footer versionado promovido (P1-DES04) */
.crm-versao {
  color: #9ca3af !important;
  font-size: .8rem !important;
  font-weight: 500;
  margin-top: 6px;
  letter-spacing: .02em;
  opacity: 1 !important;
}
