:root {
  color-scheme: light;
  --verde: #008069;
  --fundo: #f0f2f5;
  --painel: #ffffff;
  --borda: #e9edef;
  --texto: #111b21;
  --suave: #667781;
  --mudo: #898781;
  --grade: #e1e0d9;
  --bolha-minha: #d9fdd3;
  --bolha-dele: #ffffff;
  --fundo-conversa: #efeae2;
  --perigo: #c62828;
  --link: #1a6fd1;
  --alerta: #c25400;
  /* Origens (paleta categórica validada, ordem fixa). */
  --serie-1: #2a78d6;
  --serie-2: #eb6834;
  --serie-3: #1baf7a;
  --serie-4: #eda100;
  --neutra: #a3a29c;
}
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --fundo: #0b141a; --painel: #111b21; --borda: #222d34; --texto: #e9edef; --suave: #8696a0; --mudo: #898781; --grade: #2c2c2a;
    --bolha-minha: #005c4b; --bolha-dele: #202c33; --fundo-conversa: #0b141a; --verde: #00a884; --link: #53a6f5; --alerta: #f0883e;
    --serie-1: #3987e5; --serie-2: #d95926; --serie-3: #199e70; --serie-4: #c98500; --neutra: #5f5e5a;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; font-size: 14.5px; color: var(--texto); background: var(--fundo); }
button, input, select { font: inherit; color: inherit; }
a { color: var(--link); }
code { font-family: ui-monospace, Consolas, monospace; font-size: 12.5px; background: var(--fundo); padding: 2px 6px; border-radius: 4px; }
.oculto { display: none !important; }
.nota { color: var(--suave); font-size: 12.5px; }
.centro { text-align: center; }
.erro { color: var(--perigo); font-size: 13px; }
.aviso { padding: 14px; border-radius: 8px; background: var(--painel); color: var(--perigo); }
.carregando { padding: 30px; text-align: center; color: var(--suave); margin: auto; }
.vazio { padding: 22px; text-align: center; color: var(--suave); }

.marca { font-weight: 700; font-size: 19px; color: var(--verde); display: flex; align-items: center; gap: 8px; }
.marca.grande { font-size: 30px; justify-content: center; }
.marca-icone { display: inline-flex; align-items: center; justify-content: center; background: var(--verde); color: #fff; border-radius: 50%; width: 1.6em; height: 1.6em; font-size: .75em; letter-spacing: -2px; flex: none; }

.botao { display: inline-block; text-decoration: none; border: 1px solid var(--borda); background: var(--painel); border-radius: 20px; padding: 8px 16px; cursor: pointer; font-weight: 500; white-space: nowrap; color: var(--texto); }
.botao:hover { filter: brightness(.97); }
.botao.primario { background: var(--verde); border-color: var(--verde); color: #fff; }
.botao.perigo { color: var(--perigo); }
.botao.pequeno { padding: 5px 12px; font-size: 13px; }
.botao:disabled { opacity: .6; cursor: default; }
.botao-link { border: 0; background: none; padding: 0; color: var(--link); cursor: pointer; text-decoration: underline; }
.icone { border: 0; background: transparent; cursor: pointer; width: 38px; height: 38px; border-radius: 50%; font-size: 18px; color: var(--suave); }
.icone:hover { background: var(--fundo); }

input[type=text], input[type=email], input[type=password], input[type=search], input[type=date], select {
  width: 100%; padding: 9px 12px; border: 1px solid var(--borda); border-radius: 8px; background: var(--painel); font-size: 15px;
}

/* Login */
.tela-acesso { display: flex; align-items: center; justify-content: center; padding: 20px; }
.caixa-acesso { width: 100%; max-width: 380px; background: var(--painel); border-radius: 12px; padding: 32px 28px; box-shadow: 0 2px 12px rgba(0,0,0,.08); }
.caixa-acesso .sub { color: var(--suave); margin: 6px 0 22px; }
.caixa-acesso form { display: flex; flex-direction: column; gap: 14px; }
.caixa-acesso label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--suave); }
.caixa-acesso .botao { padding: 11px; border-radius: 8px; }

