/* Padrão visual definido nas abas "Padrão Tela Principal" e "Padrão da Tela de Cadastro" */
:root {
  --lateral: #141b2d;
  --lateral-ativo: #1f2937;
  --lateral-texto: #c9d1de;
  --destaque: #4ade80;
  --fundo: #f4f4f5;
  --texto: #111827;
  --suave: #4b5563;
  --borda: #e5e7eb;
  --verde: #2e6b2f;
  --azul: #1677ff;
  --vermelho: #dc2626;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  display: flex;
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
  color: var(--texto);
  background: var(--fundo);
}

/* ---------- barra lateral ---------- */
.lateral {
  width: 260px; flex: none; height: 100vh; overflow-y: auto;
  background: var(--lateral); color: var(--lateral-texto);
}
.marca {
  height: 98px; display: flex; align-items: center; justify-content: center;
  font-size: 22px; font-weight: 700; color: #fff;
  border-bottom: 1px solid rgba(255,255,255,.06);
}
nav { padding: 18px 14px; }
.item {
  display: flex; align-items: center; gap: 12px; width: 100%;
  padding: 13px 16px; margin-bottom: 4px; border: 0; border-radius: 8px;
  background: none; color: inherit; font: inherit; font-size: 17px; text-align: left; cursor: pointer;
  position: relative; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.item:hover { background: rgba(255,255,255,.05); color: #fff; }
.item svg { width: 18px; height: 18px; flex: none; opacity: .85; }
.item .rotulo { flex: 1; overflow: hidden; text-overflow: ellipsis; }
.item .seta { width: 14px; height: 14px; transition: transform .15s; }
.grupo.aberto > .item .seta { transform: rotate(180deg); }
.grupo .filhos { display: none; }
.grupo.aberto .filhos { display: block; }
.filhos .item { padding-left: 46px; }
.item.ativo { background: var(--lateral-ativo); color: #fff; font-weight: 600; }
.item.ativo::after {
  content: ""; position: absolute; right: 0; top: 0; bottom: 0; width: 6px;
  background: var(--destaque); border-radius: 0 8px 8px 0;
}

/* ---------- conteúdo ---------- */
.conteudo { flex: 1; height: 100vh; overflow-y: auto; padding: 30px 30px 40px; }
.titulo {
  margin: 0 0 18px; padding-bottom: 14px; font-size: 18px; font-weight: 700;
  border-bottom: 1px solid #d9d9de;
}
.busca label { display: block; font-size: 14px; color: var(--suave); margin-bottom: 6px; }
.busca .linha { display: flex; gap: 10px; }
input, select {
  font: inherit; font-size: 15px; color: var(--texto);
  height: 38px; padding: 0 12px; border: 1px solid #d9d9d9; border-radius: 6px; background: #fff; outline: none;
}
input:focus, select:focus { border-color: var(--azul); box-shadow: 0 0 0 2px rgba(22,119,255,.12); }
input::placeholder { color: #a3a3a3; text-transform: none; }
input.maiusculo { text-transform: uppercase; }
.busca input { width: 312px; }

.btn {
  height: 38px; padding: 0 18px; border-radius: 6px; cursor: pointer;
  font: inherit; font-size: 16px; border: 1px solid #d9d9d9; background: #fff; color: var(--texto);
}
.btn:hover { border-color: var(--azul); color: var(--azul); }
.btn.inserir { background: var(--verde); border-color: var(--verde); color: #fff; font-weight: 700; padding: 0 24px; }
.btn.inserir:hover { filter: brightness(1.12); color: #fff; }
.btn.primario { background: var(--azul); border-color: var(--azul); color: #fff; }
.btn.primario:hover { filter: brightness(1.1); color: #fff; }
.btn.perigo { color: var(--vermelho); border-color: #f5c2c2; }
.btn.perigo:hover { background: #fef2f2; }
.btn:disabled { opacity: .45; cursor: default; filter: none; color: var(--suave); border-color: #d9d9d9; }

.cabecalho-lista { display: flex; align-items: flex-end; justify-content: space-between; margin: 26px 0 16px; }
.cabecalho-lista h3 { margin: 0; font-size: 18px; }
.por-pagina { display: flex; align-items: center; gap: 10px; color: var(--suave); }
.por-pagina select { width: 100px; }

table { width: 100%; border-collapse: collapse; font-size: 14px; }
thead th {
  text-align: left; font-weight: 600; font-size: 15px; padding: 10px 14px;
  background: #faf7f7; border-bottom: 1px solid #d9d9de; white-space: nowrap;
}
tbody td { padding: 8px 14px; border-bottom: 1px solid #ececef; text-transform: uppercase; }
tbody tr { cursor: pointer; }
tbody tr:hover { background: #fff; }
th.chave, td.chave { text-align: center; width: 110px; }
td.chave { font-weight: 600; }
td.num { text-align: right; }
.vazio { text-align: center; color: var(--suave); padding: 40px; cursor: default; }

.paginacao { display: flex; justify-content: center; align-items: center; gap: 20px; margin-top: 22px; }
.paginacao span { font-weight: 600; color: var(--suave); }

/* ---------- início ---------- */
.cartoes { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; }
.cartao {
  background: #fff; border: 1px solid var(--borda); border-radius: 10px; padding: 18px 20px; cursor: pointer;
}
.cartao:hover { border-color: var(--verde); }
.cartao small { color: var(--suave); }
.cartao strong { display: block; font-size: 30px; margin-top: 6px; }

/* ---------- modal ---------- */
.fundo-modal {
  position: fixed; inset: 0; background: rgba(0,0,0,.45);
  display: flex; align-items: flex-start; justify-content: center; padding-top: 10vh; z-index: 10;
}
.fundo-modal[hidden] { display: none; }
.modal {
  position: relative; width: min(650px, 94vw); max-height: 85vh; overflow-y: auto;
  background: #fff; border-radius: 10px; padding: 26px 30px 24px; box-shadow: 0 10px 40px rgba(0,0,0,.25);
}
.modal h2 { margin: 0 0 16px; font-size: 19px; font-weight: 600; }
.fechar {
  position: absolute; right: 22px; top: 16px; border: 0; background: none;
  font-size: 30px; line-height: 1; color: #777; cursor: pointer;
}
.campo { margin-bottom: 18px; }
.campo label { display: block; font-size: 14px; color: #333; margin-bottom: 8px; }
.campo input, .campo select { width: 100%; }
.campo input[type=checkbox] { width: auto; height: auto; }
.campo .info { font-size: 12px; color: #999; margin-top: 4px; text-align: right; }
.acoes { display: flex; gap: 12px; align-items: center; margin-top: 8px; }
.espaco { flex: 1; }
.erro { color: var(--vermelho); white-space: pre-line; margin: 0 0 10px; }

.aviso {
  position: fixed; right: 24px; bottom: 24px; background: #111827; color: #fff;
  padding: 12px 18px; border-radius: 8px; opacity: 0; transition: opacity .2s; pointer-events: none;
}
.aviso.ver { opacity: 1; }

/* ---------- v1.1: tabelas largas, campos automáticos, dicas ---------- */
.rolagem { overflow-x: auto; }
.rolagem th, .rolagem td { white-space: nowrap; }
input.num { text-align: right; }
input[data-auto] { background: #f3f4f6; color: #374151; }
.campo .ajuda { font-size: 12px; color: #6b7280; margin-top: 4px; }
.obrig { color: var(--vermelho); }

/* ---------- relatório ---------- */
.grade-filtros { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px 20px; margin-bottom: 16px; }
.filtro label { display: block; font-size: 13px; color: var(--suave); margin-bottom: 5px; }
.filtro input, .filtro select { width: 100%; }
.faixa { display: flex; align-items: center; gap: 6px; }
.faixa span { font-size: 12px; color: var(--suave); }
.acoes-rel { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; padding-bottom: 16px; border-bottom: 1px solid #d9d9de; }
.rel-info { color: var(--suave); margin: 14px 0 10px; }
.dica { color: var(--suave); font-size: 14px; }
.tabela-rel tbody tr { cursor: default; }
.tabela-rel tfoot td { font-weight: 700; border-top: 2px solid #9ca3af; padding: 8px 14px; }
th.num { text-align: right; }
.cab-impressao { display: none; }

@media print {
  @page { size: landscape; margin: 12mm; }
  body { display: block; background: #fff; }
  .lateral, .sem-impressao, .aviso, .fundo-modal { display: none !important; }
  .conteudo { height: auto; overflow: visible; padding: 0; }
  .cab-impressao { display: flex; justify-content: space-between; font-size: 12px; color: #555; margin-bottom: 6px; }
  .titulo { font-size: 16px; margin-bottom: 4px; padding-bottom: 6px; }
  .rel-info { color: #333; font-size: 12px; margin: 4px 0 8px; }
  .rolagem { overflow: visible; }
  .tabela-rel { font-size: 10px; }
  .tabela-rel th, .tabela-rel td { padding: 3px 6px; white-space: normal; }
  .tabela-rel thead { display: table-header-group; }
  .tabela-rel tr { break-inside: avoid; }
}
.ordem-rel { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.ordem-rel label { font-size: 13px; color: var(--suave); }
.ordem-rel select { min-width: 280px; }
.ordem-rel .marcar { display: flex; align-items: center; gap: 6px; color: var(--texto); font-size: 14px; }
.ordem-rel .marcar input { width: auto; height: auto; }

th.ordenavel { cursor: pointer; user-select: none; }
th.ordenavel:hover { text-decoration: underline; }

td.conf { white-space: nowrap; font-size: 13px; }
td.conf.ok { color: #1a7f37; text-align: center; }
td.conf.dif, td.dif { color: #b3261e; font-weight: 600; }
.saldo-box { grid-column: 1 / -1; padding: 10px 14px; border-radius: 6px; background: #eef3fb; color: #1d3557; font-size: 14px; }
.saldo-box.ok { background: #e6f4ea; color: #1a7f37; }
.saldo-box.alerta { background: #fdecea; color: #b3261e; }
/* login / usuários */
#tela-login { position: fixed; inset: 0; z-index: 50; background: #f2f4f7; display: flex; align-items: center; justify-content: center; overflow: auto; }
.caixa-login { background: #fff; padding: 32px 36px; border-radius: 10px; box-shadow: 0 6px 30px rgba(0,0,0,.12); width: 400px; max-width: 94vw; display: flex; flex-direction: column; gap: 14px; }
.caixa-login h1 { margin: 0; font-size: 24px; }
.caixa-login h2 { margin: 0; font-size: 17px; font-weight: 600; }
.caixa-login label { display: flex; flex-direction: column; gap: 6px; font-size: 14px; color: var(--suave); }
.caixa-login label.marcar { flex-direction: row; align-items: center; color: var(--texto); }
.caixa-login label.marcar input { width: auto; height: auto; }
.usuario-menu { margin-top: auto; padding: 14px 16px; border-top: 1px solid rgba(255,255,255,.15); font-size: 13px; display: flex; flex-direction: column; gap: 4px; }
button.link { background: none; border: 0; padding: 0; color: inherit; text-decoration: underline; cursor: pointer; font-size: 12px; opacity: .85; text-align: left; }
.rastro { grid-column: 1 / -1; font-size: 12px; color: var(--suave); border-top: 1px dashed #ddd; padding-top: 8px; }
td.mudancas { font-size: 12px; }