/* ── Reset & Base ─────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --green-600: #16a34a;
  --green-700: #15803d;
  --green-50:  #f0fdf4;
  --gray-50:   #f9fafb;
  --gray-100:  #f3f4f6;
  --gray-200:  #e5e7eb;
  --gray-400:  #9ca3af;
  --gray-600:  #4b5563;
  --gray-800:  #1f2937;
  --red-600:   #dc2626;
  --red-50:    #fef2f2;
  --yellow-400:#facc15;
  --blue-600:  #2563eb;
  --font: system-ui, -apple-system, "Segoe UI", sans-serif;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,.1), 0 1px 2px rgba(0,0,0,.06);
}

body { font-family: var(--font); background: var(--gray-50); color: var(--gray-800); min-height: 100vh; }

a { color: var(--green-600); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Navbar ──────────────────────────────────────────────────────────────── */
.navbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 32px; height: 56px;
  background: #fff; border-bottom: 1px solid var(--gray-200);
  position: sticky; top: 0; z-index: 100;
}
.navbar-brand { display: flex; align-items: center; gap: 8px; width: 100%; align-items: center;}
.brand-home { display: flex; align-items: center; gap: 8px; text-decoration: none; }
.brand-home:hover .brand-name { color: var(--green-600); text-decoration: none; }
.brand-icon { height: 28px; width: 28px; object-fit: contain; border-radius: 4px; }
.brand-name { font-weight: 700; font-size: 16px; color: var(--gray-800); }
.brand-sub { font-size: 13px; color: var(--gray-400); border-left: 1px solid var(--gray-200); padding-left: 12px; margin-left: 4px; }
.navbar-link { font-size: 14px; font-weight: 500; color: var(--gray-600); margin-right: 20px; text-align: right;  flex-grow: 1; }
.navbar-link:hover { color: var(--green-600); text-decoration: none; }
.navbar-link.active { color: var(--green-600); font-weight: 700; }
.navbar-badge {
  display: inline-block; margin-left: 8px; padding: 2px 9px;
  border-radius: 999px; font-size: 12px; font-weight: 600;
  background: #fef2f2; color: var(--red-600);
}
.navbar-user { display: flex; align-items: center; gap: 10px; }
.user-avatar { width: 32px; height: 32px; border-radius: 50%; object-fit: cover; }
.user-name { font-size: 14px; color: var(--gray-600); }

/* ── Main ────────────────────────────────────────────────────────────────── */
.main-content { max-width: 1200px; margin: 0 auto; padding: 32px 24px; }

/* ── Buttons ─────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px; border-radius: var(--radius);
  font-size: 14px; font-weight: 500; cursor: pointer;
  border: 1px solid transparent; transition: all .15s;
  text-decoration: none;
}
.btn-primary    { background: var(--green-600); color: #fff; border-color: var(--green-600); }
.btn-primary:hover { background: var(--green-700); border-color: var(--green-700); }
.btn-outline    { background: #fff; color: var(--gray-800); border-color: var(--gray-200); }
.btn-outline:hover { border-color: var(--gray-400); }
.btn-ghost      { background: transparent; color: var(--gray-600); }
.btn-ghost:hover { background: var(--gray-100); }
.btn-danger     { background: var(--red-600); color: #fff; }
.btn-danger-ghost { background: transparent; color: var(--red-600); border: none; }
.btn-danger-ghost:hover { background: var(--red-50); }
.btn-sm         { padding: 5px 12px; font-size: 13px; }

/* ── Zona de perigo ──────────────────────────────────────────────────────── */
.danger-corner { position: fixed; bottom: 16px; right: 16px; opacity: .55; transition: opacity .15s; }
.danger-corner:hover { opacity: 1; }

/* ── Page header ─────────────────────────────────────────────────────────── */
.page-header   { display: flex; align-items: center; justify-content: space-between; margin-bottom: 24px; }
.page-title    { font-size: 22px; font-weight: 700; }
.header-actions { display: flex; align-items: center; gap: 8px; }

/* ── Tabs ────────────────────────────────────────────────────────────────── */
.tabs { display: flex; gap: 2px; margin-bottom: 16px; border-bottom: 1px solid var(--gray-200); }
.tab {
  padding: 8px 16px; background: transparent; border: none; cursor: pointer;
  font-size: 14px; color: var(--gray-600); border-bottom: 2px solid transparent;
  transition: all .15s;
}
.tab:hover  { color: var(--gray-800); }
.tab.active { color: var(--green-600); border-bottom-color: var(--green-600); font-weight: 600; }
.tab-count {
  display: inline-block; min-width: 18px; margin-left: 6px;
  padding: 1px 6px; border-radius: 999px;
  background: var(--gray-100); color: var(--gray-600);
  font-size: 11px; font-weight: 600; text-align: center;
}
.tab.active .tab-count { background: var(--green-50); color: var(--green-700); }

