/* ============================================================
   Pós-Venda eGestor — painel administrativo
   Design system leve: superfícies claras, acento verde (WhatsApp).
   ============================================================ */
:root {
  --bg: #eef1f5;
  --surface: #ffffff;
  --surface-2: #f6f8fa;
  --ink: #17222c;
  --muted: #61707e;
  --line: #e4e9ef;
  --line-strong: #d3dae2;

  --accent: #1b9e5a;
  --accent-d: #0f6d3d;
  --accent-soft: #e7f5ee;

  --blue: #2f7de1;
  --amber: #b8860b;
  --purple: #7c5cd6;
  --danger: #c0492c;
  --danger-soft: #fbe9e3;

  --r: 12px;
  --r-sm: 8px;
  --sh-sm: 0 1px 2px rgba(20, 35, 50, .06);
  --sh: 0 2px 10px -2px rgba(20, 35, 50, .12), 0 1px 2px rgba(20, 35, 50, .05);
  --sh-lg: 0 16px 40px -18px rgba(20, 35, 50, .35);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }

body {
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  line-height: 1.5;
  overflow-wrap: break-word; /* texto longo (nome, motivo, e-mail) quebra em vez de empurrar o layout */
}

/* ---------- Header ---------- */
header {
  display: flex; justify-content: space-between; align-items: center;
  gap: 16px;
  background: linear-gradient(115deg, #0f3d2a 0%, #14212b 100%);
  color: #fff; padding: 16px 26px;
  box-shadow: var(--sh);
  position: relative; z-index: 5;
}
.brand { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
header h1 { font-size: 19px; font-weight: 700; letter-spacing: -.02em; }
.brand-sub {
  font-size: 12.5px; color: #9fd8b8; font-weight: 500;
  letter-spacing: .02em;
}

.badge {
  font-size: 12.5px; font-weight: 600; padding: 7px 14px; border-radius: 999px;
  background: rgba(255, 255, 255, .14); color: #fff;
  border: 1px solid rgba(255, 255, 255, .18); white-space: nowrap;
  backdrop-filter: blur(4px);
}
.badge.on { background: #17904a; border-color: #1faa5a; }
.badge.off { background: #a83a2a; border-color: #c0492c; }
.badge.wait { background: #9a7500; border-color: #b8860b; }

/* Status do WhatsApp + menu de conexão (header) */
.header-conexao { display: flex; align-items: center; gap: 8px; }
.menu-conexao { position: relative; }
#btn-menu-conexao {
  font-size: 13px; line-height: 1; padding: 7px 10px; border-radius: 999px; cursor: pointer;
  background: rgba(255, 255, 255, .14); color: #fff; border: 1px solid rgba(255, 255, 255, .18);
}
#btn-menu-conexao:hover { background: rgba(255, 255, 255, .24); }
#btn-menu-conexao .caret { font-size: 10px; opacity: .85; }
.menu-dropdown {
  position: absolute; right: 0; top: calc(100% + 8px); z-index: 30; min-width: 210px;
  list-style: none; margin: 0; padding: 6px;
  background: var(--surface); color: var(--ink);
  border: 1px solid var(--line-strong); border-radius: var(--r-sm); box-shadow: var(--sh-lg);
}
.menu-dropdown[hidden] { display: none; }
.menu-dropdown li { list-style: none; }
.menu-dropdown button {
  display: block; width: 100%; text-align: left; cursor: pointer;
  font-size: 14px; padding: 9px 12px; border: 0; border-radius: var(--r-sm);
  background: transparent; color: var(--ink);
}
.menu-dropdown button:hover { background: var(--surface-2); }
.menu-dropdown button.perigo { color: var(--danger); }
.menu-dropdown button.perigo:hover { background: var(--danger-soft); }

/* ---------- Nav ---------- */
nav {
  display: flex; gap: 2px; background: var(--surface);
  border-bottom: 1px solid var(--line);
  padding: 0 14px; overflow-x: auto; -webkit-overflow-scrolling: touch;
  position: sticky; top: 0; z-index: 4;
}
nav::-webkit-scrollbar { height: 0; }
nav .tab {
  border: none; background: none; padding: 14px 16px; cursor: pointer;
  font-size: 14px; color: var(--muted); white-space: nowrap;
  border-bottom: 3px solid transparent; transition: color .15s, border-color .15s, background .15s;
  border-radius: 8px 8px 0 0;
}
nav .tab:hover { color: var(--accent-d); background: var(--surface-2); }
nav .tab.active { color: var(--accent-d); border-bottom-color: var(--accent); font-weight: 600; }

/* ---------- Layout ---------- */
main { max-width: 1200px; margin: 0 auto; padding: 26px 16px 72px; }
.painel {
  min-width: 0;
  display: none; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r); padding: 26px; box-shadow: var(--sh-sm);
  animation: painelIn .22s ease;
}
.painel.ativo { display: block; }
@keyframes painelIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
.painel h2 {
  font-size: 17px; font-weight: 700; letter-spacing: -.01em;
  margin-bottom: 20px; padding-bottom: 14px; border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 10px;
}

/* ---------- Cards de status ---------- */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; margin: 20px 0; }
.card {
  min-width: 0;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r);
  padding: 16px 18px; position: relative; overflow: hidden; box-shadow: var(--sh-sm);
  transition: transform .15s, box-shadow .15s;
}
.card:hover { transform: translateY(-2px); box-shadow: var(--sh); }
.card::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--accent); }
.cards .card:nth-child(1)::before { background: var(--blue); }
.cards .card:nth-child(2)::before { background: var(--amber); }
.cards .card:nth-child(3)::before { background: var(--accent); }
.cards .card:nth-child(4)::before { background: var(--purple); }
.card span { display: block; font-size: 30px; font-weight: 800; letter-spacing: -.02em; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
/* "Último webhook" é data/hora, não um número: fonte menor para caber no card */
.card #canal-webhook { font-size: 17px; line-height: 1.35; padding: 6px 0; }
.card label { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; }

/* ---------- Conexão / QR ---------- */
#qr-area { text-align: center; padding: 10px 0 4px; }
#conexao-info { color: var(--muted); font-size: 14px; max-width: 46ch; margin: 0 auto; }
#qr-img { margin: 16px auto; border: 1px solid var(--line-strong); border-radius: var(--r); padding: 8px; background: #fff; box-shadow: var(--sh); }

/* ---------- Formulários ---------- */
.grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px 18px; }
/* minmax(0,…) + min-width:0: sem isso um select/texto longo alarga a coluna e estoura a tela */
.grid > * { min-width: 0; }
.grid label { display: flex; flex-direction: column; font-size: 12px; font-weight: 600; color: var(--muted); gap: 6px; text-transform: uppercase; letter-spacing: .04em; }
.grid .full { grid-column: 1 / -1; }

