/* ===== CRM Comercial — estilos base ===== */
:root {
  --azul: #0ea5e9;
  --indigo: #6366f1;
  --verde: #10b981;
}

* { font-family: 'Inter', system-ui, -apple-system, sans-serif; }

body { -webkit-font-smoothing: antialiased; }

/* Navegação por abas */
.nav-tab {
  display: inline-flex;
  align-items: center;
  gap: .45rem;
  white-space: nowrap;
  padding: .7rem 1rem;
  font-size: .82rem;
  font-weight: 600;
  color: #94a3b8;
  border-bottom: 3px solid transparent;
  transition: all .18s ease;
}
.nav-tab:hover { color: #e2e8f0; background: rgba(255,255,255,.04); }
.nav-tab.active { color: #fff; border-bottom-color: var(--azul); }

.no-scrollbar::-webkit-scrollbar { display: none; }
.no-scrollbar { -ms-overflow-style: none; scrollbar-width: none; }

/* Cartões */
.card {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 1rem;
  padding: 1.15rem;
  box-shadow: 0 1px 2px rgba(15,23,42,.04);
}
.card-title {
  display: flex;
  align-items: center;
  gap: .55rem;
  font-size: .95rem;
  font-weight: 700;
  color: #0f172a;
  margin-bottom: 1rem;
}
.rel-num {
  display: inline-grid;
  place-items: center;
  width: 1.55rem; height: 1.55rem;
  border-radius: .5rem;
  background: linear-gradient(135deg, #0ea5e9, #6366f1);
  color: #fff; font-size: .75rem; font-weight: 700;
}

/* KPIs */
.kpi-card {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 1rem;
  padding: 1rem 1.1rem;
  box-shadow: 0 1px 2px rgba(15,23,42,.04);
}
.kpi-label {
  display: flex; align-items: center; gap: .4rem;
  font-size: .72rem; font-weight: 600; text-transform: uppercase;
  letter-spacing: .04em; color: #64748b;
}
.kpi-value { font-size: 1.65rem; font-weight: 800; color: #0f172a; margin-top: .35rem; line-height: 1.1; }
.kpi-hint { font-size: .72rem; color: #94a3b8; margin-top: .2rem; }

.mini-stat {
  background: #f8fafc; border: 1px solid #e2e8f0; border-radius: .75rem;
  padding: .7rem .9rem; display: flex; flex-direction: column;
}
.mini-stat span { font-size: .7rem; text-transform: uppercase; letter-spacing: .04em; color: #64748b; font-weight: 600; }
.mini-stat strong { font-size: 1.1rem; color: #0f172a; margin-top: .15rem; }

/* Formulário */
.form-label { display: block; font-size: .78rem; font-weight: 600; color: #334155; margin-bottom: .3rem; }
.req { color: #ef4444; }
.form-hint { font-size: .68rem; color: #94a3b8; margin-top: .25rem; }
.form-input {
  width: 100%;
  border: 1px solid #cbd5e1;
  border-radius: .6rem;
  padding: .6rem .75rem;
  font-size: .88rem;
  background: #fff;
  color: #0f172a;
  transition: border-color .15s, box-shadow .15s;
}
.form-input:focus {
  outline: none;
  border-color: var(--azul);
  box-shadow: 0 0 0 3px rgba(14,165,233,.15);
}
.form-input.erro { border-color: #ef4444; box-shadow: 0 0 0 3px rgba(239,68,68,.12); }

.filtro-input {
  border: 1px solid #cbd5e1; border-radius: .5rem;
  padding: .4rem .55rem; font-size: .78rem; background: #fff; color: #0f172a;
}

/* Radio cards de conversão */
.radio-card {
  display: flex; align-items: center; justify-content: center; gap: .5rem;
  border: 2px solid #e2e8f0; border-radius: .75rem;
  padding: .75rem .5rem; cursor: pointer;
  font-size: .85rem; font-weight: 600; color: #64748b;
  transition: all .15s ease; user-select: none;
}
.radio-card:hover { border-color: #cbd5e1; background: #f8fafc; }
#radio-card-sim.selecionado { border-color: var(--verde); background: #ecfdf5; color: #047857; }
#radio-card-nao.selecionado { border-color: #94a3b8; background: #f1f5f9; color: #334155; }

/* Botões */
.btn-primary {
  background: var(--azul); color: #fff; font-weight: 600; font-size: .88rem;
  padding: .65rem 1.35rem; border-radius: .6rem; transition: background .15s;
}
.btn-primary:hover { background: #0284c7; }
.btn-primary:disabled { opacity: .6; cursor: not-allowed; }
.btn-ghost {
  background: #f1f5f9; color: #475569; font-weight: 600; font-size: .88rem;
  padding: .65rem 1.2rem; border-radius: .6rem; transition: background .15s;
}
.btn-ghost:hover { background: #e2e8f0; }

.chip {
  font-size: .7rem; font-weight: 600; padding: .25rem .6rem;
  border-radius: 999px; background: #f1f5f9; color: #475569; cursor: pointer;
  border: 1px solid #e2e8f0; transition: all .15s;
}
.chip:hover { background: #e0f2fe; border-color: #7dd3fc; color: #0369a1; }

/* Tabelas */
.data-table { width: 100%; border-collapse: collapse; font-size: .82rem; }
.data-table thead th {
  text-align: left; font-size: .68rem; text-transform: uppercase; letter-spacing: .05em;
  color: #64748b; font-weight: 700; padding: .55rem .6rem;
  border-bottom: 2px solid #e2e8f0; white-space: nowrap;
}
.data-table tbody td { padding: .6rem; border-bottom: 1px solid #f1f5f9; color: #334155; vertical-align: middle; }
.data-table tbody tr:hover { background: #f8fafc; }
.data-table tfoot td { padding: .6rem; font-weight: 700; color: #0f172a; border-top: 2px solid #e2e8f0; }
.data-table .vazio { text-align: center; color: #94a3b8; padding: 2rem 0; font-style: italic; }

.badge { display: inline-block; font-size: .68rem; font-weight: 700; padding: .18rem .55rem; border-radius: 999px; white-space: nowrap; }
.badge-sim { background: #d1fae5; color: #047857; }
.badge-nao { background: #f1f5f9; color: #64748b; }
.badge-origem { background: #e0e7ff; color: #4338ca; }

.acao-btn {
  width: 1.9rem; height: 1.9rem; border-radius: .45rem;
  display: inline-grid; place-items: center; font-size: .75rem; transition: all .15s;
}
.acao-editar { background: #e0f2fe; color: #0369a1; }
.acao-editar:hover { background: #bae6fd; }
.acao-excluir { background: #fee2e2; color: #b91c1c; }
.acao-excluir:hover { background: #fecaca; }

/* Gráficos */
.chart-box { position: relative; height: 300px; width: 100%; }

@media (max-width: 640px) {
  .chart-box { height: 260px; }
  .kpi-value { font-size: 1.35rem; }
  .data-table { font-size: .76rem; }
}

/* ===== Impressão / exportação em PDF dos relatórios ===== */
@media print {
  @page { size: A4 portrait; margin: 12mm 10mm; }

  html, body {
    background: #fff !important;
    font-size: 10pt;
  }

  /* Oculta tudo que não faz parte do relatório */
  #app-header,
  footer,
  #toast,
  #loader,
  #btn-imprimir-relatorios,
  #btn-rel-limpar,
  .app-view:not(#view-relatorios) {
    display: none !important;
  }

  /* Garante que a aba de relatórios apareça mesmo se estiver oculta na tela */
  #view-relatorios { display: block !important; }

  #app-main { max-width: none; padding: 0; margin: 0; }

  /* Cabeçalho que só existe no papel */
  #print-header {
    display: block !important;
    border-bottom: 2px solid #0f172a;
    padding-bottom: 8px;
    margin-bottom: 14px;
  }
  #print-header h1 { font-size: 15pt; font-weight: 800; color: #0f172a; }
  #print-header p { font-size: 9pt; color: #475569; margin-top: 2px; }

  /* Os filtros de data viram texto informativo no cabeçalho impresso */
  #view-relatorios > div:first-of-type { display: none !important; }

  /* Cada relatório em bloco inteiro, sem quebrar no meio */
  .card {
    break-inside: avoid;
    page-break-inside: avoid;
    border: 1px solid #cbd5e1 !important;
    box-shadow: none !important;
    margin-bottom: 10px !important;
    padding: 10px !important;
  }

  /* Relatórios 3 e 5 começam em página nova, evitando cortes feios */
  .print-break {
    break-before: page;
    page-break-before: always;
  }

  .card-title { font-size: 11pt; margin-bottom: 8px; }

  /* Gráficos menores no papel para caber ao lado das tabelas */
  .chart-box { height: 62mm !important; break-inside: avoid; }
  canvas { max-width: 100% !important; }

  /* Mantém tabela e gráfico lado a lado no papel */
  .grid { display: grid !important; }
  .lg\:grid-cols-2 { grid-template-columns: 1fr 1fr !important; }
  .md\:grid-cols-4 { grid-template-columns: repeat(4, 1fr) !important; }
  .sm\:grid-cols-3 { grid-template-columns: repeat(3, 1fr) !important; }

  /* Tabelas legíveis e sem rolagem no papel */
  .overflow-x-auto { overflow: visible !important; }
  .data-table { font-size: 8pt; width: 100% !important; }
  .data-table thead th { font-size: 7pt; padding: 3px 4px; }
  .data-table tbody td { padding: 3px 4px; }
  .data-table thead { display: table-header-group; }
  .data-table tr { break-inside: avoid; page-break-inside: avoid; }

  /* Força as cores dos selos e destaques a saírem na impressão */
  .badge, .rel-num, .mini-stat, .kpi-card {
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
  .rel-num { background: #0f172a !important; color: #fff !important; }
  .badge-sim { background: #d1fae5 !important; color: #047857 !important; }
  .badge-origem { background: #e0e7ff !important; color: #3730a3 !important; }

  #rel-taxa-geral { font-size: 26pt !important; }
}
