:root {
  --fundo: #f4f6f8;
  --cartao: #ffffff;
  --texto: #1c2430;
  --discreto: #667085;
  --borda: #e2e6eb;
  --acento: #1f5fbf;
  --acento-escuro: #184c99;
  --acento-claro: #e9f0fb;
  --erro: #b42318;
  --raio: 10px;
  --sombra: 0 1px 2px rgba(16, 24, 40, 0.05), 0 1px 3px rgba(16, 24, 40, 0.07);
  color-scheme: light;
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
  font-size: 15px;
  color: var(--texto);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--fundo); }
h1 { font-size: 20px; margin: 0 0 16px; }
h2 { font-size: 18px; margin: 0 0 8px; }
h3 { font-size: 15px; margin: 24px 0 10px; }

/* Topo e abas */
.topo {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 24px;
  padding: 10px 24px; background: var(--cartao); border-bottom: 1px solid var(--borda);
}
.marca { font-weight: 700; font-size: 17px; }
.marca span { color: var(--discreto); font-weight: 500; }
.abas { display: flex; gap: 4px; }
.aba {
  border: 0; background: none; padding: 8px 14px; border-radius: 8px;
  font: inherit; color: var(--discreto); cursor: pointer;
}
.aba:hover { color: var(--texto); }
.aba.ativa { background: var(--acento-claro); color: var(--acento-escuro); font-weight: 600; }
.token { margin-left: auto; font-size: 13px; color: var(--discreto); text-align: right; }
.token.alerta { color: var(--erro); font-weight: 600; }

.faixa-alerta {
  padding: 10px 24px; font-size: 14px;
  background: #fffaeb; color: #93370d; border-bottom: 1px solid #fedf89;
}

main { max-width: 1240px; margin: 0 auto; padding: 24px; }
.cartao { background: var(--cartao); border: 1px solid var(--borda); border-radius: var(--raio); box-shadow: var(--sombra); }

/* Formulários */
.formulario { padding: 20px; margin-bottom: 20px; }
.grade { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; }
label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 600; color: var(--discreto); }
input, select {
  font: inherit; color: var(--texto); background: #fff; min-width: 0;
  padding: 8px 10px; border: 1px solid #cdd3da; border-radius: 8px;
}
input:focus, select:focus { outline: 3px solid var(--acento-claro); border-color: var(--acento); }
.acoes { margin-top: 16px; display: flex; justify-content: flex-end; }

