/* pro-financeiro — visual padrão da PRO Franchising (o mesmo do gen-comercial, do geni e da fran:
   tema padrão do Chakra + verdes da PRO). Só modo claro. Cor só por token do :root.
   Base: gen-comercial/apps/dash/public/styles.css */
:root {
  --bg: #fafafa;
  --surface: #ffffff;
  --text: #18181b;
  --text-2: #3f3f46;
  --muted: #71717a;
  --border: #e4e4e7;
  --brand: #00bfa0;
  --brand-strong: #005645;
  --brand-soft: #00e5b926;
  --code-bg: #f4f4f5;
  --placeholder: #a1a1aa;
  --on-brand: #ffffff;
  --ok: #00a868;
  --ok-bg: #e6f6ef;
  --ok-bd: #a7e3c6;
  --ok-text: #00794b;
  --warn: #f97316;
  --warn-bg: #fff7ed;
  --warn-bd: #fdba74;
  --warn-text: #c2410c;
  --err: #dc2626;
  --err-bg: #fef2f2;
  --err-bd: #fecaca;
  --err-text: #b91c1c;
  /* Cores da marca do Google, só no "G" do botão de login */
  --g-azul: #1976d2; --g-verde: #4caf50; --g-amarelo: #ffc107; --g-vermelho: #ff3d00;
  --shadow: 0 2px 4px rgba(24, 24, 27, 0.08), 0 0 1px rgba(24, 24, 27, 0.3);
  --shadow-lg: 0 8px 24px rgba(24, 24, 27, 0.12);
  --overlay: rgba(24, 24, 27, 0.45);
  /* Gráficos (paleta validada no gen-comercial). A cor segue a série, nunca a posição:
     c1 Genesis, c2 Mais1 Café, c3 Sniper, c4 Sem produto. */
  --c1: #00967d; --c2: #eb6834; --c3: #6250d6; --c4: #eda100; --c5: #2a78d6; --c6: #e87ba4;
  --o1: #40c4a8; --o2: #00a88c; --o3: #008e76; --o4: #007461; --o5: #005a4b; --o6: #004037;
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  font: 15px/1.5 Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}
a { color: var(--brand-strong); text-decoration: none; }
a:hover { text-decoration: underline; }
code { background: var(--code-bg); padding: 1px 5px; border-radius: 4px; font-size: 0.92em; overflow-wrap: anywhere; }
.ic { width: 1em; height: 1em; flex: none; }
[hidden], .hidden { display: none !important; }

/* ── Login ───────────────────────────────────────────────────────────────── */
#login { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 16px; }
#login .login-card {
  width: min(380px, 100%); background: var(--surface); border: 1px solid var(--border);
  border-radius: 16px; box-shadow: var(--shadow); padding: 28px 24px; text-align: center;
}
#login img { width: 96px; height: 96px; display: block; margin: 0 auto 14px; }
#login h1 { font-size: 22px; margin: 0 0 4px; }
#login .sub { color: var(--muted); margin: 0 0 20px; font-size: 14px; }
#login .btn-google {
  display: flex; align-items: center; justify-content: center; gap: 10px; padding: 11px 16px; border-radius: 8px;
  border: 1px solid var(--border); color: var(--text); text-decoration: none; font-weight: 600; background: var(--surface);
}
#login .btn-google:hover { border-color: var(--brand); text-decoration: none; }
#login .login-erro { margin: 16px 0 0; font-size: 13px; color: var(--err); }

