:root {
  color-scheme: light dark;
  --fundo: #f4f5f7; --cartao: #fff; --texto: #101010; --suave: #55544f; --borda: #dddcd7;
  --marca: #1f5fbf; --marca-texto: #fff;
  --bom: #0a6b0a; --bom-fundo: #dff3df; --ruim: #b3261e; --ruim-fundo: #fbe1df; --alerta: #6b4e00; --alerta-fundo: #fff1cc;
}
@media (prefers-color-scheme: dark) {
  :root {
    --fundo: #111110; --cartao: #1b1b1a; --texto: #f0efec; --suave: #bdbcb2; --borda: #383835;
    --marca: #5a9bee; --marca-texto: #08131f;
    --bom: #7fe07f; --bom-fundo: #16321a; --ruim: #ff9a91; --ruim-fundo: #3d1a17; --alerta: #ffd976; --alerta-fundo: #3a2e0c;
  }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--fundo); color: var(--texto); font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
h1 { font-size: 1.35rem; margin: 0; }
h2 { font-size: 1.05rem; margin: 1.5rem 0 .6rem; }
h3 { font-size: 1rem; margin: 0 0 .6rem; display: flex; justify-content: space-between; align-items: center; gap: .5rem; }
p { margin: .25rem 0 .75rem; }
small { color: var(--suave); display: block; font-size: .82rem; font-weight: 400; }
a { color: var(--marca); }
.suave { color: var(--suave); }

button, .botao { font: inherit; color: inherit; background: var(--cartao); border: 1px solid var(--borda); border-radius: 8px; padding: .45rem .85rem; min-height: 38px; cursor: pointer; text-decoration: none; display: inline-block; }
button:hover:not(:disabled), .botao:hover { border-color: var(--marca); }
button:disabled { opacity: .5; cursor: default; }
:focus-visible { outline: 3px solid var(--marca); outline-offset: 1px; }
.primario { background: var(--marca); border-color: var(--marca); color: var(--marca-texto); font-weight: 600; }
.perigo-cheio { background: var(--ruim); border-color: var(--ruim); color: var(--cartao); font-weight: 600; }
input, select, textarea { font: inherit; color: inherit; background: var(--cartao); border: 1px solid var(--borda); border-radius: 8px; padding: .45rem .65rem; min-height: 38px; max-width: 100%; }
input[type="checkbox"], input[type="radio"] { width: 20px; height: 20px; min-height: 0; flex: none; accent-color: var(--marca); margin: 0; }
textarea { width: 100%; resize: vertical; }
label { display: block; margin-bottom: .85rem; }
.marcador { display: flex; align-items: flex-start; gap: .55rem; }
.filtros .marcador { margin: 0; align-items: center; }

