/* ============================================================
   PONGUI CRM — Estilos da aplicação
   ============================================================ */

.pongui-crm {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
}

/* =================== TOPBAR =================== */
.crm-topbar {
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 16px 28px;
  background: var(--bg);
  position: sticky;
  top: 0;
  z-index: 30;
}
.crm-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}
.crm-logo {
  height: 26px;
  width: auto;
  display: block;
}
.crm-brand-sub {
  font-family: var(--font-body);
  font-weight: 500;
  font-size: 11px;
  color: var(--text-dim);
  border-left: 1px solid var(--line-strong);
  padding-left: 10px;
  margin-left: 2px;
}

/* Abas Dashboard / Pipeline */
.crm-tabs {
  display: flex;
  gap: 4px;
  background: var(--surface-2);
  padding: 4px;
  border-radius: 10px;
}
.crm-tab {
  font-family: var(--font-title);
  font-weight: 600;
  text-transform: uppercase;
  font-size: 14px;
  color: var(--text-muted);
  background: transparent;
  border: 0;
  padding: 8px 18px;
  border-radius: 7px;
  cursor: pointer;
  transition: all .15s ease;
}
.crm-tab:hover { color: var(--text); }
.crm-tab.is-active {
  background: var(--accent);
  color: var(--offwhite);
}

.crm-topbar-spacer { flex: 1; }

/* Filtros à direita (espelha o print) */
.crm-filters { display: flex; align-items: center; gap: 8px; }
.crm-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--line);
  padding: 8px 14px;
  border-radius: 9px;
  cursor: pointer;
  white-space: nowrap;
}
.crm-chip.is-accent {
  background: var(--accent-soft);
  border-color: rgba(15,91,199,.4);
  color: var(--accent-text);
}
.crm-chip svg { opacity: .8; }

/* Busca contextual (pipeline/fechados/perdidos) */
.crm-search {
  width: 280px; max-width: 32vw;
  font-family: var(--font-body); font-size: 13px; color: var(--text);
  background: var(--surface-2); border: 1px solid var(--line);
  border-radius: 9px; padding: 9px 14px; outline: none;
}
.crm-search::placeholder { color: var(--text-dim); }
.crm-search:focus { border-color: var(--accent); }

/* =================== ÁREA DE CONTEÚDO =================== */
.crm-content { flex: 1; padding: 8px 28px 40px; overflow: auto; }
.crm-view { display: none; }
.crm-view.is-active { display: block; }

/* Cabeçalho de seção */
.crm-page-head { margin: 16px 0 22px; }
.crm-page-head h1 {
  font-family: var(--font-title);
  font-weight: 700;
  text-transform: uppercase;
  font-size: 34px;
  line-height: 1;
  margin: 0 0 4px;
}
.crm-page-head p {
  font-family: var(--font-body);
  font-size: 13px;
  color: var(--text-muted);
  margin: 0;
}

.crm-section-label {
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 13px;
  color: var(--text-muted);
  margin: 28px 0 14px;
}

/* =================== DASHBOARD — cards de status =================== */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 14px;
}
.stat-card {
  background: var(--surface-1);
  border-radius: var(--radius);
  padding: 18px 18px 0;
  position: relative;
  overflow: hidden;
  min-height: 168px;
  display: flex;
  flex-direction: column;
}
.stat-card-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
}
.stat-dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }
.stat-name {
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 12.5px;
  color: var(--text-muted);
}
.stat-num {
  font-family: var(--font-title);
  font-weight: 700;
  font-size: 52px;
  line-height: .9;
  color: var(--text);
}
.stat-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  font-family: var(--font-body);
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 8px;
}
.stat-meta .pct { color: var(--text); font-weight: 600; }
.stat-spark {
  margin: 14px -18px 0;
  height: 56px;
  width: calc(100% + 36px);
  display: block;
}

/* =================== DASHBOARD — performance =================== */
.perf-grid {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 14px;
}
.panel {
  background: var(--surface-1);
  border-radius: var(--radius);
  padding: 20px 22px;
}
.panel h3 {
  font-family: var(--font-title);
  font-weight: 600;
  text-transform: uppercase;
  font-size: 16px;
  margin: 0 0 18px;
  color: var(--text);
}