/* ── Casca: lateral + coluna principal ───────────────────────────────────── */
#app.app { display: grid; grid-template-columns: 248px 1fr; height: 100vh; height: 100dvh; overflow: hidden; }
.sidebar { background: var(--surface); border-right: 1px solid var(--border); display: flex; flex-direction: column; min-height: 0; }
.sidebar .top { padding: 16px 16px 12px; display: flex; flex-direction: column; gap: 14px; }
.sidebar .logo-linha { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.sidebar .logo { height: 30px; width: auto; display: block; }
.sidebar .produto-nome { font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }
.btn-top.btn-menu, .btn-top.nav-fechar, .nav-fundo { display: none; }
#tools-nav { flex: 1; overflow-y: auto; padding: 0 10px 14px; }
#tools-nav .grp {
  font-size: 11px; font-weight: 700; color: var(--muted); text-transform: uppercase;
  letter-spacing: 0.06em; padding: 16px 10px 6px;
}
#tools-nav .grp:first-child { padding-top: 6px; }
#tools-nav .it {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 10px; border: 0;
  border-radius: 8px; background: none; color: var(--text); font: inherit; font-size: 13.5px;
  text-align: left; cursor: pointer; text-decoration: none;
}
#tools-nav .it + .it { margin-top: 3px; }
#tools-nav .it .rot { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#tools-nav .it:hover { background: var(--code-bg); text-decoration: none; }
#tools-nav .it .ic { width: 17px; height: 17px; color: var(--muted); }
#tools-nav .it.on { background: var(--brand-soft); color: var(--brand-strong); font-weight: 600; }
#tools-nav .it.on .ic { color: var(--brand-strong); }

.main-col { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.topbar {
  display: flex; align-items: center; gap: 12px; padding: 10px 24px; min-height: 58px;
  border-bottom: 1px solid var(--border); background: var(--surface);
}
.topbar .title { line-height: 1.3; min-width: 0; }
.topbar .crumb { font-size: 11px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }
.topbar .name { font-size: 15px; font-weight: 700; }
.topbar .espaco { flex: 1; }
#current-user { color: var(--muted); font-size: 12.5px; overflow-wrap: anywhere; }
.btn-top {
  display: inline-flex; align-items: center; gap: 6px; font: inherit; font-size: 13px; font-weight: 600;
  color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
  padding: 6px 12px; cursor: pointer; white-space: nowrap;
}
.btn-top:hover { border-color: var(--muted); }
.btn-top:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-top .ic { width: 15px; height: 15px; }
main#content { flex: 1; overflow-y: auto; padding: 24px; }
main#content > section { max-width: 1320px; }
main#content > section > * + * { margin-top: 16px; }

/* Selo do modo de envio no topo */
.modo-badge {
  display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 700; padding: 3px 10px;
  border-radius: 999px; border: 1px solid var(--border); background: var(--code-bg); color: var(--text-2); white-space: nowrap;
}
.modo-badge.sim { background: var(--warn-bg); color: var(--warn-text); border-color: var(--warn-bd); }
.modo-badge.real { background: var(--err-bg); color: var(--err-text); border-color: var(--err-bd); }
.modo-badge .ic { width: 13px; height: 13px; }

/* ── Componentes ─────────────────────────────────────────────────────────── */
.intro, .note { color: var(--muted); font-size: 13.5px; margin: 0; }
.panel, .card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px;
  box-shadow: var(--shadow); padding: 18px 20px; min-width: 0;
}
.panel > :first-child, .card > :first-child { margin-top: 0; }
.panel > :last-child, .card > :last-child { margin-bottom: 0; }
.panel-h { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 6px 10px; margin-bottom: 12px; }
.panel-h h2, .panel-h h3 { margin: 0; }
.panel-h .acoes-h { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px 16px; align-items: end; }
.span-all { grid-column: 1 / -1; }
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; font-size: 13px; font-weight: 600; color: var(--text); }
.hint { font-size: 12px; font-weight: 400; color: var(--muted); }
.check { display: inline-flex; flex-direction: row; align-items: center; gap: 8px; font-size: 13.5px; font-weight: 500; cursor: pointer; }
.actions { display: flex; flex-direction: row; align-items: center; flex-wrap: wrap; gap: 8px; margin-top: 14px; }

