/* Painel — estilo único (index.html e login.html).
   Linguagem visual: sóbria. Grafite/cinza + UM acento azul (ação e item ativo).
   Cor de estado aparece só em pontinhos, rótulos, uma fina borda lateral e barras que passam do limite.
   Para ajustes finos, mexa primeiro nas variáveis de :root. */

/* ---------- 1. Variáveis ---------- */
:root {
  color-scheme: light dark;

  /* superfícies e texto */
  --fundo: #f2f3f5;
  --superficie: #ffffff;
  --superficie-2: #f6f7f9;
  --borda: #d9dde3;
  --borda-forte: #c2c8d0;
  --texto: #14171c;
  --texto-2: #566070;

  /* acento (único): botões, item ativo, foco */
  --acento: #2a5aa8;
  --sobre-acento: #ffffff;

  /* estados: só como cor de TEXTO, ponto, borda lateral e barra acima do limite */
  --ok: #17703f;
  --atencao: #8a5700;
  --falha: #b3261e;
  --parado: #566070;

  /* barras finas */
  --barra-fundo: #e5e8ec;
  --barra-cheia: #7a8493;

  /* forma */
  --raio: 6px;
  --raio-maior: 8px;
  --lateral: 16px;           /* respiro nas bordas da tela */
  --alvo: 48px;              /* menor alvo de toque */
  --abas-altura: 56px;       /* altura da barra de baixo (sem a área segura) */
  --topo-altura: 56px;
  --fonte: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --fundo: #0e1116;
    --superficie: #161a21;
    --superficie-2: #1b2028;
    --borda: #272d37;
    --borda-forte: #363d49;
    --texto: #e4e7ec;
    --texto-2: #9aa3b0;

    --acento: #7ea6e8;
    --sobre-acento: #0b1220;

    --ok: #52c28a;
    --atencao: #e3a93e;
    --falha: #f2766e;
    --parado: #9aa3b0;

    --barra-fundo: #272d37;
    --barra-cheia: #7c8695;
  }
}

/* Elemento com data-e="ok|atencao|falha|parado|nd|novo" recebe a cor do estado em --e-cor. */
[data-e="ok"]      { --e-cor: var(--ok); }
[data-e="atencao"] { --e-cor: var(--atencao); }
[data-e="falha"]   { --e-cor: var(--falha); }
[data-e="parado"],
[data-e="nd"]      { --e-cor: var(--parado); }
[data-e="novo"]    { --e-cor: var(--acento); }

/* ---------- 2. Base ---------- */
*, *::before, *::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--fundo);
  color: var(--texto);
  font: 16px/1.45 var(--fonte);
  font-variant-numeric: tabular-nums;
  overflow-wrap: break-word;
}

h1, h2, h3, p, ul, ol { margin: 0; }
ul, ol { padding: 0; list-style: none; }
button, a { touch-action: manipulation; }
button { font: inherit; color: inherit; }

:focus-visible { outline: 2px solid var(--acento); outline-offset: 2px; }

[hidden] { display: none !important; }

.so-leitor {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap;
}

/* ---------- 3. Ícones de linha e pontos de estado ---------- */
.ico {
  width: 1.25em; height: 1.25em; flex: none;
  fill: none; stroke: currentColor; stroke-width: 1.75;
  stroke-linecap: round; stroke-linejoin: round;
}

.ponto {
  display: inline-block; flex: none;
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--e-cor, var(--parado));
}

