@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@500;600;700;800;900&family=Inter:wght@400;500;600;700;800;900&family=JetBrains+Mono:wght@400;500;700&display=swap');

/* ---------------------------------------------------------------------------
   Tokens. A base e a marca vêm do techzul-crm (slate + roxo). As três cores de
   estado sobrevivem como camada semântica: elas codificam a máquina de estados
   do atendimento e viram a cor das colunas do funil.
   --------------------------------------------------------------------------- */
:root {
  color-scheme: dark;
  /* Calibragem do techzul (MainLayout.tsx `dark:bg-slate-900` + cards
     `dark:bg-slate-800`): o app inteiro vive um degrau acima do preto. A versão
     anterior usava slate-950 no fundo e slate-900 nos cards — escuro demais,
     sem profundidade entre superfícies. */
  --ink: #0f172a;
  --panel: #1e293b;
  --panel-lift: #334155;
  --sunken: rgba(15, 23, 42, .55);
  --edge: rgba(51, 65, 85, .60);
  --edge-strong: rgba(71, 85, 105, .80);

  --brand: #aa3bff;
  --brand-2: #4f46e5;
  --indigo: #6366f1;
  --indigo-soft: rgba(99, 102, 241, .18);

  --signal: #25d366;
  --signal-deep: #0b6e3d;
  --alert: #ff8a5b;
  --human: #a78bfa;
  --warning: #fbbf24;
  --danger: #fb7185;

  --text: #e2e8f0;
  --muted: #94a3b8;

  /* Escala do techzul: rounded-xl (12) em pílulas internas, rounded-2xl (16) em
     botões/ícones, rounded-3xl (24) em cards e 28-40px nos painéis grandes do
     Dashboard. Nada abaixo de 12. */
  --r-sm: 12px;
  --r-md: 16px;
  --r-lg: 24px;
  --r-xl: 32px;

  /* font-black. É o peso que o techzul usa em label, botão, badge e título —
     a diferença mais visível entre "parece template" e "parece produto". */
  --w-black: 900;

  /* shadow-soft-dark do techzul (tailwind.config.js) e a versão elevada
     usada em hover de card e no item ativo da navegação. */
  --shadow-soft: 0 8px 30px rgba(0, 0, 0, .20);
  --shadow-lift: 0 14px 40px rgba(0, 0, 0, .34);
  --shadow: var(--shadow-soft);
  --glow: 0 0 0 1px rgba(170, 59, 255, .30), 0 8px 26px rgba(170, 59, 255, .16);

  --tab-h: 76px;

  --display: 'Poppins', 'Inter', ui-sans-serif, system-ui, sans-serif;
  --body: 'Inter', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', sans-serif;
  --data: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;

  font-synthesis: none;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  font-family: var(--body);
  background: var(--ink);
  color: var(--text);
}

/* Brilho contido nos cantos: evita que o fundo escuro fique chapado.
   Roxo/índigo da marca techzul — o verde anterior era resquício do tema
   WhatsApp que este redesign substitui. */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background:
    radial-gradient(680px 420px at 4% -6%, rgba(170, 59, 255, .10), transparent 62%),
    radial-gradient(560px 380px at 96% 4%, rgba(79, 70, 229, .09), transparent 60%);
}

/* `text-3xl font-black tracking-tight` do techzul em todo cabeçalho de página. */
h1, h2, h3 { font-family: var(--display); letter-spacing: -.03em; margin: 0; }
h1 { font-size: clamp(24px, 2.6vw, 30px); font-weight: var(--w-black); }
h2 { font-size: 19px; font-weight: 700; }
h3 { font-size: 15px; font-weight: 700; }
p { margin: 0; }

/* O techzul não usa monoespaçada em eyebrow: é a mesma sans em peso 900 com
   tracking largo. A mono ficava com cara de terminal, não de CRM. */
.eyebrow {
  display: block;
  font-family: var(--body);
  font-size: 10px;
  font-weight: var(--w-black);
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--muted);
}

.subtitle { color: var(--muted); line-height: 1.55; margin-top: 8px; max-width: 70ch; }

/* ------------------------------ Barra de abas ------------------------------ */
/* Header.tsx do techzul: fica no fluxo normal, sem fundo próprio e sem borda —
   por isso não existe costura entre cabeçalho e conteúdo. Qualquer fundo opaco
   aqui recorta o brilho de fundo e reaparece como uma faixa no topo. */
.tabbar {
  position: relative;
  z-index: 30;
  min-height: var(--tab-h);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 22px;
  padding: 26px clamp(20px, 3vw, 48px) 10px;
  background: transparent;
}

/* Marca à esquerda e ações à direita ocupam a mesma fração, o que deixa a
   navegação opticamente centrada na janela. */
.tabbar-brand { flex: 1 1 0; display: flex; align-items: center; gap: 12px; min-width: 0; }

.tabbar-logo {
  width: 118px;
  height: 62px;
  flex: none;
  display: block;
  object-fit: contain;
}

.tabbar-nav { flex: 0 0 auto; display: flex; align-items: center; gap: 6px; }

/* Pílula invertida do techzul (Sidebar.tsx): o item ativo é branco com texto
   escuro e sombra forte — a assinatura visual mais reconhecível da referência. */
/* Sidebar.tsx: ícone 22px stroke 2.5 + rótulo, raio 18px, e o item ativo é a
   pílula branca invertida com sombra forte. */
.nav-link {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 11px 18px;
  border: 0;
  border-radius: 18px;
  background: transparent;
  color: var(--muted);
  font-family: var(--body);
  font-size: 11px;
  font-weight: var(--w-black);
  letter-spacing: .12em;
  text-transform: uppercase;
  cursor: pointer;
  transition: color .18s ease, background .18s ease;
}

.nav-link .icon { width: 20px; height: 20px; stroke-width: 2.5; }

.nav-link:hover { color: var(--text); background: rgba(255, 255, 255, .06); }

.nav-link[aria-current="page"] {
  background: #fff;
  color: #0f172a;
  box-shadow: 0 12px 30px rgba(255, 255, 255, .10);
}

/* Badge de notificação sobreposto, no padrão do Header.tsx do techzul. */
.nav-tally {
  position: absolute;
  top: -6px;
  right: -6px;
  min-width: 20px;
  height: 20px;
  padding: 0 5px;
  display: none;
  place-items: center;
  border-radius: 999px;
  background: var(--brand);
  color: #fff;
  font-family: var(--body);
  font-size: 10px;
  font-weight: 800;
  box-shadow: var(--shadow-lift);
}

