/* ==========================================================================
   PAINEL ADMINISTRATIVO CRM — DESTRAVA COM NATHAN
   Design System CRM Moderno & Executivo (HubSpot / Stripe / Linear style)
   ========================================================================== */

:root {
  /* Marca Primária */
  --petroleo: #0F2A44;
  --petroleo-light: #18385a;
  --petroleo-dark: #0B192C;
  --petroleo-deep: #061019;
  --marsala: #8C3A3A;
  --marsala-hover: #732f2f;
  --marsala-soft: rgba(140, 58, 58, 0.08);
  --bege: #E6D8C3;
  --bege-soft: #faf6f0;

  /* Superfícies & Canvas */
  --bg-canvas: #f8fafc;
  --card-bg: #ffffff;
  --sidebar-bg: #09131d;
  --sidebar-w: 268px;
  --topbar-h: 68px;

  /* Tipografia & Texto */
  --ink: #0f172a;
  --ink-secondary: #334155;
  --muted: #64748b;
  --text-light: #94a3b8;

  /* Bordas & Divisórias */
  --line: #e2e8f0;
  --line-strong: #cbd5e1;
  --sidebar-line: rgba(255, 255, 255, 0.08);

  /* Status Semânticos do CRM */
  --st-novo-bg: #fee2e2;
  --st-novo-txt: #991b1b;
  --st-novo-dot: #dc2626;

  --st-contato-bg: #fef3c7;
  --st-contato-txt: #92400e;
  --st-contato-dot: #d97706;

  --st-agendado-bg: #e0f2fe;
  --st-agendado-txt: #0369a1;
  --st-agendado-dot: #0284c7;

  --st-convertido-bg: #dcfce7;
  --st-convertido-txt: #166534;
  --st-convertido-dot: #16a34a;

  --st-arquivado-bg: #f1f5f9;
  --st-arquivado-txt: #475569;
  --st-arquivado-dot: #64748b;

  /* WhatsApp Brand */
  --wa-green: #25D366;
  --wa-dark: #128C7E;
  --wa-soft: rgba(37, 211, 102, 0.12);

  /* Sombras & Profundidade */
  --shadow-xs: 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.06), 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-md: 0 4px 14px -2px rgba(15, 23, 42, 0.06), 0 2px 6px -1px rgba(15, 23, 42, 0.04);
  --shadow-lg: 0 12px 30px -4px rgba(15, 23, 42, 0.08), 0 4px 12px -2px rgba(15, 23, 42, 0.04);
  --shadow-modal: 0 25px 60px -12px rgba(15, 23, 42, 0.25);

  /* Raios de Borda Modernos */
  --radius-xs: 4px;
  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 16px;
  --radius-xl: 22px;
  --radius-full: 999px;

  /* Transições */
  --transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