input, select, textarea {
  max-width: 100%;
  padding: 10px 12px; border: 1px solid var(--line-strong); border-radius: var(--r-sm);
  font-size: 14px; font-family: inherit; font-weight: 400; text-transform: none; letter-spacing: normal;
  color: var(--ink); background: var(--surface); transition: border-color .15s, box-shadow .15s;
}
input::placeholder, textarea::placeholder { color: #9aa7b2; }
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(27, 158, 90, .16);
}
textarea { resize: vertical; line-height: 1.55; }
select { cursor: pointer; }

.linha { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; align-items: center; }
.linha input { flex: 1; min-width: 150px; }
.linha select { max-width: 100%; }

/* ---------- Botões ---------- */
button {
  cursor: pointer; border-radius: var(--r-sm); border: 1px solid var(--line-strong);
  background: var(--surface); color: var(--ink); padding: 10px 16px; font-size: 14px; font-weight: 500;
  font-family: inherit; transition: background .15s, border-color .15s, box-shadow .15s, transform .05s;
}
button:hover { border-color: var(--accent); color: var(--accent-d); background: var(--accent-soft); }
button:active { transform: translateY(1px); }
button.primario {
  background: linear-gradient(180deg, #22ab64, #178a4f); border-color: #178a4f; color: #fff;
  box-shadow: var(--sh-sm);
}
button.primario:hover { filter: brightness(1.06); color: #fff; border-color: #0f6d3d; }
button:focus-visible { outline: 3px solid rgba(27, 158, 90, .4); outline-offset: 2px; }
button.apagar, button.excluir-fila, button.editar-fila { border: none; background: none; font-size: 16px; padding: 6px 8px; }
button.apagar:hover, button.excluir-fila:hover { background: var(--danger-soft); border-radius: 6px; transform: none; }
button.salvar-vend, button.salvar-fila { border: none; background: none; font-size: 16px; padding: 6px 8px; }
button.salvar-vend:hover, button.salvar-fila:hover { background: var(--accent-soft); border-radius: 6px; }
button.perigo { border-color: var(--danger); color: var(--danger); background: var(--surface); }
button.perigo:hover { background: var(--danger-soft); color: var(--danger); border-color: var(--danger); }

/* ---------- Tabelas ---------- */
table {
  width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13.5px;
  border: 1px solid var(--line); border-radius: var(--r-sm); overflow: hidden; margin-top: 8px;
}
th, td { text-align: left; padding: 11px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; overflow-wrap: break-word; }
thead th { background: var(--surface-2); font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; }
tbody tr:last-child td { border-bottom: none; }
tbody tr { transition: background .12s; }
tbody tr:hover { background: var(--surface-2); }

/* ---------- Dicas / logs ---------- */
.dica { font-size: 13px; color: var(--muted); margin: 10px 0; }
#area-logs {
  background: #0f1519; color: #cfe8d6; font-size: 12.5px; padding: 16px;
  border-radius: var(--r); margin-top: 14px; max-height: 460px; overflow: auto;
  white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.6; border: 1px solid #1c2a22;
  font-family: ui-monospace, 'Cascadia Code', Consolas, monospace;
}

/* ---------- Checkboxes ---------- */
label.checkbox {
  display: flex; flex-direction: row; align-items: center; justify-content: flex-start;
  gap: 10px; font-size: 14px; font-weight: 500; text-align: left;
  color: var(--ink); text-transform: none; letter-spacing: normal;
  padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--surface-2);
  cursor: pointer; transition: border-color .15s, background .15s;
}
label.checkbox:hover { border-color: var(--accent); }
label.checkbox:has(input:checked) { background: var(--accent-soft); border-color: var(--accent); }
label.checkbox input { width: auto; flex: 0 0 auto; margin: 0; accent-color: var(--accent); transform: scale(1.15); }

