:root {
  --fundo: #f3f5f8;
  --painel: #ffffff;
  --tinta: #141b26;
  --suave: #5a6b7e;
  --tenue: #8595a6;
  --linha: #e4e9f0;
  --linha-forte: #d3dae4;
  --acento: #2156c9;
  --acento-escuro: #1b47a6;
  --acento-fraco: #eaf0fc;
  --lateral: #141c2b;
  --lateral-tinta: #aeb9c9;
  --lateral-ativo: #ffffff;
  --ok: #117a44;
  --ok-fundo: #e4f4ea;
  --alerta: #8a5600;
  --alerta-fundo: #fbefd7;
  --perigo: #b02a1f;
  --perigo-fundo: #fbe7e4;
  --sombra: 0 1px 2px rgba(20,27,38,.06), 0 4px 16px rgba(20,27,38,.05);
  --raio: 10px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --fundo: #0e141d;
    --painel: #19212d;
    --tinta: #e7ecf2;
    --suave: #9fadbd;
    --tenue: #73818f;
    --linha: #27313f;
    --linha-forte: #333f4f;
    --acento: #5b8def;
    --acento-escuro: #4a79d6;
    --acento-fraco: #1b2436;
    --lateral: #0b111a;
    --lateral-tinta: #91a0b3;
    --lateral-ativo: #ffffff;
    --ok: #67cf93;
    --ok-fundo: #16301f;
    --alerta: #e4ad5a;
    --alerta-fundo: #352814;
    --perigo: #ef8c82;
    --perigo-fundo: #3a1b18;
    --sombra: 0 1px 2px rgba(0,0,0,.3), 0 4px 16px rgba(0,0,0,.25);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--fundo);
  color: var(--tinta);
  font-family: Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

/* ---------- Estrutura com barra lateral ---------- */
body.app { display: flex; min-height: 100%; }

.lateral {
  position: sticky; top: 0; align-self: flex-start;
  display: flex; flex-direction: column;
  width: 248px; height: 100vh; flex-shrink: 0;
  background: var(--lateral);
  padding: 20px 14px;
}
.marca {
  display: flex; align-items: center; gap: 11px;
  color: #fff; font-weight: 600; font-size: 1.02rem;
  padding: 6px 10px 20px;
}
.marca-icone {
  display: grid; place-items: center;
  width: 34px; height: 34px; flex-shrink: 0;
  background: var(--acento); border-radius: 9px; color: #fff;
}
.marca-icone svg { width: 20px; height: 20px; }