/* RESET E BASE */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body.admin-body {
  font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background-color: var(--bg-canvas);
  color: var(--ink);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.admin-layout {
  display: flex;
  min-height: 100vh;
}

/* ==========================================================================
   SIDEBAR MODERNA (Estilo CRM Dark Executivo)
   ========================================================================== */
.admin-sidebar {
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  background: linear-gradient(180deg, #0b1724 0%, #060e18 100%);
  color: #fff;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  border-right: 1px solid var(--sidebar-line);
  position: relative;
  z-index: 100;
  transition: transform 0.3s ease;
}

.admin-sidebar-header {
  padding: 22px 20px;
  border-bottom: 1px solid var(--sidebar-line);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-icon {
  width: 34px;
  height: 34px;
  background: linear-gradient(135deg, var(--marsala) 0%, #ba4d4d 100%);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  box-shadow: 0 4px 12px rgba(140, 58, 58, 0.35);
}

.brand-title {
  font-size: 1.15rem;
  font-weight: 800;
  color: #fff;
  letter-spacing: -0.02em;
}

.brand-badge {
  background: rgba(230, 216, 195, 0.15);
  color: var(--bege);
  font-size: 0.65rem;
  font-weight: 800;
  padding: 2px 7px;
  border-radius: var(--radius-full);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  border: 1px solid rgba(230, 216, 195, 0.25);
}

.admin-nav {
  padding: 20px 14px;
  flex-grow: 1;
  overflow-y: auto;
}

.nav-group-title {
  font-size: 0.68rem;
  font-weight: 800;
  color: #64748b;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 10px 12px 6px;
  margin-top: 14px;
}
.nav-group-title:first-child {
  margin-top: 0;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: #94a3b8;
  text-decoration: none;
  font-size: 0.88rem;
  font-weight: 600;
  margin-bottom: 3px;
  transition: var(--transition);
  position: relative;
}

.nav-item:hover {
  background: rgba(255, 255, 255, 0.06);
  color: #f1f5f9;
  transform: translateX(2px);
}

.nav-item.active {
  background: linear-gradient(90deg, rgba(140, 58, 58, 0.25) 0%, rgba(140, 58, 58, 0.08) 100%);
  color: #fff;
  border-left: 3px solid var(--marsala);
  padding-left: 9px;
  font-weight: 700;
}

.nav-item .nav-svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  stroke: currentColor;
  stroke-width: 2;
  fill: none;
  transition: var(--transition);
}

.nav-item.active .nav-svg {
  stroke: #ff9999;
}

.nav-pill-badge {
  margin-left: auto;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: var(--radius-full);
  background: var(--marsala);
  color: #fff;
}

/* RODAPÉ DO SIDEBAR (PERFIL CRM) */
.admin-sidebar-footer {
  padding: 16px 18px;
  border-top: 1px solid var(--sidebar-line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(0, 0, 0, 0.15);
}

.admin-user-info {
  display: flex;
  align-items: center;
  gap: 11px;
}

.user-avatar-wrap {
  position: relative;
}

.user-avatar {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-full);
  background: linear-gradient(135deg, var(--bege) 0%, #c9ba9f 100%);
  color: var(--petroleo);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 0.85rem;
  box-shadow: var(--shadow-xs);
}

.user-status-dot {
  width: 9px;
  height: 9px;
  background: #10B981;
  border: 2px solid var(--sidebar-bg);
  border-radius: 50%;
  position: absolute;
  bottom: 0;
  right: 0;
}

.user-meta strong {
  display: block;
  font-size: 0.84rem;
  color: #f1f5f9;
  font-weight: 700;
  line-height: 1.2;
}

.user-meta small {
  font-size: 0.72rem;
  color: #64748b;
  font-weight: 500;
}

.btn-logout {
  color: #94a3b8;
  text-decoration: none;
  font-size: 0.82rem;
  padding: 6px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}

.btn-logout:hover {
  background: rgba(220, 38, 38, 0.15);
  color: #f87171;
}

/* ==========================================================================
   TOPBAR EXECUTIVA (Breadcrumbs, Quick Actions, Search)
   ========================================================================== */
.admin-main {
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.admin-topbar {
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
  height: var(--topbar-h);
  padding: 0 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 90;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 14px;
}

.sidebar-toggle-btn {
  display: none;
  background: none;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 8px;
  cursor: pointer;
  color: var(--ink);
}

.breadcrumbs {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8rem;
  color: var(--muted);
}

.breadcrumbs a {
  color: var(--muted);
  text-decoration: none;
  transition: var(--transition);
}
.breadcrumbs a:hover {
  color: var(--marsala);
}

.breadcrumbs-sep {
  color: var(--text-light);
  font-size: 0.75rem;
}

.breadcrumbs-current {
  color: var(--petroleo);
  font-weight: 700;
}

.topbar-title h2 {
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--petroleo);
  letter-spacing: -0.02em;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.admin-content {
  padding: 24px 32px;
  flex-grow: 1;
  width: 100%;
  max-width: 100%;
  margin: 0;
}

/* ==========================================================================
   CARDS, PAINÉIS & CONTAINERS CRM
   ========================================================================== */
.admin-panel, .crm-card {
  background: var(--card-bg);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  transition: var(--transition);
}

.admin-panel:hover, .crm-card:hover {
  box-shadow: var(--shadow-md);
}

.panel-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #ffffff;
}

.panel-header h3 {
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--petroleo);
  letter-spacing: -0.01em;
}

.panel-header small {
  display: block;
  font-size: 0.8rem;
  color: var(--muted);
  margin-top: 2px;
}

.panel-body {
  padding: 24px;
}

/* ==========================================================================
   STAT CARDS (MÉTRICAS CRM & MICRO-TRENDS)
   ========================================================================== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 20px;
}

.stat-card {
  background: var(--card-bg);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 22px 24px;
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: flex-start;
  gap: 18px;
  transition: var(--transition);
  position: relative;
  overflow: hidden;
}

.stat-card::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 3px;
  background: transparent;
  transition: var(--transition);
}

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}
.stat-card:hover::after {
  background: var(--marsala);
}

.stat-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  flex-shrink: 0;
}

.stat-icon svg {
  width: 24px;
  height: 24px;
}

.stat-data {
  display: flex;
  flex-direction: column;
  flex-grow: 1;
}

.stat-label {
  font-size: 0.74rem;
  color: var(--muted);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 4px;
}

.stat-number {
  font-size: 1.85rem;
  font-weight: 800;
  color: var(--petroleo);
  line-height: 1.15;
  letter-spacing: -0.03em;
}

.stat-sub {
  font-size: 0.78rem;
  color: var(--muted);
  margin-top: 6px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.stat-badge-trend {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: var(--radius-full);
}
.stat-badge-trend.positive {
  background: #dcfce7;
  color: #166534;
}
.stat-badge-trend.highlight {
  background: #fee2e2;
  color: #991b1b;
}

/* ==========================================================================
   FUNIL DE CONVERSÃO MODERNO (PIPELINE STEP CONNECTED)
   ========================================================================== */
.funnel-pipeline-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 16px;
  padding: 10px 0;
}

.funnel-card {
  background: var(--bg-canvas);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 16px;
  display: flex;
  flex-direction: column;
  position: relative;
  transition: var(--transition);
}

.funnel-card:hover {
  background: #fff;
  border-color: var(--line-strong);
  box-shadow: var(--shadow-sm);
}

.funnel-card.success-card {
  background: linear-gradient(180deg, rgba(220, 252, 231, 0.4) 0%, rgba(220, 252, 231, 0.1) 100%);
  border-color: #bbf7d0;
}

.funnel-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.funnel-step-chip {
  font-size: 0.7rem;
  font-weight: 800;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.funnel-card.success-card .funnel-step-chip {
  color: #166534;
}

.funnel-val {
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--petroleo);
  line-height: 1;
}

.funnel-title {
  font-size: 0.84rem;
  font-weight: 700;
  color: var(--ink);
  margin-top: 6px;
}

.funnel-bar-rail {
  background: rgba(15, 23, 42, 0.08);
  height: 6px;
  border-radius: var(--radius-full);
  margin-top: 14px;
  overflow: hidden;
}

.funnel-bar-fill {
  background: linear-gradient(90deg, var(--petroleo) 0%, #1e4a73 100%);
  height: 100%;
  border-radius: var(--radius-full);
  transition: width 0.6s ease;
}

.funnel-card.success-card .funnel-bar-fill {
  background: linear-gradient(90deg, #10b981 0%, #059669 100%);
}

.funnel-rate {
  font-size: 0.72rem;
  color: var(--muted);
  font-weight: 600;
  margin-top: 8px;
  display: flex;
  justify-content: space-between;
}

/* ==========================================================================
   TABELAS CRM COM HOVER & HIERARQUIA
   ========================================================================== */
.table-responsive {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  width: 100%;
}

.table-responsive::-webkit-scrollbar {
  height: 6px;
}
.table-responsive::-webkit-scrollbar-track {
  background: #f1f5f9;
}
.table-responsive::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: var(--radius-full);
}
.table-responsive::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

.admin-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.88rem;
  min-width: 820px;
}

.admin-table-leads {
  min-width: 1100px;
}

.admin-table-recent {
  min-width: 980px;
}

.admin-table th {
  background: #f8fafc;
  padding: 12px 18px;
  text-align: left;
  font-weight: 700;
  color: var(--muted);
  border-bottom: 1px solid var(--line);
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  white-space: nowrap;
}

.admin-table td {
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
  background: #fff;
  transition: var(--transition);
}

.admin-table tbody tr:hover td {
  background: #f8fafc;
}

.admin-table tbody tr:last-child td {
  border-bottom: none;
}

/* Helper cell classes for tables */
.cell-nowrap {
  white-space: nowrap !important;
}

.cell-actions {
  white-space: nowrap !important;
  text-align: right;
  min-width: 130px;
}

.cell-actions-lg {
  white-space: nowrap !important;
  text-align: right;
  min-width: 180px;
}

.cell-whatsapp {
  white-space: nowrap !important;
  min-width: 155px;
}

.cell-status {
  white-space: nowrap !important;
  min-width: 135px;
}

.cell-date {
  white-space: nowrap !important;
  min-width: 95px;
}

/* Lead Table Components */
.lead-person-cell {
  display: flex;
  align-items: center;
  gap: 12px;
}

.lead-avatar-sm {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-full);
  background: #e2e8f0;
  color: var(--petroleo);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 0.82rem;
  flex-shrink: 0;
}

.lead-person-info strong {
  display: block;
  font-size: 0.9rem;
  color: var(--petroleo);
  font-weight: 700;
}

.lead-person-info small {
  display: block;
  font-size: 0.76rem;
  color: var(--muted);
  margin-top: 1px;
}

/* ==========================================================================
   BADGES & STATUS DO CRM (Com Indicator Dot)
   ========================================================================== */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  line-height: 1.4;
}

