/* Paleta de referência validada (categórica em ordem fixa, status reservado); claro e escuro selecionados */
.viz-root {
  color-scheme: light;
  --page: #f9f9f9;
  --surface-1: #ffffff;
  --text-primary: #191919;
  --text-secondary: #666666;
  --grid: #e7e7e7;
  --axis: #c2c2c2;
  --border: rgba(11, 11, 11, 0.10);
  --wash: rgba(11, 11, 11, 0.05);
  --series-1: #257de0;
  --series-2: #f47230;
  --series-3: #00b894;
  --accent-ink: #1b64be;
  --warning: #fbb315;
  --critical: #dc3c3d;
}
@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) .viz-root {
    color-scheme: dark;
    --page: #0b0b0b;
    --surface-1: #191919;
    --text-primary: #efefef;
    --text-secondary: #9c9c9c;
    --grid: #303030;
    --axis: #474747;
    --border: rgba(255, 255, 255, 0.10);
    --wash: rgba(255, 255, 255, 0.06);
    --series-1: #338ced;
    --series-2: #e76624;
    --series-3: #00a888;
    --accent-ink: #84b9f3;
  }
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--page);
  color: var(--text-primary);
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif;
}
h1, h2, h3 { margin: 0; font-weight: 600; }
.secundario { color: var(--text-secondary); }
button, select, input { font: inherit; color: inherit; }

/* Login */
.tela-login { display: grid; place-items: center; min-height: 100vh; padding: 24px; }
.login {
  width: 100%; max-width: 340px; background: var(--surface-1); border: 1px solid var(--border);
  border-radius: 12px; padding: 28px;
}
.login h1 { font-size: 20px; }
.login p { margin: 4px 0 20px; }
.login label { display: block; font-weight: 500; margin-bottom: 6px; }
.login input {
  width: 100%; padding: 9px 11px; border: 1px solid var(--axis); border-radius: 8px; background: var(--surface-1);
}
.login button { width: 100%; margin-top: 16px; }
.erro { color: var(--critical); margin: 10px 0 0 !important; }
.erro::before { content: "⚠ "; }

button {
  cursor: pointer; border: 0; border-radius: 8px; padding: 9px 14px;
  background: var(--series-1); color: #fff; font-weight: 500;
}
button.fantasma { background: transparent; color: var(--text-secondary); border: 1px solid var(--border); padding: 6px 12px; }
button.fantasma:hover { background: var(--wash); color: var(--text-primary); }
:focus-visible { outline: 2px solid var(--series-1); outline-offset: 2px; }

/* Painel */
.topo {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 16px 24px; background: var(--surface-1); border-bottom: 1px solid var(--border);
}
.topo h1 { font-size: 18px; }
.topo form { margin: 0; }
main.painel { max-width: 1280px; margin: 0 auto; padding: 20px 24px 48px; }

.filtros { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px 20px; margin-bottom: 20px; }
.filtros label { display: block; font-size: 12px; color: var(--text-secondary); margin-bottom: 4px; }
.filtros select, .filtros input {
  padding: 7px 10px; border: 1px solid var(--axis); border-radius: 8px; background: var(--surface-1); min-width: 150px;
}
.presets { display: inline-flex; border: 1px solid var(--axis); border-radius: 8px; overflow: hidden; background: var(--surface-1); }
.presets button {
  background: transparent; color: var(--text-primary); border-radius: 0; padding: 7px 12px; font-weight: 400;
  border-right: 1px solid var(--grid);
}
.presets button:last-child { border-right: 0; }
.presets button:hover { background: var(--wash); }
.presets button[aria-pressed="true"] { font-weight: 600; background: var(--wash); }
.presets button[aria-pressed="true"]::before { content: "✓ "; font-weight: 700; }
.datas { display: flex; gap: 8px; align-items: flex-end; }
.datas[hidden] { display: none; }

.aviso {
  background: var(--surface-1); border: 1px solid var(--border); border-left: 3px solid var(--warning);
  border-radius: 8px; padding: 10px 14px; margin-bottom: 16px;
}
.aviso[hidden] { display: none; }
.aviso::before { content: "ⓘ "; }

.resumo { display: grid; grid-template-columns: minmax(220px, 1.2fr) 3fr; gap: 12px; margin-bottom: 12px; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; }
.tile, .cartao { background: var(--surface-1); border: 1px solid var(--border); border-radius: 12px; }
.tile { padding: 14px 16px; }
.tile .rotulo { color: var(--text-secondary); font-size: 13px; }
.tile .valor { font-size: 26px; font-weight: 600; margin-top: 2px; }
.tile .detalhe { color: var(--text-secondary); font-size: 12px; margin-top: 2px; }
.tile.heroi { display: flex; flex-direction: column; justify-content: center; padding: 20px 22px; }
.tile.heroi .valor { font-size: 56px; line-height: 1.1; }
.tile.alerta .valor::before { content: "⚠ "; font-size: 20px; color: var(--critical); }

.graficos { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.cartao { padding: 16px 18px; min-width: 0; }
.cartao.largo { grid-column: 1 / -1; }
.cartao header { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 10px; }
.cartao h2 { font-size: 15px; }
.cartao header p { margin: 2px 0 0; font-size: 12px; }
.area { position: relative; height: 260px; }
.cartao.largo .area { height: 280px; }
.vazio { display: grid; place-items: center; height: 100%; color: var(--text-secondary); }
.tabela { max-height: 280px; overflow: auto; }
.tabela table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.tabela th, .tabela td { text-align: right; padding: 5px 8px; border-bottom: 1px solid var(--grid); }
.tabela th:first-child, .tabela td:first-child { text-align: left; }
.tabela th { color: var(--text-secondary); font-weight: 500; position: sticky; top: 0; background: var(--surface-1); }

.carregando .resumo, .carregando .graficos { opacity: 0.55; transition: opacity 0.15s; }
.rodape { margin-top: 20px; font-size: 12px; color: var(--text-secondary); }

@media (max-width: 860px) {
  .resumo, .graficos { grid-template-columns: 1fr; }
  .topo, main.painel { padding-left: 14px; padding-right: 14px; }
}
