/* QG — Quartel General. Segue o KIT-IDENTIDADE-AMF: os tokens abaixo são os
   do painel.css do APP COMERCIAL, valor por valor; o identidade.css, que entra
   DEPOIS, troca os valores dos mesmos nomes no tema escuro. A faixa azul, o
   cabeçalho (selo · nome · quem está dentro · tema) e a intro do brasão são as
   mesmas peças dos apps irmãos (topo.css, amf-intro.js, tema-botao.js). */
:root {
  color-scheme: light;
  --brand: #055FFB; --brand-600: #0a4fd8; --brand-50: #EAF1FE; --brand-rgb: 5,95,251; --on-brand: #ffffff;
  --ink: #1B1E22; --navy: #040D1B; --mist: #F3F4F6; --line: #E7E9EE; --muted: #5B6472;
  --ring: #E1E4EA; --ring-hover: #c7cdd8;
  --bg: #ffffff; --bg-2: #F3F4F6; --card: #ffffff; --card-2: #F7F8FA;
  --border: #E7E9EE; --text: #1B1E22; --text-dim: #5B6472; --ink-muted: #6b7383; --grid: #E7E9EE;
  --shadow-card: 0 1px 2px rgba(16,24,40,.05), 0 18px 34px -20px rgba(5,95,251,.20);
  --shadow-float: 0 10px 22px -8px rgba(16,24,40,.12), 0 34px 60px -26px rgba(5,95,251,.28);
  --ease: cubic-bezier(.22,1,.36,1);
  --st-good: #0ca30c; --st-warn: #fab219; --st-crit: #d03b3b;
  --good-ink: #0a7a0a; --warn-ink: #8a5a00; --crit-ink: #b42323;
  --good-bg: #ebf7eb; --warn-bg: #fff6e0; --crit-bg: #fdeeee;
  --r1: #94b8f8; --r2: #5f95fa; --r3: #055ffb; --r4: #0e43a8;
  --radius: 24px; --radius-sm: 14px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body { color: var(--text); font-size: 15px; line-height: 1.55; min-height: 100vh; background: var(--bg);
  font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif; -webkit-font-smoothing: antialiased; }
button, select, input { font: inherit; color: inherit; }
a { color: var(--brand); }
.serif { font-family: 'Times New Roman', Times, serif; font-style: italic; font-weight: 400; letter-spacing: -.02em; }
.wrap { max-width: 1200px; margin: 0 auto; padding-block: 0 64px; padding-inline: 24px; }

/* ---------- faixa azul do topo (painel.css do Comercial) ---------- */
.topbar { background: var(--brand); color: var(--on-brand); font-size: 13px; }
.topbar-in { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 4px 20px; padding: 11px 24px; }
.topbar b { font-weight: 700; letter-spacing: .04em; }
.topbar span { opacity: .88; }
.topbar .sep { display: inline-block; width: 4px; height: 4px; border-radius: 50%; background: currentColor; opacity: .6; margin: 0 10px; vertical-align: middle; }
.topbar .hoje::first-letter { text-transform: uppercase; }

/* ---------- cabeçalho: selo · quem está dentro · tema ---------- */
header.top { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; padding-top: 20px; margin-bottom: 22px; }
header.top .spacer { flex: 1; }
.brand { display: flex; align-items: center; gap: 12px; color: inherit; text-decoration: none; border-radius: 999px; }
.brand img { width: 44px; height: 44px; border-radius: 50%; flex: none; }
.brand b { display: block; font-size: 14.5px; font-weight: 600; letter-spacing: -.02em; line-height: 1.2; }
.brand i { display: block; font-style: normal; font-size: 12px; color: var(--text-dim); line-height: 1.3; }
@media (max-width: 520px) { .brand .nome { display: none; } }
.voltar-qg { padding: 8px 14px; border-radius: 999px; background: var(--mist); color: var(--text-dim); font-size: 14px; font-weight: 500; text-decoration: none; }
.voltar-qg:hover { color: var(--text); background: var(--ring); }
/* O botão de tema que o tema-botao.js põe no cabeçalho: a mesma peça do
   .topo-tema do Comercial. */
header.top .tema-bt { flex: none; display: inline-grid; place-items: center; width: 44px; height: 44px; border: 0; border-radius: 14px;
  background: var(--mist); color: var(--text); cursor: pointer; transition: background-color .2s ease, color .2s ease; }
header.top .tema-bt:hover { background: var(--ring); }
header.top .tema-bt:focus-visible { outline: none; box-shadow: 0 0 0 3px rgba(var(--brand-rgb), .35); }
.tema-bt.solto { position: fixed; top: 16px; right: 16px; z-index: 5; width: 44px; height: 44px; border: 0; border-radius: 14px;
  background: var(--mist); color: var(--text); cursor: pointer; display: inline-grid; place-items: center; }

/* ---------- filtros ---------- */
.filtros { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; padding: 6px; border-radius: 999px; background: var(--mist); width: fit-content; max-width: 100%; }
.pilula, select.pilula, input.pilula { border: 0; background: var(--card); border-radius: 999px;
  padding: 8px 14px; font-size: 14px; font-weight: 500; cursor: pointer; box-shadow: inset 0 0 0 1px var(--ring); }
.pilula:hover { box-shadow: inset 0 0 0 1px var(--ring-hover); }
.grupo { display: inline-flex; flex-wrap: wrap; border-radius: 999px; padding: 0; gap: 2px; }
.grupo button { border: 0; background: none; border-radius: 999px; padding: 8px 13px; cursor: pointer; font-size: 14px; font-weight: 500; color: var(--text-dim); }
.grupo button:hover { color: var(--text); background: var(--card); }
.grupo button.ativa { color: var(--text); background: var(--card); font-weight: 600;
  box-shadow: 0 1px 2px rgba(16,24,40,.08), inset 0 0 0 1px var(--ring); }
.datas { display: none; gap: 6px; align-items: center; }
.datas.aberta { display: inline-flex; }
@media (max-width: 720px) { .filtros { border-radius: 20px; } }

/* ---------- página ---------- */
main { padding: 22px 0 0; }
.secao { margin-top: 36px; }
.secao > h2 { font-size: 22px; margin: 0 0 4px; }
.secao > p.sub { margin: 0 0 16px; color: var(--muted); font-size: 14px; }
.cartao { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-card); padding: 22px; }

