/* ===========================================================================
   Design System v2.0 — aplicado ao Funil de Vendas
   Carrega DEPOIS de style.css para sobrescrever os tokens essenciais.
   Mantemos a estrutura HTML antiga; apenas o vocabulario visual muda.
   =========================================================================== */

/* --- Fontes (Inter + Space Grotesk + JetBrains Mono) -------------------- */
@import url("https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500&family=Space+Grotesk:wght@500;600;700&display=swap");

/* --- Tokens ------------------------------------------------------------- */
:root {
  /* Brand scale (origem: design system). */
  --brand-400: #60a5fa;
  --brand-500: #3b82f6;
  --brand-600: #2563eb;
  --brand-700: #1d4ed8;
  --brand-800: #1e40af;
  --accent-500: #8b5cf6;  /* violeta complementar */

  /* Superficies escuras (carbon black). */
  --ds-surface-0: #050505;
  --ds-surface-1: #0a0a0a;
  --ds-surface-2: #111111;

  /* Vidro / glass surfaces. */
  --ds-glass-1: rgba(255, 255, 255, 0.02);
  --ds-glass-2: rgba(255, 255, 255, 0.03);
  --ds-glass-3: rgba(255, 255, 255, 0.05);

  /* Linhas. */
  --ds-line-1: rgba(255, 255, 255, 0.06);
  --ds-line-2: rgba(255, 255, 255, 0.08);
  --ds-line-3: rgba(255, 255, 255, 0.10);

  /* Texto. */
  --ds-text-1: #ffffff;
  --ds-text-2: rgba(255, 255, 255, 0.70);
  --ds-text-3: rgba(255, 255, 255, 0.50);
  --ds-text-4: rgba(255, 255, 255, 0.40);
  --ds-text-5: rgba(255, 255, 255, 0.30);

  /* Estados. */
  --ds-success: #10b981;
  --ds-warning: #f59e0b;
  --ds-danger:  #ef4444;

  /* Sobrescreve tokens antigos para harmonia visual. */
  --tg: var(--brand-500);
  --tg-dark: var(--brand-600);
  --bg: var(--ds-surface-0);
  --bg-soft: var(--ds-surface-1);
  --card: rgba(255, 255, 255, 0.03);
  --surface-2: rgba(255, 255, 255, 0.05);
  --line: var(--ds-line-2);

  /* Larguras do app shell (sidebar retratil). */
  --sidebar-w-collapsed: 56px;
  --sidebar-w-expanded:  240px;
}

[data-theme="light"] {
  /* No tema claro mantemos a estrutura, so trocamos o que muda de cor. */
  --ds-surface-0: #f7f9fc;
  --ds-surface-1: #ffffff;
  --ds-glass-1: rgba(0, 0, 0, 0.02);
  --ds-glass-2: rgba(0, 0, 0, 0.03);
  --ds-glass-3: rgba(0, 0, 0, 0.05);
  --ds-line-1: rgba(0, 0, 0, 0.06);
  --ds-line-2: rgba(0, 0, 0, 0.10);
  --ds-text-1: #0a0a0a;
  --ds-text-2: rgba(0, 0, 0, 0.70);
  --ds-text-3: rgba(0, 0, 0, 0.50);
  --ds-text-4: rgba(0, 0, 0, 0.45);
  --ds-text-5: rgba(0, 0, 0, 0.35);
}

/* --- Tipografia base ---------------------------------------------------- */
html, body {
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    sans-serif;
  letter-spacing: -0.005em;
}
body {
  background:
    radial-gradient(900px 480px at 20% -10%, rgba(59, 130, 246, 0.08), transparent),
    radial-gradient(700px 360px at 100% 100%, rgba(139, 92, 246, 0.06), transparent),
    var(--ds-surface-0);
}
h1, h2, h3, .display {
  font-family: "Space Grotesk", "Inter", sans-serif;
  letter-spacing: -0.02em;
}
.mono, .kicker, .ds-eyebrow {
  font-family: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;
}
.kicker, .ds-eyebrow {
  font-size: 11px;
  color: var(--ds-text-4);
  text-transform: uppercase;
  letter-spacing: 0.18em;
}

/* --- Sidebar (App Shell) ----------------------------------------------- */
body[data-sidebar] { padding-left: var(--sidebar-w-collapsed); }
body[data-sidebar="expanded"] { padding-left: var(--sidebar-w-expanded); }