/* ---------- Telefone do vendedor ---------- */
input.vend-tel { width: 100%; min-width: 140px; padding: 8px 10px; }
select.vend-agente { max-width: 100%; }
input.vend-tel.faltando { border-color: var(--amber); background: #fff8e6; }

/* Container com rolagem horizontal para tabelas largas (fila) */
.tabela-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; max-width: 100%; margin-top: 8px; }
.tabela-scroll table { margin-top: 0; min-width: 720px; }
#tabela-vendedores, #tabela-alertas, table.tabela-guia { min-width: 0; } /* cabem sem rolar; no celular as tabelas .tabela-cards viram cartões (ver @media) */
td.data { white-space: nowrap; } /* colunas de data nunca quebram em duas linhas */

/* ---------- Dias da semana ---------- */
.campo-dias { display: flex; flex-direction: column; gap: 10px; }
.rotulo-campo { font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.dias { display: flex; flex-wrap: wrap; gap: 8px; }
.chip-dia {
  display: inline-flex; align-items: center; gap: 7px; padding: 8px 14px;
  border: 1px solid var(--line-strong); border-radius: 999px; font-size: 14px;
  cursor: pointer; user-select: none; transition: background .15s, border-color .15s, color .15s;
}
.chip-dia:hover { border-color: var(--accent); }
.chip-dia input { width: auto; margin: 0; accent-color: var(--accent); }
.chip-dia:has(input:checked) { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-d); font-weight: 600; }

/* ---------- Ajuda por campo (Configurações) ---------- */
.ajuda {
  overflow-wrap: anywhere;
  display: block; font-size: 12px; font-weight: 400; color: var(--muted);
  text-transform: none; letter-spacing: normal; line-height: 1.4; margin-top: 2px;
}

/* ---------- Seletor de template do WhatsApp ---------- */
.tpl-previa {
  overflow-wrap: anywhere;
  display: block; font-size: 12px; line-height: 1.4; white-space: pre-wrap; color: var(--muted);
  background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-sm); padding: 8px 10px;
}
.tpl-previa .tpl-aviso { display: block; margin-top: 6px; color: #b45309; font-weight: 600; }
.tpl-atualizar { width: fit-content; font-size: 12px; padding: 4px 10px; }

/* ---------- Bloco "Avançado" (Configurações) ---------- */
details.avancado {
  border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--surface-2);
  padding: 14px 16px; margin: 22px 0;
}
details.avancado summary {
  cursor: pointer; font-size: 13px; font-weight: 600; color: var(--muted); list-style: none;
}
details.avancado summary::-webkit-details-marker { display: none; }
details.avancado summary::marker { content: ''; }
details.avancado[open] summary { margin-bottom: 14px; }

