* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: #f3f4f6;
  color: #111827;
  display: flex;
  flex-direction: column;
  height: 100vh;
}

/* A barra de abas rola sozinha quando não cabe — antes, entre ~770px e ~1400px,
   as 12 abas ficavam mais largas que a janela e empurravam a página inteira pro lado. */
.top-nav {
  display: flex; align-items: center; gap: 4px; padding: 0 16px;
  height: 52px; flex: 0 0 auto; background: #111827; color: #fff;
  overflow-x: auto; overflow-y: hidden; scrollbar-width: thin;
}
.top-nav .brand { font-weight: 700; margin-right: 24px; flex-shrink: 0; white-space: nowrap; }
.nav-btn {
  background: none; border: none; color: #d1d5db; padding: 8px 14px;
  border-radius: 8px; cursor: pointer; font-size: 14px; flex-shrink: 0; white-space: nowrap;
}
.nav-btn:hover { background: rgba(255,255,255,0.08); }
.nav-btn.active { background: #2563eb; color: #fff; }
.nav-badge {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 16px; height: 16px; padding: 0 4px; margin-left: 4px;
  border-radius: 999px; background: #ef4444; color: #fff; font-size: 10px; font-weight: 700;
}

.view { flex: 1; min-height: 0; overflow: auto; }

#app { display: flex; height: 100%; }

.sidebar {
  width: 320px;
  border-right: 1px solid #e5e7eb;
  background: #fff;
  display: flex;
  flex-direction: column;
}
.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px;
  border-bottom: 1px solid #e5e7eb;
}
.sidebar-header h1 { font-size: 18px; margin: 0; }
.sidebar-header button {
  border: none; background: none; font-size: 18px; cursor: pointer;
}

.sidebar-header-actions { display: flex; align-items: center; gap: 8px; }
#newContactBtn {
  border: 1px solid #2563eb; background: #eff6ff; color: #2563eb; border-radius: 8px;
  padding: 6px 10px; font-size: 12px; font-weight: 700; cursor: pointer;
}
#newContactBtn:hover { background: #dbeafe; }

