:root {
  --primary: #00a884;
  --primary-hover: #008f6f;
  --primary-dark: #075e54;
  --primary-light: #e7f7f3;
  --wa-bg: #efeae2;
  --wa-bubble: #ffffff;
  --wa-bubble-accent: #d9fdd3;
  --wa-ticks: #53bdeb;

  --slate-950: #020617;
  --slate-900: #0f172a;
  --slate-800: #1e293b;
  --slate-700: #334155;
  --slate-600: #475569;
  --slate-500: #64748b;
  --slate-400: #94a3b8;
  --slate-300: #cbd5e1;
  --slate-200: #e2e8f0;
  --slate-100: #f1f5f9;
  --slate-50: #f8fafc;

  --amber-500: #f59e0b;
  --amber-50: #fffbeb;
  --amber-700: #b45309;
  --red-500: #ef4444;
  --red-50: #fef2f2;
  --red-700: #b91c1c;
  --green-500: #10b981;
  --green-50: #ecfdf5;

  --font-main: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
  --radius-lg: 16px;
  --radius-md: 10px;
  --radius-sm: 6px;
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-card: 0 4px 20px -2px rgba(15, 23, 42, 0.05), 0 2px 6px -2px rgba(15, 23, 42, 0.03);
  --shadow-modal: 0 25px 50px -12px rgba(15, 23, 42, 0.25);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: var(--font-main);
  color: var(--slate-800);
  background-color: #f6f8fa;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

button, input, select, textarea { font-family: inherit; }
button, select { cursor: pointer; }
[hidden] { display: none !important; }

/* Banner de Conexão */
.connection-banner {
  position: sticky; top: 0; z-index: 1000;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 20px; background: var(--red-500); color: white;
  font-size: 0.88rem; font-weight: 600;
}

/* Barra Superior (Topbar) */
.topbar {
  position: sticky; top: 0; z-index: 100;
  background: var(--slate-900); color: white;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.15);
}
.topbar-inner {
  display: flex; align-items: center; justify-content: space-between;
  max-width: 1440px; margin: 0 auto; height: 68px; padding: 0 24px;
}
.brand {
  display: flex; align-items: center; gap: 12px;
  color: white; text-decoration: none;
}
.brand-badge {
  display: grid; place-items: center; width: 38px; height: 38px;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  border-radius: 10px; color: white; box-shadow: 0 2px 8px rgba(0, 168, 132, 0.35);
}
.brand-text strong { display: block; font-size: 1.05rem; font-weight: 700; letter-spacing: -0.02em; }
.brand-text span { display: block; font-size: 0.75rem; color: var(--slate-400); }

/* Seletor de Visão Principal na Topbar */
.topbar-view-switcher {
  display: flex;
  align-items: center;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 999px;
  padding: 3px;
  gap: 2px;
}
.view-switch-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  background: transparent;
  border: none;
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--slate-300);
  cursor: pointer;
  transition: all 0.15s ease;
}
.view-switch-btn:hover {
  color: white;
  background: rgba(255, 255, 255, 0.05);
}
.view-switch-btn.is-active {
  background: var(--primary);
  color: white;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
}

.topbar-actions { display: flex; align-items: center; gap: 14px; }
.active-account-pill {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 14px; background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.12); border-radius: 999px;
  font-size: 0.82rem; font-weight: 600; color: var(--slate-200);
}
.status-pulse {
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--primary);
  box-shadow: 0 0 0 0 rgba(0, 168, 132, 0.7);
  animation: pulse-ring 2s infinite;
}
@keyframes pulse-ring {
  0% { box-shadow: 0 0 0 0 rgba(0, 168, 132, 0.7); }
  70% { box-shadow: 0 0 0 8px rgba(0, 168, 132, 0); }
  100% { box-shadow: 0 0 0 0 rgba(0, 168, 132, 0); }
}

/* App Shell (Layout com Sidebar e Conteúdo Principal) */
.app-shell {
  display: grid; grid-template-columns: 280px minmax(0, 1fr);
  max-width: 1440px; margin: 0 auto; min-height: calc(100vh - 68px);
}

/* Sidebar */
.sidebar {
  background: #ffffff; border-right: 1px solid var(--slate-200);
  padding: 24px 18px; display: flex; flex-direction: column; gap: 18px;
}
.sidebar-header {
  display: flex; align-items: center; justify-content: space-between;
}
.sidebar-header h3 { margin: 0; font-size: 1.1rem; font-weight: 700; color: var(--slate-900); }
.eyebrow {
  display: block; font-size: 0.68rem; font-weight: 800; text-transform: uppercase;
  letter-spacing: 0.08em; color: var(--primary); margin-bottom: 3px;
}
.icon-button-small {
  width: 32px; height: 32px; border-radius: 8px; border: 1px solid var(--slate-200);
  background: var(--slate-50); color: var(--slate-700); font-size: 1.2rem;
  display: grid; place-items: center; transition: all 0.15s ease;
}
.icon-button-small:hover { background: var(--primary-light); color: var(--primary); border-color: var(--primary); }

.profile-list { display: flex; flex-direction: column; gap: 8px; }
.profile-item {
  width: 100%; padding: 12px 14px; border: 1.5px solid var(--slate-200);
  border-radius: var(--radius-md); background: #ffffff; text-align: left;
  transition: all 0.15s ease;
}
.profile-item:hover { border-color: var(--slate-400); transform: translateY(-1px); }
.profile-item.active {
  border-color: var(--primary); background: var(--primary-light);
  box-shadow: 0 2px 8px rgba(0, 168, 132, 0.12);
}
.profile-item strong { display: block; font-size: 0.9rem; font-weight: 700; color: var(--slate-900); }
.profile-item small { display: block; font-size: 0.74rem; color: var(--slate-500); margin-top: 2px; }

.sidebar-footer-tip {
  margin-top: auto; padding: 14px; background: var(--slate-50);
  border-radius: var(--radius-md); border: 1px dashed var(--slate-300);
  display: flex; gap: 10px; font-size: 0.75rem; color: var(--slate-600); line-height: 1.4;
}
.sidebar-footer-tip svg { flex-shrink: 0; color: var(--slate-400); margin-top: 2px; }

/* Main Content */
.main-content { padding: 32px 36px 60px; overflow-y: auto; }

/* Stepper / Barra de Passos */
.stepper-nav {
  display: flex; align-items: center; justify-content: space-between;
  background: #ffffff; padding: 16px 28px; border-radius: var(--radius-lg);
  border: 1px solid var(--slate-200); box-shadow: var(--shadow-sm);
  margin-bottom: 24px;
}
.step-item { display: flex; align-items: center; gap: 12px; opacity: 0.55; transition: opacity 0.2s; }
.step-item.is-active { opacity: 1; }
.step-circle {
  width: 34px; height: 34px; border-radius: 50%;
  display: grid; place-items: center; font-weight: 700; font-size: 0.88rem;
  background: var(--slate-100); color: var(--slate-600); border: 1.5px solid var(--slate-300);
}
.step-item.is-active .step-circle {
  background: var(--primary); color: white; border-color: var(--primary);
  box-shadow: 0 2px 8px rgba(0, 168, 132, 0.35);
}
.step-label strong { display: block; font-size: 0.88rem; font-weight: 700; color: var(--slate-900); }
.step-label small { display: block; font-size: 0.72rem; color: var(--slate-500); }
.step-connector { flex: 1; height: 2px; background: var(--slate-200); margin: 0 20px; }