/* ---------- Sub-abas de Configurações ---------- */
.sub-tabs { display: flex; gap: 2px; flex-wrap: wrap; border-bottom: 1px solid var(--line); margin-bottom: 22px; }
.sub-tab {
  border: none; background: none; padding: 10px 15px; font-size: 14px; color: var(--muted);
  cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px;
  border-radius: 7px 7px 0 0; transition: color .15s, background .15s, border-color .15s;
}
.sub-tab:hover { color: var(--accent-d); background: var(--surface-2); }
.sub-tab.ativo { color: var(--accent-d); border-bottom-color: var(--accent); font-weight: 600; }

/* .grid.sub-panel vence .grid (0,2,0 > 0,1,0) para esconder o inativo */
.grid.sub-panel { display: none; }
.grid.sub-panel.ativo { display: grid; animation: fadeIn .18s ease; }
#form-config > .primario { width: 100%; margin-top: 22px; padding: 12px; font-size: 15px; }

/* ---------- Abas de mensagem (Orçamento / Venda) ---------- */
.campo-msgs { display: flex; flex-direction: column; gap: 10px; }
.msg-tabs { display: inline-flex; max-width: 100%; gap: 4px; background: var(--surface-2); padding: 4px; border-radius: 10px; width: fit-content; border: 1px solid var(--line); }
.msg-tab {
  border: none; background: transparent; padding: 8px 18px; border-radius: 7px;
  font-size: 14px; font-weight: 500; color: var(--muted); cursor: pointer;
  transition: background .15s, color .15s, box-shadow .15s;
}
.msg-tab:hover { color: var(--accent-d); background: transparent; }
.msg-tab.ativo { background: var(--surface); color: var(--accent-d); font-weight: 700; box-shadow: var(--sh-sm); }
/* .grid label usa display:flex; precisamos de +especificidade para esconder o inativo */
.grid .msg-panel { display: none; flex-direction: column; gap: 8px; }
.grid .msg-panel.ativo { display: flex; animation: fadeIn .18s ease; }
.msg-panel textarea { min-height: 130px; width: 100%; }
.tpl-bloco { display: flex; flex-direction: column; gap: 8px; }
.msg-hint { overflow-wrap: anywhere; font-size: 12.5px; color: var(--muted); text-transform: none; letter-spacing: normal; font-weight: 400; }
.msg-hint code { background: var(--accent-soft); color: var(--accent-d); padding: 2px 7px; border-radius: 5px; font-size: 12px; font-family: ui-monospace, Consolas, monospace; }