/* Funil */
.funnel-row {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 12px;
}
.funnel-label {
  font-family: var(--font-body);
  font-size: 12px;
  color: var(--text-muted);
  width: 150px;
  flex-shrink: 0;
}
.funnel-bar-wrap { flex: 1; height: 26px; background: var(--surface-3); border-radius: 6px; overflow: hidden; }
.funnel-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-text));
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding-right: 10px;
  color: var(--offwhite);
  font-family: var(--font-title);
  font-weight: 600;
  font-size: 13px;
  min-width: 34px;
}

/* KPIs grandes */
.kpi-stack { display: flex; flex-direction: column; gap: 16px; }
.kpi {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}
.kpi:last-child { border-bottom: 0; padding-bottom: 0; }
.kpi-label { font-family: var(--font-body); font-size: 13px; color: var(--text-muted); }
.kpi-val { font-family: var(--font-title); font-weight: 700; font-size: 30px; color: var(--text); }
.kpi-val.is-success { color: var(--success); }
.kpi-val.is-danger { color: var(--danger); }

/* =================== PIPELINE — kanban =================== */
.kanban {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  overflow-x: auto;
  padding-bottom: 16px;
}
.kanban-col {
  flex: 0 0 270px;
  width: 270px;
  background: var(--surface-1);
  border-radius: var(--radius);
  padding: 12px 12px 8px;
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 220px);
}
.kanban-col.is-won { background: linear-gradient(180deg, var(--success-soft), var(--surface-1)); }
.kanban-col.is-lost { background: linear-gradient(180deg, var(--danger-soft), var(--surface-1)); }
.kanban-col.drag-over { outline: 2px dashed var(--accent-text); outline-offset: -2px; }
.kanban-col.is-won.drag-over { outline-color: var(--success); }
.kanban-col.is-lost.drag-over { outline-color: var(--danger); }

.col-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 6px 12px;
}
.col-title {
  font-family: var(--font-title);
  font-weight: 600;
  text-transform: uppercase;
  font-size: 13px;
  color: var(--text);
  flex: 1;
  line-height: 1.05;
}
.col-count {
  font-family: var(--font-title);
  font-weight: 600;
  font-size: 12px;
  color: var(--text-muted);
  background: var(--surface-3);
  border-radius: 20px;
  padding: 2px 9px;
}
.col-value {
  font-family: var(--font-body);
  font-size: 11px;
  color: var(--text-dim);
  padding: 0 6px 10px;
}
.col-body { overflow-y: auto; flex: 1; display: flex; flex-direction: column; gap: 8px; padding: 2px; }

