/* Tema M2TEC — claro, painéis brancos, header navy, azul de destaque (#2563eb).
   Paleta oficial: navy #252A42, accent #2563eb/#1d4ed8. */
:root {
  --navy: #252a42;
  --navy-600: #343c5f;
  --surface: #f4f5f9;
  --panel: #ffffff;
  --panel-2: #eef0f7;
  --line: #e0e3ee;
  --line-strong: #c7cbde;
  --accent: #2563eb;
  --accent-line: #1d4ed8;
  --accent-ink: #ffffff;
  --ink: #1b1f31;
  --ink-2: #4a5279;
  --ink-3: #757d9f;
  --verde: #16a34a;
  --verde-soft: #e7f6ec;
  --vermelho: #dc2626;
  --vermelho-soft: #fdeaea;
  --ambar: #b45309;
  --ambar-soft: #fdf0dc;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(37,42,66,.06), 0 4px 16px rgba(37,42,66,.06);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; background: var(--surface); color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif; }
body { max-width: 780px; margin: 0 auto; padding: 0 0 96px; min-height: 100vh; }

/* ---- Header (navy + logo oficial) ---- */
header.top {
  position: sticky; top: 0; z-index: 20; background: var(--navy); color: #fff;
  padding: 12px 16px; display: flex; align-items: center; gap: 12px;
  box-shadow: 0 2px 12px rgba(18,21,34,.28);
  padding-top: calc(12px + env(safe-area-inset-top));
}
header.top .brand { width: 34px; height: 34px; flex: none; display: block; }
header.top .logo { font-weight: 800; letter-spacing: .3px; font-size: 17px; line-height: 1.1; color: #fff; }
header.top .logo b { color: #93c5fd; font-weight: 800; }
header.top .sub { font-size: 11px; color: #aeb6d6; margin-top: 2px; }
header.top .ghost {
  background: rgba(255,255,255,.10); color: #fff; border: 1px solid rgba(255,255,255,.22);
}
header.top .ghost:active { background: rgba(255,255,255,.18); }

.wrap { padding: 16px; }
h2 { font-size: 17px; margin: 4px 0 12px; color: var(--ink); }
.muted { color: var(--ink-3); }
.small { font-size: 12px; }

/* ---- Botões ---- */
button, .btn {
  font: inherit; border: 1px solid transparent; border-radius: var(--radius); padding: 13px 18px;
  background: var(--accent); border-color: var(--accent-line); color: var(--accent-ink);
  font-weight: 700; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
}
button:active, .btn:active { transform: translateY(1px); }
button.ghost, .btn.ghost { background: var(--panel); color: var(--navy); border-color: var(--line-strong); }
button.danger { background: var(--vermelho); border-color: #b91c1c; }
button.ok { background: var(--verde); border-color: #15803d; }
button:disabled { opacity: .55; cursor: default; }
button.block { width: 100%; }

/* ---- Cards / linhas ---- */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px; margin-bottom: 12px; box-shadow: var(--shadow); }
.card.clic { cursor: pointer; transition: border-color .12s, box-shadow .12s; }
.card.clic:active { border-color: var(--accent); }
.row { display: flex; align-items: center; gap: 10px; }
.row.between { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }

/* ---- Inputs ---- */
input, select {
  font: inherit; width: 100%; padding: 13px 14px; border-radius: 12px;
  border: 1px solid var(--line-strong); background: #fff; color: var(--ink);
}
input:focus, select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(37,99,235,.15); }
input[inputmode="numeric"] { text-align: center; font-weight: 800; font-size: 20px; }
label.field { display: block; font-size: 12px; color: var(--ink-2); margin: 0 0 6px; font-weight: 600; }

#reader { border-radius: 12px; overflow: hidden; }

/* ---- Item da contagem ---- */
.item { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-top: 1px solid var(--line); }
.item:first-child { border-top: 0; }
.item .qtd { min-width: 48px; height: 48px; border-radius: 12px; background: var(--panel-2);
  color: var(--navy); display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 18px; }
.item .nome { font-weight: 600; color: var(--ink); }
.item .ean { font-size: 12px; color: var(--ink-3); font-variant-numeric: tabular-nums; }

.badge { font-size: 11px; padding: 3px 8px; border-radius: 999px; font-weight: 700; }
.badge.nf { background: var(--vermelho-soft); color: #b91c1c; }
.badge.ok { background: var(--verde-soft); color: #15803d; }

/* ---- Tags de status ---- */
.tag { font-size: 11px; padding: 4px 10px; border-radius: 999px; background: var(--panel-2); color: var(--ink-2); font-weight: 700; }
.tag.aberta { background: #e6efff; color: #1d4ed8; }
.tag.fechada { background: var(--ambar-soft); color: var(--ambar); }
.tag.aplicada { background: var(--verde-soft); color: #15803d; }

/* ---- Divergências ---- */
.divg-pos { color: #15803d; }   /* sobra */
.divg-neg { color: #b91c1c; }   /* falta */

/* ---- Destaque do código bipado ---- */
#pend { background: var(--panel-2); border: 1px dashed var(--line-strong); border-radius: 10px;
  padding: 10px 12px; color: var(--ink-2); }
#pend b { color: var(--navy); }

/* ---- Toast ---- */
.toast { position: fixed; left: 50%; bottom: 92px; transform: translateX(-50%);
  background: var(--navy); color: #fff; padding: 12px 18px; border-radius: 12px;
  box-shadow: 0 10px 28px rgba(18,21,34,.4); z-index: 50; opacity: 0; pointer-events: none;
  transition: opacity .2s, transform .2s; font-weight: 600; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(-6px); }

/* ---- Barra de ação fixa ---- */
.footbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  background: var(--panel); border-top: 1px solid var(--line); padding: 12px 16px;
  padding-bottom: calc(12px + env(safe-area-inset-bottom));
  display: flex; gap: 10px; max-width: 780px; margin: 0 auto;
  box-shadow: 0 -4px 16px rgba(37,42,66,.06); }
.hidden { display: none !important; }
