/* ============================================================
   CRM do Cliente — admin/customer-crm.html
   Reaproveita admin.css (cards, modal, badges, table). Adiciona
   componentes específicos do CRM (hero, abas, timeline, notas).
   ============================================================ */

/* Voltar pra users */
.crm-back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.78rem;
  color: #64748b;
  text-decoration: none;
  margin-bottom: 4px;
}
.crm-back-link:hover { color: #800020; }

/* ===== HERO ===== */
.crm-hero {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  padding: 20px 22px;
  background: white;
  border-radius: 12px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
  margin-bottom: 18px;
  flex-wrap: wrap;
}
.crm-hero-left {
  display: flex;
  align-items: center;
  gap: 16px;
  flex: 1;
  min-width: 0;
}
.crm-avatar {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: linear-gradient(135deg, #800020, #B07B7E);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  font-weight: 600;
  flex-shrink: 0;
}
.crm-hero-info { flex: 1; min-width: 0; }
.crm-hero-name {
  font-size: 1.4rem;
  font-weight: 600;
  color: #1e293b;
  /* font-family default do admin (Inter) — Oranienbaum estava destoando */
}
.crm-hero-meta {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  font-size: 0.85rem;
  color: #64748b;
  margin-top: 4px;
}
.crm-hero-meta i { color: #94a3b8; margin-right: 4px; }
.crm-hero-tags {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 10px;
}
.crm-tag {
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 0.7rem;
  background: #f1f5f9;
  color: #475569;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  font-weight: 600;
}
.crm-status-pill {
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 0.72rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.crm-status-ok { background: #dcfce7; color: #166534; }
.crm-status-warning { background: #fef3c7; color: #92400e; }
.crm-status-transfer { background: #fee2e2; color: #991b1b; }

.crm-hero-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

/* ===== ABAS ===== */
.crm-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 16px;
  border-bottom: 2px solid #f1f5f9;
  flex-wrap: wrap;
}
.crm-tab-btn {
  padding: 10px 14px;
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: 0.88rem;
  color: #64748b;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 500;
}
.crm-tab-btn:hover { color: #800020; }
.crm-tab-btn.active {
  color: #800020;
  border-bottom-color: #800020;
  font-weight: 600;
}
.crm-tab-btn .tab-count {
  background: #f1f5f9;
  color: #64748b;
  padding: 1px 8px;
  border-radius: 10px;
  font-size: 0.7rem;
  font-weight: 600;
  min-width: 18px;
  display: inline-block;
  text-align: center;
}
.crm-tab-btn.active .tab-count { background: #800020; color: white; }
/* Quando count=0, o JS deixa textContent vazio. Esconder o chip pra não
   parecer um traço solto ao lado do nome da aba. */
.crm-tab-btn .tab-count:empty { display: none; }
.crm-tab-content { display: none; }
.crm-tab-content.active { display: block; }

/* ===== Card padrão de seção ===== */
.crm-card {
  background: white;
  border-radius: 10px;
  padding: 18px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
  margin-bottom: 14px;
}
.crm-card h3 {
  font-size: 0.95rem;
  color: #800020;
  margin: 0 0 14px 0;
  display: flex;
  align-items: center;
  gap: 8px;
}
.crm-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid #f1f5f9;
  flex-wrap: wrap;
}
.crm-card-header h3 { margin: 0; }
.crm-card-header small { color: #64748b; font-size: 0.78rem; }

/* ===== RESUMO: KPIs + timeline ===== */
.crm-resumo-grid {
  display: grid;
  grid-template-columns: 1fr 1.2fr;
  gap: 16px;
  margin-bottom: 16px;
}
@media (max-width: 1100px) { .crm-resumo-grid { grid-template-columns: 1fr; } }

/* Linha do resumo abaixo dos charts: 2 cards lado a lado (Tarefas +
   Inteligência de Mercado). Origem Prospect, quando presente, ocupa toda a
   largura via .crm-card-wide. */
.crm-resumo-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
@media (max-width: 900px) { .crm-resumo-grid-2 { grid-template-columns: 1fr; } }

/* === Top produtos === */
.crm-produtos-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 320px;
  min-height: 220px;
  overflow-y: auto;
  padding-right: 4px;
}
/* Quando o container só tem o empty-state, centraliza vertical/horizontal */
.crm-produtos-list:has(> .empty-state),
.crm-im-list:has(> .empty-state),
.crm-prospect-content:has(> .empty-state),
.crm-proximos-list:has(> .empty-state) {
  justify-content: center;
  align-items: center;
}
.crm-produtos-list .empty-state,
.crm-im-list .empty-state,
.crm-prospect-content .empty-state,
.crm-proximos-list .empty-state {
  margin: auto 0;
}
.crm-produto-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
  padding: 8px 10px;
  background: #fafafa;
  border-radius: 7px;
  border-left: 3px solid #800020;
}
.crm-produto-info { flex: 1; min-width: 0; }
.crm-produto-nome {
  font-weight: 600;
  color: #1e293b;
  font-size: 0.88rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.crm-produto-meta { font-size: 0.75rem; color: #64748b; margin-top: 2px; }
.crm-produto-receita {
  font-weight: 700;
  color: #800020;
  font-size: 0.92rem;
  white-space: nowrap;
  flex-shrink: 0;
}

/* === Tarefas === */
.crm-proximos-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 320px;
  min-height: 180px;
  overflow-y: auto;
  padding-right: 4px;
}
.crm-tasks-header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}
.crm-tasks-filter {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.78rem;
  color: #64748b;
  cursor: pointer;
  user-select: none;
}
.crm-tasks-filter input { cursor: pointer; }

/* Input de adicionar nova task */
.crm-tasks-add {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}
.crm-tasks-add input {
  flex: 1;
  padding: 8px 12px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 0.88rem;
  font-family: inherit;
}
.crm-tasks-add input:focus {
  outline: none;
  border-color: #800020;
  box-shadow: 0 0 0 3px rgba(128, 0, 32, 0.08);
}

/* Linha de task */
.crm-task-row {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 8px 10px;
  background: #fafafa;
  border-radius: 7px;
  border-left: 3px solid #15803d;
  transition: opacity 0.15s;
}
.crm-task-row.is-concluded {
  border-left-color: #94a3b8;
  background: #f1f5f9;
  opacity: 0.78;
}
.crm-task-check {
  width: 18px;
  height: 18px;
  margin-top: 2px;
  cursor: pointer;
  accent-color: #800020;
  flex-shrink: 0;
}
.crm-task-body { flex: 1; min-width: 0; }
.crm-task-text {
  font-size: 0.86rem;
  color: #1e293b;
  line-height: 1.4;
}
.crm-task-row.is-concluded .crm-task-text {
  text-decoration: line-through;
  color: #64748b;
}
.crm-task-meta {
  font-size: 0.72rem;
  color: #64748b;
  margin-top: 3px;
  display: flex;
  flex-wrap: wrap;
  gap: 4px 10px;
  align-items: center;
}
.crm-task-meta i { margin-right: 2px; }
.crm-task-actions {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}
.btn-icon-mini {
  width: 26px;
  height: 26px;
  border: none;
  background: transparent;
  border-radius: 4px;
  color: #64748b;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.78rem;
  transition: background 0.12s, color 0.12s;
}
.btn-icon-mini:hover { background: rgba(128, 0, 32, 0.08); color: #800020; }
.btn-icon-danger:hover { background: rgba(220, 38, 38, 0.1); color: #dc2626; }

/* Badge de quem concluiu (manual / ai / superseded) */
.crm-task-done-badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 0.68rem;
  font-weight: 600;
}
.crm-task-done-manual { background: #dcfce7; color: #166534; }
.crm-task-done-ai     { background: #dbeafe; color: #1e40af; }
.crm-task-done-super  { background: #fef3c7; color: #92400e; }

/* Divisor entre pendentes e concluídas */
.crm-tasks-divider {
  font-size: 0.72rem;
  color: #94a3b8;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 600;
  padding: 8px 0 4px;
  border-top: 1px solid #e2e8f0;
  margin-top: 4px;
}

/* === Inteligência de Mercado === */
.crm-im-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 320px;
  min-height: 220px;
  overflow-y: auto;
  padding-right: 4px;
}
.crm-im-row {
  padding: 10px 12px;
  background: #fafafa;
  border-radius: 7px;
  border-left: 3px solid #f59e0b;
}
.crm-im-head {
  display: flex;
  justify-content: space-between;
  font-size: 0.72rem;
  color: #64748b;
  margin-bottom: 4px;
}
.crm-im-tipo {
  text-transform: uppercase;
  letter-spacing: 0.3px;
  font-weight: 600;
  color: #b45309;
}
.crm-im-text {
  font-size: 0.85rem;
  color: #1e293b;
  line-height: 1.4;
}
.crm-im-extra {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 12px;
  margin-top: 6px;
  font-size: 0.75rem;
  color: #64748b;
}
.crm-im-extra span { display: inline-flex; align-items: center; gap: 4px; }

/* === Origem Prospect === */
.crm-prospect-content {
  font-size: 0.85rem;
  color: #1e293b;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 320px;
  min-height: 220px;
  overflow-y: auto;
  padding-right: 4px;
}
.crm-prospect-row {
  padding: 6px 0;
  border-bottom: 1px solid #f1f5f9;
  line-height: 1.4;
}
.crm-prospect-row:last-child { border-bottom: 0; }
.crm-prospect-row strong {
  color: #475569;
  font-weight: 600;
  margin-right: 6px;
}
.crm-prospect-row a { color: #800020; text-decoration: none; }
.crm-prospect-row a:hover { text-decoration: underline; }
.crm-prospect-obs {
  background: #fef9c3;
  border-radius: 6px;
  padding: 8px 10px;
  font-size: 0.82rem;
  color: #713f12;
  white-space: pre-wrap;
}
.crm-prospect-ai {
  background: linear-gradient(135deg, #f5e6d3 0%, #faf3e8 100%);
  border-radius: 8px;
  padding: 10px 12px;
  margin-top: 4px;
}
.crm-prospect-ai-head {
  font-size: 0.78rem;
  font-weight: 600;
  color: #800020;
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.crm-prospect-ai-body {
  font-size: 0.82rem;
  color: #1e293b;
  line-height: 1.4;
}
.crm-prospect-foot {
  font-size: 0.72rem;
  color: #94a3b8;
  text-align: right;
  margin-top: 4px;
  font-style: italic;
}

/* === Aba ANÁLISE — dossiê de inteligência === */
.crm-analise-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: linear-gradient(135deg, #800020 0%, #b07b7e 100%);
  color: white;
  padding: 18px 22px;
  border-radius: 10px;
  margin-bottom: 16px;
  flex-wrap: wrap;
  gap: 12px;
}
.crm-analise-title {
  margin: 0 0 4px 0;
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: 0.4px;
  color: white;
}
.crm-analise-meta {
  margin: 0;
  font-size: 0.78rem;
  color: rgba(255,255,255,0.92);
}
.crm-analise-header .btn {
  background: rgba(255,255,255,0.15);
  color: white;
  border: 1px solid rgba(255,255,255,0.35);
}
.crm-analise-header .btn:hover { background: rgba(255,255,255,0.25); }

.ana-section {
  background: white;
  border-radius: 10px;
  padding: 18px 20px;
  margin-bottom: 14px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}
.ana-section-title {
  margin: 0 0 14px 0;
  font-size: 1rem;
  color: #800020;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  border-bottom: 2px solid #f1f5f9;
  padding-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.ana-block {
  background: #fafafa;
  border-left: 3px solid #800020;
  border-radius: 8px;
  padding: 12px 14px;
  margin-bottom: 10px;
}
.ana-block-danger { border-left-color: #dc2626; background: #fef2f2; }
.ana-block-success { border-left-color: #15803d; background: #f0fdf4; }
.ana-block-title {
  font-size: 0.82rem;
  font-weight: 700;
  color: #475569;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.ana-block p { margin: 6px 0; color: #1e293b; font-size: 0.88rem; line-height: 1.5; }
.ana-block ul, .ana-block ol { margin: 6px 0 0 0; padding-left: 22px; color: #1e293b; font-size: 0.88rem; line-height: 1.6; }
.ana-block small { font-size: 0.72rem; text-transform: uppercase; color: #64748b; letter-spacing: 0.4px; font-weight: 600; display: block; margin-top: 6px; }
.ana-row {
  background: white;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  padding: 10px 12px;
  margin-top: 8px;
}
.ana-row:first-of-type { margin-top: 0; }
.ana-row-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
  flex-wrap: wrap;
}
.ana-tag {
  background: #f1f5f9;
  color: #475569;
  padding: 2px 10px;
  border-radius: 12px;
  font-size: 0.72rem;
  font-weight: 600;
}
.ana-grid-2 {
  display: grid;
  grid-template-columns: 1fr 2fr;
  gap: 12px;
  margin: 8px 0;
}
@media (max-width: 600px) { .ana-grid-2 { grid-template-columns: 1fr; } }
.ana-grid-2 > div {
  background: white;
  padding: 8px 12px;
  border-radius: 6px;
  border: 1px solid #e2e8f0;
}
.ana-grid-2 small { display: block; font-size: 0.7rem; color: #64748b; text-transform: uppercase; }
.ana-grid-2 strong { font-size: 0.95rem; color: #1e293b; display: block; margin-top: 2px; }
.ana-score { font-size: 0.95rem; color: #800020; margin-bottom: 6px; }

/* Modal pequeno (alterar vendedor) — admin.css não define .modal-sm pro
   .modal-dialog, então herda o padrão 800px e fica largo demais. */
.modal-dialog.modal-sm {
  max-width: 480px;
  width: 90%;
}
.modal-dialog.modal-sm .modal-content {
  max-width: none;
  width: 100%;
}

/* === Classes utilitárias (substituem inline styles) === */
.crm-note-select { max-width: 180px; }
.crm-label-meta { color: #94a3b8; }
.crm-form-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 4px;
}
.crm-subtitle-badge { margin-left: 8px; }
.crm-modal-info {
  margin: 0 0 14px 0;
  font-size: 0.9rem;
  color: #475569;
}
.crm-modal-info strong { color: #800020; }

/* Preview do texto da tarefa no modal de exclusão */
.crm-task-delete-preview {
  background: #fef2f2;
  border-left: 3px solid #dc2626;
  padding: 10px 14px;
  margin: 0;
  font-size: 0.9rem;
  color: #1e293b;
  border-radius: 6px;
  font-style: italic;
}

.crm-kpi-list {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.crm-kpi {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: #fafafa;
  border-radius: 8px;
  border-left: 3px solid #800020;
}
.crm-kpi-icon {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: rgba(128, 0, 32, 0.08);
  color: #800020;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.88rem;
  flex-shrink: 0;
}
.crm-kpi-body { min-width: 0; flex: 1; }
.crm-kpi-label {
  font-size: 0.7rem;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.crm-kpi-value {
  font-size: 1.05rem;
  font-weight: 600;
  color: #1e293b;
  margin-top: 2px;
}

/* Timeline — altura compacta pra alinhar com o card de Indicadores ao lado.
   Os 8 KPIs em 2 colunas dão ~280px. Match aqui evita espaço vazio. */
.crm-timeline {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 280px;
  min-height: 280px;
  overflow-y: auto;
  padding-right: 4px;
}

/* Grid de charts (faturamento + evolução produtos) */
.crm-charts-grid {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 16px;
  margin-bottom: 16px;
}
@media (max-width: 1100px) { .crm-charts-grid { grid-template-columns: 1fr; } }
.crm-chart-container {
  position: relative;
  height: 240px;
  margin-top: 8px;
}
.crm-timeline-row {
  display: flex;
  gap: 10px;
  padding: 8px 10px;
  background: #fafafa;
  border-radius: 7px;
  border-left: 3px solid #cbd5e1;
}
.crm-timeline-pedido { border-left-color: #800020; }
.crm-timeline-feedback { border-left-color: #0277BD; }
.crm-timeline-nota { border-left-color: #d4a017; }
.crm-timeline-contrato { border-left-color: #15803d; }

.crm-timeline-icon {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.78rem;
  color: #64748b;
  flex-shrink: 0;
}
.crm-timeline-pedido .crm-timeline-icon { color: #800020; }
.crm-timeline-feedback .crm-timeline-icon { color: #0277BD; }
.crm-timeline-nota .crm-timeline-icon { color: #d4a017; }
.crm-timeline-contrato .crm-timeline-icon { color: #15803d; }

.crm-timeline-body { flex: 1; min-width: 0; }
.crm-timeline-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
}
.crm-timeline-title {
  font-weight: 600;
  font-size: 0.85rem;
  color: #1e293b;
}
.crm-timeline-date {
  font-size: 0.72rem;
  color: #94a3b8;
  white-space: nowrap;
}
.crm-timeline-meta {
  font-size: 0.78rem;
  color: #64748b;
  margin-top: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ===== FEEDBACKS ===== */
.crm-feedback-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.crm-feedback-card {
  padding: 12px 14px;
  background: #fafafa;
  border-radius: 8px;
  border-left: 3px solid #0277BD;
}
.crm-feedback-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
  flex-wrap: wrap;
  gap: 6px;
}
.crm-feedback-tipo {
  display: flex;
  align-items: center;
  gap: 6px;
  color: #0277BD;
  font-size: 0.85rem;
}
.crm-feedback-meta {
  font-size: 0.75rem;
  color: #64748b;
  display: flex;
  gap: 6px;
}
.crm-feedback-resumo {
  font-size: 0.85rem;
  color: #1e293b;
  margin: 6px 0;
  line-height: 1.4;
}
.crm-rec-tag {
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 0.78rem;
  margin-top: 6px;
  display: flex;
  align-items: flex-start;
  gap: 6px;
}
.crm-rec-tag.rec-bad { background: #fef2f2; color: #991b1b; border-left: 3px solid #dc2626; }
.crm-rec-tag.rec-good { background: #f0fdf4; color: #166534; border-left: 3px solid #16a34a; }

/* ===== RECLAMAÇÕES & ELOGIOS ===== */
.crm-rec-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
@media (max-width: 1000px) { .crm-rec-grid { grid-template-columns: 1fr; } }

.crm-rec-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 540px;
  overflow-y: auto;
}
.crm-rec-item {
  padding: 10px 12px;
  background: #fef2f2;
  border-radius: 8px;
  border-left: 3px solid #dc2626;
}
.crm-rec-item.rec-good-bg {
  background: #f0fdf4;
  border-left-color: #16a34a;
}
.crm-rec-text {
  font-size: 0.85rem;
  color: #1e293b;
  line-height: 1.4;
}
.crm-rec-foot {
  font-size: 0.72rem;
  color: #64748b;
  margin-top: 6px;
  display: flex;
  gap: 6px;
}

/* ===== NOTAS ===== */
.crm-note-form {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  padding: 12px;
  background: #fafafa;
  border-radius: 8px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.crm-note-form select { padding: 10px 12px; border: 1px solid #d1d5db; border-radius: 6px; font-size: 0.9rem; font-family: inherit; }
.crm-note-form textarea {
  width: 100%;
  min-height: 80px;
  padding: 10px 12px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-family: inherit;
  font-size: 0.9rem;
  line-height: 1.5;
  resize: vertical;
  box-sizing: border-box;
}
/* Layout do form de notas: linha "categoria | label", textarea full-width abaixo,
   botão alinhado à direita. Substitui o flex bagunçado de antes. */
.crm-note-form { flex-direction: column; gap: 10px; align-items: stretch; }
.crm-note-form-row {
  display: flex;
  align-items: center;
  gap: 10px;
}
.crm-note-form-label {
  font-size: 0.78rem;
  font-weight: 600;
  color: #475569;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.crm-note-form .crm-note-select {
  width: 220px;
  max-width: 100%;
  padding: 8px 12px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 0.88rem;
  font-family: inherit;
  background: white;
}
.crm-note-form-actions {
  display: flex;
  justify-content: flex-end;
}

.crm-notes-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.crm-note-card {
  padding: 12px 14px;
  background: #fafafa;
  border-radius: 8px;
  border-left: 3px solid #cbd5e1;
}
.crm-note-cat-comercial { border-left-color: #800020; }
.crm-note-cat-logistica { border-left-color: #0277BD; }
.crm-note-cat-financeiro { border-left-color: #15803d; }
.crm-note-cat-reclamacao { border-left-color: #dc2626; }
.crm-note-cat-oportunidade { border-left-color: #d4a017; }

.crm-note-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}
.crm-note-cat {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  font-weight: 600;
  color: #64748b;
}
.crm-note-text {
  font-size: 0.88rem;
  color: #1e293b;
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.45;
}
.crm-note-foot {
  font-size: 0.72rem;
  color: #94a3b8;
  margin-top: 8px;
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.crm-note-actions { display: flex; gap: 4px; }

/* ===== CONTRATOS ===== */
.crm-contracts-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.crm-contract-card {
  padding: 14px 16px;
  background: #fafafa;
  border-radius: 8px;
  border-left: 3px solid #15803d;
}
.crm-contract-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  flex-wrap: wrap;
}
.crm-contract-name {
  font-size: 0.95rem;
  font-weight: 600;
  color: #1e293b;
  display: flex;
  align-items: center;
  gap: 8px;
}
.crm-contract-name i { color: #800020; } /* ícone PDF em bordô (era vermelho danger por engano) */
.crm-contract-meta {
  font-size: 0.78rem;
  color: #64748b;
  margin-top: 4px;
}
.crm-contract-obs {
  font-size: 0.8rem;
  color: #475569;
  margin-top: 8px;
  font-style: italic;
}
.crm-contract-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.72rem;
  color: #94a3b8;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed #e5e7eb;
  flex-wrap: wrap;
  gap: 8px;
}
.crm-contract-actions { display: flex; gap: 6px; }

/* ===== CADASTRO ===== */
.crm-cadastro-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
@media (max-width: 1000px) { .crm-cadastro-grid { grid-template-columns: 1fr; } }
/* Card "wide" ocupa toda a largura (endereço, dados internos, conta SaaS) */
.crm-card-wide { grid-column: 1 / -1; }
.crm-card-saas { grid-column: 1 / -1; }

/* Badge "Sync Bling" no header — nuvem azul, indica que campo é 2-way */
.crm-bling-badge {
  display: inline-flex !important;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  background: #e0f2fe;
  color: #075985;
  border: 1px solid #bae6fd;
  border-radius: 10px;
  font-size: 0.7rem;
  font-weight: 600;
}

/* Form grids dentro dos cards de Cadastro */
.crm-form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px 16px;
  margin-bottom: 12px;
}
@media (max-width: 700px) { .crm-form-grid { grid-template-columns: 1fr; } }

/* Layout específico do endereço (CEP curto, complemento médio, UF mini, etc.) */
.crm-form-grid-address {
  grid-template-columns: 130px 1fr 100px 200px;
}
.crm-fs-bairro { grid-column: 1 / 2; }
.crm-fs-municipio { grid-column: 2 / 4; }
.crm-fs-uf { grid-column: 4 / 5; }
@media (max-width: 900px) {
  .crm-form-grid-address { grid-template-columns: 1fr 1fr; }
  .crm-fs-bairro, .crm-fs-municipio, .crm-fs-uf { grid-column: auto; }
}
@media (max-width: 600px) {
  .crm-form-grid-address { grid-template-columns: 1fr; }
}

.crm-data-list {
  display: grid;
  grid-template-columns: minmax(180px, max-content) 1fr;
  gap: 10px 18px;
  margin: 0;
  align-items: baseline;
}
.crm-data-list dt {
  font-size: 0.78rem;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  font-weight: 600;
  white-space: nowrap;
}
.crm-data-list dd {
  margin: 0;
  font-size: 0.9rem;
  color: #1e293b;
}

.crm-form-section { margin-bottom: 14px; }
.crm-form-section label,
.crm-form-row label {
  display: block;
  font-size: 0.78rem;
  color: #64748b;
  margin-bottom: 4px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.crm-form-section input,
.crm-form-section textarea,
.crm-form-row input,
.crm-form-row textarea,
.crm-form-row select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 0.9rem;
  font-family: inherit;
  box-sizing: border-box;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.crm-form-section input:focus,
.crm-form-section textarea:focus,
.crm-form-row input:focus,
.crm-form-row textarea:focus,
.crm-form-row select:focus {
  outline: none;
  border-color: #800020;
  box-shadow: 0 0 0 3px rgba(128, 0, 32, 0.08);
}
.crm-form-section textarea,
.crm-form-row textarea {
  resize: vertical;
  min-height: 64px;
  line-height: 1.5;
}
.crm-form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 14px;
}
@media (max-width: 700px) { .crm-form-row { grid-template-columns: 1fr; } }

/* ===== Botões mini ===== */
.btn-icon-mini {
  width: 28px;
  height: 28px;
  padding: 0;
  border-radius: 5px;
  border: 1px solid #e5e7eb;
  background: white;
  color: #64748b;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.78rem;
  transition: all 0.15s;
  text-decoration: none;
}
.btn-icon-mini:hover { border-color: #800020; color: #800020; }
.btn-icon-danger:hover { border-color: #dc2626; color: #dc2626; }

/* === Toggle "Atendimento Digital" + ações no card Dados Internos === */
.crm-toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 12px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  cursor: pointer;
}
.crm-toggle-label { display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 0; }
.crm-toggle-label strong { font-size: 0.92rem; color: #1e293b; }
.crm-toggle-label small { font-size: 0.75rem; color: #64748b; line-height: 1.35; }

.crm-form-actions { gap: 8px; }

/* Histórico de resets — timeline compacta abaixo do botão */
.crm-historico-resets {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px dashed #e2e8f0;
}
.crm-historico-resets > small { display: block; margin-bottom: 6px; }
.reset-history-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 8px 10px;
  background: #f8fafc;
  border-radius: 6px;
  margin-bottom: 6px;
  font-size: 0.8rem;
}
.reset-history-meta { color: #64748b; font-size: 0.72rem; }
.reset-history-tipos {
  display: inline-flex; gap: 4px; flex-wrap: wrap;
}
.reset-history-tipos span {
  background: #e0e7ff;
  color: #3730a3;
  padding: 1px 7px;
  border-radius: 8px;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.reset-history-motivo { color: #475569; font-style: italic; }

/* === Modal Reset Prazos (estrutura própria pra ter checkbox list) === */
.crm-modal {
  position: fixed;
  inset: 0;
  z-index: 99999;
  display: flex;
  align-items: center;
  justify-content: center;
}
.crm-modal-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.45);
}
.crm-modal-dialog {
  position: relative;
  background: white;
  border-radius: 12px;
  max-width: 480px;
  width: 90%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 12px 40px rgba(0,0,0,0.25);
}
.crm-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid #e2e8f0;
}
.crm-modal-header h3 { margin: 0; color: var(--marsala); font-size: 1.05rem; }
.crm-modal-close {
  background: transparent; border: none; cursor: pointer; color: #64748b;
  font-size: 1rem; padding: 4px 8px; border-radius: 4px;
}
.crm-modal-close:hover { background: #f1f5f9; color: #1e293b; }
.crm-modal-body { padding: 16px 20px; }
.crm-modal-help { font-size: 0.85rem; color: #64748b; margin: 0 0 14px 0; }
.crm-modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 20px;
  border-top: 1px solid #e2e8f0;
  background: #f8fafc;
  border-radius: 0 0 12px 12px;
}

.reset-checkbox-list { display: flex; flex-direction: column; gap: 8px; }
.reset-checkbox-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.15s;
}
.reset-checkbox-item:hover { background: #f8fafc; border-color: #cbd5e1; }
.reset-checkbox-item input[type="checkbox"] { width: 18px; height: 18px; cursor: pointer; flex-shrink: 0; }
.reset-checkbox-item span { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.reset-checkbox-item strong { font-size: 0.9rem; color: #1e293b; }
.reset-checkbox-item small { font-size: 0.75rem; color: #64748b; }
.reset-checkbox-item.disabled { opacity: 0.5; cursor: not-allowed; background: #f1f5f9; }
.reset-checkbox-item.disabled input { pointer-events: none; }
