:root {
  color-scheme: light;
  /* ---- cores da marca, tiradas do vetor da logo ---- */
  --marca-laranja: #fe6718;
  --marca-ambar:   #ffa100;
  --marca-verde:   #97b33c;
  --marca-azul:    #1d5f95;
  /* Onde cada uma serve, medido: branco sobre o laranja da marca da contraste
     2,93 (reprova para texto), mas PRETO sobre ele da 7,17 -- por isso o botao
     laranja leva texto escuro. Como TEXTO, o laranja so funciona no tema escuro
     (5,94); no claro usamos a variante #c94e0b (4,47). */
  --marca-laranja-escuro: #c94e0b;
  --botao-texto: #16120f;
  --surface-0: #f4f4f2;
  --surface-1: #fcfcfb;
  --linha: #e3e2dd;
  --text-primary: #0b0b0b;
  --text-secondary: #52514e;
  --text-muted: #78776f;
  /* ⚠️ SERIE NAO USA A COR DA MARCA. Medido em OKLab: laranja x verde da marca
     ficam a 2,8 sob daltonismo (o minimo util e 8) -- quem tem deuteranopia ve
     a mesma linha duas vezes. Estas quatro foram escolhidas por busca sobre a
     paleta validada: pior par 19,6 normal e 16,9 sob daltonismo, e tres delas
     ecoam a marca (azul, ambar, verde). A identidade vive na moldura; os dados
     ficam legiveis. */
  --series-1: #2a78d6;
  --series-2: #eda100;
  --series-3: #008300;
  --series-4: #e87ba4;
  --good: #0ca30c;
  --warning: #fab219;
  --critical: #d03b3b;
  --acento: var(--marca-laranja-escuro);
  --sombra: 0 1px 2px rgba(0,0,0,.05), 0 4px 12px rgba(0,0,0,.04);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --surface-0: #111110;
    --surface-1: #1a1a19;
    --linha: #34332f;
    --text-primary: #ffffff;
    --text-secondary: #c3c2b7;
    --text-muted: #93928a;
    --series-1: #3987e5;
    --series-2: #c98500;
    --series-3: #008300;
    --series-4: #d55181;
    --acento: var(--marca-laranja);
    --sombra: none;
  }
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--surface-0);
  color: var(--text-primary);
  font: 15px/1.5 -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
button { font: inherit; cursor: pointer; }
h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -0.01em; }

/* ---------- login ---------- */
.login-tela {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface-1);
  border: 1px solid var(--linha);
  border-radius: 14px;
  padding: 28px;
  box-shadow: var(--sombra);
}
.login-card h1 { font-size: 20px; }
.login-card p.sub { margin: 6px 0 22px; color: var(--text-secondary); font-size: 13px; }
label { display: block; font-size: 13px; color: var(--text-secondary); margin: 14px 0 5px; }
input {
  width: 100%;
  padding: 11px 12px;
  font: inherit;
  color: var(--text-primary);
  background: var(--surface-0);
  border: 1px solid var(--linha);
  border-radius: 9px;
}
input:focus { outline: 2px solid var(--acento); outline-offset: 1px; }
.botao {
  width: 100%;
  margin-top: 20px;
  padding: 11px;
  background: var(--marca-laranja);
  color: var(--botao-texto);
  border: 0;
  border-radius: 9px;
  font-weight: 600;
}
.botao[disabled] { opacity: .55; cursor: default; }
.erro { margin-top: 14px; color: var(--critical); font-size: 13px; min-height: 18px; }

/* ---------- estrutura ---------- */
header.topo {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--surface-1);
  border-bottom: 1px solid var(--linha);
  padding: 10px 16px;
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}
.marca { font-weight: 700; font-size: 15px; letter-spacing: -0.02em; }
.marca span { color: var(--text-muted); font-weight: 500; }
nav.abas { display: flex; gap: 4px; margin-left: auto; }
nav.abas button {
  padding: 7px 14px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: none;
  color: var(--text-secondary);
  font-weight: 500;
}
nav.abas button[aria-current="page"] {
  background: var(--surface-0);
  border-color: var(--linha);
  color: var(--text-primary);
}
.usuario { display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--text-muted); }
.usuario button { background: none; border: 0; color: var(--acento); padding: 4px; }

main { padding: 16px; max-width: 1280px; margin: 0 auto; }
.frescor { font-size: 12px; color: var(--text-muted); margin: 0 0 14px; }
.frescor.velho { color: var(--critical); font-weight: 600; }

/* ---------- cartoes ---------- */
.hero {
  background: var(--surface-1);
  border: 1px solid var(--linha);
  border-radius: 14px;
  padding: 20px;
  margin-bottom: 16px;
  box-shadow: var(--sombra);
}
.hero .rotulo { font-size: 13px; color: var(--text-secondary); }
.hero .numero { font-size: clamp(30px, 8vw, 42px); font-weight: 650; letter-spacing: -0.03em; margin: 2px 0 4px; }
.tiras { display: flex; flex-wrap: wrap; gap: 18px 28px; margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--linha); }
.tira .rotulo { font-size: 12px; color: var(--text-muted); }
.tira .valor { font-size: 19px; font-weight: 600; }