/* Casca: menu lateral + conteúdo */
.casca { display: flex; height: 100vh; height: 100dvh; }
.nav { width: 210px; flex: none; display: flex; flex-direction: column; gap: 2px; padding: 14px 10px; background: var(--painel); border-right: 1px solid var(--borda); }
.nav-marca { padding: 4px 10px 16px; }
.nav a, .nav-conta { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 8px; color: var(--texto); text-decoration: none; border: 0; background: none; cursor: pointer; text-align: left; width: 100%; }
.nav a:hover, .nav-conta:hover { background: var(--fundo); }
.nav a.ativo { background: var(--fundo); color: var(--verde); font-weight: 600; }
.nav-icone { width: 22px; text-align: center; flex: none; }
.nav-rotulo { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-pe { margin-top: auto; position: relative; border-top: 1px solid var(--borda); padding-top: 8px; }
.nav-conta .nav-rotulo { font-size: 12.5px; color: var(--suave); }
.menu { position: absolute; left: 0; bottom: 52px; z-index: 30; background: var(--painel); border-radius: 8px; box-shadow: 0 4px 18px rgba(0,0,0,.18); padding: 6px 0; min-width: 190px; }
.menu button { display: block; width: 100%; text-align: left; border: 0; background: transparent; padding: 10px 16px; cursor: pointer; }
.menu button:hover { background: var(--fundo); }

.principal { flex: 1; min-width: 0; overflow-y: auto; }
.tela { display: none; padding: 20px 26px 40px; max-width: 1280px; margin: 0 auto; }
.tela.ativa { display: block; }
.cabecalho { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
h1 { font-size: 24px; margin: 0; }
h3 { font-size: 15px; margin: 0 0 2px; }
.secao-titulo { font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--suave); margin: 22px 0 8px; font-weight: 600; }
.explica { color: var(--suave); margin: 0 0 14px; line-height: 1.5; }

/* Filtros */
.filtros { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-bottom: 4px; }
.filtros select { width: auto; min-width: 180px; }
.filtros input[type=date] { width: auto; }
.segmentos { display: inline-flex; background: var(--painel); border: 1px solid var(--borda); border-radius: 8px; overflow: hidden; }
.segmentos button { border: 0; background: none; padding: 8px 13px; cursor: pointer; font-size: 13.5px; border-right: 1px solid var(--borda); }
.segmentos button:last-child { border-right: 0; }
.segmentos button.ativo { background: var(--verde); color: #fff; font-weight: 600; }
.datas { display: inline-flex; align-items: center; gap: 6px; color: var(--suave); }

/* Tiles */
.tiles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.tile { background: var(--painel); border-radius: 10px; padding: 14px 16px; border: 1px solid var(--borda); min-width: 0; }
.tile-rotulo { font-size: 13px; color: var(--suave); }
.tile-valor { font-size: 26px; font-weight: 600; margin-top: 4px; font-variant-numeric: tabular-nums; }
.tile-sub { font-size: 12px; color: var(--suave); margin-top: 2px; }

/* Cartões e gráficos */
.cartao { background: var(--painel); border: 1px solid var(--borda); border-radius: 10px; padding: 16px 18px; margin-top: 14px; min-width: 0; }
.cartao .sub { font-size: 12.5px; color: var(--suave); margin-bottom: 10px; }
.cartao.vazio { text-align: center; }
.grade-graficos { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
.grade-graficos .largo { grid-column: 1 / -1; }
svg .grade { stroke: var(--grade); stroke-width: 1; }
svg .base { stroke: var(--mudo); stroke-width: 1; }
svg .eixo { fill: var(--mudo); font-size: 11px; }
svg .rotulo-barra { fill: var(--texto); font-size: 12.5px; }
svg .valor-barra { fill: var(--suave); font-size: 12px; font-variant-numeric: tabular-nums; }
svg .alvo { fill: transparent; cursor: default; }
svg .marca.serie-1 { fill: var(--serie-1); } svg .marca.serie-2 { fill: var(--serie-2); }
svg .marca.serie-3 { fill: var(--serie-3); } svg .marca.serie-4 { fill: var(--serie-4); }
svg .marca.neutra { fill: var(--neutra); }
.ponto { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 6px; vertical-align: 0; flex: none; }
.ponto.serie-1 { background: var(--serie-1); } .ponto.serie-2 { background: var(--serie-2); }
.ponto.serie-3 { background: var(--serie-3); } .ponto.serie-4 { background: var(--serie-4); }
.legenda { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 12.5px; color: var(--suave); margin-bottom: 8px; }
.dica-grafico { position: fixed; z-index: 60; pointer-events: none; background: var(--painel); color: var(--texto); border: 1px solid var(--borda); border-radius: 8px; padding: 8px 10px; font-size: 12.5px; box-shadow: 0 4px 16px rgba(0,0,0,.15); line-height: 1.6; }
.dica-titulo { font-weight: 600; margin-bottom: 2px; }
.dica-total { border-top: 1px solid var(--borda); margin-top: 4px; padding-top: 3px; }

/* Tabelas */
.tabela-rolagem { overflow-x: auto; }
.tabela { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.tabela th { text-align: left; font-weight: 600; color: var(--suave); font-size: 12px; text-transform: uppercase; letter-spacing: .03em; padding: 8px 10px; border-bottom: 1px solid var(--borda); white-space: nowrap; }
.tabela td { padding: 9px 10px; border-bottom: 1px solid var(--borda); vertical-align: middle; }
.tabela .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tabela tr.clicavel { cursor: pointer; }
.tabela tr.clicavel:hover td { background: var(--fundo); }
.tabela tr.riscada td { text-decoration: line-through; opacity: .55; }
.selo-origem { display: inline-flex; align-items: center; font-size: 12.5px; white-space: nowrap; }
.selo-venda { flex: none; font-size: 11.5px; font-weight: 600; color: var(--verde); border: 1px solid currentColor; border-radius: 10px; padding: 0 7px; }
.selo-espera { color: var(--alerta); font-size: 12px; flex: none; }
.copiar { cursor: pointer; word-break: break-all; }
.copiar.copiado { outline: 2px solid var(--verde); }

.lista-simples { display: flex; flex-direction: column; }
.linha-simples { display: flex; align-items: center; gap: 10px; padding: 8px 4px; border: 0; border-bottom: 1px solid var(--borda); background: none; cursor: pointer; text-align: left; width: 100%; }
.linha-simples:hover { background: var(--fundo); }
.ls-corpo { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.ls-corpo .nota { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ls-tempo { color: var(--alerta); font-size: 12.5px; white-space: nowrap; font-weight: 600; }

/* Formulários */
.linha-form { display: flex; gap: 8px; flex-wrap: wrap; }
.linha-form input { flex: 1 1 220px; }
.linha-form select { flex: 0 1 240px; }
.grade-form { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.grade-form label { display: flex; flex-direction: column; gap: 5px; font-size: 13px; color: var(--suave); }
.grade-form .largo { grid-column: 1 / -1; }
.coluna-form { display: flex; flex-direction: column; gap: 12px; }
.coluna-form label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--suave); }
.acoes-linha { margin-top: 12px; }

/* Conversas */
.tela-conversas { padding: 0; max-width: none; height: 100%; }
.tela-conversas.ativa { display: flex; }
.lateral { width: 380px; flex: none; display: flex; flex-direction: column; border-right: 1px solid var(--borda); min-width: 0; background: var(--painel); }
.lateral-topo { padding: 14px 14px 6px; }
.lateral-filtros { padding: 6px 12px 10px; display: flex; flex-direction: column; gap: 8px; border-bottom: 1px solid var(--borda); }
.lateral-filtros input[type=search] { background: var(--fundo); border: 0; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chips button { border: 1px solid var(--borda); background: var(--painel); border-radius: 14px; padding: 4px 11px; font-size: 13px; cursor: pointer; }
.chips button.ativo { background: var(--verde); border-color: var(--verde); color: #fff; }
.filtro-canal { font-size: 12.5px; color: var(--suave); }
.lista { flex: 1; overflow-y: auto; }
.lista-vazia { padding: 30px 24px; text-align: center; color: var(--suave); line-height: 1.6; }
.lista-vazia .botao { margin-top: 14px; }
.item { display: flex; gap: 12px; align-items: center; width: 100%; padding: 10px 14px; border: 0; border-bottom: 1px solid var(--borda); background: transparent; text-align: left; cursor: pointer; }
.item:hover, .item.ativo { background: var(--fundo); }
.item-corpo { flex: 1; min-width: 0; }
.item-linha { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.item-selos { justify-content: flex-start; margin-top: 3px; }
.item-nome { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item-hora { font-size: 12px; color: var(--suave); flex: none; }
.item-hora.alerta { color: var(--alerta); font-weight: 600; }
.item-previa { color: var(--suave); font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.avatar { flex: none; width: 44px; height: 44px; border-radius: 50%; background: #dfe5e7; color: #54656f; display: flex; align-items: center; justify-content: center; font-weight: 600; font-size: 15px; }
.avatar.pequeno { width: 32px; height: 32px; font-size: 12px; }

.conversa { flex: 1; display: flex; flex-direction: column; min-width: 0; background: var(--fundo-conversa); }
.vazio-conversa { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 30px; color: var(--suave); background: var(--fundo); }
.conversa-topo { display: flex; align-items: center; gap: 12px; padding: 10px 16px; background: var(--painel); border-bottom: 1px solid var(--borda); }
.conversa-titulo { min-width: 0; flex: 1; }
.conversa-titulo .nome { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conversa-titulo .sub { font-size: 12.5px; color: var(--suave); }
.voltar { display: none; }
.faixa-info { display: flex; flex-wrap: wrap; gap: 8px 26px; padding: 10px 16px; background: var(--painel); border-bottom: 1px solid var(--borda); font-size: 13px; }
.info-item { display: flex; flex-direction: column; gap: 2px; min-width: 0; max-width: 100%; }
.info-item > span:first-child { font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--suave); }
.mensagens { flex: 1; overflow-y: auto; padding: 16px 7% 20px; display: flex; flex-direction: column; gap: 3px; }
.dia { text-align: center; margin: 12px 0 8px; }
.dia span { background: var(--painel); color: var(--suave); font-size: 12.5px; padding: 5px 12px; border-radius: 8px; box-shadow: 0 1px .5px rgba(0,0,0,.13); }
.bolha { max-width: 65%; padding: 6px 9px 4px; border-radius: 8px; box-shadow: 0 1px .5px rgba(0,0,0,.13); overflow-wrap: anywhere; }
.bolha.dele { align-self: flex-start; background: var(--bolha-dele); border-top-left-radius: 0; }
.bolha.minha { align-self: flex-end; background: var(--bolha-minha); border-top-right-radius: 0; }
.bolha.foi-apagada { outline: 1px dashed var(--perigo); }
.bolha.tem-venda { outline: 2px solid var(--verde); }
.texto { white-space: pre-wrap; line-height: 1.4; }
.texto.original { text-decoration: line-through; opacity: .7; }
.editada { white-space: pre-wrap; margin-top: 4px; }
.marca-venda { margin-top: 5px; font-size: 12.5px; font-weight: 600; color: var(--verde); }
.marca-venda.descartada { color: var(--suave); text-decoration: line-through; }
.bolha-rodape { text-align: right; font-size: 11px; color: var(--suave); margin-top: 2px; }
.apagada { color: var(--perigo); font-weight: 500; }
.citada { border-left: 4px solid var(--verde); background: rgba(0,0,0,.05); border-radius: 5px; padding: 5px 8px; margin-bottom: 5px; font-size: 13px; color: var(--suave); }
.cartao-anuncio { border-left: 4px solid var(--serie-1); background: rgba(42,120,214,.08); border-radius: 5px; padding: 6px 8px; margin-bottom: 6px; font-size: 13px; line-height: 1.45; }
.midia-img { display: block; max-width: 100%; max-height: 340px; border-radius: 6px; cursor: zoom-in; margin-bottom: 4px; }
.midia-video { display: block; max-width: 100%; max-height: 360px; border-radius: 6px; margin-bottom: 4px; }
.figurinha { display: block; width: 140px; height: 140px; object-fit: contain; }
audio { display: block; width: 280px; max-width: 100%; margin: 2px 0; }
.documento { display: block; padding: 10px 12px; background: rgba(0,0,0,.05); border-radius: 6px; margin-bottom: 4px; text-decoration: none; color: inherit; }
.reacao { font-size: 12.5px; color: var(--suave); padding: 2px 6px; }
.reacao.minha { align-self: flex-end; }
.reacao.dele { align-self: flex-start; }
.rodape-leitura { padding: 10px; text-align: center; font-size: 12.5px; color: var(--suave); background: var(--painel); border-top: 1px solid var(--borda); }

/* Modal */
.modal-fundo { position: fixed; inset: 0; z-index: 40; background: rgba(11,20,26,.55); display: flex; align-items: center; justify-content: center; padding: 16px; }
.modal { position: relative; width: 100%; max-width: 560px; max-height: 92vh; overflow: auto; background: var(--painel); border-radius: 12px; padding: 22px 24px; }
.modal h2 { margin: 0 0 14px; font-size: 19px; }
.fechar { position: absolute; right: 10px; top: 10px; }
.numero { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--borda); flex-wrap: wrap; }
.numero:last-child { border-bottom: 0; }
.numero-info { display: flex; flex-direction: column; min-width: 0; }
.numero-info span { color: var(--suave); font-size: 12.5px; }
.numero-acoes { display: flex; gap: 6px; }
.passos { padding-left: 20px; line-height: 1.6; margin: 0 0 14px; }
.qr { display: flex; align-items: center; justify-content: center; min-height: 280px; }
.qr img { width: 264px; height: 264px; image-rendering: pixelated; background: #fff; padding: 8px; border-radius: 8px; }
.ok-grande { width: 120px; height: 120px; border-radius: 50%; background: var(--verde); color: #fff; font-size: 64px; display: flex; align-items: center; justify-content: center; }
.visor { position: fixed; inset: 0; z-index: 50; background: rgba(0,0,0,.88); display: flex; align-items: center; justify-content: center; cursor: zoom-out; }
.visor img { max-width: 96vw; max-height: 94vh; }

/* Telas médias */
@media (max-width: 1100px) {
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grade-graficos { grid-template-columns: 1fr; }
  .grade-form { grid-template-columns: 1fr 1fr; }
}

/* Celular: menu vira barra inferior; lista e conversa uma de cada vez. */
@media (max-width: 760px) {
  .casca { flex-direction: column-reverse; }
  .nav { width: 100%; flex-direction: row; justify-content: space-around; padding: 4px 2px calc(4px + env(safe-area-inset-bottom)); border-right: 0; border-top: 1px solid var(--borda); gap: 0; }
  .nav-marca, .nav-pe { display: none; }
  .nav a { flex-direction: column; gap: 2px; padding: 6px 4px; font-size: 10.5px; width: auto; flex: 1; align-items: center; }
  .nav a .nav-rotulo { font-size: 10.5px; }
  .tela { padding: 14px 12px 24px; }
  .tiles { gap: 8px; }
  .tile { padding: 11px 12px; }
  .tile-valor { font-size: 21px; }
  .filtros select { min-width: 0; flex: 1; }
  .segmentos { width: 100%; overflow-x: auto; }
  .segmentos button { flex: 1; padding: 8px 6px; font-size: 12.5px; }
  .grade-form { grid-template-columns: 1fr; }
  .lateral { width: 100%; border-right: 0; }
  .tela-conversas .conversa { display: none; }
  .tela-conversas.aberta .lateral { display: none; }
  .tela-conversas.aberta .conversa { display: flex; }
  body.em-conversa .nav { display: none; }
  .voltar { display: inline-block; margin-left: -8px; }
  .conversa-topo { padding: 8px 10px; gap: 8px; }
  .faixa-info { gap: 8px 16px; padding: 8px 12px; }
  .mensagens { padding: 12px 10px 16px; }
  .bolha { max-width: 86%; }
  .modal { padding: 20px 16px; }
  .numero-acoes { width: 100%; justify-content: flex-end; }
}
