:root {
  --fundo: #f5f6f8;
  --superficie: #ffffff;
  --texto: #1f2733;
  --texto-2: #4b5563;
  --texto-3: #6b7280;
  --borda: #e3e6ea;
  --grade: #eceef1;
  --acento: #2563eb;
  --acento-texto: #ffffff;
  --aviso-fundo: #fff4e5;
  --aviso-texto: #7a4a00;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --fundo: #12161c;
    --superficie: #1b2129;
    --texto: #e7eaee;
    --texto-2: #b4bcc6;
    --texto-3: #8a94a0;
    --borda: #2c343e;
    --grade: #262d36;
    --acento: #6b9cff;
    --acento-texto: #0b1220;
    --aviso-fundo: #3a2a10;
    --aviso-texto: #ffd699;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

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

.topo {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 16px 24px;
  background: var(--superficie);
  border-bottom: 1px solid var(--borda);
}
h1 { font-size: 20px; margin: 0; }
h2 { font-size: 16px; margin: 0; }
.sub { margin: 2px 0 0; color: var(--texto-3); font-size: 13px; }
.usuario { display: flex; align-items: center; gap: 12px; color: var(--texto-2); }

main { max-width: 1200px; margin: 0 auto; padding: 24px 16px 48px; }

button {
  font: inherit;
  border: 0;
  border-radius: 6px;
  padding: 8px 14px;
  background: var(--acento);
  color: var(--acento-texto);
  cursor: pointer;
}
button:disabled { opacity: .6; cursor: wait; }
.botao-secundario { background: transparent; color: var(--texto-2); border: 1px solid var(--borda); }
.botao-link { background: none; color: var(--acento); padding: 4px 0; }

.cartao {
  background: var(--superficie);
  border: 1px solid var(--borda);
  border-radius: 8px;
  padding: 16px 20px;
  margin-bottom: 24px;
}
.cartao-topo { display: flex; justify-content: space-between; align-items: center; }
.centro { text-align: center; }

.aviso {
  background: var(--aviso-fundo);
  color: var(--aviso-texto);
  border-radius: 8px;
  padding: 12px 16px;
  margin-bottom: 16px;
  white-space: pre-line;
}

.filtros {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 12px 16px;
  margin-bottom: 20px;
}
.filtros label, .unidades { display: flex; flex-direction: column; gap: 4px; color: var(--texto-2); font-size: 13px; }
.rotulo { color: var(--texto-2); font-size: 13px; }
select, input, .seletor {
  font: inherit;
  color: var(--texto);
  background: var(--superficie);
  border: 1px solid var(--borda);
  border-radius: 6px;
  padding: 7px 10px;
  min-width: 160px;
}
.seletor { text-align: left; min-width: 220px; }

.unidades { position: relative; }
.lista-unidades {
  position: absolute;
  top: 100%;
  left: 0;
  z-index: 10;
  width: min(420px, 90vw);
  margin-top: 4px;
  background: var(--superficie);
  border: 1px solid var(--borda);
  border-radius: 8px;
  padding: 8px;
  box-shadow: 0 8px 24px rgb(0 0 0 / .12);
}
.lista-unidades input { width: 100%; }
.acoes-lista { display: flex; justify-content: flex-end; }
.lista-unidades ul { list-style: none; margin: 0; padding: 0; max-height: 320px; overflow: auto; }
.lista-unidades li label { flex-direction: row; align-items: flex-start; gap: 8px; padding: 4px 2px; color: var(--texto); }
.lista-unidades li .caminho { color: var(--texto-3); font-size: 12px; }

.grafico { width: 100%; height: 420px; }

.tabela { overflow-x: auto; margin-top: 12px; }
table { border-collapse: collapse; width: 100%; font-variant-numeric: tabular-nums; }
th, td { padding: 6px 10px; border-bottom: 1px solid var(--grade); text-align: right; white-space: nowrap; }
th:first-child, td:first-child { text-align: left; }
th { color: var(--texto-2); font-weight: 600; }

.titulo-secao { margin: 8px 0 12px; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.card {
  background: var(--superficie);
  border: 1px solid var(--borda);
  border-radius: 8px;
  padding: 14px 16px;
}
.card-titulo { display: flex; align-items: center; gap: 8px; font-weight: 600; margin-bottom: 10px; }
.amostra { width: 12px; height: 12px; border-radius: 3px; flex: none; }
.card-valores { display: flex; justify-content: space-between; align-items: flex-end; }
.card-valores .rotulo-pequeno { color: var(--texto-3); font-size: 12px; }
.card-valores .valor { font-size: 22px; font-weight: 600; font-variant-numeric: tabular-nums; }
.card-valores .direita { text-align: right; }
.delta { color: var(--texto-2); font-size: 12px; margin-top: 6px; }
.trilho { position: relative; height: 10px; margin-top: 10px; }
.trilho .linha { position: absolute; left: 6px; right: 6px; top: 4px; height: 2px; border-radius: 1px; }
.trilho .ponto { position: absolute; top: 0; width: 10px; height: 10px; border-radius: 50%; box-shadow: 0 0 0 2px var(--superficie); }

@media (max-width: 640px) {
  .topo { padding: 12px 16px; }
  .grafico { height: 360px; }
  .filtros > * { flex: 1 1 100%; }
  select, input, .seletor { width: 100%; }
}