#app.dentro { display: grid; grid-template-columns: 210px minmax(0, 1fr); min-height: 100vh; }
nav { position: sticky; top: 0; height: 100vh; overflow: auto; display: flex; flex-direction: column; gap: .2rem; padding: 1rem .75rem; background: var(--cartao); border-right: 1px solid var(--borda); }
nav .logo { font-weight: 700; font-size: 1.1rem; margin: 0 .5rem 1rem; }
nav button { text-align: left; border-color: transparent; background: transparent; }
nav button.atual { background: color-mix(in srgb, var(--marca) 15%, transparent); font-weight: 600; }
nav .sair { margin-top: auto; }
main { padding: 1rem 1.5rem 3rem; min-width: 0; }
header { display: flex; flex-wrap: wrap; gap: .75rem; align-items: center; justify-content: space-between; margin-bottom: 1rem; }
.controles, .botoes, .abas { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.botoes { margin-top: .75rem; }
.filtros { margin-bottom: .75rem; }
.busca { width: 300px; }
.abas { margin-bottom: .75rem; }
.abas button.atual { background: var(--marca); border-color: var(--marca); color: var(--marca-texto); font-weight: 600; }

.cartao { background: var(--cartao); border: 1px solid var(--borda); border-radius: 12px; padding: 1rem; }
.grade { display: grid; gap: .75rem; }
.numeros { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.tres { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.numero { text-align: left; padding: .8rem 1rem; }
.numero span { display: block; color: var(--suave); font-size: .85rem; }
.numero strong { font-size: 1.8rem; }
.numero.ruim strong { color: var(--ruim); }
.numero.alerta strong { color: var(--alerta); }
.desligada dl { opacity: .55; }
dl { margin: 0; }
dl div { display: flex; justify-content: space-between; padding: .15rem 0; border-bottom: 1px solid var(--borda); }
dt { color: var(--suave); }
dd { margin: 0; font-variant-numeric: tabular-nums; }

.faixa { display: flex; flex-wrap: wrap; gap: .75rem; align-items: center; justify-content: space-between; border-radius: 10px; padding: .7rem 1rem; margin-bottom: .75rem; }
.faixa.alerta { background: var(--alerta-fundo); color: var(--alerta); }
.faixa.bom { background: var(--bom-fundo); color: var(--bom); }
.faixa.ruim { background: var(--ruim-fundo); color: var(--ruim); }
.faixa.neutro { background: var(--cartao); border: 1px solid var(--borda); }
.faixa button:not(.perigo-cheio) { color: var(--texto); }

.rolagem { overflow-x: auto; background: var(--cartao); border: 1px solid var(--borda); border-radius: 12px; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: .5rem .65rem; border-bottom: 1px solid var(--borda); vertical-align: middle; }
th { font-size: .78rem; text-transform: uppercase; letter-spacing: .03em; color: var(--suave); white-space: nowrap; }
tbody tr:last-child td { border-bottom: 0; }
td.n { text-align: right; font-variant-numeric: tabular-nums; }
td.titulo { min-width: 240px; max-width: 380px; }
td img { width: 44px; height: 44px; object-fit: contain; border-radius: 6px; background: #fff; display: block; }
.sku { font-family: ui-monospace, Consolas, monospace; font-size: .9rem; white-space: nowrap; }
.vermelho { color: var(--ruim); font-weight: 700; }
.vazio { background: var(--cartao); border: 1px dashed var(--borda); border-radius: 12px; padding: 2rem; text-align: center; color: var(--suave); }
.paginas { display: flex; gap: .75rem; align-items: center; justify-content: center; margin-top: .75rem; flex-wrap: wrap; }

.selo { display: inline-block; border-radius: 99px; padding: .12rem .6rem; font-size: .78rem; font-weight: 600; white-space: nowrap; }
.selo.bom { background: var(--bom-fundo); color: var(--bom); }
.selo.ruim { background: var(--ruim-fundo); color: var(--ruim); }
.selo.alerta { background: var(--alerta-fundo); color: var(--alerta); }
.selo.neutro { background: color-mix(in srgb, var(--suave) 18%, transparent); }

.simnao { display: inline-flex; }
.simnao button { border-radius: 0; font-size: .8rem; font-weight: 700; padding: .25rem .6rem; min-height: 32px; color: var(--suave); }
.simnao button:first-child { border-radius: 8px 0 0 8px; }
.simnao button:last-child { border-radius: 0 8px 8px 0; margin-left: -1px; }
.simnao button.ativo.sim { background: var(--bom-fundo); color: var(--bom); border-color: var(--bom); }
.simnao button.ativo.nao { background: var(--ruim-fundo); color: var(--ruim); border-color: var(--ruim); }

section.cartao { margin-bottom: .75rem; }
section.cartao textarea, section.cartao > input { display: block; width: 100%; margin-bottom: .6rem; }
.ajustes { max-width: 620px; }
.ajustes h2:first-child { margin-top: 0; }
.ajustes input[type="number"] { display: block; width: 160px; margin-top: .25rem; }
.acesso { width: min(380px, 92vw); margin: 12vh auto; }
.acesso input { display: block; width: 100%; margin-top: .25rem; }
.acesso button { width: 100%; }
dialog { background: var(--cartao); color: var(--texto); border: 1px solid var(--borda); border-radius: 14px; padding: 1.25rem; width: min(520px, 94vw); }
dialog h2 { margin-top: 0; }
dialog::backdrop { background: rgb(0 0 0 / .5); }
dialog .botoes { justify-content: flex-end; }
#avisos { position: fixed; right: 1rem; bottom: 1rem; display: grid; gap: .5rem; z-index: 10; max-width: min(420px, 92vw); }
.aviso { border-radius: 10px; padding: .7rem 1rem; box-shadow: 0 4px 16px rgb(0 0 0 / .2); }
.aviso.bom { background: var(--bom-fundo); color: var(--bom); }
.aviso.ruim { background: var(--ruim-fundo); color: var(--ruim); }

@media (max-width: 760px) {
  #app.dentro { display: block; }
  nav { position: static; height: auto; flex-direction: row; overflow-x: auto; border-right: 0; border-bottom: 1px solid var(--borda); }
  nav .logo { display: none; }
  nav button { white-space: nowrap; }
  nav .sair { margin: 0; }
  main { padding: .9rem; }
  .busca { width: 100%; }
}