/* Card de lead */
.lead-card {
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  padding: 12px;
  cursor: grab;
  transition: background .12s ease, transform .04s ease;
}
.lead-card:hover { background: var(--surface-hover); }
.lead-card:active { cursor: grabbing; }
.lead-card.dragging { opacity: .45; }
.lead-top { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.lead-id { min-width: 0; }

/* Etiquetas no card */
.lead-chips { display: flex; flex-wrap: wrap; gap: 5px; margin-bottom: 9px; }
.lead-chip {
  font-family: var(--font-body); font-weight: 600; font-size: 10px;
  padding: 2px 8px; border-radius: 20px;
  color: var(--c); background: color-mix(in srgb, var(--c) 18%, transparent);
}

/* Toggle de etiquetas no painel de detalhes */
.detail-labels { display: flex; flex-wrap: wrap; gap: 7px; }
.label-toggle {
  font-family: var(--font-body); font-weight: 600; font-size: 12px;
  padding: 5px 11px; border-radius: 20px; cursor: pointer;
  color: var(--text-muted); background: var(--surface-3);
  border: 1px solid transparent; transition: all .12s ease;
}
.label-toggle.is-on { color: var(--c); background: color-mix(in srgb, var(--c) 18%, transparent); border-color: var(--c); }

/* Editor de áreas */
.area-edit-list { display: flex; flex-direction: column; gap: 12px; margin-bottom: 16px; max-height: 46vh; overflow-y: auto; }
.area-edit-row { display: flex; flex-direction: column; gap: 7px; }
.area-edit-head { display: flex; align-items: center; gap: 8px; }
.area-edit-head .stage-name { flex: 1; padding: 9px 11px; }
.area-prods { font-size: 12px; padding: 8px 11px; }

/* Prévia da última mensagem */
.lead-msg {
  font-family: var(--font-body);
  font-size: 11.5px;
  color: var(--text-muted);
  line-height: 1.3;
  margin: 0 0 9px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Etiquetas de área + produto */
.lead-tags { display: flex; flex-wrap: wrap; gap: 5px; margin-bottom: 10px; }
.area-tag {
  font-family: var(--font-body); font-weight: 600; font-size: 10px;
  padding: 2px 8px; border-radius: 5px;
  color: var(--c); background: color-mix(in srgb, var(--c) 16%, transparent);
}
.produto-tag {
  font-family: var(--font-body); font-weight: 500; font-size: 10px;
  padding: 2px 8px; border-radius: 5px;
  color: var(--text-muted); background: var(--surface-3);
}
.lead-origem {
  font-family: var(--font-body); font-size: 10px; color: var(--text-dim);
  flex: 1; text-align: center;
}
.lead-avatar {
  width: 34px; height: 34px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-title); font-weight: 600; font-size: 14px;
  color: var(--offwhite); flex-shrink: 0;
}
.lead-name { font-family: var(--font-body); font-weight: 600; font-size: 13px; color: var(--text); line-height: 1.15; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lead-phone { font-family: var(--font-body); font-size: 11px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lead-foot { display: flex; align-items: center; justify-content: space-between; margin-top: 8px; }
.lead-value { font-family: var(--font-title); font-weight: 600; font-size: 14px; color: var(--accent-text); }
.lead-time { font-family: var(--font-body); font-size: 10px; color: var(--text-dim); }
.lead-tag {
  display: inline-block;
  font-family: var(--font-body); font-size: 10px; font-weight: 600;
  padding: 2px 7px; border-radius: 5px; margin-top: 8px;
}
.lead-tag.lost { background: var(--danger-soft); color: var(--danger); }

/* =================== MODAL (motivo da perda) =================== */
.crm-modal-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,.7);
  display: none; align-items: center; justify-content: center; z-index: 100;
}
.crm-modal-backdrop.is-open { display: flex; }
.crm-modal {
  background: var(--surface-2);
  border-radius: var(--radius-lg);
  padding: 26px;
  width: 380px;
  box-shadow: var(--shadow);
}
.crm-modal h3 {
  font-family: var(--font-title); font-weight: 700; text-transform: uppercase;
  font-size: 20px; margin: 0 0 4px;
}
.crm-modal p { font-family: var(--font-body); font-size: 13px; color: var(--text-muted); margin: 0 0 18px; }
.reason-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 20px; }
.reason-opt {
  display: flex; align-items: center; gap: 10px;
  font-family: var(--font-body); font-size: 14px; color: var(--text);
  background: var(--surface-3); border: 1px solid transparent;
  border-radius: var(--radius-sm); padding: 12px 14px; cursor: pointer;
  transition: all .12s ease;
}
.reason-opt:hover { background: var(--surface-hover); }
.reason-opt.selected { border-color: var(--danger); background: var(--danger-soft); }
.reason-radio { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--text-dim); flex-shrink: 0; }
.reason-opt.selected .reason-radio { border-color: var(--danger); background: var(--danger); box-shadow: inset 0 0 0 3px var(--surface-3); }
.crm-modal-actions { display: flex; gap: 10px; justify-content: flex-end; }
.btn {
  font-family: var(--font-title); font-weight: 600; text-transform: uppercase;
  font-size: 13px; border: 0; border-radius: 9px; padding: 11px 20px; cursor: pointer;
}
.btn-ghost { background: transparent; color: var(--text-muted); }
.btn-ghost:hover { color: var(--text); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:disabled { opacity: .4; cursor: not-allowed; }

/* Foto do lead (WhatsApp) */
.lead-avatar-img {
  width: 34px; height: 34px; border-radius: 50%;
  object-fit: cover; flex-shrink: 0;
}

/* Rodapé simplificado do card colapsado */
.lead-origem-left { font-family: var(--font-body); font-size: 10px; color: var(--text-dim); }

/* =================== POPOVERS DE FILTRO =================== */
.crm-chip { user-select: none; }
.crm-chip.is-open { background: var(--surface-hover); }
.crm-popover {
  position: fixed;
  z-index: 60;
  background: var(--surface-2);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 6px;
  min-width: 220px;
}
.pop-title {
  font-family: var(--font-body); font-weight: 600; font-size: 11px;
  color: var(--text-dim); padding: 8px 10px 6px;
}
.pop-opt {
  display: flex; align-items: center; gap: 10px;
  font-family: var(--font-body); font-size: 13px; color: var(--text);
  padding: 9px 10px; border-radius: 8px; cursor: pointer;
}
.pop-opt:hover { background: var(--surface-hover); }
.pop-opt.is-sel { color: var(--accent-text); }
.pop-check {
  width: 16px; height: 16px; border-radius: 4px;
  border: 1.5px solid var(--text-dim); flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; font-size: 11px; color: #fff;
}
.pop-opt.is-sel .pop-check { background: var(--accent); border-color: var(--accent); }
.pop-radio { width: 14px; height: 14px; border-radius: 50%; border: 1.5px solid var(--text-dim); flex-shrink: 0; }
.pop-opt.is-sel .pop-radio { border-color: var(--accent); background: var(--accent); box-shadow: inset 0 0 0 3px var(--surface-2); }
.pop-divider { height: 1px; background: var(--line); margin: 4px 6px; }

/* =================== TAXAS POR ETAPA =================== */
.rate-row { margin-bottom: 16px; }
.rate-row:last-child { margin-bottom: 0; }
.rate-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 6px; }
.rate-label { font-family: var(--font-body); font-size: 13px; color: var(--text-muted); }
.rate-val { font-family: var(--font-title); font-weight: 700; font-size: 20px; color: var(--text); }
.rate-val small { font-family: var(--font-body); font-weight: 400; font-size: 11px; color: var(--text-dim); margin-left: 6px; }
.rate-bar-wrap { height: 8px; background: var(--surface-3); border-radius: 5px; overflow: hidden; }
.rate-bar { height: 100%; background: var(--accent-text); border-radius: 5px; }