.botao {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 0; border-radius: 8px; padding: 9px 18px;
  background: var(--acento); color: #fff; font: inherit; font-weight: 600;
  cursor: pointer; text-decoration: none; white-space: nowrap;
}
.botao:hover { background: var(--acento-escuro); }
.botao:disabled { opacity: 0.6; cursor: progress; }
.botao.secundario { background: #fff; color: var(--acento-escuro); border: 1px solid #c6d4ea; }
.botao.secundario:hover { background: var(--acento-claro); }
.botao.pequeno { padding: 6px 12px; font-size: 13px; }

/* Tela de entrada */
.pagina-login { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.pagina-login main { width: min(380px, 100%); max-width: none; margin: 0; padding: 0; }
.login { display: flex; flex-direction: column; gap: 16px; padding: 28px; }
.login .marca { font-size: 20px; }
.login h1 { margin: 0; }
.login .erro { margin: 0; }
.login .botao { padding: 11px 18px; }

/* Tabelas */
.tabela-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 10px 14px; text-align: left; border-bottom: 1px solid var(--borda); vertical-align: top; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: 0.4px; color: var(--discreto); background: #fafbfc; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr[data-codigo] { cursor: pointer; }
tbody tr[data-codigo]:hover, tbody tr[data-codigo]:focus { background: #f5f8fd; outline: none; }
.tabela-topo { padding: 10px 14px; border-bottom: 1px solid var(--borda); }
.numero { text-align: right; font-variant-numeric: tabular-nums; }
.mono { font-family: "Cascadia Mono", Consolas, monospace; font-size: 13px; }
.discreto { color: var(--discreto); font-size: 13px; }
.vazio { text-align: center; color: var(--discreto); padding: 32px; }
.atrasado { color: var(--erro); font-weight: 600; }
.texto-erro { color: var(--erro); }
.erro {
  background: #fef3f2; border: 1px solid #fecdca; color: var(--erro);
  border-radius: 8px; padding: 12px 14px; margin: 12px 0;
}
.aviso { padding: 14px 16px; color: var(--discreto); }

/* Rastreio */
.barra { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 16px; }
.barra h1 { margin: 0; }
.barra-direita { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }

.indicadores { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; margin-bottom: 16px; }
.indicador {
  text-align: left; font: inherit; cursor: pointer;
  background: var(--cartao); border: 1px solid var(--borda); border-left: 4px solid var(--cor, #98a2b3);
  border-radius: var(--raio); padding: 12px 14px; box-shadow: var(--sombra);
}
.indicador:hover { border-color: var(--cor); }
.indicador.ativo { background: var(--acento-claro); border-color: var(--cor); }
.indicador .valor { display: block; font-size: 24px; font-weight: 700; color: var(--texto); }
.indicador .rotulo { font-size: 13px; color: var(--discreto); }

.filtros { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px; padding: 14px; margin-bottom: 16px; }
.filtros .busca { flex: 1 1 240px; }

/* Selos de status */
.selo {
  display: inline-block; padding: 2px 9px; border-radius: 999px;
  font-size: 12px; font-weight: 600; white-space: nowrap;
  background: color-mix(in srgb, var(--cor, #98a2b3) 14%, white);
  color: color-mix(in srgb, var(--cor, #98a2b3) 80%, black);
}
.s-aguardando_postagem, .ind-aguardando_postagem { --cor: #98a2b3; }
.s-em_transito, .ind-em_transito { --cor: #2e6fd8; }
.s-saiu_para_entrega, .ind-saiu_para_entrega { --cor: #7a4fd6; }
.s-aguardando_retirada, .ind-aguardando_retirada { --cor: #c27803; }
.s-entregue, .ind-entregue { --cor: #1d8a55; }
.s-ocorrencia, .ind-ocorrencia { --cor: #d1453b; }
.s-devolvido, .ind-devolvido { --cor: #8f2d26; }
.s-atrasado, .ind-atrasado { --cor: #d1453b; }

/* Detalhe do objeto */
.detalhe {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 20;
  width: min(440px, 100%); overflow-y: auto; padding: 24px;
  background: var(--cartao); border-left: 1px solid var(--borda); box-shadow: -8px 0 24px rgba(16, 24, 40, 0.12);
}
.fechar {
  position: absolute; top: 10px; right: 12px; border: 0; background: none;
  font-size: 28px; line-height: 1; cursor: pointer; color: var(--discreto);
}
.dados { display: grid; grid-template-columns: 110px 1fr; gap: 6px 12px; margin: 16px 0; font-size: 14px; }
.dados dt { color: var(--discreto); }
.dados dd { margin: 0; }
.linha-do-tempo { list-style: none; margin: 0 0 0 6px; padding: 0 0 0 18px; border-left: 2px solid var(--borda); }
.evento { position: relative; padding: 0 0 16px 4px; }
.evento::before {
  content: ""; position: absolute; left: -25px; top: 4px; width: 10px; height: 10px; border-radius: 50%;
  background: #cdd3da; border: 2px solid #fff; box-shadow: 0 0 0 1px #cdd3da;
}
.evento:first-child::before { background: var(--acento); box-shadow: 0 0 0 1px var(--acento); }
.evento .quando { font-size: 12px; color: var(--discreto); }
.evento .oque { font-weight: 600; }

.aviso-flutuante {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 30;
  max-width: min(640px, calc(100% - 32px)); padding: 10px 16px; border-radius: 8px;
  background: #1c2430; color: #fff; box-shadow: 0 6px 20px rgba(0, 0, 0, 0.2);
}
.aviso-flutuante.erro { background: var(--erro); border: 0; margin: 0; }

@media (max-width: 720px) {
  .topo { flex-wrap: wrap; gap: 12px; padding: 10px 16px; }
  .token { margin-left: 0; width: 100%; text-align: left; }
  main { padding: 16px; }
}