/* Selos */
.tag {
  display: inline-block; font-size: 11.5px; font-weight: 600; line-height: 1.5; padding: 1px 8px;
  border-radius: 999px; border: 1px solid var(--border); background: var(--code-bg); color: var(--text-2); white-space: nowrap;
}
.tag.ok { background: var(--ok-bg); color: var(--ok-text); border-color: var(--ok-bd); }
.tag.warn { background: var(--warn-bg); color: var(--warn-text); border-color: var(--warn-bd); }
.tag.err { background: var(--err-bg); color: var(--err-text); border-color: var(--err-bd); }
.tag.new { background: var(--brand-soft); color: var(--brand-strong); border-color: transparent; }
.tags { display: inline-flex; gap: 4px; flex-wrap: wrap; }

/* Avisos */
.notice {
  margin: 0; padding: 10px 14px; border: 1px solid var(--border); border-radius: 10px;
  font-size: 13.5px; background: var(--code-bg); color: var(--text);
}
.notice + .notice { margin-top: 8px; }
.notice.ok { background: var(--ok-bg); border-color: var(--ok-bd); color: var(--ok-text); }
.notice.warn { background: var(--warn-bg); border-color: var(--warn-bd); color: var(--warn-text); }
.notice.err { background: var(--err-bg); border-color: var(--err-bd); color: var(--err-text); }
.notice a { color: inherit; text-decoration: underline; font-weight: 600; }
.notice b { font-weight: 700; }
.banner-modo { font-size: 14px; padding: 12px 16px; }