.app-sidebar {
  position: fixed;
  top: 0; bottom: 0; left: 0;
  width: var(--sidebar-w-collapsed);
  display: flex;
  flex-direction: column;
  padding: 18px 8px;
  gap: 4px;
  background: var(--ds-surface-0);
  border-right: 1px solid var(--ds-line-1);
  z-index: 90;
  transition: width 0.25s cubic-bezier(0.25, 1, 0.5, 1);
  overflow: hidden;
}
body[data-sidebar="expanded"] .app-sidebar { width: var(--sidebar-w-expanded); }

.sb-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 4px 8px;
  margin-bottom: 14px;
  color: var(--ds-text-1);
  text-decoration: none;
  font-family: "Space Grotesk", sans-serif;
  font-weight: 700;
  font-size: 15px;
  white-space: nowrap;
}
.sb-logo svg { width: 24px; height: 24px; color: var(--brand-500); flex-shrink: 0; }
.sb-logo:hover { text-decoration: none; }

.sb-nav { display: flex; flex-direction: column; gap: 4px; }
.sb-item, .sb-toggle {
  display: flex;
  align-items: center;
  gap: 12px;
  height: 40px;
  padding: 0 8px;
  border-radius: 10px;
  color: var(--ds-text-4);
  text-decoration: none;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
  border: 1px solid transparent;
  white-space: nowrap;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  background: transparent;
}
.sb-item:hover, .sb-toggle:hover {
  background: rgba(255, 255, 255, 0.04);
  color: var(--ds-text-1);
  text-decoration: none;
}
.sb-item.is-active {
  background: rgba(59, 130, 246, 0.08);
  border-color: rgba(59, 130, 246, 0.15);
  color: var(--brand-500);
}

.sb-icon {
  width: 24px; height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.sb-icon svg { width: 16px; height: 16px; stroke-width: 2; }

.sb-label {
  flex: 1;
  opacity: 0;
  transform: translateX(-4px);
  transition: opacity 0.18s ease, transform 0.18s ease;
  pointer-events: none;
}
body[data-sidebar="expanded"] .sb-label {
  opacity: 1;
  transform: translateX(0);
  pointer-events: auto;
}

.sb-toggle {
  margin-top: auto;
  font: inherit;
  text-align: left;
}

/* --- Modernizacao dos componentes existentes --------------------------- */
.card {
  background: var(--ds-glass-2);
  border: 1px solid var(--ds-line-2);
  border-radius: 16px;
  box-shadow: none;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.card:hover { border-color: var(--ds-line-3); }
.card h3 { font-family: "Space Grotesk", sans-serif; letter-spacing: -0.02em; }

button, .btn {
  font-family: "Inter", sans-serif;
  font-weight: 500;
  border-radius: 10px;
  letter-spacing: -0.005em;
}
button.ghost, .btn.ghost {
  background: var(--ds-glass-2);
  border: 1px solid var(--ds-line-2);
  color: var(--ds-text-2);
}
button.ghost:hover, .btn.ghost:hover {
  background: var(--ds-glass-3);
  border-color: var(--ds-line-3);
  color: var(--ds-text-1);
}

.pill {
  font-family: "JetBrains Mono", monospace;
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 4px 10px;
  border-radius: 999px;
  font-weight: 500;
}

.topbar {
  background: rgba(5, 5, 5, 0.72);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--ds-line-1);
}
.topbar .brand {
  font-family: "Space Grotesk", sans-serif;
  font-weight: 700;
  letter-spacing: -0.01em;
}

/* Inputs modernos. */
input[type="text"], input[type="email"], input[type="password"], input[type="number"],
input[type="search"], input[type="url"], textarea, select {
  background: var(--ds-glass-1);
  border: 1px solid var(--ds-line-2);
  color: var(--ds-text-1);
  border-radius: 10px;
  font-family: "Inter", sans-serif;
  transition: border-color 0.15s ease, background 0.15s ease;
}
input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: rgba(59, 130, 246, 0.5);
  background: var(--ds-glass-2);
}

/* Theme toggle no estilo do design system (botão circular sutil). */
.theme-toggle {
  width: 36px; height: 36px;
  border-radius: 999px;
  background: var(--ds-glass-2);
  border: 1px solid var(--ds-line-2);
  color: var(--ds-text-3);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.18s ease, color 0.18s ease, transform 0.18s ease;
}
.theme-toggle svg { width: 15px; height: 15px; stroke-width: 2; }
.theme-toggle:hover {
  background: var(--ds-glass-3);
  color: var(--ds-text-1);
  transform: rotate(15deg);
}

