:root {
  --fundo: #f4f5f7; --painel: #fff; --texto: #1d2330; --suave: #5d6677; --linha: #e2e5ea;
  --marca: #0b5cad; --marca-claro: #e7f0fa; --ok: #1d7a46; --ok-claro: #e6f4ec; --alerta: #a35d00;
  --alerta-claro: #fff4e0; --erro: #b3261e; --erro-claro: #fdecea; --lateral: #16263b; --lateral-texto: #c9d3e0;
  --raio: 6px; --sombra: 0 1px 2px rgba(16, 24, 40, .06);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { font-size: 15px; }
body { margin: 0; font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--fundo);
  color: var(--texto); line-height: 1.45; }
a { color: var(--marca); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.45rem; margin: 0 0 .25rem; }
h2 { font-size: 1.15rem; margin: 1.5rem 0 .6rem; }
h3 { font-size: 1rem; margin: 1.2rem 0 .5rem; }
p { margin: .4rem 0 .8rem; }
small, .sub { color: var(--suave); }
code, .cod { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: .92em; }

/* estrutura */
.app { display: grid; grid-template-columns: 228px 1fr; min-height: 100vh; }
.lateral { background: var(--lateral); color: var(--lateral-texto); padding: 1rem .75rem; position: sticky; top: 0;
  height: 100vh; overflow-y: auto; }
