* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: "Segoe UI", -apple-system, Roboto, Arial, sans-serif;
  font-size: 16px;
  line-height: 1.45;
  color: #111;
  background: #f2f4f7;
}
main { max-width: 1500px; margin: 0 auto; padding: 16px 20px 40px; }
h1 { font-size: 1.6em; margin: 8px 0 16px; }
h2 { font-size: 1.2em; margin: 18px 0 10px; }
h3 { font-size: 1.05em; margin: 18px 0 8px; }
a { color: #0b4fa8; }
code { background: #e6e9ef; padding: 2px 5px; border-radius: 4px; font-size: .9em; }
.sub { font-size: .88em; color: #333; }
.quebra { word-break: break-all; }

.menu { display: flex; gap: 4px; background: #1d2a44; padding: 8px 20px; position: sticky; top: 0; z-index: 10; }
.menu a { color: #fff; text-decoration: none; font-weight: 600; padding: 9px 16px; border-radius: 8px; }
.menu a:hover { background: #2f4170; }
.menu a:last-child { margin-left: auto; }

.cartao { background: #fff; border-radius: 12px; padding: 16px 20px; margin: 14px 0; box-shadow: 0 1px 3px rgba(0,0,0,.12); }
.cartao.estreito { max-width: 420px; }

label { display: block; font-weight: 600; margin: 10px 0; }
input, select, textarea {
  font: inherit; color: #111; background: #fff;
  border: 2px solid #555; border-radius: 8px; padding: 8px 10px;
}
label > input, label > select { display: block; width: 100%; margin-top: 4px; }
input:focus, select:focus, textarea:focus { outline: 3px solid #0b4fa8; border-color: #0b4fa8; }

.botao {
  display: inline-block; cursor: pointer; font: inherit; font-weight: 700; color: #fff; background: #0b4fa8;
  border: 0; border-radius: 8px; padding: 10px 18px; margin: 6px 6px 6px 0; text-decoration: none;
}
.botao.verde { background: #13803a; }
.botao.vermelho { background: #b42318; }
.botao.claro { background: #fff; color: #0b4fa8; border: 2px solid #0b4fa8; }
.botao.pequeno { padding: 6px 12px; font-size: .9em; }

.aviso { padding: 12px 14px; border-radius: 10px; background: #e8eefc; border: 2px solid #0b4fa8; font-weight: 600; }
.aviso.ok { background: #e3f6e8; border-color: #13803a; }
.aviso.erro { background: #fde8e7; border-color: #b42318; }

.filtros { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; background: #fff; padding: 12px 16px; border-radius: 12px; box-shadow: 0 1px 3px rgba(0,0,0,.12); }
.filtros label { margin: 0; }
.filtros input, .filtros select { min-width: 150px; }
.linha-form { display: flex; flex-wrap: wrap; gap: 14px; align-items: flex-end; }
.linha-form label { margin: 0; min-width: 260px; }

.resumo { margin: 14px 0 8px; }
.tabela-rolagem { overflow-x: auto; background: #fff; border-radius: 12px; box-shadow: 0 1px 3px rgba(0,0,0,.12); }
table.notas, table.simples { width: 100%; border-collapse: collapse; }
table.notas th, table.simples th {
  text-align: left; background: #1d2a44; color: #fff; padding: 10px 8px; font-size: .9em; white-space: nowrap;
  position: sticky; top: 0;
}
table.notas td, table.simples td { padding: 8px; border-bottom: 1px solid #c9ced8; vertical-align: top; }
table.notas tr:hover td { background: #f5f8ff; }
/* Página Início: atalhos */
.atalhos { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; margin-top: 10px; }
.atalho { display: flex; flex-direction: column; gap: 6px; background: #fff; border-radius: 12px; padding: 18px; text-decoration: none; color: #111;
  box-shadow: 0 1px 3px rgba(0,0,0,.12); border: 2px solid transparent; }
.atalho:hover { border-color: #0b4fa8; }
.atalho-icone { font-size: 1.8em; }
.atalho-nome { font-weight: 700; font-size: 1.1em; color: #0b4fa8; }
.atalho-desc { font-size: .92em; color: #333; }
/* Tela Usuários: caixas de acesso */
.grade-acessos { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 6px 14px; margin: 8px 0 10px; }
.opcao-acesso { display: flex; align-items: center; gap: 8px; font-weight: 500; margin: 4px 0; }
.opcao-acesso input { width: 18px; height: 18px; }
.opcao-acesso.admin { margin-top: 8px; }

/* Prazo vencido da situação atual: linha em vermelho e negrito */
table.notas tr.em-alerta td { background: #fde8e7; color: #9b1c13; font-weight: 700; }
/* Títulos que ordenam a coluna ao clicar */
table.notas th.ordena { cursor: pointer; user-select: none; }
table.notas th.ordena:hover { background: #2f4170; }
table.notas th.ordena::after { content: " ⇅"; font-size: .85em; opacity: .7; }
table.notas th.ordena[data-dir="asc"]::after { content: " ▲"; opacity: 1; }
table.notas th.ordena[data-dir="desc"]::after { content: " ▼"; opacity: 1; }
table.notas tr.salvando { opacity: .6; }
table.notas tr.salvo td { background: #e3f6e8; transition: background .3s; }
table.notas tr.saindo { opacity: 0; transition: opacity .4s; }
td.num { white-space: nowrap; text-align: right; }
td.vazio { text-align: center; padding: 24px; font-weight: 600; }
.c-alerta { width: 34px; text-align: center; position: relative; }
.alerta { font-size: 1.2em; color: #b42318; cursor: pointer; background: none; border: 0; padding: 2px 4px; border-radius: 6px; }
.alerta:hover, .alerta:focus { background: #b42318; color: #fff; outline: none; }
/* Balão com o aviso de prazo, aberto ao clicar no ícone ⚠ */
.balao {
  position: absolute; left: 32px; top: 4px; z-index: 5; width: max-content; max-width: 280px;
  background: #fff; color: #9b1c13; border: 2px solid #b42318; border-radius: 8px;
  padding: 6px 10px; font-size: .9em; font-weight: 700; text-align: left; box-shadow: 0 2px 8px rgba(0,0,0,.2);
}
.txt-alerta { color: #b42318; font-weight: 700; font-size: .88em; }
.na { color: #333; font-size: .85em; font-style: italic; }

.tag { display: inline-block; font-size: .78em; font-weight: 700; padding: 1px 6px; border-radius: 5px; color: #fff; }
/* Cores fixas: azul = fora do estado, verde = Amazonas (iguais às bolinhas 🔵 🟢 do Telegram) */
.tag.fora { background: #1f5fbf; }
.tag.dentro { background: #13803a; }

/* Abas da página do grupo */
.abas { display: flex; flex-wrap: wrap; gap: 8px; margin: 14px 0 0; }
.aba {
  font: inherit; font-weight: 700; font-size: 1.05em; cursor: pointer;
  padding: 12px 20px; border-radius: 10px 10px 0 0; border: 3px solid; border-bottom: 0; background: #fff;
}
.aba-fora { color: #1f5fbf; border-color: #1f5fbf; }
.aba-am { color: #13803a; border-color: #13803a; }
.aba-fora.ativa { background: #1f5fbf; color: #fff; }
.aba-am.ativa { background: #13803a; color: #fff; }
.selo-alerta { display: inline-block; margin-left: 6px; padding: 1px 8px; border-radius: 10px; background: #b42318; color: #fff; font-size: .85em; }
.painel { border-top: 6px solid; padding-top: 4px; margin-bottom: 24px; }
.painel-fora { border-color: #1f5fbf; }
.painel-am { border-color: #13803a; }
.painel-fora .titulo-painel { color: #1f5fbf; }
.painel-am .titulo-painel { color: #13803a; }
.com-abas .titulo-painel { display: none; }
.titulo-alerta { color: #b42318; }

/* Lista por empresa (abre e fecha ao tocar no nome) */
details.empresa { margin: 12px 0; }
details.empresa > summary {
  cursor: pointer; font-weight: 700; font-size: 1.05em; padding: 10px 12px; margin-bottom: 6px;
  background: #fff; border: 2px solid #555; border-radius: 10px; list-style-position: inside;
}
details.empresa[open] > summary { border-color: #1d2a44; }

.empresa-cel { display: none; font-weight: 700; font-size: .85em; margin-top: 2px; }

/* Celular: só Fornecedor, NF, Valor e ICMS (as outras colunas ficam no computador) */
@media (max-width: 700px) {
  main { padding: 10px 8px 30px; }
  h1 { font-size: 1.3em; margin: 4px 0 8px; }
  .pagina-grupo .c-emissao, .pagina-grupo .c-entrada, .pagina-grupo .c-selada,
  .pagina-grupo .c-entrega, .pagina-grupo .c-cnpj, .pagina-grupo .c-empresa { display: none; }
  .pagina-grupo .empresa-cel { display: block; }
  .pagina-grupo table.notas th, .pagina-grupo table.notas td { padding: 7px 5px; font-size: .95em; }
  .pagina-grupo .c-alerta { width: 20px; }
  .aba { padding: 10px 12px; font-size: 1em; }
}

/* Campos da tabela sem borda (parecem texto); ao clicar aparece só o contorno azul de foco */
input.campo.data, input.campo.icms {
  border: 0; background: transparent; border-radius: 4px; color: #111; font: inherit;
}
input.campo.data { width: 105px; padding: 4px 2px; }
input.campo.icms { width: 115px; text-align: right; padding: 4px 2px; }
input.campo.data::placeholder, input.campo.icms::placeholder { color: #555; opacity: 1; }
input.campo.data:hover, input.campo.icms:hover { background: #eef2fa; }
input.campo.data:focus, input.campo.icms:focus { background: #fff; outline: 3px solid #0b4fa8; }
textarea.campo.obs { width: 200px; min-height: 34px; resize: vertical; padding: 5px 8px; border-width: 1px; }
input.data-st { margin-top: 4px; font-size: .9em; }
.data-st-txt { font-size: .88em; margin-top: 3px; }

/* Todos os botões de situação (Selada, Não Selada, Aguardando, Aguardando selar) com o mesmo tamanho */
.st {
  display: inline-block; box-sizing: border-box; width: 11.5em; text-align: center;
  font-weight: 700; padding: 5px 8px; border-radius: 6px; white-space: nowrap; user-select: none;
  border: 2px solid transparent;
}
.st.ok { background: #13803a; color: #fff; border-color: #13803a; }
.st.pendente { background: #ffe3b3; color: #5c3600; border: 2px solid #a15c00; }
.st.bloqueada { background: #e6e9ef; color: #222; border: 2px dashed #555; }
.st.cancelada { background: #b42318; color: #fff; }
.st.alterna { cursor: pointer; }
.st.alterna:hover { outline: 3px solid #0b4fa8; }
.contagem { font-weight: 400; }
.contador { background: #e8eefc; border: 2px solid #0b4fa8; border-radius: 10px; padding: 10px 14px; margin: 0 0 12px; font-weight: 600; }
.contador-tempo { font-size: 1.15em; font-variant-numeric: tabular-nums; }
.contador details { margin-top: 4px; font-weight: 400; }
.contador summary { cursor: pointer; font-size: .9em; }
.contador ul { margin: 6px 0 0; }
/* Página das notas de fora do estado (link de selagem e link do grupo): grupos independentes que abrem ao tocar.
   Tons claros/cinza; o texto continua escuro para facilitar a leitura. */
details.acord { margin: 8px 0; background: #fff; border: 2px solid #c9ced8; border-radius: 10px; overflow: hidden; }
details.acord > summary {
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  cursor: pointer; list-style: none; padding: 14px 16px; font-weight: 700; font-size: 1.1em;
  color: #111; background: #eceff3;
}
details.acord > summary::-webkit-details-marker { display: none; }
details.acord > summary .acord-nome::before { content: '▸'; display: inline-block; width: 1.1em; }
details.acord[open] > summary .acord-nome::before { content: '▾'; }
details.acord[open] > summary { border-bottom: 2px solid #c9ced8; }
.acord-qtd { font-weight: 700; white-space: nowrap; background: #fff; border: 1px solid #c9ced8; border-radius: 12px; padding: 0 10px; }
.acord-espaco { height: 18px; }
details.acord .tabela-rolagem { border-radius: 0; box-shadow: none; }
table.notas.selar th { background: #f6f7f9; color: #111; border-bottom: 2px solid #c9ced8; }
table.notas.selar th.num { text-align: right; }
/* Precisa de atenção: linha com fundo rosado e letra vermelha */
table.notas.selar tr.atencao td { background: #fde8e7; color: #9b1c13; font-weight: 700; }
label.marcar { display: flex; gap: 8px; align-items: center; font-weight: 600; }
label.marcar input { width: 20px; height: 20px; }
details.diagnostico { margin-top: 14px; border-top: 2px solid #c9ced8; padding-top: 8px; }
details.diagnostico > summary { cursor: pointer; font-weight: 700; padding: 6px 0; }
.form-nome { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.form-nome input { font-weight: 700; min-width: 220px; padding: 5px 8px; }
.form-nome .botao { margin: 0; }
.form-nome input.sigla { min-width: 0; width: 80px; }