.nav-tally[data-count]:not([data-count="0"]) { display: grid; }

.tabbar-actions { flex: 1 1 0; display: flex; align-items: center; justify-content: flex-end; gap: 10px; }

/* Botões circulares de 44px do Header.tsx. */
.round-action {
  width: 46px;
  height: 46px;
  flex: none;
  padding: 0;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 999px;
  background: var(--panel);
  color: var(--muted);
  font-size: 19px;
  cursor: pointer;
  box-shadow: var(--shadow-soft);
  transition: color .18s ease, box-shadow .18s ease, background .18s ease;
}

.round-action:hover { color: #fff; background: var(--panel-lift); box-shadow: var(--shadow-lift); transform: none; }

/* O toggle do agente carrega texto, então é pílula e não círculo. O dot à
   esquerda repete a leitura de estado sem depender só da cor do texto. */
.agent-pill {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  height: 46px;
  padding: 0 20px;
  border: 1px solid var(--edge);
  border-radius: 999px;
  background: var(--panel);
  color: var(--text);
  font-size: 11px;
  font-weight: var(--w-black);
  letter-spacing: .1em;
  text-transform: uppercase;
  cursor: pointer;
  box-shadow: var(--shadow-soft);
}

.agent-pill::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--muted);
}

.agent-pill.is-on::before { background: var(--signal); }
.agent-pill.is-off::before { background: var(--alert); }
.agent-pill:hover { transform: none; box-shadow: var(--shadow-lift); }

/* --------------------------------- Shell --------------------------------- */
main {
  position: relative;
  z-index: 1;
  flex: 1;
  min-width: 0;
  width: 100%;
  max-width: 1600px;
  margin: 0 auto;
  padding: 38px clamp(20px, 3vw, 48px) 48px;
  display: flex;
  flex-direction: column;
  gap: 26px;
}

.actions, .demo-actions { display: flex; gap: 9px; flex-wrap: wrap; align-items: center; }

/* Views: uma tela por vez, em vez de rolagem única. */
.view { display: none; flex-direction: column; gap: 18px; }
.view.is-active { display: flex; animation: view-in .26s ease both; }

@keyframes view-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

/* -------------------------------- Botões --------------------------------- */
/* `rounded-2xl` + `text-xs font-black uppercase tracking-widest` — a assinatura
   de botão do techzul, do CRM ao modal de Novo Lead. */
button {
  border: 0;
  border-radius: var(--r-md);
  padding: 12px 18px;
  font-family: var(--body);
  font-size: 11px;
  font-weight: var(--w-black);
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--text);
  background: var(--panel-lift);
  cursor: pointer;
  transition: transform .14s ease, background .18s ease, opacity .18s ease;
}

button:hover { transform: translateY(-1px); }
button:active { transform: scale(.97); }
button:disabled { cursor: not-allowed; opacity: .5; transform: none; }

/* CTA indigo sólido do techzul (`bg-indigo-600` + sombra colorida), no lugar do
   gradiente roxo→índigo que estourava contra o fundo mais claro. */
.primary {
  background: var(--brand-2);
  color: #fff;
  box-shadow: 0 14px 30px rgba(79, 70, 229, .28);
}

.primary:hover { background: #4338ca; }

.secondary { background: var(--panel); border: 1px solid var(--edge); }
.secondary:hover { border-color: rgba(99, 102, 241, .45); }
.danger-button { background: rgba(251, 113, 133, .12); color: #fda4af; border: 1px solid rgba(251, 113, 133, .28); }

:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

/* ------------------------- Superfícies e métricas ------------------------- */
.card, .panel, .knowledge-item {
  position: relative;
  background: var(--panel);
  border: 1px solid var(--edge);
  border-radius: var(--r-lg);
  padding: 26px;
  box-shadow: var(--shadow-soft);
}

.grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
/* São cinco métricas: numa grade de quatro a última ficava órfã numa linha só. */
.grid.metrics { grid-template-columns: repeat(5, minmax(0, 1fr)); }

/* Card de métrica do techzul: rótulo uppercase pequeno em slate-400 e número
   grande em branco, sem cor de destaque. */
.metric-card {
  background: var(--panel);
  border: 1px solid var(--edge);
  border-radius: 28px;
  padding: 24px 26px;
  box-shadow: var(--shadow-soft);
  transition: border-color .18s ease, box-shadow .18s ease;
}

.metric-card:hover { border-color: rgba(99, 102, 241, .35); box-shadow: var(--shadow-lift); }

.metric-label {
  display: block;
  font-size: 10px;
  font-weight: var(--w-black);
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--muted);
}

.metric-card strong {
  display: block;
  margin-top: 10px;
  font-family: var(--display);
  font-size: 34px;
  font-weight: var(--w-black);
  letter-spacing: -.04em;
  color: #fff;
  font-variant-numeric: tabular-nums;
}

.funnel-metrics { display: grid; gap: 14px; }

.panel-title { display: flex; justify-content: space-between; align-items: center; gap: 14px; margin-bottom: 15px; }

/* ------------------ Assinatura: faixa de triagem ao vivo ------------------ */
.triage { display: grid; gap: 14px; }

.triage-bar {
  display: flex;
  height: 13px;
  border-radius: 999px;
  overflow: hidden;
  background: rgba(255, 255, 255, .05);
  border: 1px solid var(--edge);
}

.triage-seg { transition: flex-grow .5s cubic-bezier(.4, 0, .2, 1); min-width: 0; }
.triage-seg[data-state="ai_active"] { background: linear-gradient(90deg, var(--signal-deep), var(--signal)); }
.triage-seg[data-state="waiting_human"] { background: var(--alert); animation: tug 2.4s ease-in-out infinite; }
.triage-seg[data-state="human_active"] { background: var(--human); }
.triage-seg[data-state="closed"] { background: rgba(255, 255, 255, .14); }

@keyframes tug { 0%, 100% { opacity: 1; } 50% { opacity: .55; } }

.triage-legend { display: flex; flex-wrap: wrap; gap: 8px 20px; }

.triage-key { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); }
.triage-key b { font-family: var(--data); font-size: 13px; color: var(--text); font-variant-numeric: tabular-nums; }
.triage-key i { width: 9px; height: 9px; border-radius: 3px; display: inline-block; }
.triage-key[data-state="ai_active"] i { background: var(--signal); }
.triage-key[data-state="waiting_human"] i { background: var(--alert); }
.triage-key[data-state="human_active"] i { background: var(--human); }
.triage-key[data-state="closed"] i { background: rgba(255, 255, 255, .28); }