.lateral .marca { color: #fff; font-weight: 700; font-size: 1.05rem; display: block; margin: 0 .5rem 1rem; }
.lateral .grupo { text-transform: uppercase; font-size: .72rem; letter-spacing: .06em; color: #7f90a8;
  margin: 1rem .5rem .3rem; }
.lateral a { display: block; color: var(--lateral-texto); padding: .32rem .5rem; border-radius: 4px; }
.lateral a:hover { background: rgba(255,255,255,.07); text-decoration: none; }
.lateral a.ativo { background: rgba(255,255,255,.14); color: #fff; }
.lateral .usuario { margin: 1.5rem .5rem 0; font-size: .85rem; color: #9fb0c6; }
.lateral form { display: inline; }
.lateral button.link { background: none; border: 0; color: #c9d3e0; padding: 0; cursor: pointer; font: inherit;
  text-decoration: underline; }
.conteudo { padding: 1.4rem 1.8rem 3rem; min-width: 0; }
.topo { display: flex; flex-wrap: wrap; gap: .75rem; align-items: flex-end; justify-content: space-between;
  margin-bottom: 1rem; }
.topo .acoes { display: flex; gap: .5rem; flex-wrap: wrap; }
.menu-movel { display: none; }

@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .lateral { position: static; height: auto; display: none; }
  .lateral.aberta { display: block; }
  .menu-movel { display: flex; align-items: center; justify-content: space-between; background: var(--lateral);
    color: #fff; padding: .6rem 1rem; }
  .menu-movel button { background: none; border: 1px solid #fff5; color: #fff; border-radius: 4px; padding: .3rem .6rem; }
  .conteudo { padding: 1rem; }
}

/* blocos */
.card { background: var(--painel); border: 1px solid var(--linha); border-radius: var(--raio); padding: 1rem 1.1rem;
  box-shadow: var(--sombra); margin-bottom: 1rem; }
.card > h2:first-child, .card > h3:first-child { margin-top: 0; }
.grade { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }
.grade-2 { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); }
.numero { font-size: 1.6rem; font-weight: 650; }
.kpi small { display: block; }
dl.dados { display: grid; grid-template-columns: max-content 1fr; gap: .3rem 1rem; margin: 0; }
dl.dados dt { color: var(--suave); }
dl.dados dd { margin: 0; }

/* tabelas */
.tabela-wrap { overflow-x: auto; background: var(--painel); border: 1px solid var(--linha); border-radius: var(--raio); }
table { border-collapse: collapse; width: 100%; }
th, td { padding: .42rem .6rem; text-align: left; border-bottom: 1px solid var(--linha); vertical-align: top; }
th { font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; color: var(--suave); background: #fafbfc;
  position: sticky; top: 0; white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
td.n, th.n { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
tr.secao td { background: #f0f3f7; font-weight: 600; }
tr.bloqueado td { background: var(--erro-claro); }
tr.oculta td { color: var(--suave); }
tr.total td { font-weight: 650; background: #fafbfc; }
td .desc { max-width: 520px; }
.mini { width: 44px; height: 44px; object-fit: contain; background: #fff; border: 1px solid var(--linha); border-radius: 4px; }
.sem-foto { width: 44px; height: 44px; display: inline-flex; align-items: center; justify-content: center;
  font-size: .65rem; color: var(--suave); border: 1px dashed var(--linha); border-radius: 4px; }
.foto-grande { max-width: 100%; max-height: 320px; object-fit: contain; background: #fff; border: 1px solid var(--linha);
  border-radius: var(--raio); }

/* etiquetas e mensagens */
.tag { display: inline-block; font-size: .74rem; padding: .05rem .45rem; border-radius: 999px; background: #eef1f5;
  color: var(--suave); white-space: nowrap; }
.tag.ok { background: var(--ok-claro); color: var(--ok); }
.tag.alerta { background: var(--alerta-claro); color: var(--alerta); }
.tag.erro { background: var(--erro-claro); color: var(--erro); }
.tag.info { background: var(--marca-claro); color: var(--marca); }
.pos { color: var(--erro); }
.neg { color: var(--ok); }
.mensagens { list-style: none; padding: 0; margin: 0 0 1rem; }
.mensagens li { padding: .6rem .8rem; border-radius: var(--raio); margin-bottom: .4rem; border: 1px solid; }
.mensagens .success { background: var(--ok-claro); border-color: #b5dec6; color: #145233; }
.mensagens .error { background: var(--erro-claro); border-color: #f1b9b4; color: #7d1a14; }
.mensagens .warning, .mensagens .info { background: var(--alerta-claro); border-color: #f2d39b; color: #6b3d00; }
.aviso { background: var(--alerta-claro); border: 1px solid #f2d39b; border-radius: var(--raio); padding: .6rem .8rem;
  margin: .5rem 0 1rem; }
.erro-box { background: var(--erro-claro); border: 1px solid #f1b9b4; border-radius: var(--raio); padding: .6rem .8rem;
  margin: .5rem 0 1rem; }
ul.lista-simples { margin: .3rem 0; padding-left: 1.2rem; }

/* formulários */
form.linha, .filtros { display: flex; flex-wrap: wrap; gap: .5rem; align-items: flex-end; margin-bottom: 1rem; }
form.linha > *, .filtros > * { min-width: 0; max-width: 100%; }
form.linha select, .filtros select { max-width: min(100%, 420px); }
label { display: block; font-size: .85rem; color: var(--suave); margin-bottom: .15rem; }
input, select, textarea { font: inherit; padding: .38rem .55rem; border: 1px solid #c8ced8; border-radius: 5px;
  background: #fff; color: var(--texto); max-width: 100%; }
input[type=checkbox] { width: auto; }
textarea { width: 100%; min-height: 80px; }
.campo { margin-bottom: .75rem; }
.campo .ajuda { font-size: .8rem; color: var(--suave); margin-top: .15rem; }
.campo .errorlist { color: var(--erro); margin: .2rem 0 0; padding-left: 1rem; font-size: .85rem; }
.form-grade { display: grid; gap: 0 1rem; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.btn { display: inline-block; font: inherit; padding: .4rem .85rem; border-radius: 5px; border: 1px solid #c8ced8;
  background: #fff; color: var(--texto); cursor: pointer; white-space: nowrap; }
.btn:hover { background: #f3f5f8; text-decoration: none; }
.btn.primario { background: var(--marca); border-color: var(--marca); color: #fff; }
.btn.primario:hover { background: #094c90; }
.btn.perigo { color: var(--erro); border-color: #e7b3ae; }
.btn.pequeno { padding: .18rem .5rem; font-size: .85rem; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.inline { display: inline; }

/* memória de cálculo */
.passos td:first-child { width: 60%; }
.passos tr.forte td { font-weight: 650; background: var(--marca-claro); }
.passos tr.alerta td { background: var(--alerta-claro); }

.paginacao { display: flex; gap: .5rem; align-items: center; margin: .8rem 0; }

/* painel lateral (resumo de uma peça do kit, como a gaveta do protótipo) */
#painel[hidden] { display: none; }
.painel-fundo { position: fixed; inset: 0; background: rgba(16, 24, 40, .35); z-index: 50; }
.painel { position: fixed; top: 0; right: 0; bottom: 0; width: min(1200px, 85vw); z-index: 51; background: var(--fundo);
  box-shadow: -10px 0 30px rgba(16, 24, 40, .2); display: flex; flex-direction: column; animation: painel-entra .16s ease-out; }
@keyframes painel-entra { from { transform: translateX(40px); opacity: .4; } to { transform: none; opacity: 1; } }
@media (max-width: 900px) { .painel { width: 100vw; } }
.painel-barra { display: flex; gap: .5rem; align-items: center; padding: .6rem 1rem; background: var(--painel);
  border-bottom: 1px solid var(--linha); }
.painel-barra .espaco { flex: 1; }
.painel-corpo { flex: 1; overflow-y: auto; padding: 1rem 1.1rem 2rem; }
.painel-cab h2 { margin: 0 0 .2rem; }
.painel-foto { text-align: center; margin-bottom: 1rem; }
.painel-foto .foto-grande { max-height: 260px; }
.painel-rodape { margin-top: 1.2rem; display: flex; gap: .5rem; flex-wrap: wrap; }
body.com-painel { overflow: hidden; }
a[data-painel] .mini { cursor: zoom-in; }
tr[data-painel] { cursor: pointer; }
tr[data-painel]:hover td { background: #f3f6fa; }
tr.bloqueado[data-painel]:hover td { background: #fbdcd9; }

/* seletor de produtos dos pedidos: fica abaixo do painel lateral, que abre o resumo de um produto por cima */
#seletor[hidden] { display: none; }
body.com-seletor { overflow: hidden; }
.seletor-fundo { position: fixed; inset: 0; background: rgba(16, 24, 40, .45); z-index: 45; }
.seletor { position: fixed; inset: 3vh 3vw; z-index: 46; background: var(--fundo); border-radius: var(--raio); overflow: hidden;
  box-shadow: 0 12px 40px rgba(16, 24, 40, .3); display: flex; flex-direction: column; }
.seletor-corpo { flex: 1; min-height: 0; display: flex; }
.seletor-busca { flex: 1; min-width: 0; display: flex; flex-direction: column; padding: .8rem 1rem 0; }
.seletor-busca .filtros { margin-bottom: .5rem; }
.seletor-q { flex: 1; min-width: 200px; }
.seletor-q input { width: 100%; }
.seletor-busca select { max-width: 220px; }
.seletor-nota { margin: 0 0 .4rem; }
.seletor-lista { flex: 1; min-height: 0; overflow-y: auto; padding-bottom: 1rem; }
.seletor-total { margin: 0 0 .4rem; color: var(--suave); }
.seletor-item { display: flex; align-items: center; gap: .8rem; padding: .55rem .8rem; margin: 0 0 .4rem; background: var(--painel);
  border: 1px solid var(--linha); border-radius: var(--raio); cursor: pointer; font-weight: normal; }
.seletor-item:hover { border-color: var(--marca); }
.seletor-item:has(input:checked) { border-color: var(--marca); background: var(--marca-claro); }
.seletor-item.bloqueado { cursor: not-allowed; opacity: .7; }
.seletor-item > input { width: 1.2rem; height: 1.2rem; flex: none; }
.seletor-foto { flex: none; display: flex; }
.seletor-foto .mini, .seletor-foto .sem-foto { width: 72px; height: 72px; }
.seletor-texto { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: .1rem; color: var(--texto); }
.seletor-texto small, .seletor-info small { color: var(--suave); }
.seletor-nome { overflow-wrap: anywhere; }
.seletor-info { flex: none; width: 170px; display: flex; flex-direction: column; align-items: flex-end; gap: .15rem; text-align: right; color: var(--texto); }
.seletor-mais { display: block; margin: .6rem auto 0; }
.seletor-escolhidos { flex: none; width: 360px; display: flex; flex-direction: column; gap: .6rem; margin: 0; padding: .8rem 1rem;
  background: var(--painel); border-left: 1px solid var(--linha); }
.seletor-escolhidos h3 { margin: 0; }
.seletor-tray { flex: 1; min-height: 0; overflow-y: auto; }
.seletor-escolhido { display: flex; align-items: center; gap: .5rem; padding: .35rem 0; border-bottom: 1px solid var(--linha); }
.seletor-escolhido .mini, .seletor-escolhido .sem-foto { width: 40px; height: 40px; font-size: .6rem; }
.seletor-escolhido > div { flex: 1; min-width: 0; line-height: 1.25; }
.seletor-escolhido > div small { display: block; color: var(--suave); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.seletor-escolhido input[type=text] { width: 4.2rem; text-align: right; }
.seletor-escolhido input.invalido { border-color: var(--erro); background: var(--erro-claro); }
.seletor-campos { display: flex; flex-wrap: wrap; gap: .5rem; }
.seletor-campos > div { flex: 1; min-width: 130px; }
.seletor-campos input, .seletor-campos select { width: 100%; }
.seletor-escolhidos .erro-box { max-height: 8rem; overflow-y: auto; margin: 0; }
.seletor-escolhidos [data-seletor-enviar] { width: 100%; }
@media (max-width: 900px) {
  .seletor { inset: 0; border-radius: 0; }
  .seletor-corpo { flex-direction: column; }
  .seletor-busca { padding: .5rem .7rem 0; min-height: 0; }
  .seletor-busca .filtros { gap: .35rem; }
  .seletor-q { flex-basis: 100%; }
  .seletor-busca .filtros > div:not(.seletor-q) { flex: 1 1 40%; min-width: 0; }
  .seletor-busca select { max-width: 100%; width: 100%; }
  .seletor-item { gap: .5rem; padding: .45rem .5rem; flex-wrap: wrap; }
  .seletor-foto .mini, .seletor-foto .sem-foto { width: 52px; height: 52px; }
  .seletor-texto { flex-basis: calc(100% - 5rem); }
  .seletor-info { width: 100%; flex-direction: row; justify-content: flex-end; align-items: baseline; gap: .6rem; }
  .seletor-escolhidos { width: auto; max-height: 42vh; gap: .35rem; border-left: 0; border-top: 1px solid var(--linha); padding: .5rem .7rem; }
  .seletor-tray { flex: 0 1 auto; min-height: 2.5rem; }
}
@media print {
  .lateral, .menu-movel, .nao-imprimir, .topo .acoes, form.filtros { display: none !important; }
  .app { display: block; }
  .conteudo { padding: 0; }
  body { background: #fff; font-size: 12px; }
  .card, .tabela-wrap { border: 0; box-shadow: none; }
  th { position: static; }
  tr { page-break-inside: avoid; }
}
