:root {
  --ink: #201a1e;
  --brand: #6d2340;      /* vinho — distingue do verde do dash da Camila */
  --brand-2: #a8456b;
  --paper: #f6f4f5;
  --card: #ffffff;
  --line: #e6e0e3;
  --muted: #857a80;
  --ok: #1f7a5c;
  --bad: #b23b3b;
  --warn: #8a6d1f;
}
* { box-sizing: border-box; }
body {
  margin: 0; background: var(--paper); color: var(--ink);
  font-family: Inter, system-ui, sans-serif; font-size: 14px;
}
.num, .card .v, table td.num, table th.num { font-family: Montserrat, sans-serif; font-variant-numeric: tabular-nums; }
code { background: var(--paper); border: 1px solid var(--line); border-radius: 4px; padding: 1px 5px; font-size: 12px; }

/* Topbar */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 20px; background: var(--card); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 10;
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand .dot { width: 12px; height: 12px; border-radius: 50%; background: var(--brand-2); }
.brand h1 { font-size: 15px; font-weight: 500; margin: 0; }
.brand strong { font-weight: 700; }
.meta { display: flex; align-items: center; gap: 10px; }
.pill { font-size: 12px; color: var(--muted); background: var(--paper); border: 1px solid var(--line); padding: 4px 10px; border-radius: 999px; }
.pill.bad { color: var(--bad); border-color: #f0d5d5; background: #fdf3f3; }
.btn { border: 1px solid var(--line); background: var(--card); border-radius: 8px; padding: 6px 12px; cursor: pointer; font: inherit; }
.btn:hover { background: var(--paper); }
.btn:disabled { opacity: .5; cursor: default; }

/* Tabs */
.tabs { display: flex; gap: 4px; padding: 0 20px; background: var(--card); border-bottom: 1px solid var(--line); overflow-x: auto; }
.tab { border: none; background: none; padding: 12px 14px; cursor: pointer; font: inherit; color: var(--muted); border-bottom: 2px solid transparent; white-space: nowrap; }
.tab.active { color: var(--ink); border-bottom-color: var(--brand); font-weight: 600; }

/* Período */
.periodbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  max-width: 1320px; margin: 0 auto; padding: 14px 18px 0;
}
.presets { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { border: 1px solid var(--line); background: var(--card); border-radius: 999px; padding: 5px 12px; cursor: pointer; font: inherit; font-size: 13px; color: var(--muted); }
.chip.active { background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 600; }
.range { display: flex; gap: 10px; align-items: center; font-size: 13px; color: var(--muted); }
.range input { border: 1px solid var(--line); border-radius: 8px; padding: 5px 8px; font: inherit; background: var(--card); color: var(--ink); }

/* Avisos */
#avisos { max-width: 1320px; margin: 0 auto; padding: 12px 18px 0; }
.aviso {
  background: #fff8e6; border: 1px solid #e8d9a8; color: #6b551a;
  border-radius: 10px; padding: 10px 14px; margin-bottom: 8px; font-size: 13px; line-height: 1.5;
}

main { max-width: 1320px; margin: 0 auto; padding: 18px; }
.page { display: none; }
.page.active { display: block; }

/* Cards */
.cards { display: flex; flex-wrap: wrap; justify-content: center; gap: 12px; margin-bottom: 14px; }
.card { flex: 1 1 140px; max-width: 230px; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 14px; overflow: hidden; }
.card .k { font-size: 11px; text-transform: uppercase; letter-spacing: .4px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card .v { font-size: 20px; font-weight: 800; margin-top: 6px; white-space: nowrap; }
.card .s { font-size: 11px; color: var(--muted); margin-top: 3px; }
.card.hl { background: var(--brand); color: #fff; }
.card.hl .k, .card.hl .s { color: #edd3dd; }
.card .v.ok { color: var(--ok); }
.card .v.bad { color: var(--bad); }

/* Painéis */
.grid-2 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 14px; margin-bottom: 14px; }
.panel { min-width: 0; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 14px; }
.page > .panel { margin-bottom: 14px; }
.panel h2 { font-size: 13px; font-weight: 600; margin: 0 0 12px; color: var(--brand); }
.panel h2 .hint { font-weight: 400; color: var(--muted); font-size: 12px; margin-left: 6px; }
.panel.note { font-size: 13px; line-height: 1.6; color: #5b5157; background: #fdfbfc; }
.chart-wrap { position: relative; height: 260px; }

/* Tabelas */
.table-wrap { overflow-x: auto; max-width: 100%; }
table { width: 100%; min-width: 640px; border-collapse: collapse; font-size: 13px; }
th, td { padding: 9px 10px; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { font-size: 11px; text-transform: uppercase; letter-spacing: .4px; color: var(--muted); font-weight: 600; background: #fbf9fa; position: sticky; top: 0; }
td.num, th.num { text-align: right; }
tbody tr:hover { background: #fbf9fa; }
tr.total td { font-weight: 700; border-top: 2px solid var(--line); background: #fbf9fa; }
td.name { white-space: normal; min-width: 220px; }

/* Hierarquia (tráfego) */
tr.lv-campanha { cursor: pointer; font-weight: 600; }
tr.lv-campanha td:first-child::before { content: "▸ "; color: var(--brand-2); }
tr.lv-campanha.open td:first-child::before { content: "▾ "; }
tr.lv-conjunto td:first-child { padding-left: 30px; font-weight: 500; }
tr.lv-anuncio td:first-child { padding-left: 50px; color: var(--muted); }
tr.lv-conjunto, tr.lv-anuncio { display: none; background: #fdfcfc; }
tr.lv-conjunto.show, tr.lv-anuncio.show { display: table-row; }
tr.orfa td { color: var(--warn); font-style: italic; }

.tag { font-size: 11px; padding: 2px 7px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); background: var(--paper); }
.tag.ok { color: var(--ok); border-color: #cfe8df; background: #f2faf7; }
.tag.bad { color: var(--bad); border-color: #f0d5d5; background: #fdf3f3; }
.tag.warn { color: var(--warn); border-color: #e8d9a8; background: #fff8e6; }
.roas.ok { color: var(--ok); font-weight: 700; }
.roas.bad { color: var(--bad); font-weight: 700; }

.vazio { padding: 28px; text-align: center; color: var(--muted); font-size: 13px; }

footer { max-width: 1320px; margin: 0 auto; padding: 8px 18px 28px; color: var(--muted); font-size: 12px; }

@media (max-width: 860px) {
  .grid-2 { grid-template-columns: 1fr; }
  .topbar { padding: 10px 12px; }
  .brand h1 { font-size: 13px; }
  .periodbar { padding: 12px 12px 0; }
  main { padding: 12px; }
  .cards { gap: 10px; }
  .card { flex: 1 1 calc(50% - 5px); max-width: none; padding: 12px 14px; }
  .card .v { font-size: 18px; }
  .panel { padding: 12px; }
  .chart-wrap { height: 220px; }
}

/* Funil — rótulo fora do desenho: dentro, faixa estreita corta o texto */
svg.funil { width: 100%; height: auto; display: block; }
svg.funil .fx-rot { text-anchor: end; font-size: 14px; fill: var(--ink); font-weight: 500; }
svg.funil .fx-num { text-anchor: middle; font-family: Montserrat, sans-serif;
                    font-weight: 800; font-size: 20px; fill: #fff; }
svg.funil .fx-q { text-anchor: start; font-family: Montserrat, sans-serif;
                  font-size: 13px; font-weight: 700; fill: var(--muted); }
svg.funil polygon { transition: opacity .2s; }
svg.funil polygon:hover { opacity: 1 !important; }

/* Criativos — a imagem é o card e clicar abre o anúncio (padrão do dash da AUVP) */
.grid-criativos {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 14px; margin-bottom: 14px;
}
.cri { background: var(--card); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; display: flex; flex-direction: column; }
.cri.vendeu { border-color: #bfe3d4; box-shadow: 0 0 0 1px #bfe3d4 inset; }
.cri-thumb {
  position: relative; display: block; aspect-ratio: 9 / 16; max-height: 300px;
  background: #efeaec; overflow: hidden;
}
.cri-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .3s; }
.cri-thumb:hover img { transform: scale(1.04); }
.cri-thumb.sem-img::after {
  content: "sem prévia"; position: absolute; inset: 0; display: flex;
  align-items: center; justify-content: center; color: var(--muted); font-size: 12px;
}
.cri-lupa {
  position: absolute; top: 8px; right: 8px; width: 26px; height: 26px; border-radius: 50%;
  background: rgba(0,0,0,.55); color: #fff; display: flex; align-items: center;
  justify-content: center; font-size: 13px; opacity: 0; transition: opacity .2s;
}
.cri-thumb:hover .cri-lupa { opacity: 1; }
.cri-corpo { padding: 12px; display: flex; flex-direction: column; gap: 10px; }
.cri-nome { font-weight: 600; font-size: 13px; }
.cri-num { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 6px; }
.cri-num div { display: flex; flex-direction: column; }
.cri-num b { font-family: Montserrat, sans-serif; font-size: 14px; font-weight: 800; }
.cri-num span { font-size: 10px; text-transform: uppercase; letter-spacing: .3px; color: var(--muted); }
.cri-pe {
  display: flex; flex-wrap: wrap; gap: 4px 10px; padding-top: 9px;
  border-top: 1px solid var(--line); font-size: 11px; color: var(--muted);
}
@media (max-width: 640px) { .grid-criativos { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); } }
