/* Zeta Academy — dashboard de vendas.
   Cores e tipografia vêm de tokens.css (fonte única da marca). Não redefinir aqui. */

*, *::before, *::after { box-sizing: border-box; }

:root {
  /* Status: paleta fixa de dataviz, nunca tematizada. Só aparece nas tiles de
     saúde, sempre com ícone + rótulo — nunca cor sozinha. */
  --status-good: var(--accent);   /* o verde da marca já é o "bom" */
  --status-warning: #fab219;
  --status-critical: #d03b3b;

  --maxw: 1180px;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-weight: 400;
  -webkit-font-smoothing: antialiased;
}

h1, h2 { font-family: var(--font-display); font-weight: 900; letter-spacing: -0.02em; margin: 0; }
h1 { font-size: 2rem; margin-bottom: 1.25rem; }
h2 { font-size: 1.0625rem; }

code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.9em; color: var(--text-muted); }

.muted { color: var(--text-muted); }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.skip {
  position: absolute; left: -9999px; top: 0; z-index: 10;
  background: var(--accent); color: var(--black); padding: 0.5rem 1rem; font-weight: 700;
}
.skip:focus { left: 0; }

/* Foco sempre visível — piso de qualidade da marca. */
:where(a, button, input, summary):focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

/* ---------- layout ---------- */

.topo {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 1.5rem 1.5rem 0;
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
}
.wordmark { height: 38px; width: auto; display: block; }

.topo-meta { display: flex; align-items: center; gap: 0.75rem; }
.btn-sync {
  display: inline-flex; align-items: center; gap: 0.4rem;
  font-family: var(--font-body); font-size: 0.8125rem; font-weight: 500;
  background: transparent; color: var(--text-muted);
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 0.35rem 0.7rem; cursor: pointer;
}
.btn-sync:hover { color: var(--text); background: var(--bg-3); border-color: var(--bg-3); }
.btn-sync[disabled] { opacity: 0.55; cursor: wait; }
.btn-sync-icon { display: inline-block; }
.btn-sync[data-loading="true"] .btn-sync-icon { animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.topo-meta { font-size: 0.8125rem; }

main { max-width: var(--maxw); margin: 0 auto; padding: 2rem 1.5rem 3rem; }

.bloco {
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.5rem;
  margin-bottom: 1.25rem;
}

.bloco-topo {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 1rem; flex-wrap: wrap; margin-bottom: 1.25rem;
}

.sub { color: var(--text-muted); font-size: 0.8125rem; font-weight: 300; margin: 0.25rem 0 0; }

.rodape { max-width: var(--maxw); margin: 0 auto; padding: 0 1.5rem 2rem; font-size: 0.75rem; }

/* ---------- filtros ---------- */

.filtros {
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; flex-wrap: wrap; margin-bottom: 1.25rem;
}

.periodos, .dimensoes { display: flex; gap: 0.25rem; background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 0.25rem; }

.periodos button, .dimensoes button {
  font-family: var(--font-body); font-size: 0.8125rem; font-weight: 500;
  color: var(--text-muted); background: transparent; border: 0;
  padding: 0.4rem 0.75rem; border-radius: 6px; cursor: pointer;
}
.periodos button:hover, .dimensoes button:hover { color: var(--text); background: var(--bg-3); }
.periodos button[aria-pressed="true"], .dimensoes button[aria-pressed="true"] {
  background: var(--accent-soft); color: var(--accent); font-weight: 700;
}

.datas { display: flex; align-items: center; gap: 0.5rem; font-size: 0.8125rem; color: var(--text-muted); }
.datas input {
  font-family: var(--font-body); font-size: 0.8125rem;
  background: var(--bg-2); color: var(--text);
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 0.4rem 0.5rem; color-scheme: dark;
}

.btn-primario {
  font-family: var(--font-body); font-size: 0.8125rem; font-weight: 700;
  background: var(--accent); color: var(--black);
  border: 0; border-radius: var(--radius-sm); padding: 0.45rem 1rem; cursor: pointer;
}
.btn-primario:hover { background: var(--accent-deep); }

.aviso {
  border: 1px solid var(--line); border-left: 3px solid var(--status-warning);
  background: var(--bg-2); border-radius: var(--radius-sm);
  padding: 0.75rem 1rem; margin-bottom: 1.25rem; font-size: 0.8125rem;
}
.aviso[data-tipo="erro"] { border-left-color: var(--status-critical); }

/* ---------- hero + kpis ---------- */

.hero-linha { display: flex; align-items: flex-end; justify-content: space-between; gap: 2rem; flex-wrap: wrap; }

.rotulo {
  font-size: 0.6875rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--text-muted); margin: 0 0 0.4rem;
}