/* --- Responsivo: em telas estreitas, sidebar volta a 56px ------------- */
@media (max-width: 760px) {
  body[data-sidebar="expanded"] { padding-left: var(--sidebar-w-collapsed); }
  body[data-sidebar="expanded"] .app-sidebar { width: var(--sidebar-w-collapsed); }
  body[data-sidebar="expanded"] .sb-label { opacity: 0; transform: translateX(-4px); }
}

/* ===========================================================================
   Sistema de botões — primário, secundário, ícone, perigo
   =========================================================================== */
.btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 38px;
  padding: 0 16px;
  border-radius: 10px;
  font-family: "Inter", sans-serif;
  font-weight: 600;
  font-size: 13.5px;
  letter-spacing: -0.005em;
  color: #ffffff;
  background: rgba(59, 130, 246, 0.10);
  border: 1px solid rgba(59, 130, 246, 0.32);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.05) inset,
    0 6px 16px rgba(37, 99, 235, 0.15);
  cursor: pointer;
  position: relative;
  overflow: hidden;
  transition:
    transform 0.18s cubic-bezier(0.25, 1, 0.5, 1),
    box-shadow 0.2s ease,
    background 0.2s ease,
    border-color 0.2s ease;
}
.btn-primary::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg,
              rgba(96, 165, 250, 0.12) 0%, transparent 100%);
  pointer-events: none;
  border-radius: inherit;
}
.btn-primary:hover {
  transform: translateY(-1px);
  background: rgba(59, 130, 246, 0.16);
  border-color: rgba(96, 165, 250, 0.48);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.08) inset,
    0 10px 24px rgba(37, 99, 235, 0.25);
  text-decoration: none;
}
.btn-primary:active { transform: translateY(0) scale(0.98); }
.btn-primary:focus-visible {
  outline: 2px solid rgba(96, 165, 250, 0.55);
  outline-offset: 2px;
}

.btn-secondary {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 38px;
  padding: 0 14px;
  border-radius: 10px;
  font-family: "Inter", sans-serif;
  font-weight: 500;
  font-size: 13.5px;
  color: var(--ds-text-2);
  background: var(--ds-glass-2);
  border: 1px solid var(--ds-line-2);
  cursor: pointer;
  transition: background 0.18s ease, border-color 0.18s ease, color 0.18s ease,
              transform 0.18s cubic-bezier(0.25, 1, 0.5, 1);
}
.btn-secondary:hover {
  background: var(--ds-glass-3);
  border-color: var(--ds-line-3);
  color: var(--ds-text-1);
  text-decoration: none;
}
.btn-secondary:active { transform: scale(0.98); }

.btn-icon {
  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  background: var(--ds-glass-2);
  border: 1px solid var(--ds-line-2);
  color: var(--ds-text-3);
  cursor: pointer;
  transition: background 0.18s ease, border-color 0.18s ease, color 0.18s ease,
              transform 0.18s cubic-bezier(0.25, 1, 0.5, 1);
  padding: 0;
}
.btn-icon:hover {
  background: var(--ds-glass-3);
  border-color: var(--ds-line-3);
  color: var(--ds-text-1);
}
.btn-icon:active { transform: scale(0.95); }
.btn-icon svg { width: 16px; height: 16px; stroke-width: 2; }

.btn-icon--danger:hover {
  background: rgba(239, 68, 68, 0.10);
  border-color: rgba(239, 68, 68, 0.35);
  color: var(--ds-danger);
}

/* Quando um ícone aparece dentro de um botão padrão. */
.btn-primary svg, .btn-secondary svg {
  width: 16px;
  height: 16px;
  stroke-width: 2;
  flex-shrink: 0;
}

/* ===========================================================================
   Thumb do funil — cartão polido com hierarquia, estado e hover.
   =========================================================================== */
.funnel-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 18px;
}

