:root {
  --bg-main: #101623;
  --bg-card: #141d2e;
  --bg-card-alt: #162138;
  --bg-darker: #0d1421;
  --border: #2d3d59;
  --border-light: #3a4d70;
  --text-main: #e8ecf6;
  --text-muted: #94a3b8;
  --text-dim: #64748b;
  --primary: #38bdf8;
  --primary-glow: rgba(56, 189, 248, 0.35);
  --accent: #8b5cf6;
  --success: #10b981;
  --success-bg: #064e3b;
  --warning: #f59e0b;
  --danger: #ef4444;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--text-main);
  background: radial-gradient(circle at 20% 0%, #203b54 0, #101623 43%);
  min-height: 100vh;
  line-height: 1.5;
}

.container {
  max-width: 1320px;
  margin: 0 auto;
  padding: 36px 24px;
}

.eyebrow {
  letter-spacing: 0.14em;
  font-size: 0.75rem;
  color: #8ecae6;
  font-weight: 800;
  text-transform: uppercase;
}

header.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 28px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
  gap: 16px;
}

.app-title h1 {
  font-size: 1.8rem;
  margin: 2px 0 0 0;
  letter-spacing: -0.04em;
  color: #fff;
}

.user-nav {
  display: flex;
  align-items: center;
  gap: 14px;
}

.user-badge {
  background: #1e293b;
  border: 1px solid var(--border);
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 0.8rem;
  color: #cbd5e1;
}

.btn-logout {
  background: #334155;
  color: #f1f5f9;
  text-decoration: none;
  font-size: 0.8rem;
  font-weight: 700;
  padding: 6px 12px;
  border-radius: 6px;
  transition: all 0.2s;
}

.btn-logout:hover {
  background: #ef4444;
  color: #fff;
}

/* Painel de Campanhas */
.campaigns-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 18px;
  margin-top: 20px;
}

.campaign-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 22px;
  text-decoration: none;
  color: inherit;
  transition: all 0.22s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.campaign-card:hover {
  transform: translateY(-3px);
  border-color: var(--primary);
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.6), 0 0 20px var(--primary-glow);
}

.campaign-name {
  font-size: 1.15rem;
  font-weight: 700;
  color: #fff;
  margin-bottom: 8px;
  line-height: 1.35;
}

.campaign-meta {
  font-size: 0.82rem;
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 16px;
}

.campaign-stats {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 14px;
  border-top: 1px solid #1e2d42;
}

.stat-badge {
  background: #064e3b;
  color: #a7f3d0;
  border: 1px solid #10b981;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 800;
}

.stat-total {
  font-size: 0.78rem;
  color: #94a3b8;
}

.campaign-sync-date {
  font-size: 0.72rem;
  color: #64748b;
  margin-top: 8px;
  display: flex;
  align-items: center;
  gap: 4px;
}

/* Tabela de Leads */
.table-panel {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 14px 50px rgba(5, 8, 17, 0.5);
  margin-top: 18px;
}

.table-toolbar {
  padding: 16px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
  gap: 12px;
}

.table-title {
  display: flex;
  align-items: center;
  gap: 10px;
}

.table-title h2 {
  font-size: 1.25rem;
  color: #fff;
  margin: 0;
}

.table-wrap {
  overflow-x: auto;
}

table.leads-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 900px;
}

table.leads-table th {
  background: var(--bg-card-alt);
  color: #9fb0cd;
  font-size: 0.74rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 12px 14px;
  text-align: left;
  border-bottom: 1px solid #27354e;
}

table.leads-table td {
  padding: 14px;
  vertical-align: top;
  border-bottom: 1px solid #27354e;
  font-size: 0.88rem;
}

table.leads-table tr:hover td {
  background: #172338;
}

.lead-name {
  font-weight: 700;
  font-size: 0.98rem;
  color: #fff;
  margin-bottom: 4px;
}