/* ---------- 4. Barra do topo ---------- */
.topo {
  position: sticky; top: 0; z-index: 20;
  padding: env(safe-area-inset-top) max(var(--lateral), env(safe-area-inset-right)) 0 max(var(--lateral), env(safe-area-inset-left));
  background: var(--superficie);
  border-bottom: 1px solid var(--borda);
}
.topo-linha {
  display: flex; align-items: center; gap: 10px;
  max-width: 40rem; margin: 0 auto; min-height: var(--topo-altura);
}
.topo-titulos { flex: 1; min-width: 0; padding: 6px 0; }
.topo-titulo { font-size: 17px; font-weight: 650; letter-spacing: .01em; line-height: 1.2; }
.topo-resumo { display: flex; align-items: center; gap: 8px; min-width: 0; font-size: 14px; color: var(--texto-2); line-height: 1.3; }
.topo-resumo-texto { min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topo-atualizado {
  flex: none; max-width: 42%; text-align: right;
  font-size: 13px; color: var(--texto-2);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.botao-icone {
  display: grid; place-items: center; flex: none;
  width: var(--alvo); height: var(--alvo); margin-right: -12px;
  border: 0; border-radius: var(--raio); background: transparent; color: var(--texto-2); cursor: pointer;
  font-size: 22px;
}
.botao-icone:active { background: var(--superficie-2); }

.menu-caixa { position: relative; }
.menu {
  position: absolute; right: -8px; top: calc(100% + 2px); z-index: 30;
  width: min(18rem, calc(100vw - 32px));
  background: var(--superficie); border: 1px solid var(--borda-forte);
  border-radius: var(--raio-maior);
  overflow: hidden;
}
.menu-item {
  display: flex; flex-direction: column; align-items: flex-start; gap: 2px; text-align: left;
  width: 100%; min-height: var(--alvo); padding: 10px 16px;
  border: 0; border-top: 1px solid var(--borda); background: transparent; cursor: pointer;
}
.menu-item:first-child { border-top: 0; }
.menu-item:active { background: var(--superficie-2); }
.menu-item-titulo { font-size: 16px; font-weight: 500; }
.menu-item-perigo { color: var(--falha); }
.menu-item-sub { font-size: 14px; color: var(--texto-2); }

/* Faixa "sem conexão": flutua sobre o conteúdo, não empurra nada */
.offline {
  position: absolute; left: 0; right: 0; top: 100%;
  padding: 8px max(var(--lateral), env(safe-area-inset-right)) 8px max(var(--lateral), env(safe-area-inset-left));
  background: var(--superficie); color: var(--atencao);
  border-bottom: 1px solid var(--borda); border-left: 3px solid var(--atencao);
  font-size: 14px; font-weight: 600;
}

/* ---------- 5. Barra de baixo (abas) ---------- */
.abas {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  padding: 0 env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  background: var(--superficie);
  border-top: 1px solid var(--borda);
}
.abas-grade {
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr));
  max-width: 40rem; margin: 0 auto;
}
.aba {
  position: relative;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  min-height: var(--abas-altura); padding: 6px 2px;
  color: var(--texto-2); text-decoration: none;
}
.aba::before { /* traço do item ativo */
  content: ""; position: absolute; left: 24%; right: 24%; top: -1px; height: 2px; background: transparent;
}
.aba:active { background: var(--superficie-2); }
.aba[aria-current="page"] { color: var(--acento); }
.aba[aria-current="page"]::before { background: var(--acento); }
.aba-icone { position: relative; display: grid; place-items: center; }
.aba-svg { display: grid; place-items: center; font-size: 22px; line-height: 0; }
.aba-svg .ico { width: 22px; height: 22px; }
.aba-ponto {
  position: absolute; top: -3px; right: -7px;
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--e-cor, var(--parado));
  border: 2px solid var(--superficie); box-sizing: content-box;
}
.aba-rotulo { font-size: 14px; font-weight: 600; line-height: 1.1; }

/* ---------- 6. Conteúdo: cada aba é uma tela ---------- */
.conteudo {
  max-width: 40rem; margin: 0 auto;
  padding: 16px max(var(--lateral), env(safe-area-inset-right))
           calc(var(--abas-altura) + env(safe-area-inset-bottom) + 24px)
           max(var(--lateral), env(safe-area-inset-left));
}
.tela { display: flex; flex-direction: column; gap: 20px; }

.grupo { display: flex; flex-direction: column; gap: 8px; }
.titulo-secao {
  font-size: 13px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase;
  color: var(--texto-2);
}
.nota { font-size: 14px; color: var(--texto-2); }
.nota:empty { display: none; }
.hoje { font-size: 16px; }

