:root {
  --marinho: #13233f;
  --marinho-2: #1d3360;
  --azul: #2357d6;
  --azul-claro: #e8eefc;
  --fundo: #f4f5f8;
  --cartao: #ffffff;
  --texto: #1b2230;
  --sutil: #667085;
  --borda: #e2e5ec;
  --ok: #157f3b;
  --ok-fundo: #e6f4ea;
  --alerta: #9a6700;
  --alerta-fundo: #fff4d6;
  --erro: #b42318;
  --erro-fundo: #fdecea;
  --raio: 10px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; color: var(--texto); background: var(--fundo); }
a { color: var(--azul); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.45rem; margin: 0 0 .5rem; line-height: 1.25; }
h2 { font-size: 1.05rem; margin: 0 0 .75rem; }
code { font-size: .82rem; background: var(--fundo); padding: 1px 4px; border-radius: 4px; word-break: break-all; }
.sutil { color: var(--sutil); }
.vazio { color: var(--sutil); text-align: center; padding: 1rem 0; margin: 0; }
.quebra { word-break: break-all; }

/* Layout */
.layout { display: flex; min-height: 100vh; }
.lateral { width: 230px; background: var(--marinho); color: #fff; padding: 1.2rem .8rem; position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; flex-shrink: 0; }
.marca { display: flex; align-items: center; gap: .55rem; color: #fff; font-weight: 700; font-size: 1.02rem; padding: 0 .5rem 1.2rem; }
.marca:hover { text-decoration: none; }
.marca.grande { color: var(--marinho); font-size: 1.3rem; padding: 0; justify-content: center; }
.logo { display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 8px; background: var(--azul); color: #fff; font-weight: 800; }
.lateral nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.lateral nav a { color: #c9d3e6; padding: .55rem .75rem; border-radius: 8px; }
.lateral nav a:hover { background: var(--marinho-2); color: #fff; text-decoration: none; }
.lateral nav a.ativo { background: var(--marinho-2); color: #fff; font-weight: 600; }
.lateral .sep { font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: #7f8ba3; padding: 1rem .75rem .3rem; }
.sair { padding: .75rem; border-top: 1px solid #2b3d61; display: flex; justify-content: space-between; align-items: center; gap: .5rem; }
.sair small { color: #c9d3e6; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conteudo { flex: 1; padding: 1.6rem 2rem 3rem; min-width: 0; max-width: 1200px; }
.sozinho { max-width: 420px; margin: 8vh auto; padding: 0 16px; }
.inferior { display: none; }

/* Blocos */
.cartao { background: var(--cartao); border: 1px solid var(--borda); border-radius: var(--raio); padding: 1.1rem 1.2rem; margin-bottom: 1rem; }
.cartao.estreito { max-width: 460px; }
.cartao.destaque { border: 2px solid var(--azul); background: #fbfcff; }
.entrar { padding: 2rem 1.6rem; text-align: center; }
.entrar form { text-align: left; margin-top: 1rem; }
.topo { display: flex; justify-content: space-between; align-items: flex-start; gap: .75rem; flex-wrap: wrap; margin-bottom: 1rem; }
.topo h1, .topo h2 { margin: 0 0 .25rem; }
.cartao .topo { margin-bottom: .5rem; }
.acoes { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.duas-colunas { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.duas-colunas > .cartao { margin-bottom: 0; }
.duas-colunas { margin-bottom: 1rem; }

/* Indicadores */
.indicadores { display: grid; grid-template-columns: repeat(auto-fill, minmax(175px, 1fr)); gap: .75rem; margin-bottom: 1rem; }
.ind { background: var(--cartao); border: 1px solid var(--borda); border-radius: var(--raio); padding: .8rem 1rem; display: flex; flex-direction: column; }
.ind small { color: var(--sutil); font-size: .8rem; }
.ind strong { font-size: 1.3rem; font-variant-numeric: tabular-nums; }
.ind span { font-size: .82rem; color: var(--sutil); }
.ind.futuro { background: transparent; border-style: dashed; }

/* Botões */
.botao { display: inline-flex; align-items: center; justify-content: center; gap: .3rem; font: inherit; font-weight: 600; padding: .55rem .95rem; border-radius: 8px; border: 1px solid var(--borda); background: #fff; color: var(--texto); cursor: pointer; min-height: 40px; text-decoration: none; }
.botao:hover { background: var(--fundo); text-decoration: none; }
.botao.primario { background: var(--azul); border-color: var(--azul); color: #fff; }
.botao.primario:hover { background: #1b47b5; }
.botao.perigo { color: var(--erro); border-color: #f1b8b2; }
.botao.perigo:hover { background: var(--erro-fundo); }
.botao.pequeno { padding: .3rem .65rem; min-height: 34px; font-size: .88rem; }
.botao.largo { width: 100%; margin-top: .5rem; }
.botao.link, button.link { background: none; border: 0; color: #fff; text-decoration: underline; cursor: pointer; font: inherit; padding: 0; }

/* Avisos e selos */
.aviso { padding: .7rem 1rem; border-radius: 8px; margin-bottom: 1rem; border: 1px solid; }
.aviso-ok { background: var(--ok-fundo); color: var(--ok); border-color: #b7dfc3; }
.aviso-erro { background: var(--erro-fundo); color: var(--erro); border-color: #f1b8b2; }
.aviso-aviso { background: var(--alerta-fundo); color: var(--alerta); border-color: #f0d68a; }
.selo { display: inline-block; font-size: .76rem; font-weight: 600; padding: .12rem .5rem; border-radius: 999px; background: var(--fundo); color: var(--sutil); white-space: nowrap; vertical-align: middle; }
.s-aguardando_pagamento { background: var(--alerta-fundo); color: var(--alerta); }
.s-pago { background: var(--azul-claro); color: var(--azul); }
.s-em_producao, .s-pronto { background: #efe7fd; color: #6b3fc4; }
.s-em_remessa, .s-enviado, .s-recebido_representante { background: #e3f2f7; color: #136a85; }
.s-entregue { background: var(--ok-fundo); color: var(--ok); }
.s-cancelado, .s-estornado { background: var(--erro-fundo); color: var(--erro); }
.r-ativo { background: var(--ok-fundo); color: var(--ok); }
.r-candidato { background: var(--alerta-fundo); color: var(--alerta); }
.r-bloqueado { background: var(--erro-fundo); color: var(--erro); }

/* Tabelas */
.tabela { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 0 -.2rem; }
table { width: 100%; border-collapse: collapse; font-size: .92rem; }
th { text-align: left; font-size: .76rem; text-transform: uppercase; letter-spacing: .04em; color: var(--sutil); font-weight: 600; padding: .5rem .55rem; border-bottom: 1px solid var(--borda); white-space: nowrap; }
td { padding: .6rem .55rem; border-bottom: 1px solid var(--borda); vertical-align: top; }
tbody tr:last-child td { border-bottom: 0; }
tr[data-href] { cursor: pointer; }
tr[data-href]:hover td { background: #f8f9fc; }
.acoes-col { white-space: nowrap; text-align: right; width: 1%; }
.acoes-col form, .acoes form { display: inline; margin: 0; }
.acoes-col .botao + form, .acoes-col .botao + .botao { margin-left: .3rem; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
table.compacta td { font-size: .84rem; }
code.json { display: block; max-width: 340px; white-space: pre-wrap; }

/* Formulários */
.formulario fieldset { border: 0; padding: 0; margin: 0 0 1.1rem; }
legend { font-weight: 700; margin-bottom: .6rem; padding: 0; }
.grade { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: .2rem 1rem; }
.campo { display: flex; flex-direction: column; gap: .25rem; margin-bottom: .75rem; min-width: 0; }
.campo > span { font-size: .86rem; font-weight: 600; }
.campo small { color: var(--sutil); font-size: .8rem; }
.campo small.erro { color: var(--erro); }
.req { color: var(--erro); font-weight: 600; }
input, select, textarea { font: inherit; font-size: 16px; padding: .55rem .65rem; border: 1px solid #cdd2dc; border-radius: 8px; background: #fff; color: var(--texto); width: 100%; min-height: 42px; }
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--azul-claro); border-color: var(--azul); }
.com-erro input, .com-erro select, .com-erro textarea { border-color: var(--erro); }
.check { display: flex; align-items: center; gap: .45rem; font-size: .92rem; margin: .4rem 0 .8rem; }
.check input { width: auto; min-height: 0; }
.filtros { display: flex; gap: .5rem; flex-wrap: wrap; margin-bottom: 1rem; }
.filtros input[type=search] { flex: 1 1 240px; width: auto; }
.filtros select { flex: 0 1 230px; width: auto; }
details { margin: .2rem 0 .8rem; }
details summary { cursor: pointer; color: var(--azul); font-weight: 600; font-size: .92rem; padding: .3rem 0; }
details.perigo summary { color: var(--erro); }
details[open] summary { margin-bottom: .5rem; }

.linha-edicao { display: grid; grid-template-columns: 1.6fr 1fr 1fr auto 190px; gap: .75rem; align-items: end; padding: .6rem 0; border-bottom: 1px solid var(--borda); }
.linha-edicao:last-child { border-bottom: 0; }
.linha-edicao .campo, .linha-edicao .check { margin-bottom: 0; }
.linha-edicao .botao { margin-bottom: 1px; }
.linha-edicao > .acoes { justify-content: flex-end; flex-wrap: nowrap; }

.grade-placas { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: .6rem; }
.placa-qtd { display: grid; grid-template-columns: 1fr 96px; grid-template-rows: auto auto; column-gap: .75rem; align-items: center; border: 1px solid var(--borda); border-radius: 8px; padding: .55rem .7rem; background: #fff; cursor: text; }
.placa-qtd .nome { font-weight: 600; font-size: .92rem; grid-column: 1; grid-row: 1; }
.placa-qtd .preco { color: var(--sutil); font-size: .8rem; grid-column: 1; grid-row: 2; }
.placa-qtd input { grid-column: 2; grid-row: 1 / span 2; text-align: center; font-weight: 700; }
.placa-qtd.preenchida { border-color: var(--azul); background: #fbfcff; }
.previa { display: flex; gap: 1.5rem; flex-wrap: wrap; background: var(--azul-claro); border-radius: 8px; padding: .7rem 1rem; margin: .8rem 0 .3rem; }
.previa strong { font-variant-numeric: tabular-nums; font-size: 1.1rem; margin-left: .3rem; }

/* Listas e dados */
.dados { display: grid; grid-template-columns: max-content 1fr; gap: .45rem 1rem; margin: 0; }
.dados dt { color: var(--sutil); font-size: .88rem; }
.dados dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.dados.valores { grid-template-columns: 1fr auto; }
.lista-simples { list-style: none; margin: 0; padding: 0; }
.lista-simples li { display: flex; justify-content: space-between; align-items: center; gap: .75rem; padding: .55rem 0; border-bottom: 1px solid var(--borda); }
.lista-simples li:last-child { border-bottom: 0; }
.linha-tempo { list-style: none; margin: 0; padding: 0 0 0 1rem; border-left: 2px solid var(--borda); }
.linha-tempo li { position: relative; padding: 0 0 .9rem .4rem; }
.linha-tempo li::before { content: ""; position: absolute; left: -1.43rem; top: .45rem; width: 10px; height: 10px; border-radius: 50%; background: var(--azul); }
.linha-tempo small { display: block; color: var(--sutil); }

/* Celular */
@media (max-width: 860px) {
  .lateral { position: fixed; left: 0; top: 0; z-index: 30; transform: translateX(-100%); transition: transform .2s; visibility: hidden; }
  body.menu-aberto .lateral { transform: translateX(0); visibility: visible; box-shadow: 0 0 40px rgba(0,0,0,.25); }
  .conteudo { padding: 1rem 16px 90px; }
  .inferior { display: flex; position: fixed; bottom: 0; left: 0; right: 0; z-index: 20; background: #fff; border-top: 1px solid var(--borda); padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); }
  .inferior a { flex: 1; text-align: center; font-size: .78rem; font-weight: 600; color: var(--sutil); padding: .55rem .2rem; border-radius: 8px; }
  .inferior a.ativo { color: var(--azul); background: var(--azul-claro); }
  .inferior a.mais { color: #fff; background: var(--azul); margin: 0 4px; }
  .inferior a:hover { text-decoration: none; }
  .duas-colunas { grid-template-columns: 1fr; }
  .duas-colunas > .cartao { margin-bottom: 0; }
  .cartao { padding: .95rem 1rem; }
  .topo .acoes { width: 100%; }
  .topo .acoes .botao { flex: 1; }
  .linha-edicao { grid-template-columns: 1fr 1fr; }
  .linha-edicao > .acoes { justify-content: flex-start; grid-column: 1 / -1; }
  .linha-edicao .campo:first-of-type { grid-column: 1 / -1; }
  .filtros select { flex: 1 1 100%; }
  .dados { grid-template-columns: 1fr; gap: .1rem; }
  .dados dd { margin-bottom: .55rem; }
  .dados.valores { grid-template-columns: 1fr auto; gap: .35rem 1rem; }
  .dados.valores dd { margin-bottom: 0; }
  /* Tabelas viram cartões no celular */
  .tabela table, .tabela tbody, .tabela tr, .tabela td { display: block; width: 100%; }
  .tabela thead { display: none; }
  .tabela tr { border-bottom: 1px solid var(--borda); padding: .55rem 0; display: grid; grid-template-columns: 1fr auto; gap: .1rem .75rem; }
  .tabela tbody tr:last-child { border-bottom: 0; }
  .tabela td { border: 0; padding: 0; }
  .tabela td.num { text-align: right; }
  .tabela td.acoes-col { grid-column: 1 / -1; text-align: left; padding-top: .35rem; }
  code.json { max-width: 100%; }
  .tabela td[data-rotulo] { grid-column: 1 / -1; display: flex; justify-content: space-between; font-size: .88rem; }
  .tabela td[data-rotulo]::before { content: attr(data-rotulo); color: var(--sutil); }
}