/* ── Elementos (peso zero: qualquer classe passa por cima). .ui = conteúdo, gaveta e diálogo ── */
:where(.ui) h1 { font-size: 20px; margin: 0 0 14px; letter-spacing: -0.01em; }
:where(.ui) h2 { font-size: 15px; font-weight: 700; color: var(--text); margin: 24px 0 10px; }
:where(.ui) h3 { font-size: 14px; font-weight: 700; margin: 16px 0 8px; }
:where(.ui) label { font-size: 13px; color: var(--text-2); }
:where(.ui) input:where(:not([type="checkbox"], [type="radio"], [type="file"], [type="range"], [type="color"])),
:where(.ui) select,
:where(.ui) textarea {
  font: inherit; font-size: 14px; height: 38px; max-width: 100%; padding: 0 11px; color: var(--text);
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px; outline: none;
}
:where(.ui) textarea { height: auto; min-height: 76px; padding: 8px 11px; resize: vertical; line-height: 1.45; }
:where(.ui) :where(input, select, textarea):where(:focus) { outline: 2px solid var(--brand); outline-offset: -1px; }
:where(.ui) :where(input, textarea)::placeholder { color: var(--placeholder); }
:where(.ui) :where(input, select, textarea):where(:disabled) { background: var(--code-bg); color: var(--muted); cursor: not-allowed; }
:where(.ui) input:where([type="checkbox"], [type="radio"]) { width: 16px; height: 16px; margin: 0; flex: none; accent-color: var(--brand-strong); cursor: pointer; }
:where(.ui) button {
  font: inherit; font-size: 13.5px; font-weight: 600; line-height: 1.2; min-height: 36px; padding: 6px 16px;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; color: var(--text);
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px; cursor: pointer;
}
:where(.ui) button .ic { width: 15px; height: 15px; }
:where(.ui) button:where(:hover:not(:disabled)) { border-color: var(--muted); }
:where(.ui) button:where(.primary) { color: var(--on-brand); background: var(--brand-strong); border-color: var(--brand-strong); }
:where(.ui) button:where(.primary):where(:hover:not(:disabled)) { background: var(--brand); border-color: var(--brand); }
:where(.ui) button:where(.danger) { color: var(--on-brand); background: var(--err); border-color: var(--err); }
:where(.ui) button:where(.danger):where(:hover:not(:disabled)) { background: var(--err-text); border-color: var(--err-text); }
:where(.ui) button:where(.small) { min-height: 28px; padding: 3px 10px; font-size: 12.5px; }
:where(.ui) button:where(.link) { min-height: 0; padding: 0; border: 0; background: none; color: var(--brand-strong); font-weight: 600; }
:where(.ui) button:where(.link):where(:hover:not(:disabled)) { text-decoration: underline; }
:where(.ui) button:where(:focus-visible) { outline: 2px solid var(--brand); outline-offset: 2px; }
:where(.ui) button:where(:disabled) { opacity: 0.45; cursor: not-allowed; }
:where(.ui) table { width: 100%; border-collapse: collapse; font-size: 13px; }
:where(.ui) th {
  text-align: left; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em;
  color: var(--muted); background: var(--code-bg); padding: 8px 10px; border-bottom: 1px solid var(--border); white-space: nowrap;
}
:where(.ui) td { padding: 8px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
:where(.ui) tr:hover td { background: var(--bg); }
:where(.ui) details > summary { cursor: pointer; color: var(--brand-strong); font-size: 12.5px; font-weight: 600; }
:where(.ui) pre {
  white-space: pre-wrap; overflow-wrap: anywhere; font: 12.5px/1.5 ui-monospace, Consolas, monospace;
  background: var(--code-bg); border-radius: 8px; padding: 10px 12px; margin: 6px 0 0;
}

.meta { font-size: 12.5px; color: var(--muted); }
.sub { display: block; font-size: 12px; color: var(--muted); font-weight: 400; }
.empty-state { color: var(--muted); font-size: 14px; padding: 8px 0; }
.muted { color: var(--muted); }
.crit { color: var(--err-text); }
.good { color: var(--ok-text); }
td.num, th.num, .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
td.nowrap { white-space: nowrap; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 1000px) { .grid2 { grid-template-columns: 1fr; } }
.scroll { overflow: auto; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); }
.scroll table { min-width: 720px; }
.scroll th { position: sticky; top: 0; z-index: 1; }
tr.clicavel { cursor: pointer; }
.trunc { max-width: 360px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Cartões de número */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 12px; }
.cards .card { padding: 14px 16px; }
.kl { font-size: 12px; color: var(--muted); font-weight: 600; }
.kv { font-size: 26px; font-weight: 700; line-height: 1.2; margin: 4px 0 2px; font-variant-numeric: tabular-nums; }
.kv.crit { color: var(--err-text); }
.kn { font-size: 12.5px; color: var(--muted); }
.delta { font-size: 12px; font-weight: 650; margin-right: 2px; }
.delta.sobe { color: var(--ok-text); } .delta.desce { color: var(--err-text); } .delta.igual { color: var(--muted); }
.mini { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; margin: 8px 0 12px; }
.mini div { font-size: 12px; color: var(--muted); border: 1px solid var(--border); border-radius: 10px; padding: 8px 12px; }
.mini b { display: block; font-size: 18px; line-height: 1.25; color: var(--text); font-variant-numeric: tabular-nums; }

/* Filtros e barras de ação */
.filtros { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.filtros label { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--muted); }
:where(.ui) .filtros select, :where(.ui) .filtros input:not([type="checkbox"]) { height: 34px; }
.filtros .busca { min-width: 240px; }
.filtros .espaco { flex: 1; }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; background: var(--surface); max-width: 100%; overflow-x: auto; }
:where(.ui) .seg button { min-height: 32px; padding: 4px 12px; font-size: 12.5px; border: 0; border-radius: 0; color: var(--text-2); background: none; flex: none; }
:where(.ui) .seg button + button { border-left: 1px solid var(--border); }
:where(.ui) .seg button.on { color: var(--on-brand); background: var(--brand-strong); }
.paginacao { display: flex; align-items: center; justify-content: flex-end; gap: 8px; margin-top: 10px; font-size: 13px; color: var(--muted); }
.resumo-linha { font-size: 13px; color: var(--text-2); }
.resumo-linha b { font-variant-numeric: tabular-nums; }

