:root {
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  /* Cores primárias */
  --primary: #e11d48;
  --primary-dark: #be123c;
  --primary-soft: #ffe4e6;
  --success: #0f7b55;
  --warning: #a15c07;
  --danger: #b42318;
  --shadow: 0 14px 34px rgba(0, 0, 0, 0.1);
  --shadow-soft: 0 6px 16px rgba(0, 0, 0, 0.07);
}

/* ===== TEMA CLARO (padrão) ===== */
:root,
[data-theme="light"] {
  color-scheme: light;
  --bg: #f5f5f5;
  --surface: #ffffff;
  --surface-muted: #fafafa;
  --surface-strong: #0a0a0a;
  --text: #111111;
  --muted: #6b7280;
  --line: #e5e7eb;
  --line-strong: #d1d5db;
  --sidebar-bg: linear-gradient(180deg, #171321 0%, #0c0a12 56%, #050408 100%);
  --input-bg: #ffffff;
  --card-strong: #0c0a12;
}

/* ===== TEMA ESCURO ===== */
[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0a0a0a;
  --surface: #1a1a1a;
  --surface-muted: #141414;
  --surface-strong: #f1f5f9;
  --text: #f1f5f9;
  --muted: #9ca3af;
  --line: #262626;
  --line-strong: #333333;
  --sidebar-bg: linear-gradient(180deg, #0f0f0f 0%, #080808 100%);
  --input-bg: #1f1f1f;
  --card-strong: #f1f5f9;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
  margin: 0;
}

body {
  background: var(--bg);
  color: var(--text);
  transition: background 0.25s, color 0.25s;
}

[data-theme="light"] body {
  background: linear-gradient(180deg, #ffffff 0, var(--bg) 320px), var(--bg);
}

button,
input,
select {
  font: inherit;
}

button {
  border: 0;
}

.app-shell {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 24px;
  padding: 22px;
  background: var(--sidebar-bg);
  color: #fff;
  transition: background 0.25s;
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-bottom: 18px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.brand-crm {
  font-size: 11px;
  font-weight: 800;
  color: #e11d48;
  letter-spacing: 2px;
  text-transform: uppercase;
  padding: 3px 7px;
  border: 1px solid rgba(225,29,72,0.35);
  border-radius: 4px;
  background: rgba(225,29,72,0.08);
  flex-shrink: 0;
}

.brand-mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: linear-gradient(135deg, #f43f5e, #be123c);
  font-weight: 800;
  box-shadow: 0 12px 28px rgba(225, 29, 72, 0.35);
}

/* ==================== AVIX LOGO ==================== */

.avix-logo {
  color: #fff;
  display: block;
}

.avix-logo-sm {
  width: 38px;
  height: 38px;
  flex-shrink: 0;
}

.sidebar-logo {
  width: 170px;
  height: auto;
  object-fit: contain;
  filter: brightness(0) invert(1);
}

.avix-logo-lg {
  width: 200px;
  height: auto;
  margin: 0 auto 18px;
}

.brand strong,
.brand span {
  display: block;
}

.brand span,
.sidebar-card small,
.sidebar-card span {
  color: #c9c0d9;
}

.nav-menu {
  display: grid;
  gap: 8px;
}

.nav-link {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border-radius: 8px;
  background: transparent;
  color: #ded7eb;
  cursor: pointer;
  text-align: left;
  transition: background 0.18s ease, color 0.18s ease;
}

.nav-link:hover,
.nav-link.active {
  background: rgba(225, 29, 72, 0.18);
  color: #fff;
}

.nav-icon {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.07);
  color: #fda4af;
  font-size: 12px;
  font-weight: 700;
}

.sidebar-card {
  margin-top: auto;
  display: grid;
  gap: 8px;
  padding: 14px;
  border-radius: 8px;
  border: 1px solid rgba(225, 29, 72, 0.2);
  background: rgba(225, 29, 72, 0.07);
}

.sidebar-card strong {
  font-size: 15px;
}

.workspace {
  min-width: 0;
  display: grid;
  align-content: start;
  gap: 18px;
  padding: 22px;
}

.topbar,
.panel,
.kpi-card,
.mini-card {
  border: 1px solid var(--line);
  background: var(--surface);
  box-shadow: var(--shadow-soft);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 18px 22px;
  border-radius: 12px;
  background: var(--surface);
}

.topbar-verse {
  flex: 1;
  padding: 0 24px;
  text-align: center;
  opacity: 0;
  animation: fade-in-up 0.5s 0.4s forwards;
}

.topbar-verse p {
  margin: 0 0 4px;
  font-size: 13px;
  color: var(--muted);
}

.topbar-verse strong {
  font-size: 12px;
  color: var(--muted);
}

.eyebrow {
  display: block;
  margin-bottom: 4px;
  color: var(--primary);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: 28px;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 4px;
  font-size: 20px;
}

h3 {
  margin-bottom: 4px;
  font-size: 16px;
}

p {
  color: var(--muted);
  line-height: 1.5;
}

.topbar-actions,
.actions-row,
.table-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.primary-btn,
.ghost-btn {
  min-height: 40px;
  padding: 0 14px;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 700;
}

.primary-btn {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #fff;
  box-shadow: 0 10px 20px rgba(225, 29, 72, 0.25);
}

.primary-btn:hover {
  background: linear-gradient(135deg, #f43f5e, #9f1239);
}

.ghost-btn {
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--text);
}

.ghost-btn:hover {
  border-color: var(--primary);
  background: var(--primary-soft);
  color: var(--primary-dark);
}

.tab-panel {
  display: none;
  gap: 18px;
}

.tab-panel.active {
  display: grid;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(150px, 1fr));
  gap: 12px;
}

.kpi-card,
.mini-card {
  display: grid;
  gap: 8px;
  min-height: 124px;
  padding: 18px;
  border-radius: 12px;
  transition: transform 0.16s ease, box-shadow 0.16s ease, border-color 0.16s ease;
  position: relative;
  overflow: hidden;
}

.kpi-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--primary), transparent);
  opacity: 0;
  transition: opacity 0.2s;
}

