:root {
  --bg: #f5f6f3;
  --card: #ffffff;
  --text: #1d2420;
  --muted: #66706a;
  --line: #e3e6e1;
  --accent: #2f7d4f;
  --accent-soft: #e4f1e8;
  --up: #c0392b;
  --up-soft: #fbe9e7;
  --down: #2f7d4f;
  --down-soft: #e4f1e8;
  --radius: 14px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121614;
    --card: #1b201d;
    --text: #e8ece9;
    --muted: #9aa49e;
    --line: #2b322e;
    --accent: #5cc285;
    --accent-soft: #1f3528;
    --up: #ef7b6c;
    --up-soft: #3a2220;
    --down: #5cc285;
    --down-soft: #1f3528;
  }
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
.wrap { max-width: 1200px; margin: 0 auto; padding: 0 16px; }
h1, h2 { margin: 0; }
h2 { font-size: 1.05rem; }
code { background: var(--accent-soft); padding: 1px 6px; border-radius: 6px; }

.topo { padding: 28px 0 20px; }
.topo h1 { font-size: 1.7rem; }
.sub { margin: 4px 0 0; color: var(--muted); }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 16px;
}
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.kpi span { display: block; color: var(--muted); font-size: .82rem; }
.kpi strong { font-size: 1.4rem; font-variant-numeric: tabular-nums; }

.grid { display: grid; grid-template-columns: 300px 1fr; gap: 16px; align-items: start; }
.col { min-width: 0; }

.produtos ul { list-style: none; margin: 0; padding: 0; max-height: 640px; overflow: auto; }
.produtos li button {
  width: 100%; text-align: left; background: none; border: 0; color: inherit; font: inherit;
  padding: 9px 10px; border-radius: 9px; cursor: pointer; display: flex; justify-content: space-between; gap: 8px;
}
.produtos li button:hover { background: var(--bg); }
.produtos li button.ativo { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.produtos small { color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
#busca {
  width: 100%; padding: 8px 10px; border: 1px solid var(--line); border-radius: 9px;
  background: var(--bg); color: var(--text); font: inherit;
}

.tag { font-size: .85rem; padding: 3px 10px; border-radius: 999px; font-weight: 600; }
.tag.up { background: var(--up-soft); color: var(--up); }
.tag.down { background: var(--down-soft); color: var(--down); }
.tag.flat { background: var(--bg); color: var(--muted); }

.mini-stats { display: flex; gap: 22px; flex-wrap: wrap; margin-bottom: 10px; }
.mini-stats div span { display: block; color: var(--muted); font-size: .8rem; }
.mini-stats div strong { font-variant-numeric: tabular-nums; }

.chart-box { position: relative; height: 320px; }
.chart-box.pequeno { height: 240px; }

.tabela { width: 100%; border-collapse: collapse; margin-top: 14px; font-size: .9rem; }
.tabela th, .tabela td { padding: 7px 8px; border-bottom: 1px solid var(--line); text-align: left; }
.tabela th { color: var(--muted); font-weight: 500; }
.tabela td.num, .tabela th.num { text-align: right; font-variant-numeric: tabular-nums; }

.compras { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; }
.compra { border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: var(--bg); }
.compra img { width: 100%; height: 180px; object-fit: cover; display: block; cursor: zoom-in; background: var(--line); }
.compra .info { padding: 10px 12px; }
.compra .info strong { display: block; }
.compra .info span { color: var(--muted); font-size: .85rem; }
.compra details { padding: 0 12px 10px; font-size: .85rem; }
.compra details summary { cursor: pointer; color: var(--accent); }
.compra details ul { margin: 6px 0 0; padding-left: 16px; }

dialog#lightbox { border: 0; padding: 0; background: transparent; max-width: 95vw; max-height: 95vh; }
dialog#lightbox::backdrop { background: rgba(0,0,0,.8); }
dialog#lightbox img { max-width: 95vw; max-height: 88vh; display: block; border-radius: 8px; }
dialog#lightbox .legenda { color: #fff; text-align: center; margin: 8px 0 0; }
dialog#lightbox .fechar {
  position: fixed; top: 12px; right: 16px; font-size: 2rem; background: none; border: 0; color: #fff; cursor: pointer;
}

.vazio p { color: var(--muted); max-width: 640px; }

@media (max-width: 820px) {
  .grid { grid-template-columns: 1fr; }
  .produtos ul { max-height: 260px; }
  .chart-box { height: 260px; }
}

.rodape { text-align: center; padding: 28px 16px 36px; color: var(--muted); font-size: .9rem; }
.rodape p { margin: 0 0 14px; }
.credito {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 10px 20px; border-radius: 999px;
  background: #1f5c34; color: #fff; text-decoration: none;
  border: 1px solid #2f7d4f; transition: background .15s, transform .15s;
}
.credito:hover { background: #26703f; transform: translateY(-1px); }
.credito .coracao { color: #6fdc8c; }
.credito strong { font-weight: 700; }

.compra .capa { position: relative; }
.qtd-fotos {
  position: absolute; right: 8px; bottom: 8px; background: rgba(0,0,0,.65); color: #fff;
  font-size: .75rem; padding: 2px 8px; border-radius: 999px;
}
.economia { color: var(--down); font-style: normal; }
.compra .info .economia { display: block; font-weight: 600; }
dialog#lightbox .nav {
  position: fixed; top: 50%; transform: translateY(-50%); font-size: 2.6rem; line-height: 1;
  background: rgba(0,0,0,.45); color: #fff; border: 0; border-radius: 50%; width: 52px; height: 52px; cursor: pointer;
}
dialog#lightbox .nav.ant { left: 12px; }
dialog#lightbox .nav.prox { right: 12px; }