/* =================== INTELIGÊNCIA COMERCIAL =================== */
.intel-kpis { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
.intel-kpi { min-height: auto; padding: 16px 18px; }
.intel-kpi .stat-num { font-size: 30px; margin-top: 8px; }
.intel-table th, .intel-table td { white-space: nowrap; }
.intel-table tbody tr:hover td { background: transparent; }
.intel-total td { font-weight: 700; color: var(--text); border-top: 2px solid var(--line-strong); }
.inv-list { display: flex; flex-direction: column; gap: 4px; margin-bottom: 8px; }
.inv-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.inv-row:last-child { border-bottom: 0; }
.inv-origem { font-family: var(--font-body); font-size: 14px; color: var(--text); }
.inv-input { display: flex; align-items: center; gap: 6px; }
.inv-input span { font-family: var(--font-body); font-size: 13px; color: var(--text-muted); }
.inv-input input {
  width: 120px; text-align: right;
  font-family: var(--font-body); font-size: 14px; color: var(--text);
  background: var(--surface-3); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; outline: none;
}
.inv-input input:focus { border-color: var(--accent); }

/* =================== BREAKDOWN (distribuição) =================== */
.bk-row { display: flex; align-items: center; gap: 12px; margin-bottom: 11px; }
.bk-row:last-child { margin-bottom: 0; }
.bk-label { font-family: var(--font-body); font-size: 12.5px; color: var(--text-muted); width: 160px; flex-shrink: 0; display: flex; align-items: center; gap: 7px; }
.bk-bar-wrap { flex: 1; height: 8px; background: var(--surface-3); border-radius: 5px; overflow: hidden; }
.bk-bar { height: 100%; background: var(--accent-text); border-radius: 5px; }
.bk-count { font-family: var(--font-title); font-weight: 600; font-size: 14px; color: var(--text); width: 28px; text-align: right; }
.bk-empty { font-family: var(--font-body); font-size: 13px; color: var(--text-dim); }

/* =================== PAINEL DE DETALHES DO LEAD =================== */
.detail-modal { width: 460px; max-width: 92vw; }
.detail-head { display: flex; align-items: center; gap: 14px; margin-bottom: 6px; }
.detail-head .lead-avatar, .detail-head .lead-avatar-img { width: 48px; height: 48px; font-size: 18px; }
.detail-head h3 { font-size: 22px; margin: 0; }
.detail-sub { font-family: var(--font-body); font-size: 12px; color: var(--text-muted); }
.detail-stage {
  display: inline-flex; align-items: center; gap: 6px;
  font-family: var(--font-body); font-size: 11px; font-weight: 600;
  padding: 3px 9px; border-radius: 20px; background: var(--surface-3); color: var(--text-muted);
  margin-top: 18px;
}
.detail-msg {
  font-family: var(--font-body); font-size: 13px; color: var(--text); line-height: 1.4;
  background: var(--surface-3); border-radius: var(--radius-sm); padding: 12px 14px; margin: 14px 0 6px;
}
.detail-attr {
  font-family: var(--font-body); font-size: 12.5px; color: var(--accent-text);
  background: var(--accent-soft); border-radius: var(--radius-sm); padding: 9px 12px; margin-top: 6px;
}
.detail-msg-label, .field-label {
  font-family: var(--font-body); font-weight: 600; font-size: 11px; color: var(--text-dim);
  display: block; margin: 16px 0 6px;
}
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.field-input, .field-select, .field-textarea {
  width: 100%;
  font-family: var(--font-body); font-size: 14px; color: var(--text);
  background: var(--surface-3); border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 11px 12px; outline: none;
}
.field-input:focus, .field-select:focus, .field-textarea:focus { border-color: var(--accent); }
.field-select { appearance: none; cursor: pointer; }
.field-textarea { resize: vertical; min-height: 60px; }
.btn-primary { background: var(--accent); color: var(--offwhite); }

/* =================== ZONAS DE SAÍDA (aparecem ao arrastar) =================== */
.drop-zones {
  position: fixed; left: 28px; right: 28px; bottom: 20px;
  display: none; gap: 16px; z-index: 50;
}
.pongui-crm.is-dragging .drop-zones { display: flex; animation: dz-in .18s ease; }
@keyframes dz-in { from { opacity: 0; transform: translateY(24px); } to { opacity: 1; transform: none; } }
.drop-zone {
  flex: 1; height: 88px; border-radius: var(--radius-lg);
  display: flex; align-items: center; justify-content: center; gap: 12px;
  font-family: var(--font-title); font-weight: 600; text-transform: uppercase; font-size: 16px;
  border: 2px dashed; backdrop-filter: blur(6px);
}
.drop-zone .dz-text b { font-weight: 700; }
.drop-zone .dz-icon { font-size: 22px; line-height: 1; }
.drop-zone.won { background: rgba(31,181,115,.16); border-color: var(--success); color: var(--success); }
.drop-zone.lost { background: rgba(229,72,77,.16); border-color: var(--danger); color: var(--danger); }
.drop-zone.drag-over { border-style: solid; filter: brightness(1.25); transform: scale(1.01); }

/* =================== TABELAS (fechados / perdidos) =================== */
.crm-table { width: 100%; border-collapse: collapse; }
.crm-table th {
  font-family: var(--font-body); font-weight: 600; font-size: 11px; color: var(--text-dim);
  text-align: left; padding: 6px 14px 12px;
}
.crm-table td {
  font-family: var(--font-body); font-size: 13px; color: var(--text);
  padding: 13px 14px; border-top: 1px solid var(--line); vertical-align: middle;
}
.crm-table tbody tr { cursor: pointer; transition: background .1s ease; }
.crm-table tbody tr:hover td { background: var(--surface-2); }
.t-lead { display: flex; align-items: center; gap: 10px; }
.t-lead .lead-avatar, .t-lead .lead-avatar-img { width: 30px; height: 30px; font-size: 12px; }
.t-lead b { font-weight: 600; }
.t-value { font-family: var(--font-title); font-weight: 600; font-size: 14px; color: var(--accent-text); }
.t-reason { color: var(--danger); font-weight: 500; }
.empty-state {
  font-family: var(--font-body); font-size: 14px; color: var(--text-muted);
  background: var(--surface-1); border-radius: var(--radius); padding: 40px; text-align: center;
}

/* =================== CALENDÁRIO PERSONALIZADO =================== */
.custom-range { padding: 10px; border-top: 1px solid var(--line); margin-top: 4px; }
.range-row { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.range-row label { font-family: var(--font-body); font-size: 12px; color: var(--text-muted); width: 28px; }
.range-row input[type="date"] {
  flex: 1; color-scheme: dark;
  background: var(--surface-3); border: 1px solid var(--line); border-radius: 8px;
  padding: 8px 10px; color: var(--text); font-family: var(--font-body); font-size: 13px; outline: none;
}
.range-row input[type="date"]:focus { border-color: var(--accent); }
.range-apply { width: 100%; margin-top: 4px; }

/* =================== AUTOMAÇÕES =================== */
.auto-list { display: flex; flex-direction: column; gap: 12px; }
.auto-card { display: flex; gap: 14px; align-items: flex-start; background: var(--surface-1); border-radius: var(--radius); padding: 16px 18px; }
.auto-main { flex: 1; min-width: 0; }
.auto-name { font-family: var(--font-body); font-weight: 700; font-size: 15px; color: var(--text); display: flex; align-items: center; gap: 8px; }
.auto-on { font-family: var(--font-body); font-weight: 600; font-size: 10px; color: var(--success); background: var(--success-soft); padding: 2px 8px; border-radius: 20px; }
.auto-off { font-family: var(--font-body); font-weight: 600; font-size: 10px; color: var(--text-dim); background: var(--surface-3); padding: 2px 8px; border-radius: 20px; }
.auto-meta { font-family: var(--font-body); font-size: 12.5px; color: var(--text-muted); margin: 6px 0; }
.auto-meta b { color: var(--text); }
.auto-msg { font-family: var(--font-body); font-size: 13px; color: var(--text); background: var(--surface-3); border-radius: var(--radius-sm); padding: 9px 12px; }
.auto-actions { display: flex; gap: 6px; flex-shrink: 0; }

/* =================== CONVERSAS (inbox) =================== */
.conv-wrap { display: flex; height: calc(100vh - 210px); min-height: 420px; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: var(--surface-1); }
.conv-list-pane { width: 320px; flex-shrink: 0; border-right: 1px solid var(--line); display: flex; flex-direction: column; }
.conv-filters { padding: 12px; display: flex; flex-direction: column; gap: 8px; border-bottom: 1px solid var(--line); }
.conv-filters .conv-search { width: 100%; max-width: none; }
.conv-list { overflow-y: auto; flex: 1; }
.conv-item { display: flex; align-items: center; gap: 10px; padding: 11px 12px; cursor: pointer; border-bottom: 1px solid var(--line); }
.conv-item:hover { background: var(--surface-2); }
.conv-item.is-active { background: var(--surface-3); }
.conv-item-mid { flex: 1; min-width: 0; }
.conv-item-name { font-family: var(--font-body); font-weight: 600; font-size: 13px; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv-item-prev { font-family: var(--font-body); font-size: 12px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv-item-right { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; flex-shrink: 0; }
.conv-item-time { font-size: 10px; color: var(--text-dim); font-family: var(--font-body); }
.conv-stage-dot { width: 8px; height: 8px; border-radius: 50%; }
.conv-thread-pane { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.conv-empty { display: flex; align-items: center; justify-content: center; height: 100%; color: var(--text-dim); font-family: var(--font-body); font-size: 14px; }
.conv-thread-head { display: flex; align-items: center; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.conv-thread { flex: 1; overflow-y: auto; padding: 18px; display: flex; flex-direction: column; gap: 8px; background: var(--bg); }
.msg { display: flex; }
.msg.out { justify-content: flex-end; }
.msg-bubble { max-width: 72%; padding: 9px 12px; border-radius: 12px; font-family: var(--font-body); font-size: 13px; line-height: 1.35; color: var(--text); }
.msg.in .msg-bubble { background: var(--surface-2); border-bottom-left-radius: 4px; }
.msg.out .msg-bubble { background: var(--accent-soft); border: 1px solid rgba(15, 91, 199, .4); border-bottom-right-radius: 4px; }
.msg-time { display: block; font-size: 9px; color: var(--text-dim); text-align: right; margin-top: 3px; }
.conv-reply { display: flex; gap: 8px; padding: 12px; border-top: 1px solid var(--line); }
.conv-reply-input { flex: 1; font-family: var(--font-body); font-size: 14px; color: var(--text); background: var(--surface-3); border: 1px solid var(--line); border-radius: 10px; padding: 11px 14px; outline: none; }
.conv-reply-input:focus { border-color: var(--accent); }

/* thread compacto dentro do card */
.detail-conv { background: var(--surface-3); border-radius: var(--radius-sm); padding: 8px; }
.detail-thread { max-height: 180px; overflow-y: auto; display: flex; flex-direction: column; gap: 6px; padding: 4px; }
.detail-conv .conv-reply { border-top: 0; padding: 8px 0 0; }
.detail-conv .conv-reply-input { font-size: 13px; padding: 9px 12px; }

/* =================== CHIP + MODAL WHATSAPP =================== */
.wa-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text-dim); display: inline-block; margin-right: 7px; vertical-align: middle; }
.wa-tabs { display: flex; gap: 6px; background: var(--surface-3); padding: 4px; border-radius: 10px; margin-bottom: 16px; }
.wa-ptab {
  flex: 1; border: 0; background: transparent; cursor: pointer; padding: 9px; border-radius: 7px;
  font-family: var(--font-body); font-weight: 600; font-size: 13px; color: var(--text-muted);
}
.wa-ptab.is-active { background: var(--accent); color: var(--offwhite); }
.wa-ptab span { font-weight: 400; font-size: 10px; opacity: .8; }
.wa-help { font-family: var(--font-body); font-size: 12.5px; color: var(--text-muted); line-height: 1.4; margin: 0 0 14px; }
.wa-qr-area { display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 12px 0; min-height: 120px; justify-content: center; }
.wa-qr { width: 220px; height: 220px; border-radius: 10px; background: #fff; padding: 8px; }
.wa-connected { display: flex; align-items: center; gap: 14px; padding: 10px 0; }
.wa-check { width: 44px; height: 44px; border-radius: 50%; background: var(--success-soft); color: var(--success); display: flex; align-items: center; justify-content: center; font-size: 22px; }
.wa-conn-title { font-family: var(--font-body); font-weight: 700; font-size: 16px; color: var(--text); }

/* =================== TELA DE LOGIN =================== */
.login-screen {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: var(--bg); padding: 24px;
}
.login-card {
  width: 380px; max-width: 92vw;
  background: var(--surface-1); border-radius: var(--radius-lg);
  padding: 38px 34px; box-shadow: var(--shadow);
}
.login-logo { height: 30px; display: block; margin-bottom: 26px; }
.login-logo-txt { font-family: var(--font-body); font-weight: 700; font-size: 26px; color: var(--offwhite); margin-bottom: 26px; }
.login-title {
  font-family: var(--font-title); font-weight: 700; text-transform: uppercase;
  font-size: 30px; line-height: 1; color: var(--text); margin: 0 0 6px;
}
.login-sub { font-family: var(--font-body); font-size: 13px; color: var(--text-muted); margin: 0 0 26px; }
.login-form .field-label { margin-top: 14px; }
.login-form .field-label:first-child { margin-top: 0; }
.login-error { color: var(--danger); font-family: var(--font-body); font-size: 13px; min-height: 18px; margin-top: 12px; }
.login-btn { width: 100%; margin-top: 8px; padding: 13px; font-size: 15px; }
.login-btn:disabled { opacity: .6; cursor: wait; }
.login-forgot {
  display: block; width: 100%; margin-top: 14px; padding: 4px;
  background: none; border: 0; cursor: pointer;
  font-family: var(--font-body); font-size: 13px; color: var(--text-muted);
}
.login-forgot:hover { color: var(--text); text-decoration: underline; }

/* =================== EDITOR DE ETAPAS =================== */
.stage-edit-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; max-height: 46vh; overflow-y: auto; }
.stage-edit-row { display: flex; align-items: center; gap: 8px; }
.stage-edit-row .stage-name { flex: 1; padding: 9px 11px; }
.stage-color {
  width: 30px; height: 30px; flex-shrink: 0; padding: 0; border: 1px solid var(--line);
  border-radius: 8px; background: var(--surface-3); cursor: pointer;
}
.stage-color::-webkit-color-swatch-wrapper { padding: 3px; }
.stage-color::-webkit-color-swatch { border: 0; border-radius: 5px; }
.stage-mini {
  width: 30px; height: 30px; flex-shrink: 0; border: 1px solid var(--line);
  background: var(--surface-3); color: var(--text); border-radius: 8px; cursor: pointer;
  font-size: 13px; font-family: var(--font-body);
}
.stage-mini:hover:not(:disabled) { background: var(--surface-hover); }
.stage-mini:disabled { opacity: .3; cursor: not-allowed; }
.stage-mini.danger { color: var(--danger); }
.stage-add-row { display: flex; gap: 8px; }
.stage-add-row .field-input { flex: 1; }

/* Scrollbars discretas */
.col-body::-webkit-scrollbar, .crm-content::-webkit-scrollbar, .kanban::-webkit-scrollbar { width: 8px; height: 8px; }
.col-body::-webkit-scrollbar-thumb, .crm-content::-webkit-scrollbar-thumb, .kanban::-webkit-scrollbar-thumb {
  background: var(--surface-3); border-radius: 8px;
}