/* ---------- 7. Bloco de resumo (topo de cada tela) ---------- */
.cartao-resumo {
  padding: 14px 16px;
  background: var(--superficie);
  border: 1px solid var(--borda); border-left: 3px solid var(--e-cor, var(--borda-forte));
  border-radius: var(--raio-maior);
}
.cartao-estado {
  display: flex; align-items: center; gap: 8px;
  font-size: 13px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase;
  color: var(--e-cor, var(--texto-2));
}
.cartao-titulo { margin-top: 6px; font-size: 20px; font-weight: 600; line-height: 1.3; overflow-wrap: anywhere; }
.cartao-sub { margin-top: 4px; font-size: 14px; color: var(--texto-2); overflow-wrap: anywhere; }
.cartao-sub:empty { display: none; }

.caixa-erro, .caixa-aviso {
  padding: 12px 14px;
  background: var(--superficie); border: 1px solid var(--borda);
  border-radius: var(--raio);
  font-size: 15px; line-height: 1.4; overflow-wrap: anywhere;
}
.caixa-erro { border-left: 3px solid var(--falha); }
.caixa-aviso { border-left: 3px solid var(--atencao); margin: 12px 0; }

/* ---------- 8. Botões ---------- */
.botao {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; min-height: var(--alvo); padding: 12px 16px;
  border: 1px solid var(--acento); border-radius: var(--raio);
  background: var(--acento); color: var(--sobre-acento);
  font-size: 16px; font-weight: 600; line-height: 1.2; text-align: center; text-decoration: none;
  cursor: pointer;
}
.botao:active { filter: brightness(.92); }
.botao:disabled {
  cursor: default; filter: none;
  background: var(--superficie-2); border-color: var(--borda); color: var(--e-cor, var(--texto-2));
}
.botao-secundario { background: transparent; color: var(--acento); border-color: var(--borda-forte); }
.botao-secundario:active { background: var(--superficie-2); filter: none; }
.botao .ico { font-size: 18px; }
.bloco-botao { display: flex; flex-direction: column; gap: 6px; }

/* ---------- 9. Listas ---------- */
.lista {
  background: var(--superficie);
  border: 1px solid var(--borda); border-radius: var(--raio-maior);
  overflow: hidden;
}
.lista > li + li { border-top: 1px solid var(--borda); }
.lista-interna { border-radius: var(--raio); background: var(--superficie-2); }

.linha {
  display: flex; align-items: center; gap: 12px;
  min-height: var(--alvo); padding: 10px 14px;
}
.linha-vazia { color: var(--texto-2); font-size: 15px; }
.linha-textos { flex: 1; min-width: 0; }
.linha-nome { font-size: 16px; font-weight: 500; overflow-wrap: anywhere; }
.linha-codigo { font-size: 14px; font-weight: 400; color: var(--texto-2); }
.linha-detalhe { font-size: 14px; color: var(--texto-2); overflow-wrap: anywhere; }
.linha-lado {
  display: flex; align-items: baseline; gap: 8px; flex: none;
  font-size: 14px; color: var(--texto-2); text-align: right;
}
.linha-estado { color: var(--e-cor, var(--texto-2)); }
.linha[data-e="atencao"] > .linha-lado,
.linha[data-e="falha"] > .linha-lado { color: var(--e-cor); }
.linha-novos { font-size: 16px; font-weight: 650; color: var(--texto); }

.avisos { display: flex; flex-direction: column; gap: 8px; }
.avisos:empty { display: none; }
.aviso {
  padding: 10px 14px;
  background: var(--superficie); border: 1px solid var(--borda); border-left: 3px solid var(--atencao);
  border-radius: var(--raio); font-size: 15px; overflow-wrap: anywhere;
}

.etiquetas { display: flex; flex-wrap: wrap; gap: 8px; }
.etiquetas:empty { display: none; }
.etiqueta {
  display: inline-flex; flex-wrap: wrap; align-items: baseline; gap: 2px 8px; min-width: 0; max-width: 100%;
  padding: 6px 10px; border: 1px solid var(--borda-forte); border-radius: var(--raio);
  font-size: 15px; overflow-wrap: anywhere;
}
.etiqueta-fina { font-size: 13px; color: var(--texto-2); }