.grade { display: grid; gap: 12px; grid-template-columns: 1fr; }
@media (min-width: 700px) { .grade { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1080px) { .grade.quatro { grid-template-columns: repeat(4, 1fr); } }

.card {
  background: var(--surface-1);
  border: 1px solid var(--linha);
  border-radius: 12px;
  padding: 16px;
  box-shadow: var(--sombra);
}
.card h3 { font-size: 14px; display: flex; align-items: center; gap: 7px; }
.ponto { width: 9px; height: 9px; border-radius: 3px; flex: none; }
.card .grande { font-size: 26px; font-weight: 650; letter-spacing: -0.02em; margin: 10px 0 2px; }
.variacao { font-size: 13px; font-weight: 600; }
.variacao.sobe { color: var(--good); }
.variacao.desce { color: var(--critical); }
.variacao .contexto { display: block; font-weight: 400; color: var(--text-muted); font-size: 12px; margin-top: 2px; }
.mini { display: flex; gap: 16px; flex-wrap: wrap; margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--linha); }
.mini div { font-size: 12px; color: var(--text-muted); }
.mini b { display: block; font-size: 16px; color: var(--text-primary); font-weight: 600; }

/* ---------- meta ---------- */
.linha-meta { margin-top: 14px; }
.linha-meta:first-of-type { margin-top: 8px; }
.linha-meta .cabeca { display: flex; justify-content: space-between; font-size: 12px; color: var(--text-secondary); }
.linha-meta .cabeca b { color: var(--text-primary); font-size: 13px; }
.barra { position: relative; height: 10px; background: var(--surface-0); border: 1px solid var(--linha); border-radius: 5px; margin-top: 5px; overflow: hidden; }
.barra .preenche { height: 100%; border-radius: 5px 0 0 5px; }
.barra .marca-hoje { position: absolute; top: -3px; bottom: -3px; width: 2px; background: var(--text-muted); }
.linha-meta .pe { font-size: 11px; color: var(--text-muted); margin-top: 4px; }

/* ---------- grafico ---------- */
.grafico { margin-top: 16px; }
.grafico svg { width: 100%; height: auto; display: block; overflow: visible; }
.legenda { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-top: 10px; font-size: 12px; color: var(--text-secondary); }
.legenda span { display: inline-flex; align-items: center; gap: 6px; }
.eixo { fill: var(--text-muted); font-size: 11px; }
/* O SVG encolhe junto com a tela; no celular 11px do viewBox viram ~5px reais.
   Como a unidade e do viewBox, aumentar aqui devolve o tamanho legivel. */
@media (max-width: 700px) { .eixo { font-size: 19px; } }
.grade-linha { stroke: var(--linha); stroke-width: 1; }

/* ---------- alertas ---------- */
.alerta-item { display: flex; gap: 10px; align-items: flex-start; padding: 10px 0; border-top: 1px solid var(--linha); }
.alerta-item:first-child { border-top: 0; }
.alerta-item .selo { font-size: 11px; font-weight: 700; color: var(--critical); border: 1px solid var(--critical); border-radius: 5px; padding: 1px 6px; flex: none; }
.alerta-item .detalhe { font-size: 12px; color: var(--text-muted); }
.vazio { color: var(--text-muted); font-size: 13px; padding: 8px 0; }

/* ---------- modal de metas ---------- */
dialog {
  border: 1px solid var(--linha);
  border-radius: 14px;
  background: var(--surface-1);
  color: var(--text-primary);
  padding: 20px;
  width: min(560px, calc(100vw - 32px));
  box-shadow: var(--sombra);
}
dialog::backdrop { background: rgba(0,0,0,.45); }
.tabela-metas { width: 100%; border-collapse: collapse; margin-top: 12px; font-size: 13px; }
.tabela-metas th { text-align: left; font-weight: 600; color: var(--text-secondary); font-size: 12px; padding: 6px 8px 6px 0; }
.tabela-metas td { padding: 4px 8px 4px 0; }
.tabela-metas input { padding: 7px 9px; }
.acoes { display: flex; gap: 10px; justify-content: flex-end; margin-top: 18px; }
.acoes button { padding: 9px 16px; border-radius: 9px; border: 1px solid var(--linha); background: var(--surface-0); color: var(--text-primary); }
.acoes button.principal { background: var(--marca-laranja); border-color: var(--marca-laranja);
  color: var(--botao-texto); font-weight: 600; }
.secundario { background: none; border: 1px solid var(--linha); color: var(--text-primary); padding: 7px 12px; border-radius: 8px; }
.nota { font-size: 12px; color: var(--text-muted); margin-top: 14px; }
[hidden] { display: none !important; }

