:root {
  --bg: #F6F7F9;
  --card: #FFFFFF;
  --ink: #111827;
  --muted: #6B7280;
  --line: #E5E7EB;
  --brand: #0F766E;
  --brand-2: #115E59;
  --brand-soft: #CCFBF1;
  --danger: #DC2626;
  --danger-soft: #FEE2E2;
  --ok: #15803D;
  --ok-soft: #DCFCE7;
  --warn: #B45309;
  --warn-soft: #FEF3C7;
  --r: 14px;
  --sombra: 0 1px 2px rgba(17, 24, 39, .06), 0 1px 3px rgba(17, 24, 39, .08);
  --safe-b: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); }
body {
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
button, input, textarea, select { font: inherit; color: inherit; }
a { color: var(--brand); }
h1, h2, h3 { margin: 0; line-height: 1.2; }
h1 { font-size: 22px; }
h2 { font-size: 17px; }
h3 { font-size: 15px; }
p { margin: 0; }
.muted { color: var(--muted); }
.pequeno { font-size: 13px; }

/* layout */
.topo {
  position: sticky; top: 0; z-index: 5;
  background: rgba(246, 247, 249, .92); backdrop-filter: blur(8px);
  padding: calc(env(safe-area-inset-top, 0px) + 14px) 18px 12px;
  display: flex; align-items: center; gap: 10px;
}
.topo .titulo { flex: 1; min-width: 0; }
.topo .titulo h1 { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.voltar { border: 0; background: var(--card); box-shadow: var(--sombra); width: 38px; height: 38px; border-radius: 12px; font-size: 18px; cursor: pointer; }
main { padding: 4px 16px calc(96px + var(--safe-b)); max-width: 720px; margin: 0 auto; display: grid; gap: 14px; }
.sem-nav main { padding-bottom: 32px; }

.card { background: var(--card); border-radius: var(--r); box-shadow: var(--sombra); padding: 16px; display: grid; gap: 12px; }
.linha { display: flex; align-items: center; gap: 10px; }
.linha.entre { justify-content: space-between; }
.coluna { display: grid; gap: 4px; min-width: 0; }
.grade-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

/* navegação inferior */
.nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  background: var(--card); border-top: 1px solid var(--line);
  display: flex; justify-content: space-around;
  padding: 6px 4px calc(6px + var(--safe-b));
}
.nav a {
  flex: 1; text-decoration: none; color: var(--muted);
  display: grid; justify-items: center; gap: 2px; padding: 6px 0; font-size: 11.5px; font-weight: 600;
  border-radius: 10px;
}
.nav a svg { width: 22px; height: 22px; }
.nav a.ativo { color: var(--brand); }

/* formulários */
label { display: grid; gap: 6px; font-size: 13px; font-weight: 600; color: #374151; }
input[type=text], input[type=email], input[type=password], input[type=tel], textarea, select {
  width: 100%; padding: 12px 13px; border: 1px solid var(--line); border-radius: 11px; background: #fff;
  outline: none; transition: border-color .15s, box-shadow .15s;
}
input:focus, textarea:focus, select:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
textarea { resize: vertical; min-height: 96px; }
.check { display: flex; align-items: center; gap: 10px; font-weight: 500; font-size: 14px; color: var(--ink); }
.check input { width: 20px; height: 20px; accent-color: var(--brand); }

.btn {
  border: 0; border-radius: 12px; padding: 12px 16px; font-weight: 700; cursor: pointer;
  background: var(--brand); color: #fff; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 46px; text-decoration: none;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: default; }
.btn.sec { background: #EEF2F4; color: var(--ink); }
.btn.perigo { background: var(--danger-soft); color: var(--danger); }
.btn.grande { min-height: 56px; font-size: 16px; width: 100%; }
.btn.bloco { width: 100%; }
.btn.mini { min-height: 34px; padding: 6px 11px; font-size: 13px; border-radius: 10px; }

/* selos */
.selo { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 700; padding: 4px 9px; border-radius: 999px; white-space: nowrap; }
.selo.ok { background: var(--ok-soft); color: var(--ok); }
.selo.off { background: #F3F4F6; color: var(--muted); }
.selo.aviso { background: var(--warn-soft); color: var(--warn); }
.selo.erro { background: var(--danger-soft); color: var(--danger); }
.selo .ponto { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.papel { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--brand-2); background: var(--brand-soft); padding: 3px 7px; border-radius: 6px; }

.aviso-box { border-radius: 12px; padding: 12px 14px; font-size: 14px; }
.aviso-box.aviso { background: var(--warn-soft); color: #78350F; }
.aviso-box.info { background: #EFF6FF; color: #1E3A8A; }
.aviso-box.ok { background: var(--ok-soft); color: #14532D; }

/* login */
.tela-login { min-height: 100dvh; display: grid; place-items: center; padding: 24px; }
.tela-login .card { width: 100%; max-width: 380px; padding: 24px; gap: 16px; }
.marca { display: flex; align-items: center; gap: 12px; }
.marca img { width: 44px; height: 44px; border-radius: 12px; }

/* listas */
.lista { display: grid; gap: 0; }
.item { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-top: 1px solid var(--line); }
.item:first-child { border-top: 0; padding-top: 0; }
.item:last-child { padding-bottom: 0; }
.avatar { width: 40px; height: 40px; border-radius: 50%; background: var(--brand-soft); color: var(--brand-2); display: grid; place-items: center; font-weight: 800; flex: none; overflow: hidden; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.loja-card { cursor: pointer; }
.loja-card:active { background: #FAFAFA; }

/* WhatsApp */
.qr-box { display: grid; justify-items: center; gap: 10px; padding: 8px 0; }
.qr-box img { width: min(280px, 100%); aspect-ratio: 1; image-rendering: pixelated; border-radius: 12px; border: 1px solid var(--line); }
.codigo { font: 800 30px/1 ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .12em; padding: 14px 18px; background: #F3F4F6; border-radius: 12px; }
ol.passos { margin: 0; padding-left: 20px; display: grid; gap: 6px; font-size: 14px; }

/* status */
.abas { display: flex; background: #EEF2F4; border-radius: 12px; padding: 4px; gap: 4px; }
.abas button { flex: 1; border: 0; background: transparent; padding: 9px 6px; border-radius: 9px; font-weight: 700; color: var(--muted); cursor: pointer; }
.abas button.ativo { background: #fff; color: var(--ink); box-shadow: var(--sombra); }
.previa {
  width: min(240px, 70%); aspect-ratio: 9 / 16; margin: 0 auto; border-radius: 18px; overflow: hidden;
  display: grid; place-items: center; text-align: center; padding: 18px; color: #fff; position: relative;
  background: #0F766E; box-shadow: 0 8px 24px rgba(0, 0, 0, .18);
}
.previa .txt { font-size: 20px; line-height: 1.3; white-space: pre-wrap; word-break: break-word; }
.previa img, .previa video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.previa .legenda { position: absolute; left: 0; right: 0; bottom: 0; padding: 14px; background: linear-gradient(transparent, rgba(0,0,0,.65)); font-size: 14px; text-align: center; white-space: pre-wrap; }
.previa.vazia { background: #E5E7EB; color: var(--muted); }
.cores { display: flex; flex-wrap: wrap; gap: 10px; }
.cores button { width: 34px; height: 34px; border-radius: 50%; border: 3px solid #fff; box-shadow: 0 0 0 1px var(--line); cursor: pointer; }
.cores button.ativo { box-shadow: 0 0 0 2px var(--ink); }
.arquivo { border: 2px dashed var(--line); border-radius: 12px; padding: 18px; text-align: center; cursor: pointer; color: var(--muted); font-weight: 600; }
.arquivo input { display: none; }
.hist-thumb { width: 44px; height: 44px; border-radius: 10px; flex: none; overflow: hidden; display: grid; place-items: center; color: #fff; font-size: 10px; font-weight: 700; padding: 4px; text-align: center; line-height: 1.1; }
.hist-thumb img, .hist-thumb video { width: 100%; height: 100%; object-fit: cover; }

/* folha (modal inferior) */
.fundo { position: fixed; inset: 0; background: rgba(17, 24, 39, .45); z-index: 20; display: flex; align-items: flex-end; justify-content: center; animation: aparece .15s ease; }
.folha { background: var(--card); width: 100%; max-width: 560px; border-radius: 20px 20px 0 0; padding: 20px 18px calc(20px + var(--safe-b)); display: grid; gap: 14px; max-height: 90dvh; overflow: auto; animation: sobe .2s ease; }
@media (min-width: 640px) { .fundo { align-items: center; } .folha { border-radius: 20px; } }
@keyframes aparece { from { opacity: 0; } }
@keyframes sobe { from { transform: translateY(24px); opacity: .6; } }

.credenciais { background: #F3F4F6; border-radius: 12px; padding: 12px 14px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 14px; display: grid; gap: 4px; word-break: break-all; }

/* toast */
#toast { position: fixed; left: 50%; bottom: calc(88px + var(--safe-b)); transform: translateX(-50%) translateY(20px); opacity: 0; pointer-events: none; z-index: 30; background: var(--ink); color: #fff; padding: 11px 16px; border-radius: 12px; font-weight: 600; font-size: 14px; max-width: calc(100% - 32px); transition: .2s; text-align: center; }
#toast.on { opacity: 1; transform: translateX(-50%); }
#toast.erro { background: var(--danger); }

/* carregando */
.carregando { min-height: 60dvh; display: grid; place-items: center; }
.spinner { width: 28px; height: 28px; border: 3px solid var(--line); border-top-color: var(--brand); border-radius: 50%; animation: gira .8s linear infinite; }
.btn .spinner { width: 18px; height: 18px; border-width: 2px; border-color: rgba(255,255,255,.4); border-top-color: #fff; }
@keyframes gira { to { transform: rotate(360deg); } }

.vazio { text-align: center; padding: 18px 8px; color: var(--muted); }
.hero { background: linear-gradient(135deg, var(--brand), var(--brand-2)); color: #fff; }
.hero .muted { color: rgba(255,255,255,.8); }
.hero .btn { background: #fff; color: var(--brand-2); }

/* ================= atendimento ================= */
main.largo { max-width: 1280px; padding-bottom: calc(76px + var(--safe-b)); }
main.sem-gap { gap: 10px; }
.corta { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }

.inbox { display: grid; grid-template-columns: 360px 1fr; gap: 14px; height: calc(100dvh - 160px - var(--safe-b)); min-height: 420px; }
.inbox-lista { display: flex; flex-direction: column; gap: 10px; min-height: 0; }
.inbox .inbox-lista { background: var(--card); border-radius: var(--r); box-shadow: var(--sombra); padding: 12px; }
.inbox .convs { overflow-y: auto; flex: 1; margin: 0 -12px; }
.inbox-busca { display: flex; gap: 8px; }
.inbox-busca input { padding: 10px 12px; border: 1px solid var(--line); border-radius: 11px; flex: 1; min-width: 0; outline: none; }
.inbox-busca input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.chips { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chips button { border: 1px solid var(--line); background: #fff; padding: 6px 11px; border-radius: 999px; font-size: 13px; font-weight: 600; color: var(--muted); white-space: nowrap; cursor: pointer; }
.chips button.ativo { background: var(--ink); color: #fff; border-color: var(--ink); }
.chips .sep { width: 1px; background: var(--line); flex: none; margin: 4px 2px; }

.convs { display: grid; align-content: start; }
main:not(.largo) .convs { background: var(--card); border-radius: var(--r); box-shadow: var(--sombra); overflow: hidden; }
.conv { display: flex; gap: 12px; align-items: center; padding: 12px 14px; text-decoration: none; color: inherit; border-top: 1px solid var(--line); position: relative; }
.conv:first-child { border-top: 0; }
.conv:hover { background: #FAFAFA; }
.conv.atual { background: var(--brand-soft); }
.conv .hora { font-size: 12px; color: var(--muted); flex: none; }
.conv.nova .hora { color: var(--brand); font-weight: 700; }
.conv.nova h3 { font-weight: 800; }
.previa-txt { font-size: 13.5px; color: var(--muted); flex: 1; }
.conv.nova .previa-txt { color: var(--ink); }
.badge { background: var(--brand); color: #fff; font-size: 11.5px; font-weight: 800; min-width: 20px; height: 20px; border-radius: 10px; display: grid; place-items: center; padding: 0 6px; flex: none; }
.dono-conv { font-size: 11px; font-weight: 700; color: var(--brand-2); }

/* chat */
.inbox-chat { background: #EFEAE2; border-radius: var(--r); box-shadow: var(--sombra); display: flex; flex-direction: column; min-height: 0; overflow: hidden; }
.inbox-chat.tela-cheia { position: fixed; inset: 0; border-radius: 0; z-index: 15; }
.vazio-chat { flex: 1; display: grid; place-items: center; }
.chat-topo { display: flex; align-items: center; gap: 10px; padding: calc(env(safe-area-inset-top, 0px) + 10px) 12px 10px; background: var(--card); border-bottom: 1px solid var(--line); }
.inbox .chat-topo { padding-top: 10px; }
.chat-topo .avatar { width: 38px; height: 38px; }
.chat-msgs { flex: 1; overflow-y: auto; padding: 12px 12px 6px; display: flex; flex-direction: column; gap: 4px; overscroll-behavior: contain; }
.mais { text-align: center; padding: 6px; }
.dia { text-align: center; margin: 10px 0 6px; }
.dia span { background: rgba(255,255,255,.9); color: #4B5563; font-size: 12px; font-weight: 600; padding: 4px 10px; border-radius: 8px; box-shadow: 0 1px 1px rgba(0,0,0,.06); }
.msg { max-width: min(78%, 520px); padding: 6px 9px 4px; border-radius: 10px; box-shadow: 0 1px 1px rgba(0,0,0,.08); font-size: 14.5px; line-height: 1.38; word-wrap: break-word; }
.msg.ele { align-self: flex-start; background: #fff; border-top-left-radius: 3px; }
.msg.eu { align-self: flex-end; background: #D9FDD3; border-top-right-radius: 3px; }
.msg.sem-fundo { background: transparent; box-shadow: none; }
.msg .txt { white-space: pre-wrap; }
.msg .autor { font-size: 12px; font-weight: 800; color: var(--brand-2); margin-bottom: 1px; }
.msg .meta { font-size: 11px; color: #667781; text-align: right; margin-top: 2px; display: flex; justify-content: flex-end; gap: 4px; align-items: center; }
.msg .midia { display: block; max-width: 100%; max-height: 320px; border-radius: 8px; margin-bottom: 3px; background: #ddd; }
.msg .figurinha { width: 130px; height: 130px; object-fit: contain; }
.msg audio { width: 250px; max-width: 100%; height: 40px; }
.msg .doc { display: flex; align-items: center; gap: 8px; background: rgba(0,0,0,.05); padding: 9px 10px; border-radius: 8px; color: inherit; text-decoration: none; font-weight: 600; }
.tique { font-size: 11px; letter-spacing: -2px; color: #8696A0; }
.tique.lida { color: #53BDEB; }
.tique.erro { color: var(--danger); letter-spacing: 0; font-weight: 800; }

.chat-rodape { background: #F0F2F5; padding: 8px 8px calc(8px + var(--safe-b)); display: grid; gap: 6px; }
.inbox .chat-rodape { padding-bottom: 8px; }
.compositor { display: flex; align-items: flex-end; gap: 6px; }
.compositor textarea { flex: 1; min-height: 44px; max-height: 140px; resize: none; border-radius: 22px; padding: 11px 15px; border: 0; box-shadow: none; line-height: 1.35; }
.compositor textarea:focus { box-shadow: 0 0 0 2px var(--brand-soft); }
.icone-btn { width: 44px; height: 44px; border-radius: 50%; border: 0; background: transparent; font-size: 20px; display: grid; place-items: center; cursor: pointer; flex: none; }
.icone-btn:hover { background: rgba(0,0,0,.05); }
.btn.enviar { width: 44px; height: 44px; min-height: 44px; border-radius: 50%; padding: 0; font-size: 17px; flex: none; }
.sugestoes { display: grid; gap: 2px; }
.sugestoes:empty, .anexo-previa:empty { display: none; }
.sugestoes button { text-align: left; border: 0; background: #fff; padding: 9px 12px; border-radius: 10px; cursor: pointer; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.anexo-previa { background: #fff; border-radius: 12px; padding: 8px; }
.anexo-previa img { width: 48px; height: 48px; object-fit: cover; border-radius: 8px; }
.gravando { display: flex; align-items: center; gap: 10px; background: #fff; border-radius: 22px; padding: 6px 8px 6px 16px; font-weight: 700; }
.gravando[hidden] { display: none; }
.gravando span:nth-child(2) { flex: 1; }
.ponto-rec { width: 10px; height: 10px; border-radius: 50%; background: var(--danger); animation: pisca 1s infinite; }
@keyframes pisca { 50% { opacity: .25; } }
.compositor[hidden] { display: none; }
.opcao { width: 100%; text-align: left; background: none; border: 0; border-top: 1px solid var(--line); padding: 14px 4px; font-size: 15px; cursor: pointer; }
.opcao.ativo { color: var(--brand); font-weight: 800; }
body.em-chat .nav, body.em-chat .topo { display: none; }

@media (max-width: 899px) {
  .chat-topo .btn.mini { padding: 6px 9px; }
}
main > * { min-width: 0; }
.inbox-lista, .inbox-chat { min-width: 0; }

/* ================= etiquetas, loja e relatório ================= */
.et { --c: #0F766E; display: inline-flex; align-items: center; gap: 4px; font-size: 11.5px; font-weight: 700; line-height: 1; padding: 4px 8px 4px 7px; border-radius: 6px;
  color: var(--c); background: color-mix(in srgb, var(--c) 12%, white); border: 1px solid color-mix(in srgb, var(--c) 25%, white); white-space: nowrap; }
.et::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: var(--c); }
.mini-selo { font-size: 11px; padding: 3px 7px; }
.chat-faixa { display: flex; flex-wrap: wrap; gap: 6px; padding: 7px 12px; background: #fff; border-bottom: 1px solid var(--line); align-items: center; }
.chat-faixa[hidden] { display: none; }
.origem { font-size: 12px; font-weight: 700; color: #1E3A8A; background: #EFF6FF; padding: 4px 8px; border-radius: 6px; }
.chat-topo #etq { padding: 6px 8px; }
.chat-topo #etq svg { width: 18px; height: 18px; }

.menu { padding: 4px 16px; gap: 0; }
.menu-item { display: flex; align-items: center; gap: 12px; padding: 14px 0; border-top: 1px solid var(--line); text-decoration: none; color: inherit; }
.menu-item:first-child { border-top: 0; }
.menu-ic { width: 38px; height: 38px; border-radius: 10px; background: var(--brand-soft); color: var(--brand-2); display: grid; place-items: center; flex: none; }
.menu-ic svg { width: 20px; height: 20px; }
.seta { color: var(--muted); font-size: 22px; }

.kpis { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
@media (min-width: 640px) { .kpis { grid-template-columns: repeat(4, 1fr); } }
.kpi { background: var(--card); border-radius: var(--r); box-shadow: var(--sombra); padding: 14px; display: grid; gap: 2px; }
.card .kpi { box-shadow: none; background: #F6F7F9; }
.kpi b { font-size: 26px; line-height: 1.1; }
.kpi span { font-size: 13px; font-weight: 600; color: #374151; }
.kpi small { font-size: 11.5px; color: var(--muted); }
.barras { display: grid; gap: 14px; }
.barra-linha { display: grid; gap: 6px; }
.barra { position: relative; height: 10px; background: #F1F3F5; border-radius: 6px; overflow: hidden; }
.barra span { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 6px; opacity: .35; }
.barra span.vendida { background: var(--ok); opacity: 1; }
.num { display: grid; justify-items: center; min-width: 48px; }
.num b { font-size: 18px; }
.num small { font-size: 11px; color: var(--muted); }
.opcao .et { font-size: 13px; }
label.item.check { cursor: pointer; }

/* filtros quebram linha em vez de esconder opções (ex: "Resolvidas" cortado no computador) */
.inbox-lista .chips { flex-wrap: wrap; overflow: visible; }
.inbox-lista .chips .sep { display: none; }
