:root {
  --fundo: #f5f7f3;
  --cartao: #ffffff;
  --texto: #1b2119;
  --sutil: #5b6558;
  --borda: #e1e6dd;
  --primaria: #2e7d32;
  --sobre-primaria: #ffffff;
  --primaria-suave: #e2f0e2;
  --sobe: #c62828;
  --desce: #2e7d32;
  --sombra: 0 1px 2px rgba(0, 0, 0, .04), 0 6px 20px rgba(0, 0, 0, .04);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --fundo: #101310;
    --cartao: #191d18;
    --texto: #e5e9e2;
    --sutil: #9ba597;
    --borda: #2a3028;
    --primaria: #81c784;
    --sobre-primaria: #0b2e0f;
    --primaria-suave: #1c301d;
    --sobe: #ef9a9a;
    --desce: #81c784;
    --sombra: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--fundo);
  color: var(--texto);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

h1 { font-size: 1.5rem; line-height: 1.2; margin: 0; }
h2 { font-size: .9rem; font-weight: 600; margin: 0 0 12px; color: var(--sutil); }

.topo {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  max-width: 1100px;
  margin: 0 auto;
  padding: 24px 16px 8px;
}

main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 8px 16px 48px;
  display: grid;
  gap: 16px;
}

.indicadores {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.cartao {
  background: var(--cartao);
  border: 1px solid var(--borda);
  border-radius: 16px;
  padding: 20px;
  box-shadow: var(--sombra);
  min-width: 0;
}

.destaque { background: var(--primaria-suave); border-color: transparent; }

.valor {
  font-size: 1.9rem;
  font-weight: 700;
  margin: 0;
  font-variant-numeric: tabular-nums;
}

.sutil { color: var(--sutil); margin: 4px 0 0; font-size: .875rem; }
.sobe { color: var(--sobe); }
.desce { color: var(--desce); }

.grafico { position: relative; height: 280px; margin-top: 12px; }

select, input {
  font: inherit;
  color: inherit;
  background: var(--fundo);
  border: 1px solid var(--borda);
  border-radius: 10px;
  padding: 10px 12px;
  width: 100%;
  max-width: 440px;
}

button {
  font: inherit;
  cursor: pointer;
  border-radius: 10px;
  padding: 8px 16px;
  border: 1px solid var(--borda);
  background: var(--cartao);
  color: var(--texto);
}

.botao {
  background: var(--primaria);
  color: var(--sobre-primaria);
  border: none;
  padding: 12px 16px;
  font-weight: 600;
}

.tabela { overflow-x: auto; }

table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--borda); vertical-align: top; }
th { font-size: .8rem; color: var(--sutil); font-weight: 600; }
.num { text-align: right; white-space: nowrap; }
tr:last-child td { border-bottom: none; }

details { border-bottom: 1px solid var(--borda); }
details:last-child { border-bottom: none; }
summary {
  cursor: pointer;
  padding: 12px 0;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  list-style: none;
}
summary::-webkit-details-marker { display: none; }
summary::before { content: "▸"; color: var(--sutil); margin-right: 4px; }
details[open] summary::before { content: "▾"; }
summary > span:first-of-type { flex: 1; }
details table { margin-bottom: 12px; font-size: .9rem; }

.vazio { text-align: center; color: var(--sutil); padding: 64px 16px; max-width: 520px; margin: 0 auto; }

/* Tela de login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login form { width: 100%; max-width: 360px; display: grid; gap: 12px; }
.login input { max-width: none; }
.erro { color: var(--sobe); margin: 0; }

@media (max-width: 520px) {
  .valor { font-size: 1.6rem; }
  .grafico { height: 240px; }
}