.funnel-thumb {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 20px;
  border-radius: 18px;
  background: var(--ds-glass-2);
  border: 1px solid var(--ds-line-2);
  overflow: hidden;
  text-decoration: none;
  color: var(--ds-text-1);
  animation: thumb-in 0.5s cubic-bezier(0.25, 1, 0.5, 1) backwards;
  transition:
    transform 0.28s cubic-bezier(0.25, 1, 0.5, 1),
    border-color 0.2s ease,
    box-shadow 0.3s ease;
}
.funnel-thumb::before {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(360px circle at 85% -20%,
              rgba(59, 130, 246, 0.10), transparent 55%);
  opacity: 0;
  transition: opacity 0.35s ease;
  pointer-events: none;
  border-radius: inherit;
}
.funnel-thumb::after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent,
              rgba(59, 130, 246, 0.30), transparent);
  opacity: 0;
  transition: opacity 0.35s ease;
}
.funnel-thumb:hover {
  transform: translateY(-3px);
  border-color: rgba(59, 130, 246, 0.22);
  box-shadow:
    0 14px 36px rgba(0, 0, 0, 0.35),
    0 0 0 1px rgba(59, 130, 246, 0.08);
}
.funnel-thumb:hover::before,
.funnel-thumb:hover::after { opacity: 1; }

.thumb-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: relative;
  z-index: 1;
}
.thumb-title {
  font-family: "Space Grotesk", sans-serif;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--ds-text-1);
  margin: 4px 0 0;
  line-height: 1.25;
  position: relative;
  z-index: 1;
}
.thumb-meta {
  display: flex;
  flex-direction: column;
  gap: 8px;
  position: relative;
  z-index: 1;
}
.thumb-meta-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  color: var(--ds-text-3);
}
.thumb-meta-item svg {
  width: 14px;
  height: 14px;
  stroke-width: 2;
  color: var(--ds-text-4);
  flex-shrink: 0;
}
.thumb-meta-item strong {
  color: var(--ds-text-2);
  font-weight: 500;
}

.thumb-footer {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: auto;
  position: relative;
  z-index: 1;
}
.thumb-footer .btn-primary { flex: 1; justify-content: center; }

/* --- Status (dot + label) --------------------------------------------- */
.status-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px 6px 10px;
  border-radius: 999px;
  border: 1px solid var(--ds-line-2);
  background: var(--ds-glass-2);
  font-family: "JetBrains Mono", monospace;
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ds-text-3);
}
.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--ds-text-5);
  flex-shrink: 0;
}
.status-chip[data-status="online"]    { color: #10b981; border-color: rgba(16, 185, 129, 0.30); }
.status-chip[data-status="online"]    .status-dot {
  background: #10b981;
  box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.5);
  animation: pulse-dot 2.2s ease-in-out infinite;
}
.status-chip[data-status="published"] { color: var(--brand-400); border-color: rgba(96, 165, 250, 0.28); }
.status-chip[data-status="published"] .status-dot { background: var(--brand-400); }
.status-chip[data-status="draft"]     { color: var(--ds-warning); border-color: rgba(245, 158, 11, 0.30); }
.status-chip[data-status="draft"]     .status-dot { background: var(--ds-warning); }
.status-chip[data-status="suspended"] { color: var(--ds-danger); border-color: rgba(239, 68, 68, 0.35); }
.status-chip[data-status="suspended"] .status-dot { background: var(--ds-danger); }

/* ===========================================================================
   Empty state polido
   =========================================================================== */
.empty-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 14px;
  padding: 56px 32px;
  border-radius: 18px;
  border: 1px dashed var(--ds-line-2);
  background: var(--ds-glass-1);
}
.empty-icon {
  width: 56px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 16px;
  background: rgba(59, 130, 246, 0.08);
  border: 1px solid rgba(59, 130, 246, 0.18);
  color: var(--brand-500);
}
.empty-icon svg { width: 24px; height: 24px; stroke-width: 1.8; }
.empty-title {
  font-family: "Space Grotesk", sans-serif;
  font-size: 18px;
  font-weight: 700;
  color: var(--ds-text-1);
  margin: 0;
}
.empty-text {
  font-size: 13.5px;
  color: var(--ds-text-3);
  max-width: 340px;
  margin: 0;
}