.lateral nav { display: flex; flex-direction: column; gap: 3px; }
.lateral nav a, .lateral .sair {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; border-radius: 8px;
  color: var(--lateral-tinta); text-decoration: none;
  font-weight: 500; font-size: .94rem;
  transition: background .15s, color .15s;
}
.lateral nav a svg, .lateral .sair svg { width: 19px; height: 19px; flex-shrink: 0; }
.lateral nav a:hover { background: rgba(255,255,255,.06); color: #fff; }
.lateral nav a[aria-current="page"] { background: var(--acento); color: var(--lateral-ativo); }
.lateral .sair { margin-top: auto; }
.lateral .sair:hover { background: rgba(255,255,255,.06); color: #fff; }

.conteudo { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.cabecalho {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: 0 clamp(1.1rem, 3vw, 2.2rem);
  height: 66px; flex-shrink: 0;
  background: var(--painel); border-bottom: 1px solid var(--linha);
  position: sticky; top: 0; z-index: 5;
}
.cabecalho h1 { font-size: 1.22rem; font-weight: 600; margin: 0; letter-spacing: -.01em; }
.usuario {
  font-size: .82rem; font-weight: 500; color: var(--suave);
  background: var(--fundo); border: 1px solid var(--linha);
  padding: 5px 12px; border-radius: 999px;
}
main { padding: clamp(1.1rem, 3vw, 2.2rem); max-width: 1240px; width: 100%; }

h2 { font-size: 1rem; font-weight: 600; margin: 0 0 1rem; letter-spacing: -.01em; }
.intro { color: var(--suave); max-width: 72ch; margin: -.3rem 0 1.4rem; }
.nota { color: var(--tenue); font-size: .86rem; }

/* ---------- Cartões ---------- */
.painel {
  background: var(--painel);
  border: 1px solid var(--linha);
  border-radius: var(--raio);
  box-shadow: var(--sombra);
  padding: 1.4rem 1.5rem;
  margin-bottom: 1.3rem;
}
.painel h2 + p, .painel h2 + .nota { margin-top: -.5rem; }
.vazio { text-align: center; padding: 3rem 1rem; }
.vazio p { color: var(--suave); margin-bottom: 1.2rem; }
.duas-colunas { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 1.3rem; align-items: start; }
.duas-colunas .painel { margin-bottom: 0; }

/* ---------- Formulários ---------- */
label { display: block; font-weight: 500; font-size: .88rem; color: var(--tinta); margin-bottom: 1rem; }
input, select {
  display: block; width: 100%; margin-top: .4rem;
  font: inherit; color: var(--tinta);
  background: var(--painel);
  border: 1px solid var(--linha-forte); border-radius: 8px;
  padding: .6rem .75rem; transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus { outline: none; border-color: var(--acento); box-shadow: 0 0 0 3px var(--acento-fraco); }
input[type="file"] { padding: .5rem; background: var(--fundo); cursor: pointer; }

button, .botao {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  font: inherit; font-weight: 600; font-size: .92rem; cursor: pointer;
  background: var(--acento); color: #fff;
  border: 1px solid transparent; border-radius: 8px;
  padding: .6rem 1.2rem; text-decoration: none;
  transition: background .15s, border-color .15s;
}
button:hover, .botao:hover { background: var(--acento-escuro); }
button.secundario { background: var(--painel); color: var(--tinta); border-color: var(--linha-forte); }
button.secundario:hover { background: var(--fundo); border-color: var(--suave); }
button.alerta { background: var(--alerta); } button.alerta:hover { filter: brightness(.92); }
button.perigo { background: var(--perigo); } button.perigo:hover { filter: brightness(.92); }
button.texto { background: none; border: 0; color: var(--perigo); padding: .35rem 0; font-weight: 500; }
button.texto:hover { background: none; text-decoration: underline; }
:focus-visible { outline: 2px solid var(--acento); outline-offset: 2px; }

.linha { display: flex; flex-wrap: wrap; gap: .75rem; align-items: flex-end; margin: 1.2rem 0; }
.linha label { flex: 1 1 200px; margin: 0; }
.linha.compacta { margin: 0; align-items: center; }
.linha.compacta select { margin: 0; min-width: 215px; }
.acoes-rapidas { display: flex; flex-wrap: wrap; gap: .6rem; margin-bottom: 1rem; }

details { border-top: 1px solid var(--linha); padding-top: 1rem; margin-top: 1.2rem; }
summary { cursor: pointer; font-weight: 600; font-size: .92rem; margin-bottom: .7rem; }
summary::marker { color: var(--tenue); }
details.perigo summary { color: var(--perigo); }

/* ---------- Avisos ---------- */
.aviso {
  display: flex; align-items: flex-start; gap: .5rem;
  padding: .8rem 1.05rem; border-radius: 9px; margin-bottom: 1.3rem;
  font-size: .9rem; font-weight: 500;
  background: var(--ok-fundo); color: var(--ok);
  border: 1px solid color-mix(in srgb, var(--ok) 25%, transparent);
}
.aviso.erro { background: var(--perigo-fundo); color: var(--perigo); border-color: color-mix(in srgb, var(--perigo) 25%, transparent); }

/* ---------- Tabelas ---------- */
.tabela-rolagem { overflow-x: auto; background: var(--painel); border: 1px solid var(--linha); border-radius: var(--raio); box-shadow: var(--sombra); }
.painel .tabela-rolagem { border: 0; box-shadow: none; border-radius: 0; }
table { width: 100%; border-collapse: collapse; font-size: .92rem; }
th, td { text-align: left; padding: .8rem 1.1rem; border-bottom: 1px solid var(--linha); vertical-align: middle; }
th { font-size: .74rem; letter-spacing: .04em; text-transform: uppercase; color: var(--tenue); font-weight: 600; background: color-mix(in srgb, var(--fundo) 60%, transparent); }
tbody tr { transition: background .12s; }
tbody tr:hover { background: color-mix(in srgb, var(--fundo) 55%, transparent); }
tbody tr:last-child td { border-bottom: 0; }
td a { color: var(--acento); font-weight: 600; text-decoration: none; }
td a:hover { text-decoration: underline; }

.estado { display: inline-flex; align-items: center; gap: .4rem; padding: .25rem .7rem; border-radius: 999px; font-size: .8rem; font-weight: 600; }
.estado::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.estado.ativo { color: var(--ok); background: var(--ok-fundo); }
.estado.alerta { color: var(--alerta); background: var(--alerta-fundo); }
.estado.neutro { color: var(--suave); background: var(--fundo); }

.dados { display: grid; grid-template-columns: max-content 1fr; gap: .55rem 1.4rem; margin: 0 0 1.3rem; font-size: .92rem; }
.dados dt { color: var(--tenue); }
.dados dd { margin: 0; word-break: break-all; font-weight: 500; }

.passos { padding-left: 1.2rem; margin: 0; }
.passos li { margin-bottom: .55rem; padding-left: .2rem; }
.passos li::marker { color: var(--acento); font-weight: 700; }

.qr-cartao { text-align: center; }
#qr { display: inline-block; padding: 16px; background: #fff; border-radius: 10px; border: 1px solid var(--linha); margin: .5rem 0; }
#qr img, #qr canvas { max-width: 100%; height: auto; display: block; }
.qr-cartao code { display: block; word-break: break-all; text-align: left; font-size: .82rem; background: var(--fundo); padding: .7rem; border-radius: 8px; margin-top: .5rem; }

.play-quadro { margin-top: 1rem; border-top: 1px solid var(--linha); padding-top: 1rem; }

/* ---------- Login ---------- */
body.auth { display: grid; place-items: center; padding: 1.5rem; }
.tela-login { width: 100%; max-width: 380px; padding: 0; }
.login-marca {
  display: flex; align-items: center; justify-content: center; gap: 11px;
  font-size: 1.3rem; font-weight: 700; letter-spacing: -.01em;
  margin-bottom: 1.5rem;
}
.tela-login .painel { margin: 0; padding: 1.6rem; }
.tela-login label:last-of-type { margin-bottom: 1.3rem; }
.tela-login button { width: 100%; padding: .7rem; }
.estreito { max-width: 440px; }

/* ---------- Responsivo ---------- */
@media (max-width: 760px) {
  body.app { flex-direction: column; }
  .lateral {
    flex-direction: row; align-items: center; width: 100%; height: auto;
    padding: 8px 10px; gap: 4px; overflow-x: auto;
    position: sticky; top: 0; z-index: 10;
  }
  .marca { padding: 6px 10px; font-size: 0; gap: 0; }
  .marca span:not(.marca-icone) { display: none; }
  .lateral nav { flex-direction: row; gap: 2px; }
  .lateral nav a span, .lateral .sair span { display: none; }
  .lateral nav a, .lateral .sair { padding: 10px; }
  .lateral .sair { margin: 0 0 0 auto; }
  .cabecalho { height: 56px; }
  .cabecalho h1 { font-size: 1.1rem; }
  .usuario { display: none; }
  .duas-colunas { grid-template-columns: 1fr; }
  .linha.compacta { flex-wrap: wrap; }
  .linha.compacta select { min-width: 0; width: 100%; }
}