/* Cards & Layout */
.grid-two-panel {
  display: grid; grid-template-columns: 1fr 1.35fr; gap: 24px; margin-bottom: 24px;
}
.card {
  background: #ffffff; border-radius: var(--radius-lg);
  border: 1px solid var(--slate-200); box-shadow: var(--shadow-card);
  padding: 24px;
}
.card-badge-header {
  display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px;
}
.step-pill {
  font-size: 0.7rem; font-weight: 800; text-transform: uppercase;
  padding: 3px 10px; border-radius: 999px; letter-spacing: 0.06em;
  background: var(--slate-100); color: var(--slate-600);
}
.step-pill.green { background: var(--primary-light); color: var(--primary); }

.card-title { margin: 0 0 6px; font-size: 1.3rem; font-weight: 700; color: var(--slate-900); letter-spacing: -0.02em; }
.card-subtitle { margin: 0 0 18px; font-size: 0.84rem; color: var(--slate-500); }

/* Passo 1 - Subconta Card */
.account-profile-header {
  display: flex; align-items: center; gap: 14px; margin-bottom: 20px;
}
.account-avatar {
  width: 48px; height: 48px; border-radius: 12px;
  background: var(--primary-light); color: var(--primary);
  display: grid; place-items: center;
}
.account-status-sub { font-size: 0.78rem; color: var(--slate-500); }
.fact-chips { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 22px; }
.fact-chip {
  background: var(--slate-50); border: 1px solid var(--slate-200);
  border-radius: var(--radius-md); padding: 10px 14px;
}
.fact-chip-lbl { display: block; font-size: 0.68rem; font-weight: 700; text-transform: uppercase; color: var(--slate-400); }
.fact-chip-val { display: block; font-size: 0.84rem; font-weight: 700; color: var(--slate-800); margin-top: 2px; overflow: hidden; text-overflow: ellipsis; }

.card-actions-footer { display: flex; flex-wrap: wrap; gap: 8px; border-top: 1px solid var(--slate-100); padding-top: 18px; }

/* Passo 2 - Lote Form */
.batch-form { display: flex; flex-direction: column; gap: 16px; }
.form-group { display: flex; flex-direction: column; gap: 6px; }
.field-label-row { display: flex; justify-content: space-between; align-items: center; }
.field-label-row label, .form-group label { font-size: 0.82rem; font-weight: 700; color: var(--slate-700); }
.text-link {
  background: none; border: none; padding: 0; font-size: 0.78rem;
  font-weight: 700; color: var(--primary); text-decoration: underline;
}
.form-row-compact { display: flex; gap: 12px; align-items: flex-end; }
.flex-2 { flex: 2; }
.flex-1 { flex: 1; }

.qty-pill-selector { display: flex; align-items: center; gap: 8px; }
.input-qty {
  width: 70px !important; text-align: center; font-weight: 700; font-size: 1rem;
  padding: 8px !important; min-height: 42px !important;
}
.quick-qty-pills { display: flex; gap: 4px; }
.qty-pill {
  border: 1px solid var(--slate-300); border-radius: 8px; background: white;
  padding: 8px 12px; font-size: 0.8rem; font-weight: 700; color: var(--slate-600);
  transition: all 0.15s;
}
.qty-pill:hover, .qty-pill.active {
  background: var(--slate-900); color: white; border-color: var(--slate-900);
}

select, input, textarea {
  width: 100%; border: 1.5px solid var(--slate-300); border-radius: var(--radius-md);
  padding: 10px 14px; font-size: 0.9rem; color: var(--slate-800); background: #ffffff;
  transition: border-color 0.15s, box-shadow 0.15s;
}
select:focus, input:focus, textarea:focus {
  outline: none; border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(0, 168, 132, 0.15);
}
.select-lg { min-height: 44px; font-weight: 600; }
.select-clean { min-height: 42px; }

/* CTAs Principais */
.main-cta-group {
  display: grid; grid-template-columns: 1fr 1.2fr; gap: 12px; margin-top: 6px;
}
.button {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 10px 18px; border-radius: var(--radius-md);
  font-weight: 700; font-size: 0.88rem; border: none; transition: all 0.15s ease;
}
.button:hover:not(:disabled) { transform: translateY(-1px); box-shadow: var(--shadow-sm); }
.button:active:not(:disabled) { transform: translateY(0); }
.button:disabled { opacity: 0.55; cursor: wait; }

.button.primary {
  background: var(--primary); color: white;
  box-shadow: 0 2px 10px rgba(0, 168, 132, 0.3);
}
.button.primary:hover:not(:disabled) { background: var(--primary-hover); }

.button.secondary {
  background: white; border: 1.5px solid var(--slate-300); color: var(--slate-700);
}
.button.secondary:hover:not(:disabled) { background: var(--slate-50); border-color: var(--slate-400); }

.button.ghost { background: transparent; color: var(--slate-600); }
.button.ghost:hover:not(:disabled) { background: var(--slate-100); color: var(--slate-900); }

.button.danger { background: var(--red-50); border: 1.5px solid var(--red-500); color: var(--red-700); }
.button.danger:hover:not(:disabled) { background: var(--red-500); color: white; }

.button.small { min-height: 34px; padding: 6px 12px; font-size: 0.78rem; border-radius: 8px; }

/* Badges */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 4px 10px; border-radius: 999px; font-size: 0.72rem; font-weight: 700;
}
.badge.active { background: var(--green-50); color: var(--green-500); border: 1px solid rgba(16, 185, 129, 0.3); }
.badge.warning { background: var(--amber-50); color: var(--amber-700); border: 1px solid rgba(245, 158, 11, 0.3); }
.badge.danger { background: var(--red-50); color: var(--red-700); border: 1px solid rgba(239, 68, 68, 0.3); }
.badge.neutral { background: var(--slate-100); color: var(--slate-600); }

/* Notice Box */
.notice {
  margin-bottom: 20px; padding: 14px 18px; border-radius: var(--radius-md);
  font-size: 0.88rem; font-weight: 600; display: flex; align-items: center; gap: 10px;
  background: var(--primary-light); color: var(--primary-dark); border: 1px solid rgba(0, 168, 132, 0.25);
}
.notice.error { background: var(--red-50); color: var(--red-700); border-color: rgba(239, 68, 68, 0.25); }
.notice.warning { background: var(--amber-50); color: var(--amber-700); border-color: rgba(245, 158, 11, 0.25); }