.kpi-card:hover::before {
  opacity: 1;
}

.kpi-card:hover,
.mini-card:hover {
  transform: translateY(-3px);
  border-color: var(--primary);
  box-shadow: 0 0 0 1px rgba(225,29,72,0.2), 0 16px 32px rgba(225,29,72,0.12);
}

.kpi-card span,
.mini-card span,
.lead-card small,
.kanban-card small,
.history-card small {
  color: var(--muted);
}

.kpi-card strong {
  font-size: 30px;
  letter-spacing: 0;
  color: #0c0a12;
}

.kpi-card small {
  color: var(--muted);
}

.dashboard-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(320px, 0.8fr);
  gap: 18px;
}

.wide-panel {
  grid-column: 1 / -1;
}

.panel {
  min-width: 0;
  padding: 18px;
  border-radius: 8px;
}

.panel-heading {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 16px;
}

.panel-heading p {
  margin-bottom: 0;
}

.badge,
.lead-chip,
.stage-chip {
  display: inline-flex;
  align-items: center;
  width: max-content;
  max-width: 100%;
  min-height: 28px;
  padding: 0 9px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--primary-soft);
  color: var(--primary-dark);
  font-size: 12px;
  font-weight: 800;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

label {
  display: grid;
  gap: 7px;
  color: #344054;
  font-size: 14px;
  font-weight: 700;
}

input,
select {
  width: 100%;
  min-height: 42px;
  padding: 0 12px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--input-bg, var(--surface));
  color: var(--text);
}

input:focus,
select:focus {
  outline: 3px solid rgba(225, 29, 72, 0.18);
  border-color: var(--primary);
}

.helper-text {
  color: var(--muted);
  font-size: 14px;
}

.alert {
  margin-top: 14px;
  padding: 12px;
  border-radius: 8px;
  border: 1px solid #fde68a;
  background: #fffbeb;
  color: #92400e;
  font-weight: 700;
}

.hidden {
  display: none;
}

.mini-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.mini-card strong {
  font-size: 28px;
}

.funnel-bars,
.company-list,
.priority-list,
.history-list,
.leads-table {
  display: grid;
  gap: 10px;
}

.funnel-bar {
  display: grid;
  gap: 8px;
  animation: fade-up 0.5s cubic-bezier(0.22,1,0.36,1) both;
}

