:root {
  --azul: #1e5a9c;
  --azul-esc: #16406e;
  --laranja: #f28c1e;
  --verde: #2e9c5a;
  --vermelho: #d64545;
  --amarelo: #e0a800;
  --cinza-bg: #f2f4f7;
  --cinza-borda: #d9dee6;
  --cinza-txt: #5a6472;
  --branco: #ffffff;
  --texto: #1f2733;
  --sombra: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.04);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  background: var(--cinza-bg);
  color: var(--texto);
  line-height: 1.45;
  padding-bottom: 20px;
}

/* ---------- Cabeçalho (barra de título + menu, gruda no topo) ---------- */
.cabecalho { position: sticky; top: 0; z-index: 50; box-shadow: var(--sombra); }

.topbar {
  background: var(--azul);
  color: #fff;
  display: flex;
  align-items: center;
  gap: 12px;
  /* alinha o conteúdo com a coluna da página (fundo continua inteiro) */
  padding: 10px max(16px, calc((100% - 1000px) / 2 + 14px));
}
.logo { display: flex; align-items: center; text-decoration: none; flex-shrink: 0; }
.logo-img { height: 32px; width: auto; display: block; }

/* nome do sistema em destaque, separado do menu */
.titulo-app {
  font-size: 1.2rem; font-weight: 600; color: #fff; letter-spacing: .3px;
  padding-left: 12px; border-left: 1px solid rgba(255,255,255,.35);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.titulo-app b { font-weight: 800; }
.titulo-sep { color: rgba(255,255,255,.5); font-weight: 400; margin: 0 3px; }

/* usuário logado / sair */
.usuario-box { display: flex; align-items: center; gap: 10px; margin-left: auto; flex-shrink: 0; }
.usuario-nome { color: #eaf2fb; font-size: .88rem; font-weight: 600; white-space: nowrap; }
.btn-sair {
  color: #fff; text-decoration: none; font-size: .82rem; font-weight: 700;
  border: 1px solid rgba(255,255,255,.45); border-radius: 6px; padding: 5px 12px;
  transition: background .15s; white-space: nowrap;
}
.btn-sair:hover { background: rgba(255,255,255,.18); }

/* menu principal: barra que rola na horizontal (nunca quebra em telas menores) */
.menu-principal {
  background: var(--azul-esc);
  display: flex; align-items: stretch; gap: 2px;
  overflow-x: auto; overflow-y: hidden;
  padding: 0 max(2px, calc((100% - 1000px) / 2));
  scrollbar-width: thin; scrollbar-color: rgba(255,255,255,.3) transparent;
  -webkit-overflow-scrolling: touch;
}

/* páginas largas (ex.: Painel) alinham o cabeçalho com a coluna larga */
.cabecalho.wide .topbar { padding-left: max(16px, calc((100% - 1320px) / 2 + 14px));
                          padding-right: max(16px, calc((100% - 1320px) / 2 + 14px)); }
.cabecalho.wide .menu-principal { padding-left: max(2px, calc((100% - 1320px) / 2));
                                  padding-right: max(2px, calc((100% - 1320px) / 2)); }
.menu-principal::-webkit-scrollbar { height: 5px; }
.menu-principal::-webkit-scrollbar-thumb { background: rgba(255,255,255,.3); border-radius: 3px; }
.menu-principal a {
  color: #d3e2f3; text-decoration: none; padding: 11px 14px;
  font-size: .92rem; font-weight: 600; white-space: nowrap;
  border-bottom: 3px solid transparent; transition: background .15s, color .15s;
}
.menu-principal a:hover { background: rgba(255,255,255,.1); color: #fff; }

/* item com submenu (dropdown), ex.: Materiais */
.menu-drop { display: flex; }
.menu-drop-btn {
  background: none; border: none; cursor: pointer; font: inherit;
  color: #d3e2f3; padding: 11px 14px; font-size: .92rem; font-weight: 600;
  white-space: nowrap; border-bottom: 3px solid transparent; transition: background .15s, color .15s;
}
.menu-drop-btn:hover, .menu-drop.aberto .menu-drop-btn { background: rgba(255,255,255,.12); color: #fff; }
.menu-drop-panel {
  position: fixed; display: none; min-width: 190px; z-index: 60;
  background: #fff; border: 1px solid var(--cinza-borda); border-radius: 10px;
  box-shadow: 0 10px 28px rgba(0,0,0,.2); padding: 6px;
}
.menu-drop.aberto .menu-drop-panel { display: block; }
.menu-drop-panel a {
  display: block; padding: 10px 12px; border-radius: 7px; color: var(--texto);
  text-decoration: none; font-size: .93rem; font-weight: 600; white-space: nowrap; border: none;
}
.menu-drop-panel a:hover { background: var(--cinza-bg); color: var(--azul); }

/* esconde a barra de rolagem no celular mas mantém o gesto de arrastar */
@media (max-width: 640px) {
  .titulo-app { font-size: 1.05rem; padding-left: 10px; }
  .usuario-nome { display: none; }
  .menu-principal::-webkit-scrollbar { height: 0; }
}

/* ---------- Conteúdo ---------- */
.conteudo { max-width: 1000px; margin: 0 auto; padding: 18px 14px 20px; }
.conteudo-wide { max-width: 1320px; }   /* painel usa a tela toda */

.pagina-titulo {
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 10px; margin-bottom: 16px;
}
.pagina-titulo h1 { font-size: 1.4rem; color: var(--azul-esc); }
.subtitulo { color: var(--cinza-txt); font-size: .9rem; }

/* ---------- Cards ---------- */
.card {
  background: var(--branco); border-radius: 12px; padding: 16px;
  box-shadow: var(--sombra); margin-bottom: 16px; border: 1px solid var(--cinza-borda);
}
.card h2 { font-size: 1.05rem; margin-bottom: 12px; color: var(--azul-esc); }

/* ---------- Dashboard stats ---------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(158px, 1fr));
         gap: 12px; margin-bottom: 18px; }
/* duas colunas lado a lado (empilha no celular) */
.grid-2 { display: grid; grid-template-columns: 1fr; gap: 16px; }
@media (min-width: 780px) { .grid-2 { grid-template-columns: 1fr 1fr; } }
.grid-2 > .card { margin-bottom: 0; }
.stat {
  background: var(--branco); border-radius: 12px; padding: 16px;
  box-shadow: var(--sombra); border-left: 4px solid var(--azul);
}
.stat .valor { font-size: 1.6rem; font-weight: 700; color: var(--azul-esc); }
.stat .rotulo { color: var(--cinza-txt); font-size: .82rem; margin-top: 2px; }
.stat.laranja { border-left-color: var(--laranja); }
.stat.laranja .valor { color: var(--laranja); }
.stat.verde { border-left-color: var(--verde); }
.stat.verde .valor { color: var(--verde); }
.stat.vermelho { border-left-color: var(--vermelho); }

/* ---------- Botões ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 6px; justify-content: center;
  background: var(--azul); color: #fff; border: none; border-radius: 8px;
  padding: 10px 16px; font-size: .95rem; font-weight: 600; cursor: pointer;
  text-decoration: none; transition: background .15s;
}
.btn:hover { background: var(--azul-esc); }
.btn-laranja { background: var(--laranja); }
.btn-laranja:hover { background: #d97b0e; }
.btn-verde { background: var(--verde); }
.btn-verde:hover { background: #26804a; }
.btn-cinza { background: #6b7684; }
.btn-cinza:hover { background: #55606d; }
.btn-perigo { background: var(--vermelho); }
.btn-perigo:hover { background: #b83636; }
.btn-sm { padding: 6px 10px; font-size: .82rem; }
.btn-bloco { width: 100%; }

/* ---------- Formulários ---------- */
.form-grid { display: grid; grid-template-columns: 1fr; gap: 12px; }
@media (min-width: 640px) { .form-grid.col2 { grid-template-columns: 1fr 1fr; } }
.campo { display: flex; flex-direction: column; gap: 4px; }
.campo label { font-size: .85rem; font-weight: 600; color: var(--cinza-txt); }
.campo input, .campo select, .campo textarea {
  padding: 11px 12px; border: 1px solid var(--cinza-borda); border-radius: 8px;
  font-size: 1rem; font-family: inherit; background: #fff; color: var(--texto);
}
.campo input:focus, .campo select:focus, .campo textarea:focus {
  outline: none; border-color: var(--azul); box-shadow: 0 0 0 3px rgba(30,90,156,.12);
}
.campo textarea { resize: vertical; min-height: 60px; }
.form-acoes { margin-top: 14px; display: flex; gap: 10px; flex-wrap: wrap; }

/* ---------- Tabelas ---------- */
.tabela-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; font-size: .92rem; }
th, td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--cinza-borda); }
th { background: #f7f9fc; color: var(--cinza-txt); font-weight: 600; font-size: .82rem;
     text-transform: uppercase; letter-spacing: .3px; white-space: nowrap; }
tbody tr:hover { background: #f9fbfd; }
td.num, th.num { text-align: right; white-space: nowrap; }
td a { color: var(--azul); text-decoration: none; font-weight: 600; }
td a:hover { text-decoration: underline; }

/* ---------- Badges ---------- */
.badge {
  display: inline-block; padding: 3px 10px; border-radius: 20px;
  font-size: .75rem; font-weight: 700;
}
.badge-verde { background: #e2f5ea; color: #1e7a44; }
.badge-amarelo { background: #fdf3d7; color: #9a7400; }
.badge-cinza { background: #eceff3; color: #5a6472; }
.badge-vermelho { background: #fbe4e4; color: #b02a2a; }
.badge-azul { background: #e2edf9; color: var(--azul); }
.badge-laranja { background: #fdecd7; color: #b56b0e; }

/* ---------- Flash ---------- */
.flash { padding: 12px 16px; border-radius: 8px; margin-bottom: 14px; font-weight: 500; }
.flash-ok { background: #e2f5ea; color: #1e7a44; border: 1px solid #b6e3c8; }
.flash-erro { background: #fbe4e4; color: #b02a2a; border: 1px solid #f0bcbc; }
.flash-aviso { background: #fdf3d7; color: #8a6800; border: 1px solid #f0dca0; }

/* ---------- Itens dinâmicos (compra/envio) ---------- */
.linha-item {
  display: grid; gap: 8px; align-items: end; margin-bottom: 10px;
  padding-bottom: 10px; border-bottom: 1px dashed var(--cinza-borda);
}
.linha-item .campo { gap: 3px; }
.remover-linha {
  background: var(--vermelho); color: #fff; border: none; border-radius: 8px;
  padding: 10px; cursor: pointer; font-weight: 700; height: 44px;
}

.vazio { text-align: center; color: var(--cinza-txt); padding: 30px 10px; }
.vazio .icone { font-size: 2.5rem; display: block; margin-bottom: 8px; }
.total-linha { text-align: right; font-size: 1.2rem; font-weight: 700; color: var(--azul-esc); margin-top: 10px; }
.info-linha { display: flex; flex-wrap: wrap; gap: 6px 18px; color: var(--cinza-txt); font-size: .9rem; margin-bottom: 4px; }
.info-linha b { color: var(--texto); }

/* ---------- Cabeçalho de impressão (dados da empresa) ---------- */
.print-cabecalho {
  display: flex; align-items: center; gap: 16px; padding: 14px 16px; margin-bottom: 16px;
  background: #fff; border: 1px solid var(--cinza-borda); border-radius: 12px;
}
.print-cabecalho img { height: 56px; width: auto; max-width: 180px; object-fit: contain; }
.print-empresa { font-size: 1.15rem; font-weight: 700; color: var(--azul-esc); }
.print-info { font-size: .84rem; color: var(--cinza-txt); line-height: 1.4; }

/* ---------- Impressão ---------- */
@media print {
  .cabecalho, .btn, .btn-sair, .form-acoes, .pagina-titulo a,
  details, .no-print { display: none !important; }
  body { padding: 0 !important; background: #fff; }
  .conteudo { max-width: 100%; padding: 0; }
  .card { box-shadow: none; border: 1px solid #ccc; break-inside: avoid; }
  .print-cabecalho { border: none; border-bottom: 2px solid var(--azul); border-radius: 0; }
  a { color: #000 !important; text-decoration: none; }
  .barra > span { animation: none !important; }
}

/* ---------- Barras de progresso / cards de etapa ---------- */
.barra { background: #eceff3; border-radius: 999px; height: 10px; overflow: hidden; }
.barra > span {
  display: block; height: 100%; border-radius: 999px;
  transform-origin: left center; animation: barraGrow .9s cubic-bezier(.34, 1, .5, 1);
}
@keyframes barraGrow { from { transform: scaleX(0); } to { transform: scaleX(1); } }
@media (prefers-reduced-motion: reduce) { .barra > span { animation: none; } }
.barra-lg { height: 16px; }
.etapas-grid { display: grid; gap: 12px; grid-template-columns: 1fr; }
@media (min-width: 700px) { .etapas-grid { grid-template-columns: 1fr 1fr; } }
.etapa-card { border: 1px solid var(--cinza-borda); border-radius: 12px; padding: 14px; background: #fff; }
.rotulo-mini { font-size: .72rem; color: var(--cinza-txt); text-transform: uppercase;
               letter-spacing: .3px; font-weight: 600; margin-bottom: 1px; }

/* ---------- Galeria de fotos de recebimento ---------- */
.galeria { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; }
.foto-item { position: relative; }
.foto-item img {
  width: 100%; height: 120px; object-fit: cover; border-radius: 10px;
  border: 1px solid var(--cinza-borda); display: block;
}
.foto-remover {
  position: absolute; top: 6px; right: 6px; width: 26px; height: 26px;
  border: none; border-radius: 50%; background: rgba(0,0,0,.6); color: #fff;
  font-weight: 700; cursor: pointer; line-height: 1;
}
.foto-remover:hover { background: var(--vermelho); }

/* ---------- Login / Setup ---------- */
.auth-body {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  padding: 24px 16px;
  background: linear-gradient(135deg, #16406e 0%, #1e5a9c 55%, #2b7fd0 100%);
}
.auth-card {
  background: #fff; width: 100%; max-width: 400px; border-radius: 16px;
  padding: 30px 26px; box-shadow: 0 12px 40px rgba(0,0,0,.28);
}
.auth-logo { text-align: center; margin-bottom: 8px; }
.auth-logo img { max-width: 210px; width: 70%; height: auto; }
.auth-titulo { text-align: center; color: var(--azul-esc); font-size: 1.15rem;
               font-weight: 700; margin-bottom: 4px; }
.auth-sub { text-align: center; color: var(--cinza-txt); font-size: .88rem; margin-bottom: 20px; }
.auth-card .campo { margin-bottom: 14px; }
.auth-card .btn { width: 100%; padding: 12px; font-size: 1rem; margin-top: 4px; }
.auth-rodape { text-align: center; color: var(--cinza-txt); font-size: .78rem; margin-top: 18px; }
.auth-flash { padding: 11px 14px; border-radius: 8px; margin-bottom: 16px; font-size: .9rem; font-weight: 500; }
.auth-flash.erro { background: #fbe4e4; color: #b02a2a; border: 1px solid #f0bcbc; }
.auth-flash.ok { background: #e2f5ea; color: #1e7a44; border: 1px solid #b6e3c8; }