/* ── Table ───────────────────────────────────────────────────────────────── */
.table-wrapper { overflow-x: auto; border-radius: var(--radius); border: 1px solid var(--gray-200); background: #fff; }
.leads-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.leads-table th { padding: 12px 16px; text-align: left; background: var(--gray-50); font-weight: 600; color: var(--gray-600); border-bottom: 1px solid var(--gray-200); font-size: 12px; text-transform: uppercase; letter-spacing: .05em; }
.leads-table td { padding: 12px 16px; border-bottom: 1px solid var(--gray-100); vertical-align: middle; }
.leads-table tr:last-child td { border-bottom: none; }
.leads-table tr:hover td { background: var(--gray-50); }
.td-name   { font-weight: 500; }
.td-email  { color: var(--gray-600); font-size: 13px; }
.td-anchor { max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--gray-600); font-size: 13px; }
.td-date   { color: var(--gray-400); font-size: 13px; white-space: nowrap; }
.td-actions { display: flex; gap: 6px; align-items: center; }
.sent-date { font-size: 12px; color: var(--gray-400); }
.loading-row, .empty-row { text-align: center; padding: 32px; color: var(--gray-400); }

/* ── Badges ──────────────────────────────────────────────────────────────── */
.badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.badge-pendente           { background: #fef9c3; color: #854d0e; }
.badge-enviado            { background: #dcfce7; color: #166534; }
.badge-sem_atividades,
.badge-sem-atividades     { background: var(--gray-100); color: var(--gray-600); }
.badge-erro               { background: #fee2e2; color: #991b1b; }
.badge-aguardando_mensagem,
.badge-aguardando-mensagem { background: #fff7ed; color: #9a3412; }
.badge-fonte-campanha     { background: var(--gray-100); color: var(--gray-600); }
.badge-fonte-fluxo        { background: #e0f2fe; color: #075985; }

/* ── E-mails comerciais (contexto manual) ───────────────────────────────── */
.contexto-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 10px; flex-wrap: wrap; }
.contexto-header strong { font-size: 14px; margin-left: 8px; }
.contexto-textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--gray-200);
  border-radius: var(--radius); font-family: inherit; font-size: 14px; resize: vertical;
}
.contexto-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 10px; }
.file-label { cursor: pointer; }

/* ── Alert ───────────────────────────────────────────────────────────────── */
.alert { padding: 10px 16px; border-radius: var(--radius); margin-bottom: 16px; font-size: 14px; }
.alert-error   { background: #fee2e2; color: #991b1b; }
.alert-success { background: #dcfce7; color: #166534; }

/* ── Toast ───────────────────────────────────────────────────────────────── */
#toast-container { position: fixed; bottom: 24px; right: 24px; display: flex; flex-direction: column; gap: 8px; z-index: 9999; }
.toast {
  padding: 12px 20px; border-radius: var(--radius); font-size: 14px;
  background: var(--gray-800); color: #fff;
  animation: slide-in .2s ease; box-shadow: var(--shadow);
}
.toast-success { background: var(--green-700); }
.toast-error   { background: var(--red-600); }
@keyframes slide-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

/* ── Modal ───────────────────────────────────────────────────────────────── */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.4); display: flex; align-items: center; justify-content: center; z-index: 1000; }
.modal { background: #fff; border-radius: var(--radius); padding: 28px 32px; max-width: 480px; width: 90%; box-shadow: 0 20px 40px rgba(0,0,0,.2); }
.modal-title { font-size: 16px; font-weight: 700; margin-bottom: 12px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }
#modal-message { font-size: 14px; line-height: 1.6; color: var(--gray-600); }
.regenerate-textarea {
  width: 100%; padding: 8px 12px; border: 1px solid var(--gray-200);
  border-radius: var(--radius); font-family: inherit; font-size: 14px; resize: vertical;
}

/* ── Login ───────────────────────────────────────────────────────────────── */
.login-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: var(--gray-50); }
.login-card { background: #fff; border-radius: 12px; padding: 48px 40px; text-align: center; box-shadow: var(--shadow); max-width: 380px; width: 100%; }
.login-logo  { height: 56px; width: 56px; object-fit: contain; border-radius: 8px; margin: 0 auto 12px; display: block; }
.login-title { font-size: 22px; font-weight: 700; margin-bottom: 4px; }
.login-subtitle { color: var(--gray-400); font-size: 14px; margin-bottom: 32px; }
.login-hint  { color: var(--gray-400); font-size: 12px; margin-top: 16px; }
.btn-google  {
  display: inline-flex; align-items: center; gap: 10px;
  padding: 10px 20px; border-radius: var(--radius);
  background: #fff; border: 1px solid var(--gray-200);
  font-size: 14px; font-weight: 500; color: var(--gray-800);
  cursor: pointer; transition: all .15s; text-decoration: none;
}
.btn-google:hover { border-color: var(--gray-400); box-shadow: var(--shadow); text-decoration: none; }

/* ── Card ────────────────────────────────────────────────────────────────── */
.card { background: #fff; border-radius: var(--radius); border: 1px solid var(--gray-200); padding: 20px 24px; margin-bottom: 16px; }

/* ── Detail page ─────────────────────────────────────────────────────────── */
.detail-header { display: flex; align-items: center; gap: 12px; margin-bottom: 24px; flex-wrap: wrap; }
.detail-grid   { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 16px; }
.info-row      { display: flex; justify-content: space-between; padding: 6px 0; border-bottom: 1px solid var(--gray-100); font-size: 14px; }
.info-row:last-child { border-bottom: none; }
.info-label    { color: var(--gray-400); font-size: 13px; }
.info-link     { color: var(--green-600); }
.section-title { font-size: 15px; font-weight: 700; margin-bottom: 14px; }

.activity-card  { border: 1px solid var(--gray-200); border-radius: var(--radius); padding: 12px 16px; margin-bottom: 8px; }
.activity-anchor { border-left: 3px solid var(--green-600); }
.activity-aux    { border-left: 3px solid var(--gray-200); }
.activity-badge  { display: inline-block; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--green-700); background: var(--green-50); padding: 2px 8px; border-radius: 4px; margin-bottom: 4px; }
.aux-badge       { color: var(--gray-600); background: var(--gray-100); }
.activity-weight { font-size: 12px; color: var(--gray-400); float: right; margin-top: -22px; }
.activity-title  { font-size: 14px; font-weight: 500; margin: 4px 0; }
.activity-meta   { font-size: 12px; color: var(--gray-400); }

.message-header  { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; flex-wrap: wrap; gap: 8px; }
.message-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.subject-row  { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.subject-input {
  flex: 1; padding: 8px 12px; border: 1px solid var(--gray-200);
  border-radius: var(--radius); font-family: inherit; font-size: 14px;
}
.subject-input[readonly] { background: var(--gray-50); color: var(--gray-600); }
#editor-container { min-height: 280px; font-size: 14px; }
#editor-container .ql-editor p { margin-bottom: 1em; }
#editor-container .ql-editor p:last-child { margin-bottom: 0; }

.sent-info { display: flex; align-items: center; gap: 8px; font-size: 14px; }

.whatsapp-result { background: var(--gray-50); border-radius: var(--radius); padding: 16px; font-size: 14px; line-height: 1.7; white-space: pre-wrap; min-height: 80px; }

/* ── Spinner ─────────────────────────────────────────────────────────────── */
@keyframes spin { to { transform: rotate(360deg); } }
.spinner-icon { display: none; width: 14px; height: 14px; border: 2px solid rgba(255,255,255,.35); border-top-color: #fff; border-radius: 50%; flex-shrink: 0; }
.scanning .spinner-icon { display: block; animation: spin .65s linear infinite; }
.scanning .btn-text { opacity: .7; }
.td-deal-title  { font-size: 12px; color: var(--gray-400); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 220px; }
.td-anchor-title { font-size: 13px; color: var(--gray-800); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 200px; }
.td-anchor-meta  { font-size: 12px; color: var(--gray-400); margin-top: 2px; }
.td-empty { color: var(--gray-400); }

/* ── Progress bar ─────────────────────────────────────────────────────────── */
.scan-progress-wrap {
  display: flex; align-items: center; gap: 12px;
  margin-bottom: 16px; padding: 10px 14px;
  background: #fff; border: 1px solid var(--gray-200); border-radius: var(--radius);
}
.scan-progress-bar {
  flex: 1; height: 8px; background: var(--gray-100); border-radius: 999px; overflow: hidden;
}
.scan-progress-fill {
  height: 100%; background: var(--green-600); border-radius: 999px;
  transition: width .4s ease; width: 0%;
}
.scan-progress-label { font-size: 13px; color: var(--gray-600); white-space: nowrap; }

/* ── Btn-link (nome clicável na tabela) ───────────────────────────────────── */
.btn-link {
  background: none; border: none; padding: 0; cursor: pointer;
  color: var(--green-600); font-size: 14px; font-weight: 500; text-align: left;
}
.btn-link:hover { text-decoration: underline; }

/* ── Modal wide ───────────────────────────────────────────────────────────── */
.modal-wide { max-width: 560px; }
.act-modal-email { font-size: 13px; color: var(--gray-400); margin-top: 2px; }
