:root {
  --bg: #f3f4f6;
  --panel: #ffffff;
  --text: #111827;
  --muted: #6b7280;
  --border: #e5e7eb;
  --key: #ffffff;
  --key-active: #e5e7eb;
  --primary: #2563eb;
  --primary-text: #ffffff;
  --warn-bg: #fef3c7;
  --warn-border: #f59e0b;
  --danger-bg: #fee2e2;
  --danger: #b91c1c;
  --qty-bg: #111827;
  --qty-text: #ffffff;
  --qty-multi-bg: #dc2626;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
}
[hidden] { display: none !important; }
.muted { color: var(--muted); }
button { font: inherit; color: inherit; cursor: pointer; }

/* ---------- Teclado ---------- */
.keypad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  user-select: none;
}
.keypad button {
  height: 72px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--key);
  font-size: 30px;
  font-weight: 600;
  box-shadow: 0 1px 2px rgb(0 0 0 / 0.06);
  touch-action: manipulation;
}
.keypad button:active { background: var(--key-active); transform: scale(0.98); }
.keypad .k-fn { font-size: 18px; color: var(--muted); }
.keypad .k-go {
  grid-column: 1 / -1;
  background: var(--primary);
  color: var(--primary-text);
  border-color: var(--primary);
  font-size: 22px;
}
.keypad .k-go:active { background: #1d4ed8; }

/* ---------- Login ---------- */
.login {
  min-height: 100%;
  display: grid;
  place-items: center;
  padding: 24px 16px;
}
.login-box { width: 100%; max-width: 340px; text-align: center; }
.login-box h1 { font-size: 22px; margin: 0 0 4px; }
.pin-dots { display: flex; justify-content: center; gap: 14px; margin: 24px 0 8px; }
.pin-dots span {
  width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid var(--muted);
}
.pin-dots span.on { background: var(--text); border-color: var(--text); }
.pin-dots.shake { animation: shake 0.35s; }
@keyframes shake {
  25% { transform: translateX(-8px); }
  75% { transform: translateX(8px); }
}
.error { color: var(--danger); min-height: 1.4em; margin: 0 0 16px; }

/* ---------- App ---------- */
.app {
  height: 100%;
  display: grid;
  grid-template-columns: 1fr 340px;
}
.order {
  overflow-y: auto;
  padding: 24px 28px;
}
.side {
  background: var(--panel);
  border-left: 1px solid var(--border);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.display {
  border: 2px solid var(--border);
  border-radius: 14px;
  padding: 10px 16px;
  display: flex;
  align-items: baseline;
  gap: 12px;
  min-height: 72px;
}
.display-label { color: var(--muted); font-weight: 600; }
.display-value {
  font-size: 40px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: 1px;
  overflow: hidden;
  text-overflow: ellipsis;
}
.logout {
  margin-top: auto;
  background: none;
  border: none;
  color: var(--muted);
  padding: 8px;
}

.placeholder, .status {
  height: 100%;
  display: grid;
  place-items: center;
  text-align: center;
  font-size: 22px;
}
.status.err { color: var(--danger); }

.banner {
  background: var(--danger-bg);
  color: var(--danger);
  border: 2px solid var(--danger);
  border-radius: 12px;
  padding: 12px 16px;
  font-weight: 700;
  font-size: 20px;
  margin-bottom: 16px;
}
.order-head { display: flex; flex-wrap: wrap; gap: 8px; }
.tag {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 15px;
  color: var(--muted);
}
.tag strong { color: var(--text); }
.cliente { font-size: 34px; margin: 18px 0 4px; line-height: 1.15; }
.destinatario { margin: 0 0 4px; color: var(--muted); font-size: 18px; }
.endereco { font-style: normal; font-size: 19px; line-height: 1.45; color: #374151; }

.obs {
  background: var(--warn-bg);
  border: 2px solid var(--warn-border);
  border-radius: 12px;
  padding: 12px 16px;
  margin: 20px 0 0;
}
.obs-title { font-weight: 700; font-size: 14px; text-transform: uppercase; letter-spacing: 0.04em; color: #92400e; }
.obs p { margin: 6px 0 0; font-size: 20px; white-space: pre-wrap; }

.itens-head {
  display: flex;
  justify-content: space-between;
  margin: 24px 0 8px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  font-size: 14px;
  letter-spacing: 0.04em;
}
.itens { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.itens li {
  display: flex;
  align-items: center;
  gap: 16px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 16px;
}
.qty {
  flex: none;
  min-width: 64px;
  height: 56px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: var(--qty-bg);
  color: var(--qty-text);
  font-size: 28px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}
.qty.multi { background: var(--qty-multi-bg); }
.foto {
  flex: none;
  width: 88px;
  height: 88px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
  overflow: hidden;
}
.foto img { width: 100%; height: 100%; object-fit: cover; display: block; }
.foto.sem::after {
  content: "sem foto";
  display: grid;
  place-items: center;
  height: 100%;
  font-size: 12px;
  color: var(--muted);
}

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 10;
  background: rgb(0 0 0 / 0.85);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 16px;
  cursor: zoom-out;
}
.lightbox img {
  max-width: 100%;
  max-height: calc(100% - 60px);
  object-fit: contain;
  border-radius: 12px;
  background: #fff;
}
.lightbox p { color: #fff; font-size: 20px; margin: 0; text-align: center; }
.item-desc { font-size: 20px; font-weight: 600; }
.item-sku { font-size: 14px; color: var(--muted); }

/* ---------- Telas estreitas ---------- */
@media (max-width: 800px) {
  .app { grid-template-columns: 1fr; grid-template-rows: auto auto; height: auto; }
  .side { border-left: none; border-top: 1px solid var(--border); order: -1; }
  .order { padding: 16px; }
  .placeholder, .status { min-height: 160px; }
  .keypad button { height: 60px; }
  .cliente { font-size: 26px; }
  .itens li { gap: 10px; padding: 10px; }
  .foto { width: 64px; height: 64px; }
  .qty { min-width: 48px; height: 48px; font-size: 24px; }
  .item-desc { font-size: 17px; }
}