.maps-link {
  color: #38bdf8;
  text-decoration: none;
  font-size: 0.78rem;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.maps-link:hover {
  text-decoration: underline;
}

.lead-contact {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.phone-text {
  color: #e2e8f0;
  font-weight: 600;
  font-size: 0.88rem;
}

.btn-whatsapp {
  background: #25d366;
  color: #052e16;
  text-decoration: none;
  font-weight: 900;
  font-size: 0.76rem;
  padding: 4px 10px;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  width: fit-content;
  transition: all 0.2s;
}

.btn-whatsapp:hover {
  background: #1eb954;
  transform: translateY(-1px);
}

.lead-location {
  color: #cbd5e1;
  font-size: 0.82rem;
  line-height: 1.4;
}

.lead-location strong {
  color: #f1f5f9;
  display: block;
}

.lead-website-cell {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.site-link {
  color: #68ddc5;
  text-decoration: none;
  font-weight: 700;
  font-size: 0.85rem;
  word-break: break-all;
}

.site-link:hover {
  text-decoration: underline;
}

.social-links-row {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 2px;
}

.btn-social-chip {
  background: #8b5cf6;
  color: #fff;
  text-decoration: none;
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 0.72rem;
  font-weight: 800;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.btn-social-chip:hover {
  background: #7c3aed;
}

.btn-social-chip.fb {
  background: #1877f2;
}

.btn-social-chip.fb:hover {
  background: #0d6efd;
}

.btn-add-social,
.btn-add-email {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  background: rgba(96, 165, 250, 0.08);
  color: #93c5fd;
  border: 1px dashed rgba(96, 165, 250, 0.35);
  font-size: 0.68rem;
  font-weight: 600;
  padding: 1px 6px;
  line-height: 1.25;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.2s;
  vertical-align: middle;
}

.btn-add-social:hover,
.btn-add-email:hover {
  border-style: solid;
  border-color: #60a5fa;
  background: rgba(59, 130, 246, 0.2);
  color: #ffffff;
}

.btn-mini-edit {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  color: #64748b;
  border: none;
  font-size: 0.72rem;
  cursor: pointer;
  padding: 0 3px;
  line-height: 1;
  transition: color 0.15s;
}

.btn-mini-edit:hover {
  color: #38bdf8;
}

/* Anotações */
.lead-note-box {
  background: rgba(245, 158, 11, 0.12);
  border: 1px solid rgba(245, 158, 11, 0.35);
  border-radius: 6px;
  padding: 6px 10px;
  margin-bottom: 6px;
  cursor: pointer;
  transition: all 0.2s;
}

.lead-note-box:hover {
  background: rgba(245, 158, 11, 0.22);
  border-color: rgba(245, 158, 11, 0.6);
}

.lead-note-text {
  font-size: 0.8rem;
  color: #fef08a;
  line-height: 1.35;
  word-break: break-word;
  white-space: pre-wrap;
}

.btn-add-note {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 9px;
  font-size: 0.74rem;
  font-weight: 700;
  color: #93c5fd;
  background: rgba(59, 130, 246, 0.1);
  border: 1px dashed rgba(59, 130, 246, 0.35);
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-add-note:hover {
  background: rgba(59, 130, 246, 0.22);
  color: #bfdbfe;
  border-style: solid;
}

/* Badges de Qualificação */
.badge {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 800;
  white-space: nowrap;
}
.badge.sem_site, .badge.fora_do_ar {
  background: #5b2332;
  color: #ffaab7;
  border: 1px solid #814051;
}
.badge.defasado {
  background: #5a481a;
  color: #ffdc79;
  border: 1px solid #856920;
}
.badge.saudavel {
  background: #164d42;
  color: #7ceacb;
  border: 1px solid #207262;
}
.badge.pendente {
  background: #303c59;
  color: #b8cbef;
  border: 1px solid #43547c;
}

.badges-col {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.badge-insp {
  background: #064e3b;
  color: #a7f3d0;
  border: 1px solid #10b981;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 800;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  width: fit-content;
}

.badge-audit {
  background: #581c87;
  color: #e9d5ff;
  border: 1px solid #9333ea;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 800;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  width: fit-content;
}

/* Botão Voltar */
.btn-back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #1e293b;
  color: #cbd5e1;
  text-decoration: none;
  font-size: 0.82rem;
  font-weight: 700;
  padding: 8px 14px;
  border-radius: 8px;
  border: 1px solid var(--border);
  transition: all 0.2s;
}

.btn-back:hover {
  background: #334155;
  color: #fff;
}

/* Modais */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(8, 12, 22, 0.82);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  padding: 20px;
}

.modal-overlay.active {
  display: flex;
}

.modal-card {
  background: var(--bg-card-alt);
  border-radius: 16px;
  width: 100%;
  max-width: 500px;
  padding: 24px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.85);
  color: #e8ecf6;
  position: relative;
}

/* Mini modal de redes com contorno destacado */
.modal-card.social-modal {
  max-width: 460px;
  border: 2px solid #3b82f6;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.85), 0 0 25px rgba(59, 130, 246, 0.4);
}

.modal-card.email-modal {
  max-width: 440px;
  border: 2px solid #38bdf8;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.85), 0 0 25px rgba(56, 189, 248, 0.35);
}

.modal-card.notes-modal {
  border: 2px solid #f59e0b;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.85), 0 0 25px rgba(245, 158, 11, 0.35);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.modal-header h3 {
  margin: 0;
  font-size: 1.1rem;
  color: #fff;
}

.modal-close {
  background: transparent;
  border: none;
  color: #94a3b8;
  font-size: 1.3rem;
  cursor: pointer;
  line-height: 1;
  padding: 4px;
}

.modal-close:hover {
  color: #fff;
}

.modal-body {
  margin-bottom: 20px;
}

.modal-input-group {
  margin-bottom: 14px;
}

.modal-input-group label {
  display: block;
  font-size: 0.82rem;
  font-weight: 700;
  margin-bottom: 6px;
}

.modal-input {
  width: 100%;
  padding: 10px 12px;
  background: #0f172a;
  border: 1px solid #334155;
  border-radius: 6px;
  color: #f8fafc;
  font-size: 0.9rem;
  box-sizing: border-box;
  outline: none;
  transition: border-color 0.2s;
}

.modal-input:focus {
  border-color: #38bdf8;
}

.modal-textarea {
  width: 100%;
  min-height: 110px;
  background: #0f172a;
  color: #f8fafc;
  border: 1px solid #334155;
  border-radius: 8px;
  padding: 12px;
  font-family: inherit;
  font-size: 0.9rem;
  line-height: 1.5;
  resize: vertical;
  box-sizing: border-box;
  outline: none;
  transition: border-color 0.2s;
}

.modal-textarea:focus {
  border-color: #f59e0b;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.btn-modal-cancel {
  padding: 8px 16px;
  background: transparent;
  border: 1px solid #475569;
  border-radius: 6px;
  color: #cbd5e1;
  cursor: pointer;
  font-size: 0.84rem;
}

.btn-modal-cancel:hover {
  background: #334155;
  color: #fff;
}

.btn-modal-save {
  padding: 8px 18px;
  background: #2563eb;
  border: none;
  border-radius: 6px;
  color: #ffffff;
  font-weight: 700;
  cursor: pointer;
  font-size: 0.84rem;
  transition: all 0.2s;
}

.btn-modal-save:hover {
  background: #1d4ed8;
}

.btn-modal-save.notes-save {
  background: #f59e0b;
  color: #1c1917;
  font-weight: 800;
}

.btn-modal-save.notes-save:hover {
  background: #d97706;
  color: #fff;
}

.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-muted);
}

/* CRM Stage Select & Badges */
.crm-stage-select {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  border-radius: 8px;
  padding: 6px 26px 6px 10px;
  font-size: 0.76rem;
  font-weight: 700;
  cursor: pointer;
  outline: none;
  transition: all 0.2s ease;
  background-repeat: no-repeat;
  background-position: right 8px center;
  background-size: 10px 10px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='rgba(255,255,255,0.6)' stroke-width='2'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' d='M19 9l-7 7-7-7'%3E%3C/path%3E%3C/svg%3E");
  display: inline-block;
  max-width: 100%;
}

.crm-stage-select option {
  background: #0f172a;
  color: #f8fafc;
  font-weight: 600;
  padding: 6px;
}

.stage-prospeccao {
  background-color: #1e1b4b !important;
  color: #a5b4fc !important;
  border: 1px solid #4338ca !important;
}

.stage-mensagem_enviada {
  background-color: #451a03 !important;
  color: #fcd34d !important;
  border: 1px solid #b45309 !important;
}

.stage-em_conversa {
  background-color: #082f49 !important;
  color: #7dd3fc !important;
  border: 1px solid #0284c7 !important;
}

.stage-reuniao {
  background-color: #3b0764 !important;
  color: #d8b4fe !important;
  border: 1px solid #7e22ce !important;
}

.stage-fechado {
  background-color: #064e3b !important;
  color: #6ee7b7 !important;
  border: 1px solid #059669 !important;
}

.stage-perdido {
  background-color: #450a0a !important;
  color: #fca5a5 !important;
  border: 1px solid #991b1b !important;
}

/* CRM Funnel Filter Bar in Campaign Details */
.crm-funnel-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
  align-items: center;
}

