:root {
  --bg: #f5f6f8;
  --card: #ffffff;
  --text: #1d2330;
  --muted: #6b7385;
  --line: #e3e6ec;
  --brand: #2d5bff;
  --brand-soft: #e8eeff;
  --ok: #12985a;
  --ok-soft: #e3f6ec;
  --warn: #b7791f;
  --warn-soft: #fdf3e1;
  --bad: #d23c3c;
  --bad-soft: #fde8e8;
  --radius: 10px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12151c;
    --card: #1b1f29;
    --text: #e7e9ee;
    --muted: #9aa1b1;
    --line: #2b313e;
    --brand: #6e8cff;
    --brand-soft: #232c4a;
    --ok: #3cc98a;
    --ok-soft: #173326;
    --warn: #e0a84a;
    --warn-soft: #3a2f19;
    --bad: #f07070;
    --bad-soft: #3d1f22;
  }
}
* { box-sizing: border-box; }
/* Elementos escondidos pela busca/filtros somem mesmo quando o estilo deles define display (ex.: .prod é flex) */
[hidden] { display: none !important; }
body {
  margin: 0;
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
}
a { color: var(--brand); }
h1, h2, h3 { margin: 0; }
.wrap { max-width: 1180px; margin: 0 auto; padding: 0 16px; }

header.top {
  background: var(--card);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 5;
}
header.top .wrap { display: flex; align-items: center; gap: 16px; height: 56px; }
header.top h1 { font-size: 17px; white-space: nowrap; }
nav.tabs { display: flex; gap: 4px; overflow-x: auto; }
nav.tabs button {
  border: 0; background: none; color: var(--muted); font: inherit; font-weight: 600;
  padding: 8px 12px; border-radius: 8px; cursor: pointer; white-space: nowrap;
}
nav.tabs button.on { background: var(--brand-soft); color: var(--brand); }

main.wrap { padding-top: 28px; padding-bottom: 48px; }
section.view { display: none; }
section.view.on { display: block; }
.bar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 20px; }
.bar h2 { font-size: 18px; margin-right: auto; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; margin-bottom: 20px; }
.kpi .lbl { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
.kpi .val { font-size: 24px; font-weight: 700; margin-top: 4px; font-variant-numeric: tabular-nums; }

input, select, textarea {
  font: inherit; color: var(--text); background: var(--card);
  border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; width: 100%;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand); outline-offset: -1px; }