@keyframes fade-up {
  from { opacity:0; transform:translateY(8px); }
  to   { opacity:1; transform:translateY(0); }
}

.funnel-bar header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

.funnel-count {
  font-size: 12px;
  font-weight: 700;
  color: var(--primary);
  background: rgba(225,29,72,0.1);
  border: 1px solid rgba(225,29,72,0.2);
  padding: 1px 8px;
  border-radius: 999px;
}

.bar {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(225,29,72,0.08);
  position: relative;
}

.bar::before {
  content: '';
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(90deg, rgba(255,255,255,0.02) 0px, rgba(255,255,255,0.02) 1px, transparent 1px, transparent 24px);
}

.bar span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #be123c, #e11d48, #f43f5e);
  box-shadow: 0 0 12px rgba(225,29,72,0.55), 0 0 24px rgba(225,29,72,0.25);
  animation: bar-expand 0.7s cubic-bezier(0.22,1,0.36,1) both;
  transform-origin: left;
}

@keyframes bar-expand {
  from { transform: scaleX(0); }
  to   { transform: scaleX(1); }
}

.score-chart {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  align-items: end;
  gap: 10px;
  min-height: 200px;
  padding: 16px 12px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-muted);
  position: relative;
  overflow: hidden;
}

.score-chart::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(225,29,72,0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(225,29,72,0.04) 1px, transparent 1px);
  background-size: 28px 28px;
  pointer-events: none;
}

.score-chart::after {
  content: '';
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(225,29,72,0.4), transparent);
}

.score-column {
  display: grid;
  align-content: end;
  gap: 6px;
  min-height: 160px;
  text-align: center;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  position: relative;
  z-index: 1;
  animation: fade-up 0.5s cubic-bezier(0.22,1,0.36,1) both;
}

.score-column i {
  display: block;
  min-height: 12px;
  border-radius: 4px 4px 2px 2px;
  animation: col-rise 0.6s cubic-bezier(0.22,1,0.36,1) both;
  transform-origin: bottom;
}

.score-bar-high {
  background: linear-gradient(180deg, #ff4d6d, #e11d48, #be123c);
  box-shadow: 0 0 20px rgba(225,29,72,0.8), 0 0 40px rgba(225,29,72,0.4);
}

.score-bar-mid {
  background: linear-gradient(180deg, #fb7185, #e11d48, #9f1239);
  box-shadow: 0 0 12px rgba(225,29,72,0.5), 0 0 24px rgba(225,29,72,0.25);
}

.score-bar-low {
  background: linear-gradient(180deg, #fda4af, #be123c);
  box-shadow: 0 0 8px rgba(225,29,72,0.3);
}

@keyframes col-rise {
  from { transform: scaleY(0); opacity: 0; }
  to   { transform: scaleY(1); opacity: 1; }
}

.lead-card,
.priority-card,
.history-card,
.lead-row,
.kanban-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.lead-card,
.priority-card,
.history-card {
  display: grid;
  gap: 12px;
  padding: 14px;
}

.lead-card:hover,
.priority-card:hover,
.lead-row:hover,
.kanban-card:hover {
  border-color: var(--primary);
  box-shadow: 0 6px 16px rgba(245, 158, 11, 0.1);
}

.lead-header,
.priority-card header,
.history-card header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

.lead-meta,
.lead-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.lead-actions button {
  min-height: 34px;
  padding: 0 10px;
  border-radius: 8px;
  border: 1px solid var(--line-strong);
  background: #fff;
  cursor: pointer;
  color: #344054;
  font-weight: 700;
}

.lead-actions button:hover {
  border-color: var(--primary);
  background: var(--primary-soft);
  color: var(--primary-dark);
}

.analysis-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.analysis-list ul {
  margin: 6px 0 0;
  padding-left: 18px;
  color: var(--muted);
}

.kanban-panel {
  overflow: hidden;
}

.kanban-board {
  display: flex;
  gap: 12px;
  min-height: 620px;
  overflow-x: auto;
  padding-bottom: 12px;
}

.kanban-column {
  flex: 0 0 286px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-muted);
}

.kanban-column.drag-over {
  outline: 3px solid rgba(245, 158, 11, 0.2);
  border-color: var(--primary);
}

.kanban-column-header {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
}

.kanban-column-header h3 {
  margin: 0;
}

.kanban-cards {
  display: grid;
  align-content: start;
  gap: 10px;
  min-height: 520px;
}

.kanban-card {
  display: grid;
  gap: 10px;
  padding: 12px;
  cursor: grab;
}

.kanban-card.dragging {
  opacity: 0.45;
}

.card-value {
  color: var(--primary-dark);
  font-weight: 800;
}

.table-actions {
  display: grid;
  grid-template-columns: minmax(240px, 1fr) 220px;
  margin-bottom: 14px;
}

.lead-row {
  display: grid;
  grid-template-columns: minmax(200px, 1.5fr) 70px 110px 150px 200px 64px;
  gap: 12px;
  align-items: center;
  padding: 12px;
}

.lead-row div {
  min-width: 0;
}

.lead-row small,
.lead-row span,
.lead-row strong {
  overflow-wrap: anywhere;
}

.empty-state {
  padding: 18px;
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  background: var(--surface-muted);
  color: var(--muted);
  text-align: center;
}

/* ==================== MODAL ==================== */

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(12, 10, 18, 0.55);
  backdrop-filter: blur(4px);
  padding: 16px;
}

.modal-backdrop.hidden {
  display: none;
}

.modal {
  width: 100%;
  max-width: 760px;
  max-height: 92vh;
  overflow-y: auto;
  border-radius: 12px;
  background: var(--surface);
  box-shadow: 0 32px 80px rgba(0, 0, 0, 0.35);
  border: 1px solid var(--line);
}

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

.modal-header h2 {
  margin: 0;
}

.modal-close {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--surface);
  cursor: pointer;
  font-size: 20px;
  color: var(--muted);
}