.search-bar { padding: 10px 12px; border-bottom: 1px solid #e5e7eb; }
.search-bar input {
  width: 100%; padding: 8px 10px; border: 1px solid #d1d5db; border-radius: 8px; font-size: 13px; font-family: inherit;
}

.quick-filter-bar {
  display: flex; gap: 6px; flex-wrap: wrap; align-items: center;
  padding: 0 12px 10px;
}
.quick-filter-chip {
  font-size: 12px; font-weight: 600; padding: 5px 12px; border-radius: 999px;
  border: 1px solid #d1d5db; background: #fff; color: #374151; cursor: pointer;
}
.quick-filter-chip:hover { background: #f3f4f6; }
.quick-filter-chip.active { background: #2563eb; border-color: #2563eb; color: #fff; }

.tag-filter-bar {
  display: flex; gap: 6px; flex-wrap: wrap; align-items: center;
  padding: 10px 16px; border-bottom: 1px solid #e5e7eb; background: #fafafa;
}
.tag-filter-clear {
  font-size: 11px; padding: 2px 8px; border-radius: 999px; border: 1px solid #d1d5db;
  background: #fff; color: #6b7280; cursor: pointer;
}
.tag-filter-clear:hover { background: #f3f4f6; }

.conversation-list { overflow-y: auto; flex: 1; }
.conversation-item {
  padding: 12px 16px;
  border-bottom: 1px solid #f3f4f6;
  cursor: pointer;
  display: flex;
  gap: 10px;
  align-items: flex-start;
}
.conversation-item:hover { background: #f9fafb; }
.conversation-item.active { background: #eef2ff; }
.conversation-item-body { display: flex; flex-direction: column; gap: 4px; min-width: 0; flex: 1; }
.conversation-item .name { font-weight: 600; }
.conversation-item .preview {
  font-size: 13px; color: #6b7280;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.conversation-item.unread .name { font-weight: 800; }
.conversation-item.unread .preview { color: #111827; font-weight: 600; }
.unread-dot {
  display: inline-block; width: 8px; height: 8px; border-radius: 50%;
  background: #2563eb; margin-left: 6px; vertical-align: middle;
}
.conversation-item .badges { display: flex; gap: 4px; flex-wrap: wrap; }
.avatar {
  flex: 0 0 auto; width: 38px; height: 38px; border-radius: 50%;
  background: #2563eb; color: #fff; display: flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 700; text-transform: uppercase;
}
.tag-chip {
  font-size: 11px; padding: 2px 8px; border-radius: 999px; color: #fff;
}
.manual-badge {
  font-size: 11px; padding: 2px 8px; border-radius: 999px;
  background: #fee2e2; color: #b91c1c;
}
.human-needed-badge {
  font-size: 11px; padding: 2px 8px; border-radius: 999px;
  background: #fef3c7; color: #92400e; font-weight: 600;
}
.conversation-item.needs-human { border-left: 3px solid #f59e0b; }

/* min-width: 0 em toda a cadeia flex da conversa: sem isso, um item flex nunca
   fica mais estreito que o seu conteúdo — o cabeçalho (nome + Negócio + IA) ou
   um link comprido esticava a conversa além da tela e o atendente tinha que
   arrastar pro lado pra ler a mensagem inteira (visto no celular, 14/09/2026). */
.chat { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.empty-state {
  flex: 1; display: flex; align-items: center; justify-content: center; color: #9ca3af;
}
.hidden { display: none !important; }

#appShell { display: flex; flex-direction: column; flex: 1; min-height: 0; }

.login-screen {
  position: fixed; inset: 0; z-index: 1000;
  display: flex; align-items: center; justify-content: center;
  background: #111827;
}
.login-box {
  width: 100%; max-width: 320px; background: #fff; border-radius: 12px;
  padding: 28px 24px; display: flex; flex-direction: column; gap: 12px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.25);
}
.login-box h1 { font-size: 18px; margin: 0 0 4px; text-align: center; }
.login-box label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: #374151; }
.login-box input {
  padding: 10px; border: 1px solid #d1d5db; border-radius: 8px; font-size: 15px;
}
.login-box button {
  margin-top: 8px; padding: 10px; border: none; border-radius: 8px;
  background: #2563eb; color: #fff; font-weight: 600; font-size: 14px; cursor: pointer;
}
.login-box button:hover { background: #1d4ed8; }
.login-msg { min-height: 16px; font-size: 13px; color: #dc2626; margin: 0; text-align: center; }

.logout-btn { margin-left: auto; }

.chat-view { flex: 1; display: flex; flex-direction: column; min-height: 0; min-width: 0; position: relative; }
.chat-header {
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  padding: 12px 20px; border-bottom: 1px solid #e5e7eb; background: #fff;
}
/* Nome e telefone encolhem com reticências; os botões da direita ficam inteiros. */
.chat-header > div:not(.chat-header-actions) { min-width: 0; flex: 1; }
.chat-header h2, .chat-header .muted { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; }
.chat-header h2 { margin: 0; font-size: 16px; }
.chat-header-actions, .chat-back-btn { flex-shrink: 0; }
.muted { color: #6b7280; font-size: 13px; }
.chat-header-actions { display: flex; align-items: center; gap: 14px; }
.ai-toggle label { display: flex; align-items: center; gap: 6px; font-size: 14px; }
#contactDetailsBtn {
  border: 1px solid #d1d5db; background: #fff; padding: 6px 12px; border-radius: 8px;
  font-size: 13px; cursor: pointer;
}
#contactDetailsBtn:hover { background: #f3f4f6; }

.chat-tags {
  padding: 8px 20px; display: flex; gap: 6px; flex-wrap: wrap; align-items: center; background: #fff;
  border-bottom: 1px solid #f3f4f6;
}
.tag-chip-toggle { cursor: pointer; opacity: 0.35; border: 2px solid transparent; transition: opacity 0.15s; }
.tag-chip-toggle.active { opacity: 1; box-shadow: 0 0 0 2px rgba(0,0,0,0.08) inset; }
.tag-chip-toggle.exclude { opacity: 1; box-shadow: 0 0 0 2px #ef4444 inset; text-decoration: line-through; }
.tag-chip-toggle:hover { opacity: 0.75; }
.tag-add-btn {
  font-size: 11px; padding: 2px 10px; border-radius: 999px; border: 1px dashed #9ca3af;
  background: none; color: #6b7280; cursor: pointer;
}
.tag-add-btn:hover { background: #f3f4f6; color: #374151; }

.messages {
  flex: 1; overflow-y: auto; overflow-x: hidden; padding: 20px; display: flex; flex-direction: column; gap: 10px;
  background: #f9fafb; min-width: 0;
}
.message {
  max-width: 60%; padding: 8px 12px; border-radius: 12px; font-size: 14px; line-height: 1.4;
  min-width: 0; overflow-wrap: anywhere; /* link/código sem espaço quebra dentro do balão */
}
.message .meta { font-size: 11px; opacity: 0.7; margin-top: 4px; }
.message.inbound { align-self: flex-start; background: #fff; border: 1px solid #e5e7eb; }
.message.outbound { align-self: flex-end; background: #dbeafe; }
.message.outbound.ai { background: #ede9fe; }
.message.outbound.system { align-self: center; background: #f3f4f6; color: #6b7280; font-style: italic; }
.message.reaction {
  align-self: center; background: #f3f4f6; color: #6b7280; font-style: italic;
  border: none; font-size: 13px; padding: 6px 12px; max-width: 80%;
}

.day-separator {
  align-self: center; font-size: 11.5px; font-weight: 600; color: #6b7280;
  background: #e5e7eb; padding: 3px 10px; border-radius: 999px; margin: 6px 0 2px;
}
.msg-tick { margin-left: 2px; letter-spacing: -2px; color: #6b7280; }
.msg-tick.read { color: #2563eb; }
.msg-tick.failed { letter-spacing: 0; color: #b91c1c; font-weight: 600; }

.msg-media-image { max-width: min(260px, 100%); max-height: 320px; border-radius: 10px; display: block; cursor: pointer; }
.msg-media-audio { width: 260px; max-width: 100%; }
.msg-media-video { max-width: min(280px, 100%); border-radius: 10px; display: block; }
.msg-media-doc {
  display: inline-flex; align-items: center; gap: 6px; padding: 8px 10px; border-radius: 8px;
  background: rgba(0,0,0,0.04); text-decoration: none; color: inherit; font-size: 13px; max-width: min(240px, 100%);
  overflow-wrap: anywhere; /* nome do arquivo quebra linha e aparece inteiro, em vez de cortar */
}
.msg-media-missing { font-style: italic; color: #9ca3af; font-size: 13px; }
.msg-text, .msg-caption { white-space: pre-wrap; word-break: break-word; }
.msg-caption { margin-top: 6px; }

.upload-status {
  padding: 6px 20px; font-size: 12px; color: #6b7280; background: #fff;
  border-top: 1px solid #f3f4f6;
}

/* Citação (responder mensagem) — mesmo recurso do WhatsApp normal */
.message { position: relative; }
.msg-reply-btn {
  position: absolute; top: -10px; width: 22px; height: 22px; border-radius: 50%;
  border: 1px solid #e5e7eb; background: #fff; cursor: pointer; font-size: 11px;
  display: flex; align-items: center; justify-content: center; opacity: 0; transition: opacity 0.1s;
}
.message:hover .msg-reply-btn { opacity: 1; }
.message.inbound .msg-reply-btn { right: -10px; }
.message.outbound .msg-reply-btn { left: -10px; }
.msg-quoted {
  border-left: 3px solid #2563eb; background: rgba(37,99,235,0.07); border-radius: 6px;
  padding: 5px 8px; margin-bottom: 6px; font-size: 12.5px; color: #4b5563; cursor: pointer;
}
.msg-quoted .msg-quoted-author { font-weight: 600; color: #2563eb; display: block; font-size: 11.5px; }
.msg-quoted .msg-quoted-text { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; }
.message.highlight { outline: 2px solid #2563eb; outline-offset: 2px; }

.replying-to-bar {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 8px 20px; background: #eff6ff; border-top: 1px solid #dbeafe;
}
.replying-to-content { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.replying-to-label { font-size: 11px; font-weight: 600; color: #2563eb; }
.replying-to-text {
  font-size: 12.5px; color: #4b5563; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.replying-to-bar button {
  border: none; background: none; cursor: pointer; font-size: 14px; color: #6b7280; flex: 0 0 auto;
}

.send-form {
  display: flex; gap: 8px; padding: 12px 20px; background: #fff; border-top: 1px solid #e5e7eb; align-items: center;
}
.send-form textarea {
  flex: 1; min-width: 0; padding: 10px 12px; border: 1px solid #d1d5db; border-radius: 8px; font-size: 14px;
  font-family: inherit; resize: none; max-height: 120px; overflow-y: auto; line-height: 1.4;
}
.attach-btn {
  border: 1px solid #d1d5db; background: #fff; width: 40px; height: 40px; border-radius: 8px;
  font-size: 18px; cursor: pointer; flex: 0 0 auto;
}
.attach-btn:hover { background: #f3f4f6; }
/* Só o "Enviar" é azul: `.send-form button` pegava também 📎 ⚡ 📨 e, por ser
   mais específico que .attach-btn/.quickreply-btn, pintava os três de azul com
   o ícone quase sumindo. */
.send-form button[type="submit"], .new-tag-form button {
  padding: 10px 16px; border: none; border-radius: 8px; background: #2563eb; color: #fff; cursor: pointer;
}

dialog { border: none; border-radius: 12px; padding: 20px; width: 320px; max-width: calc(100vw - 24px); }
.new-tag-form { display: flex; gap: 8px; margin-bottom: 12px; }
.new-tag-form input[type="text"], .new-tag-form input:not([type]) { flex: 1; padding: 8px; border: 1px solid #d1d5db; border-radius: 6px; }
.tags-list { list-style: none; padding: 0; margin: 0 0 12px; display: flex; flex-direction: column; gap: 6px; }
.tags-list li { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.tags-list li .tag-chip { min-width: 0; overflow-wrap: anywhere; }
.tags-list button { background: none; border: none; color: #b91c1c; cursor: pointer; }
.tag-actions { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.tag-manual-toggle { display: flex; align-items: center; gap: 4px; font-size: 12px; color: #4b5563; cursor: pointer; white-space: nowrap; }
#tagsDialog { width: 420px; }

/* Disparos */
.campaigns-layout {
  display: grid; grid-template-columns: 380px 1fr; gap: 20px; padding: 24px; align-items: start;
}
.campaign-form-card, .campaign-list-card {
  background: #fff; border: 1px solid #e5e7eb; border-radius: 12px; padding: 20px;
}
.campaign-form-card h2, .campaign-list-card h2 { margin-top: 0; font-size: 16px; }
#campaignForm, #emailCampaignForm { display: flex; flex-direction: column; gap: 14px; }
#campaignForm label, #emailCampaignForm label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 600; color: #374151; }
#campaignForm input, #campaignForm select, #emailCampaignForm input, #emailCampaignForm select, #emailCampaignForm textarea {
  font-weight: 400; padding: 9px 10px; border: 1px solid #d1d5db; border-radius: 8px; font-size: 14px; font-family: inherit;
}
#emailCampaignForm textarea { resize: vertical; }
.campaign-tag-filters { display: flex; gap: 8px; flex-wrap: wrap; }
#campaignForm .campaign-checkbox-filter, #emailCampaignForm .campaign-checkbox-filter {
  flex-direction: row; align-items: center; gap: 8px; margin-top: 10px;
  font-weight: 400; font-size: 13px; color: #374151; cursor: pointer;
}
.campaign-checkbox-filter input { width: auto; }
.campaign-tag-toggle {
  cursor: pointer; opacity: 0.35; border: 2px solid transparent; transition: opacity 0.15s;
}
.campaign-tag-toggle.active { opacity: 1; box-shadow: 0 0 0 2px rgba(0,0,0,0.08) inset; }
.campaign-tag-toggle.exclude { opacity: 1; box-shadow: 0 0 0 2px #ef4444 inset; text-decoration: line-through; }
.campaign-tag-toggle:hover { opacity: 0.75; }
#campaignForm button {
  padding: 10px 16px; border: none; border-radius: 8px; background: #2563eb; color: #fff;
  cursor: pointer; font-size: 14px; font-weight: 600;
}
#campaignFormMsg { font-size: 13px; color: #374151; min-height: 18px; }

.campaign-list { display: flex; flex-direction: column; gap: 10px; }
.campaign-item {
  border: 1px solid #e5e7eb; border-radius: 10px; padding: 12px 14px; cursor: pointer;
}
.campaign-item:hover { background: #f9fafb; }
.campaign-item-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.campaign-status { font-size: 11px; padding: 2px 8px; border-radius: 999px; background: #e5e7eb; }
.campaign-status-RUNNING { background: #fef3c7; color: #92400e; }
.campaign-status-DONE { background: #d1fae5; color: #065f46; }
.campaign-status-FAILED { background: #fee2e2; color: #b91c1c; }
.campaign-status-SCHEDULED { background: #dbeafe; color: #1e40af; }
.campaign-status-CANCELED { background: #f3f4f6; color: #6b7280; }
.campaign-progress-bar { height: 6px; background: #f3f4f6; border-radius: 999px; overflow: hidden; margin-bottom: 6px; }
.campaign-progress-fill { height: 100%; background: #2563eb; }

#campaignDialog { width: 640px; }
.campaign-schedule-box { margin: 12px 0; padding: 12px; border: 1px solid #dbeafe; background: #eff6ff; border-radius: 8px; }
.campaign-schedule-box label { display: block; font-size: 13px; font-weight: 600; color: #374151; margin-bottom: 6px; }
.campaign-schedule-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.campaign-schedule-row input { padding: 8px 10px; border: 1px solid #d1d5db; border-radius: 8px; font-size: 14px; font-family: inherit; }
.campaign-schedule-row button { padding: 8px 12px; border: none; border-radius: 8px; background: #2563eb; color: #fff; cursor: pointer; font-size: 13px; font-weight: 600; }
.campaign-schedule-row .campaign-cancel-btn { background: #fff; color: #b91c1c; border: 1px solid #fca5a5; }
#emailCampaignDialog { width: 640px; }
.recipient-list { list-style: none; padding: 0; margin: 12px 0; max-height: 60vh; overflow-y: auto; border-top: 1px solid #f3f4f6; }
.recipient-row { padding: 8px 2px; border-bottom: 1px solid #f3f4f6; font-size: 13px; }
.recipient-row-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.recipient-name { font-weight: 600; color: #111827; min-width: 0; }
.recipient-row-top .recipient-status { flex-shrink: 0; }
.recipient-email { color: #4b5563; overflow-wrap: anywhere; margin-top: 2px; }
.recipient-extra { color: #6b7280; font-size: 12px; margin-top: 2px; }
.recipient-error { color: #b91c1c; font-size: 12px; margin-top: 2px; overflow-wrap: anywhere; }
.recipient-status { font-size: 11px; padding: 2px 8px; border-radius: 999px; background: #e5e7eb; }
.recipient-status-PENDING { background: #e5e7eb; color: #374151; }
.recipient-status-SENT { background: #d1fae5; color: #065f46; }
.recipient-status-FAILED { background: #fee2e2; color: #b91c1c; }
.recipient-status-DELIVERED { background: #dbeafe; color: #1e40af; }
.recipient-status-OPENED { background: #e0e7ff; color: #3730a3; }
.recipient-status-CLICKED { background: #ede9fe; color: #5b21b6; }
.recipient-status-BOUNCED { background: #fee2e2; color: #b91c1c; }

/* Detalhes do negócio */
.contact-details-dialog { width: 380px; }
.contact-details-form { display: flex; flex-direction: column; gap: 12px; }
.contact-details-form label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 600; color: #374151; }
.contact-details-form input, .contact-details-form select, .contact-details-form textarea {
  font-weight: 400; padding: 9px 10px; border: 1px solid #d1d5db; border-radius: 8px; font-size: 14px; font-family: inherit;
}
.contact-details-form textarea { resize: vertical; }
.contact-details-form button {
  padding: 10px 16px; border: none; border-radius: 8px; background: #2563eb; color: #fff;
  cursor: pointer; font-size: 14px; font-weight: 600;
}

.cd-optout-zone {
  display: flex; flex-direction: column; gap: 6px; margin-top: 4px;
  padding-top: 12px; border-top: 1px solid #e5e7eb;
}
.cd-optout-btn {
  padding: 9px 16px; border: 1px solid #d1d5db; border-radius: 8px;
  background: #f9fafb; color: #374151; cursor: pointer; font-size: 13px; font-weight: 600;
}
.cd-optout-btn:hover { background: #f3f4f6; }
.cd-optout-btn.active { border-color: #fca5a5; background: #fef2f2; color: #b91c1c; }

.cd-danger-zone {
  display: flex; flex-direction: column; gap: 6px; margin-top: 4px;
  padding-top: 12px; border-top: 1px solid #e5e7eb;
}
.cd-delete-btn {
  padding: 9px 16px; border: 1px solid #fca5a5; border-radius: 8px;
  background: #fef2f2; color: #b91c1c; cursor: pointer; font-size: 13px; font-weight: 600;
}
.cd-delete-btn:hover { background: #fee2e2; }

/* Editar linha de Proposta/Inscrição (tabela Dados dos Formulários) */
.record-edit-dialog { width: 380px; }
.record-edit-form { display: flex; flex-direction: column; gap: 12px; }
.record-edit-form label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 600; color: #374151; }
.record-edit-form input {
  font-weight: 400; padding: 9px 10px; border: 1px solid #d1d5db; border-radius: 8px; font-size: 14px; font-family: inherit;
}
.record-edit-form button {
  padding: 10px 16px; border: none; border-radius: 8px; background: #2563eb; color: #fff;
  cursor: pointer; font-size: 14px; font-weight: 600;
}

.rec-edit-btn, .rec-delete-btn {
  border: 1px solid #d1d5db; border-radius: 6px; background: #f9fafb; cursor: pointer;
  font-size: 13px; padding: 4px 7px; margin-right: 4px;
}
.rec-edit-btn:hover { background: #f3f4f6; }
.rec-delete-btn { border-color: #fca5a5; background: #fef2f2; }
.rec-delete-btn:hover { background: #fee2e2; }

/* Funil */
.funnel-board { display: flex; gap: 16px; padding: 24px; height: 100%; overflow-x: auto; }
.funnel-column {
  flex: 0 0 240px; display: flex; flex-direction: column; background: #f3f4f6;
  border-radius: 10px; max-height: 100%;
}
.funnel-column-header {
  padding: 12px 14px; font-weight: 700; font-size: 13px; border-top: 4px solid #94a3b8;
  border-radius: 10px 10px 0 0; background: #fff; display: flex; justify-content: space-between; align-items: center;
}
.funnel-count { color: #6b7280; font-weight: 600; }
.funnel-cards { padding: 10px; display: flex; flex-direction: column; gap: 8px; overflow-y: auto; }
.funnel-empty { text-align: center; padding: 12px 0; }
.funnel-card {
  background: #fff; border: 1px solid #e5e7eb; border-radius: 8px; padding: 10px 12px;
  cursor: pointer; font-size: 13px;
}
.funnel-card:hover { border-color: #2563eb; }
.funnel-card-name { font-weight: 600; margin-bottom: 2px; }
.funnel-card-value { margin-top: 6px; font-weight: 700; color: #059669; font-size: 12px; }

/* Lembretes (reaproveita .funnel-board/.funnel-column/.funnel-card do Funil) */
.reminder-card-overdue { border-color: #fecaca; background: #fef2f2; }
.reminder-card-overdue .funnel-card-value { color: #b91c1c; }

/* Dashboard */
.dashboard-page { padding: 24px; max-width: 960px; }
.dashboard-page h2 { margin: 0 0 16px; }
.stat-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-bottom: 24px; }
.stat-card { background: #fff; border: 1px solid #e5e7eb; border-radius: 10px; padding: 16px; }
.stat-card.highlight { border-color: #059669; background: #ecfdf5; }
.stat-value { font-size: 22px; font-weight: 700; }
.stat-label { font-size: 12px; color: #6b7280; margin-top: 4px; }
.dashboard-panels { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.dashboard-panel { background: #fff; border: 1px solid #e5e7eb; border-radius: 10px; padding: 16px; }
.dashboard-panel.dashboard-panel-wide { grid-column: 1 / -1; }
.dashboard-panel h3 { margin: 0 0 12px; font-size: 14px; }
.bar-row { display: grid; grid-template-columns: 110px 1fr 28px; align-items: center; gap: 8px; margin-bottom: 8px; font-size: 12px; }
.bar-row.tag-bar-row { grid-template-columns: 110px 1fr 130px; }
.bar-label { color: #374151; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-track { height: 8px; background: #f3f4f6; border-radius: 999px; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 999px; }
.bar-count { text-align: right; color: #6b7280; font-weight: 600; white-space: nowrap; }

.conversion-table-wrap { overflow-x: auto; }
.conversion-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.conversion-table th {
  text-align: left; padding: 8px 10px; border-bottom: 1px solid #e5e7eb; white-space: nowrap;
  font-weight: 700; color: #374151;
}
.conversion-table td { padding: 8px 10px; border-bottom: 1px solid #f3f4f6; white-space: nowrap; }

/* Cursos */
.course-layout { display: grid; grid-template-columns: 320px 1fr; gap: 20px; padding: 24px; align-items: start; height: 100%; overflow-y: auto; }
.course-list-card, .course-form-card {
  background: #fff; border: 1px solid #e5e7eb; border-radius: 12px; padding: 20px;
}
.course-list-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 4px; }
.course-list-header h2 { margin: 0; font-size: 16px; }
.course-list-header button {
  border: 1px solid #2563eb; background: #fff; color: #2563eb; border-radius: 8px;
  padding: 6px 10px; font-size: 12px; font-weight: 600; cursor: pointer;
}
.course-list-header button:hover { background: #eff6ff; }
.course-list { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.course-item {
  border: 1px solid #e5e7eb; border-radius: 8px; padding: 10px 12px; cursor: pointer; font-size: 13px;
}
.course-item:hover { background: #f9fafb; }
.course-item.active { border-color: #2563eb; background: #eff6ff; }
.course-item.archived { opacity: 0.55; }
.course-archived-badge {
  font-size: 10px; margin-left: 6px; padding: 1px 6px; border-radius: 999px; background: #e5e7eb; color: #6b7280;
}
.wa-template-status {
  font-size: 10px; margin-left: 6px; padding: 1px 6px; border-radius: 999px; font-weight: 700;
  background: #e5e7eb; color: #6b7280;
}
.wa-template-status-approved { background: #d1fae5; color: #065f46; }
.wa-template-status-pending { background: #fef3c7; color: #92400e; }
.wa-template-status-rejected { background: #fee2e2; color: #b91c1c; }
.wa-template-delete-btn {
  margin-top: 8px; font-size: 11px; padding: 3px 10px; border-radius: 999px;
  border: 1px solid #fca5a5; background: #fef2f2; color: #b91c1c; cursor: pointer;
}
.wa-template-delete-btn:hover { background: #fee2e2; }
.course-form-card h2 { margin-top: 0; font-size: 16px; }
.course-form { display: flex; flex-direction: column; gap: 14px; margin-top: 16px; }
.course-form label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 600; color: #374151; }
.course-form input, .course-form textarea {
  font-weight: 400; padding: 9px 10px; border: 1px solid #d1d5db; border-radius: 8px; font-size: 14px; font-family: inherit;
}
.course-form textarea { resize: vertical; }
.course-folder-status { margin: -6px 0 12px; font-size: 13px; }

/* Documentos para contratação */
#docForm select, #courseRepasseBase {
  font-weight: 400; padding: 9px 10px; border: 1px solid #d1d5db; border-radius: 8px; font-size: 14px; font-family: inherit; background: #fff;
}
.course-form label.doc-checkbox { flex-direction: row; align-items: center; gap: 8px; font-weight: 400; }
.doc-public-link { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 12px; font-size: 13px; }
.doc-public-link a { color: #2563eb; }
.doc-public-link button { padding: 6px 10px; border-radius: 8px; font-size: 12px; font-weight: 600; cursor: pointer; }
.doc-group-title { margin: 10px 0 0; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; color: #6b7280; }
.doc-chip { display: inline-block; margin-top: 4px; font-size: 11px; font-weight: 700; padding: 1px 7px; border-radius: 999px; }
.doc-chip.valid { background: #dcfce7; color: #166534; }
.doc-chip.expiring { background: #fef3c7; color: #92400e; }
.doc-chip.expired { background: #fee2e2; color: #991b1b; }
.doc-chip.hidden-doc { background: #e5e7eb; color: #6b7280; }
.doc-issue-link { display: inline-block; margin-top: 6px; font-size: 12px; font-weight: 700; color: #2563eb; text-decoration: none; }
.doc-issue-link:hover { text-decoration: underline; }
.doc-issue-btn {
  padding: 10px 16px; border-radius: 8px; border: 1px solid #93c5fd; background: #fff; color: #2563eb;
  font-size: 14px; font-weight: 600; text-decoration: none;
}
.doc-issue-btn:hover { background: #eff6ff; }
.course-form-actions { display: flex; gap: 10px; }
.course-form button {
  padding: 10px 16px; border: none; border-radius: 8px; background: #2563eb; color: #fff;
  cursor: pointer; font-size: 14px; font-weight: 600;
}
.course-archive-btn { background: #fff !important; color: #b91c1c !important; border: 1px solid #fecaca !important; }
.course-archive-btn:hover { background: #fef2f2 !important; }
.course-link-btn { background: #fff !important; color: #2563eb !important; border: 1px solid #93c5fd !important; }
.course-link-btn:hover { background: #eff6ff !important; }

/* Detalhes do negócio: histórico de propostas/inscrições */
.cd-proposal-history { border-top: 1px solid #e5e7eb; padding-top: 10px; font-size: 12px; }
.proposal-history-item { display: flex; justify-content: space-between; gap: 8px; padding: 4px 0; }
.proposal-history-item a { color: #2563eb; }

.cd-contract-section { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 600; color: #374151; }
.cd-contract-btn {
  align-self: flex-start; padding: 8px 12px; border: 1px solid #d1d5db; background: #fff; border-radius: 8px;
  font-size: 13px; font-weight: 600; cursor: pointer; color: #374151;
}
.cd-contract-btn:hover { background: #f3f4f6; }

/* Usuários */
.users-page { padding: 24px; max-width: 560px; }
.users-page h2 { margin: 0 0 4px; }
.user-form { display: flex; flex-wrap: wrap; gap: 10px; margin: 16px 0; }
.user-form input {
  flex: 1; min-width: 140px; padding: 9px 10px; border: 1px solid #d1d5db; border-radius: 8px; font-size: 14px; font-family: inherit;
}
.user-form .user-readonly-check { display: flex; align-items: center; gap: 6px; font-size: 14px; color: #374151; white-space: nowrap; }
.user-form .user-readonly-check input { flex: none; min-width: 0; width: auto; padding: 0; }
.user-form button {
  padding: 9px 16px; border: none; border-radius: 8px; background: #2563eb; color: #fff;
  cursor: pointer; font-size: 14px; font-weight: 600;
}
.user-list { display: flex; flex-direction: column; gap: 8px; margin-top: 16px; }
.user-item {
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  border: 1px solid #e5e7eb; border-radius: 8px; padding: 10px 12px; font-size: 13px;
}
.user-item.disabled { opacity: 0.55; }
.user-disabled-badge {
  font-size: 10px; margin-left: 6px; padding: 1px 6px; border-radius: 999px; background: #fee2e2; color: #b91c1c;
}
.user-toggle-btn {
  border: 1px solid #d1d5db; background: #fff; border-radius: 6px; padding: 4px 10px; font-size: 12px; cursor: pointer;
}
.user-toggle-btn:hover { background: #f3f4f6; }

/* Modelo de Documento */
.template-layout { display: grid; grid-template-columns: minmax(360px, 480px) 1fr; gap: 20px; padding: 24px; height: 100%; overflow-y: auto; align-items: start; }
.template-form-card, .template-preview-card {
  background: #fff; border: 1px solid #e5e7eb; border-radius: 12px; padding: 20px;
}
.template-preview-card { position: sticky; top: 24px; height: calc(100vh - 160px); display: flex; flex-direction: column; }
.template-preview-card h2 { margin: 0 0 12px; font-size: 16px; }
.template-preview-frame { flex: 1; width: 100%; border: 1px solid #e5e7eb; border-radius: 8px; }
.template-form-card h2 { margin: 0 0 4px; font-size: 16px; }
.template-form-card code { background: #f3f4f6; padding: 1px 5px; border-radius: 4px; font-size: 12px; }
.template-kind-tabs { display: flex; gap: 8px; margin: 16px 0; }
.template-kind-btn {
  padding: 8px 14px; border: 1px solid #d1d5db; background: #fff; border-radius: 999px;
  font-size: 13px; font-weight: 600; cursor: pointer; color: #374151;
}
.template-kind-btn.active { background: #2563eb; border-color: #2563eb; color: #fff; }
.template-form { display: flex; flex-direction: column; gap: 14px; }
.template-form label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 600; color: #374151; }
.template-form input, .template-form select, .template-form textarea {
  font-weight: 400; padding: 9px 10px; border: 1px solid #d1d5db; border-radius: 8px; font-size: 14px; font-family: inherit;
}
.template-form input[type="color"] { padding: 4px; height: 40px; width: 80px; }
.template-form textarea { resize: vertical; }
.template-watermark-actions { display: flex; gap: 8px; }
.template-form-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.template-form button[type="submit"] {
  padding: 10px 16px; border: none; border-radius: 8px; background: #2563eb; color: #fff;
  cursor: pointer; font-size: 14px; font-weight: 600;
}
.template-secondary-btn {
  padding: 9px 14px; border: 1px solid #d1d5db; background: #fff; border-radius: 8px;
  font-size: 13px; font-weight: 600; cursor: pointer; color: #374151;
}
.template-secondary-btn:hover { background: #f3f4f6; }

/* Dados dos Formulários */
.records-page { padding: 24px; height: 100%; display: flex; flex-direction: column; overflow: hidden; }
.records-page h2 { margin: 0 0 4px; flex: 0 0 auto; }
.records-kind-tabs { display: flex; gap: 8px; margin: 12px 0; flex: 0 0 auto; }
.records-kind-btn, .fin-tab-btn {
  padding: 8px 14px; border: 1px solid #d1d5db; background: #fff; border-radius: 999px;
  font-size: 13px; font-weight: 600; cursor: pointer; color: #374151;
}
.records-kind-btn.active, .fin-tab-btn.active { background: #2563eb; border-color: #2563eb; color: #fff; }
.records-filters { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; margin-bottom: 14px; flex: 0 0 auto; }
.records-filters label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; font-weight: 600; color: #374151; }
.records-filters input, .records-filters select {
  padding: 8px 10px; border: 1px solid #d1d5db; border-radius: 8px; font-size: 13px; font-family: inherit;
}
.records-export-btn {
  padding: 9px 14px; border: 1px solid #059669; background: #ecfdf5; color: #059669;
  border-radius: 8px; font-size: 13px; font-weight: 600; cursor: pointer;
}
.records-export-btn:hover { background: #d1fae5; }
.records-cert-btn {
  padding: 9px 14px; border: 1px solid #0b1233; background: #eef0f8; color: #0b1233;
  border-radius: 8px; font-size: 13px; font-weight: 600; cursor: pointer;
}
.records-cert-btn:hover { background: #dfe3f1; }
.records-cert-btn:disabled { opacity: 0.6; cursor: wait; }
.rec-cert-btn, .rec-cert-send-btn, .rec-cert-wa-btn {
  border: 1px solid #c7cbe0; border-radius: 6px; background: #f5f6fb; cursor: pointer;
  font-size: 12px; padding: 3px 7px; margin-left: 4px; white-space: nowrap;
}
.rec-cert-btn:hover, .rec-cert-send-btn:hover, .rec-cert-wa-btn:hover { background: #e8eaf4; }
.rec-cert-cell { white-space: nowrap; }
.records-table-wrap { flex: 1; overflow: auto; border: 1px solid #e5e7eb; border-radius: 10px; }
#recordsTable { width: 100%; border-collapse: collapse; font-size: 13px; }
#recordsTable th {
  position: sticky; top: 0; background: #f9fafb; text-align: left; padding: 10px 12px;
  border-bottom: 1px solid #e5e7eb; white-space: nowrap; font-weight: 700; color: #374151;
}
#recordsTable td { padding: 8px 12px; border-bottom: 1px solid #f3f4f6; white-space: nowrap; }
#recordsTable tbody tr:hover { background: #f9fafb; cursor: pointer; }
#recordsTable a { color: #2563eb; }

/* Respostas rápidas */
.quickreplies-page { padding: 24px; max-width: 640px; }
.quickreplies-page h2 { margin: 0 0 4px; }
.quickreply-form { display: flex; flex-direction: column; gap: 10px; margin: 16px 0 24px; }
.quickreply-form input, .quickreply-form textarea {
  padding: 9px 10px; border: 1px solid #d1d5db; border-radius: 8px; font-size: 14px; font-family: inherit; resize: vertical;
}
.quickreply-form-actions { display: flex; gap: 10px; align-items: center; }
.quickreply-form button {
  align-self: flex-start; padding: 9px 16px; border: none; border-radius: 8px; background: #2563eb; color: #fff;
  cursor: pointer; font-size: 14px; font-weight: 600;
}
.quickreply-cancel-btn { background: #fff !important; color: #6b7280 !important; border: 1px solid #d1d5db !important; }
.quickreply-cancel-btn:hover { background: #f3f4f6 !important; }
.quickreply-list { display: flex; flex-direction: column; gap: 8px; }
.quickreply-item {
  display: flex; justify-content: space-between; align-items: flex-start; gap: 10px;
  border: 1px solid #e5e7eb; border-radius: 8px; padding: 10px 12px;
}
.quickreply-item.editing { border-color: #2563eb; background: #eff6ff; }
.quickreply-item p { margin: 2px 0 0; }
.quickreply-item-actions { display: flex; gap: 10px; white-space: nowrap; }
.quickreply-edit-btn, .quickreply-delete-btn {
  border: none; background: none; font-size: 12px; cursor: pointer; white-space: nowrap;
}
.quickreply-edit-btn { color: #2563eb; }
.quickreply-delete-btn { color: #b91c1c; }

.quickreply-btn {
  border: none; background: none; font-size: 18px; cursor: pointer; padding: 4px 6px; border-radius: 6px;
}
.quickreply-btn:hover { background: #f3f4f6; }
.quickreply-popover {
  position: absolute; bottom: 64px; left: 16px; right: 16px; max-height: 260px; overflow-y: auto;
  background: #fff; border: 1px solid #e5e7eb; border-radius: 10px; box-shadow: 0 8px 24px rgba(0,0,0,0.12);
  z-index: 20;
}
.quickreply-option { padding: 10px 14px; border-bottom: 1px solid #f3f4f6; cursor: pointer; }
.quickreply-option:last-child { border-bottom: none; }
.quickreply-option:hover { background: #f9fafb; }
.quickreply-option strong { display: block; font-size: 12px; color: #2563eb; }
.quickreply-option span { display: block; font-size: 13px; color: #374151; margin-top: 2px; }

.sendform-panel { padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.sendform-label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; font-weight: 600; color: #374151; }
.sendform-label select {
  font-weight: 400; padding: 8px 10px; border: 1px solid #d1d5db; border-radius: 8px; font-size: 13px; font-family: inherit;
}
.sendform-action {
  padding: 9px 12px; border: 1px solid #d1d5db; background: #fff; border-radius: 8px;
  font-size: 13px; font-weight: 600; cursor: pointer; text-align: left; color: #374151;
}
.sendform-action:hover { background: #f3f4f6; border-color: #2563eb; color: #2563eb; }

/* ---------- Celular ---------- */

.chat-back-btn {
  display: none; border: none; background: none; font-size: 20px; cursor: pointer;
  padding: 4px 10px 4px 0; color: #111827; flex: 0 0 auto;
}

@media (max-width: 768px) {
  .top-nav { overflow-x: auto; white-space: nowrap; -webkit-overflow-scrolling: touch; }
  .top-nav .brand { display: none; } /* economiza espaço na barra de abas */

  /* Conversas: lista OU chat, nunca os dois ao mesmo tempo — alterna pela
     classe "conversation-open" no <body> (ver selectConversation em app.js). */
  #app { position: relative; }
  .sidebar { width: 100%; }
  body:not(.conversation-open) .chat { display: none; }
  body.conversation-open .sidebar { display: none; }
  .chat-back-btn { display: block; }

  .message { max-width: 85%; }
  .messages { padding: 12px; }

  /* Cabeçalho e barra de envio compactos: no celular cada pixel de largura conta. */
  .chat-header { padding: 10px 12px; gap: 8px; }
  .chat-header-actions { gap: 8px; }
  #contactDetailsBtn { padding: 6px 8px; }
  .ai-toggle label { font-size: 13px; gap: 4px; }
  .chat-tags { padding: 8px 12px; }
  .send-form { padding: 8px 10px; gap: 6px; }
  .attach-btn { width: 36px; height: 36px; font-size: 16px; }
  .quickreply-btn { padding: 4px; }
  .send-form button[type="submit"] { padding: 10px 12px; }

  /* Layouts em grade de 2 colunas viram 1 coluna empilhada */
  .campaigns-layout,
  .course-layout,
  .template-layout,
  .dashboard-panels {
    grid-template-columns: 1fr !important;
    padding: 16px;
  }
}

/* Disparos: de onde vem cada variável do modelo (curso, link, ID, senha) */
.campaign-vars { margin: 4px 0 12px; padding: 10px 12px; border: 1px solid #dbeafe; background: #eff6ff; border-radius: 8px; }
.campaign-vars-title { margin: 0 0 6px; font-size: 13px; font-weight: 600; color: #1e3a8a; }
/* #campaignForm label é coluna: aqui cada linha é "{{n}} contexto" em cima e o seletor embaixo */
#campaignForm .campaign-var-row { gap: 4px; margin-bottom: 8px; font-weight: 400; }
.campaign-var-name { min-width: 0; overflow-wrap: anywhere; font-weight: 600; }
#campaignForm .campaign-var-row select { width: 100%; }
.campaign-vars-preview { margin: 8px 0 0; padding: 8px; background: #fff; border-radius: 6px; font-size: 12px; color: #374151; white-space: pre-wrap; overflow-wrap: anywhere; }

/* Cursos: sala da aula ao vivo */
.course-meeting { border: 1px solid #e5e7eb; border-radius: 8px; padding: 8px 12px; margin: 4px 0 12px; }
.course-meeting legend { font-size: 13px; font-weight: 600; color: #374151; padding: 0 4px; }
.course-meeting-row { display: flex; flex-wrap: wrap; gap: 0 12px; }
.course-meeting-row label { flex: 1 1 140px; }

/* ---------- Assistente do dono (public/ownerChat.js) ---------- */
.user-admin-badge {
  font-size: 10px; margin-left: 6px; padding: 1px 6px; border-radius: 999px; background: #dbeafe; color: #1d4ed8;
}
.user-item-actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.users-security { margin-top: 24px; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }

.oc-layout { display: grid; grid-template-columns: 260px 1fr; height: 100%; min-height: 0; }
.oc-sidebar {
  border-right: 1px solid #e5e7eb; background: #fff; display: flex; flex-direction: column; min-height: 0; padding: 12px;
}
.oc-new-btn {
  padding: 10px; border: none; border-radius: 8px; background: #2563eb; color: #fff; font-weight: 600; cursor: pointer; font-size: 14px;
}
.oc-chat-list { flex: 1; overflow-y: auto; margin: 12px 0; display: flex; flex-direction: column; gap: 4px; }
.oc-chat-item {
  display: flex; flex-direction: column; align-items: flex-start; gap: 2px; text-align: left; padding: 8px 10px;
  border: none; background: none; border-radius: 8px; cursor: pointer; font-size: 13px; color: #111827; min-width: 0;
}
.oc-chat-item span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
.oc-chat-item:hover { background: #f3f4f6; }
.oc-chat-item.active { background: #eff6ff; }
.oc-chat-item small { font-size: 11px; }
.oc-budget { font-size: 12px; margin: 0; }
.oc-none { padding: 8px; font-size: 13px; }

.oc-main { display: flex; flex-direction: column; min-height: 0; min-width: 0; }
.oc-header {
  display: flex; align-items: center; gap: 8px; padding: 12px 16px; background: #fff; border-bottom: 1px solid #e5e7eb;
  font-size: 15px; min-width: 0;
}
.oc-header strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.oc-header .muted { font-size: 12px; flex-shrink: 0; }
.oc-back-btn { display: none; border: none; background: none; font-size: 20px; cursor: pointer; padding: 0 8px 0 0; }
.oc-messages { flex: 1; overflow-y: auto; padding: 20px; display: flex; flex-direction: column; gap: 10px; min-height: 0; }
.oc-empty { max-width: 620px; margin: auto; text-align: center; }
.oc-empty h2 { margin: 0 0 8px; }
.oc-suggestions { display: flex; flex-direction: column; gap: 8px; margin-top: 16px; }
.oc-suggestion {
  padding: 10px 12px; border: 1px solid #d1d5db; background: #fff; border-radius: 10px; cursor: pointer; font-size: 14px; text-align: left;
}
.oc-suggestion:hover { background: #f9fafb; }

.oc-msg { max-width: 80%; padding: 10px 14px; border-radius: 12px; font-size: 14px; line-height: 1.45; overflow-wrap: anywhere; }
.oc-user { align-self: flex-end; background: #2563eb; color: #fff; border-bottom-right-radius: 4px; }
.oc-assistant { align-self: flex-start; background: #fff; border: 1px solid #e5e7eb; border-bottom-left-radius: 4px; }
.oc-assistant code { background: #f3f4f6; padding: 0 4px; border-radius: 4px; font-size: 13px; }
.oc-read { align-self: flex-start; font-size: 12px; color: #6b7280; padding: 0 4px; }
.oc-read.failed { color: #b45309; }
.oc-read .oc-msg-files { margin: 4px 0 0; }
.oc-read .oc-msg-file { color: #2563eb; font-size: 14px; font-weight: 600; }

.oc-card {
  align-self: stretch; max-width: 680px; background: #fff; border: 1px solid #e5e7eb; border-left: 4px solid #9ca3af;
  border-radius: 10px; padding: 12px 14px; font-size: 13px; display: flex; flex-direction: column; gap: 8px;
}
.oc-card-pending { border-left-color: #f59e0b; box-shadow: 0 1px 6px rgba(245, 158, 11, 0.18); }
.oc-card-running { border-left-color: #2563eb; }
.oc-card-done { border-left-color: #16a34a; }
.oc-card-failed { border-left-color: #dc2626; }
.oc-card-canceled { opacity: 0.6; }
.oc-card-head { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; }
.oc-card-head strong { font-size: 14px; overflow-wrap: anywhere; }
.oc-card-status { font-size: 11px; white-space: nowrap; padding: 2px 8px; border-radius: 999px; background: #f3f4f6; color: #374151; }
.oc-card-lines { margin: 0; padding-left: 18px; color: #374151; }
.oc-card-lines li { overflow-wrap: anywhere; }
.oc-card-text, .oc-card-result pre {
  margin: 0; padding: 10px; background: #f9fafb; border: 1px solid #f3f4f6; border-radius: 8px; white-space: pre-wrap;
  overflow-wrap: anywhere; font-family: inherit; font-size: 13px; max-height: 320px; overflow-y: auto;
}
.oc-card-html { width: 100%; height: 280px; border: 1px solid #e5e7eb; border-radius: 8px; background: #fff; }
.oc-card-people summary, .oc-card-result summary { cursor: pointer; color: #2563eb; }
.oc-card-people p { margin: 6px 0 0; color: #374151; max-height: 160px; overflow-y: auto; }
.oc-card-warn { margin: 0; padding: 8px 10px; background: #fffbeb; border-radius: 6px; color: #92400e; }
.oc-card-error { margin: 0; color: #b91c1c; overflow-wrap: anywhere; }
.oc-card-actions { display: flex; gap: 8px; }
.oc-confirm, .oc-cancel { padding: 8px 18px; border-radius: 8px; font-size: 14px; font-weight: 600; cursor: pointer; }
.oc-confirm { border: none; background: #16a34a; color: #fff; }
.oc-confirm:hover { background: #15803d; }
.oc-cancel { border: 1px solid #d1d5db; background: #fff; color: #374151; }
.oc-confirm:disabled, .oc-cancel:disabled { opacity: 0.5; cursor: default; }

.oc-status { margin: 0; padding: 6px 20px; font-size: 13px; color: #1d4ed8; background: #eff6ff; }
.oc-status-error { color: #b91c1c; background: #fef2f2; }
.oc-form { padding: 10px 16px 8px; background: #fff; border-top: 1px solid #e5e7eb; }
.oc-form.oc-dragging { background: #eff6ff; outline: 2px dashed #2563eb; outline-offset: -6px; }
.oc-compose {
  display: flex; align-items: flex-end; gap: 6px; border: 1px solid #d1d5db; border-radius: 14px; padding: 6px 6px 6px 4px; background: #fff;
}
.oc-compose:focus-within { border-color: #2563eb; box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12); }
/* Começa com 3 linhas e cresce com o texto (ocAutosize em ownerChat.js limita a ~45% da tela). */
.oc-form textarea {
  flex: 1; min-width: 0; min-height: 66px; resize: none; border: none; outline: none; padding: 6px 4px; font-size: 15px;
  line-height: 1.45; font-family: inherit; background: transparent; overflow-y: hidden;
}
.oc-attach-btn {
  flex: 0 0 auto; width: 38px; height: 38px; border: none; border-radius: 10px; background: none; font-size: 18px; cursor: pointer;
}
.oc-attach-btn:hover { background: #f3f4f6; }
.oc-form #ocSendBtn {
  flex: 0 0 auto; height: 38px; padding: 0 16px; border: none; border-radius: 10px; background: #2563eb; color: #fff; font-weight: 600;
  cursor: pointer; font-size: 14px;
}
.oc-form #ocSendBtn:disabled { background: #93c5fd; cursor: default; }
.oc-hint { margin: 4px 4px 0; font-size: 11px; }
.oc-files { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.oc-file-chip {
  display: inline-flex; align-items: center; gap: 6px; max-width: 100%; padding: 4px 4px 4px 10px; border: 1px solid #dbeafe;
  background: #eff6ff; border-radius: 999px; font-size: 12px; color: #1e3a8a; overflow-wrap: anywhere;
}
.oc-file-chip small { color: #6b7280; white-space: nowrap; }
.oc-file-chip button { border: none; background: none; font-size: 16px; line-height: 1; cursor: pointer; color: #6b7280; padding: 0 6px; }
.oc-msg-files { display: flex; flex-direction: column; gap: 4px; margin-bottom: 6px; }
.oc-msg-file { color: #fff; text-decoration: underline; overflow-wrap: anywhere; font-size: 13px; }

@media (max-width: 768px) {
  /* Lista de conversas OU a conversa, como na aba Conversas */
  .oc-layout { grid-template-columns: 1fr; }
  body.oc-chat-open .oc-sidebar { display: none; }
  body:not(.oc-chat-open) .oc-main { display: none; }
  .oc-back-btn { display: block; }
  .oc-messages { padding: 12px; }
  .oc-msg { max-width: 92%; }
  .oc-form { padding: 8px 10px; }
  .oc-hint { display: none; }
}

/* ---------- Regras da IA (public/aiRules.js) ---------- */
.rules-page { padding: 20px 24px; height: 100%; display: flex; flex-direction: column; min-height: 0; }
.rules-head { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.rules-head h2 { margin: 0 0 4px; }
.rules-head p { margin: 0; max-width: 760px; font-size: 13px; }
.rules-tip { padding: 8px 12px; background: #eff6ff; border-radius: 8px; color: #1e3a8a !important; align-self: flex-start; }
.rules-layout { display: grid; grid-template-columns: 1fr 280px; gap: 16px; margin-top: 16px; flex: 1; min-height: 0; }
.rules-main { display: flex; flex-direction: column; min-height: 0; min-width: 0; background: #fff; border: 1px solid #e5e7eb; border-radius: 12px; }
.rules-toolbar { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; padding: 10px 14px; border-bottom: 1px solid #e5e7eb; }
.rules-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.rules-save-btn { padding: 4px 12px; border: none; border-radius: 6px; background: #16a34a; color: #fff; font-size: 12px; font-weight: 600; cursor: pointer; }
.rules-text, .rules-editor {
  flex: 1; min-height: 0; margin: 0; padding: 14px; overflow: auto; white-space: pre-wrap; overflow-wrap: anywhere;
  font-family: inherit; font-size: 13px; line-height: 1.55; color: #1f2937;
}
.rules-editor { border: none; outline: none; resize: none; background: #fffbeb; }
.rules-versions { background: #fff; border: 1px solid #e5e7eb; border-radius: 12px; padding: 12px; overflow-y: auto; min-height: 0; }
.rules-versions h3 { margin: 0 0 8px; font-size: 14px; }
.rules-version {
  display: flex; flex-direction: column; gap: 2px; width: 100%; text-align: left; padding: 8px 10px; margin-bottom: 4px;
  border: 1px solid transparent; background: none; border-radius: 8px; cursor: pointer; font-size: 12px; color: #111827;
}
.rules-version:hover { background: #f3f4f6; }
.rules-version.active { border-color: #bfdbfe; background: #eff6ff; }
.rules-version span { color: #374151; overflow-wrap: anywhere; }
@media (max-width: 768px) {
  .rules-page { padding: 12px; height: auto; }
  .rules-layout { grid-template-columns: 1fr; }
  .rules-text, .rules-editor { min-height: 60vh; }
  .rules-versions { max-height: 40vh; }
}

/* Financeiro (contas a receber) */
.sales-page { overflow: auto; }
.sales-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex: 0 0 auto; }
.sales-header p { margin: 0; }
.sales-primary-btn {
  padding: 9px 16px; border: none; border-radius: 8px; background: #2563eb; color: #fff;
  font-size: 14px; font-weight: 600; cursor: pointer; white-space: nowrap;
}
.sales-summary { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin: 14px 0; flex: 0 0 auto; }
.sales-card {
  display: flex; flex-direction: column; gap: 2px; text-align: left; padding: 10px 12px; cursor: pointer;
  border: 1px solid #e5e7eb; border-radius: 10px; background: #fff; font-family: inherit; color: #111827;
}
.sales-card:hover { border-color: #93c5fd; }
.sales-card.active { border-color: #2563eb; box-shadow: 0 0 0 1px #2563eb; }
.sales-card.alert strong { color: #b91c1c; }
.sales-card strong { font-size: 18px; }
.sales-card-label { font-size: 12px; font-weight: 600; color: #4b5563; }
.sales-card .muted { font-size: 11px; }
.sales-page .records-table-wrap { min-height: 240px; }
.sales-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.sales-table th {
  position: sticky; top: 0; background: #f9fafb; text-align: left; padding: 10px 10px;
  border-bottom: 1px solid #e5e7eb; white-space: nowrap; font-weight: 700; color: #374151; z-index: 1;
}
.sales-table td { padding: 8px 10px; border-bottom: 1px solid #f3f4f6; vertical-align: top; }
.sales-table tbody tr[data-id]:hover { background: #f9fafb; cursor: pointer; }
.sales-table tr.overdue td:first-child { box-shadow: inset 3px 0 0 #dc2626; }
.sales-table .sale-buyer { min-width: 200px; }
.sales-table .sale-course { min-width: 160px; }
.sales-table .muted { font-size: 11px; }
.sales-table a { color: #2563eb; }
.sales-empty { padding: 24px !important; text-align: center; }
.sale-chip { display: inline-block; font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 999px; white-space: nowrap; background: #e5e7eb; color: #374151; }
.sale-chip.waiting { background: #fef3c7; color: #92400e; }
.sale-chip.todo { background: #e0e7ff; color: #3730a3; }
.sale-chip.invoiced { background: #dbeafe; color: #1e40af; }
.sale-chip.paid { background: #dcfce7; color: #166534; }
.sale-chip.canceled { background: #f3f4f6; color: #6b7280; text-decoration: line-through; }
.sale-chip.overdue { background: #fee2e2; color: #991b1b; }

.sale-dialog { width: 640px; }
.sale-dialog h4 { margin: 18px 0 8px; font-size: 14px; }
.sale-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 12px; }
.sale-cancel-label { justify-content: center; }
.sale-cancel-label span { display: flex; align-items: center; gap: 6px; font-weight: 600; }
.sale-cancel-label input { width: auto; }
.sale-hint { font-size: 12px; font-weight: 400; }
.sale-form-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.contact-details-form .sale-secondary-btn { background: #fff; color: #2563eb; border: 1px solid #93c5fd; }
.contact-details-form .sale-danger-btn { background: #fff; color: #b91c1c; border: 1px solid #fecaca; }
.sale-docs, .sale-enrollments { display: flex; flex-direction: column; gap: 6px; font-size: 13px; }
.sale-doc-row, .sale-enrollment-row {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; padding: 6px 8px;
  border: 1px solid #e5e7eb; border-radius: 8px;
}
.sale-doc-row a { color: #2563eb; overflow-wrap: anywhere; }
.sale-doc-notes { flex-basis: 100%; font-size: 12px; }
.sale-doc-kind { font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 999px; background: #e5e7eb; }
.sale-doc-kind.empenho { background: #fef3c7; color: #92400e; }
.sale-doc-kind.nf { background: #dbeafe; color: #1e40af; }
.sale-doc-kind.pagamento { background: #dcfce7; color: #166534; }
.sale-doc-del { margin-left: auto; border: none; background: none; color: #b91c1c; font-size: 18px; cursor: pointer; line-height: 1; }
.sale-doc-form { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 10px; }
.sale-doc-form select, .sale-doc-form input[type="text"], .sale-doc-form input[type="date"] {
  padding: 8px 10px; border: 1px solid #d1d5db; border-radius: 8px; font-size: 13px; font-family: inherit;
}
.sale-doc-form input[type="file"], .sale-doc-form details, .sale-doc-form button { grid-column: 1 / -1; font-size: 13px; }
.sale-doc-form button {
  justify-self: start; padding: 9px 14px; border: none; border-radius: 8px; background: #2563eb; color: #fff; font-weight: 600; cursor: pointer;
}
.sale-doc-also summary { cursor: pointer; color: #4b5563; }
.sale-doc-also-list { display: flex; flex-direction: column; gap: 4px; padding: 6px 0 0 4px; }
.sale-fix { display: flex; gap: 6px; margin-left: auto; }
.sale-fix input { padding: 4px 8px; border: 1px solid #d1d5db; border-radius: 6px; font-size: 12px; width: 170px; }
.sale-fix button { padding: 4px 10px; border: 1px solid #93c5fd; border-radius: 6px; background: #fff; color: #2563eb; font-size: 12px; font-weight: 600; cursor: pointer; white-space: nowrap; }
.sale-close-btn { margin-top: 14px; }
.cd-sale-item {
  display: flex; flex-direction: column; gap: 4px; padding: 6px 8px; border: 1px solid #e5e7eb; border-radius: 8px;
  font-weight: 400; color: #111827; cursor: pointer;
}
.cd-sale-item:hover { background: #f9fafb; }
#cdSales { display: flex; flex-direction: column; gap: 6px; }

@media (max-width: 768px) {
  .sales-header { flex-direction: column; }
  .sales-summary { grid-template-columns: 1fr 1fr; }
  .sale-grid, .sale-doc-form { grid-template-columns: 1fr; }
  .sale-fix { margin-left: 0; width: 100%; }
  .sale-fix input { flex: 1; width: auto; }
}
.contact-details-form #cdNewSaleBtn { align-self: flex-start; background: #fff; color: #2563eb; border: 1px solid #93c5fd; padding: 7px 12px; font-size: 13px; }
.sale-warn { font-size: 12px; font-weight: 600; color: #b91c1c; }
.sales-scope { margin: 12px 0 -6px; font-size: 13px; font-weight: 600; color: #1e40af; flex: 0 0 auto; }
.fin-tabs { margin-top: 0; }
.fin-pane { display: flex; flex-direction: column; flex: 0 0 auto; }
.pay-by-category { margin: -4px 0 12px; font-size: 13px; }
.pay-speaker { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; font-size: 13px; padding: 8px 10px; background: #f9fafb; border: 1px solid #e5e7eb; border-radius: 8px; }
.contact-details-form .pay-speaker .sale-secondary-btn { padding: 5px 10px; font-size: 12px; }
.pay-speaker .sale-hint { flex-basis: 100%; }
.pay-file-current { font-size: 12px; font-weight: 400; display: flex; align-items: center; gap: 6px; }
.pay-file-current a { color: #2563eb; overflow-wrap: anywhere; }
.contact-details-form .pay-file-current .sale-doc-del { margin-left: 0; padding: 0 4px; background: none; color: #b91c1c; font-size: 18px; }
.pay-dialog h4 { margin: 6px 0 -4px; }
.pay-dialog .sale-grid > label { min-width: 0; }
.pay-dialog input[type="file"] { width: 100%; min-width: 0; font-size: 12px; padding: 6px; }
/* Financeiro > Banco Inter */
.bank-badge { background: #2563eb; }
.bank-setup { background: #fffbeb; border: 1px solid #fde68a; border-radius: 10px; padding: 12px 14px; margin: 12px 0; font-size: 13px; }
.bank-setup p { margin: 6px 0; }
.bank-setup pre { background: #fff; border: 1px solid #e5e7eb; border-radius: 6px; padding: 8px 10px; font-size: 12px; overflow-x: auto; white-space: pre-wrap; word-break: break-all; }
.bank-status-line { margin: 12px 0 0; font-size: 13px; color: #374151; flex: 0 0 auto; }
.bank-import { font-size: 12px; align-self: center; }
.bank-import summary { cursor: pointer; color: #4b5563; font-weight: 600; }
.bank-import label { flex-direction: row !important; align-items: center; gap: 6px !important; margin: 6px 0; }
.bank-table .bank-amount { white-space: nowrap; font-weight: 700; }
.bank-table .bank-amount.in { color: #15803d; }
.bank-table .bank-amount.out { color: #b91c1c; }
.bank-table .bank-suggestion { min-width: 220px; }
.bank-table .bank-actions-cell { white-space: nowrap; text-align: right; }
.bank-table tr.bank-row:hover { background: #f9fafb; }
.bank-btn { padding: 5px 10px; margin: 2px 0 2px 4px; border: 1px solid #93c5fd; border-radius: 6px; background: #fff; color: #2563eb; font-size: 12px; font-weight: 600; cursor: pointer; }
.bank-btn.primary { background: #2563eb; border-color: #2563eb; color: #fff; }
.bank-btn.ghost { border-color: #e5e7eb; color: #6b7280; }
.bank-btn:disabled { opacity: 0.6; cursor: wait; }
.bank-dialog { width: 680px; }
.bank-dialog-info { font-size: 14px; margin: 0 0 10px; padding: 10px 12px; background: #f9fafb; border-radius: 8px; }
.bank-search { width: 100%; box-sizing: border-box; padding: 8px 10px; border: 1px solid #d1d5db; border-radius: 8px; font-size: 13px; margin: 6px 0; }
.bank-pick-list { display: flex; flex-direction: column; gap: 6px; max-height: 340px; overflow-y: auto; }
.bank-pick-row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; padding: 8px 10px; border: 1px solid #e5e7eb; border-radius: 8px; font-size: 13px; cursor: pointer; }
.bank-pick-row.checked { border-color: #2563eb; background: #eff6ff; }
.bank-pick-main { display: flex; align-items: flex-start; gap: 8px; flex: 1 1 260px; min-width: 0; cursor: pointer; font-weight: 400; }
.bank-pick-main input { margin-top: 3px; }
.bank-pick-amount { white-space: nowrap; font-size: 13px; }
.bank-pick-amount input { width: 100px; padding: 5px 8px; border: 1px solid #d1d5db; border-radius: 6px; font-size: 13px; }
.bank-settle { flex-basis: 100%; font-size: 12px; color: #92400e; display: flex; align-items: center; gap: 6px; padding-left: 24px; }
.bank-alloc-total { font-size: 13px; margin: 8px 0 0; }
.bank-new-pay { margin-top: 10px; font-size: 13px; }
.bank-new-pay summary { cursor: pointer; font-weight: 600; color: #2563eb; }
.bank-new-pay .sale-grid { margin: 10px 0; }
.bank-new-pay label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; font-weight: 600; color: #374151; }
.bank-new-pay input, .bank-new-pay select { padding: 7px 9px; border: 1px solid #d1d5db; border-radius: 8px; font-size: 13px; font-family: inherit; min-width: 0; }
.bank-dialog-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.bank-dialog-actions .bank-btn { padding: 9px 14px; font-size: 13px; margin: 0; }
@media (max-width: 700px) {
  .bank-table .bank-actions-cell { white-space: normal; }
  .bank-pick-amount { padding-left: 24px; }
}
.fin-tabs { flex-wrap: wrap; }
.fin-tab-btn { white-space: nowrap; }
.bank-link-opt { flex-basis: 100%; font-size: 12px; color: #1e40af; display: flex; align-items: center; gap: 6px; padding-left: 24px; cursor: pointer; }
.bank-pick-paid { padding-left: 24px; }
.bank-invest { margin: 8px 0 0; font-size: 13px; flex: 0 0 auto; }
.bank-invest summary { cursor: pointer; }
.bank-invest-edit { color: #2563eb; font-weight: 600; margin-left: 4px; }
.bank-invest-form { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; margin-top: 8px; }
.bank-invest-form label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; font-weight: 600; color: #374151; }
.bank-invest-form input { padding: 7px 9px; border: 1px solid #d1d5db; border-radius: 8px; font-size: 13px; font-family: inherit; }
.bank-invest-form .bank-btn { padding: 8px 14px; margin: 0; }
.bank-invest-history { display: flex; flex-direction: column; gap: 4px; margin-top: 6px; max-width: 520px; }
.bank-invest-row { display: flex; gap: 12px; align-items: center; padding: 4px 0; border-bottom: 1px solid #f3f4f6; }
.bank-invest-row .sale-doc-del { margin-left: auto; }