.triage-empty { color: var(--muted); font-size: 13px; }

/* -------------------------------- Simulador ------------------------------- */
.hero-panel { display: grid; gap: 16px; border-color: var(--edge-strong); }
.hero-panel p:not(.eyebrow) { color: var(--muted); line-height: 1.55; margin-top: 8px; max-width: 70ch; }

.demo-status {
  padding: 12px 14px;
  border-radius: var(--r-md);
  background: rgba(0, 0, 0, .3);
  border: 1px solid var(--edge);
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

/* --------------------------------- Badges --------------------------------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 11px;
  border-radius: 999px;
  font-size: 9px;
  font-weight: var(--w-black);
  letter-spacing: .14em;
  text-transform: uppercase;
  background: rgba(255, 255, 255, .06);
  border: 1px solid var(--edge);
  color: var(--muted);
  margin: 2px 3px 2px 0;
}

.badge.ok { background: rgba(37, 211, 102, .14); color: var(--signal); }
.badge.danger { background: rgba(255, 138, 91, .16); color: var(--alert); }
.badge.warning { background: rgba(167, 139, 250, .16); color: var(--human); }

/* -------------------------- Formulários e tabelas ------------------------- */
/* `text-xs font-black uppercase tracking-widest` em todo rótulo de formulário
   do techzul, do modal de Novo Lead ao painel de preferências. */
label {
  display: grid;
  gap: 9px;
  color: var(--muted);
  font-size: 10px;
  font-weight: var(--w-black);
  letter-spacing: .16em;
  text-transform: uppercase;
}

/* Rótulos que envolvem um controle inline continuam em texto corrido. */
.checkbox-label, .toolbar-check { font-size: 12px; font-weight: 700; letter-spacing: 0; text-transform: none; }

input, textarea, select {
  width: 100%;
  padding: 11px 13px;
  border: 1px solid var(--edge-strong);
  border-radius: var(--r-sm);
  background: rgba(255, 255, 255, .03);
  color: var(--text);
  font-family: var(--body);
  font-size: 13px;
  transition: border-color .18s ease, background .18s ease;
}

input:focus, textarea:focus, select:focus { border-color: var(--brand); background: rgba(255, 255, 255, .05); outline: none; }
input[readonly] { opacity: .6; }
textarea { min-height: 86px; resize: vertical; line-height: 1.55; }

.settings-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 13px; margin-bottom: 13px; }
.checkbox-label { display: flex; align-items: center; gap: 9px; }
.checkbox-label input { width: auto; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { padding: 12px 10px; border-bottom: 1px solid var(--edge); text-align: left; }
th { font-family: var(--data); font-size: 10px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); font-weight: 500; }
td:nth-child(2) { font-family: var(--data); font-size: 12px; }

/* ---------------------------- Base de conhecimento ------------------------ */
.knowledge-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.knowledge-item { display: flex; flex-direction: column; gap: 9px; }
.knowledge-item.inactive { opacity: .55; }
.knowledge-item p { color: var(--muted); font-size: 13px; line-height: 1.55; }
.knowledge-actions { display: flex; gap: 7px; flex-wrap: wrap; margin-top: auto; padding-top: 13px; }
.knowledge-actions button { padding: 7px 11px; font-size: 12px; }

.knowledge-form {
  display: grid;
  gap: 13px;
  margin-bottom: 15px;
  padding: 16px;
  border: 1px solid var(--edge-strong);
  border-radius: var(--r-md);
  background: rgba(37, 211, 102, .05);
}

.knowledge-form[hidden] { display: none; }

.knowledge-form-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.knowledge-form-grid { display: grid; grid-template-columns: 2fr 1fr; gap: 13px; }

.inline-status { color: var(--muted); font-size: 12px; margin-bottom: 13px; }
.calendar-status-row { display: flex; align-items: center; justify-content: space-between; gap: 13px; margin-bottom: 13px; padding: 12px 0; border-top: 1px solid var(--edge); border-bottom: 1px solid var(--edge); }
.calendar-status-row .inline-status { margin: 0; min-width: 0; }
.calendar-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.calendar-actions button { display: inline-flex; align-items: center; gap: 7px; }
.reminder-templates { margin-top: 20px; padding-top: 20px; border-top: 1px solid var(--edge); }
.reminder-templates .panel-title { margin-bottom: 13px; }
.reminder-templates h3 { margin: 0; font-size: 15px; }
.template-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 13px; margin-bottom: 16px; }
.template-grid textarea { min-height: 132px; }
.documents-block { margin-top: 24px; padding-top: 22px; border-top: 1px solid var(--edge); }
.document-meta { font-family: var(--data); font-size: 11px; color: var(--muted); }

.document-alert {
  margin-bottom: 13px;
  padding: 12px 14px;
  border-radius: var(--r-md);
  background: rgba(251, 191, 36, .09);
  border: 1px solid rgba(251, 191, 36, .26);
  color: var(--warning);
  font-size: 12px;
  line-height: 1.5;
}

.document-alert[hidden] { display: none; }
#documentList .empty-state { grid-column: 1 / -1; }

.empty-state {
  padding: 30px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
  border: 1px dashed var(--edge-strong);
  border-radius: var(--r-md);
}

/* --------------------------------- Login ---------------------------------- */
.login-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  overflow-y: auto;
  padding: 32px 20px;
  background: #040815;
}