.modal-close:hover {
  background: var(--surface-muted);
  color: var(--text);
}

.modal-form {
  display: grid;
  gap: 16px;
  padding: 20px 24px;
}

.form-grid-3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--input-bg, var(--surface));
  color: var(--text);
  font: inherit;
  resize: vertical;
  min-height: 64px;
}

textarea:focus {
  outline: 3px solid rgba(225, 29, 72, 0.16);
  border-color: var(--primary);
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding-top: 8px;
  border-top: 1px solid var(--line);
  margin-top: 4px;
}

/* ==================== DANGER BTN ==================== */

.btn-danger {
  border-color: #fca5a5 !important;
  color: var(--danger) !important;
}

.btn-danger:hover {
  background: #fff1f0 !important;
  border-color: var(--danger) !important;
}

.btn-danger-sm,
.icon-btn {
  min-height: 28px;
  padding: 0 8px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: #fff;
  cursor: pointer;
  font-size: 13px;
}

.btn-danger-sm:hover {
  background: #fff1f0;
  border-color: var(--danger);
}

/* ==================== WHATSAPP BUTTONS ==================== */

.btn-whatsapp {
  min-height: 28px;
  padding: 0 8px;
  border-radius: 6px;
  border: 1px solid #25d366;
  background: #f0fdf4;
  color: #15803d;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  transition: background .15s;
}
.btn-whatsapp:hover { background: #dcfce7; }

.btn-whatsapp-row {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 20px;
  border: 1px solid #25d366;
  background: #f0fdf4;
  color: #15803d;
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: background .15s;
}
.btn-whatsapp-row:hover { background: #dcfce7; }

/* lead sem número → visual "buscar" */
.btn-whatsapp-row[title^="Sem"] {
  border-color: var(--line);
  background: var(--surface);
  color: var(--muted);
}

/* ==================== KANBAN CARD ACTIONS ==================== */

.kanban-card-actions {
  display: flex;
  gap: 6px;
  justify-content: flex-end;
  flex-wrap: wrap;
}

/* ==================== ROW ACTIONS ==================== */

.lead-row-override {
  display: none; /* removido — resolvido acima */
}

.row-actions {
  display: flex;
  gap: 4px;
  align-items: center;
}

/* ==================== ALERT SUCCESS ==================== */

.alert-success {
  border-color: #86efac !important;
  background: #f0fdf4 !important;
  color: #166534 !important;
}

/* ==================== GHOST BTN ==================== */

.ghost-btn {
  min-height: 40px;
  padding: 0 14px;
  border-radius: 8px;
  border: 1px solid var(--line-strong);
  background: #fff;
  color: var(--text);
  cursor: pointer;
  font-weight: 700;
}

.ghost-btn:hover {
  border-color: var(--primary);
  background: var(--primary-soft);
  color: #92400e;
}

/* ==================== RESPONSIVE MODAL ==================== */

@media (max-width: 820px) {
  .form-grid-3 {
    grid-template-columns: 1fr;
  }

  .modal-form {
    padding: 16px;
  }
}

::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  border-radius: 999px;
  background: #b8c2d2;
}

@media (max-width: 1180px) {
  .kpi-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .dashboard-layout,
  .form-grid,
  .analysis-list {
    grid-template-columns: 1fr;
  }

  .lead-row {
    grid-template-columns: 1fr 70px 110px;
  }
}

/* ==================== CNPJ LOOKUP ==================== */

.cnpj-lookup-row {
  padding: 14px;
  border-radius: 8px;
  border: 1px solid #fde68a;
  background: #fffbeb;
  display: grid;
  gap: 6px;
}

.cnpj-hint {
  margin: 0;
  font-size: 12px;
  font-weight: 400;
  color: var(--muted);
}

/* ==================== AI CHAT ==================== */

.ai-fab {
  position: fixed;
  bottom: 28px;
  right: 28px;
  z-index: 150;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #000;
  font-size: 24px;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(245, 158, 11, 0.4);
  transition: transform 0.18s ease, box-shadow 0.18s ease;
  display: grid;
  place-items: center;
}

.ai-fab:hover {
  transform: scale(1.1);
  box-shadow: 0 12px 32px rgba(245, 158, 11, 0.55);
}

.ai-panel {
  position: fixed;
  bottom: 96px;
  right: 28px;
  z-index: 150;
  width: 360px;
  max-height: 520px;
  display: flex;
  flex-direction: column;
  border-radius: 16px;
  background: #fff;
  border: 1px solid var(--line);
  box-shadow: 0 24px 64px rgba(12, 10, 18, 0.2);
  overflow: hidden;
}

.ai-panel.hidden {
  display: none;
}

.ai-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 16px;
  background: linear-gradient(90deg, #0c0a12, #1a0f2e);
  color: #fff;
}

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

.ai-title strong {
  font-size: 15px;
}

.ai-title small {
  color: #c9c0d9;
  font-size: 12px;
}

.ai-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #4ade80;
  animation: ai-pulse 2s infinite;
}

