/* =============================================================================
   Painel do robô AERIS · Direção "Cockpit" (base Obsidian) · prancha: design/direcoes/direcao-b.html
   Tipografia   Inter (interface, base 13px, cv11/ss01/ss03) + JetBrains Mono para micro-rótulos em
                caixa-alta (11px, tracking .08em), horários, telefones e números.
   Cor          quase-preto frio. Verde do WhatsApp SÓ em: ação primária, item ativo, "Aguardando você",
                contadores e online/ok. Carmim = erro. Todo o resto é cinza.
   Profundidade borda a 7% + realce interno de 1px (inset). Sombra preta só no que flutua (toast, dica).
   Navegação    barra de telemetria no topo (robô, teste, WhatsApp, Gemini, Supabase, webhook, ao vivo) +
                trilho de ícones de 56px. No celular: barra de abas em vidro escuro com as 5 áreas.
   Assinatura   a passagem para humano como "alerta de cabine": borda esquerda de 2px verde, rótulo mono.
   Escala       múltiplos de 4px. Raios curtos de instrumento: 4 · 6 · 10 · 14.
   ============================================================================= */

:root {
  color-scheme: dark;

  /* Superfícies */
  --bg: #08090A;
  --bg-subtle: #0C0D0F;          /* trilho, coluna da lista, telemetria */
  --surface: #111214;            /* alerta, composer, painéis */
  --surface-raised: #17181B;     /* balão do cliente, dica, item ativo */
  --surface-hover: rgba(255, 255, 255, .045);
  --surface-active: rgba(255, 255, 255, .075);
  --border: rgba(255, 255, 255, .07);
  --border-strong: rgba(255, 255, 255, .13);

  /* Texto */
  --text: #EDEEF0;               /* 17:1 */
  --text-secondary: #9A9EA7;     /* 7,4:1 */
  --text-tertiary: #6C707A;      /* 4,0:1 · só metadado, eixo, placeholder */

  /* Verde do WhatsApp (modo escuro): botão em #00A884 com texto escuro, como no WhatsApp Web */
  --accent: #00A884;             /* texto #0B141A sobre ele = 6,1:1 */
  --accent-hover: #06CF9C;       /* mais claro no hover, texto escuro continua AA */
  --accent-fg: #0B141A;
  --accent-text: #25D366;        /* verde como texto/ícone: 10:1 sobre o fundo */
  --accent-subtle: rgba(37, 211, 102, .13);
  --signal: #25D366;             /* sinal (ponto, borda, barra da hora atual, contadores) */
  --ring: rgba(37, 211, 102, .5);

  --success: #25D366;  --success-subtle: rgba(37, 211, 102, .14);   /* online/ok: o mesmo verde, para não haver dois */
  --warning: #E8B54A;  --warning-subtle: rgba(232, 181, 74, .12);
  --danger:  #EF4F6B;  --danger-subtle:  rgba(239, 79, 107, .12);
  --info:    #8EA2C8;  --info-subtle:    rgba(142, 162, 200, .12);

  --chart-1: #4E525C; --chart-2: #3FD69F; --chart-3: #8EA2C8; --chart-4: #E8B54A; --chart-5: #2A2C31;

  --font-sans: "Inter Variable", "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;
  --font-display: var(--font-sans);

  --radius-sm: 4px; --radius-md: 6px; --radius-lg: 10px; --radius-xl: 14px;
  --shadow-xs: 0 0 0 1px var(--border), inset 0 1px 0 rgba(255, 255, 255, .05);
  --shadow-sm: 0 0 0 1px var(--border), inset 0 1px 0 rgba(255, 255, 255, .05), 0 2px 6px rgba(0, 0, 0, .35);
  --shadow-md: 0 0 0 1px var(--border-strong), inset 0 1px 0 rgba(255, 255, 255, .06), 0 12px 28px -8px rgba(0, 0, 0, .6);
  --shadow-lg: 0 0 0 1px var(--border-strong), inset 0 1px 0 rgba(255, 255, 255, .06), 0 24px 64px -16px rgba(0, 0, 0, .75);

  --ease-out: cubic-bezier(.16, 1, .3, 1);
  --ease-in-out: cubic-bezier(.65, 0, .35, 1);
  --dur-1: 120ms; --dur-2: 180ms; --dur-3: 260ms;

  /* Extensões da Cockpit */
  --text-body: 13px;
  --leading-body: 20px;
  --text-micro: 11px;
  --tracking-micro: .08em;
  --edge: inset 0 1px 0 rgba(255, 255, 255, .05);
  --edge-accent: inset 0 1px 0 rgba(255, 255, 255, .22);
  --spotlight: radial-gradient(620px 300px at 50% -12%, rgba(190, 202, 235, .075), transparent 70%);
  --rail-w: 56px;
  --tele-h: 28px;
  --h-sm: 36px; --h-md: 44px;
  --gutter: 16px; --nav-h: 60px;
  --glass-bg-bar: rgba(17, 18, 20, .72);
}

/* ---------- Base complementar ---------- */
html, body { height: 100%; }
body { font-feature-settings: "cv11", "ss01", "ss03"; letter-spacing: -.006em; overflow: hidden; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; letter-spacing: inherit; padding: 0; }
button:disabled { cursor: default; opacity: .55; }
ul, ol { list-style: none; margin: 0; padding: 0; }
dl, dd { margin: 0; }
[hidden] { display: none !important; }
input, textarea, select { font: inherit; color: inherit; letter-spacing: inherit; }
.num { font-variant-numeric: tabular-nums; }
.micro {
  font-family: var(--font-mono); font-size: var(--text-micro); line-height: 16px; font-weight: 500;
  letter-spacing: var(--tracking-micro); text-transform: uppercase; font-variant-numeric: tabular-nums;
}
.mono-n { font-family: var(--font-mono); font-variant-numeric: tabular-nums; letter-spacing: 0; }
.ph, .ph-fill { line-height: 1; }