.heroi { display: grid; grid-template-columns: 1.3fr 1fr; gap: 16px; }
/* Item de grid tem min-width:auto: uma tabela larga lá dentro alargaria a
   página inteira em vez de rolar dentro do cartão. */
.heroi > *, .duas > *, .kpis > *, .vaz > * { min-width: 0; }
main { overflow-x: clip; }
.heroi h1 { font-size: clamp(34px, 5vw, 56px); margin: 6px 0 4px; }
.heroi .rotulo { color: var(--muted); font-size: 14px; }
.heroi .frase { font-size: 17px; margin: 8px 0 0; }
.heroi .frase b { font-variant-numeric: tabular-nums; }
.roas { display: flex; flex-direction: column; justify-content: center; }
.roas .big { font-size: 64px; font-weight: 700; letter-spacing: -.05em; line-height: 1; }
.roas .big small { font-size: 28px; color: var(--muted); font-weight: 500; margin-left: .3em; letter-spacing: -.02em; }

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-top: 16px; }
.kpi { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 14px 16px; }
.kpi .r { color: var(--muted); font-size: 13px; }
.kpi .value { font-size: 26px; font-weight: 650; letter-spacing: -.03em; margin-top: 2px; }
.kpi .d { color: var(--muted); font-size: 12px; margin-top: 2px; }