.hero-valor {
  font-family: var(--font-display); font-weight: 900; font-size: clamp(2.5rem, 6vw, 3.5rem);
  line-height: 1; letter-spacing: -0.03em; margin: 0;
  font-variant-numeric: tabular-nums;
}
.hero-delta, .kpi-delta { font-size: 0.8125rem; margin: 0.5rem 0 0; color: var(--text-muted); }

.kpis { display: flex; gap: 2.5rem; flex-wrap: wrap; row-gap: 1rem; }

/* Mídia paga ganha uma marca sutil — não é KPI "a mais", é o número que orienta
   decisão de investimento, então destaca sem gritar. */
.kpi-paga {
  padding-left: 0.9rem;
  border-left: 2px solid var(--accent-soft);
}
.kpi-valor {
  font-family: var(--font-display); font-weight: 700; font-size: 1.75rem;
  margin: 0; line-height: 1; font-variant-numeric: tabular-nums;
}

.delta-up { color: var(--accent); font-weight: 700; }
.delta-down { color: var(--text-muted); font-weight: 700; }

/* ---------- gráficos ---------- */

.grafico { margin: 0; }
.chart-host { width: 100%; }
/* O SVG é desenhado na largura real do container (ver app.js), então não escala
   por CSS — é o que mantém o texto no tamanho certo em qualquer tela. */
.chart-host svg { display: block; max-width: 100%; overflow: visible; }

.legenda { display: flex; gap: 1rem; font-size: 0.75rem; color: var(--text-muted); }
.legenda span { display: inline-flex; align-items: center; gap: 0.4rem; }
.legenda i { width: 14px; height: 2px; border-radius: 1px; flex: none; }

.vazio { color: var(--text-muted); font-size: 0.875rem; padding: 2.5rem 0; text-align: center; }

/* ---------- tabela (canal de acessibilidade) ---------- */

.tabela-toggle { margin-top: 1rem; }
.tabela-toggle summary {
  font-size: 0.75rem; color: var(--text-muted); cursor: pointer;
  list-style: none; display: inline-flex; align-items: center; gap: 0.4rem;
}
.tabela-toggle summary::-webkit-details-marker { display: none; }
.tabela-toggle summary::before { content: "▸"; font-size: 0.7em; }
.tabela-toggle[open] summary::before { content: "▾"; }
.tabela-toggle summary:hover { color: var(--text); }

.tabela-wrap { overflow-x: auto; margin-top: 0.75rem; }
table { border-collapse: collapse; width: 100%; font-size: 0.8125rem; }
th, td { text-align: left; padding: 0.5rem 0.75rem; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { font-weight: 700; color: var(--text-muted); font-size: 0.6875rem; text-transform: uppercase; letter-spacing: 0.06em; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- status ---------- */

.status-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 1rem; margin-top: 1.25rem;
}
.status-tile { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 1rem; background: var(--bg); }
.status-valor {
  font-family: var(--font-display); font-weight: 900; font-size: 1.75rem;
  margin: 0.25rem 0 0; line-height: 1; font-variant-numeric: tabular-nums;
}
.status-sinal { display: inline-flex; align-items: center; gap: 0.35rem; font-size: 0.75rem; font-weight: 700; margin-top: 0.5rem; }
.status-sinal svg { flex: none; }
.status-good { color: var(--status-good); }
.status-warning { color: var(--status-warning); }
.status-critical { color: var(--status-critical); }
.status-nota { font-size: 0.6875rem; color: var(--text-muted); font-weight: 300; margin: 0.4rem 0 0; }

/* ---------- tooltip ---------- */

.tooltip {
  position: fixed; pointer-events: none; z-index: 20;
  background: var(--bg-3); border: 1px solid var(--line);
  border-radius: var(--radius-sm); padding: 0.6rem 0.75rem;
  font-size: 0.75rem; line-height: 1.5;
  box-shadow: 0 8px 24px rgba(0,0,0,0.5);
  opacity: 0; transition: opacity 0.12s;
}
.tooltip[data-visivel="true"] { opacity: 1; }
.tooltip b { font-weight: 700; }
.tooltip .tt-linha { display: flex; align-items: center; gap: 0.4rem; white-space: nowrap; }
.tooltip .tt-swatch { width: 8px; height: 8px; border-radius: 2px; flex: none; }

@media (max-width: 640px) {
  .hero-linha { align-items: flex-start; }
  .kpis { gap: 1.5rem; }
  .filtros { align-items: stretch; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