/* ---------- 10. Histórico de rodadas (linhas densas) ---------- */
.rodada-cab {
  display: flex; align-items: center; gap: 10px;
  min-height: var(--alvo); padding: 8px 14px;
  list-style: none; cursor: pointer;
}
div.rodada-cab { cursor: default; }
.rodada-cab::-webkit-details-marker { display: none; }
.rodada-cab::marker { content: ""; }
.rodada-cab:focus-visible { outline-offset: -2px; }
.rodada-det > .rodada-cab:active { background: var(--superficie-2); }
.rodada-hora { flex: none; width: 5.9rem; font-size: 14px; font-weight: 600; }
.rodada-resumo { flex: 1; min-width: 0; font-size: 15px; overflow-wrap: anywhere; }
.rodada .seta { display: grid; place-items: center; flex: none; color: var(--texto-2); font-size: 18px; }
@media (prefers-reduced-motion: no-preference) {
  .rodada .seta .ico { transition: transform .15s ease; }
}
.rodada-det[open] > .rodada-cab .seta .ico { transform: rotate(180deg); }
.rodada-corpo { padding: 0 14px 12px; display: flex; flex-direction: column; gap: 8px; }
.rodada-meta { font-size: 14px; color: var(--texto-2); }

/* ---------- 11. Servidor: medidores ---------- */
.medidor { padding: 12px 14px; }
.medidor-cab { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.medidor-nome { font-size: 16px; font-weight: 500; }
.medidor-valor { font-size: 18px; font-weight: 600; }
.barra { height: 4px; margin-top: 8px; border-radius: 2px; background: var(--barra-fundo); overflow: hidden; }
.barra > span { display: block; height: 100%; width: 0; border-radius: 2px; background: var(--barra-cheia); }
.medidor[data-e="atencao"] .barra > span { background: var(--atencao); }
.medidor[data-e="falha"] .barra > span { background: var(--falha); }
@media (prefers-reduced-motion: no-preference) {
  .barra > span { transition: width .3s ease; }
}
.medidor-detalhe { margin-top: 6px; font-size: 14px; color: var(--texto-2); }

/* ---------- 12. Aviso rápido (toast) ---------- */
.toast {
  position: fixed; left: 50%; transform: translateX(-50%); z-index: 40;
  bottom: calc(var(--abas-altura) + env(safe-area-inset-bottom) + 12px);
  width: max-content; max-width: calc(100vw - 32px);
  padding: 12px 16px; border-radius: var(--raio);
  background: var(--texto); color: var(--fundo);
  border-left: 3px solid var(--borda-forte);
  font-size: 15px; font-weight: 500;
}
.toast[data-e="falha"] { border-left-color: var(--falha); }
.toast[data-e="ok"]    { border-left-color: var(--ok); }

/* ---------- 13. Login ---------- */
.pagina-login { display: grid; place-items: center; }
.login {
  display: flex; flex-direction: column; gap: 8px;
  width: 100%; max-width: 22rem;
  padding: max(24px, env(safe-area-inset-top)) max(20px, env(safe-area-inset-right)) max(24px, env(safe-area-inset-bottom)) max(20px, env(safe-area-inset-left));
}
.login-titulo { font-size: 22px; font-weight: 650; }
.login-texto { font-size: 16px; color: var(--texto-2); margin-bottom: 8px; }
.login-form { display: flex; flex-direction: column; gap: 12px; width: 100%; }
.login-campo {
  width: 100%; min-height: 56px; padding: 10px 14px;
  border: 1px solid var(--texto-2); border-radius: var(--raio);
  background: var(--superficie); color: var(--texto);
  font: inherit; font-size: 24px; font-weight: 600; letter-spacing: .3em; text-align: center;
  font-variant-numeric: tabular-nums;
}
.login-campo:focus { outline: 2px solid var(--acento); outline-offset: 1px; border-color: var(--acento); }
.login-campo:disabled { opacity: .6; }
.login-aviso { min-height: 1.5em; font-size: 15px; font-weight: 500; color: var(--falha); }

/* ---------- 14. Telas largas e movimento reduzido ---------- */
@media (min-width: 40.01rem) {
  .conteudo { padding-top: 24px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