/* ---------- Peças da direção ---------- */
.led { display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--success); box-shadow: 0 0 0 3px var(--success-subtle); flex: none; }
.led.off { background: var(--danger); box-shadow: 0 0 0 3px var(--danger-subtle); }
.led.idle { background: var(--text-tertiary); box-shadow: 0 0 0 3px var(--surface-hover); }
.sw { position: relative; display: inline-block; width: 26px; height: 14px; border-radius: 999px; background: var(--border-strong); flex: none; }
.sw::after { content: ""; position: absolute; top: 2px; left: 2px; width: 10px; height: 10px; border-radius: 50%; background: var(--text); transition: transform var(--dur-1) var(--ease-out); }
.sw.on { background: var(--success); }
.sw.on::after { transform: translateX(12px); background: var(--bg); }
kbd { min-width: 18px; height: 18px; padding: 0 4px; border-radius: var(--radius-sm); background: var(--surface-hover); border: 0; box-shadow: inset 0 0 0 1px var(--border); font: 500 11px/1 var(--font-mono); color: var(--text-secondary); }

/* Status pela forma: círculo vazio (robô), meio (você respondeu), cheio verde (aguardando você) */
.st { font-size: 16px; line-height: 1; flex: none; }
.st-wait { color: var(--signal); }
.st-you { color: var(--text-secondary); }
.st-bot { color: var(--text-tertiary); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 32px; padding: 0 12px;
  border-radius: var(--radius-md); font: 500 13px/1 var(--font-sans); letter-spacing: -.005em; white-space: nowrap;
}
.btn i { font-size: 16px; }
.btn-primary { background: var(--accent); color: var(--accent-fg); font-weight: 600; box-shadow: var(--edge-accent), 0 0 0 1px var(--border); }
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); }
.btn-primary kbd { background: rgba(11, 20, 26, .16); box-shadow: none; color: var(--accent-fg); }
.btn-secondary { background: var(--surface-raised); color: var(--text); box-shadow: var(--shadow-xs); }
.btn-secondary:hover:not(:disabled) { box-shadow: 0 0 0 1px var(--border-strong), var(--edge); }
.btn-ghost { color: var(--text-secondary); }
.btn-ghost:hover:not(:disabled) { background: var(--surface-hover); color: var(--text); }
.ib { width: 28px; height: 28px; display: grid; place-items: center; border-radius: var(--radius-md); color: var(--text-tertiary); flex: none; }
.ib i { font-size: 16px; }
.ib:hover { background: var(--surface-hover); color: var(--text); }
.av {
  width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; flex: none;
  background: var(--surface-raised); box-shadow: var(--shadow-xs); font: 600 12px/1 var(--font-sans); letter-spacing: 0; color: var(--text-secondary);
}
.find {
  display: flex; align-items: center; gap: 8px; height: 32px; padding: 0 6px 0 10px; border-radius: var(--radius-md);
  background: var(--surface-hover); box-shadow: inset 0 0 0 1px var(--border); color: var(--text-tertiary);
}
.find:focus-within { box-shadow: inset 0 0 0 1px var(--border-strong), 0 0 0 3px var(--accent-subtle); }
.find i { font-size: 16px; }
.find input { flex: 1; min-width: 0; height: 100%; background: none; border: 0; outline: none; color: var(--text); font-size: 13px; }
.find input::placeholder { color: var(--text-tertiary); }
.find kbd { margin-left: auto; }

/* ---------- Login ---------- */
.login { position: fixed; inset: 0; display: grid; place-items: center; padding: 24px; background: var(--bg); overflow: auto; }
.login::before { content: ""; position: absolute; inset: 0; background: var(--spotlight); pointer-events: none; }
.login-card { position: relative; width: 100%; max-width: 360px; display: grid; gap: 18px; }
.login-mark { display: flex; align-items: center; gap: 10px; }
.mark {
  width: 28px; height: 28px; display: grid; place-items: center; border-radius: var(--radius-md);
  background: var(--surface-raised); box-shadow: var(--shadow-xs); font: 600 13px/1 var(--font-mono); color: var(--text); flex: none;
}
.login-mark .micro { color: var(--text-tertiary); }
.login h1 { font: 600 22px/28px var(--font-sans); letter-spacing: -.022em; }
.login p { color: var(--text-secondary); }
.login-panel { display: grid; gap: 12px; padding: 18px; border-radius: var(--radius-lg); background: var(--surface); box-shadow: var(--shadow-xs); }
.login-panel .btn { height: 36px; width: 100%; }
.login-err { color: var(--danger); font-size: 13px; }