.crm-filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-muted);
  transition: all 0.2s ease;
  user-select: none;
}

.crm-filter-chip:hover {
  border-color: #475569;
  color: #fff;
}

.crm-filter-chip.active {
  box-shadow: 0 0 12px rgba(56, 189, 248, 0.25);
  border-color: #38bdf8;
  color: #fff;
}

.crm-filter-chip .chip-count {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 10px;
  font-size: 0.7rem;
  background: rgba(255, 255, 255, 0.12);
}

/* State (UF) Filter Bar on Index */
.state-filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin: 16px 0;
  padding: 12px 16px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
}

.state-filter-label {
  font-size: 0.82rem;
  font-weight: 700;
  color: #94a3b8;
  display: flex;
  align-items: center;
  gap: 6px;
  margin-right: 4px;
}

.state-chip {
  padding: 5px 12px;
  border-radius: 8px;
  font-size: 0.8rem;
  font-weight: 700;
  text-decoration: none;
  background: var(--bg-card-alt);
  border: 1px solid var(--border);
  color: #cbd5e1;
  transition: all 0.15s ease;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.state-chip:hover {
  background: #1e293b;
  border-color: #38bdf8;
  color: #fff;
}

.state-chip.active {
  background: #0369a1;
  border-color: #38bdf8;
  color: #fff;
  box-shadow: 0 0 10px rgba(56, 189, 248, 0.3);
}

.state-chip .badge-count {
  font-size: 0.7rem;
  padding: 1px 5px;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.3);
  color: #e2e8f0;
}