/* ---------- funil ---------- */
.funil-cab { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.anuncio { display: flex; gap: 22px; flex-wrap: wrap; padding-bottom: 14px; margin-bottom: 14px; border-bottom: 1px dashed var(--line); color: var(--muted); font-size: 14px; }
.anuncio b { color: var(--text); font-size: 18px; font-variant-numeric: tabular-nums; }
.etapa { display: grid; grid-template-columns: 170px 1fr 150px; gap: 14px; align-items: center; padding: 6px 0; }
.etapa .nome { font-weight: 550; }
.etapa .nome small { display: block; color: var(--muted); font-weight: 400; font-size: 12px; }
.barra { height: 30px; background: var(--mist); border-radius: 8px; overflow: hidden; }
.barra i { display: block; height: 100%; border-radius: 8px; min-width: 2px; transition: width .6s var(--ease, ease); }
.etapa .num { text-align: right; font-variant-numeric: tabular-nums; }
.etapa .num b { font-size: 18px; }
.etapa .num small { display: block; color: var(--muted); font-size: 12px; }

/* ---------- gráficos ----------
   Cores validadas com o validate_palette.js (diretrizes de dataviz):
   - funil = rampa ordinal de um tom só, clara → escura conforme a etapa
     (claro: azul da marca; escuro: o dourado, que é a cor de ação lá);
   - duas séries (gasto/receita, anúncio/outras) = azul + dourado, um par
     para cada tema, os dois passando banda de luz, croma e daltonismo.
   O texto nunca usa a cor da série: valor e rótulo ficam na tinta normal. */
:root {
  --f1: #8fb4f7; --f2: #5c93f7; --f3: #2a72ee; --f4: #0a50c8; --f5: #0b3477;
  --c1: #055FFB; --c2: #C9781E;
}
:root[data-tema="escuro"] {
  --f1: #F2E0C8; --f2: #E6C9A3; --f3: #D8B189; --f4: #C4986B; --f5: #96704A;
  --c1: #2F8AE0; --c2: #C0832C;
}
.c1 { background: var(--c1); }
.c2 { background: var(--c2); }
.legenda { display: flex; flex-wrap: wrap; gap: 6px 18px; font-size: 13px; color: var(--text-dim); margin-bottom: 14px; }
.legenda span { display: inline-flex; align-items: center; gap: 7px; }
.legenda i { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
.legenda i.ponto { width: 18px; height: 18px; border-radius: 6px; background: var(--card); box-shadow: inset 0 0 0 1px var(--line); position: relative; }
.legenda i.ponto::after { content: "1"; position: absolute; inset: 0; display: grid; place-items: center; font: 600 11px Inter, sans-serif; font-style: normal; color: var(--text); }

/* Funil: barras centradas que afunilam, a passagem entre etapas no meio. */
.funil-g { display: grid; gap: 0; }
.f-linha { display: grid; grid-template-columns: 180px 1fr 140px; gap: 16px; align-items: center; padding: 4px 0; border-radius: 10px; cursor: default; }
.f-linha:hover { background: var(--mist); }
.f-nome { font-weight: 600; padding-left: 6px; }
.f-nome small { display: block; color: var(--text-dim); font-weight: 400; font-size: 12px; }
.f-trilho { position: relative; height: 46px; }
.f-barra { position: absolute; top: 0; bottom: 0; left: 50%; transform: translateX(-50%); border-radius: 6px; transition: width .6s var(--ease); }
.f1 { background: var(--f1); } .f2 { background: var(--f2); } .f3 { background: var(--f3); } .f4 { background: var(--f4); } .f5 { background: var(--f5); }
.f-num { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); font-size: 18px; font-variant-numeric: tabular-nums;
  color: #fff; text-shadow: 0 1px 2px rgba(0,0,0,.25); }
.f1 + .f-num, .f2 + .f-num { color: var(--navy); text-shadow: none; }
:root[data-tema="escuro"] .f-num { color: #011E39; text-shadow: none; }
.f-num.fora { transform: translate(0, -50%); color: var(--text) !important; text-shadow: none; }
.f-lado { text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; padding-right: 6px; }
.f-lado small { display: block; color: var(--text-dim); font-weight: 400; font-size: 12px; }
.f-passo { display: flex; justify-content: center; gap: 14px; font-size: 12.5px; color: var(--text-dim); padding: 2px 0; margin-left: 196px; margin-right: 156px; }
.f-passo span:first-child { color: var(--text); font-weight: 600; }

/* Colunas por semana. */
.colunas { position: relative; display: flex; align-items: flex-end; gap: 6px; height: 240px; margin: 8px 0 26px 34px; }
.g-linha { position: absolute; left: 0; right: 0; border-top: 1px dashed var(--line); }
.g-linha span { position: absolute; left: -34px; top: -9px; width: 28px; text-align: right; font-size: 11px; color: var(--text-dim); font-variant-numeric: tabular-nums; }
.col { position: relative; flex: 1; height: 100%; display: flex; align-items: flex-end; justify-content: center; cursor: default; }
.col:hover { background: color-mix(in srgb, var(--mist) 70%, transparent); border-radius: 6px; }
.pilha { width: min(100%, 44px); display: flex; flex-direction: column; gap: 2px; position: relative; z-index: 1; }
.pilha i { display: block; min-height: 2px; }
.pilha i:first-child { border-radius: 4px 4px 0 0; }
.col .x { position: absolute; bottom: -22px; font-size: 11px; color: var(--text-dim); white-space: nowrap; }
.col .venda { position: absolute; z-index: 2; font-size: 11px; font-weight: 600; padding: 0 5px; border-radius: 6px; background: var(--card);
  box-shadow: inset 0 0 0 1px var(--line); color: var(--text); line-height: 18px; }

/* Gasto × receita. */
.gr { display: grid; gap: 4px; }
.gr-linha { display: grid; grid-template-columns: minmax(160px, 260px) 1fr; gap: 16px; align-items: center; padding: 8px 6px; border-radius: 10px; cursor: default; }
.gr-linha:hover { background: var(--mist); }
.gr-nome { font-weight: 550; font-size: 14px; line-height: 1.35; }
.gr-barras { display: grid; gap: 4px; }
.gr-b { display: flex; align-items: center; gap: 8px; height: 14px; }
.gr-b i { height: 12px; border-radius: 0 4px 4px 0; display: block; }
.gr-b span { font-size: 12px; color: var(--text-dim); font-variant-numeric: tabular-nums; white-space: nowrap; }

.dica { position: fixed; z-index: 50; max-width: 300px; padding: 9px 12px; border-radius: 12px; font-size: 13px; line-height: 1.45;
  background: var(--navy); color: #fff; box-shadow: var(--shadow-float); pointer-events: none; }
:root[data-tema="escuro"] .dica { background: #FFFFFF; color: #011E39; }

@media (max-width: 860px) {
  .f-linha { grid-template-columns: 1fr 76px; }
  .f-nome { grid-column: 1 / -1; }
  .f-trilho { grid-column: 1; }
  .f-passo { margin: 0 82px 0 0; flex-wrap: wrap; gap: 2px 10px; }
  .gr-linha { grid-template-columns: 1fr; gap: 6px; }
  .colunas { gap: 3px; }
}

/* ---------- tabelas ---------- */
.tabela-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; font-weight: 550; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .03em;
  padding: 10px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; cursor: pointer; user-select: none; }
th.n, td.n { text-align: right; font-variant-numeric: tabular-nums; }
td { padding: 11px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
tr:last-child td { border-bottom: 0; }
tfoot td { font-weight: 650; border-top: 2px solid var(--line); }
td .tit { font-weight: 550; }
#tCamp td:first-child { min-width: 230px; }
#tCamp td:last-child { min-width: 200px; }
#tCamp .etq { white-space: normal; line-height: 1.35; padding: 4px 10px; }
td .meta { color: var(--muted); font-size: 12px; }
.vazio { color: var(--muted); text-align: center; padding: 28px; }
.etq { display: inline-block; font-size: 12px; padding: 2px 9px; border-radius: 999px; white-space: nowrap; }
.etq.good { background: var(--good-bg); color: var(--good-ink); }
.etq.warn { background: var(--warn-bg); color: var(--warn-ink); }
.etq.crit { background: var(--crit-bg); color: var(--crit-ink); }
.etq.neutro { background: var(--mist); color: var(--muted); }
/* Selo do gerenciador: identidade de canal, cor fixa nos dois temas. */
.selo { display: inline-block; font-size: 11px; font-weight: 600; padding: 1px 7px; border-radius: 6px; color: #fff; vertical-align: 1px; }
.selo-meta { background: #1877F2; }
.selo-google { background: #188038; }
.selo-tiktok { background: #111; box-shadow: inset 0 0 0 1px #555; }
.mini { display: inline-flex; gap: 2px; vertical-align: middle; margin-left: 6px; }

.duas { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.vaz { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 12px; margin-bottom: 16px; }
.vaz .kpi .value { font-size: 24px; }
.vaz .kpi.crit { border-color: var(--st-crit); }
.vaz .kpi.warn { border-color: var(--st-warn); }

.avisos { margin-top: 16px; display: grid; gap: 8px; }
.aviso { border: 1px solid var(--line); border-left: 4px solid var(--st-warn); background: var(--card); border-radius: 10px; padding: 10px 14px; font-size: 14px; }
.carregando { color: var(--muted); padding: 60px 0; text-align: center; }
.erro { border-left-color: var(--st-crit); }
.rodape { color: var(--muted); font-size: 12px; margin-top: 40px; }

@media (max-width: 860px) {
  .heroi, .duas { grid-template-columns: 1fr; }
  .roas .big { font-size: 46px; }
  .roas .big small { display: block; margin: 6px 0 0; font-size: 20px; }
  .kpis { grid-template-columns: 1fr 1fr; }
  .kpi .value { font-size: 21px; }
  .etapa { grid-template-columns: 110px 1fr 96px; gap: 8px; }
  .wrap { padding-inline: 16px; }
}

/* ---------- entrar ---------- */
.entrar { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.entrar form { width: min(380px, 100%); display: grid; gap: 14px; }
.entrar h1 { margin: 6px 0 0; font-size: 34px; }
.entrar p { margin: 0; color: var(--muted); }
.entrar input { border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; background: var(--card); width: 100%; }
.entrar button { border: 0; border-radius: 999px; padding: 12px; background: var(--brand); color: var(--on-brand, #fff); font-weight: 600; cursor: pointer; }
.entrar .msg { color: var(--crit-ink); min-height: 1.5em; font-size: 14px; }