/* ---------- Campos ---------- */
.field { display: grid; gap: 6px; }
.field > span { font-size: 12px; line-height: 16px; color: var(--text-secondary); font-weight: 500; }
.field small { font-size: 12px; line-height: 17px; color: var(--text-tertiary); }
.input, .textarea {
  width: 100%; border-radius: var(--radius-md); background: var(--bg); color: var(--text); border: 0;
  box-shadow: inset 0 0 0 1px var(--border-strong); padding: 7px 10px; font-size: 13px; line-height: 20px; outline: none;
}
.input { height: 32px; }
.textarea { resize: vertical; min-height: 64px; }
.input:focus, .textarea:focus { box-shadow: inset 0 0 0 1px var(--signal), 0 0 0 3px var(--accent-subtle); }
.input::placeholder, .textarea::placeholder { color: var(--text-tertiary); }
.check { display: flex; align-items: flex-start; gap: 10px; cursor: pointer; font-size: 13px; line-height: 20px; color: var(--text); }
.check input { appearance: none; margin: 2px 0 0; width: 16px; height: 16px; flex: none; border-radius: var(--radius-sm); background: var(--bg); box-shadow: inset 0 0 0 1px var(--border-strong); display: grid; place-items: center; cursor: pointer; }
.check input:checked { background: var(--accent); box-shadow: var(--edge-accent); }
.check input:checked::after { content: ""; width: 8px; height: 4px; margin-top: -2px; border-left: 2px solid var(--accent-fg); border-bottom: 2px solid var(--accent-fg); transform: rotate(-45deg); }
.check small { display: block; color: var(--text-tertiary); font-size: 12px; line-height: 17px; }

/* ============================================================
   SHELL: telemetria + trilho + conteúdo (+ abas no celular)
   ============================================================ */
.shell { height: 100vh; height: 100dvh; display: grid; grid-template-rows: var(--tele-h) minmax(0, 1fr); background: var(--bg); }

.tele { display: flex; align-items: stretch; background: var(--bg-subtle); box-shadow: inset 0 -1px 0 var(--border); color: var(--text-secondary); overflow: hidden; z-index: 5; }
.tl { display: flex; align-items: center; gap: 8px; padding: 0 14px; box-shadow: inset -1px 0 0 var(--border); white-space: nowrap; }
.tl b { font-weight: 500; color: var(--text); }
.tl.warn { color: var(--accent-text); }
.tl-robot { color: var(--text); }
.tl-robot:hover { background: var(--surface-hover); }
.tl-link:hover { background: var(--surface-hover); color: var(--text); }
.tl-end { margin-left: auto; display: flex; }
.tl-end .tl { box-shadow: inset 1px 0 0 var(--border); }

.body { display: flex; min-height: 0; }
.rail {
  position: relative; width: var(--rail-w); flex: none; display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 12px 0; background: var(--bg-subtle); box-shadow: inset -1px 0 0 var(--border); z-index: 4;
}
.rail .mark { margin-bottom: 12px; }
.ri { position: relative; width: 36px; height: 36px; display: grid; place-items: center; border-radius: var(--radius-md); color: var(--text-tertiary); }
.ri i { font-size: 18px; }
.ri:hover { background: var(--surface-hover); color: var(--text); }
.ri[aria-current="page"] { background: var(--surface-active); color: var(--accent-text); box-shadow: var(--edge); }
.cnt {
  position: absolute; top: 2px; right: 1px; min-width: 15px; height: 15px; padding: 0 3px; border-radius: 999px;
  background: var(--accent); color: var(--accent-fg); font: 600 10px/15px var(--font-mono); text-align: center; box-shadow: 0 0 0 2px var(--bg-subtle);
}
.rail-foot { margin-top: auto; display: flex; flex-direction: column; gap: 4px; }
.tip {
  position: fixed; display: flex; align-items: center; gap: 8px; height: 28px; padding: 0 5px 0 10px; border-radius: var(--radius-md);
  background: var(--surface-raised); box-shadow: var(--shadow-md); font: 500 12px/1 var(--font-sans); color: var(--text); white-space: nowrap; z-index: 50; pointer-events: none;
}
.tip span { display: flex; gap: 3px; }

.view { position: relative; flex: 1; min-width: 0; min-height: 0; display: flex; background: var(--bg); }
.tabbar { display: none; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 60; max-width: min(520px, calc(100vw - 32px));
  display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-radius: var(--radius-md);
  background: var(--surface-raised); box-shadow: var(--shadow-lg); color: var(--text); font-size: 13px; line-height: 18px;
  animation: toast-in var(--dur-2) var(--ease-out);
}
.toast::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--success); flex: none; }
.toast.error::before { background: var(--danger); }
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 6px); } }

/* ---------- Página genérica (Início, Empresa, Atividade) ---------- */
.page { position: relative; flex: 1; min-width: 0; overflow-y: auto; }
.page::before { content: ""; position: absolute; inset: 0 0 auto 0; height: 340px; background: var(--spotlight); pointer-events: none; }
.page-in { position: relative; max-width: 1120px; margin: 0 auto; padding: 22px 32px 48px; display: flex; flex-direction: column; gap: 24px; }
.ph-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; }
.ph-head h1 { font: 600 22px/28px var(--font-sans); letter-spacing: -.022em; }
.ph-head p { margin-top: 4px; color: var(--text-tertiary); }
.ph-head .find { width: 300px; }
.ph-acts { display: flex; gap: 8px; align-items: center; }
.sec-k { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; color: var(--text-tertiary); }
.sec-k.acc { color: var(--accent-text); }
.sec-k .st { font-size: 12px; }
.sec-k .r { margin-left: auto; color: var(--text-secondary); }
.sec-k a { margin-left: auto; display: inline-flex; align-items: center; gap: 4px; color: var(--text-secondary); }
.sec-k a:hover { color: var(--text); }
.empty-line { padding: 14px 16px; border-radius: var(--radius-md); background: var(--surface); box-shadow: var(--shadow-xs); color: var(--text-secondary); display: flex; align-items: center; gap: 10px; }
.empty-line i { color: var(--success); font-size: 16px; }