@keyframes ai-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

.ai-header .modal-close {
  background: rgba(255,255,255,0.1);
  border-color: rgba(255,255,255,0.2);
  color: #c9c0d9;
}

.ai-messages {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: #f9f8fc;
}

.ai-msg {
  max-width: 88%;
  padding: 10px 13px;
  border-radius: 12px;
  font-size: 14px;
  line-height: 1.5;
}

.ai-msg-bot {
  align-self: flex-start;
  background: #fff;
  border: 1px solid var(--line);
  border-bottom-left-radius: 4px;
  color: var(--text);
}

.ai-msg-user {
  align-self: flex-end;
  background: var(--primary);
  color: #000;
  border-bottom-right-radius: 4px;
}

.ai-typing {
  opacity: 0.5;
  font-style: italic;
}

.ai-input-row {
  display: flex;
  gap: 8px;
  padding: 12px;
  border-top: 1px solid var(--line);
  background: #fff;
}

.ai-input-row input {
  flex: 1;
  min-height: 36px;
  font-size: 14px;
}

.ai-input-row .primary-btn {
  min-height: 36px;
  padding: 0 14px;
  font-size: 16px;
}

/* ==================== LOGIN SCREEN ==================== */

.login-screen {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  overflow: hidden;
}
.login-screen.hidden { display: none; }