/* Passo 3: Prévia & Simulador do WhatsApp */
.preview-studio { margin-top: 24px; padding: 28px; }
.preview-header {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 20px;
  border-bottom: 1px solid var(--slate-200); padding-bottom: 20px; margin-bottom: 20px;
}
.step-pill-wrapper { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.badge-count {
  font-size: 0.76rem; font-weight: 700; color: var(--slate-600);
  background: var(--slate-100); padding: 3px 8px; border-radius: 6px;
}
.preview-title { margin: 0 0 4px; font-size: 1.45rem; font-weight: 700; color: var(--slate-900); }
.preview-subtitle { margin: 0; font-size: 0.85rem; color: var(--slate-500); }

.decisions-banner {
  background: var(--slate-50); border: 1px solid var(--slate-200);
  border-radius: var(--radius-md); padding: 16px; margin-bottom: 24px;
}
.decisions-banner-title { display: block; font-size: 0.72rem; font-weight: 800; text-transform: uppercase; color: var(--slate-400); margin-bottom: 10px; }
.decision-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.decision {
  background: white; border: 1px solid var(--slate-200); border-radius: 8px;
  padding: 10px 12px;
}
.decision small { display: block; font-size: 0.65rem; font-weight: 800; text-transform: uppercase; color: var(--slate-400); }
.decision strong { display: block; font-size: 0.95rem; font-weight: 700; color: var(--slate-900); margin: 3px 0 2px; }
.decision span { display: block; font-size: 0.72rem; color: var(--slate-500); line-height: 1.3; }

/* Grid da Prévia: Tabela + Mockup do WhatsApp */
.preview-stage-grid {
  display: grid; grid-template-columns: 1.15fr 360px; gap: 28px; align-items: start;
}
.table-column { display: flex; flex-direction: column; gap: 12px; }
.table-title-row { display: flex; justify-content: space-between; align-items: center; }
.table-title-row h4 { margin: 0; font-size: 0.95rem; font-weight: 700; color: var(--slate-800); }
.table-title-row small { font-size: 0.74rem; color: var(--slate-400); }

.table-wrap {
  border: 1px solid var(--slate-200); border-radius: var(--radius-md);
  overflow: hidden; max-height: 520px; overflow-y: auto;
}
.preview-table { width: 100%; border-collapse: collapse; font-size: 0.84rem; text-align: left; }
.preview-table th {
  background: var(--slate-50); padding: 10px 14px; font-size: 0.7rem;
  font-weight: 700; text-transform: uppercase; color: var(--slate-500);
  border-bottom: 1px solid var(--slate-200); position: sticky; top: 0; z-index: 2;
}
.preview-table td {
  padding: 12px 14px; border-bottom: 1px solid var(--slate-100);
  vertical-align: middle; cursor: pointer; transition: background 0.1s;
}
.preview-table tr:hover td { background: var(--slate-50); }
.preview-table tr.selected-row td { background: var(--primary-light); font-weight: 600; }

/* ============================================================
   PHONE MOCKUP DO WHATSAPP (Simulador Realista de Celular)
   ============================================================ */
.phone-column { display: flex; flex-direction: column; align-items: center; }
.phone-frame {
  width: 340px; height: 550px; background: #111827; border-radius: 40px;
  padding: 12px; box-shadow: 0 25px 50px -12px rgba(15, 23, 42, 0.4), 0 0 0 4px #374151;
  position: relative; display: flex; flex-direction: column;
}
.phone-speaker {
  width: 60px; height: 4px; background: #374151; border-radius: 99px;
  position: absolute; top: 7px; left: calc(50% - 30px); z-index: 10;
}
.phone-camera {
  width: 8px; height: 8px; background: #1f2937; border-radius: 50%;
  position: absolute; top: 6px; right: 90px; z-index: 10;
}

.wa-screen {
  width: 100%; height: 100%; background: var(--wa-bg); border-radius: 30px;
  overflow: hidden; display: flex; flex-direction: column; position: relative;
}
/* Topo do WhatsApp */
.wa-topbar {
  background: var(--primary-dark); color: white; padding: 10px 14px;
  display: flex; align-items: center; gap: 10px; flex-shrink: 0;
}
.wa-back-btn {
  background: none; border: none; color: white; font-size: 1.1rem;
  padding: 0; margin-right: -4px;
}
.wa-avatar {
  width: 34px; height: 34px; border-radius: 50%; background: #ffffff;
  color: var(--primary-dark); font-weight: 800; font-size: 0.78rem;
  display: grid; place-items: center; flex-shrink: 0;
}
.wa-contact-info { flex: 1; min-width: 0; }
.wa-contact-info strong {
  display: block; font-size: 0.84rem; font-weight: 600; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis;
}
.wa-badge-verified {
  display: block; font-size: 0.65rem; color: #a3e635; line-height: 1.2;
}
.wa-actions-dots { font-size: 1.1rem; opacity: 0.8; }

/* Área do Chat */
.wa-chat-area {
  flex: 1; padding: 14px; overflow-y: auto; display: flex; flex-direction: column;
  background-image: radial-gradient(#d1d5db 1px, transparent 0);
  background-size: 16px 16px;
}
.wa-date-pill {
  align-self: center; background: rgba(255, 255, 255, 0.9);
  padding: 3px 10px; border-radius: 6px; font-size: 0.65rem;
  font-weight: 700; color: #6b7280; box-shadow: 0 1px 2px rgba(0,0,0,0.06);
  margin-bottom: 14px;
}

/* Balão Oficial */
.wa-bubble {
  align-self: flex-start; width: 100%; max-width: 100%; background: var(--wa-bubble);
  border-radius: 0 10px 10px 10px; padding: 10px 12px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.12); position: relative;
  font-size: 0.82rem; color: #111827; line-height: 1.45; word-break: break-word;
}
.wa-bubble::before {
  content: ""; position: absolute; top: 0; left: -8px; width: 0; height: 0;
  border-top: 10px solid var(--wa-bubble); border-left: 8px solid transparent;
}
.wa-msg-header { font-weight: 700; margin-bottom: 6px; }
.wa-msg-body { white-space: pre-wrap; }
.wa-var-tag {
  display: inline-block; background: #e0f2fe; color: #0369a1;
  font-weight: 700; padding: 1px 5px; border-radius: 4px; font-size: 0.78rem;
}
.wa-msg-footer {
  margin-top: 8px; font-size: 0.7rem; color: #6b7280; line-height: 1.3;
}
.wa-msg-meta {
  display: flex; justify-content: flex-end; align-items: center; gap: 4px;
  margin-top: 4px; font-size: 0.66rem; color: #9ca3af;
}
.wa-msg-ticks { color: var(--wa-ticks); font-weight: 700; }

/* Botões do Balão */
.wa-buttons-stack {
  display: flex; flex-direction: column; gap: 4px; margin-top: 4px; width: 100%;
}
.wa-btn-action {
  width: 100%; background: white; border: none; border-radius: 8px;
  padding: 8px; font-size: 0.8rem; font-weight: 600; color: #00a884;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08); text-align: center;
}

/* Switcher Footer no Mockup */
.wa-switcher-footer {
  background: white; border-top: 1px solid var(--slate-200); padding: 8px 12px;
  display: flex; justify-content: space-between; align-items: center; flex-shrink: 0;
}
.wa-switch-btn {
  background: var(--slate-100); border: 1px solid var(--slate-300);
  border-radius: 6px; padding: 4px 10px; font-size: 0.72rem; font-weight: 700;
  color: var(--slate-700);
}
.wa-switch-btn:hover { background: var(--slate-200); }
.wa-indicator { font-size: 0.75rem; font-weight: 700; color: var(--slate-500); }
.phone-tip { font-size: 0.75rem; color: var(--slate-500); text-align: center; margin-top: 12px; }

/* Passo 4 - Acompanhamento ao Vivo */
.job-card-live { margin-top: 24px; padding: 26px; }
.job-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 20px; }
.job-heading { margin: 6px 0 2px; font-size: 1.35rem; font-weight: 700; color: var(--slate-900); }
.job-sub { margin: 0; font-size: 0.82rem; color: var(--slate-500); }