/* ---------- Início ---------- */
.wlist { display: grid; gap: 8px; }
.wrow {
  display: grid; grid-template-columns: 240px minmax(0, 1fr) auto; align-items: center; column-gap: 28px; padding: 13px 14px 13px 16px;
  background: var(--surface); border: 1px solid var(--border); border-left: 2px solid var(--signal); border-radius: 0 var(--radius-md) var(--radius-md) 0; box-shadow: var(--edge);
  cursor: pointer;
}
.wrow:hover { background: var(--surface-raised); }
.w-who { min-width: 0; }
.w-who b { display: block; font: 600 14px/20px var(--font-sans); letter-spacing: -.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.w-who .micro { color: var(--text-tertiary); }
.w-who .micro em { font-style: normal; color: var(--accent-text); }
.w-msg { font-size: 13px; line-height: 20px; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.w-why { display: flex; align-items: baseline; gap: 8px; margin-top: 2px; font-size: 13px; line-height: 20px; color: var(--text-secondary); min-width: 0; }
.w-why .micro { color: var(--text-tertiary); flex: none; }
.w-why span:last-child { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.hm-grid { display: grid; grid-template-columns: minmax(0, 540px) minmax(0, 1fr); border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.kpi { padding: 18px 32px 20px 0; box-shadow: inset -1px 0 0 var(--border); }
.hero-n { display: flex; align-items: flex-end; gap: 20px; margin-top: 4px; }
.hero-n .big { display: block; font: 500 72px/.9 var(--font-mono); letter-spacing: -.06em; color: var(--text); font-variant-numeric: tabular-nums; }
.hero-n .big small { font-size: 32px; letter-spacing: -.02em; color: var(--text-secondary); margin-left: 4px; }
.hero-n b { display: block; font: 600 15px/20px var(--font-sans); letter-spacing: -.01em; }
.hero-n div span { display: block; font-size: 13px; line-height: 18px; color: var(--text-secondary); margin-top: 2px; }
.strip { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); margin-top: 22px; border-top: 1px solid var(--border); }
.strip div { padding: 12px 12px 0 0; min-width: 0; }
.strip div + div { padding-left: 14px; box-shadow: inset 1px 0 0 var(--border); }
.strip dt { font-size: 12px; line-height: 16px; color: var(--text-secondary); white-space: nowrap; }
.strip dd { margin-top: 8px; font: 500 24px/28px var(--font-mono); letter-spacing: -.04em; color: var(--text); font-variant-numeric: tabular-nums; }
.strip dd small { font-size: 14px; letter-spacing: 0; color: var(--text-secondary); margin-left: 2px; }
.strip dd.acc { color: var(--accent-text); }

.chart { padding: 18px 0 16px 32px; min-width: 0; }
.plot { position: relative; height: 120px; margin-top: 22px; display: grid; grid-template-columns: repeat(24, 1fr); align-items: end; }
.plot .grid { position: absolute; left: 0; right: 0; height: 0; border-top: 1px dashed var(--border); }
.plot .g1 { bottom: 33.3%; } .plot .g2 { bottom: 66.6%; } .plot .g3 { bottom: 100%; }
.bar { position: relative; justify-self: center; width: 8px; height: calc(var(--v, 0) * 100%); min-height: 2px; border-radius: 2px 2px 0 0; background: var(--chart-1); }
.bar.zero { height: 2px; border-radius: 1px; background: var(--border-strong); }
.bar.later { height: 2px; border-radius: 1px; background: var(--border); }
.bar.now { background: var(--signal); }
.bar[data-l]::after { content: attr(data-l); position: absolute; bottom: calc(100% + 6px); left: 50%; transform: translateX(-50%); font: 500 11px/1 var(--font-mono); color: var(--text-secondary); white-space: nowrap; }
.bar.now[data-l]::after { color: var(--accent-text); }
.axis { display: grid; grid-template-columns: repeat(24, 1fr); margin-top: 8px; color: var(--text-tertiary); }
.axis span { text-align: center; white-space: nowrap; }
.axis .now { color: var(--accent-text); }

.rrow { display: grid; grid-template-columns: 16px minmax(0, 200px) minmax(0, 1fr) 72px; align-items: center; column-gap: 12px; height: 34px; box-shadow: inset 0 -1px 0 var(--border); font-size: 13px; cursor: pointer; }
.rrow:first-of-type { box-shadow: inset 0 1px 0 var(--border), inset 0 -1px 0 var(--border); }
.rrow:hover { background: var(--surface-hover); }
.rrow b { font-weight: 500; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rrow span { min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--text-secondary); }
.rrow span em { font-style: normal; color: var(--text-tertiary); }
.rrow time { text-align: right; color: var(--text-tertiary); }

.sys { display: flex; align-items: center; gap: 14px; min-height: 52px; padding: 8px 8px 8px 16px; border-radius: var(--radius-md); background: var(--surface); border: 1px solid var(--border); box-shadow: var(--edge); flex-wrap: wrap; }
.sys .ok { font-size: 16px; color: var(--success); }
.sys .ok.bad { color: var(--signal); }
.sys > b { font: 600 13px/1 var(--font-sans); }
.sys .micro { color: var(--text-secondary); }
.ticks { display: flex; gap: 3px; }
.ticks i { width: 12px; height: 4px; border-radius: 1px; background: var(--success); }
.ticks i.no { background: var(--border-strong); }
.sys p { font-size: 13px; color: var(--text-secondary); }
.sys .sep { width: 1px; height: 20px; background: var(--border); }
.sys a { color: var(--text); text-decoration: underline; text-decoration-color: var(--border-strong); text-underline-offset: 3px; }
.sys .btn { margin-left: auto; }
.sys .btn .ph-caret-down { transition: transform var(--dur-2) var(--ease-out); }
.sys .btn[aria-expanded="true"] .ph-caret-down { transform: rotate(180deg); }

/* Detalhes do sistema (checklist, webhook, .env) */
.sysd { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 380px); gap: 24px; }
.steps { border-top: 1px solid var(--border); }
.step { display: grid; grid-template-columns: 20px minmax(0, 1fr) auto; column-gap: 12px; align-items: center; padding: 10px 0; box-shadow: inset 0 -1px 0 var(--border); }
.step > i { font-size: 16px; color: var(--success); }
.step.todo > i { color: var(--signal); }
.step b { display: block; font-weight: 500; color: var(--text); }
.step p { font-size: 12px; line-height: 17px; color: var(--text-secondary); overflow-wrap: anywhere; }
.panel { padding: 14px 16px; border-radius: var(--radius-md); background: var(--surface); border: 1px solid var(--border); box-shadow: var(--edge); display: grid; gap: 10px; align-content: start; }
.panel h3 { color: var(--text-tertiary); }
.panel p { font-size: 12px; line-height: 18px; color: var(--text-secondary); }
.panel code, .copy code { font: 500 12px/18px var(--font-mono); color: var(--text); overflow-wrap: anywhere; }
.copy { display: flex; align-items: center; gap: 8px; padding: 8px 8px 8px 10px; border-radius: var(--radius-md); background: var(--bg); box-shadow: inset 0 0 0 1px var(--border); }
.copy code { flex: 1; min-width: 0; }
.envl div { display: grid; grid-template-columns: 14px minmax(0, 1fr); column-gap: 8px; padding: 7px 0; box-shadow: inset 0 -1px 0 var(--border); }
.envl i { font-size: 13px; margin-top: 2px; color: var(--success); }
.envl i.no { color: var(--danger); }
.envl dt { font: 500 12px/17px var(--font-mono); color: var(--text); }
.envl dd { grid-column: 2; font-size: 12px; line-height: 17px; color: var(--text-tertiary); overflow-wrap: anywhere; }

/* ============================================================
   CONVERSAS: lista + conversa + contexto
   ============================================================ */
.clist { width: 344px; flex: none; display: flex; flex-direction: column; background: var(--bg-subtle); box-shadow: inset -1px 0 0 var(--border); min-height: 0; }
.cl-head { height: 52px; flex: none; display: flex; align-items: center; justify-content: space-between; padding: 0 10px 0 16px; }
.cl-head h1 { display: flex; align-items: baseline; gap: 8px; font: 600 15px/1 var(--font-sans); letter-spacing: -.015em; }
.cl-head h1 .micro { color: var(--text-tertiary); }
.clist .find { margin: 0 12px; flex: none; }
.seg { display: flex; gap: 2px; margin: 10px 12px 6px; padding: 2px; border-radius: var(--radius-md); background: var(--bg); box-shadow: inset 0 0 0 1px var(--border); flex: none; }
.seg button { flex: auto; height: 26px; display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 0 8px; border-radius: var(--radius-sm); font: 500 12px/1 var(--font-sans); color: var(--text-secondary); white-space: nowrap; }
.seg button:hover { color: var(--text); }
.seg button[aria-selected="true"] { background: var(--surface-raised); color: var(--text); box-shadow: var(--shadow-xs); }
.seg .n { font: 500 11px/1 var(--font-mono); color: var(--text-tertiary); }
.seg .n.acc { color: var(--accent-text); }
.cl-items { flex: 1; min-height: 0; overflow-y: auto; padding: 4px 8px 12px; }
.ci { width: 100%; text-align: left; display: grid; grid-template-columns: 16px minmax(0, 1fr); column-gap: 10px; padding: 9px 10px 10px 8px; border-radius: var(--radius-md); }
.ci + .ci { margin-top: 1px; }
.ci:hover { background: var(--surface-hover); }
.ci.is-sel { background: var(--surface-active); box-shadow: var(--edge); }
.ci .st { margin-top: 1px; }
.ci > div { min-width: 0; }
.ci-top { display: flex; align-items: baseline; gap: 8px; }
.ci-top b { font-weight: 500; font-size: 13px; line-height: 18px; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ci-top time { margin-left: auto; flex: none; color: var(--text-tertiary); }
.ci-msg { display: flex; align-items: center; gap: 8px; margin-top: 2px; font-size: 13px; line-height: 18px; color: var(--text-secondary); }
.ci-msg span { min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ci-msg em { font-style: normal; color: var(--text-tertiary); }
.new { flex: none; margin-left: auto; height: 16px; padding: 0 6px; border-radius: 999px; background: var(--accent-subtle); color: var(--accent-text); font: 600 10px/16px var(--font-mono); letter-spacing: .06em; text-transform: uppercase; }
.ci-why { margin-top: 7px; padding-left: 9px; border-left: 2px solid var(--signal); font-size: 12px; line-height: 16px; color: var(--text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cl-empty { padding: 28px 16px; text-align: center; color: var(--text-secondary); display: grid; gap: 6px; justify-items: center; }
.cl-empty i { font-size: 20px; color: var(--text-tertiary); }

.thread { position: relative; flex: 1; min-width: 0; display: flex; flex-direction: column; background: var(--bg); min-height: 0; }
.thread::before { content: ""; position: absolute; inset: 0 0 auto 0; height: 340px; background: var(--spotlight); pointer-events: none; }
.th-head { position: relative; height: 56px; flex: none; display: flex; align-items: center; gap: 12px; padding: 0 12px 0 20px; box-shadow: inset 0 -1px 0 var(--border); }
.th-head > div:not(.th-acts) { min-width: 0; }
.th-head h2 { font: 600 14px/18px var(--font-sans); letter-spacing: -.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.th-head p { color: var(--text-tertiary); }
.th-back { display: none; }
.th-acts { margin-left: auto; display: flex; align-items: center; gap: 8px; flex: none; }
.state { display: inline-flex; align-items: center; gap: 6px; color: var(--text-secondary); margin-right: 4px; }
.state.wait { color: var(--accent-text); }
.state .st { font-size: 12px; }
.th-body { position: relative; flex: 1; min-height: 0; overflow-y: auto; padding: 16px 24px 18px; display: flex; flex-direction: column; gap: 14px; }
.th-body > :first-child { margin-top: auto; }
.day { display: flex; align-items: center; gap: 12px; color: var(--text-tertiary); }
.day::before, .day::after { content: ""; flex: 1; height: 1px; background: var(--border); }
.msg { max-width: min(560px, 78%); display: flex; flex-direction: column; gap: 5px; }
.msg .meta { color: var(--text-tertiary); }
.msg .meta .fail { color: var(--danger); }
.msg.in { align-self: flex-start; }
.msg.out { align-self: flex-end; align-items: flex-end; }
.bub { padding: 8px 12px; border-radius: var(--radius-lg); font-size: 13px; line-height: 20px; white-space: pre-wrap; overflow-wrap: anywhere; }
.msg.in .bub { background: var(--surface-raised); box-shadow: var(--shadow-xs); color: var(--text); border-top-left-radius: var(--radius-sm); }
.msg.out .bub { box-shadow: inset 0 0 0 1px var(--border-strong); color: var(--text-secondary); border-top-right-radius: var(--radius-sm); }
.msg.you .bub { color: var(--text); background: var(--surface); }
.msg.failed .bub { box-shadow: inset 0 0 0 1px var(--danger); }
.sysline { align-self: center; max-width: 80%; text-align: center; color: var(--text-tertiary); }

/* Assinatura: a passagem como alerta de cabine */
.alert {
  position: relative; display: grid; grid-template-columns: minmax(0, 1fr) auto; column-gap: 16px; padding: 11px 14px 12px;
  background: var(--surface); border: 1px solid var(--border); border-left: 2px solid var(--signal); border-radius: 0 var(--radius-md) var(--radius-md) 0; box-shadow: var(--edge);
}
.alert.past { border-left-color: var(--border-strong); }
.alert.past .al-k { color: var(--text-tertiary); }
.al-k { display: flex; align-items: center; gap: 6px; color: var(--accent-text); }
.al-k .st { font-size: 12px; }
.al-time { color: var(--text-tertiary); text-align: right; }
.al-t { grid-column: 1 / -1; margin-top: 5px; font: 600 14px/20px var(--font-sans); letter-spacing: -.01em; color: var(--text); }
.al-d { grid-column: 1 / -1; margin-top: 2px; font-size: 12px; line-height: 18px; color: var(--text-secondary); }
.alert .btn { grid-column: 1 / -1; justify-self: start; margin-top: 10px; }

.composer { position: relative; flex: none; padding: 0 20px 16px; }
.cp-box { border-radius: var(--radius-lg); background: var(--surface); box-shadow: var(--shadow-sm); }
.cp-box:focus-within { box-shadow: 0 0 0 1px var(--border-strong), var(--edge), 0 0 0 3px var(--accent-subtle); }
.cp-in { display: block; width: 100%; height: 58px; max-height: 180px; padding: 11px 14px; border: 0; background: none; resize: none; outline: none; font-size: 13px; line-height: 20px; color: var(--text); }
.cp-in::placeholder { color: var(--text-tertiary); }
.cp-bar { display: flex; align-items: center; gap: 8px; padding: 8px 8px 8px 14px; box-shadow: inset 0 1px 0 var(--border); }
.cp-bar .micro { color: var(--text-tertiary); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cp-bar .btns { margin-left: auto; display: flex; gap: 8px; flex: none; }

.th-empty { flex: 1; display: grid; place-content: center; justify-items: center; gap: 8px; padding: 24px; text-align: center; color: var(--text-secondary);
  background: radial-gradient(var(--border) 1px, transparent 1px) 0 0 / 16px 16px; }
.th-empty i { font-size: 22px; color: var(--text-tertiary); }
.th-empty .micro { color: var(--text-tertiary); }

.ctx { width: 264px; flex: none; display: flex; flex-direction: column; gap: 22px; padding: 18px 16px; background: var(--bg-subtle); box-shadow: inset 1px 0 0 var(--border); overflow-y: auto; }
.ctx h3 { color: var(--text-tertiary); margin-bottom: 6px; }
.props div { display: grid; grid-template-columns: 92px minmax(0, 1fr); gap: 8px; padding: 7px 0; box-shadow: inset 0 -1px 0 var(--border); }
.props dt { font-size: 12px; line-height: 18px; color: var(--text-tertiary); }
.props dd { font-size: 13px; line-height: 18px; color: var(--text); overflow-wrap: anywhere; }
.props dd.mono-n { font-size: 12px; }
.keys li { display: flex; align-items: center; gap: 6px; padding: 4px 0; font-size: 12px; line-height: 18px; color: var(--text-secondary); }
.keys li kbd:last-of-type { margin-right: 4px; }

/* ---------- Simulador ---------- */
.sim-note { align-self: center; max-width: 90%; display: flex; align-items: center; gap: 8px; padding: 6px 10px; border-radius: var(--radius-md); background: var(--surface); box-shadow: var(--shadow-xs); color: var(--text-secondary); font-size: 12px; line-height: 18px; }
.sim-note.hand { color: var(--accent-text); box-shadow: inset 0 0 0 1px var(--accent-subtle); }
.typing { display: inline-flex; gap: 3px; }
.typing i { width: 4px; height: 4px; border-radius: 50%; background: var(--text-tertiary); animation: blink 1.2s infinite var(--ease-in-out); }
.typing i:nth-child(2) { animation-delay: .15s; } .typing i:nth-child(3) { animation-delay: .3s; }
@keyframes blink { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }

/* ---------- Empresa ---------- */
.form { display: grid; gap: 28px; }
.fsec { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 24px; padding-top: 18px; border-top: 1px solid var(--border); }
.fsec > header h2 { font: 600 14px/20px var(--font-sans); letter-spacing: -.01em; }
.fsec > header p { margin-top: 4px; font-size: 12px; line-height: 18px; color: var(--text-tertiary); }
.fsec > header .micro { color: var(--text-tertiary); display: block; margin-bottom: 6px; }
.fgrid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.fgrid .full { grid-column: 1 / -1; }
.prompt { margin: 10px 0 0; padding: 12px 14px; border-radius: var(--radius-md); background: var(--bg); box-shadow: inset 0 0 0 1px var(--border); font: 400 12px/19px var(--font-mono); color: var(--text-secondary); white-space: pre-wrap; max-height: 420px; overflow: auto; }
details summary { cursor: pointer; color: var(--text-secondary); font-size: 13px; list-style: none; display: inline-flex; align-items: center; gap: 6px; }
details summary::-webkit-details-marker { display: none; }
details summary:hover { color: var(--text); }
details[open] summary .ph-caret-right { transform: rotate(90deg); }
.savebar { position: sticky; bottom: 0; z-index: 3; display: flex; align-items: center; gap: 8px; margin: 0 -32px -48px; padding: 12px 32px; background: var(--glass-bg-bar); box-shadow: inset 0 1px 0 var(--border);
  -webkit-backdrop-filter: saturate(1.4) blur(16px); backdrop-filter: saturate(1.4) blur(16px); }
.savebar .micro { color: var(--text-tertiary); }
.savebar .btns { margin-left: auto; display: flex; gap: 8px; }

/* ---------- Atividade ---------- */
.ev { display: grid; grid-template-columns: 16px 132px minmax(0, 1fr); column-gap: 12px; align-items: baseline; padding: 9px 4px; box-shadow: inset 0 -1px 0 var(--border); font-size: 13px; line-height: 20px; }
.ev:first-child { box-shadow: inset 0 1px 0 var(--border), inset 0 -1px 0 var(--border); }
.ev i { font-size: 12px; align-self: center; }
.ev.info i { color: var(--text-tertiary); }
.ev.warn i { color: var(--signal); }
.ev.error i { color: var(--danger); }
.ev time { color: var(--text-tertiary); }
.ev span { color: var(--text-secondary); overflow-wrap: anywhere; }
.ev.error span { color: var(--text); }
.ev-filter { display: flex; gap: 2px; padding: 2px; border-radius: var(--radius-md); background: var(--bg); box-shadow: inset 0 0 0 1px var(--border); }
.ev-filter button { height: 26px; padding: 0 10px; border-radius: var(--radius-sm); font-size: 12px; color: var(--text-secondary); }
.ev-filter button[aria-selected="true"] { background: var(--surface-raised); color: var(--text); box-shadow: var(--shadow-xs); }

/* ---------- Pequenas peças ---------- */
.only-mob { display: none !important; }
.loading { color: var(--text-tertiary); }
.acc-text { color: var(--accent-text) !important; }
.sysd-side { display: grid; gap: 12px; align-content: start; }
.sysline { font-size: 12px; line-height: 18px; }
.sysline .micro { color: var(--text-secondary); }
.mob-state { display: none; }
.mob-state.wait { color: var(--accent-text); }
.alert .al-mob { display: none; }
.th-head .av i { font-size: 15px; color: var(--text-secondary); }

/* ============================================================
   RESPONSIVO
   ============================================================ */
@media (max-width: 1199px) {
  .ctx { display: none; }
}
@media (max-width: 1023px) {
  .tele .tl-opt { display: none; }
  .hm-grid { grid-template-columns: minmax(0, 1fr); }
  .kpi { padding-right: 0; box-shadow: inset 0 -1px 0 var(--border); }
  .chart { padding-left: 0; }
  .sysd { grid-template-columns: minmax(0, 1fr); }
  .wrow { grid-template-columns: minmax(0, 1fr) auto; row-gap: 8px; }
  .wrow > div:nth-child(2) { grid-column: 1 / -1; grid-row: 2; }
  .wrow .w-act { grid-column: 2; grid-row: 1; }
}

/* Celular: abas embaixo, nada escondido atrás de menu */
@media (max-width: 760px) {
  :root { --text-body: 15px; --leading-body: 22px; }
  .shell { grid-template-rows: 36px minmax(0, 1fr) calc(var(--nav-h) + env(safe-area-inset-bottom)); }
  .rail { display: none; }
  .tele { padding: 0 4px; }
  .tele .tl { padding: 0 12px; }
  .tele .tl-desk { display: none; }
  .tabbar {
    display: grid; grid-template-columns: repeat(5, 1fr); padding: 0 4px env(safe-area-inset-bottom);
    background: var(--glass-bg-bar); -webkit-backdrop-filter: saturate(1.4) blur(20px); backdrop-filter: saturate(1.4) blur(20px);
    box-shadow: inset 0 1px 0 var(--border); z-index: 20;
  }
  @supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) { .tabbar { background: var(--surface); } }
  .tab { position: relative; display: flex; flex-direction: column; align-items: center; gap: 3px; padding-top: 9px; font: 500 11px/14px var(--font-sans); color: var(--text-tertiary); }
  .tab i { font-size: 22px; line-height: 1; }
  .tab[aria-current="page"] { color: var(--text); font-weight: 600; }
  .tab[aria-current="page"] i { color: var(--accent-text); }
  .tab .cnt { top: 5px; right: auto; left: calc(50% + 6px); min-width: 16px; height: 16px; line-height: 16px; }

  .page-in { padding: 16px var(--gutter) 32px; gap: 20px; }
  .ph-head { flex-wrap: wrap; align-items: flex-start; }
  .ph-head .find { width: 100%; }
  .btn { height: var(--h-sm); font-size: 14px; }
  .input { height: var(--h-md); font-size: 16px; }
  .textarea { font-size: 16px; line-height: 23px; }
  .find { height: var(--h-sm); }
  .find input { font-size: 16px; }
  .find kbd { display: none; }

  /* Conversas: lista OU conversa, em tela cheia */
  .clist { width: 100%; box-shadow: none; }
  .view.has-open .clist { display: none; }
  .view:not(.has-open) .thread { display: none; }
  .ci { padding: 11px 10px 12px 8px; }
  .ci-top b, .ci-msg { font-size: 15px; line-height: 21px; }
  .ci-why { font-size: 13px; line-height: 18px; }
  .seg button { height: 32px; font-size: 13px; }
  .th-head { height: 64px; padding: 0 4px; gap: 10px; }
  .th-back { display: grid; width: var(--h-md); height: var(--h-md); place-items: center; color: var(--text-secondary); flex: none; }
  .th-back i { font-size: 22px; }
  .th-head h2 { font-size: 16px; line-height: 20px; }
  .th-head .av { width: 36px; height: 36px; }
  .th-head .phone-n { display: none; }
  .mob-state { display: inline; }
  .alert .al-mob { display: inline-flex; }
  .only-mob { display: inline-flex !important; }
  .th-acts .state { display: none; }
  .th-body { padding: 12px var(--gutter) 14px; gap: 12px; }
  .msg { max-width: 86%; }
  .bub { font-size: 15px; line-height: 22px; padding: 9px 12px; }
  .al-t { font-size: 15px; line-height: 22px; }
  .al-d { font-size: 13px; line-height: 19px; }
  .composer { padding: 8px 12px; box-shadow: inset 0 1px 0 var(--border); }
  .cp-box { display: flex; align-items: flex-end; gap: 8px; background: none; box-shadow: none; }
  .cp-box:focus-within { box-shadow: none; }
  .cp-in { flex: 1; height: var(--h-md); min-height: var(--h-md); padding: 10px 14px; border-radius: var(--radius-lg); background: var(--surface); box-shadow: var(--shadow-xs); font-size: 16px; line-height: 23px; }
  .cp-bar { padding: 0; box-shadow: none; }
  .cp-bar .micro, .cp-bar .btn-secondary, .btn kbd, .cp-bar .lbl { display: none; }
  .cp-bar .btn-primary { width: var(--h-md); height: var(--h-md); padding: 0; border-radius: var(--radius-lg); }
  .cp-bar .btn-primary i { font-size: 20px; }

  .hero-n .big { font-size: 56px; }
  .strip { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .strip div:nth-child(3) { padding-left: 0; box-shadow: none; }
  .strip dd { font-size: 22px; }
  .plot { height: 96px; }
  .axis span:not(.k) { visibility: hidden; }
  .rrow { grid-template-columns: 16px minmax(0, 1fr) 56px; height: auto; padding: 8px 0; }
  .rrow span { display: none; }
  .sys { gap: 10px; }
  .sys .sep, .sys .ticks { display: none; }
  .sys .btn { margin-left: 0; }
  .fsec { grid-template-columns: minmax(0, 1fr); gap: 12px; }
  .fgrid { grid-template-columns: minmax(0, 1fr); }
  .savebar { margin: 0 calc(var(--gutter) * -1) -32px; padding: 10px var(--gutter); }
  .ev { grid-template-columns: 16px minmax(0, 1fr); }
  .ev time { grid-column: 2; }
  .ev span { grid-column: 2; }
  .toast { bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 12px); }
}

/* ---------- Dashboard 14 dias ---------- */
.dash { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 320px); gap: 32px; padding-bottom: 20px; border-bottom: 1px solid var(--border); }
.area { width: 100%; height: 150px; display: block; margin-top: 8px; }
.area .gl { stroke: var(--border); stroke-dasharray: 3 4; }
.area .ln { fill: none; stroke: var(--signal); stroke-width: 2; vector-effect: non-scaling-stroke; filter: drop-shadow(0 0 6px rgba(37, 211, 102, .6)); }
.hbars { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 4px; align-items: end; height: 28px; margin-top: 10px; }
.hbars i { height: calc(var(--v, 0) * 100%); min-height: 2px; border-radius: 2px; background: var(--chart-1); }
.axis2 { display: flex; justify-content: space-between; margin-top: 6px; color: var(--text-tertiary); }
.rs { padding: 7px 0; }
.rs-t { display: flex; justify-content: space-between; gap: 8px; font-size: 13px; color: var(--text-secondary); }
.rs-t b { color: var(--text); font-weight: 500; }
.rs-b { height: 4px; margin-top: 6px; border-radius: 2px; background: var(--surface-hover); overflow: hidden; }
.rs-b i { display: block; height: 100%; width: calc(var(--v, 0) * 100%); background: var(--signal); border-radius: 2px; box-shadow: 0 0 8px rgba(37, 211, 102, .5); }
@media (max-width: 1023px) { .dash { grid-template-columns: minmax(0, 1fr); } }
