:root {
  --fundo: #f4f5f7;
  --cartao: #ffffff;
  --texto: #111827;
  --suave: #6b7280;
  --borda: #e3e5e8;
  --escuro: #111827;
  --destaque: #f97316;
  --destaque-forte: #c2410c;
  --perigo: #b91c1c;
  --ok: #15803d;
  --raio: 8px;
  color-scheme: light;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
  font: 14px/1.45 "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  background: var(--fundo);
  color: var(--texto);
}
h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -0.01em; }
h1 { font-size: 22px; }
h2 { font-size: 17px; }
h3 { font-size: 15px; }
a { color: inherit; }
button, input, select { font: inherit; color: inherit; }

/* ---------- Entrada ---------- */
.entrada {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px 16px;
}
.entrada .caixa {
  width: 100%;
  max-width: 380px;
  background: var(--cartao);
  border: 1px solid var(--borda);
  border-radius: 12px;
  padding: 28px;
}
.marca { display: flex; align-items: center; gap: 10px; margin-bottom: 22px; }
.marca .logo { width: 30px; height: 30px; flex: none; }
.marca strong { font-size: 17px; }
.entrada h1 { font-size: 18px; margin-bottom: 16px; }
.qr { display: grid; place-items: center; margin: 4px 0 12px; }
.qr svg { width: 200px; height: 200px; border: 1px solid var(--borda); border-radius: var(--raio); }
.segredo {
  font: 13px/1.4 ui-monospace, Consolas, monospace;
  background: var(--fundo);
  border-radius: 6px;
  padding: 8px 10px;
  word-break: break-all;
  text-align: center;
  margin-bottom: 16px;
  user-select: all;
}

/* ---------- Formulários ---------- */
label { display: block; font-weight: 500; margin-bottom: 14px; }
label span { display: block; margin-bottom: 5px; }
input[type=text], input[type=email], input[type=password], select, textarea {
  width: 100%;
  border: 1px solid #cfd3d8;
  border-radius: 6px;
  padding: 9px 11px;
  background: #fff;
}
input:focus, select:focus, button:focus-visible { outline: 2px solid var(--destaque); outline-offset: 1px; }
input.codigo { font-size: 22px; letter-spacing: 0.35em; text-align: center; font-family: ui-monospace, Consolas, monospace; }
.check { display: flex; align-items: center; gap: 8px; font-weight: 400; }
.check input { width: 16px; height: 16px; margin: 0; }

.botao {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 8px 14px;
  font-weight: 600;
  background: var(--escuro);
  color: #fff;
  cursor: pointer;
  white-space: nowrap;
}
.botao:hover { background: #1f2937; }
.botao:disabled { opacity: 0.55; cursor: default; }
.botao.cheio { width: 100%; padding: 10px 14px; }
.botao.leve { background: #fff; color: var(--texto); border-color: #cfd3d8; }
.botao.leve:hover { background: var(--fundo); }
.botao.perigo { background: #fff; color: var(--perigo); border-color: #f0c4c4; }
.botao.perigo:hover { background: #fdf2f2; }
.botao.pequeno { padding: 4px 9px; font-size: 13px; font-weight: 500; }
.link { background: none; border: 0; padding: 0; color: var(--suave); cursor: pointer; text-decoration: underline; }

.erro { color: var(--perigo); margin: -4px 0 12px; min-height: 0; }
.erro:empty { display: none; }

/* ---------- Estrutura ---------- */
.topo {
  background: var(--escuro);
  color: #fff;
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 0 24px;
  height: 56px;
  position: sticky;
  top: 0;
  z-index: 5;
}
.topo .marca { margin: 0; }
.topo nav { display: flex; gap: 4px; flex: 1; overflow-x: auto; }
.topo nav a {
  text-decoration: none;
  color: #cbd5e1;
  padding: 7px 12px;
  border-radius: 6px;
  white-space: nowrap;
}
.topo nav a:hover { color: #fff; background: rgba(255, 255, 255, 0.08); }
.topo nav a.ativo { color: #fff; background: rgba(255, 255, 255, 0.14); }
.topo .quem { display: flex; align-items: center; gap: 12px; color: #cbd5e1; white-space: nowrap; }
.topo .quem .botao { background: transparent; border-color: #374151; color: #e5e7eb; }
.topo .quem .botao:hover { background: rgba(255, 255, 255, 0.08); }

main { max-width: 1120px; margin: 0 auto; padding: 24px; }
.cabecalho { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.cabecalho .acoes { display: flex; gap: 8px; }
.voltar { color: var(--suave); text-decoration: none; font-size: 13px; display: inline-block; margin-bottom: 6px; }
.voltar:hover { color: var(--texto); }

.cartao {
  background: var(--cartao);
  border: 1px solid var(--borda);
  border-radius: 10px;
  padding: 20px;
  margin-bottom: 18px;
}
.cartao > h2 { margin-bottom: 14px; }
.grade { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 0 16px; }

/* ---------- Tabelas ---------- */
.tabela-caixa { overflow-x: auto; background: var(--cartao); border: 1px solid var(--borda); border-radius: 10px; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--borda); vertical-align: middle; }
th { font-size: 12px; font-weight: 600; color: var(--suave); text-transform: uppercase; letter-spacing: 0.04em; background: #fafafb; }
tr:last-child td { border-bottom: 0; }
tbody tr.clicavel { cursor: pointer; }
tbody tr.clicavel:hover { background: #fafafb; }
td.acoes { white-space: nowrap; text-align: right; }
td.acoes .botao + .botao { margin-left: 6px; }
td.centro, th.centro { text-align: center; }
.mono { font-family: ui-monospace, Consolas, monospace; font-size: 13px; }
.suave { color: var(--suave); }
.vazio { padding: 32px; text-align: center; color: var(--suave); }

.selo {
  display: inline-block;
  font-size: 12px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
  background: #eef0f3;
  color: #374151;
}
.selo.ok { background: #e7f6ec; color: var(--ok); }
.selo.alerta { background: #fff4e5; color: #9a3412; }
.selo.perigo { background: #fdecec; color: var(--perigo); }
.selo.admin { background: #ffedd5; color: var(--destaque-forte); }

/* ---------- Senha mostrada uma vez ---------- */
.entrega {
  border: 1px solid #fcd9b6;
  background: #fff8f1;
  border-radius: var(--raio);
  padding: 14px 16px;
  margin-bottom: 18px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.entrega .mono { font-size: 16px; font-weight: 600; letter-spacing: 0.04em; }
.entrega .fechar { margin-left: auto; }

/* ---------- Janela de confirmação ---------- */
.fundo-modal {
  position: fixed;
  inset: 0;
  background: rgba(17, 24, 39, 0.45);
  display: grid;
  place-items: center;
  padding: 16px;
  z-index: 20;
}
.modal { width: 100%; max-width: 340px; background: #fff; border-radius: 12px; padding: 22px; }
.modal h2 { margin-bottom: 14px; }
.modal .linha-botoes { display: flex; gap: 8px; justify-content: flex-end; }

/* ---------- Avisos ---------- */
#avisos { position: fixed; right: 16px; bottom: 16px; display: grid; gap: 8px; z-index: 30; }
.aviso {
  background: var(--escuro);
  color: #fff;
  padding: 10px 14px;
  border-radius: var(--raio);
  max-width: 360px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.18);
}
.aviso.erro-aviso { background: var(--perigo); }

@media (max-width: 720px) {
  .topo { padding: 0 12px; gap: 12px; }
  .topo .marca strong, .topo .quem .nome { display: none; }
  main { padding: 16px; }
}