/* Barrinha proporcional (faixas de atraso) */
.barrinha { display: inline-block; height: 8px; border-radius: 0 4px 4px 0; background: var(--o3); vertical-align: middle; }

/* Gráfico de barras empilhadas */
.graf { overflow-x: auto; }
.graf > svg { display: block; width: 100%; height: auto; }
svg text { font: 11px Inter, -apple-system, "Segoe UI", sans-serif; fill: var(--text-2); }
svg .tick { fill: var(--muted); }
svg .val { fill: var(--text); font-weight: 600; }
svg .gridl, svg .axis { stroke: var(--border); }
svg .s-genesis { fill: var(--c1); }
svg .s-mais1 { fill: var(--c2); }
svg .s-sniper { fill: var(--c3); }
svg .s-sem_produto { fill: var(--c4); }
svg .hit { fill: transparent; }
svg .hit:hover { fill: var(--code-bg); fill-opacity: 0.5; }
.legenda { display: flex; gap: 14px; flex-wrap: wrap; margin-top: 8px; font-size: 12.5px; color: var(--text-2); }
.legenda span { display: inline-flex; align-items: center; gap: 6px; }
.legenda i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.sw-genesis { background: var(--c1); }
.sw-mais1 { background: var(--c2); }
.sw-sniper { background: var(--c3); }
.sw-sem_produto { background: var(--c4); }

/* Status da sincronização */
.kvlist { display: grid; grid-template-columns: max-content 1fr; gap: 4px 14px; font-size: 13px; margin: 0; }
.kvlist dt { color: var(--muted); }
.kvlist dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }

