/* ============================================================
   Tokens
   ============================================================ */
:root {
  --bg: #F4F5F3;
  --panel: #FFFFFF;
  --ink: #1E2422;
  --ink-soft: #5B655F;
  --line: #DADFDC;
  --meat: #A8402B;
  --meat-deep: #8A331F;
  --steel: #375061;
  --success: #4C7A57;
  --warn: #C98A2C;

  --display: "Barlow Condensed", sans-serif;
  --body: "Inter", sans-serif;
  --mono: "IBM Plex Mono", monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--body);
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}
button, input, select { font-family: var(--body); }
.hidden { display: none !important; }

/* ============================================================
   Layout shell
   ============================================================ */
.app { min-height: 100vh; padding-bottom: 88px; }
.screen { padding: 20px 18px 24px; max-width: 520px; margin: 0 auto; }

.bottom-nav {
  position: fixed; left: 0; right: 0; bottom: 0;
  display: flex; background: var(--panel);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
  z-index: 20;
}
.nav-btn {
  flex: 1; border: none; background: none; padding: 12px 4px 10px;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  color: var(--ink-soft); font-size: 13px; font-weight: 600;
}
.nav-icon { font-size: 20px; line-height: 1; }
.nav-btn.active { color: var(--meat); }
.nav-btn-exit { color: var(--steel); }

.offline-banner {
  position: fixed; top: 0; left: 0; right: 0; z-index: 30;
  background: var(--warn); color: #241a05; text-align: center;
  font-size: 13px; font-weight: 600; padding: 8px 12px;
}
.pending-badge {
  position: fixed; top: 0; left: 0; right: 0; z-index: 29;
  background: var(--steel); color: white; text-align: center;
  font-size: 12px; font-weight: 600; padding: 6px 12px;
  margin-top: 34px;
}
.offline-banner.hidden + .pending-badge { margin-top: 0; }

/* ============================================================
   Login (grade de fotos)
   ============================================================ */
.login-screen { padding-top: 48px; text-align: center; }
.brand-mark {
  font-family: var(--display); font-weight: 800; letter-spacing: 4px;
  font-size: 15px; color: var(--meat);
}
.login-title { font-family: var(--display); font-weight: 700; font-size: 30px; margin: 8px 0 28px; }
.login-grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px;
  margin-bottom: 32px;
}
.login-card {
  background: var(--panel); border: 1px solid var(--line); border-radius: 18px;
  padding: 14px 6px 12px; display: flex; flex-direction: column; align-items: center; gap: 8px;
  min-height: 128px;
}
.login-avatar {
  width: 64px; height: 64px; border-radius: 50%; background-color: var(--steel);
  background-size: cover; background-position: center;
  display: flex; align-items: center; justify-content: center;
  color: white; font-family: var(--display); font-size: 26px; font-weight: 700;
}
.login-nome { font-size: 14px; font-weight: 600; line-height: 1.2; }
.link-discreto { background: none; border: none; color: var(--ink-soft); font-size: 13px; text-decoration: underline; padding: 8px; }
.empty-msg { color: var(--ink-soft); font-size: 14px; grid-column: 1 / -1; }

/* ============================================================
   PIN
   ============================================================ */
.pin-screen { text-align: center; padding-top: 24px; }
.voltar { background: none; border: none; color: var(--steel); font-size: 15px; font-weight: 600; align-self: flex-start; margin-bottom: 12px; }
.pin-avatar {
  width: 88px; height: 88px; margin: 8px auto 12px; border-radius: 50%;
  background-color: var(--steel); background-size: cover; background-position: center;
  display: flex; align-items: center; justify-content: center;
  color: white; font-family: var(--display); font-size: 34px; font-weight: 700;
}
.pin-nome { font-family: var(--display); font-size: 26px; font-weight: 700; margin: 0 0 4px; }
.pin-label { color: var(--ink-soft); font-size: 14px; margin: 0 0 18px; }
.pin-dots { display: flex; justify-content: center; gap: 16px; margin-bottom: 12px; }
.dot { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--ink-soft); }
.dot.preenchido { background: var(--meat); border-color: var(--meat); }
.pin-erro { color: var(--meat); font-size: 13px; font-weight: 600; margin-bottom: 8px; }
.teclado {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-top: 16px;
}
.tecla {
  padding: 20px 0; border-radius: 16px; border: 1px solid var(--line); background: var(--panel);
  font-family: var(--display); font-size: 26px; font-weight: 700; color: var(--ink);
}
.tecla:active { background: var(--line); }