@keyframes fade-in-up {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

.login-screen.hidden { display: none; }

/* ---- PAINEL ESQUERDO ---- */
.login-left {
  flex: 1;
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: center;
  background: #0a0a0a;
  overflow: hidden;
  padding: 60px 64px;
}

.login-left-inner {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  max-width: 580px;
  gap: 0;
}

.login-left-inner > * {
  opacity: 0;
}

.login-left-inner > .animated {
  animation: fade-in-up 0.6s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

.login-logo-left {
  display: none; /* Mantido como none, conforme solicitado anteriormente */
}

.login-headline {
  margin: 0 0 20px;
  font-size: 84px;
  font-weight: 700;
  line-height: 1.1;
  color: #fff;
}

.login-headline-white { color: #ffffff; }
.login-headline-gold  { color: #be123c; }

.login-tagline {
  margin: 0 0 64px;
  font-size: 18px;
  max-width: 480px;
  color: #6b7280;
  line-height: 1.6;
}

.login-features {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.login-feature {
  display: flex;
  align-items: flex-start;
  gap: 18px;
}

.login-feature-icon {
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  border-radius: 10px;
  background: rgba(225,29,72,0.08);
  border: 1px solid rgba(225,29,72,0.16);
  display: grid;
  place-items: center;
  color: #e11d48;
}

.login-feature-text {
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding-top: 2px;
}

.login-feature-text strong {
  font-size: 14px;
  font-weight: 700;
  color: #e5e7eb;
}

.login-feature-text span {
  font-size: 13px;
  color: #4b5563;
  line-height: 1.5;
}

/* Decoração avermelhada */
.login-wave-decoration {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 340px;
  pointer-events: none;
  z-index: 1;
  overflow: hidden;
}

.login-wave-orb {
  position: absolute;
  bottom: -140px;
  left: -80px;
  width: 560px;
  height: 380px;
  border-radius: 50%;
  background: radial-gradient(ellipse at 38% 58%,
    rgba(225,29,72,0.35) 0%,
    rgba(190,18,60,0.18) 40%,
    transparent 70%);
  filter: blur(40px);
}

/* ---- PAINEL DIREITO ---- */
.login-right {
  width: 620px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: #0d0d0d;
  padding: 40px 40px 32px;
  gap: 0;
}

/* Card flutuante que contém o formulário */
.login-box {
  width: 100%;
  max-width: 460px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
  padding: 40px 36px 36px;
  background: #1a1a1a;
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 20px;
  box-shadow: 0 24px 64px rgba(0,0,0,0.6);
  opacity: 0;
}

.login-box.animated {
  animation: fade-in-up 0.6s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

@keyframes login-rise {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}
.login-welcome { animation-delay: 0.1s !important; }
.login-features { animation-delay: 0.4s !important; }
.login-box { animation-delay: 0.2s !important; }
}

.login-lock-wrap {
  margin-bottom: 20px;
}

.login-lock-icon {
  width: 54px;
  height: 54px;
  border-radius: 14px;
  background: rgba(225,29,72,0.12);
  border: 1px solid rgba(225,29,72,0.22);
  display: grid;
  place-items: center;
  color: #e11d48;
}

.login-box-title {
  margin: 0 0 8px;
  font-size: 24px;
  font-weight: 700;
  color: #fff;
  text-align: center;
}

.login-box-subtitle {
  margin: 0 0 28px;
  font-size: 13px;
  color: #6b7280;
  text-align: center;
}

.login-footer-text {
  margin: 20px 0 0;
  font-size: 12px;
  color: #374151;
  text-align: center;
}

/* ---- USER LIST ---- */
.user-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: 100%;
  margin-bottom: 8px;
}

.user-list-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 16px;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.06);
  background: rgba(255,255,255,0.03);
  color: #d1d5db;
  cursor: pointer;
  text-align: left;
  font-size: 14px;
  font-weight: 500;
  transition: all 0.15s ease;
  width: 100%;
}

.user-list-item:hover {
  background: rgba(225,29,72,0.09);
  border-color: rgba(225,29,72,0.25);
  color: #fff;
}

.user-list-item.selected {
  background: rgba(225,29,72,0.12);
  border-color: rgba(225,29,72,0.45);
  color: #fff;
}

.user-list-item span {
  flex: 1;
}

.user-list-arrow {
  opacity: 0.35;
  transition: opacity 0.15s, transform 0.15s;
}

.user-list-item:hover .user-list-arrow {
  opacity: 0.8;
  transform: translateX(3px);
}

/* Avatar lateral (sidebar) */
.user-avatar {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 13px;
  color: #fff;
  flex-shrink: 0;
}

/* ---- PIN SECTION ---- */
.pin-section {
  flex-direction: column;
  align-items: center;
  gap: 12px;
  animation: login-rise 0.3s ease;
  width: 100%;
}

.pin-section:not(.hidden) {
  display: flex;
}

.pin-user-info {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 20px;
  border-radius: 50px;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.1);
  margin-bottom: 4px;
}

.pin-user-info .user-avatar {
  width: 32px;
  height: 32px;
  font-size: 11px;
}

.pin-user-info-name {
  font-size: 14px;
  font-weight: 700;
  color: #fff;
}

.pin-label {
  color: #6b7280;
  margin: 0;
  font-size: 13px;
}

.pin-input-row {
  width: 100%;
}

.pin-input-row input {
  width: 100%;
  text-align: center;
  font-size: 26px;
  letter-spacing: 12px;
  padding: 14px 12px;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 12px;
  color: #fff;
  transition: border-color 0.18s, background 0.18s;
}

.pin-input-row input:focus {
  background: rgba(225,29,72,0.07);
  border-color: #e11d48;
  outline: none;
  box-shadow: 0 0 0 3px rgba(225,29,72,0.15);
}

.login-enter-btn {
  width: 100%;
  min-height: 48px;
  border-radius: 10px;
  background: linear-gradient(135deg, #e11d48, #be123c);
  color: #fff;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  border: none;
  box-shadow: 0 8px 24px rgba(225,29,72,0.35);
  transition: all 0.18s ease;
  letter-spacing: 0.3px;
}

.login-enter-btn:hover {
  background: linear-gradient(135deg, #f43f5e, #9f1239);
  box-shadow: 0 12px 32px rgba(225,29,72,0.5);
  transform: translateY(-1px);
}

.pin-error {
  color: #fca5a5;
  margin: 0;
  font-size: 13px;
  font-weight: 600;
  background: rgba(180,35,24,0.12);
  border: 1px solid rgba(180,35,24,0.25);
  padding: 8px 16px;
  border-radius: 8px;
  width: 100%;
  text-align: center;
}

.pin-back {
  background: none !important;
  border: none !important;
  color: #4b5563 !important;
  font-size: 13px !important;
  cursor: pointer;
  padding: 4px 8px !important;
  min-height: unset !important;
  transition: color 0.15s;
}

.pin-back:hover {
  color: #9ca3af !important;
  background: none !important;
}

/* ---- TEMA ESCURO — overrides ---- */
[data-theme="dark"] .topbar {
  background: var(--surface);
  border-color: var(--line);
}
[data-theme="dark"] .panel,
[data-theme="dark"] .kpi-card,
[data-theme="dark"] .mini-card {
  background: var(--surface);
  border-color: var(--line);
}
[data-theme="dark"] .lead-card,
[data-theme="dark"] .priority-card,
[data-theme="dark"] .history-card,
[data-theme="dark"] .lead-row,
[data-theme="dark"] .kanban-card {
  background: var(--surface);
  border-color: var(--line);
}
[data-theme="dark"] .kanban-column {
  background: var(--surface-muted);
  border-color: var(--line);
}
[data-theme="dark"] .score-chart {
  background: var(--surface-muted);
  border-color: var(--line);
}
[data-theme="dark"] .ai-panel {
  background: var(--surface);
  border-color: var(--line);
}
[data-theme="dark"] .ai-messages {
  background: var(--surface-muted);
}
[data-theme="dark"] .ai-msg-bot {
  background: var(--surface);
  border-color: var(--line);
  color: var(--text);
}
[data-theme="dark"] .ai-input-row {
  background: var(--surface);
  border-color: var(--line);
}
[data-theme="dark"] label {
  color: #e5e7eb;
}
[data-theme="dark"] .kpi-card strong {
  color: var(--text);
}
[data-theme="dark"] .funnel-bar header {
  color: #e5e7eb;
}
[data-theme="dark"] .bar {
  background: #2a2a2a;
}
[data-theme="dark"] .empty-state {
  background: var(--surface-muted);
  border-color: var(--line);
  color: var(--muted);
}
[data-theme="dark"] .cnpj-lookup-row {
  background: #1f1a1c;
  border-color: rgba(225,29,72,0.2);
}
[data-theme="dark"] .alert {
  background: #1f1a1c;
  border-color: rgba(225,29,72,0.25);
  color: #fda4af;
}
[data-theme="dark"] .modal-header {
  border-color: var(--line);
}
[data-theme="dark"] .modal-footer {
  border-color: var(--line);
}
[data-theme="dark"] h2, [data-theme="dark"] h3, [data-theme="dark"] p {
  color: inherit;
}
[data-theme="dark"] .ghost-btn {
  background: var(--surface);
  border-color: var(--line-strong);
  color: var(--text);
}
[data-theme="dark"] .lead-actions button {
  background: var(--surface);
  border-color: var(--line-strong);
  color: #e5e7eb;
}

/* ---- BOTÃO TEMA ---- */
.theme-toggle-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-radius: 8px;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.1);
  color: #9ca3af;
  cursor: pointer;
  font-weight: 600;
  font-size: 13px;
  width: 100%;
  transition: background 0.15s;
}

.theme-toggle-btn:hover {
  background: rgba(255,255,255,0.09);
  color: #fff;
}

/* ---- MOBILE LOGIN ---- */
@media (max-width: 860px) {
  .login-left {
    display: none;
  }
  .login-right {
    width: 100%;
    padding: 32px 24px;
  }
}

@media (max-width: 480px) {
  .login-right {
    padding: 24px 16px;
  }
  .user-btn { width: 68px; }
}

/* ==================== USER BAR (SIDEBAR) ==================== */

.current-user-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.12);
  font-weight: 700;
  font-size: 14px;
  color: #fff;
  min-height: 48px;
}

