:root {
  --fundo: #f4f6f9;
  --superficie: #ffffff;
  --borda: #dde3ea;
  --texto: #1c2733;
  --texto-suave: #5b6b7c;
  --primaria: #1f4e79;
  --primaria-escura: #173a5a;
  --primaria-clara: #e8f0f8;
  --ok: #1e7a46;      --ok-fundo: #e3f4ea;
  --aviso: #8a5a00;   --aviso-fundo: #fff3d6;
  --erro: #b3261e;    --erro-fundo: #fde7e5;
  --info: #1f4e79;    --info-fundo: #e8f0f8;
  --neutro: #4b5563;  --neutro-fundo: #eceff3;
  --raio: 10px;
  --sombra: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--fundo); color: var(--texto);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
a { color: var(--primaria); }
h1 { font-size: 1.45rem; margin: 0 0 .25rem; }
h2 { font-size: 1.1rem; margin: 0 0 .75rem; }
.sub { color: var(--texto-suave); margin: 0 0 1.25rem; }
code, .mono { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: .85em; }

/* faixa de ambiente */
.ambiente { text-align: center; font-size: .8rem; font-weight: 600; padding: .3rem 1rem; letter-spacing: .02em; }
.ambiente.homologacao { background: var(--aviso-fundo); color: var(--aviso); }
.ambiente.producao { background: var(--erro); color: #fff; }

/* topo */
.topo { background: var(--primaria); color: #fff; }
.topo .dentro { max-width: 1200px; margin: 0 auto; padding: 0 16px; display: flex; align-items: center;
  gap: 1.5rem; min-height: 56px; flex-wrap: wrap; }
.marca { font-weight: 700; font-size: 1.05rem; color: #fff; text-decoration: none; white-space: nowrap; }
.marca span { opacity: .7; font-weight: 500; }
.menu { display: flex; gap: .25rem; flex-wrap: wrap; flex: 1; }
.menu a { color: #dce8f4; text-decoration: none; padding: .45rem .75rem; border-radius: 8px; font-weight: 500; }
.menu a:hover { background: rgba(255,255,255,.1); color: #fff; }
.menu a.ativo { background: rgba(255,255,255,.16); color: #fff; }
.quem { display: flex; align-items: center; gap: .75rem; font-size: .88rem; color: #dce8f4; }
.quem form { margin: 0; }
.quem button { background: transparent; border: 1px solid rgba(255,255,255,.35); color: #fff; border-radius: 8px;
  padding: .3rem .7rem; cursor: pointer; font: inherit; }

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

/* blocos */
.cartao { background: var(--superficie); border: 1px solid var(--borda); border-radius: var(--raio);
  box-shadow: var(--sombra); padding: 20px; margin-bottom: 20px; }
.grade { display: grid; gap: 16px; }
.grade.kpis { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); margin-bottom: 20px; }
.kpi { background: var(--superficie); border: 1px solid var(--borda); border-radius: var(--raio); padding: 16px;
  box-shadow: var(--sombra); }
.kpi .rotulo { color: var(--texto-suave); font-size: .85rem; }
.kpi .valor { font-size: 1.8rem; font-weight: 700; line-height: 1.2; font-variant-numeric: tabular-nums; }
.kpi.ok .valor { color: var(--ok); } .kpi.aviso .valor { color: var(--aviso); } .kpi.erro .valor { color: var(--erro); }

/* tabelas */
.tabela-wrap { overflow-x: auto; margin: 0 -20px; padding: 0 20px; }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th { text-align: left; color: var(--texto-suave); font-weight: 600; font-size: .78rem; text-transform: uppercase;
  letter-spacing: .03em; padding: .6rem .6rem; border-bottom: 1px solid var(--borda); white-space: nowrap; }
td { padding: .65rem .6rem; border-bottom: 1px solid var(--borda); vertical-align: top; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #f8fafc; }
td.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
td.msg { color: var(--texto-suave); max-width: 460px; }
td.mono { white-space: nowrap; }
.vazio { text-align: center; color: var(--texto-suave); padding: 2rem 1rem; }

/* etiquetas */
.tag { display: inline-block; padding: .12rem .55rem; border-radius: 999px; font-size: .78rem; font-weight: 600;
  white-space: nowrap; }
.tag.ok { background: var(--ok-fundo); color: var(--ok); }
.tag.aviso { background: var(--aviso-fundo); color: var(--aviso); }
.tag.erro { background: var(--erro-fundo); color: var(--erro); }
.tag.info { background: var(--info-fundo); color: var(--info); }
.tag.neutro { background: var(--neutro-fundo); color: var(--neutro); }
.tipo { font-weight: 700; font-size: .75rem; color: var(--primaria); background: var(--primaria-clara);
  padding: .1rem .4rem; border-radius: 4px; }

/* formulários e botões */
label { display: block; font-weight: 600; font-size: .88rem; margin-bottom: .3rem; }
input[type=text], input[type=password], input[type=search], select, textarea {
  width: 100%; padding: .55rem .7rem; border: 1px solid var(--borda); border-radius: 8px; font: inherit;
  background: #fff; color: var(--texto); }
input:not([type]) { width: 100%; padding: .55rem .7rem; border: 1px solid var(--borda); border-radius: 8px; font: inherit;
  background: #fff; color: var(--texto); }
.form-gestao label { margin-bottom: .8rem; }
/* dashboard */
.dash-topo { display: grid; grid-template-columns: minmax(240px, 1fr) 2fr; gap: 16px; align-items: center; }
.hero .rotulo { color: var(--texto-suave); font-size: .9rem; }
.hero-valor { font-size: 2.6rem; font-weight: 650; line-height: 1.15; margin: .2rem 0; }
.dash-kpis { margin: 0; }
@media (max-width: 760px) { .dash-topo { grid-template-columns: 1fr; } .hero-valor { font-size: 2.1rem; } }
.grafico { position: relative; }
.grafico svg { width: 100%; height: auto; display: block; overflow: visible; }
.grafico .grade-linha { stroke: #e6ebf1; stroke-width: 1; }
.grafico .eixo-linha { stroke: #c9d2dc; stroke-width: 1; }
.grafico .eixo { fill: var(--texto-suave); font-size: 11px; font-variant-numeric: tabular-nums; }
.grafico .eixo-atual { fill: var(--texto); font-weight: 600; }
.grafico .coluna { fill: #6f94ba; }   /* meses anteriores: mesmo azul, um tom mais claro (contraste >= 3:1) */
.grafico .coluna.atual { fill: var(--primaria); }
.grafico .valor-rotulo { fill: var(--texto); font-size: 12px; font-weight: 600; }
.grafico .alvo { fill: transparent; cursor: pointer; }
.grafico .alvo.sobre { fill: rgba(31, 78, 121, .06); }
.grafico .dica { position: absolute; pointer-events: none; background: var(--superficie); border: 1px solid var(--borda);
  box-shadow: var(--sombra); border-radius: 8px; padding: .4rem .6rem; font-size: .85rem; white-space: nowrap; }
.grafico .dica span { color: var(--texto-suave); }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.ranking { display: grid; grid-template-columns: minmax(110px, 1.1fr) 2fr auto; gap: .55rem .6rem; align-items: center; }
.rank-linha { display: contents; }   /* as 3 colunas de todas as linhas ficam alinhadas */
.rank-nome { font-size: .9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rank-trilho { height: 14px; }
.rank-barra { height: 14px; background: var(--primaria); border-radius: 0 4px 4px 0; min-width: 2px; }
.rank-valor { font-size: .88rem; }
@media (max-width: 520px) { .ranking { grid-template-columns: 1fr auto; } .rank-trilho { grid-column: 1 / -1; order: 0; } }
.abas { display: flex; gap: .25rem; flex-wrap: wrap; border-bottom: 1px solid var(--borda); margin: 1rem 0; }
.abas button { background: none; border: 0; border-bottom: 3px solid transparent; padding: .6rem 1rem; font: inherit;
  font-weight: 600; color: var(--texto-suave); cursor: pointer; }
.abas button[aria-selected=true] { color: var(--primaria); border-bottom-color: var(--primaria); }
.abas .contador { background: var(--aviso-fundo); color: var(--aviso); border-radius: 999px; padding: 0 .5rem; font-size: .8rem; }
.form-gestao label input, .form-gestao label select { margin-top: .3rem; font-weight: 400; }
input:focus, select:focus, textarea:focus, button:focus-visible, .botao:focus-visible {
  outline: 2px solid var(--primaria); outline-offset: 1px; }
.botao, button.botao { display: inline-flex; align-items: center; gap: .4rem; background: var(--primaria);
  color: #fff; border: 0; border-radius: 8px; padding: .6rem 1.1rem; font: inherit; font-weight: 600;
  cursor: pointer; text-decoration: none; }
.botao:hover { background: var(--primaria-escura); }
.botao.secundario { background: #fff; color: var(--primaria); border: 1px solid var(--borda); }
.botao.secundario:hover { background: var(--primaria-clara); }
.botao.perigo { background: var(--erro); }
.botao:disabled { opacity: .5; cursor: not-allowed; }
.acoes { display: flex; gap: .6rem; flex-wrap: wrap; align-items: center; }
.filtros { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; align-items: end; }

/* upload */
.soltar { border: 2px dashed var(--borda); border-radius: var(--raio); padding: 32px 16px; text-align: center;
  background: #fafbfd; cursor: pointer; transition: .15s; display: block; }
.soltar:hover, .soltar.arrastando { border-color: var(--primaria); background: var(--primaria-clara); }
.soltar strong { display: block; font-size: 1.05rem; margin-bottom: .25rem; }
.soltar input { display: none; }
.passos { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; margin: 0;
  padding: 0; list-style: none; counter-reset: p; }
.passos li { counter-increment: p; padding-left: 2.2rem; position: relative; color: var(--texto-suave); font-size: .9rem; }
.passos li::before { content: counter(p); position: absolute; left: 0; top: 0; width: 1.6rem; height: 1.6rem;
  border-radius: 50%; background: var(--primaria-clara); color: var(--primaria); font-weight: 700;
  display: grid; place-items: center; font-size: .85rem; }
.passos li b { color: var(--texto); display: block; }

/* avisos */
.alerta { border-radius: 8px; padding: .75rem 1rem; margin-bottom: 16px; font-size: .92rem; }
.alerta.ok { background: var(--ok-fundo); color: var(--ok); }
.alerta.erro { background: var(--erro-fundo); color: var(--erro); }
.alerta.aviso { background: var(--aviso-fundo); color: var(--aviso); }
.alerta.info { background: var(--info-fundo); color: var(--info); }

.giro { width: 18px; height: 18px; border: 3px solid var(--primaria-clara); border-top-color: var(--primaria);
  border-radius: 50%; animation: gira 1s linear infinite; display: inline-block; vertical-align: middle; }
@keyframes gira { to { transform: rotate(360deg); } }

dl.dados { display: grid; grid-template-columns: max-content 1fr; gap: .45rem 1.25rem; margin: 0; }
dl.dados dt { color: var(--texto-suave); font-size: .88rem; }
dl.dados dd { margin: 0; word-break: break-all; }

/* login */
.login { max-width: 380px; margin: 10vh auto; }
.login .cartao { padding: 28px; }
.login h1 { text-align: center; margin-bottom: 1.25rem; }
.login .campo { margin-bottom: 14px; }
.login button { width: 100%; justify-content: center; }

dialog { border: 0; border-radius: var(--raio); padding: 24px; max-width: 480px; width: calc(100% - 32px);
  box-shadow: 0 20px 50px rgba(0,0,0,.25); }
dialog::backdrop { background: rgba(16, 24, 40, .45); }

@media (max-width: 640px) {
  .topo .dentro { padding: 8px 16px; gap: .5rem; }
  .marca { flex: 1; }
  .menu { order: 3; width: 100%; flex: none; padding-bottom: 6px; }
  .quem { gap: .5rem; }
  .quem span { display: none; }
  h1 { font-size: 1.25rem; }
  dl.dados { grid-template-columns: 1fr; gap: .1rem; }
  dl.dados dd { margin-bottom: .5rem; }
}
