:root {
  --bg: #f3f5f9;
  --card: #ffffff;
  --texto: #1b2333;
  --texto-2: #5b6577;
  --texto-3: #8b95a8;
  --borda: #e1e6ef;
  --hover: #f5f7fb;
  --primaria: #0a1f44;
  --primaria-2: #1a3b70;
  --destaque: #ffcc00;
  --destaque-texto: #0a1f44;
  --verde: #4f8f00;
  --verde-bg: #edf7dc;
  --vermelho: #c93b3b;
  --vermelho-bg: #fdecec;
  --amarelo: #a86f00;
  --amarelo-bg: #fff4d1;
  --azul: #1a3b70;
  --azul-bg: #e6edf9;
  --neutro: #5b6577;
  --neutro-bg: #eef1f6;
  --lateral: #0a1f44;
  --lateral-texto: #c9d3e6;
  --lateral-ativo: rgba(255, 255, 255, 0.12);
  --bolha-recebida: #ffffff;
  --bolha-enviada: #e6edf9;
  --raio: 12px;
  --sombra: 0 1px 2px rgba(10, 31, 68, 0.05), 0 6px 20px rgba(10, 31, 68, 0.05);
  --fonte: "Segoe UI", system-ui, -apple-system, Roboto, Helvetica, Arial, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f141f;
    --card: #161c2a;
    --texto: #e8ecf4;
    --texto-2: #a3adc2;
    --texto-3: #6f7a90;
    --borda: #273046;
    --hover: #1c2434;
    --verde: #9bd64a;
    --verde-bg: #1c2a12;
    --vermelho: #ff8585;
    --vermelho-bg: #3a1c1c;
    --amarelo: #f0c04a;
    --amarelo-bg: #3a2f10;
    --azul: #93b4f2;
    --azul-bg: #1a2740;
    --neutro: #a3adc2;
    --neutro-bg: #212a3a;
    --lateral: #0a1224;
    --bolha-recebida: #1c2434;
    --bolha-enviada: #1a2740;
    --sombra: 0 1px 2px rgba(0, 0, 0, 0.3), 0 6px 20px rgba(0, 0, 0, 0.25);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0f141f;
  --card: #161c2a;
  --texto: #e8ecf4;
  --texto-2: #a3adc2;
  --texto-3: #6f7a90;
  --borda: #273046;
  --hover: #1c2434;
  --verde: #9bd64a;
  --verde-bg: #1c2a12;
  --vermelho: #ff8585;
  --vermelho-bg: #3a1c1c;
  --amarelo: #f0c04a;
  --amarelo-bg: #3a2f10;
  --azul: #93b4f2;
  --azul-bg: #1a2740;
  --neutro: #a3adc2;
  --neutro-bg: #212a3a;
  --lateral: #0a1224;
  --bolha-recebida: #1c2434;
  --bolha-enviada: #1a2740;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body { font-family: var(--fonte); background: var(--bg); color: var(--texto); font-size: 15px; line-height: 1.45; -webkit-font-smoothing: antialiased; }
a { color: var(--primaria-2); }
h2 { font-size: 17px; margin: 0 0 14px; }
h3 { font-size: 15px; margin: 18px 0 8px; }
code { font-family: Consolas, Menlo, monospace; font-size: 13px; background: var(--neutro-bg); padding: 1px 6px; border-radius: 6px; }
.ic { width: 20px; height: 20px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: 0 0 auto; }
.texto-2 { color: var(--texto-2); }
.pequeno { font-size: 13px; }
.ajuda { color: var(--texto-2); font-size: 13px; margin: 4px 0 14px; }
[hidden] { display: none !important; }

/* ---------- estrutura ---------- */
.app { display: flex; min-height: 100vh; }
.lateral { width: 250px; flex: 0 0 250px; background: var(--lateral); color: var(--lateral-texto); display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; padding: 20px 14px 16px; transition: transform 0.2s ease; z-index: 20; }
.lateral-topo { padding: 4px 8px 18px; border-bottom: 1px solid rgba(255, 255, 255, 0.08); margin-bottom: 12px; }
.lateral-logo { display: block; width: 168px; height: auto; background: #0b0b0b; border-radius: 10px; padding: 12px 16px; }
.lateral-sub { display: block; margin-top: 12px; font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; color: #8fa0c2; font-weight: 600; }
.menu { display: flex; flex-direction: column; gap: 4px; }
.menu a { display: flex; align-items: center; gap: 12px; padding: 11px 12px; border-radius: 10px; color: var(--lateral-texto); text-decoration: none; font-weight: 500; }
.menu a:hover { background: rgba(255, 255, 255, 0.06); color: #fff; }
.menu a.ativo { background: var(--lateral-ativo); color: #fff; }
.badge { margin-left: auto; background: var(--destaque); color: #0a1f44; font-size: 12px; font-weight: 700; min-width: 22px; text-align: center; padding: 2px 7px; border-radius: 999px; line-height: 1.3; }
.lateral-rodape { margin-top: auto; padding: 14px 4px 0; display: flex; flex-direction: column; gap: 14px; border-top: 1px solid rgba(255, 255, 255, 0.08); }
.btn-sair { display: flex; align-items: center; gap: 10px; background: none; border: 0; color: var(--lateral-texto); font: inherit; font-weight: 500; cursor: pointer; padding: 8px 10px; border-radius: 10px; }
.btn-sair:hover { background: rgba(255, 255, 255, 0.06); color: #fff; }
.selo { display: flex; align-items: center; gap: 8px; font-size: 11px; color: #8fa0c2; text-decoration: none; padding: 0 10px; }
.selo img { height: 16px; width: auto; opacity: 0.75; filter: invert(1); }
.selo-escuro { color: var(--texto-3); justify-content: center; margin-top: 18px; }
.principal { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topo { display: flex; align-items: center; gap: 12px; padding: 16px 28px; border-bottom: 1px solid var(--borda); background: var(--card); position: sticky; top: 0; z-index: 5; }
.topo h1 { font-size: 20px; margin: 0; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#acoes-tela { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.conteudo { padding: 24px 28px 48px; width: 100%; max-width: 1440px; }
.btn-icone { display: none; background: none; border: 0; color: var(--texto); padding: 6px; border-radius: 8px; cursor: pointer; }
.cortina { display: none; position: fixed; inset: 0; background: rgba(0, 0, 0, 0.45); z-index: 19; }

/* ---------- botões e campos ---------- */
.btn { display: inline-flex; align-items: center; gap: 8px; padding: 10px 16px; border-radius: 10px; border: 1px solid transparent; font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; line-height: 1.2; white-space: nowrap; transition: background 0.15s, border-color 0.15s; }
.btn .ic { width: 18px; height: 18px; }
.btn:disabled { opacity: 0.55; cursor: default; }
.btn-primario { background: var(--primaria); color: #fff; }
.btn-primario:hover:not(:disabled) { background: var(--primaria-2); }
.btn-destaque { background: var(--destaque); color: var(--destaque-texto); }
.btn-destaque:hover:not(:disabled) { background: #ffd83a; }
.btn-claro { background: var(--card); color: var(--texto); border-color: var(--borda); }
.btn-claro:hover:not(:disabled) { background: var(--hover); }
.btn-perigo { background: var(--vermelho); color: #fff; }
.btn-perigo-suave { color: var(--vermelho); }
.btn-sm { padding: 7px 10px; font-size: 13px; }
.btn-largo { width: 100%; justify-content: center; padding: 13px; }
.campo { display: flex; flex-direction: column; gap: 6px; margin: 0 0 14px; }
.campo > span { font-size: 13px; font-weight: 600; color: var(--texto-2); }
.campo > span small { font-weight: 400; }
.entrada { width: 100%; padding: 10px 12px; border: 1px solid var(--borda); border-radius: 10px; background: var(--card); color: var(--texto); font: inherit; }
.entrada:focus { outline: 2px solid var(--primaria-2); outline-offset: 1px; border-color: var(--primaria-2); }
textarea.entrada { resize: vertical; min-height: 120px; line-height: 1.5; }
select.entrada { appearance: none; -webkit-appearance: none; padding-right: 34px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%235b6577' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 0 16px; }
.acoes-form { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.copiar { display: flex; gap: 6px; }
.copiar .entrada { font-family: Consolas, Menlo, monospace; font-size: 12px; }

/* ---------- blocos ---------- */
.painel { background: var(--card); border: 1px solid var(--borda); border-radius: var(--raio); padding: 20px 22px; box-shadow: var(--sombra); margin-bottom: 18px; }
.cartoes { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; margin-bottom: 18px; }
.cartao { background: var(--card); border: 1px solid var(--borda); border-radius: var(--raio); padding: 16px 18px; box-shadow: var(--sombra); display: flex; gap: 14px; align-items: flex-start; }
.cartao .ic { width: 22px; height: 22px; color: var(--primaria-2); margin-top: 3px; }
.cartao-rotulo { font-size: 13px; color: var(--texto-2); font-weight: 600; }
.cartao-valor { font-size: 26px; font-weight: 700; line-height: 1.2; margin: 2px 0; }
.cartao-sub { font-size: 12px; color: var(--texto-3); }
.grade-2 { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 18px; align-items: start; }
.grade-editor { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 18px; align-items: start; }
.alerta { display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px; border-radius: var(--raio); background: var(--amarelo-bg); color: var(--texto); border: 1px solid transparent; margin-bottom: 18px; }
.alerta .ic { color: var(--amarelo); margin-top: 2px; }
.alerta ul { margin: 6px 0 0; padding-left: 18px; }
.alerta-erro { background: var(--vermelho-bg); }
.alerta-erro .ic { color: var(--vermelho); }
.alerta-info { background: var(--azul-bg); }
.alerta-info .ic { color: var(--azul); }
.vazio { text-align: center; padding: 48px 20px; color: var(--texto-2); }
.vazio .ic { width: 40px; height: 40px; color: var(--texto-3); stroke-width: 1.5; }
.vazio p { margin: 12px auto 16px; max-width: 460px; }
.vazio.pequeno { padding: 28px 12px; }
.carregando { display: flex; align-items: center; gap: 10px; color: var(--texto-2); padding: 24px 0; }
.giro { width: 18px; height: 18px; border: 2px solid var(--borda); border-top-color: var(--primaria-2); border-radius: 50%; animation: giro 0.8s linear infinite; }
@keyframes giro { to { transform: rotate(360deg); } }
.selo-status, .selo-ok, .selo-erro, .selo-alerta, .selo-info, .selo-neutro { display: inline-block; padding: 3px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.selo-ok { background: var(--verde-bg); color: var(--verde); }
.selo-erro { background: var(--vermelho-bg); color: var(--vermelho); }
.selo-alerta { background: var(--amarelo-bg); color: var(--amarelo); }
.selo-info { background: var(--azul-bg); color: var(--azul); }
.selo-neutro { background: var(--neutro-bg); color: var(--neutro); }
.progresso { height: 10px; background: var(--neutro-bg); border-radius: 999px; overflow: hidden; margin: 10px 0 8px; }
.progresso.grande { height: 14px; }
.progresso-barra { height: 100%; background: linear-gradient(90deg, var(--primaria-2), var(--verde)); border-radius: 999px; transition: width 0.4s ease; }
.lista-resumo { list-style: none; padding: 0; margin: 0; }
.lista-resumo li { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--borda); }
.lista-resumo li:last-child { border-bottom: 0; }
.lista-resumo .ic { color: var(--primaria-2); }

/* ---------- tabelas ---------- */
.barra { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.busca { display: flex; align-items: center; gap: 8px; flex: 1 1 260px; background: var(--card); border: 1px solid var(--borda); border-radius: 10px; padding: 0 12px; }
.busca .ic { color: var(--texto-3); width: 18px; height: 18px; }
.busca input { flex: 1; border: 0; background: none; padding: 10px 0; font: inherit; color: var(--texto); min-width: 0; }
.busca input:focus { outline: none; }
.barra select.entrada { width: auto; min-width: 180px; }
.contagem { color: var(--texto-2); font-size: 13px; margin-left: auto; }
.tabela-rolagem { overflow-x: auto; margin: -6px -10px 0; padding: 0 10px; }
.tabela { width: 100%; border-collapse: collapse; font-size: 14px; }
.tabela th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--texto-3); padding: 10px 10px; border-bottom: 1px solid var(--borda); white-space: nowrap; }
.tabela td { padding: 12px 10px; border-bottom: 1px solid var(--borda); vertical-align: middle; }
.tabela tbody tr[data-id] { cursor: pointer; }
.tabela tbody tr[data-id]:hover td { background: var(--hover); }
.tabela tbody tr:last-child td { border-bottom: 0; }
.tabela-compacta th, .tabela-compacta td { padding: 7px 8px; font-size: 13px; }
.paginacao { display: flex; align-items: center; justify-content: flex-end; gap: 10px; padding-top: 12px; font-size: 13px; color: var(--texto-2); }
.ficha dl { display: grid; grid-template-columns: 130px 1fr; gap: 6px 12px; margin: 0 0 14px; font-size: 14px; }
.ficha dt { color: var(--texto-2); }
.ficha dd { margin: 0; word-break: break-word; }

/* ---------- editor de disparo ---------- */
.previa { position: sticky; top: 84px; padding: 0; overflow: hidden; }
.previa-topo { display: flex; gap: 10px; align-items: baseline; padding: 12px 16px; border-bottom: 1px solid var(--borda); font-size: 14px; }
.previa-topo span { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.previa iframe { display: block; width: 100%; height: calc(100vh - 170px); min-height: 520px; border: 0; background: #eef1f6; }
.previa-dialogo { width: 100%; height: 70vh; border: 0; background: #eef1f6; border-radius: 8px; }
.cabecalho-disparo { display: flex; justify-content: space-between; gap: 16px; align-items: flex-start; flex-wrap: wrap; }
.cabecalho-disparo h2 { font-size: 18px; margin: 0 0 6px; }
.cabecalho-disparo p { margin: 0; }
.arquivo { display: flex; align-items: center; justify-content: center; gap: 10px; padding: 26px 16px; border: 2px dashed var(--borda); border-radius: var(--raio); cursor: pointer; color: var(--primaria-2); font-weight: 600; background: var(--hover); }
.arquivo input { display: none; }

/* ---------- caixa de entrada (chat) ---------- */
.caixa-layout { display: grid; grid-template-columns: 340px minmax(0, 1fr); gap: 0; background: var(--card); border: 1px solid var(--borda); border-radius: var(--raio); box-shadow: var(--sombra); height: calc(100vh - 130px); min-height: 480px; overflow: hidden; }
.conversas { border-right: 1px solid var(--borda); display: flex; flex-direction: column; min-height: 0; }
.conversas .busca { margin: 12px; flex: 0 0 auto; }
.lista-conversas { overflow-y: auto; flex: 1; }
.item-conversa { display: flex; gap: 12px; padding: 12px 14px; text-decoration: none; color: var(--texto); border-bottom: 1px solid var(--borda); }
.item-conversa:hover { background: var(--hover); }
.item-conversa.ativo { background: var(--azul-bg); }
.item-conversa.nao-lida strong { color: var(--primaria-2); }
.item-texto { flex: 1; min-width: 0; }
.item-linha { display: flex; justify-content: space-between; gap: 8px; align-items: center; }
.item-linha strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; }
.item-linha .hora { font-size: 12px; color: var(--texto-3); white-space: nowrap; }
.item-linha .resumo { font-size: 13px; color: var(--texto-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.avatar { width: 40px; height: 40px; border-radius: 50%; background: var(--primaria); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 14px; flex: 0 0 auto; }
.conversa { display: flex; flex-direction: column; min-height: 0; }
.conversa-topo { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--borda); }
.mensagens { flex: 1; overflow-y: auto; padding: 18px 16px; background: var(--bg); display: flex; flex-direction: column; gap: 12px; }
.bolha { max-width: min(680px, 88%); padding: 10px 14px; border-radius: 14px; background: var(--bolha-recebida); border: 1px solid var(--borda); box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04); }
.bolha.enviada { align-self: flex-end; background: var(--bolha-enviada); border-bottom-right-radius: 4px; }
.bolha.recebida { align-self: flex-start; border-bottom-left-radius: 4px; }
.bolha-assunto { font-size: 12px; font-weight: 600; color: var(--texto-2); margin-bottom: 4px; }
.bolha-texto { white-space: pre-wrap; word-break: break-word; font-size: 14px; line-height: 1.5; }
.bolha-hora { font-size: 11px; color: var(--texto-3); margin-top: 6px; text-align: right; }
.responder { display: flex; gap: 10px; padding: 12px 16px; border-top: 1px solid var(--borda); align-items: flex-end; }
.responder textarea { min-height: 64px; }
.so-celular { display: none; }

/* ---------- diálogo e avisos ---------- */
.dlg { border: 0; border-radius: 16px; padding: 0; background: var(--card); color: var(--texto); box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3); width: min(560px, calc(100vw - 32px)); }
.dlg::backdrop { background: rgba(10, 31, 68, 0.45); }
.dlg-form { padding: 22px 24px; }
.dlg-larga { width: min(860px, calc(100vw - 32px)); }
.dlg-form h2 { font-size: 18px; margin: 0 0 12px; }
.dlg-corpo { max-height: 70vh; overflow-y: auto; }
.dlg-corpo p { margin: 0 0 12px; }
.dlg-botoes { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
.avisos { position: fixed; right: 18px; bottom: 18px; display: flex; flex-direction: column; gap: 8px; z-index: 50; }
.aviso { background: var(--primaria); color: #fff; padding: 12px 16px; border-radius: 10px; box-shadow: var(--sombra); font-weight: 500; max-width: 380px; animation: entrar 0.2s ease; }
.aviso-erro { background: var(--vermelho); }
@keyframes entrar { from { opacity: 0; transform: translateY(8px); } }

/* ---------- login ---------- */
.pagina-login { background: var(--primaria); background-image: radial-gradient(circle at 20% 10%, rgba(255, 204, 0, 0.18), transparent 40%), radial-gradient(circle at 85% 90%, rgba(119, 184, 0, 0.18), transparent 40%); min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; }
.login { width: min(420px, 100%); }
.login-caixa { background: var(--card); border-radius: 18px; padding: 32px 30px 26px; box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3); }
.login-logo { display: block; width: 210px; max-width: 70%; height: auto; margin: 0 auto 18px; background: #0b0b0b; border-radius: 12px; padding: 14px 18px; box-sizing: border-box; }
.login-caixa h1 { font-size: 20px; text-align: center; margin: 0 0 4px; }
.login-caixa .texto-2 { text-align: center; margin: 0 0 22px; }
.login .erro { color: var(--vermelho); font-size: 14px; margin: -6px 0 12px; }

/* ---------- celular ---------- */
@media (max-width: 1000px) {
  .grade-2, .grade-editor { grid-template-columns: 1fr; }
  .previa { position: static; }
  .previa iframe { height: 640px; }
}
@media (max-width: 900px) {
  .lateral { position: fixed; left: 0; top: 0; transform: translateX(-100%); width: 270px; }
  .lateral.aberta { transform: none; }
  .cortina.aberta { display: block; }
  .btn-icone { display: inline-flex; }
  .topo { padding: 12px 16px; }
  .topo h1 { font-size: 18px; }
  .conteudo { padding: 16px 16px 40px; }
  #acoes-tela .btn { padding: 8px 10px; font-size: 13px; }
  .caixa-layout { grid-template-columns: 1fr; height: calc(100vh - 100px); }
  .caixa-layout .conversa { display: none; }
  .caixa-layout.com-conversa .conversas { display: none; }
  .caixa-layout.com-conversa .conversa { display: flex; }
  .so-celular { display: inline-flex; }
  .responder { flex-direction: column; align-items: stretch; }
  .ficha dl { grid-template-columns: 1fr; }
  .contagem { margin-left: 0; }
}
