:root {
  --bg: #f3f5f8; --painel: #ffffff; --borda: #e3e7ee; --texto: #1d2433; --suave: #667085; --fraco: #98a2b3;
  --pri: #1e3a6e; --pri-esc: #142850; --pri-claro: #e6ecf7; --azul: #2563eb; --verm: #d92d20; --verm-claro: #fef3f2;
  --amar: #b54708; --amar-claro: #fffaeb; --verde: #067647; --verde-claro: #ecfdf3; --in: #ffffff; --out: #dbe5f5;
  --sombra: 0 1px 2px rgba(16,24,40,.06), 0 1px 3px rgba(16,24,40,.08); --raio: 10px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; color: var(--texto); background: var(--bg); }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--azul); }
h1 { font-size: 20px; margin: 0 0 16px; }
h2 { font-size: 16px; margin: 0 0 12px; }
h3 { font-size: 14px; margin: 0 0 8px; }

/* layout */
.casca { display: grid; grid-template-columns: 210px 1fr; height: 100vh; }
.lateral { background: #0b0d12; color: #d6dbe5; display: flex; flex-direction: column; padding: 14px 10px; gap: 2px; }
.marca { display: flex; align-items: center; gap: 9px; font-weight: 700; font-size: 16px; color: #fff; padding: 4px 8px 16px; }
.marca i { width: 28px; height: 28px; border-radius: 8px; background: var(--pri); display: grid; place-items: center; font-style: normal; }
.lateral a { color: inherit; text-decoration: none; padding: 9px 10px; border-radius: 8px; display: flex; gap: 10px; align-items: center; }
.lateral a:hover { background: rgba(255,255,255,.07); }
.lateral a.ativo { background: var(--pri); color: #fff; }
.lateral .rodape { margin-top: auto; font-size: 12px; color: #8b93a5; padding: 8px; }
.principal { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.topo { height: 56px; background: var(--painel); border-bottom: 1px solid var(--borda); display: flex; align-items: center; gap: 12px; padding: 0 18px; flex-shrink: 0; }
.topo .titulo { font-weight: 600; font-size: 15px; }
.topo .espaco { flex: 1; }
.conteudo { flex: 1; overflow: auto; padding: 20px; min-height: 0; }
.conteudo.cheio { padding: 0; overflow: hidden; }

/* componentes */
.btn { border: 1px solid var(--borda); background: #fff; padding: 7px 13px; border-radius: 8px; cursor: pointer; font-weight: 500; white-space: nowrap; }
.btn:hover { background: #f7f8fa; }
.btn.pri { background: var(--pri); border-color: var(--pri); color: #fff; }
.btn.pri:hover { background: var(--pri-esc); }
.btn.perigo { color: var(--verm); border-color: #fecdca; }
.btn.perigo:hover { background: var(--verm-claro); }
.btn.peq { padding: 4px 9px; font-size: 13px; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.campo { display: flex; flex-direction: column; gap: 4px; margin-bottom: 12px; }
.campo label { font-size: 12.5px; color: var(--suave); font-weight: 500; }
.campo small { color: var(--fraco); font-size: 12px; }
input[type=text], input[type=password], input[type=number], input[type=date], input[type=time], input[type=search], input[type=tel], select, textarea {
  border: 1px solid var(--borda); border-radius: 8px; padding: 8px 10px; background: #fff; width: 100%; outline: none; }
input:focus, select:focus, textarea:focus { border-color: var(--pri); box-shadow: 0 0 0 3px var(--pri-claro); }
textarea { resize: vertical; min-height: 70px; }
.linha { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; }
.linha > .campo { flex: 1; min-width: 140px; }
.cartao { background: var(--painel); border: 1px solid var(--borda); border-radius: var(--raio); padding: 16px; box-shadow: var(--sombra); }
.cartao + .cartao { margin-top: 16px; }
.grade { display: grid; gap: 14px; }
.g4 { grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); }
.g3 { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.kpi { background: var(--painel); border: 1px solid var(--borda); border-radius: var(--raio); padding: 14px 16px; box-shadow: var(--sombra); }
.kpi .rot { font-size: 12.5px; color: var(--suave); }
.kpi .val { font-size: 24px; font-weight: 700; margin-top: 4px; font-variant-numeric: tabular-nums; }
.kpi .sub { font-size: 12px; color: var(--fraco); }
table.tab { width: 100%; border-collapse: collapse; background: #fff; }
.tab th { text-align: left; font-size: 12px; color: var(--suave); font-weight: 600; padding: 8px 10px; border-bottom: 1px solid var(--borda); background: #fafbfc; white-space: nowrap; }
.tab td { padding: 9px 10px; border-bottom: 1px solid #f0f2f5; vertical-align: middle; }
.tab tr:hover td { background: #fafcfc; }
.tab td.num, .tab th.num { text-align: right; font-variant-numeric: tabular-nums; }
.rolagem { overflow: auto; border: 1px solid var(--borda); border-radius: var(--raio); }
.etq { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; padding: 2px 8px; border-radius: 999px; background: #f2f4f7; color: #344054; white-space: nowrap; font-weight: 500; }
.etq.verde { background: var(--verde-claro); color: var(--verde); }
.etq.verm { background: var(--verm-claro); color: var(--verm); }
.etq.amar { background: var(--amar-claro); color: var(--amar); }
.etq.azul { background: #eff4ff; color: #3538cd; }
.bola { width: 8px; height: 8px; border-radius: 50%; display: inline-block; background: var(--fraco); }
.bola.online, .bola.conectado { background: #12b76a; }
.bola.pausa, .bola.conectando, .bola.aguardando_leitura { background: #f79009; }
.bola.banido { background: var(--verm); }
.vazio { color: var(--fraco); text-align: center; padding: 30px 10px; }
.barra { height: 8px; background: #eef1f4; border-radius: 99px; overflow: hidden; }
.barra > i { display: block; height: 100%; background: var(--pri); }
.dica { background: #f0f9ff; border: 1px solid #b9e6fe; color: #075985; padding: 10px 12px; border-radius: 8px; font-size: 13px; }
.aviso { background: var(--amar-claro); border: 1px solid #fedf89; color: #93370d; padding: 10px 12px; border-radius: 8px; font-size: 13px; }
.abas { display: flex; gap: 4px; border-bottom: 1px solid var(--borda); margin-bottom: 16px; flex-wrap: wrap; }
.abas button { border: 0; background: none; padding: 9px 14px; cursor: pointer; border-bottom: 2px solid transparent; color: var(--suave); font-weight: 500; }
.abas button.ativo { color: var(--pri); border-bottom-color: var(--pri); }
.cab { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; }
.cab h1 { margin: 0; }
.cab .espaco { flex: 1; }
code, .mono { font-family: ui-monospace, Consolas, monospace; font-size: 12.5px; }
pre.codigo { background: #0f172a; color: #e2e8f0; padding: 12px; border-radius: 8px; overflow: auto; font-size: 12.5px; }

/* status do operador */
.status-pilula { display: flex; align-items: center; gap: 8px; padding: 6px 12px; border: 1px solid var(--borda); border-radius: 999px; cursor: pointer; background: #fff; font-weight: 500; position: relative; }
.menu-sus { position: absolute; top: calc(100% + 6px); right: 0; background: #fff; border: 1px solid var(--borda); border-radius: 10px; box-shadow: 0 10px 30px rgba(0,0,0,.12); min-width: 220px; z-index: 50; padding: 6px; }
.menu-sus button { display: flex; width: 100%; text-align: left; border: 0; background: none; padding: 8px 10px; border-radius: 6px; cursor: pointer; gap: 8px; align-items: center; }
.menu-sus button:hover { background: #f4f6f8; }
.menu-sus hr { border: 0; border-top: 1px solid var(--borda); margin: 4px 0; }
.faixa-pausa { background: #fff4e5; border-bottom: 1px solid #fedf89; padding: 10px 18px; display: flex; align-items: center; gap: 12px; font-weight: 500; color: #93370d; }
.faixa-pausa.estourou { background: var(--verm-claro); color: var(--verm); border-color: #fecdca; }
.faixa-pausa .tempo { font-variant-numeric: tabular-nums; font-size: 16px; font-weight: 700; }

/* atendimento */
.atend { display: grid; grid-template-columns: 320px 1fr 300px; height: 100%; min-height: 0; }
.lista { border-right: 1px solid var(--borda); background: #fff; display: flex; flex-direction: column; min-height: 0; }
.lista .abas { margin: 0; padding: 0 6px; }
.lista .abas button { padding: 10px 8px; font-size: 13px; }
.lista .busca { padding: 10px; border-bottom: 1px solid var(--borda); display: flex; gap: 6px; }
.itens { overflow: auto; flex: 1; }
.item { padding: 11px 12px; border-bottom: 1px solid #f0f2f5; cursor: pointer; display: flex; gap: 10px; }
.item:hover { background: #f8fafb; }
.item.sel { background: var(--pri-claro); }
.avatar { width: 38px; height: 38px; border-radius: 50%; background: #d5deef; color: var(--pri-esc); display: grid; place-items: center; font-weight: 700; flex-shrink: 0; }
.item .meio { flex: 1; min-width: 0; }
.item .nome { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item .prev { color: var(--suave); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item .dir { text-align: right; font-size: 11.5px; color: var(--fraco); display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.cont { background: var(--pri); color: #fff; border-radius: 999px; font-size: 11px; padding: 1px 7px; font-weight: 700; }
.chat { display: flex; flex-direction: column; min-height: 0; background: #efeae2; }
.chat .cab-chat { background: #fff; border-bottom: 1px solid var(--borda); padding: 10px 14px; display: flex; align-items: center; gap: 10px; }
.chat .cab-chat .info { flex: 1; min-width: 0; }
.chat .cab-chat .info b { display: block; }
.chat .cab-chat .info span { font-size: 12.5px; color: var(--suave); }
.msgs { flex: 1; overflow: auto; padding: 16px 6%; display: flex; flex-direction: column; gap: 4px; }
.msg { max-width: 72%; padding: 7px 10px 5px; border-radius: 8px; box-shadow: 0 1px .5px rgba(11,20,26,.13); background: var(--in); align-self: flex-start; white-space: pre-wrap; word-wrap: break-word; position: relative; }
.msg.out { background: var(--out); align-self: flex-end; }
.msg.bot, .msg.campanha, .msg.api { background: #e6f0ff; }
.msg .meta { font-size: 11px; color: #667781; text-align: right; margin-top: 2px; display: flex; gap: 6px; justify-content: flex-end; align-items: center; }
.msg .autor { font-size: 11.5px; font-weight: 600; color: var(--pri-esc); margin-bottom: 2px; }
.msg.falha { border: 1px solid var(--verm); }
.msg img, .msg video { max-width: 280px; max-height: 320px; border-radius: 6px; display: block; margin-bottom: 4px; cursor: pointer; }
.msg audio { width: 260px; }
.sis { align-self: center; background: #fff8d6; color: #54656f; font-size: 12px; padding: 4px 10px; border-radius: 7px; margin: 6px 0; text-align: center; max-width: 85%; }
.dia { align-self: center; background: #fff; color: #54656f; font-size: 12px; padding: 4px 10px; border-radius: 7px; margin: 8px 0; box-shadow: 0 1px .5px rgba(11,20,26,.13); }
.compor { background: #f0f2f5; padding: 10px 14px; display: flex; gap: 8px; align-items: flex-end; position: relative; }
.compor textarea { min-height: 42px; max-height: 160px; border-radius: 10px; resize: none; }
.rapidas { position: absolute; bottom: 100%; left: 14px; right: 14px; background: #fff; border: 1px solid var(--borda); border-radius: 10px; box-shadow: 0 -8px 24px rgba(0,0,0,.1); max-height: 260px; overflow: auto; }
.rapidas div { padding: 8px 12px; cursor: pointer; border-bottom: 1px solid #f2f4f7; }
.rapidas div:hover, .rapidas div.sel { background: var(--pri-claro); }
.rapidas b { color: var(--pri-esc); margin-right: 8px; }
.detalhe { border-left: 1px solid var(--borda); background: #fff; overflow: auto; padding: 14px; }
.detalhe .bloco { margin-bottom: 18px; }
.detalhe .par { display: flex; justify-content: space-between; gap: 8px; font-size: 13px; padding: 3px 0; }
.detalhe .par span:first-child { color: var(--suave); }
.chat-vazio { flex: 1; display: grid; place-items: center; color: var(--suave); text-align: center; }

/* modal / toast */
.fundo-modal { position: fixed; inset: 0; background: rgba(16,24,40,.45); display: grid; place-items: center; z-index: 100; padding: 16px; }
.modal { background: #fff; border-radius: 14px; width: min(560px, 100%); max-height: 92vh; overflow: auto; box-shadow: 0 20px 50px rgba(0,0,0,.25); }
.modal.largo { width: min(900px, 100%); }
.modal .mcab { padding: 16px 18px; border-bottom: 1px solid var(--borda); display: flex; align-items: center; }
.modal .mcab h2 { margin: 0; flex: 1; }
.modal .mcorpo { padding: 18px; }
.modal .mrod { padding: 12px 18px; border-top: 1px solid var(--borda); display: flex; justify-content: flex-end; gap: 8px; }
.x { border: 0; background: none; font-size: 22px; cursor: pointer; color: var(--suave); line-height: 1; }
#toasts { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 200; }
.toast { background: #1d2433; color: #fff; padding: 10px 14px; border-radius: 9px; box-shadow: 0 8px 20px rgba(0,0,0,.2); max-width: 380px; }
.toast.erro { background: var(--verm); }
.toast.ok { background: var(--verde); }

/* login */
.login { min-height: 100vh; display: grid; place-items: center; background: linear-gradient(135deg, #0b0d12, #1e3a6e); padding: 16px; }
.login .cartao { width: min(380px, 100%); padding: 28px; }
.login h1 { display: flex; align-items: center; gap: 10px; }

/* chips */
.chip-card { display: flex; flex-direction: column; gap: 10px; }
.chip-card .topo-chip { display: flex; align-items: center; gap: 10px; }
.chip-card .topo-chip b { flex: 1; }
.codigo-pareamento { font-size: 38px; font-weight: 800; letter-spacing: 6px; text-align: center; font-family: ui-monospace, Consolas, monospace; background: var(--pri-claro); color: var(--pri-esc); padding: 18px; border-radius: 12px; margin: 12px 0; }
.qr { display: grid; place-items: center; padding: 10px; }
ol.passos { padding-left: 20px; margin: 8px 0; }
ol.passos li { margin-bottom: 5px; }

/* fluxo do bot */
.etapa { border: 1px solid var(--borda); border-radius: 10px; padding: 12px; background: #fff; margin-bottom: 12px; }
.etapa.inicio { border-color: var(--pri); box-shadow: 0 0 0 2px var(--pri-claro); }
.etapa .ecab { display: flex; gap: 8px; align-items: center; margin-bottom: 10px; flex-wrap: wrap; }
.opcao { display: grid; grid-template-columns: 60px 1fr 160px 150px 32px; gap: 6px; margin-bottom: 6px; }
.vars button { margin: 0 4px 4px 0; }
.barras-hora { display: flex; align-items: flex-end; gap: 4px; height: 140px; padding-top: 10px; }
.barras-hora div { flex: 1; background: var(--pri); border-radius: 4px 4px 0 0; min-height: 2px; position: relative; }
.barras-hora div span { position: absolute; bottom: -18px; left: 50%; transform: translateX(-50%); font-size: 10px; color: var(--fraco); }
.barras-hora div em { position: absolute; top: -16px; left: 50%; transform: translateX(-50%); font-size: 10px; font-style: normal; color: var(--suave); }

@media (max-width: 1100px) { .atend { grid-template-columns: 280px 1fr; } .detalhe { display: none; } }
@media (max-width: 760px) {
  .casca { grid-template-columns: 1fr; }
  .lateral { flex-direction: row; overflow-x: auto; padding: 6px; }
  .lateral .marca, .lateral .rodape { display: none; }
  .atend { grid-template-columns: 1fr; }
  .atend.com-chat .lista { display: none; }
  .atend:not(.com-chat) .chat { display: none; }
  .conteudo { padding: 12px; }
}

/* ---- ambientes (operador x gestão) ---- */
.lateral .ambiente { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; padding: 4px 10px 8px; color: #8b93a5; }
.lateral .ambiente.operador { color: #9db5e0; }
.lateral .secao { font-size: 10.5px; text-transform: uppercase; letter-spacing: .08em; color: #6b7489; padding: 12px 10px 4px; }
/* ---- API oficial ---- */
.faixa-janela { background: var(--pri-claro); color: var(--pri-esc); font-size: 12.5px; padding: 6px 14px; border-top: 1px solid var(--borda); }
.botoes-msg { display: flex; flex-direction: column; gap: 4px; margin-top: 8px; border-top: 1px solid rgba(0,0,0,.08); padding-top: 6px; }
.botoes-msg span { display: block; text-align: center; color: #027eb5; font-weight: 600; font-size: 13.5px; padding: 4px; cursor: pointer; white-space: normal; }
/* ---- pré-visualização "como chega no celular" ---- */
.celular-previa { background: #efeae2; border-radius: 10px; padding: 12px; display: flex; flex-direction: column; gap: 10px; min-height: 60px; }
.celular-msg { display: flex; flex-direction: column; }
.celular-msg .quem { font-size: 11px; color: #667781; margin-bottom: 3px; align-self: flex-start; }
.celular-msg .msg { max-width: 100%; align-self: flex-start; background: var(--in); }
.celular-msg a, .msg a { color: #027eb5; word-break: break-all; }
/* ---- simulador ---- */
.celular { background: #efeae2; border: 8px solid #1d2433; border-radius: 28px; overflow: hidden; display: flex; flex-direction: column; height: 620px; max-height: 78vh; }
.cel-topo { background: #1e3a6e; color: #fff; display: flex; gap: 10px; align-items: center; padding: 10px 12px; }
.cel-topo small { display: block; opacity: .8; font-size: 11.5px; }
.cel-topo .avatar { background: #ffffff33; color: #fff; }
.cel-msgs { flex: 1; overflow-y: auto; padding: 12px; display: flex; flex-direction: column; gap: 6px; }
.cel-msgs .msg { max-width: 85%; }
.cel-msgs .msg.in { background: var(--in); align-self: flex-start; }
.cel-msgs .msg.out { background: var(--out); align-self: flex-end; }
.cel-compor { display: flex; gap: 6px; padding: 8px; background: #f0f2f5; }
.cel-compor input { flex: 1; border-radius: 20px; }

/* ---- fluxograma ---- */
.fluxograma { display: flex; flex-direction: column; align-items: center; padding: 8px 0; overflow-x: auto; }
.fluxograma div:not(.fx-caixa):not(.fx-seta):not(.fx-ramos) { display: flex; flex-direction: column; align-items: center; }
.fx-caixa { background: #fff; border: 1.5px solid var(--pri); border-radius: 10px; padding: 8px 12px; max-width: 320px; text-align: center; box-shadow: var(--sombra); }
.fx-caixa b { display: block; font-size: 13px; color: var(--pri-esc); }
.fx-caixa span { display: block; font-size: 12px; color: var(--suave); white-space: pre-wrap; margin-top: 2px; }
.fx-caixa.cliente { background: var(--pri); border-color: var(--pri); } .fx-caixa.cliente b, .fx-caixa.cliente span { color: #fff; }
.fx-caixa.fila { border-color: var(--amar); background: var(--amar-claro); } .fx-caixa.fila b { color: var(--amar); }
.fx-caixa.fim { border-color: var(--verde); background: var(--verde-claro); } .fx-caixa.fim b { color: var(--verde); }
.fx-caixa.volta { border-style: dashed; }
.fx-seta { width: 2px; min-height: 26px; background: var(--pri); position: relative; display: flex; align-items: center; margin: 0 auto; }
.fx-seta::after { content: ''; position: absolute; bottom: -1px; left: -4px; border: 5px solid transparent; border-top-color: var(--pri); border-bottom: 0; }
.fx-seta small { position: absolute; left: 8px; white-space: nowrap; font-size: 11.5px; color: var(--pri-esc); font-weight: 600; background: #fff; padding: 0 4px; }
.fx-ramos { display: flex; gap: 26px; align-items: flex-start; justify-content: center; }
.fx-ramos > div > .fx-seta { min-height: 34px; }