.progress-container { margin-bottom: 20px; }
.progress-track {
  height: 12px; border-radius: 99px; background: var(--slate-200); overflow: hidden;
}
#progress-bar {
  display: block; width: 0; height: 100%; background: linear-gradient(90deg, var(--primary), var(--green-500));
  border-radius: inherit; transition: width 0.3s ease;
}
.progress-details { margin-top: 8px; }
.progress-text-live { font-size: 0.85rem; font-weight: 600; color: var(--slate-700); margin: 0; }

.job-control-row { display: flex; gap: 8px; margin-bottom: 20px; }

.event-console-wrapper {
  background: var(--slate-950); border-radius: var(--radius-md);
  border: 1px solid var(--slate-800); overflow: hidden;
}
.event-console-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 8px 16px; background: var(--slate-900); color: var(--slate-400);
  font-size: 0.72rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em;
}
.live-dot {
  width: 8px; height: 8px; border-radius: 50%; background: var(--green-500);
  box-shadow: 0 0 8px var(--green-500);
}
.event-log {
  max-height: 240px; overflow-y: auto; margin: 0; padding: 12px 16px;
  list-style: none; font-family: var(--font-mono); font-size: 0.78rem;
}
.event-log li {
  display: flex; gap: 14px; padding: 4px 0; color: var(--slate-300);
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}
.event-log time { color: var(--slate-500); flex-shrink: 0; }
.event-log .failed { color: #f87171; font-weight: 600; }

/* Passo 5 - Histórico */
.history-section { margin-top: 36px; }
.section-heading-row {
  display: flex; justify-content: space-between; align-items: flex-end; margin-bottom: 18px;
}
.section-heading-row h2 { margin: 2px 0 0; font-size: 1.3rem; font-weight: 700; color: var(--slate-900); }
.history-list { display: flex; flex-direction: column; gap: 10px; }
.history-item {
  display: flex; justify-content: space-between; align-items: center;
  background: white; border: 1px solid var(--slate-200); border-radius: var(--radius-md);
  padding: 16px 20px; box-shadow: var(--shadow-sm);
}
.history-item h3 { margin: 0 0 3px; font-size: 0.95rem; font-weight: 700; color: var(--slate-900); }
.history-item p { margin: 0; font-size: 0.78rem; color: var(--slate-500); }
.history-metrics { display: flex; align-items: center; gap: 8px; }
.history-empty {
  padding: 30px; border: 1.5px dashed var(--slate-300); border-radius: var(--radius-md);
  text-align: center; color: var(--slate-500); font-size: 0.88rem; background: white;
}

/* Modais & Diálogos */
dialog {
  width: min(640px, calc(100% - 32px)); max-height: calc(100vh - 40px);
  padding: 0; border: none; border-radius: 20px; background: #ffffff;
  box-shadow: var(--shadow-modal); overflow: hidden;
}
dialog::backdrop { background: rgba(15, 23, 42, 0.65); backdrop-filter: blur(4px); }
.dialog-form { padding: 28px; display: flex; flex-direction: column; gap: 18px; max-height: 85vh; overflow-y: auto; }
.dialog-header-clean {
  display: flex; justify-content: space-between; align-items: flex-start;
  border-bottom: 1px solid var(--slate-100); padding-bottom: 14px;
}
.dialog-header-clean h2 { margin: 0; font-size: 1.4rem; font-weight: 700; color: var(--slate-900); }
.close-icon-btn {
  width: 32px; height: 32px; border-radius: 50%; border: none; background: var(--slate-100);
  font-size: 1.3rem; display: grid; place-items: center; color: var(--slate-600);
}
.close-icon-btn:hover { background: var(--slate-200); color: var(--slate-900); }
.field-hint { font-size: 0.72rem; color: var(--slate-400); margin-top: 3px; }
.dialog-actions-row {
  display: flex; justify-content: flex-end; gap: 10px; border-top: 1px solid var(--slate-100);
  padding-top: 20px; margin-top: 6px;
}
.dialog-actions-row.center { justify-content: center; }

/* Guia do Modal cURL */
.curl-guide-banner {
  background: var(--slate-50); border: 1px solid var(--slate-200); border-radius: var(--radius-md);
  padding: 14px 16px; display: flex; flex-direction: column; gap: 8px;
}
.guide-step { display: flex; align-items: center; gap: 10px; font-size: 0.8rem; color: var(--slate-700); }
.guide-num {
  width: 20px; height: 20px; border-radius: 50%; background: var(--primary);
  color: white; font-weight: 700; font-size: 0.7rem; display: grid; place-items: center; flex-shrink: 0;
}

/* Fórmula do Modal de Preset */
.formula-banner {
  background: linear-gradient(135deg, #f0fdf4, #ecfdf5); border: 1px solid #bbf7d0;
  border-radius: var(--radius-md); padding: 16px;
}
.formula-title { font-size: 0.78rem; font-weight: 700; color: #166534; margin-bottom: 8px; }
.formula-blocks { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.f-pill {
  background: white; border: 1px solid #86efac; padding: 4px 10px;
  border-radius: 6px; font-size: 0.76rem; font-weight: 700; color: #15803d;
}
.f-pill.final { background: var(--primary); color: white; border-color: var(--primary); }
.f-plus, .f-equal { font-weight: 800; color: #16a34a; font-size: 0.9rem; }
.formula-hint { margin: 10px 0 0; font-size: 0.74rem; color: #166534; line-height: 1.4; }

.field-row-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.vars-toolbar {
  display: flex; align-items: center; gap: 8px; background: var(--slate-50);
  border: 1px solid var(--slate-200); padding: 8px 12px; border-radius: 8px;
}
.vars-lbl { font-size: 0.74rem; font-weight: 700; color: var(--slate-500); }
.btn-insert-var {
  background: white; border: 1px solid var(--slate-300); border-radius: 6px;
  padding: 4px 8px; font-size: 0.72rem; font-weight: 700; color: var(--primary);
}
.btn-insert-var:hover { background: var(--primary-light); border-color: var(--primary); }

.tag-counter { font-size: 0.72rem; font-weight: 500; color: var(--slate-400); }
.blocks-container { display: flex; flex-direction: column; gap: 14px; }

.advanced-details {
  border: 1px solid var(--slate-200); border-radius: var(--radius-md); overflow: hidden;
}
.advanced-summary {
  padding: 12px 16px; background: var(--slate-50); font-size: 0.84rem;
  font-weight: 700; color: var(--slate-700); cursor: pointer;
}
.details-content-box { padding: 16px; display: flex; flex-direction: column; gap: 12px; }

/* Modal de Confirmação */
.confirm-modal-body { text-align: center; align-items: center; padding: 36px 28px; }
.confirm-icon-pulse {
  width: 56px; height: 56px; border-radius: 50%; background: var(--primary-light);
  color: var(--primary); display: grid; place-items: center; margin-bottom: 12px;
}
.confirm-title { margin: 0 0 8px; font-size: 1.4rem; font-weight: 700; color: var(--slate-900); }
.confirm-text { margin: 0 0 20px; font-size: 0.88rem; color: var(--slate-600); max-width: 440px; }

/* ==========================================================================
   ESTÚDIO GHL: SUBACCOUNT BAR, SPLIT GRID & PRÉ-VISUALIZADOR REALISTA
   ========================================================================== */

/* Barra Superior de Subconta */
.subaccount-bar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 20px; margin-bottom: 20px; background: white;
  border: 1px solid var(--slate-200); border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
}
.subaccount-bar-info { display: flex; align-items: center; gap: 14px; }
.account-avatar-sm {
  width: 38px; height: 38px; border-radius: 10px;
  background: var(--primary-light); color: var(--primary);
  display: grid; place-items: center;
}
.subaccount-name-row { display: flex; align-items: center; gap: 10px; }
.subaccount-name-row strong { font-size: 1.05rem; font-weight: 700; color: var(--slate-900); }
.subaccount-meta-row {
  display: flex; align-items: center; gap: 8px; font-size: 0.78rem; color: var(--slate-500); margin-top: 2px;
}
.subaccount-meta-row code {
  font-family: var(--font-mono); background: var(--slate-100);
  padding: 2px 6px; border-radius: 4px; color: var(--slate-700);
}
.subaccount-bar-actions { display: flex; align-items: center; gap: 8px; }

/* Grid do Estúdio GHL */
.ghl-studio-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(360px, 1fr);
  gap: 24px;
  align-items: start;
  margin-bottom: 24px;
}
.studio-editor-card { padding: 24px; }
.badge-step-title { display: flex; align-items: center; gap: 10px; }
.badge-step-title h2 { margin: 0; font-size: 1.2rem; font-weight: 700; color: var(--slate-900); }
.header-action-buttons { display: flex; align-items: center; gap: 8px; }

.studio-batch-row {
  display: flex; gap: 14px; margin-top: 16px;
}
.flex-3 { flex: 3; }
.flex-2 { flex: 2; }
.flex-1 { flex: 1; }

/* Configuração e Prévia do Nome dos Modelos */
.studio-naming-box {
  background: #f8fafc;
  border: 1px solid var(--slate-200);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  margin-top: 14px;
}
.naming-fields-row {
  display: flex;
  gap: 12px;
}
.naming-live-preview-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #ffffff;
  border: 1px solid var(--slate-200);
  border-radius: 8px;
  padding: 8px 12px;
  margin-top: 10px;
  gap: 8px;
  flex-wrap: wrap;
}
.naming-live-preview-title {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.82rem;
  color: var(--slate-700);
  flex-wrap: wrap;
}
.naming-preview-tag {
  font-weight: 700;
  color: var(--slate-600);
}
.naming-preview-value {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: #0284c7;
  background: #e0f2fe;
  padding: 2px 7px;
  border-radius: 4px;
}
.naming-preview-sep {
  font-size: 0.72rem;
  color: var(--slate-400);
}
.naming-preview-hint {
  font-size: 0.72rem;
  color: var(--slate-400);
}

/* Tag do Nome do Modelo no Balão WhatsApp */
.ghl-stage-model-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(4px);
  border: 1px solid rgba(0, 0, 0, 0.08);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
  padding: 4px 10px;
  border-radius: 6px;
  margin-bottom: 8px;
  font-size: 0.76rem;
  font-weight: 600;
  color: var(--slate-700);
}
.ghl-stage-model-badge code {
  font-family: var(--font-mono);
  font-weight: 700;
  color: var(--slate-900);
  background: #e2e8f0;
  padding: 1px 5px;
  border-radius: 3px;
}

.studio-divider {
  border: 0; border-top: 1px solid var(--slate-200); margin: 20px 0;
}

.studio-textarea {
  width: 100%; border: 1.5px solid var(--slate-200); border-radius: var(--radius-sm);
  padding: 12px; font-size: 0.88rem; line-height: 1.5; color: var(--slate-800);
  resize: vertical; min-height: 110px; transition: border-color 0.15s;
}
.studio-textarea:focus {
  outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(0, 168, 132, 0.15);
}
.studio-input {
  width: 100%; border: 1.5px solid var(--slate-200); border-radius: var(--radius-sm);
  padding: 9px 12px; font-size: 0.86rem; color: var(--slate-800);
}
.studio-input:focus {
  outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(0, 168, 132, 0.15);
}

.studio-var-shortcuts { display: flex; gap: 6px; margin-top: 8px; }
.btn-var-shortcut {
  background: var(--slate-100); border: 1px solid var(--slate-200);
  border-radius: 6px; padding: 4px 10px; font-size: 0.74rem; font-weight: 700;
  color: var(--primary-dark); cursor: pointer; transition: all 0.1s;
}
.btn-var-shortcut:hover {
  background: var(--primary-light); border-color: var(--primary); color: var(--primary);
}

/* Seção de Mapeamento de Variáveis (GHL Style) */
.variable-mapping-section {
  background: var(--slate-50); border: 1px solid var(--slate-200);
  border-radius: var(--radius-md); padding: 16px; margin-top: 16px;
}
.mapping-section-header {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 14px;
}
.mapping-title { margin: 0 0 3px; font-size: 0.94rem; font-weight: 700; color: var(--slate-900); }
.mapping-subtitle { margin: 0; font-size: 0.76rem; color: var(--slate-500); line-height: 1.4; }

.variable-mapping-list { display: flex; flex-direction: column; gap: 10px; }
.var-mapping-row {
  display: grid;
  grid-template-columns: 54px minmax(180px, 1.3fr) minmax(180px, 1.6fr);
  gap: 10px;
  align-items: center;
  background: white;
  border: 1px solid var(--slate-200);
  border-radius: 8px;
  padding: 8px 12px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
}
.var-badge-cell {
  font-family: var(--font-mono); font-weight: 700; font-size: 0.8rem;
  color: var(--primary-dark); background: var(--primary-light);
  padding: 6px 8px; border-radius: 6px; text-align: center;
}
.var-field-picker-btn {
  display: flex; align-items: center; justify-content: space-between; gap: 6px;
  padding: 8px 10px; background: white; border: 1px solid var(--slate-300);
  border-radius: 6px; font-size: 0.8rem; color: var(--slate-800); text-align: left;
  transition: all 0.15s;
}
.var-field-picker-btn:hover {
  border-color: var(--primary); background: #fcfdfd;
}
.var-field-txt {
  font-family: var(--font-mono); font-size: 0.76rem; color: #0369a1;
  background: #f0f9ff; padding: 2px 6px; border-radius: 4px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.var-tag-icon { color: var(--slate-400); font-size: 0.85rem; }
.var-example-input {
  padding: 7px 10px; border: 1px solid var(--slate-300); border-radius: 6px;
  font-size: 0.8rem; color: var(--slate-800); width: 100%;
}
.var-example-input:focus {
  outline: none; border-color: var(--primary);
}

.studio-bottom-fields {
  display: grid; grid-template-columns: 1fr 1fr; gap: 14px;
}
.studio-footer-cta {
  display: flex; gap: 12px; margin-top: 24px; padding-top: 16px;
  border-top: 1px solid var(--slate-200);
}
.studio-footer-cta .button { flex: 1; justify-content: center; padding: 12px 18px; font-size: 0.95rem; }

/* Coluna Direita: Pré-visualizador GHL */
.sticky-preview {
  position: sticky; top: 88px; padding: 20px;
}
.ghl-preview-header {
  display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px;
}
.ghl-preview-title {
  display: flex; align-items: center; gap: 8px; font-size: 0.95rem; color: var(--slate-800);
}
.ghl-var-switcher {
  display: flex; align-items: center; gap: 6px; background: var(--slate-100);
  border: 1px solid var(--slate-200); border-radius: 999px; padding: 2px 8px;
}
.ghl-var-nav {
  background: none; border: none; font-size: 0.75rem; color: var(--slate-600);
  padding: 2px 6px; cursor: pointer; border-radius: 4px;
}
.ghl-var-nav:hover { color: var(--primary); background: white; }
.ghl-var-label { font-size: 0.74rem; font-weight: 700; color: var(--slate-700); }

/* Fundo Bege Estilo WhatsApp / GHL */
.ghl-whatsapp-stage {
  background-color: #eae6df;
  background-image: 
    radial-gradient(#d3cbbe 1px, transparent 1px),
    radial-gradient(#d3cbbe 1px, transparent 1px);
  background-size: 20px 20px;
  background-position: 0 0, 10px 10px;
  border-radius: 12px;
  padding: 22px 16px;
  min-height: 380px;
  border: 1px solid #d9d2c5;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.04);
}

/* Balão Branco do WhatsApp */
.ghl-wa-bubble {
  background: #ffffff;
  border-radius: 8px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.15);
  padding: 12px 14px 8px 14px;
  width: 92%;
  position: relative;
  font-size: 0.86rem;
  line-height: 1.44;
  color: #111b21;
  word-break: break-word;
}
.ghl-bubble-header {
  font-weight: 700; color: var(--slate-900); margin-bottom: 6px; font-size: 0.9rem;
}
.ghl-bubble-body {
  white-space: pre-wrap; font-size: 0.86rem; color: #111b21;
}
.ghl-bubble-footer {
  font-size: 0.74rem; color: #667781; margin-top: 8px; line-height: 1.35;
  border-top: 1px dashed #e2e8f0; padding-top: 6px;
}
.ghl-bubble-meta {
  display: flex; align-items: center; justify-content: flex-end; gap: 4px;
  margin-top: 4px; font-size: 0.68rem; color: #667781;
}
.ghl-bubble-ticks { color: var(--wa-ticks); font-weight: bold; letter-spacing: -1px; }

/* Botões de Resposta Rápida (com a setinha ↩) */
.ghl-buttons-stack {
  display: flex; flex-direction: column; gap: 6px; width: 92%; margin-top: 8px;
}
.ghl-quick-reply {
  background: #ffffff; border-radius: 8px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
  padding: 9px 12px; color: #00a884; font-weight: 600; font-size: 0.82rem;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  transition: all 0.15s; border: none; width: 100%;
}
.ghl-quick-reply:hover { background: #f9fbfb; }
.ghl-qr-icon {
  font-size: 0.95rem; color: #00a884; font-weight: bold;
}
.ghl-preview-footer-note {
  margin-top: 12px; font-size: 0.74rem; color: var(--slate-500); line-height: 1.35;
}

/* Popover Flutuante de Campos da Subconta (Estilo GHL) */
.fields-popover {
  position: fixed;
  z-index: 9999;
  width: 320px;
  max-height: 380px;
  background: white;
  border-radius: 10px;
  box-shadow: 0 12px 36px rgba(15, 23, 42, 0.22), 0 2px 8px rgba(15, 23, 42, 0.08);
  border: 1px solid var(--slate-200);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: fadeIn 0.12s ease-out;
}
.fields-popover-search {
  display: flex; align-items: center; gap: 8px; padding: 10px 14px;
  background: var(--slate-50); border-bottom: 1px solid var(--slate-200);
}
.fields-popover-search input {
  border: none; outline: none; background: transparent; font-size: 0.82rem; width: 100%;
}
.popover-categories {
  overflow-y: auto; max-height: 310px; padding: 6px 0;
}
.popover-cat-title {
  padding: 6px 14px 4px 14px; font-size: 0.68rem; font-weight: 800;
  text-transform: uppercase; letter-spacing: 0.05em; color: var(--slate-400);
}
.popover-field-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 14px; font-size: 0.8rem; color: var(--slate-800);
  cursor: pointer; transition: background 0.1s;
}
.popover-field-item:hover {
  background: var(--slate-100); color: var(--primary);
}
.popover-field-item .field-key-badge {
  font-family: var(--font-mono); font-size: 0.72rem; color: #0284c7;
  background: #e0f2fe; padding: 2px 6px; border-radius: 4px;
}

/* ==========================================================================
   Responsividade Mobile-First & Otimizações Touch (Smartphones & Tablets)
   ========================================================================== */

/* Elementos do Seletor Mobile */
.mobile-studio-switch { display: none; }
.mobile-preview-jump-row { display: none; }
.mobile-back-editor-btn { display: none; }
.fields-popover-drag-pill { display: none; }
.fields-popover-header-mobile { display: none; }
.fields-popover-backdrop {
  position: fixed; inset: 0; z-index: 9998;
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(2px);
  animation: fadeIn 0.15s ease-out;
}
.sidebar-chevron {
  display: inline-block; transition: transform 0.2s; font-size: 0.85rem; color: var(--slate-400);
}

/* ==========================================================================
   Dashboard de Estatísticas & Métricas de Uso dos Modelos
   ========================================================================== */
.stats-dashboard-card {
  padding: 24px;
  background: white;
  border-radius: var(--radius-lg);
  border: 1px solid var(--slate-200);
  box-shadow: var(--shadow-sm);
  margin-bottom: 24px;
}

.stats-top-bar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--slate-200);
  flex-wrap: wrap;
}

.stats-pill-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 6px;
}

.stats-source-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--slate-600);
  background: var(--slate-100);
  border: 1px solid var(--slate-200);
  padding: 3px 10px;
  border-radius: 999px;
}