@keyframes fadeIn { from { opacity: 0; transform: translateY(2px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { *, .painel, .msg-panel.ativo { animation: none !important; } }

/* ---------- Modais (avisos e confirmações) ---------- */
.modal-overlay {
  position: fixed; inset: 0; z-index: 100; padding: 16px;
  display: flex; align-items: center; justify-content: center;
  background: rgba(13, 22, 18, .5); backdrop-filter: blur(3px);
  animation: fadeIn .15s ease;
}
.modal-overlay[hidden] { display: none; }
.modal {
  background: var(--surface); border-radius: var(--r); box-shadow: var(--sh-lg);
  width: 100%; max-width: min(430px, calc(100vw - 32px)); padding: 28px 26px 22px; text-align: center;
  max-height: calc(100vh - 32px); max-height: calc(100dvh - 32px); overflow-y: auto; /* nunca passa da tela: rola por dentro */
  border-top: 4px solid var(--accent); animation: modalIn .2s cubic-bezier(.2, .8, .3, 1);
}
.modal-info, .modal-pergunta { border-top-color: var(--blue); }
.modal-sucesso { border-top-color: var(--accent); }
.modal-erro { border-top-color: var(--danger); }
.modal-aviso { border-top-color: var(--amber); }
.modal-icon { font-size: 42px; line-height: 1; margin-bottom: 10px; }
.modal-titulo { font-size: 18px; font-weight: 700; color: var(--ink); margin-bottom: 8px; overflow-wrap: anywhere; }
.modal-msg { font-size: 14.5px; color: var(--muted); line-height: 1.55; white-space: pre-line; overflow-wrap: anywhere; margin-bottom: 24px; }
.modal-acoes { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.modal-acoes button { min-width: 120px; }
@keyframes modalIn { from { opacity: 0; transform: translateY(12px) scale(.98); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .modal, .modal-overlay { animation: none; } }

/* Modal largo (lista do modo teste) */
.modal.modal-lg {
  max-width: min(1160px, calc(100vw - 32px)); text-align: left; border-top-color: var(--blue);
  display: flex; flex-direction: column; /* título/ações fixos; só a lista rola */
}
.modal-lg > * { flex: 0 0 auto; }
.modal-lg .modal-titulo { text-align: left; }
.modal-lg .modal-msg { text-align: left; margin-bottom: 12px; }
.teste-corpo { flex: 1 1 auto; min-height: 0; max-height: 55vh; overflow: auto; -webkit-overflow-scrolling: touch; margin-bottom: 18px; }
.teste-corpo table { margin-top: 0; min-width: 640px; } /* colunas legíveis; a lista rola na horizontal dentro do modal */
.teste-corpo th:first-child, .teste-corpo td:first-child { width: 34px; text-align: center; }
.teste-corpo td.sem-tel, #tabela-fila td.sem-tel { color: var(--amber); font-weight: 600; }
.teste-corpo tr.desabilitada { opacity: .55; }
td.motivo { min-width: 11rem; max-width: 16rem; font-size: .85em; color: var(--muted); }
/* Fila: 9 colunas em ~930px — células mais compactas para caber sem rolar no desktop */
@media (min-width: 641px) { #tabela-fila th, #tabela-fila td, #tabela-lista th, #tabela-lista td { padding: 10px 7px; } }
.modal-lg .modal-acoes { justify-content: flex-end; }

/* Modal de edição do telefone (aba Fila) */
.modal.modal-form { max-width: min(460px, calc(100vw - 32px)); }
.modal-form label { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; font-weight: 600; }
.modal-form label.check { flex-direction: row; align-items: center; gap: 8px; font-weight: 400; }
.modal-form .erro-form { color: var(--danger); margin-top: -4px; }
td.acoes-fila { white-space: nowrap; }

/* Botão "Ver" nos contadores do Canal */
.card .card-ver { display: block; margin-top: 8px; padding: 3px 10px; font-size: 12px; }

/* Modal de novidades da versão */
#novidades-overlay .modal.modal-lg { max-width: min(560px, calc(100vw - 32px)); text-align: center; border-top-color: var(--accent); }
#novidades-overlay .modal-titulo { text-align: center; }
#novidades-versao { font-size: 12.5px; font-weight: 600; color: var(--muted); margin: -2px 0 16px; }
.novidades-lista { list-style: none; text-align: left; margin: 0 0 22px; padding: 0; display: grid; gap: 12px; flex: 1 1 auto; min-height: 0; overflow-y: auto; }
.novidades-lista li {
  position: relative; padding: 12px 14px 12px 42px; font-size: 14px; line-height: 1.5;
  color: var(--ink); background: var(--surface-2); border: 1px solid var(--line);
  border-radius: var(--r-sm);
}
.novidades-lista li::before { content: "✅"; position: absolute; left: 14px; top: 11px; font-size: 15px; }

/* ---------- Paginação ---------- */
.paginacao { display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 10px 14px; margin-top: 16px; }
.paginacao button { padding: 7px 14px; }
.paginacao button:disabled { opacity: .45; cursor: not-allowed; background: var(--surface); border-color: var(--line); color: var(--muted); }
.pag-info { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; min-width: 180px; max-width: 100%; text-align: center; }
td.vazio { text-align: center; color: var(--muted); padding: 22px; font-style: italic; }
input[type="date"] { min-width: 150px; }
.filtro-data { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }
.linha .filtro-data input { flex: 0 0 auto; min-width: 140px; }

/* ---------- Aba Instruções ---------- */
.guia-titulo { font-size: 15px; font-weight: 700; color: var(--ink); margin: 24px 0 12px; }
.guia-passos { display: grid; gap: 12px; }
.guia-passo { display: flex; gap: 14px; align-items: flex-start; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-sm); padding: 14px 16px; }
.guia-passo .guia-num { flex: 0 0 auto; width: 30px; height: 30px; border-radius: 50%; background: var(--accent); color: #fff; font-weight: 700; display: flex; align-items: center; justify-content: center; font-size: 14px; }
.guia-passo strong { display: block; margin-bottom: 3px; color: var(--ink); }
.guia-passo > div { min-width: 0; }
.guia-passo p { margin: 0; font-size: 13.5px; color: var(--muted); line-height: 1.5; }
.guia-lista { margin: 0 0 8px; padding-left: 20px; }
.guia-lista li { margin: 8px 0; font-size: 14px; }
.guia-lista li::marker { color: var(--accent); }

/* ============================================================
   Autenticação (login, definir senha, perfil, usuários)
   ============================================================ */
body.auth-pagina { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.auth-card {
  width: min(94vw, 400px); background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r); box-shadow: var(--sh-lg); padding: 28px 26px;
}
.auth-card h1 { font-size: 20px; margin-bottom: 4px; }
.auth-card .dica { margin-bottom: 14px; }
.auth-card form { display: flex; flex-direction: column; gap: 12px; }
.auth-card label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; font-weight: 600; }
.auth-card input, .perfil-bloco input, .form-usuario input, .form-usuario select {
  padding: 9px 11px; border: 1px solid var(--line-strong); border-radius: var(--r-sm);
  font: inherit; background: var(--surface);
}
.auth-card .erro-msg, .erro-msg { color: var(--danger); font-size: 13px; min-height: 18px; }
.auth-card .ok-msg, .ok-msg { color: var(--accent-d); font-size: 13px; }
.auth-card .links { margin-top: 14px; font-size: 13px; text-align: center; }
.auth-card a { color: var(--blue); }

.header-usuario { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: flex-end; }
.header-usuario .quem { font-size: 13px; color: #d7efe2; }
.header-usuario button, .header-usuario a.btn-link {
  font-size: 12.5px; padding: 6px 12px; border-radius: 999px; cursor: pointer; text-decoration: none;
  background: rgba(255, 255, 255, .14); color: #fff; border: 1px solid rgba(255, 255, 255, .18);
}
.header-usuario button:hover, .header-usuario a.btn-link:hover { background: rgba(255, 255, 255, .24); }

.perfil-bloco { max-width: 520px; margin-bottom: 26px; display: flex; flex-direction: column; gap: 10px; }
.perfil-bloco label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; font-weight: 600; }
.perfil-bloco img.qr { width: 200px; max-width: 100%; height: auto; aspect-ratio: 1;  border: 1px solid var(--line); border-radius: var(--r-sm); background: #fff; }
.perfil-bloco code { word-break: break-all; background: var(--surface-2); padding: 4px 8px; border-radius: 6px; }
.form-usuario { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 16px; }
.form-usuario label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; font-weight: 600; min-width: 0; max-width: 100%; }
.tabela-usuarios td .acoes { display: flex; gap: 6px; flex-wrap: wrap; }
.tabela-usuarios td .acoes button { white-space: nowrap; }
.tabela-usuarios .tag { font-size: 11.5px; padding: 2px 8px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line); }
.tabela-usuarios .tag.admin { background: var(--accent-soft); color: var(--accent-d); }
.tabela-usuarios .tag.inativo { background: var(--danger-soft); color: var(--danger); }
#form-config.somente-leitura input:disabled, #form-config.somente-leitura select:disabled,
#form-config.somente-leitura textarea:disabled { background: var(--surface-2); color: var(--muted); cursor: not-allowed; }

/* ============================================================
   Responsivo
   - <= 900px (tablet): menos respiro lateral, cabeçalho em duas linhas.
   - <= 640px (celular): coluna única, alvos de toque >= 40px, fonte de
     campo 16px (o iOS dá zoom automático em campos menores que isso),
     vendedores/alertas viram cartões, demais tabelas rolam na horizontal
     dentro do próprio contêiner (a página nunca rola de lado).
   ============================================================ */
@media (max-width: 900px) {
  header { flex-wrap: wrap; padding: 14px 20px; }
  .header-usuario { flex: 1 1 auto; }
  main { padding: 20px 12px 64px; }
}

@media (max-width: 640px) {
  header { flex-direction: column; align-items: stretch; gap: 10px; padding: 12px 14px; }
  .header-usuario { justify-content: flex-start; gap: 8px; }
  .header-usuario .quem { flex: 1 1 100%; order: 5; font-size: 12.5px; }
  .header-usuario button, .header-usuario a.btn-link { min-height: 40px; padding: 8px 14px; display: inline-flex; align-items: center; }
  .badge { padding: 9px 14px; }

  nav { padding: 0 6px; }
  nav .tab { padding: 13px 14px; min-height: 46px; }

  main { padding: 12px 10px 56px; }
  .painel { padding: 16px 14px; }
  .painel h2 { font-size: 16px; margin-bottom: 14px; padding-bottom: 12px; }

  .cards { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin: 14px 0; }
  .card { padding: 12px 14px; }
  .card span { font-size: 26px; }
  .card #canal-webhook { font-size: 15px; }

  .grid { grid-template-columns: minmax(0, 1fr); gap: 14px; }

  /* Campos: 16px evita o zoom do iOS; 44px de altura facilita o toque */
  input:not([type="checkbox"]):not([type="radio"]), select, textarea { font-size: 16px; min-height: 44px; }
  textarea { min-height: 130px; }
  button { min-height: 40px; }
  button.apagar, button.excluir-fila, button.editar-fila, button.salvar-vend, button.salvar-fila { min-width: 40px; min-height: 40px; }
  .card .card-ver, .tpl-atualizar { min-height: 40px; padding: 6px 12px; font-size: 13px; }
  .chip-dia { padding: 10px 14px; }
  label.checkbox { padding: 12px; }

  /* Barras de botões e filtros: um por linha, largura total */
  .linha > button, .linha > select { flex: 1 1 100%; }
  .linha > input { flex: 1 1 100%; min-width: 0; }
  .linha .filtro-data { flex: 1 1 calc(50% - 5px); min-width: 0; }
  .linha .filtro-data input { flex: 1 1 auto; min-width: 0; width: 100%; }
  .linha > .dica { flex: 1 1 100%; margin: 0; }
  input[type="date"] { min-width: 0; }
  .form-usuario > label, .form-usuario > button { flex: 1 1 100%; }
  .form-usuario input, .form-usuario select { width: 100%; }

  /* Sub-abas de Configurações: uma faixa rolável em vez de várias linhas */
  .sub-tabs { flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch; margin-bottom: 18px; }
  .sub-tabs::-webkit-scrollbar { height: 0; }
  .sub-tab { white-space: nowrap; flex: 0 0 auto; min-height: 44px; }
  .msg-tabs { width: 100%; }
  .msg-tab { flex: 1 1 0; min-height: 40px; padding: 8px 10px; }

  /* Tabelas que rolam na horizontal */
  th, td { padding: 9px 10px; }
  .tabela-scroll table { min-width: 680px; }
  .tabela-scroll table.tabela-cards, .teste-corpo table.tabela-cards, table.tabela-guia { min-width: 0; }
  td.motivo { min-width: 11rem; }
  .teste-corpo table { min-width: 620px; }

  /* Vendedores e Alertas: cada linha vira um cartão (rótulo vem da coluna) */
  table.tabela-cards, table.tabela-cards tbody, table.tabela-cards tr, table.tabela-cards td { display: block; width: 100%; }
  table.tabela-cards thead { display: none; }
  table.tabela-cards { border: none; margin-top: 0; }
  table.tabela-cards tr { border: 1px solid var(--line); border-radius: var(--r-sm); padding: 10px 12px; margin-bottom: 10px; background: var(--surface); }
  table.tabela-cards tbody tr:last-child td, table.tabela-cards td { border-bottom: none; }
  table.tabela-cards td { padding: 5px 0; }
  table.tabela-cards td::before { display: block; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin-bottom: 2px; }
  table.tabela-cards td:empty { display: none; }
  table.tabela-cards:not(.tabela-cards-lin) td:last-child { display: flex; gap: 8px; justify-content: flex-end; padding-top: 8px; }
  #tabela-vendedores td:nth-child(1)::before { content: "ID eGestor"; }
  #tabela-vendedores td:nth-child(2)::before { content: "Nome"; }
  #tabela-vendedores td:nth-child(3)::before { content: "WhatsApp"; }
  #tabela-vendedores td:nth-child(4)::before { content: "Agente Chatwoot"; }
  #tabela-alertas td:nth-child(1)::before { content: "Responsável"; }
  #tabela-alertas td:nth-child(2)::before { content: "WhatsApp"; }
  table.tabela-cards input.vend-tel, table.tabela-cards select { min-width: 0; width: 100%; }
  table.tabela-cards:not(.tabela-cards-lin) td:last-child::before { content: none; }

  /* Fila e listas dos modais: cartão com o cliente em destaque e "rótulo  valor" por linha
     (o rótulo vem do data-label gerado no app.js) */
  table.tabela-cards-lin tr { display: flex; flex-direction: column; position: relative; }
  table.tabela-cards-lin td { display: flex; align-items: baseline; gap: 10px; padding: 4px 0; }
  table.tabela-cards-lin td::before { content: attr(data-label); flex: 0 0 112px; margin: 0; white-space: nowrap; }
  table.tabela-cards-lin td > * { min-width: 0; }
  table.tabela-cards-lin td.cartao-titulo { order: -3; font-size: 15px; font-weight: 700; padding: 0 0 6px; }
  table.tabela-cards-lin td.cartao-titulo::before { display: none; }
  table.tabela-cards-lin td.motivo { min-width: 0; max-width: none; font-size: 13px; }
  table.tabela-cards-lin td.vazio { display: block; text-align: center; padding: 18px 0; }
  table.tabela-cards-lin td.vazio::before { display: none; }
  table.tabela-cards-lin td.sem-tel { color: var(--amber); }
  /* Fila e "Ver": status e motivo logo abaixo do nome */
  #tabela-fila td[data-label="Status"], #tabela-lista td[data-label="Status"],
  #tabela-fila td.motivo, #tabela-lista td.motivo { order: -2; }
  #tabela-fila td.motivo, #tabela-lista td.motivo { order: -1; }
  #tabela-fila td.acoes-fila { order: 9; justify-content: flex-end; gap: 8px; padding-top: 8px; margin-top: 4px; border-top: 1px solid var(--line); }
  #tabela-fila td.acoes-fila::before { display: none; }
  #tabela-fila td.acoes-fila button { font-size: 18px; border: 1px solid var(--line-strong); min-width: 44px; min-height: 44px; }
  /* Modo teste: caixa de seleção no canto do cartão + "selecionar todos" no lugar do cabeçalho */
  #tabela-teste td.cartao-check { position: absolute; top: 8px; right: 6px; width: auto; padding: 0; display: flex; align-items: center; justify-content: center; min-width: 44px; min-height: 44px; }
  #tabela-teste td.cartao-check::before { display: none; }
  #tabela-teste td.cartao-check input { width: 22px; height: 22px; }
  #tabela-teste td.cartao-titulo { padding-right: 46px; min-height: 30px; }
  #tabela-teste thead { display: block; }
  #tabela-teste thead tr { display: block; padding: 8px 12px; border: none; margin: 0; background: var(--surface-2); border-radius: var(--r-sm); }
  #tabela-teste thead th { display: none; }
  #tabela-teste thead th:first-child { display: flex; align-items: center; gap: 10px; width: 100%; padding: 0; background: none; border: none; text-align: left; min-height: 36px; }
  #tabela-teste thead th:first-child::after { content: "Selecionar todos"; font-size: 13px; text-transform: none; letter-spacing: normal; color: var(--ink); }
  #tabela-teste thead th:first-child input { width: 22px; height: 22px; }
  .teste-corpo th:first-child, .teste-corpo td:first-child { width: 100%; text-align: left; }

  #area-logs { max-height: 60vh; font-size: 12px; padding: 12px; }
  .paginacao button { min-height: 40px; }
  .pag-info { min-width: 0; flex: 1 1 100%; order: 3; }

  /* Modais: margem mínima, botões do rodapé em linha quebrável */
  .modal-overlay { padding: 12px; }
  .modal { padding: 22px 16px 16px; max-width: calc(100vw - 24px); max-height: calc(100vh - 24px); max-height: calc(100dvh - 24px); }
  .modal.modal-lg, .modal.modal-form, #novidades-overlay .modal.modal-lg { max-width: calc(100vw - 24px); }
  .modal-icon { font-size: 36px; }
  .teste-corpo { max-height: none; }
  .modal-acoes { gap: 8px; }
  .modal-acoes button { flex: 1 1 130px; min-width: 0; min-height: 44px; }
  .modal-lg .modal-acoes { justify-content: stretch; }

  .perfil-bloco { max-width: 100%; }
  .perfil-bloco button, .perfil-bloco .primario { min-height: 44px; }
  .auth-card { padding: 22px 18px; }
  body.auth-pagina { padding: 12px; }
}

/* Telas muito estreitas (360px ou menos) */
@media (max-width: 380px) {
  .header-usuario .quem { font-size: 12px; }
  .card span { font-size: 24px; }
  .modal-acoes button { flex-basis: 100%; }
}