/* ===========================================================================
   KPI cards — dashboard de vendas
   =========================================================================== */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
  margin-bottom: 22px;
}
.kpi {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 18px 20px;
  border-radius: 16px;
  background: var(--ds-glass-2);
  border: 1px solid var(--ds-line-2);
  transition: border-color 0.2s ease, transform 0.2s ease;
}
.kpi:hover {
  border-color: var(--ds-line-3);
  transform: translateY(-1px);
}
.kpi-icon {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
  flex-shrink: 0;
}
.kpi-icon svg { width: 18px; height: 18px; stroke-width: 2; }
.kpi[data-tint="brand"]   .kpi-icon { background: rgba(59, 130, 246, 0.10);  border: 1px solid rgba(59, 130, 246, 0.20);  color: var(--brand-400); }
.kpi[data-tint="success"] .kpi-icon { background: rgba(16, 185, 129, 0.10);  border: 1px solid rgba(16, 185, 129, 0.22);  color: #10b981; }
.kpi[data-tint="warning"] .kpi-icon { background: rgba(245, 158, 11, 0.10);  border: 1px solid rgba(245, 158, 11, 0.22);  color: #f59e0b; }
.kpi[data-tint="accent"]  .kpi-icon { background: rgba(139, 92, 246, 0.10);  border: 1px solid rgba(139, 92, 246, 0.22);  color: #8b5cf6; }
.kpi-body {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}
.kpi-label {
  font-family: "JetBrains Mono", monospace;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--ds-text-4);
  font-weight: 500;
}
.kpi-value {
  font-family: "Space Grotesk", sans-serif;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--ds-text-1);
  line-height: 1.1;
}

/* ===========================================================================
   Modal de templates de funil
   =========================================================================== */
.modal-templates {
  max-width: 720px;
  width: min(720px, calc(100vw - 32px));
  padding: 28px;
  max-height: calc(100vh - 64px);
  overflow-y: auto;
}
.modal-templates header { margin-bottom: 20px; }
.modal-templates header h2 {
  font-family: "Space Grotesk", sans-serif;
  font-size: 22px;
  letter-spacing: -0.02em;
  margin: 0 0 6px;
  color: var(--ds-text-1);
}
.modal-templates header p {
  margin: 0;
  font-size: 13px;
  color: var(--ds-text-3);
}

.template-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}
.template-card {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 16px;
  border-radius: 14px;
  background: var(--ds-glass-1);
  border: 1px solid var(--ds-line-2);
  text-align: left;
  cursor: pointer;
  font: inherit;
  color: inherit;
  transition: background 0.18s ease, border-color 0.18s ease, transform 0.18s ease;
}
.template-card:hover {
  background: var(--ds-glass-2);
  border-color: rgba(59, 130, 246, 0.30);
  transform: translateY(-1px);
}
.template-card:focus-visible {
  outline: 2px solid rgba(96, 165, 250, 0.55);
  outline-offset: 2px;
}
.template-emoji {
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
  background: rgba(59, 130, 246, 0.08);
  border: 1px solid rgba(59, 130, 246, 0.18);
  font-size: 22px;
  flex-shrink: 0;
}
.template-info { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.template-info h3 {
  font-family: "Space Grotesk", sans-serif;
  font-size: 14.5px;
  font-weight: 700;
  letter-spacing: -0.015em;
  color: var(--ds-text-1);
  margin: 0;
}
.template-info p {
  font-size: 12.5px;
  color: var(--ds-text-3);
  margin: 0;
  line-height: 1.4;
}
.template-info .kicker { margin-top: 6px; font-size: 10px; }

/* ===========================================================================
   Caixa de entrada (inbox)
   =========================================================================== */
.inbox-shell {
  display: grid;
  grid-template-columns: minmax(260px, 320px) 1fr;
  gap: 14px;
  height: calc(100vh - 220px);
  min-height: 480px;
}
@media (max-width: 800px) {
  .inbox-shell { grid-template-columns: 1fr; height: auto; }
}

.conv-list {
  background: var(--ds-glass-2);
  border: 1px solid var(--ds-line-2);
  border-radius: 16px;
  overflow-y: auto;
  padding: 8px;
}
.conv-item {
  width: 100%;
  text-align: left;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 12px;
  padding: 12px;
  margin-bottom: 4px;
  cursor: pointer;
  font: inherit;
  color: inherit;
  display: flex;
  flex-direction: column;
  gap: 4px;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.conv-item:hover {
  background: var(--ds-glass-2);
  border-color: var(--ds-line-2);
}
.conv-item.is-active {
  background: rgba(59, 130, 246, 0.08);
  border-color: rgba(59, 130, 246, 0.22);
}
.conv-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
}
.conv-head strong {
  font-family: "Space Grotesk", sans-serif;
  font-size: 13.5px;
  color: var(--ds-text-1);
  font-weight: 600;
}
.conv-time {
  font-family: "JetBrains Mono", monospace;
  font-size: 10px;
  color: var(--ds-text-4);
  flex-shrink: 0;
}
.conv-preview {
  font-size: 12.5px;
  color: var(--ds-text-3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.conv-meta { display: flex; gap: 6px; flex-wrap: wrap; }
.conv-meta .pill { font-size: 9px; padding: 3px 8px; }

.thread-pane {
  background: var(--ds-glass-2);
  border: 1px solid var(--ds-line-2);
  border-radius: 16px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.thread-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  color: var(--ds-text-4);
}
.thread-empty p { margin: 0; font-size: 13px; }

.thread-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--ds-line-1);
}
.thread-head h2 {
  margin: 0;
  font-family: "Space Grotesk", sans-serif;
  font-size: 15px;
  letter-spacing: -0.015em;
  color: var(--ds-text-1);
}

.thread-body {
  flex: 1;
  overflow-y: auto;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.msg { display: flex; flex-direction: column; max-width: 75%; }
.msg-in  { align-self: flex-start; }
.msg-out { align-self: flex-end; align-items: flex-end; }
.msg-bubble {
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 13.5px;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
}
.msg-in  .msg-bubble {
  background: var(--ds-glass-3);
  border: 1px solid var(--ds-line-2);
  color: var(--ds-text-1);
  border-bottom-left-radius: 4px;
}
.msg-out .msg-bubble {
  background: rgba(59, 130, 246, 0.18);
  border: 1px solid rgba(59, 130, 246, 0.32);
  color: var(--ds-text-1);
  border-bottom-right-radius: 4px;
}
.msg-time {
  font-family: "JetBrains Mono", monospace;
  font-size: 9.5px;
  color: var(--ds-text-4);
  margin-top: 4px;
}

.composer {
  display: flex;
  gap: 8px;
  padding: 12px;
  border-top: 1px solid var(--ds-line-1);
  align-items: flex-end;
}
.composer textarea {
  flex: 1;
  resize: vertical;
  min-height: 38px;
  max-height: 160px;
  padding: 10px 12px;
  background: var(--ds-glass-1);
  border: 1px solid var(--ds-line-2);
  border-radius: 10px;
  color: var(--ds-text-1);
  font: inherit;
}
.composer textarea:focus {
  outline: none;
  border-color: rgba(59, 130, 246, 0.45);
  background: var(--ds-glass-2);
}

/* ===========================================================================
   User menu (canto superior direito) — global em todas as páginas autenticadas
   =========================================================================== */
.user-menu {
  position: fixed;
  top: 12px;
  right: 16px;
  z-index: 80;
  display: flex;
  align-items: center;
  gap: 8px;
}
.user-menu .theme-toggle { margin: 0; }

.user-menu-trigger {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 38px;
  padding: 4px 14px 4px 4px;
  border-radius: 999px;
  background: var(--ds-glass-2);
  border: 1px solid var(--ds-line-2);
  color: var(--ds-text-2);
  cursor: pointer;
  font: inherit;
  transition: background 0.18s ease, border-color 0.18s ease, color 0.18s ease;
  max-width: 260px;
}
.user-menu-trigger:hover,
.user-menu.is-open .user-menu-trigger {
  background: var(--ds-glass-3);
  border-color: var(--ds-line-3);
  color: var(--ds-text-1);
}
.user-avatar {
  width: 30px; height: 30px;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--brand-500), var(--accent-500, #8b5cf6));
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-family: "Space Grotesk", sans-serif;
  font-weight: 700;
  font-size: 13px;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(59, 130, 246, 0.30);
}
.user-info {
  font-size: 13px;
  font-weight: 500;
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.user-menu-trigger .um-chev {
  width: 14px; height: 14px;
  opacity: 0.6;
  transition: transform 0.2s ease, opacity 0.2s ease;
  flex-shrink: 0;
}
.user-menu.is-open .um-chev {
  transform: rotate(180deg);
  opacity: 1;
}

.user-menu-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 240px;
  background: var(--ds-surface-1);
  border: 1px solid var(--ds-line-2);
  border-radius: 14px;
  box-shadow: 0 18px 44px rgba(0, 0, 0, 0.48),
              0 0 0 1px rgba(96, 165, 250, 0.04);
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  animation: um-pop 0.18s cubic-bezier(0.25, 1, 0.5, 1);
}
/* O atributo HTML "hidden" precisa vencer o "display: flex" acima. Sem
   esta regra com especificidade maior, o dropdown fica sempre visivel
   (o bug do menu "enganchado"). */
.user-menu-dropdown[hidden] {
  display: none !important;
}
@keyframes um-pop {
  from { opacity: 0; transform: translateY(-6px) scale(0.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.user-menu-head {
  padding: 10px 12px 8px;
}
.user-menu-name {
  font-family: "Space Grotesk", sans-serif;
  font-weight: 600;
  font-size: 13.5px;
  color: var(--ds-text-1);
  letter-spacing: -0.01em;
}
.user-menu-sub {
  font-size: 11.5px;
  color: var(--ds-text-4);
  margin-top: 2px;
  word-break: break-all;
}

.user-menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 8px;
  font: inherit;
  font-size: 13px;
  color: var(--ds-text-2);
  text-decoration: none;
  background: transparent;
  border: 0;
  cursor: pointer;
  width: 100%;
  text-align: left;
  transition: background 0.15s ease, color 0.15s ease;
}
.user-menu-item:hover {
  background: var(--ds-glass-3);
  color: var(--ds-text-1);
  text-decoration: none;
}
.user-menu-item svg {
  width: 15px; height: 15px;
  stroke-width: 2;
  flex-shrink: 0;
  opacity: 0.7;
}
.user-menu-logout { color: var(--ds-text-3); }
.user-menu-logout:hover {
  background: rgba(239, 68, 68, 0.08);
  color: var(--ds-danger);
}
.user-menu-logout:hover svg { opacity: 1; }

.user-menu-divider {
  border: 0;
  border-top: 1px solid var(--ds-line-1);
  margin: 4px 6px;
}

/* Em telas estreitas, esconde o e-mail e mostra só o avatar arredondado. */
@media (max-width: 640px) {
  .user-info, .user-menu-trigger .um-chev { display: none; }
  .user-menu-trigger {
    padding: 4px;
    gap: 0;
    border-radius: 999px;
  }
}

/* Reserva espaço no topbar de cada página pra não conflitar com o user-menu. */
body:has(.user-menu) .topbar { padding-right: 280px; }
@media (max-width: 640px) {
  body:has(.user-menu) .topbar { padding-right: 100px; }
}

/* ===========================================================================
   Animações utilitárias
   =========================================================================== */
@keyframes thumb-in {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes pulse-dot {
  0%, 100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.55); }
  50%      { box-shadow: 0 0 0 6px rgba(16, 185, 129, 0); }
}
@keyframes shimmer-bg {
  0%   { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

/* ===========================================================================
   Editor: abas horizontais (Configuração / Fluxo)
   =========================================================================== */
.editor-tabs {
  display: flex;
  gap: 4px;
  padding: 4px;
  margin-bottom: 14px;
  background: var(--ds-glass-1, rgba(255,255,255,0.04));
  border: 1px solid var(--ds-line-2, rgba(255,255,255,0.08));
  border-radius: 12px;
}
.editor-tab {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 14px;
  font: 600 13px/1 "Inter", system-ui, sans-serif;
  color: var(--ds-text-2, #a8b1c2);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 9px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.editor-tab:hover {
  color: var(--ds-text-1, #e6edf7);
  background: var(--ds-glass-2, rgba(255,255,255,0.06));
}
.editor-tab.is-active {
  color: var(--ds-text-1, #e6edf7);
  background: var(--ds-glass-3, rgba(255,255,255,0.10));
  border-color: var(--ds-line-3, rgba(255,255,255,0.14));
  box-shadow: 0 1px 0 rgba(255,255,255,0.04) inset;
}
.editor-tab svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}
.editor-pane.is-hidden { display: none; }

/* ===========================================================================
   Botoes secundarios em variante compacta (Salvar funil, Salvar pagamento, etc).
   .btn-secondary normal e 38px; aqui descemos pra 32px quando combinado com .small.
   =========================================================================== */
.btn-secondary.small {
  height: 32px;
  padding: 0 12px;
  font-size: 13px;
  border-radius: 8px;
}

/* ===========================================================================
   Modal overlay reforçado — backdrop opaco com blur, em vez de translúcido
   (sem isso, o conteúdo da pagina aparecia atras do modal "Escolha um template").
   =========================================================================== */
.modal-overlay {
  background: rgba(8, 11, 18, 0.92) !important;
  backdrop-filter: blur(12px) saturate(120%);
  -webkit-backdrop-filter: blur(12px) saturate(120%);
}

/* ===========================================================================
   Simulador — mockup de iPhone com Telegram dentro
   Estrutura: .phone (chassi) > .phone-head (status+nav bar) > .chat (corpo)
   O design imita um iPhone 14 Pro com Dynamic Island e tela do Telegram dentro.
   =========================================================================== */
.sim-panel .card { background: transparent; border: none; box-shadow: none; padding: 12px 0; }

.phone {
  position: relative;
  background: #0a0a0c;
  border-radius: 48px;
  padding: 10px;                /* moldura uniforme bem fina */
  max-width: 330px;
  margin: 0 auto;
  /* Acabamento metalico: dois aros + sombra projetada limpa */
  box-shadow:
    inset 0 0 0 2px #2c2c30,    /* aro interno (titânio) */
    0 0 0 1px #1a1a1d,          /* outline preto sutil */
    0 24px 50px -16px rgba(0, 0, 0, 0.65),
    0 10px 24px -10px rgba(0, 0, 0, 0.45);
}
/* Botoes laterais do iPhone (decorativos) */
.phone::before,
.phone::after {
  content: "";
  position: absolute;
  background: #1f1f23;
  border-radius: 2px;
  z-index: -1;
}
.phone::before {           /* sleep/wake (direita) */
  right: -3px;
  top: 130px;
  width: 4px;
  height: 80px;
}
.phone::after {            /* volume + + - (esquerda) */
  left: -3px;
  top: 100px;
  width: 4px;
  height: 56px;
  box-shadow: 0 80px 0 #1f1f23, 0 144px 0 #1f1f23;
}

/* Tela do iPhone — wrapper interno */
.phone > * {
  position: relative;
}
.phone-head {
  position: relative;
  background: #17212b;        /* azul-petroleo do Telegram dark */
  margin: 0;
  padding: 56px 12px 10px;    /* topo grande pra a status bar caber acima */
  color: #fff;
  border-top-left-radius: 38px;
  border-top-right-radius: 38px;
  display: flex;
  align-items: center;
  gap: 10px;
}
/* Dynamic Island */
.phone-head::before {
  content: "";
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  width: 102px;
  height: 30px;
  background: #000;
  border-radius: 999px;
  z-index: 2;
}
/* Status bar (hora) — overlay em cima da phone-head */
.phone-head::after {
  content: "9:41";
  position: absolute;
  top: 18px;
  left: 28px;
  font-family: -apple-system, "SF Pro Text", "Helvetica Neue", sans-serif;
  font-size: 14px;
  font-weight: 600;
  color: #fff;
  letter-spacing: 0.02em;
  z-index: 3;
}
/* Status bar (sinal/wifi/bateria) — pseudo via .phone-head .avatar~indicator (simulado) */
.phone-head .avatar {
  width: 30px;
  height: 30px;
  background: linear-gradient(135deg, #4ea2d6, #2b7cb3);
  font-size: 13px;
}
/* Ícones de sinal/wifi/bateria à direita usando uma barra desenhada via SVG inline */
.phone-head > div:last-child::before {
  content: "";
  position: absolute;
  top: 22px;
  right: 24px;
  width: 60px;
  height: 12px;
  background-image:
    /* bateria */
    linear-gradient(#fff, #fff),
    /* corpo bateria */
    linear-gradient(#fff, #fff),
    /* wifi (3 arcos simplificados como pontos) */
    radial-gradient(circle, #fff 40%, transparent 42%),
    radial-gradient(circle, #fff 40%, transparent 42%),
    /* sinal (3 pontos) */
    radial-gradient(circle, #fff 40%, transparent 42%);
  background-repeat: no-repeat;
  background-size:
    18px 8px,
    2px 4px,
    8px 8px,
    8px 8px,
    8px 8px;
  background-position:
    right 0 top 2px,
    right -2px top 4px,
    right 22px top 2px,
    right 36px top 2px,
    right 50px top 2px;
  z-index: 3;
}

/* Corpo do chat dentro do iPhone */
.chat {
  margin: 0;
  border-radius: 0;
  padding: 14px 12px 22px;
  background-image:
    radial-gradient(ellipse at top, rgba(96, 165, 250, 0.04), transparent 60%),
    linear-gradient(180deg, #17212b 0%, #0e1621 100%);
  height: 460px;
  /* arredonda o canto inferior pra encaixar no chassi */
  border-bottom-left-radius: 38px;
  border-bottom-right-radius: 38px;
}
/* Home indicator (barrinha embaixo) sobre o chat */
.chat::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: 6px;
  transform: translateX(-50%);
  width: 110px;
  height: 4px;
  background: rgba(255, 255, 255, 0.45);
  border-radius: 999px;
  z-index: 4;
}