.stats-title-group h2 {
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--slate-900);
  margin: 4px 0;
}

.stats-desc {
  font-size: 0.85rem;
  color: var(--slate-500);
  margin: 0;
}

/* 4 Cards de Métricas Principais (KPIs) */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 20px;
}

.kpi-card {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 18px;
  background: #ffffff;
  border: 1px solid var(--slate-200);
  border-radius: var(--radius-md);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
  transition: transform 0.15s, box-shadow 0.15s;
}

.kpi-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.07);
}

.kpi-icon {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  font-size: 1.3rem;
  flex-shrink: 0;
}

.kpi-card-blue .kpi-icon { background: #e0f2fe; color: #0284c7; }
.kpi-card-green .kpi-icon { background: #dcfce7; color: #16a34a; }
.kpi-card-purple .kpi-icon { background: #f3e8ff; color: #9333ea; }
.kpi-card-orange .kpi-icon { background: #ffedd5; color: #ea580c; }

.kpi-body {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
}

.kpi-label {
  font-size: 0.74rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--slate-500);
}

.kpi-number {
  font-size: 1.65rem;
  font-weight: 800;
  color: var(--slate-900);
  line-height: 1.1;
}

.kpi-sub {
  font-size: 0.72rem;
  color: var(--slate-400);
}

.kpi-badge-row {
  margin-top: 4px;
}

.kpi-rate-tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
}

.tag-green { background: #dcfce7; color: #15803d; }
.tag-purple { background: #f3e8ff; color: #7e22ce; }

/* Faixa de Saúde e Aprovação */
.stats-health-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--slate-50);
  border: 1px solid var(--slate-200);
  border-radius: var(--radius-md);
  padding: 10px 16px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.health-col {
  display: flex;
  align-items: center;
}

.health-badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--slate-700);
}

.health-badge strong {
  font-weight: 800;
}

.health-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.dot-green { background: #16a34a; }
.dot-yellow { background: #eab308; }
.dot-red { background: #dc2626; }

.health-col-total {
  margin-left: auto;
  border-left: 1px solid var(--slate-300);
  padding-left: 14px;
}

/* Filtros da Tabela */
.stats-filter-row {
  display: flex;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.stats-search-group {
  flex: 3;
  margin-bottom: 0;
}

.stats-filter-select {
  flex: 1;
  min-width: 140px;
  margin-bottom: 0;
}

/* Tabela de Estatísticas */
.stats-table-wrapper {
  overflow-x: auto;
  border: 1px solid var(--slate-200);
  border-radius: var(--radius-md);
  background: white;
}

.stats-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}

.stats-table th {
  background: #f8fafc;
  padding: 12px 14px;
  font-size: 0.76rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--slate-600);
  border-bottom: 1.5px solid var(--slate-200);
  white-space: nowrap;
}

.stats-table td {
  padding: 12px 14px;
  font-size: 0.84rem;
  color: var(--slate-800);
  border-bottom: 1px solid var(--slate-100);
  vertical-align: middle;
}

.stats-table tbody tr:hover {
  background: #f8fafc;
}

.model-name-cell {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.model-name-link {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--slate-900);
}

.model-date-text {
  font-size: 0.72rem;
  color: var(--slate-400);
}

.metric-bar-cell {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 90px;
}

.metric-bar-bg {
  width: 100%;
  height: 5px;
  background: #e2e8f0;
  border-radius: 999px;
  overflow: hidden;
}

.metric-bar-fill {
  height: 100%;
  border-radius: 999px;
}

.bar-blue { background: #0284c7; }
.bar-green { background: #16a34a; }
.bar-purple { background: #9333ea; }

/* Status Badges */
.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.74rem;
  font-weight: 700;
  white-space: nowrap;
}

.status-approved { background: #dcfce7; color: #15803d; }
.status-paused { background: #fef9c3; color: #854d0e; }
.status-rejected { background: #fee2e2; color: #991b1b; }
.status-pending { background: #e0f2fe; color: #0369a1; }

.stats-mobile-cards {
  display: none;
}

/* Telas de Tablets / Telas Médias (<= 1080px) */
@media (max-width: 1080px) {
  .ghl-studio-grid {
    display: block;
  }
  .sticky-preview {
    position: static;
    margin-bottom: 20px;
    padding: 16px;
  }
  .preview-stage-grid { grid-template-columns: 1fr; }
  .phone-column { margin-bottom: 20px; }

  /* Seletor Tabulado de Estúdio (Editor vs Prévia WhatsApp) */
  .mobile-studio-switch {
    display: flex;
    background: #e2e8f0;
    padding: 4px;
    border-radius: 12px;
    margin-bottom: 16px;
    gap: 4px;
  }
  .mobile-switch-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 12px;
    font-size: 0.86rem;
    font-weight: 700;
    color: var(--slate-600);
    background: transparent;
    border: none;
    border-radius: 9px;
    transition: all 0.15s ease-in-out;
    min-height: 44px;
  }
  .mobile-switch-btn.is-active {
    background: #ffffff;
    color: var(--slate-900);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
  }
  .mobile-badge-pill {
    font-size: 0.72rem;
    background: var(--primary);
    color: white;
    padding: 2px 7px;
    border-radius: 999px;
    font-weight: 800;
  }

  /* Alternância de Abas */
  .ghl-studio-grid[data-mobile-view="editor"] .studio-right-column {
    display: none !important;
  }
  .ghl-studio-grid[data-mobile-view="preview"] .studio-left-column {
    display: none !important;
  }

  /* Botão de Atalho Rápido para Prévia dentro do Editor */
  .mobile-preview-jump-row {
    display: block;
    margin-top: 14px;
    padding-top: 12px;
    border-top: 1px dashed var(--slate-200);
  }
  .mobile-preview-jump-btn {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    font-size: 0.88rem;
    font-weight: 700;
    color: var(--primary);
    background: var(--primary-light);
    border: 1.5px solid rgba(0, 168, 132, 0.3);
    border-radius: 10px;
    min-height: 46px;
  }

  /* Botão Voltar ao Editor no Topo da Prévia */
  .mobile-back-editor-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--slate-100);
    border: 1px solid var(--slate-200);
    border-radius: 8px;
    width: 36px;
    height: 36px;
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--slate-700);
    cursor: pointer;
    margin-right: 8px;
  }
}

/* Telas de Celular (<= 768px) */
@media (max-width: 768px) {
  /* Prevenção de Auto-Zoom no iOS Safari (Fonte >= 16px em campos editáveis) */
  input, select, textarea {
    font-size: 16px !important;
  }

  /* Estrutura da Página */
  .app-shell { grid-template-columns: 1fr; }
  .main-content { padding: 12px 12px 80px; }
  .card { padding: 16px 12px; border-radius: 14px; }

  /* Barra Superior */
  .topbar-inner { padding: 0 14px; height: 60px; }
  .brand-subtitle { display: none; }
  .brand-text strong { font-size: 0.95rem; }
  .brand-badge { width: 34px; height: 34px; border-radius: 8px; }
  .active-account-pill { display: none; } /* Já exibido no card da subconta */

  /* Sidebar Colapsável no Mobile */
  .sidebar {
    border-right: none;
    border-bottom: 1px solid var(--slate-200);
    padding: 12px 14px;
    gap: 10px;
    background: #f8fafc;
  }
  .sidebar-header {
    cursor: pointer;
    user-select: none;
    padding: 4px 0;
  }
  .sidebar.is-collapsed #profile-list,
  .sidebar.is-collapsed .sidebar-footer-tip {
    display: none !important;
  }
  .sidebar:not(.is-collapsed) .sidebar-chevron {
    transform: rotate(180deg);
  }

  /* Stepper Compacto */
  .stepper-nav {
    padding: 10px 14px;
    margin-bottom: 14px;
    gap: 6px;
  }
  .step-circle {
    width: 26px; height: 26px; font-size: 0.76rem;
  }
  .step-label strong { font-size: 0.78rem; }
  .step-label small { display: none; }
  .step-connector { height: 1.5px; margin: 0 6px; }

  /* Subconta Card */
  .subaccount-bar {
    padding: 14px 12px;
    gap: 12px;
  }
  .subaccount-bar-info { gap: 10px; }
  .account-avatar-sm { width: 36px; height: 36px; border-radius: 8px; }
  .subaccount-name-row strong { font-size: 0.95rem; }
  .subaccount-meta-row {
    flex-wrap: wrap; font-size: 0.72rem; gap: 4px;
  }
  .subaccount-meta-row code {
    max-width: 140px; overflow: hidden; text-overflow: ellipsis; vertical-align: bottom;
  }
  .subaccount-bar-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    width: 100%;
  }
  .subaccount-bar-actions #edit-profile {
    grid-column: span 2;
  }
  .subaccount-bar-actions .button {
    min-height: 42px;
    justify-content: center;
  }

  /* Editor do Estúdio */
  .card-badge-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }
  .header-action-buttons {
    display: flex;
    width: 100%;
    gap: 8px;
  }
  .header-action-buttons .button {
    flex: 1;
    justify-content: center;
    min-height: 42px;
    font-size: 0.8rem;
  }

  /* Linha de Preset & Qtd */
  .studio-batch-row {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }
  .naming-fields-row {
    flex-direction: column;
    gap: 10px;
  }
  .naming-live-preview-bar {
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
  }
  .qty-pill-selector {
    width: 100%;
  }
  .quick-qty-pills {
    flex: 1;
  }
  .qty-pill {
    flex: 1;
    text-align: center;
    padding: 10px 4px;
    min-height: 44px;
    font-size: 0.86rem;
  }

  /* Atalhos de Variáveis */
  .studio-var-shortcuts {
    gap: 8px;
    margin-top: 8px;
  }
  .btn-var-shortcut {
    flex: 1;
    min-height: 42px;
    padding: 8px;
    font-size: 0.88rem;
    font-weight: 700;
  }

  /* Mapeamento de Variáveis (Linhas no Mobile) */
  .mapping-section-header {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }
  #sync-subaccount-fields-btn {
    width: 100%;
    justify-content: center;
    min-height: 42px;
  }
  .var-mapping-row {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 10px;
    background: #f8fafc;
    border-radius: 10px;
    border: 1px solid var(--slate-200);
  }
  .var-badge-cell {
    align-self: flex-start;
    padding: 3px 10px;
    font-size: 0.78rem;
  }
  .var-field-picker-btn {
    width: 100%;
    min-height: 44px;
    padding: 8px 12px;
    justify-content: space-between;
  }
  .var-field-picker-btn .var-field-txt {
    font-size: 0.85rem;
  }
  .var-example-input {
    width: 100%;
    min-height: 44px;
    font-size: 16px !important; /* Previne zoom no iPhone */
    padding: 8px 12px;
  }

  /* Rodapé e Botões Opcionais */
  .studio-bottom-fields {
    grid-template-columns: 1fr;
    gap: 12px;
  }
  .studio-input {
    min-height: 44px;
  }

  /* Barra de Disparo Principal (CTAs) */
  .studio-footer-cta {
    flex-direction: column;
    gap: 10px;
  }
  .studio-footer-cta .button {
    width: 100%;
    min-height: 48px;
    font-size: 0.96rem;
  }

  /* Balão WhatsApp no Mobile */
  .ghl-whatsapp-stage {
    padding: 16px 10px;
    min-height: 300px;
  }
  .ghl-wa-bubble {
    width: 100%;
    padding: 10px 12px;
  }
  .ghl-bubble-body {
    font-size: 0.88rem;
  }
  .ghl-buttons-stack {
    width: 100%;
  }
  .ghl-quick-reply {
    min-height: 44px;
    font-size: 0.88rem;
  }

  /* Modais no Mobile */
  dialog {
    width: 96vw !important;
    max-width: 96vw !important;
    border-radius: 16px !important;
    margin: auto !important;
  }
  .dialog-form {
    padding: 18px 14px !important;
    gap: 14px !important;
  }
  .dialog-actions-row {
    flex-direction: column-reverse !important;
    gap: 8px !important;
  }
  .dialog-actions-row .button {
    width: 100% !important;
    min-height: 46px !important;
    justify-content: center !important;
  }

  /* Histórico no Mobile */
  .history-item {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }
  .history-metrics {
    width: 100%;
    justify-content: flex-start;
    flex-wrap: wrap;
  }

  /* Dashboard de Estatísticas no Mobile */
  .topbar-view-switcher {
    width: 100%;
    margin-top: 6px;
    justify-content: center;
  }
  .view-switch-btn {
    flex: 1;
    justify-content: center;
    padding: 8px 10px;
    font-size: 0.8rem;
  }
  .kpi-grid {
    grid-template-columns: 1fr;
    gap: 10px;
  }
  .stats-health-bar {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }
  .health-col-total {
    margin-left: 0;
    border-left: none;
    padding-left: 0;
    border-top: 1px solid var(--slate-200);
    padding-top: 8px;
    width: 100%;
  }
  .stats-filter-row {
    flex-direction: column;
    gap: 10px;
  }
  .stats-table-wrapper {
    display: none;
  }
  .stats-mobile-cards {
    display: flex;
    flex-direction: column;
    gap: 12px;
  }
  .mobile-model-card {
    background: white;
    border: 1px solid var(--slate-200);
    border-radius: var(--radius-md);
    padding: 14px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
  }
  .mobile-card-top {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 8px;
    margin-bottom: 10px;
  }
  .mobile-card-metrics {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    background: #f8fafc;
    border-radius: 8px;
    padding: 10px;
    margin-bottom: 10px;
  }
  .mobile-metric-item {
    display: flex;
    flex-direction: column;
  }
  .mobile-metric-val {
    font-size: 1rem;
    font-weight: 800;
    color: var(--slate-900);
  }
  .mobile-metric-lbl {
    font-size: 0.7rem;
    color: var(--slate-500);
    text-transform: uppercase;
  }
}

/* Bottom Sheet no Celular para o Seletor de Campos (<= 640px) */
@media (max-width: 640px) {
  .fields-popover {
    position: fixed !important;
    top: auto !important;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    width: 100vw !important;
    max-width: 100vw !important;
    max-height: 82vh !important;
    border-radius: 20px 20px 0 0 !important;
    box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.3) !important;
    z-index: 9999 !important;
    border: none !important;
    border-top: 1px solid var(--slate-200) !important;
    animation: slideUpSheet 0.22s cubic-bezier(0.16, 1, 0.3, 1) !important;
  }
  .fields-popover-drag-pill {
    display: block;
    width: 42px;
    height: 4.5px;
    background: #cbd5e1;
    border-radius: 99px;
    margin: 10px auto 4px auto;
  }
  .fields-popover-header-mobile {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 16px;
    border-bottom: 1px solid var(--slate-100);
    font-size: 0.92rem;
    font-weight: 700;
    color: var(--slate-800);
  }
  .popover-close-btn {
    background: var(--slate-100);
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--slate-600);
    cursor: pointer;
  }
  .fields-popover-search input {
    font-size: 16px !important; /* Sem zoom no iOS */
  }
  .popover-field-item {
    padding: 12px 16px;
    min-height: 46px;
  }

  @keyframes slideUpSheet {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
  }
}