.badge-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  display: inline-block;
}

.badge-novo {
  background: var(--st-novo-bg);
  color: var(--st-novo-txt);
}
.badge-novo .badge-dot {
  background: var(--st-novo-dot);
}

.badge-em-contato {
  background: var(--st-contato-bg);
  color: var(--st-contato-txt);
}
.badge-em-contato .badge-dot {
  background: var(--st-contato-dot);
}

.badge-agendado {
  background: var(--st-agendado-bg);
  color: var(--st-agendado-txt);
}
.badge-agendado .badge-dot {
  background: var(--st-agendado-dot);
}

.badge-convertido {
  background: var(--st-convertido-bg);
  color: var(--st-convertido-txt);
}
.badge-convertido .badge-dot {
  background: var(--st-convertido-dot);
}

.badge-arquivado {
  background: var(--st-arquivado-bg);
  color: var(--st-arquivado-txt);
}
.badge-arquivado .badge-dot {
  background: var(--st-arquivado-dot);
}

.badge-info { background: #e0f2fe; color: #0369a1; }
.badge-warning { background: #fef3c7; color: #92400e; }
.badge-danger { background: #fee2e2; color: #991b1b; }
.badge-success { background: #dcfce7; color: #166534; }

/* STATUS SELECTOR NO CRM */
.status-select-wrap {
  position: relative;
  display: inline-block;
}

.status-select {
  appearance: none;
  -webkit-appearance: none;
  padding: 6px 26px 6px 12px;
  border-radius: var(--radius-full);
  font-size: 0.76rem;
  font-weight: 700;
  border: 1px solid var(--line);
  cursor: pointer;
  background-color: #fff;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  transition: var(--transition);
  white-space: nowrap;
  flex-shrink: 0;
}

.status-select:focus {
  outline: none;
  border-color: var(--petroleo);
  box-shadow: 0 0 0 2px rgba(15, 42, 68, 0.1);
}

.status-select.status-novo { background-color: var(--st-novo-bg); color: var(--st-novo-txt); border-color: #fca5a5; }
.status-select.status-em-contato { background-color: var(--st-contato-bg); color: var(--st-contato-txt); border-color: #fcd34d; }
.status-select.status-agendado { background-color: var(--st-agendado-bg); color: var(--st-agendado-txt); border-color: #7dd3fc; }
.status-select.status-convertido { background-color: var(--st-convertido-bg); color: var(--st-convertido-txt); border-color: #86efac; }
.status-select.status-arquivado { background-color: var(--st-arquivado-bg); color: var(--st-arquivado-txt); border-color: #cbd5e1; }

/* ==========================================================================
   BOTÕES CRM
   ========================================================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  font-size: 0.86rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  border: 1px solid transparent;
  transition: var(--transition);
  font-family: inherit;
  line-height: 1.4;
  white-space: nowrap;
  flex-shrink: 0;
}

.btn:active {
  transform: translateY(1px);
}

.btn-primary {
  background: var(--marsala);
  color: #fff;
  box-shadow: 0 2px 6px rgba(140, 58, 58, 0.25);
}
.btn-primary:hover {
  background: var(--marsala-hover);
  box-shadow: 0 4px 12px rgba(140, 58, 58, 0.35);
  transform: translateY(-1px);
}

.btn-ghost {
  background: #ffffff;
  border-color: var(--line);
  color: var(--ink-secondary);
}
.btn-ghost:hover {
  background: #f8fafc;
  border-color: var(--line-strong);
  color: var(--petroleo);
}

.btn-dark {
  background: var(--petroleo);
  color: #fff;
}
.btn-dark:hover {
  background: var(--petroleo-light);
}

.btn-danger {
  background: #dc2626;
  color: #fff;
}
.btn-danger:hover {
  background: #b91c1c;
}

.btn-wa {
  background: var(--wa-green);
  color: #fff;
  font-weight: 700;
  box-shadow: 0 2px 8px rgba(37, 211, 102, 0.28);
  white-space: nowrap;
  flex-shrink: 0;
}
.btn-wa:hover {
  background: #20ba5a;
  box-shadow: 0 4px 14px rgba(37, 211, 102, 0.38);
  transform: translateY(-1px);
}

.btn-sm {
  padding: 7px 14px;
  font-size: 0.8rem;
  border-radius: var(--radius-sm);
  white-space: nowrap;
  flex-shrink: 0;
}

.btn-xs {
  padding: 5px 11px;
  font-size: 0.75rem;
  border-radius: var(--radius-xs);
  font-weight: 600;
  white-space: nowrap;
  flex-shrink: 0;
}

.btn-block {
  width: 100%;
}

.btn-icon-only {
  padding: 8px;
  border-radius: var(--radius-sm);
}

.btn-text-danger {
  background: none;
  border: none;
  color: #dc2626;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: var(--radius-xs);
  transition: var(--transition);
}
.btn-text-danger:hover {
  background: #fee2e2;
}

.wa-link {
  color: var(--wa-dark);
  font-weight: 700;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border-radius: var(--radius-sm);
  background: var(--wa-soft);
  transition: var(--transition);
  white-space: nowrap;
  flex-shrink: 0;
  font-size: 0.82rem;
}
.wa-link svg {
  flex-shrink: 0;
}
.wa-link:hover {
  background: rgba(37, 211, 102, 0.22);
}

/* ==========================================================================
   ALERTAS FLASH FLUTUANTES COM AUTO-DISMISS
   ========================================================================== */
.flash-container {
  margin-bottom: 24px;
}

.flash-alert {
  padding: 14px 20px;
  border-radius: var(--radius);
  margin-bottom: 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.88rem;
  font-weight: 600;
  box-shadow: var(--shadow-sm);
  animation: flashFadeIn 0.3s ease;
}

@keyframes flashFadeIn {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}

.flash-success { background: #f0fdf4; color: #166534; border: 1px solid #bbf7d0; }
.flash-danger  { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }
.flash-warning { background: #fffbeb; color: #92400e; border: 1px solid #fde68a; }
.flash-info    { background: #f0f9ff; color: #075985; border: 1px solid #bae6fd; }

.flash-close {
  background: none;
  border: none;
  font-size: 1.25rem;
  cursor: pointer;
  color: inherit;
  opacity: 0.6;
  transition: var(--transition);
}
.flash-close:hover { opacity: 1; }

/* ==========================================================================
   FORMULÁRIOS & CONTROLES CRM
   ========================================================================== */
.form-group {
  margin-bottom: 18px;
}

.form-group label {
  display: block;
  font-size: 0.84rem;
  font-weight: 700;
  color: var(--petroleo);
  margin-bottom: 6px;
}

.form-control {
  width: 100%;
  padding: 11px 15px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-family: inherit;
  color: var(--ink);
  background: #ffffff;
  transition: var(--transition);
}

.form-control:focus {
  outline: none;
  border-color: var(--marsala);
  box-shadow: 0 0 0 3px rgba(140, 58, 58, 0.12);
}

.form-control-sm {
  padding: 7px 12px;
  font-size: 0.82rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: #fff;
}
.form-control-sm:focus {
  outline: none;
  border-color: var(--marsala);
  box-shadow: 0 0 0 2px rgba(140, 58, 58, 0.12);
}

.form-row-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.form-row-3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 16px;
}

/* ==========================================================================
   FILTER TABS & BUSCA CRM
   ========================================================================== */
.filter-tabs {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.filter-chip {
  padding: 6px 14px;
  border-radius: var(--radius-full);
  background: #f1f5f9;
  color: var(--muted);
  text-decoration: none;
  font-size: 0.8rem;
  font-weight: 600;
  border: 1px solid transparent;
  transition: var(--transition);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  flex-shrink: 0;
}

.filter-chip:hover {
  background: #e2e8f0;
  color: var(--petroleo);
}

.filter-chip.active {
  background: var(--petroleo);
  color: #fff;
  box-shadow: var(--shadow-xs);
}

.search-form {
  display: flex;
  gap: 8px;
  align-items: center;
}

.search-input-wrap {
  position: relative;
  display: flex;
  align-items: center;
}
.search-input-wrap .search-icon {
  position: absolute;
  left: 10px;
  color: var(--muted);
  pointer-events: none;
}
.search-input-wrap input {
  padding-left: 32px;
}

/* ==========================================================================
   LEAD DETALHE (DOSSIÊ 360° DO CRM)
   ========================================================================== */
.lead-detail-grid {
  display: grid;
  grid-template-columns: 1.55fr 0.9fr;
  gap: 28px;
  align-items: start;
}

.lead-hero-card {
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 24px;
  margin-bottom: 24px;
  box-shadow: var(--shadow-sm);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
}

.lead-hero-info {
  display: flex;
  align-items: center;
  gap: 16px;
}

.lead-hero-avatar {
  width: 56px;
  height: 56px;
  border-radius: var(--radius-full);
  background: linear-gradient(135deg, var(--marsala) 0%, #a64545 100%);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  font-weight: 800;
  box-shadow: 0 4px 14px rgba(140, 58, 58, 0.3);
}

.lead-hero-title h1 {
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--petroleo);
  letter-spacing: -0.02em;
}

.lead-hero-title span {
  font-size: 0.86rem;
  color: var(--muted);
}

.detail-row {
  margin-bottom: 16px;
}
.detail-row:last-child {
  margin-bottom: 0;
}

.detail-row .label {
  font-size: 0.72rem;
  font-weight: 800;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  display: block;
  margin-bottom: 3px;
}

.detail-row strong {
  font-size: 0.95rem;
  color: var(--petroleo);
}

.tag-pill {
  display: inline-block;
  background: #f1f5f9;
  color: #1e293b;
  border: 1px solid #e2e8f0;
  padding: 5px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  font-weight: 600;
  line-height: 1.35;
  max-width: 280px;
  word-break: break-word;
}

.quote-box {
  background: rgba(140, 58, 58, 0.04);
  border-left: 3px solid var(--marsala);
  padding: 16px 20px;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-style: italic;
  color: var(--ink);
  line-height: 1.6;
}

/* ==========================================================================
   FORM BUILDER (Editor do Diagnóstico)
   ========================================================================== */
.stage-order-badge {
  background: var(--petroleo);
  color: #fff;
  font-size: 0.72rem;
  font-weight: 800;
  padding: 4px 9px;
  border-radius: var(--radius-full);
}

.questions-list {
  display: grid;
  gap: 14px;
}

.question-item-card {
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 20px;
  transition: var(--transition);
}
.question-item-card:hover {
  background: #fff;
  box-shadow: var(--shadow-xs);
  border-color: var(--line-strong);
}

.q-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.q-title-box {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.q-num {
  font-weight: 800;
  color: var(--muted);
  font-size: 0.85rem;
}

.req-tag {
  background: #fee2e2;
  color: #991b1b;
  font-size: 0.68rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: var(--radius-full);
}

.type-tag {
  background: #e0f2fe;
  color: #0369a1;
  font-size: 0.68rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: var(--radius-full);
}

.key-tag {
  background: #f1f5f9;
  color: #64748b;
  font-size: 0.68rem;
  padding: 2px 7px;
  border-radius: var(--radius-xs);
  font-family: monospace;
}

.q-options-preview {
  margin-top: 12px;
  border-top: 1px dashed var(--line);
  padding-top: 10px;
}

.options-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.op-badge {
  background: #fff;
  border: 1px solid var(--line);
  padding: 3px 9px;
  border-radius: var(--radius-sm);
  font-size: 0.76rem;
  color: var(--ink-secondary);
}

.btn-icon-danger {
  background: none;
  border: none;
  font-size: 1.1rem;
  cursor: pointer;
  opacity: 0.6;
  transition: var(--transition);
}
.btn-icon-danger:hover {
  opacity: 1;
}

/* ==========================================================================
   MODAIS MODERNOS (Glassmorphism Backdrop & Smooth Scale)
   ========================================================================== */
.admin-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(15, 23, 42, 0.65);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  padding: 20px;
}

.modal-content {
  background: #fff;
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 520px;
  box-shadow: var(--shadow-modal);
  overflow: hidden;
  animation: modalScaleIn 0.25s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes modalScaleIn {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}

.modal-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-header h3 {
  font-size: 1.1rem;
  font-weight: 800;
  margin: 0;
  color: var(--petroleo);
}

.modal-close {
  background: none;
  border: none;
  font-size: 1.4rem;
  cursor: pointer;
  color: var(--muted);
  line-height: 1;
  transition: var(--transition);
}
.modal-close:hover {
  color: var(--petroleo);
}

.modal-body {
  padding: 24px;
  max-height: 70vh;
  overflow-y: auto;
}

.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--line);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  background: #f8fafc;
}

/* ==========================================================================
   TELA DE LOGIN EXECUTIVA (Glassmorphism & Depth)
   ========================================================================== */
.login-body {
  background: radial-gradient(circle at top right, #1a426b 0%, var(--petroleo-deep) 70%);
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 24px;
  font-family: 'Plus Jakarta Sans', sans-serif;
}

.login-wrapper {
  width: 100%;
  max-width: 440px;
}

.login-card {
  background: rgba(255, 255, 255, 0.98);
  border-radius: var(--radius-xl);
  padding: 44px 38px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.login-header {
  text-align: center;
  margin-bottom: 32px;
}

.login-badge {
  background: var(--bege);
  color: var(--petroleo);
  font-size: 0.72rem;
  font-weight: 800;
  padding: 5px 14px;
  border-radius: var(--radius-full);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.login-header h1 {
  font-size: 1.6rem;
  color: var(--petroleo);
  margin: 14px 0 6px;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.login-header p {
  font-size: 0.88rem;
  color: var(--muted);
  line-height: 1.5;
}

.login-card .form-group {
  margin-bottom: 20px;
}

.login-card label {
  display: block;
  font-size: 0.84rem;
  font-weight: 700;
  color: var(--petroleo);
  margin-bottom: 7px;
}

.login-footer {
  text-align: center;
  margin-top: 24px;
}
.login-footer a {
  color: var(--muted);
  font-size: 0.84rem;
  text-decoration: none;
  font-weight: 600;
  transition: var(--transition);
}
.login-footer a:hover {
  color: var(--petroleo);
}

/* ==========================================================================
   RESPONSIVIDADE COMPLETA (TABLETS & SMARTPHONES)
   ========================================================================== */
@media (max-width: 1100px) {
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .funnel-pipeline-grid {
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  }
  .lead-detail-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 860px) {
  .admin-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    transform: translateX(-100%);
    box-shadow: var(--shadow-modal);
  }
  .admin-sidebar.sidebar-open {
    transform: translateX(0);
  }
  .sidebar-toggle-btn {
    display: flex;
    align-items: center;
    justify-content: center;
  }
  .admin-topbar {
    padding: 0 16px;
  }
  .admin-content {
    padding: 16px;
  }
  .funnel-pipeline-grid {
    grid-template-columns: 1fr 1fr;
  }
  .form-row-2, .form-row-3 {
    grid-template-columns: 1fr;
  }
  .search-form {
    width: 100%;
  }
  .search-input-wrap {
    flex: 1;
  }
  .search-input-wrap input {
    width: 100%;
    min-width: 0 !important;
  }
  .lead-hero-card {
    flex-direction: column;
    align-items: flex-start;
    gap: 16px;
  }
  .lead-hero-info {
    width: 100%;
  }
}

@media (max-width: 600px) {
  .stats-grid {
    grid-template-columns: 1fr;
  }
  .funnel-pipeline-grid {
    grid-template-columns: 1fr;
  }
  .topbar-actions .btn {
    display: none;
  }
  .topbar-actions .btn-sm {
    display: inline-flex;
  }
  .panel-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }
  .filter-tabs {
    width: 100%;
    overflow-x: auto;
    flex-wrap: nowrap;
    padding-bottom: 4px;
    -webkit-overflow-scrolling: touch;
  }
  .filter-chip {
    flex-shrink: 0;
  }
  .topbar-title h2 {
    font-size: 1.05rem;
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
}