.user-avatar-sm {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 12px;
  color: #fff;
  flex-shrink: 0;
}

/* ==================== LOGOUT BTN ==================== */

.logout-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 12px;
  border-radius: 8px;
  background: rgba(180, 35, 24, 0.12);
  border: 1px solid rgba(180, 35, 24, 0.25);
  color: #fca5a5;
  cursor: pointer;
  font-weight: 700;
  font-size: 14px;
  width: 100%;
  transition: background 0.18s ease;
}

.logout-btn:hover {
  background: rgba(180, 35, 24, 0.28);
  border-color: rgba(180, 35, 24, 0.5);
  color: #fff;
}

@media (max-width: 820px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
    padding: 14px;
  }

  .nav-menu {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .nav-link {
    justify-content: center;
  }

  .nav-link span:last-child {
    display: none;
  }

  .sidebar-card {
    display: none;
  }

  .workspace {
    padding: 14px;
  }

  .topbar {
    position: static;
    align-items: stretch;
    flex-direction: column;
  }

  .topbar-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .kpi-grid,
  .mini-grid,
  .table-actions,
  .lead-row {
    grid-template-columns: 1fr;
  }
}

/* ==================== MOBILE FINE-TUNING ==================== */

@media (max-width: 520px) {
  .nav-menu {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .nav-icon {
    width: 24px;
    height: 24px;
    font-size: 11px;
  }

  h1 { font-size: 22px; }
  h2 { font-size: 18px; }

  .workspace { padding: 10px; gap: 12px; }

  .panel { padding: 14px; }

  .panel-heading {
    flex-direction: column;
    align-items: stretch;
  }

  .actions-row,
  .topbar-actions {
    grid-template-columns: 1fr;
    display: grid;
  }

  .ai-panel {
    left: 12px;
    right: 12px;
    bottom: 84px;
    width: auto;
    max-height: 70vh;
  }

  .ai-fab {
    bottom: 18px;
    right: 18px;
    width: 50px;
    height: 50px;
    font-size: 20px;
  }

  .modal {
    max-height: 96vh;
    border-radius: 12px;
  }

  .modal-header,
  .modal-form {
    padding: 14px 16px;
  }

  .analysis-list {
    grid-template-columns: 1fr;
  }

  .kanban-column {
    flex: 0 0 250px;
  }

  .btn-whatsapp-row {
    max-width: 120px;
  }
}

@media (max-width: 380px) {
  .nav-menu {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