.login-overlay::before {
  content: "";
  position: fixed;
  inset: 0 0 auto;
  height: 3px;
  background: linear-gradient(90deg, transparent 8%, var(--brand) 34%, #c4b5fd 50%, var(--brand-2) 66%, transparent 92%);
}

.login-overlay[hidden] { display: none; }

.login-shell {
  width: min(480px, 100%);
  display: grid;
  gap: 28px;
}

.login-brand {
  display: grid;
  justify-items: center;
  gap: 8px;
  text-align: center;
}

.login-brand-logo {
  display: block;
  width: min(300px, 76vw);
  height: auto;
}

.login-brand p {
  color: #a9b4c8;
  font-size: 15px;
  font-weight: 500;
  line-height: 1.5;
  letter-spacing: 0;
}

.login-card {
  position: relative;
  display: grid;
  gap: 22px;
  padding: 34px;
  overflow: hidden;
  border: 1px solid rgba(148, 163, 184, .20);
  border-radius: 28px;
  background: rgba(15, 23, 42, .76);
  box-shadow: 0 28px 70px rgba(0, 0, 0, .42);
}

.login-card::before {
  content: "";
  position: absolute;
  inset: 0 18% auto;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(170, 59, 255, .9), transparent);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.login-field {
  gap: 9px;
  color: #cbd5e1;
  font-family: var(--display);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

.login-input-shell {
  min-height: 58px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 17px;
  border: 1px solid var(--edge-strong);
  border-radius: 16px;
  background: rgba(255, 255, 255, .04);
  color: var(--muted);
  transition: border-color .18s ease, box-shadow .18s ease, background .18s ease;
}

.login-input-shell:focus-within {
  border-color: var(--brand);
  background: rgba(255, 255, 255, .06);
  box-shadow: 0 0 0 3px rgba(170, 59, 255, .16);
  color: var(--text);
}

.login-input-shell .icon { width: 20px; height: 20px; flex: none; }

.login-input-shell input {
  min-width: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--text);
  font-size: 15px;
  font-weight: 500;
  letter-spacing: 0;
}

.login-input-shell input::placeholder { color: var(--muted); opacity: 1; }
.login-input-shell input:focus { border: 0; outline: none; }

.login-submit {
  min-height: 58px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-top: 2px;
  border-radius: 16px;
  color: #fff;
  font-family: var(--display);
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

.login-submit .icon { width: 20px; height: 20px; transition: transform .18s ease; }
.login-submit:hover .icon { transform: translateX(3px); }

.login-assurances {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 26px;
  color: #65758f;
}

.login-assurances span {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
  white-space: nowrap;
}

.login-assurances .icon { width: 17px; height: 17px; color: var(--human); }
.form-error { min-height: 18px; color: #fda987; font-size: 12px; line-height: 1.45; }
.form-error:empty { display: none; }

@media (max-width: 520px) {
  .login-overlay { align-items: start; padding: 28px 16px; }
  .login-shell { gap: 22px; }
  .login-brand-logo { width: min(248px, 72vw); }
  .login-card { gap: 19px; padding: 26px 22px; border-radius: 24px; }
  .login-assurances { gap: 12px 20px; flex-wrap: wrap; }
}

@media (max-height: 740px) and (min-width: 521px) {
  .login-overlay { align-items: start; padding-top: 24px; padding-bottom: 24px; }
  .login-shell { gap: 18px; }
  .login-brand-logo { width: 230px; }
  .login-card { gap: 18px; padding-top: 26px; padding-bottom: 26px; }
}

/* --------------------------------- Toasts --------------------------------- */
.toast-region { position: fixed; z-index: 1100; top: 16px; right: 16px; display: grid; gap: 9px; width: min(360px, calc(100vw - 32px)); }

.toast {
  padding: 13px 15px;
  border-radius: var(--r-md);
  background: var(--panel-lift);
  border: 1px solid var(--edge-strong);
  box-shadow: var(--shadow);
  font-size: 13px;
  line-height: 1.45;
  animation: toast-in .24s ease both;
}

.toast.success { border-color: rgba(37, 211, 102, .42); }
.toast.error { border-color: rgba(255, 138, 91, .5); color: #ffd9c9; }

@keyframes toast-in {
  from { opacity: 0; transform: translateX(14px); }
  to { opacity: 1; transform: none; }
}

/* ------------------------------- Responsivo ------------------------------- */
@media (max-width: 1120px) {
  .grid.metrics { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

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

@media (max-width: 820px) {
  .tabbar { height: auto; gap: 12px; padding: 12px 14px; flex-wrap: wrap; }
  .tabbar-brand span { display: none; }
  .tabbar-actions { gap: 8px; }
  .agent-pill { padding: 0 13px; font-size: 10px; }
  .nav-link { padding: 10px 13px; }
  main { padding: 14px 16px 30px; }
  .grid, .settings-grid, .knowledge-list, .knowledge-form-grid, .template-grid, .shortcut-row { grid-template-columns: 1fr; }
  .calendar-status-row { align-items: flex-start; flex-direction: column; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
}

/* --------------------------- Instruções do agente -------------------------- */
.instructions-header { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: 16px; margin-bottom: 8px; color: var(--muted); font-size: 13px; }
.instructions-actions { display: flex; align-items: center; gap: 12px; }
.instructions-count { color: var(--muted); font-size: 12px; }
.instructions-count.is-near-limit { color: var(--warning); }
.instructions-input { min-height: 320px; font-family: ui-monospace, "JetBrains Mono", "SFMono-Regular", Menlo, monospace; font-size: 13px; line-height: 1.55; }

/* ------------------------------- Scrollbar -------------------------------- */
::-webkit-scrollbar { width: 7px; height: 7px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(148, 163, 184, .14); border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: rgba(148, 163, 184, .26); }

/* --------------------------------- Ícones --------------------------------- */
.icon {
  width: 1em;
  height: 1em;
  flex: none;
  vertical-align: -0.125em;
}

/* ------------------------- Cabeçalho de página ---------------------------- */
/* CRM/index.tsx: título black + divisor vertical arredondado + pílula de
   contexto em roxo sobre fundo translúcido. */
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.page-title { display: flex; align-items: center; gap: 16px; min-width: 0; }
.page-divider { width: 4px; height: 32px; flex: none; border-radius: 999px; background: var(--panel-lift); }

.page-tag {
  display: inline-flex;
  align-items: center;
  padding: 7px 14px;
  border-radius: 999px;
  background: rgba(170, 59, 255, .16);
  color: #d8b4fe;
  font-size: 10px;
  font-weight: var(--w-black);
  letter-spacing: .18em;
  text-transform: uppercase;
  white-space: nowrap;
}

/* -------------------------- Atalhos da tela Início ------------------------- */
.shortcut-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }

.shortcut-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 24px 26px;
  border: 1px solid var(--edge);
  border-radius: 28px;
  background: var(--panel);
  text-align: left;
  text-transform: none;
  letter-spacing: 0;
  box-shadow: var(--shadow-soft);
  transition: border-color .18s ease, box-shadow .18s ease;
}

.shortcut-card:hover { transform: none; border-color: rgba(99, 102, 241, .38); box-shadow: var(--shadow-lift); }
.shortcut-body { display: grid; gap: 5px; min-width: 0; }

.shortcut-head {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  font-family: var(--display);
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -.02em;
  color: #fff;
}

.shortcut-head .icon { width: 18px; height: 18px; color: var(--indigo); }
.shortcut-meta { font-size: 13px; font-weight: 600; color: var(--muted); }
.shortcut-go { width: 20px; height: 20px; flex: none; color: var(--muted); }
.shortcut-card:hover .shortcut-go { color: var(--text); }

/* ------------------------------ Grade da Início ---------------------------- */
.home-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; align-items: start; }
.home-panel { border-radius: 32px; display: flex; flex-direction: column; }

.panel-heading {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  font-family: var(--display);
  font-size: 19px;
  font-weight: 700;
  letter-spacing: -.02em;
  color: #fff;
}

.panel-heading .icon { width: 19px; height: 19px; color: var(--indigo); }
.panel-note { font-size: 13px; font-weight: 600; color: var(--muted); }

.link-action {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 0;
  background: none;
  color: var(--text);
  font-size: 11px;
  font-weight: var(--w-black);
  letter-spacing: .1em;
  text-transform: uppercase;
}

.link-action .icon { width: 15px; height: 15px; }
.link-action:hover { transform: none; color: #a5b4fc; }

/* Gráfico de barras do Dashboard.tsx: gradiente azul, guias tracejadas ao
   fundo, contagem acima e rótulo curto abaixo. */
.funnel-chart {
  position: relative;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 10px;
  height: 210px;
  padding: 4px 2px 0;
}

.funnel-chart::before {
  content: "";
  position: absolute;
  inset: 0 0 34px;
  background-image: repeating-linear-gradient(to bottom, var(--edge) 0 1px, transparent 1px 25%);
  opacity: .6;
  pointer-events: none;
}

.chart-col { position: relative; z-index: 1; flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: center; gap: 8px; height: 100%; }
.chart-count { flex: none; font-size: 12px; font-weight: var(--w-black); color: var(--text); font-variant-numeric: tabular-nums; }

/* A barra é ancorada por posicionamento absoluto na pista. Como filha flex
   comum, a altura em porcentagem resolvia para zero: a pista tira a própria
   altura de `flex: 1`, e o navegador a trata como indefinida para efeito de
   resolução de porcentagem. Contra um ancestral posicionado a conta fecha. */
.chart-track { position: relative; flex: 1; min-height: 0; width: 100%; }

/* A altura vem de `top`, não de `height`: em porcentagem, `height` resolvia
   para zero aqui, enquanto o par top/bottom resolve contra a pista sem
   ambiguidade. O JS emite `top: (100 - proporção)%`. */
.chart-bar {
  position: absolute;
  bottom: 0;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 46px;
  border-radius: 10px;
  background: linear-gradient(180deg, #9dbaff, #6084ff);
  transition: top .8s cubic-bezier(.4, 0, .2, 1);
}

.chart-label { height: 26px; font-size: 10px; font-weight: 600; line-height: 1.25; text-align: center; color: var(--muted); }
.triage-block { margin-top: 22px; padding-top: 20px; border-top: 1px solid var(--edge); display: grid; gap: 12px; }

/* ---------------------------- Conversas recentes --------------------------- */
.recent-list { display: flex; flex-direction: column; }

.recent-row {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  padding: 15px 6px;
  border: 0;
  border-bottom: 1px dashed var(--edge);
  border-radius: 0;
  background: none;
  text-align: left;
  text-transform: none;
  letter-spacing: 0;
}

.recent-row:last-child { border-bottom: 0; }
.recent-row:hover { transform: none; background: rgba(255, 255, 255, .03); }
.recent-main { display: grid; gap: 4px; min-width: 0; flex: 1; }
.recent-name { font-size: 14px; font-weight: 700; color: #fff; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.recent-sub { font-size: 12px; font-weight: 500; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.recent-go {
  width: 32px;
  height: 32px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: var(--panel-lift);
  color: var(--muted);
}

.recent-go .icon { width: 14px; height: 14px; }
.recent-row:hover .recent-go { background: var(--indigo-soft); color: #c7d2fe; }

/* ---------------------------------- Busca ---------------------------------- */
/* `rounded-[20px] pl-14 py-4 font-bold` com o ícone posicionado à esquerda. */
.search-shell { position: relative; display: flex; align-items: center; }

.search-icon {
  position: absolute;
  left: 20px;
  width: 18px;
  height: 18px;
  pointer-events: none;
  color: var(--muted);
}

.search-shell input[type="search"] {
  width: 100%;
  padding: 16px 22px 16px 52px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 600;
}

.search-shell:focus-within .search-icon { color: #a5b4fc; }

/* ---------------------------------- Funil ---------------------------------- */
.toolbar-check { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 12px; font-weight: 700; }
.toolbar-check input { width: auto; }

/* Largura fixa com scroll horizontal, como o KanbanBoard do techzul.
   A rolagem fica no quadro; o corpo da página nunca rola na horizontal. */
/* As colunas se esticam até o fim da janela em vez de encolherem ao tamanho do
   conteúdo: com um único lead, o quadro terminava logo abaixo do primeiro card
   e a barra de rolagem horizontal subia para o meio da tela. */
.funnel-board {
  display: flex;
  align-items: stretch;
  gap: 20px;
  min-height: min(62vh, 560px);
  overflow-x: auto;
  padding-bottom: 10px;
}

/* Coluna neutra: sem faixa colorida no topo, sem borda. */
.funnel-column {
  width: 280px;
  flex: none;
  display: flex;
  flex-direction: column;
  background: rgba(30, 41, 59, .30);
  border-radius: var(--r-lg);
  padding: 16px;
}

.column-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 16px; padding: 0 4px; }

.column-title {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  margin: 0;
  font-family: var(--body);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Único vestígio de cor de estado na coluna. */
.column-dot { width: 8px; height: 8px; flex: none; border-radius: 999px; background: var(--tone, var(--muted)); }

.column-count {
  flex: none;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--ink);
  border: 1px solid var(--edge-strong);
  box-shadow: var(--shadow-soft);
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.column-body { flex: 1; display: flex; flex-direction: column; gap: 16px; min-height: 120px; overflow-y: auto; }
.column-empty { color: var(--muted); font-size: 13px; margin: 0; line-height: 1.5; }

.funnel-column[data-tone="signal"] { --tone: var(--signal); }
.funnel-column[data-tone="alert"] { --tone: var(--alert); }
.funnel-column[data-tone="human"] { --tone: var(--human); }
.funnel-column[data-tone="brand"] { --tone: var(--brand); }
.funnel-column[data-tone="muted"] { --tone: var(--muted); }

/* Card do LeadCard.tsx: sem borda-esquerda colorida, raio 24, sombra suave.
   O estado vira um badge pequeno em vez de faixa lateral. */
.funnel-card {
  position: relative;
  background: var(--panel);
  border: 1px solid var(--edge-strong);
  border-radius: var(--r-lg);
  padding: 20px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 10px;
  text-align: left;
  box-shadow: var(--shadow-soft);
  transition: border-color .18s ease, box-shadow .18s ease;
}

.funnel-card[data-tone="signal"] { --tone: var(--signal); }
.funnel-card[data-tone="alert"] { --tone: var(--alert); }
.funnel-card[data-tone="human"] { --tone: var(--human); }
.funnel-card[data-tone="brand"] { --tone: var(--brand); }
.funnel-card[data-tone="muted"] { --tone: var(--muted); }

.funnel-card:hover { border-color: rgba(99, 102, 241, .30); box-shadow: var(--shadow-lift); }
.funnel-card:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.funnel-card.is-dragging { opacity: .42; box-shadow: none; }
.funnel-column.can-drop { outline: 1px dashed rgba(129, 140, 248, .58); outline-offset: -2px; }
.funnel-column.cannot-drop { cursor: not-allowed; opacity: .72; }
.funnel-column.is-drop-target {
  outline: 2px solid var(--tone, var(--brand));
  outline-offset: -2px;
  background: rgba(79, 70, 229, .14);
}

.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.card-body { min-width: 0; }
.card-name { display: block; font-family: var(--display); font-size: 18px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-phone { font-family: var(--data); font-size: 12px; color: var(--muted); margin-top: 2px; }

/* Badge de estado no molde do badge de segmento do techzul. */
.card-state {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  align-self: flex-start;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, .05);
  border: 1px solid var(--edge-strong);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--muted);
}

/* O fallback importa: este mesmo badge é reusado no cabeçalho da página do
   lead (Task 8) e nas conversas recentes da Início, onde não existe ancestral
   com data-tone para definir --tone. */
.card-state i { width: 6px; height: 6px; border-radius: 999px; background: var(--tone, var(--muted)); }
.card-state[data-tone="signal"] { --tone: var(--signal); }
.card-state[data-tone="alert"] { --tone: var(--alert); }
.card-state[data-tone="human"] { --tone: var(--human); }
.card-state[data-tone="brand"] { --tone: var(--brand); }
.card-state[data-tone="muted"] { --tone: var(--muted); }

/* Contador de não lidas em roxo, no padrão do badge de notificação do
   Header.tsx — o coral anterior competia com o dot de estado. */
.unread-count {
  display: inline-grid;
  place-items: center;
  min-width: 20px;
  height: 20px;
  flex: none;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--brand);
  color: #fff;
  font-size: 10px;
  font-weight: 800;
  box-shadow: var(--shadow-lift);
}

.card-preview { color: var(--muted); font-size: 13px; margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-outcome, .card-handoff { font-size: 12px; margin: 0; color: var(--muted); display: flex; align-items: center; gap: 6px; line-height: 1.45; }

.card-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 4px; padding-top: 14px; border-top: 1px solid var(--edge); }
.card-foot-main { display: grid; gap: 3px; min-width: 0; }
.card-product { font-size: 10px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; color: var(--brand); }
.card-time { font-family: var(--data); font-size: 11px; color: var(--muted); display: inline-flex; align-items: center; gap: 4px; }

/* Botão circular de abrir conversa, espelhando o botão de WhatsApp do techzul.
   É decorativo: quem recebe o clique é o card inteiro. */
.card-open {
  width: 40px;
  height: 40px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: var(--r-md);
  background: rgba(79, 70, 229, .18);
  color: #a5b4fc;
  font-size: 18px;
}

.funnel-card:hover .card-open { background: rgba(79, 70, 229, .30); color: #c7d2fe; }

@media (prefers-reduced-motion: reduce) {
  .funnel-card, .nav-link { transition: none; }
}

/* -------------------------- Menu de ações do card -------------------------- */
.card-menu { position: relative; flex: none; }
.icon-button { background: none; border: 0; color: var(--muted); cursor: pointer; padding: 6px; border-radius: var(--r-sm); font-size: 18px; }
.icon-button:hover { color: var(--text); background: rgba(255, 255, 255, .07); transform: none; }
.icon-button:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

.card-menu-list {
  position: absolute;
  right: 0;
  top: 100%;
  z-index: 20;
  min-width: 200px;
  background: var(--panel-lift);
  border: 1px solid var(--edge-strong);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-lift);
  padding: 6px;
  display: flex;
  flex-direction: column;
}

/* Regra companheira obrigatória: sem ela o atributo hidden não vence a
   declaração de display acima e o menu fica permanentemente aberto. */
.card-menu-list[hidden] { display: none; }

.card-menu-list button { background: none; border: 0; color: var(--text); text-align: left; padding: 10px 12px; border-radius: var(--r-sm); cursor: pointer; font-size: 10px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; }
.card-menu-list button:hover { background: rgba(255, 255, 255, .06); transform: none; }
.card-menu-list .menu-danger { color: #fca5a5; border-top: 1px solid var(--edge); border-radius: 0; margin-top: 4px; padding-top: 12px; }
.card-menu-list .menu-danger:hover { background: rgba(239, 68, 68, .10); }

.modal { position: fixed; inset: 0; background: rgba(2, 6, 23, .72); display: grid; place-items: center; z-index: 60; padding: 20px; }
.modal[hidden] { display: none; }
.modal-card { background: var(--panel); border: 1px solid var(--edge-strong); border-radius: var(--r-lg); box-shadow: var(--shadow); padding: 20px; width: min(440px, 100%); }
.modal-card h3 { font-family: var(--display); margin: 0 0 4px; }
.modal-help { color: var(--muted); font-size: 13px; margin: 0 0 12px; }
.modal-card textarea { width: 100%; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px; }
.delete-warning { margin: 0; color: #fecaca; font-size: 13px; line-height: 1.5; }

/* ------------------------------- Lead / Chat ------------------------------ */
.lead-head { display: flex; align-items: center; gap: 14px; margin-bottom: 6px; flex-wrap: wrap; }
.lead-head .actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }

/* Avatar quadrado com gradiente indigo→roxo da LeadDetail do techzul. */
.lead-avatar {
  position: relative;
  width: 56px;
  height: 56px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: var(--r-md);
  background: linear-gradient(135deg, var(--indigo), #a855f7, var(--brand));
  color: #fff;
  font-family: var(--display);
  font-size: 18px;
  font-weight: var(--w-black);
  box-shadow: 0 14px 34px rgba(139, 92, 246, .32);
}

/* Etiqueta sobreposta no canto do avatar, como no LeadDetail do techzul. */
.lead-avatar::after {
  content: "Lead";
  position: absolute;
  right: -5px;
  bottom: -5px;
  padding: 2px 6px;
  border-radius: 7px;
  border: 1px solid var(--edge-strong);
  background: var(--panel);
  color: var(--muted);
  font-family: var(--body);
  font-size: 8px;
  font-weight: var(--w-black);
  letter-spacing: .14em;
  text-transform: uppercase;
}

.lead-identity { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; min-width: 0; }
.lead-name { font-family: var(--display); font-size: 28px; font-weight: 800; letter-spacing: -.03em; margin: 0; color: #fff; }

/* Ação primária: botão invertido do techzul. */
.action-primary {
  padding: 12px 20px;
  border: 0;
  border-radius: var(--r-md);
  background: #fff;
  color: #0f172a;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .1em;
  text-transform: uppercase;
  cursor: pointer;
  box-shadow: var(--shadow-lift);
}

.action-primary:hover { background: #f8fafc; box-shadow: 0 16px 34px rgba(15, 23, 42, .30); }

.action-secondary {
  padding: 12px 18px;
  border: 1px solid var(--edge-strong);
  border-radius: var(--r-md);
  background: var(--panel-lift);
  color: var(--text);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .1em;
  text-transform: uppercase;
  cursor: pointer;
}

.action-secondary:hover { border-color: rgba(99, 102, 241, .35); }

/* FunnelStepper do techzul: cartão raso com as etapas em pílulas; a atual é a
   pílula branca invertida, as cumpridas ficam em índigo com um check. */
.lead-stages {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px;
  border: 1px solid var(--edge);
  border-radius: var(--r-lg);
  background: var(--panel);
  box-shadow: var(--shadow-soft);
  overflow-x: auto;
}

.lead-stage {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex: none;
  padding: 10px 14px;
  border-radius: var(--r-sm);
  font-size: 10px;
  font-weight: var(--w-black);
  letter-spacing: .12em;
  text-transform: uppercase;
  white-space: nowrap;
}

.lead-stage .icon { width: 11px; height: 11px; }
.lead-stage[data-state="current"] { background: #fff; color: #0f172a; box-shadow: 0 10px 22px rgba(255, 255, 255, .10); }
.lead-stage[data-state="past"] { background: rgba(99, 102, 241, .22); color: #a5b4fc; }
.lead-stage[data-state="future"] { background: rgba(51, 65, 85, .45); color: var(--muted); }

.lead-grid { display: grid; grid-template-columns: 300px minmax(0, 1fr) 320px; gap: 16px; align-items: start; }
.lead-grid.audit-collapsed { grid-template-columns: 300px minmax(0, 1fr); }
.lead-grid.audit-collapsed .lead-audit { display: none; }

@media (max-width: 1100px) { .lead-grid, .lead-grid.audit-collapsed { grid-template-columns: minmax(0, 1fr); } }

/* Painéis laterais no padrão das seções "Sobre"/"Preferências" do techzul. */
.side-title { font-size: 13px; font-weight: 800; letter-spacing: .18em; text-transform: uppercase; color: #fff; margin: 0 0 4px; }
.side-field { padding: 12px 0; border-bottom: 1px solid var(--edge); }
.side-field:last-child { border-bottom: 0; }
.side-label { display: block; font-size: 10px; font-weight: 800; letter-spacing: .18em; text-transform: uppercase; color: var(--muted); margin-bottom: 5px; }
.side-field p { font-size: 14px; font-weight: 500; line-height: 1.45; overflow-wrap: anywhere; }
/* ------------------------ Conversa (WhatsApp real) ------------------------ */
/* Este bloco imita o WhatsApp, não o techzul: é a única superfície do sistema
   com essa regra, e é deliberado — o operador reconhece o app que o lead usa. */
.lead-chat {
  display: flex;
  flex-direction: column;
  min-height: 60vh;
  padding: 0;
  overflow: hidden;
  background: #0b141a;
  border-color: rgba(0, 0, 0, .4);
}

.chat-stream {
  flex: 1;
  overflow-y: auto;
  max-height: 62vh;
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 18px 22px;
  background-color: #0b141a;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140' viewBox='0 0 140 140'%3E%3Cg fill='none' stroke='%23ffffff' stroke-opacity='0.03' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='22' cy='24' r='9'/%3E%3Cpath d='M64 16h18v13h-9l-5 6v-6h-4z'/%3E%3Cpath d='M112 30a9 9 0 1 1-18 0 9 9 0 0 1 18 0z'/%3E%3Cpath d='M26 74h16v11h-8l-4 5v-5h-4z'/%3E%3Cpath d='M70 68l7 7-7 7-7-7z'/%3E%3Cpath d='M104 78h14M111 71v14'/%3E%3Cpath d='M18 116h16M26 108v16'/%3E%3Ccircle cx='76' cy='118' r='8'/%3E%3Cpath d='M110 112h16v12h-8l-4 5v-5h-4z'/%3E%3C/g%3E%3C/svg%3E");
}

.chat-row { display: flex; }
.chat-row[data-sender="lead"] { justify-content: flex-start; }
.chat-row[data-sender="ai"], .chat-row[data-sender="human"] { justify-content: flex-end; }

.chat-bubble {
  position: relative;
  max-width: 65%;
  border-radius: 7.5px;
  padding: 6px 9px 8px;
  color: #e9edef;
  font-size: 14.2px;
  line-height: 1.35;
  box-shadow: 0 1px 0.5px rgba(11, 20, 26, .13);
}

.chat-row[data-sender="lead"] .chat-bubble { background: #202c33; }
.chat-row[data-sender="ai"] .chat-bubble,
.chat-row[data-sender="human"] .chat-bubble { background: #005c4b; }

/* Rabinho apenas no primeiro balão de cada sequência. */
.chat-bubble.starts-run::after {
  content: "";
  position: absolute;
  top: 0;
  width: 8px;
  height: 13px;
  clip-path: polygon(0 0, 100% 0, 0 100%);
}

.chat-row[data-sender="lead"] .chat-bubble.starts-run { border-top-left-radius: 0; }
.chat-row[data-sender="lead"] .chat-bubble.starts-run::after { left: -8px; background: #202c33; clip-path: polygon(100% 0, 100% 100%, 0 0); }
.chat-row[data-sender="ai"] .chat-bubble.starts-run,
.chat-row[data-sender="human"] .chat-bubble.starts-run { border-top-right-radius: 0; }
.chat-row[data-sender="ai"] .chat-bubble.starts-run::after,
.chat-row[data-sender="human"] .chat-bubble.starts-run::after { right: -8px; background: #005c4b; }

.chat-bubble.is-failed { outline: 1px solid var(--danger); }
.bubble-text { display: inline; overflow-wrap: anywhere; }
.bubble-text .icon { margin-right: 5px; opacity: .75; }

/* Metadados dentro da bolha, no canto inferior direito, como no WhatsApp. */
.bubble-meta {
  float: right;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin: 6px -3px -3px 10px;
  font-size: 11px;
  color: rgba(233, 237, 239, .6);
}

.bubble-sender { display: inline-flex; opacity: .75; font-size: 12px; }
.bubble-time { font-variant-numeric: tabular-nums; }
.bubble-check { display: inline-flex; align-items: center; letter-spacing: -.08em; }
.bubble-check[data-status="failed"] { color: var(--danger); font-weight: 800; letter-spacing: 0; }

/* Divisor de data e mensagens de sistema: mesmo pill centralizado. */
.chat-day { display: flex; justify-content: center; margin: 12px 0; }

.chat-day span,
.chat-system {
  display: inline-block;
  padding: 6px 13px;
  border-radius: 8px;
  background: #182229;
  color: rgba(233, 237, 239, .75);
  font-size: 12px;
  box-shadow: 0 1px 0.5px rgba(11, 20, 26, .13);
}

.chat-system { align-self: center; margin: 8px 0; text-align: center; }

/* ------------------------------- Composer -------------------------------- */
.chat-composer { position: relative; padding: 10px 16px 14px; background: #202c33; border-top: 1px solid rgba(0, 0, 0, .4); }
.composer-hint { color: rgba(233, 237, 239, .5); font-size: 11.5px; margin: 0 0 8px; padding: 0 4px; }
.composer-hint:empty { display: none; }

.composer-bar { display: flex; align-items: flex-end; gap: 8px; }

.composer-icon {
  width: 42px;
  height: 42px;
  flex: none;
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: rgba(233, 237, 239, .6);
  font-size: 22px;
  cursor: pointer;
}

.composer-icon:hover { color: #e9edef; transform: none; }

.chat-composer textarea {
  flex: 1;
  min-height: 42px;
  max-height: 132px;
  padding: 11px 15px;
  border: 0;
  border-radius: 8px;
  background: #2a3942;
  color: #e9edef;
  font-family: var(--body);
  font-size: 14.2px;
  line-height: 1.35;
  resize: none;
  overflow-y: auto;
}

.chat-composer textarea::placeholder { color: rgba(233, 237, 239, .45); }
.chat-composer textarea:focus { border: 0; outline: none; }

.composer-send {
  width: 42px;
  height: 42px;
  flex: none;
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: #00a884;
  color: #0b141a;
  font-size: 19px;
  cursor: pointer;
  box-shadow: none;
}

.composer-send:hover { background: #06cf9c; transform: none; }
.composer-send:disabled { background: #2a3942; color: rgba(233, 237, 239, .35); }

.emoji-panel {
  position: absolute;
  left: 16px;
  bottom: 64px;
  z-index: 40;
  width: min(320px, calc(100% - 32px));
  max-height: 220px;
  overflow-y: auto;
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 2px;
  padding: 10px;
  border-radius: var(--r-md);
  background: #233138;
  border: 1px solid rgba(0, 0, 0, .4);
  box-shadow: var(--shadow-lift);
}

/* Regra companheira obrigatória do atributo hidden. */
.emoji-panel[hidden] { display: none; }

.emoji-panel button { padding: 6px; border: 0; border-radius: 8px; background: transparent; font-size: 20px; line-height: 1; cursor: pointer; }
.emoji-panel button:hover { background: rgba(255, 255, 255, .08); transform: none; }

/* ---------------------------- Conversation summary ---------------------------- */
.conversation-summary-text { margin: 16px 0 0; font-size: 14px; font-weight: 600; line-height: 1.55; overflow-wrap: anywhere; }
.conversation-summary-list { list-style: none; margin: 18px 0 0; padding: 16px 0 0; display: flex; flex-direction: column; gap: 13px; border-top: 1px solid var(--edge); }
.conversation-summary-item { display: flex; gap: 10px; align-items: flex-start; }
.conversation-summary-item p { margin: 0; font-size: 13px; line-height: 1.5; color: var(--text-soft); overflow-wrap: anywhere; }
.conversation-summary-icon { flex: 0 0 auto; color: var(--success); margin-top: 2px; }
.conversation-summary-empty { margin: 16px 0 0; color: var(--muted); font-size: 13px; line-height: 1.5; }
.conversation-summary-updated { display: flex; align-items: center; gap: 6px; margin: 18px 0 0; padding-top: 13px; border-top: 1px solid var(--edge); font-family: var(--data); font-size: 10px; color: var(--muted); }

/* ------------------------------- Sub-abas -------------------------------- */
/* Padrão do LeadDetail do techzul: uppercase com tracking largo, ativa em
   roxo com sublinhado de 2px arredondado, inativas em slate-400. */
.subtabs {
  display: flex;
  align-items: center;
  gap: 4px;
  border-bottom: 1px solid var(--edge-strong);
  overflow-x: auto;
}

.subtab {
  position: relative;
  padding: 14px 20px;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .1em;
  text-transform: uppercase;
  white-space: nowrap;
  cursor: pointer;
  transition: color .18s ease;
}

.subtab:hover { color: var(--text); transform: none; }
.subtab[aria-current="page"] { color: var(--brand); }

.subtab[aria-current="page"]::after {
  content: "";
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: -1px;
  height: 2px;
  border-radius: 999px;
  background: var(--brand);
}

/* Uma sub-view por vez, mesmo mecanismo de .view. */
.subview { display: none; flex-direction: column; gap: 18px; }
.subview.is-active { display: flex; }