/* tooltip da curva */
.grafico { position: relative; }
.tooltip {
  position: absolute;
  top: 8px;
  min-width: 170px;
  background: var(--surface-1);
  border: 1px solid var(--linha);
  border-radius: 9px;
  padding: 9px 11px;
  font-size: 12px;
  box-shadow: 0 4px 16px rgba(0,0,0,.18);
  pointer-events: none;
}
.tooltip b { display: block; margin-bottom: 4px; }
.tooltip span { display: flex; align-items: center; gap: 6px; padding: 1px 0; color: var(--text-secondary); }
.tooltip span b { display: inline; margin: 0 0 0 auto; color: var(--text-primary); }
.tooltip i { width: 8px; height: 8px; border-radius: 2px; flex: none; }

/* No celular o nome do gestor nao paga o espaco que ocupa no topo: quem esta
   logado sabe quem e; o botao Sair fica. */
@media (max-width: 760px) {
  header.topo { padding: 8px 0 0; gap: 6px; }
  .marca, .usuario { padding: 0 12px; }
  #nome-usuario { display: none; }
  main { padding: 12px; }
  /* Com seis abas, deixar quebrar empilhava o topo em tres linhas (142px de
     altura medidos no celular, roubando a tela do numero). Vira faixa rolavel:
     uma linha so, e o dedo arrasta. */
  nav.abas {
    order: 3;
    width: 100%;
    margin-left: 0;
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: none;
    padding: 2px 12px 8px;
    scroll-snap-type: x proximity;
  }
  nav.abas::-webkit-scrollbar { display: none; }
  nav.abas button { padding: 7px 13px; white-space: nowrap; scroll-snap-align: start; }
  .usuario { order: 2; margin-left: auto; }
}

/* ---------- tabelas das telas novas ---------- */
.card h4 { font-size: 12px; color: var(--text-secondary); margin: 16px 0 6px; font-weight: 600; }
table.lista { width: 100%; border-collapse: collapse; font-size: 12.5px; margin-top: 6px; }
table.lista th { text-align: left; font-weight: 600; font-size: 11px; color: var(--text-muted);
  padding: 0 6px 5px 0; border-bottom: 1px solid var(--linha); }
table.lista td { padding: 5px 6px 5px 0; border-bottom: 1px solid var(--linha); }
table.lista tr:last-child td { border-bottom: 0; }
table.lista .n { text-align: right; white-space: nowrap; }
table.lista .erro-txt { color: var(--critical); font-size: 11px; }
.tag { font-size: 10px; color: var(--text-muted); border: 1px solid var(--linha);
  border-radius: 4px; padding: 0 4px; }
.aviso { margin-top: 14px; padding: 10px 12px; border-radius: 9px; font-size: 12px;
  background: var(--surface-0); border: 1px solid var(--linha); }
.aviso.atencao { border-color: var(--warning); }
.aviso .contexto { display: block; color: var(--text-muted); margin-top: 4px; }
.card .pe { font-size: 11px; color: var(--text-muted); margin: 8px 0 0; }

/* Dia em curso: a variacao perde a cor de alarme, porque comparar manha com dia
   fechado sempre daria vermelho. O numero continua la; o alarme e que sai. */
.variacao.em-curso.desce, .variacao.em-curso.sobe { color: var(--text-secondary); }

/* O denominador do NPS anda junto do numero, em corpo menor: "100" e "100 de 4
   respostas" nao sao a mesma informacao. */
.card .grande .de-quantos { font-size: 13px; font-weight: 500; color: var(--text-muted); letter-spacing: 0; }

/* ---------- marca ---------- */
.logo { height: 30px; width: auto; display: block; }
.login-card .logo { height: 42px; margin: 0 auto 18px; }
header.topo .marca { display: flex; align-items: center; gap: 10px; }
/* "Painel de gestão" e o nome do produto, nao uma legenda: mesmo peso visual
   que a logo ao lado. */
header.topo .marca .sufixo { color: var(--text-primary); font-weight: 600; font-size: 18px;
  letter-spacing: -0.01em; border-left: 1px solid var(--linha); padding-left: 12px; }
.login-card h1 { font-size: 26px; letter-spacing: -0.02em; }
/* A barra de acento no topo usa as quatro cores da marca em sequencia -- e o
   unico lugar onde elas aparecem juntas, e ali nao ha dado para confundir. */
header.topo::before {
  content: ""; position: absolute; top: 0; left: 0; right: 0; height: 3px;
  background: linear-gradient(90deg,
    var(--marca-laranja) 0 25%, var(--marca-ambar) 25% 50%,
    var(--marca-verde) 50% 75%, var(--marca-azul) 75% 100%);
}
header.topo { position: sticky; }
@media (max-width: 760px) {
  .logo { height: 24px; }
  .login-card .logo { height: 36px; }
  header.topo .marca .sufixo { font-size: 15px; padding-left: 9px; }
  .login-card h1 { font-size: 22px; }
}

/* ---------- rodape ---------- */
.rodape {
  max-width: 1280px;
  margin: 8px auto 0;
  padding: 14px 16px 22px;
  border-top: 1px solid var(--linha);
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 12px;
  color: var(--text-muted);
}
.rodape b { color: var(--text-secondary); font-weight: 600; }
.rodape-sep { opacity: .5; }
.rodape .atrasado { color: var(--critical); font-weight: 600; }
@media (max-width: 760px) { .rodape { padding: 14px 12px 26px; } }