.activity-select {
  background: var(--bg-card-alt);
  color: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 7px 12px;
  font-size: 0.82rem;
  font-weight: 600;
  outline: none;
  cursor: pointer;
  width: 100%;
  max-width: 260px;
  transition: border-color 0.2s;
}

.activity-select:hover, .activity-select:focus {
  border-color: #38bdf8;
}

.activity-select option {
  background: #0f172a;
  color: #f8fafc;
  padding: 6px;
}

/* Gestão de Usuários */
.btn-manage-users {
  background: #1e1b4b;
  border: 1px solid #6366f1;
  color: #c7d2fe;
  text-decoration: none;
  font-size: 0.8rem;
  font-weight: 700;
  padding: 6px 12px;
  border-radius: 6px;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.btn-manage-users:hover {
  background: #4338ca;
  color: #fff;
  box-shadow: 0 0 10px rgba(99, 102, 241, 0.4);
}

.badge-role-admin {
  background: #3b0764;
  color: #d8b4fe;
  border: 1px solid #7e22ce;
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 0.72rem;
  font-weight: 700;
  display: inline-block;
}

.badge-role-user {
  background: #082f49;
  color: #7dd3fc;
  border: 1px solid #0284c7;
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 0.72rem;
  font-weight: 700;
  display: inline-block;
}

.badge-status-active {
  background: #064e3b;
  color: #6ee7b7;
  border: 1px solid #059669;
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 0.72rem;
  font-weight: 700;
  display: inline-block;
}

.badge-status-inactive {
  background: #450a0a;
  color: #fca5a5;
  border: 1px solid #991b1b;
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 0.72rem;
  font-weight: 700;
  display: inline-block;
}

.btn-action-edit {
  background: #0284c7;
  color: #fff;
  border: none;
  padding: 5px 10px;
  border-radius: 6px;
  font-size: 0.76rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.btn-action-edit:hover {
  background: #0369a1;
}

.btn-action-delete {
  background: #dc2626;
  color: #fff;
  border: none;
  padding: 5px 10px;
  border-radius: 6px;
  font-size: 0.76rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.btn-action-delete:hover {
  background: #b91c1c;
}

/* Status de Atribuição de Busca (Admin) */
.campaign-card.unassigned-campaign {
  border: 2px solid #22c55e !important;
  box-shadow: 0 0 16px rgba(34, 197, 94, 0.25) !important;
  background: linear-gradient(180deg, rgba(34, 197, 94, 0.04) 0%, var(--bg-card) 100%);
}

.campaign-card.unassigned-campaign:hover {
  border-color: #4ade80 !important;
  box-shadow: 0 0 24px rgba(74, 222, 128, 0.4) !important;
}

.badge-unassigned {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #14532d;
  color: #86efac;
  border: 1px solid #22c55e;
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 700;
  margin-bottom: 12px;
}

.campaign-sync-date {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  font-size: 0.78rem;
  color: var(--text-dim);
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px dashed rgba(255, 255, 255, 0.08);
}

.user-assignment-info {
  font-weight: 600;
  font-size: 0.78rem;
}

.user-assignment-info.assigned {
  color: #38bdf8;
}

.user-assignment-info.unassigned {
  color: #4ade80;
  font-weight: 700;
}

.campaign-assign-bar {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.assign-select {
  background: var(--bg-darker);
  border: 1px solid var(--border-light);
  color: var(--text-main);
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 0.82rem;
  font-weight: 600;
  width: 100%;
  cursor: pointer;
  outline: none;
  transition: border-color 0.2s;
}

.assign-select:focus {
  border-color: var(--primary);
}