/* ── Gaveta do cliente ───────────────────────────────────────────────────── */
.gaveta-fundo { position: fixed; inset: 0; z-index: 50; background: var(--overlay); }
.gaveta {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 51; width: min(820px, 100vw);
  background: var(--bg); box-shadow: var(--shadow-lg); display: flex; flex-direction: column;
}
.gaveta-h {
  display: flex; align-items: flex-start; gap: 12px; padding: 14px 20px; background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.gaveta-h .t { flex: 1; min-width: 0; }
.gaveta-h .t b { display: block; font-size: 17px; line-height: 1.3; overflow-wrap: anywhere; }
.gaveta-corpo { flex: 1; overflow-y: auto; padding: 18px 20px 32px; }
.gaveta-corpo > * + * { margin-top: 14px; }
.resultados { border: 1px solid var(--border); border-radius: 10px; max-height: 240px; overflow-y: auto; background: var(--surface); margin-top: 6px; }
:where(.ui) .resultados button {
  display: block; width: 100%; text-align: left; border: 0; border-radius: 0; min-height: 0; padding: 8px 12px; font-weight: 500;
}
:where(.ui) .resultados button + button { border-top: 1px solid var(--border); }
:where(.ui) .resultados button:hover { background: var(--code-bg); }
.escolhido { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 13px; padding: 8px 10px; border-radius: 8px; background: var(--brand-soft); }

/* ── Diálogo de confirmação ──────────────────────────────────────────────── */
.modal-fundo { position: fixed; inset: 0; z-index: 60; background: var(--overlay); display: grid; place-items: center; padding: 16px; }
.modal { width: min(480px, 100%); background: var(--surface); border-radius: 14px; box-shadow: var(--shadow-lg); padding: 20px 22px; }
.modal h2 { margin: 0 0 8px; font-size: 16px; }
.modal .modal-texto { font-size: 14px; color: var(--text-2); white-space: pre-line; }
.modal .actions { justify-content: flex-end; }

/* ── Toasts ──────────────────────────────────────────────────────────────── */
#toasts { position: fixed; right: 16px; bottom: 16px; z-index: 70; display: flex; flex-direction: column; gap: 8px; max-width: min(420px, calc(100vw - 32px)); }
.toast {
  background: var(--surface); color: var(--text); border: 1px solid var(--border); border-left-width: 4px;
  border-radius: 10px; box-shadow: var(--shadow-lg); padding: 10px 14px; font-size: 13.5px; overflow-wrap: anywhere;
}
.toast.ok { border-left-color: var(--ok); }
.toast.err { border-left-color: var(--err); color: var(--err-text); }
.toast.info { border-left-color: var(--brand); }

/* ── Régua ───────────────────────────────────────────────────────────────── */
.semana { display: flex; gap: 10px; flex-wrap: wrap; }
.etapas { display: flex; flex-direction: column; gap: 12px; }
.etapa { border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px; background: var(--surface); }
.etapa.off { background: var(--bg); }
.etapa-h { display: grid; grid-template-columns: 1fr 120px auto auto; gap: 10px; align-items: end; }
.etapa-h .quando { font-size: 12px; color: var(--muted); font-weight: 600; white-space: nowrap; padding-bottom: 10px; }
.etapa textarea { width: 100%; min-height: 120px; margin-top: 10px; }
.chips { display: flex; gap: 5px; flex-wrap: wrap; margin-top: 6px; }
:where(.ui) .chips button {
  min-height: 24px; padding: 1px 8px; font: 600 11.5px ui-monospace, Consolas, monospace; color: var(--brand-strong);
  background: var(--brand-soft); border-color: transparent; border-radius: 999px;
}
.previa { margin-top: 10px; }
.sujo { color: var(--warn-text); font-weight: 700; }
@media (max-width: 640px) {
  .etapa-h { grid-template-columns: 1fr 1fr; }
  .etapa-h .quando { grid-column: 1 / -1; padding: 0; }
}

/* ── Conversas e chat de teste ───────────────────────────────────────────── */
.conv-layout { display: grid; grid-template-columns: 330px 1fr; gap: 16px; align-items: start; }
.conv-layout > *, .grid2 > * { min-width: 0; }
@media (max-width: 1000px) { .conv-layout { grid-template-columns: 1fr; } }
.conv-lista { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow); max-height: calc(100dvh - 230px); min-height: 300px; overflow-y: auto; }
:where(.ui) .conv-lista button {
  display: block; width: 100%; text-align: left; border: 0; border-radius: 0; min-height: 0; padding: 10px 14px; font-weight: 400;
  border-bottom: 1px solid var(--border);
}
:where(.ui) .conv-lista button:hover { background: var(--bg); }
:where(.ui) .conv-lista button.on { background: var(--brand-soft); }
.conv-lista .l1 { display: flex; align-items: center; gap: 6px; font-weight: 600; font-size: 13.5px; }
.conv-lista .l1 .nome { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conv-lista .l2 { font-size: 12.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-top: 2px; }
.conv-lista .l3 { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 4px; }
.contador {
  display: inline-block; min-width: 18px; font-size: 11px; font-weight: 700; line-height: 18px; text-align: center;
  color: var(--on-brand); background: var(--err); border-radius: 999px; padding: 0 5px;
}
.chat {
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 14px;
  height: 480px; overflow-y: auto; display: flex; flex-direction: column; gap: 8px;
}
.chat.alto { height: calc(100dvh - 380px); min-height: 320px; }
.msg { display: flex; flex-direction: column; max-width: 78%; }
.msg.esq { align-self: flex-start; }
.msg.dir { align-self: flex-end; align-items: flex-end; }
.msg .quem { font-size: 11px; font-weight: 700; color: var(--muted); margin: 0 4px 2px; }
.bolha { padding: 8px 12px; border-radius: 12px; font-size: 14px; line-height: 1.45; white-space: pre-wrap; overflow-wrap: anywhere; }
.msg.esq .bolha { background: var(--code-bg); border-bottom-left-radius: 3px; }
.msg.dir .bolha { background: var(--brand-soft); border-bottom-right-radius: 3px; }
.msg.humano .bolha { background: var(--ok-bg); border: 1px solid var(--ok-bd); }
.msg.nao-enviada .bolha { background: var(--surface); border: 1px dashed var(--warn-bd); }
.msg .rodape { font-size: 11px; color: var(--muted); margin: 2px 4px 0; }
.msg .rodape .aviso-envio { color: var(--warn-text); font-weight: 600; }
.msg .rodape .erro-envio { color: var(--err-text); font-weight: 600; }
.ferramenta {
  font: 11.5px ui-monospace, Consolas, monospace; color: var(--muted); background: var(--code-bg);
  border: 1px solid var(--border); border-radius: 6px; padding: 3px 8px; margin-top: 4px; max-width: 100%; overflow-wrap: anywhere;
}
.pensando { align-self: flex-start; font-size: 13px; color: var(--muted); font-style: italic; }
.chatbar { display: flex; gap: 8px; align-items: flex-end; margin-top: 10px; }
.chatbar textarea { flex: 1; min-height: 44px; max-height: 160px; resize: vertical; }
.conv-h { display: flex; align-items: flex-start; gap: 12px; flex-wrap: wrap; margin-bottom: 10px; }
.conv-h .t { flex: 1; min-width: 200px; }
.conv-h .t b { font-size: 16px; }

/* Agente */
.agente-texto textarea { width: 100%; min-height: 260px; font: 13px/1.55 ui-monospace, Consolas, monospace; padding: 12px; }
.historico { margin-top: 10px; border-top: 1px solid var(--border); padding-top: 10px; }
.historico .item { padding: 6px 0; border-bottom: 1px solid var(--border); font-size: 13px; }

/* WhatsApp */
.qr img { display: block; margin: 10px 0; max-width: 280px; height: auto; border: 1px solid var(--border); border-radius: 8px; }

/* ── Tablet e celular: a lateral vira gaveta ─────────────────────────────── */
@media (max-width: 900px) {
  #app.app { grid-template-columns: minmax(0, 1fr); }
  .sidebar {
    position: fixed; top: 0; bottom: 0; left: 0; z-index: 40; width: min(280px, 86vw);
    transform: translateX(-100%); visibility: hidden; transition: transform 0.2s ease, visibility 0.2s;
    box-shadow: var(--shadow-lg); border-right: 0;
  }
  #app.nav-aberta .sidebar { transform: none; visibility: visible; }
  #app.nav-aberta .nav-fundo { display: block; position: fixed; inset: 0; z-index: 35; background: var(--overlay); }
  .btn-top.btn-menu, .btn-top.nav-fechar { display: inline-flex; }
  .btn-top { min-height: 38px; }
  .btn-top .ic { width: 18px; height: 18px; }
  .topbar { gap: 8px; padding: 8px 12px; min-height: 54px; }
  .topbar .title { flex: 1; }
  .topbar .espaco { display: none; }
  #current-user { display: none; }
  main#content { padding: 16px; }
}

/* ── Celular ─────────────────────────────────────────────────────────────── */
@media (max-width: 640px) {
  .btn-top .rot-top { display: none; }
  .btn-top { padding: 6px 10px; }
  main#content { padding: 12px 10px 24px; }
  :where(.ui) input:where(:not([type="checkbox"], [type="radio"], [type="file"], [type="range"], [type="color"])),
  :where(.ui) select,
  :where(.ui) textarea { font-size: 16px; }
  .panel, .card { padding: 14px 12px; border-radius: 12px; }
  .filtros > label, .filtros .busca { flex: 1 1 140px; min-width: 0; }
  .filtros > label select { flex: 1; min-width: 0; }
  .cards { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .cards .card { padding: 10px 12px; }
  .kv { font-size: 20px; overflow-wrap: anywhere; }
  .mini { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  :where(.ui) :not(.scroll) > table { display: block; overflow-x: auto; }
  :where(.ui) th, :where(.ui) td { padding: 7px 8px; }
  .graf > svg { min-width: 640px; }
  .msg { max-width: 90%; }
  .modo-badge .rot-top { display: none; }
  .gaveta-corpo { padding: 14px 12px 28px; }
}