label { display: block; font-size: 12px; color: var(--muted); font-weight: 600; margin-bottom: 4px; }
.field { margin-bottom: 12px; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.btn {
  display: inline-flex; align-items: center; gap: 6px; justify-content: center;
  font: inherit; font-weight: 600; border-radius: 8px; padding: 8px 14px; cursor: pointer;
  border: 1px solid var(--line); background: var(--card); color: var(--text); text-decoration: none;
}
.btn:hover { border-color: var(--brand); }
.btn.pri { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn.sm { padding: 5px 9px; font-size: 13px; }
.btn.ghost { border-color: transparent; background: none; color: var(--muted); }
.btn.ghost:hover { color: var(--bad); }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; }
.prod { display: flex; flex-direction: column; padding: 0; overflow: hidden; }
.prod .foto { aspect-ratio: 1; background: #fff; display: flex; align-items: center; justify-content: center; border-bottom: 1px solid var(--line); }
.prod .foto img { max-width: 88%; max-height: 88%; object-fit: contain; }
.prod .info { padding: 12px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.prod .tit { font-weight: 600; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; min-height: 2.9em; }
.prod .precos { display: flex; justify-content: space-between; align-items: baseline; font-variant-numeric: tabular-nums; }
.prod .venda { font-size: 19px; font-weight: 700; }
.prod .custo { color: var(--muted); font-size: 12px; }
.prod .acoes { display: flex; flex-wrap: wrap; gap: 6px; margin-top: auto; padding-top: 6px; }

.pill { display: inline-block; font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 99px; }
.pill.ok { background: var(--ok-soft); color: var(--ok); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.bad { background: var(--bad-soft); color: var(--bad); }
.pill.azul { background: var(--brand-soft); color: var(--brand); }

/* Painel: gráfico de cliques por dia */
.grafico { display: flex; align-items: flex-end; gap: 4px; height: 190px; overflow-x: auto; padding-bottom: 2px; }
.grafico .barra { flex: 1 0 22px; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 3px; }
.grafico .b { width: 70%; min-height: 2px; background: var(--brand); border-radius: 4px 4px 0 0; }
.grafico .n { font-size: 11px; font-weight: 700; font-variant-numeric: tabular-nums; }
.grafico .d, .grafico .v { font-size: 10px; color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.check-linha { display: flex; align-items: center; gap: 8px; margin: 0; font-size: 14px; color: var(--text); font-weight: 400; cursor: pointer; }
.check-linha input { width: 18px; height: 18px; accent-color: var(--brand); }
.duas-colunas { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 800px) { .duas-colunas { grid-template-columns: 1fr; } }
.tabela { width: 100%; border-collapse: collapse; }
.tabela th, .tabela td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tabela th { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.tabela td.num, .tabela th.num { text-align: right; font-variant-numeric: tabular-nums; }
.tabela select { width: auto; padding: 4px 6px; }
.scroll-x { overflow-x: auto; }
.vazio { text-align: center; color: var(--muted); padding: 40px 16px; }
.muted { color: var(--muted); }

dialog {
  border: 1px solid var(--line); border-radius: 12px; padding: 0; width: min(520px, calc(100vw - 32px));
  background: var(--card); color: var(--text);
}
dialog::backdrop { background: rgba(10, 14, 25, .5); }
dialog form { padding: 20px; }
dialog h3 { margin-bottom: 14px; }
dialog .fim { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }

.toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 8px;
  font-weight: 600; opacity: 0; transition: opacity .2s; pointer-events: none; z-index: 50;
}
.toast.on { opacity: 1; }

.bookmarklet {
  display: inline-block; padding: 10px 18px; border-radius: 8px; background: #ffe600; color: #2d3277;
  font-weight: 700; text-decoration: none; border: 2px dashed #2d3277; cursor: grab;
}
ol.passos li { margin-bottom: 8px; }

.busca-topo { max-width: 240px; margin-left: auto; }

/* Vitrine: benefícios, anúncios e rodapé */
.apresentacao { margin-bottom: 18px; }
.apresentacao h2 { font-size: 22px; line-height: 1.3; margin-bottom: 8px; }
.beneficios { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 4px 20px; color: var(--muted); font-size: 14px; }
.anuncio:empty { display: none; }
.anuncio { margin: 0 0 20px; text-align: center; max-width: 100%; overflow: hidden; }
.anuncio ins.adsbygoogle { max-width: 100%; }
/* Quando o Google não tem anúncio para mostrar, o espaço some */
.anuncio:has(ins[data-ad-status="unfilled"]) { display: none; }
.anuncio-lista { grid-column: 1 / -1; margin: 4px 0; }
.rodape { border-top: 1px solid var(--line); color: var(--muted); font-size: 13px; padding: 20px 0 32px; }
.rodape p { margin: 0; }
.rodape-cats { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-bottom: 12px; }
.rodape-cats a { color: var(--muted); text-decoration: none; }
.rodape-cats a:hover { color: var(--brand); }

/* Páginas públicas: marca, categorias, migalhas e página de produto */
a.marca { color: inherit; text-decoration: none; }
.prod a.tit { color: var(--text); text-decoration: none; }
.prod a.tit:hover { color: var(--brand); }
.titulo-secao { font-size: 18px; margin: 4px 0 14px; }
/* No computador as categorias quebram linha; no celular deslizam para o lado, sem barra de rolagem */
.cats { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.cat { flex: none; padding: 6px 12px; border-radius: 99px; border: 1px solid var(--line); background: var(--card);
  color: var(--text); text-decoration: none; font-weight: 600; font-size: 13px; white-space: nowrap; }
.cat span { color: var(--muted); font-weight: 500; }
.cat.on, .cat:hover { border-color: var(--brand); color: var(--brand); }
.filtros { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; margin-bottom: 16px; }
.filtros select { width: auto; padding: 7px 10px; font-size: 13px; }
.filtros .check { display: inline-flex; align-items: center; gap: 6px; margin: 0; font-size: 13px; color: var(--text); font-weight: 600; cursor: pointer; }
.filtros .check input { width: 16px; height: 16px; accent-color: var(--brand); }
.filtros .contagem { margin-left: auto; color: var(--muted); font-size: 13px; }
.filtros .limpar { font-size: 13px; }
.migalhas { font-size: 13px; color: var(--muted); margin-bottom: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.migalhas a { color: var(--muted); }
.detalhe { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr); gap: 24px; margin-bottom: 24px; }
.detalhe-foto { background: #fff; border-radius: 8px; display: flex; align-items: center; justify-content: center; aspect-ratio: 1; }
.detalhe-foto img { max-width: 90%; max-height: 90%; object-fit: contain; }
.detalhe-info h2 { font-size: 22px; line-height: 1.3; margin-bottom: 14px; }
.detalhe-preco { display: flex; align-items: center; gap: 10px; margin: 4px 0 18px; }
.detalhe-preco span:first-child { font-size: 32px; font-weight: 700; font-variant-numeric: tabular-nums; }
.btn.grande { width: 100%; padding: 14px; font-size: 16px; }
.detalhe-lista { list-style: none; padding: 0; margin: 18px 0 0; display: grid; gap: 8px; color: var(--muted); font-size: 14px; }

@media (max-width: 640px) {
  header.top .wrap { height: auto; flex-direction: column; align-items: stretch; gap: 8px; padding-top: 12px; padding-bottom: 12px; }
  .busca-topo { max-width: none; margin-left: 0; }
  main.wrap { padding-top: 16px; }
  .row { grid-template-columns: 1fr; }
  /* Duas colunas de produtos no celular */
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .prod .info { padding: 10px; gap: 4px; }
  .prod .tit { font-size: 13px; }
  .prod .venda { font-size: 16px; }
  .prod .precos { flex-wrap: wrap; gap: 4px; }
  .prod .pill { font-size: 11px; padding: 1px 6px; }
  .prod .btn { padding: 7px 8px; font-size: 13px; }
  .so-largo { display: none; }
  .apresentacao { margin-bottom: 14px; }
  .apresentacao h2 { font-size: 17px; }
  .beneficios { font-size: 12px; gap: 2px 12px; }
  .cats { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin-left: -16px; margin-right: -16px; padding: 0 16px; }
  .cats::-webkit-scrollbar { display: none; }
  .filtros select { flex: 1 1 140px; }
  .filtros .contagem { margin-left: 0; width: 100%; }
  .detalhe { grid-template-columns: 1fr; gap: 14px; padding: 12px; }
  .detalhe-info h2 { font-size: 18px; }
  .detalhe-preco span:first-child { font-size: 26px; }
}