/* ============================================================
   Lançar
   ============================================================ */
.topo { display: flex; justify-content: flex-end; margin-bottom: 12px; }
.topo-usuario { display: flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 600; }
.mini-avatar {
  width: 32px; height: 32px; border-radius: 50%; background-color: var(--steel);
  background-size: cover; background-position: center;
  display: flex; align-items: center; justify-content: center; color: white; font-size: 13px; font-weight: 700;
}
.lote-chip {
  background: var(--ink); color: white; border: none; border-radius: 14px; padding: 14px 16px;
  display: flex; flex-direction: column; gap: 4px; margin-bottom: 18px; font-size: 14px;
  width: 100%; text-align: left;
}
.lote-chip-topo { display: flex; justify-content: space-between; align-items: center; }
.lote-chip-trocar-label {
  font-size: 12px; font-weight: 700; color: #B6C4BE; border: 1px solid #4C5A55;
  border-radius: 20px; padding: 4px 10px;
}
.lote-chip-detalhes {
  display: flex; flex-direction: column; gap: 2px; margin-top: 6px; padding-top: 8px;
  border-top: 1px solid rgba(255,255,255,0.12); font-size: 12px; color: #B6C4BE;
}
.lote-tipo { font-family: var(--display); font-size: 20px; font-weight: 700; color: #F5C9BC; letter-spacing: 1px; }
.aviso-caixa { background: var(--panel); border: 1px dashed var(--line); border-radius: 14px; padding: 18px; text-align: center; margin-bottom: 18px; }

.acoes-lancar { display: flex; flex-direction: column; gap: 12px; }
.acoes-lancar.disabled { opacity: 0.5; }
.botao-grande {
  border: none; border-radius: 18px; padding: 22px 16px; font-family: var(--display);
  font-size: 22px; font-weight: 700; color: white; background: var(--meat);
  display: flex; align-items: center; justify-content: center; gap: 10px;
}
.botao-grande:active { background: var(--meat-deep); }
.botao-confirmar { background: var(--success); }
.botao-confirmar:active { background: #3d6347; }
.icone-grande { font-size: 26px; }
.botao-secundario {
  border: 1px solid var(--line); background: var(--panel); border-radius: 14px;
  padding: 14px; font-size: 15px; font-weight: 600; color: var(--ink);
}

.recentes-titulo { font-size: 13px; text-transform: uppercase; letter-spacing: 1px; color: var(--ink-soft); margin: 22px 0 8px; }
.recentes-lista { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.recentes-lista li {
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
  padding: 12px 14px; display: flex; justify-content: space-between; font-size: 14px;
}

/* ============================================================
   Visor de balança — elemento de assinatura
   ============================================================ */
.visor-balanca {
  background: var(--ink); border-radius: 18px; padding: 18px 20px; margin-bottom: 16px;
  font-family: var(--mono); color: #B6E5A8;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.06);
}
.visor-linha { display: flex; align-items: baseline; justify-content: space-between; }
.visor-corte { font-size: 16px; letter-spacing: 1px; color: #E9EFEA; margin-bottom: 10px; text-transform: uppercase; }
.visor-peso { font-size: 36px; font-weight: 600; }
.visor-peso input {
  background: none; border: none; color: #B6E5A8; font-family: var(--mono);
  font-size: 36px; font-weight: 600; width: 60%; outline: none;
}
.visor-unidade { font-size: 16px; color: #7FA972; }
.confirmar-linha { display: flex; flex-direction: column; gap: 10px; }

.scanner-screen { text-align: center; }
.video-scanner { width: 100%; border-radius: 16px; background: black; aspect-ratio: 3/4; object-fit: cover; }
.scanner-dica { color: var(--ink-soft); font-size: 14px; margin-top: 12px; }
.select-grande {
  width: 100%; padding: 16px; border-radius: 14px; border: 1px solid var(--line);
  font-size: 16px; margin-bottom: 16px; background: var(--panel);
}

/* ============================================================
   Peça / Lote
   ============================================================ */
.titulo-tela { font-family: var(--display); font-size: 24px; font-weight: 700; margin-bottom: 16px; }
.lote-lista { display: flex; flex-direction: column; gap: 10px; }
.lote-item {
  text-align: left; background: var(--panel); border: 1px solid var(--line); border-radius: 14px;
  padding: 14px 16px; display: flex; flex-direction: column; gap: 2px; font-size: 14px;
}
.lote-item.selecionado { border-color: var(--meat); box-shadow: 0 0 0 1px var(--meat); }
.recebimento-grupo { margin-bottom: 18px; }
.recebimento-cabecalho {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 13px; font-weight: 700; color: var(--ink-soft); text-transform: uppercase;
  letter-spacing: 0.5px; margin-bottom: 8px; padding: 0 2px;
}
.recebimento-grupo .lote-item { margin-bottom: 8px; width: 100%; }
.lote-item.completa {
  background: #EAEBE8; border-color: #C9CEC9; opacity: 0.75;
}
.lote-item.completa .lote-tipo { color: var(--ink-soft); }
.recebimento-admin-item { flex-direction: column; align-items: stretch; gap: 8px; }
.botao-add-peca {
  width: 100%; border: 2px dashed var(--meat); background: rgba(168,64,43,0.06);
  border-radius: 16px; padding: 18px; margin-bottom: 14px;
  display: flex; align-items: center; justify-content: center; gap: 10px;
  font-family: var(--display); font-size: 20px; font-weight: 700; color: var(--meat);
}
.botao-add-peca:active { background: rgba(168,64,43,0.14); }
.subgrupo-tipo { margin-bottom: 16px; }
.subgrupo-titulo {
  font-size: 13px; text-transform: uppercase; letter-spacing: 1px; color: var(--ink-soft);
  margin: 0 0 8px; font-weight: 700;
}
.numero-peca-visor {
  background: var(--ink); color: #E9EFEA; border-radius: 12px; padding: 14px 16px;
  font-family: var(--mono); font-size: 15px; margin-bottom: 4px; text-align: center;
}
.zona-concluir { margin-top: 56px; padding-top: 20px; border-top: 1px dashed var(--line); text-align: center; }
.botao-concluir-distante {
  border: none; background: none; color: var(--ink-soft); font-size: 14px;
  text-decoration: underline; padding: 14px;
}
.recebimento-admin-topo { display: flex; justify-content: space-between; font-weight: 600; }
.form-preco { flex-direction: row; margin-bottom: 0; }
.form-preco input { flex: 1; padding: 10px; font-size: 14px; }
.form-preco button { padding: 10px 14px; font-size: 13px; }

/* ============================================================
   Painel
   ============================================================ */
.cards-resumo { display: flex; gap: 10px; margin-bottom: 20px; }
.card-resumo {
  flex: 1; background: var(--panel); border: 1px solid var(--line); border-radius: 14px;
  padding: 14px 10px; display: flex; flex-direction: column; gap: 4px; text-align: center;
}
.card-resumo span { font-size: 11px; color: var(--ink-soft); text-transform: uppercase; letter-spacing: 0.5px; }
.card-resumo strong { font-family: var(--display); font-size: 20px; }
.card-resumo.destaque { background: var(--ink); color: white; border: none; }
.card-resumo.destaque span { color: #B6C4BE; }

/* ============================================================
   Admin
   ============================================================ */
.admin-topo { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.admin-abas { display: flex; gap: 8px; margin-bottom: 16px; }
.aba {
  flex: 1; padding: 10px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--panel); font-size: 13px; font-weight: 600; color: var(--ink-soft);
}
.aba.ativa { background: var(--meat); color: white; border-color: var(--meat); }
.admin-form { display: flex; flex-direction: column; gap: 10px; margin-bottom: 20px; }
.admin-form input, .admin-form select {
  padding: 14px; border-radius: 12px; border: 1px solid var(--line); font-size: 15px;
}
.admin-lista { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.admin-lista li {
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
  padding: 12px 14px; display: flex; justify-content: space-between; align-items: center; font-size: 14px;
}

/* ============================================================
   Toast
   ============================================================ */
.toast {
  position: fixed; left: 50%; bottom: 100px; transform: translate(-50%, 12px);
  background: var(--ink); color: white; padding: 12px 20px; border-radius: 12px;
  font-size: 14px; opacity: 0; transition: all 0.25s ease; z-index: 50; white-space: nowrap;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (prefers-reduced-motion: reduce) {
  .toast { transition: none; }
}
