:root {
  --accent: #0B5FFF;
  --accent-pressed: #0948c7;
  --bg: #ffffff;
  --muted: #5b6472;
  --border: #e5e8ef;
  --danger: #c62828;
  --ok: #1b7f3a;
  --shadow: 0 8px 24px rgba(11, 95, 255, 0.12);
  --radius: 16px;
  --tap: 48px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--bg); color: #111; }
body { min-height: 100dvh; }

.hidden { display: none !important; }
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 12px 14px; background: #fff; border-bottom: 1px solid var(--border);
}
.brand { font-weight: 800; letter-spacing: 0.04em; color: var(--accent); }
.nav { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; }
.nav-btn, .btn {
  min-height: var(--tap); min-width: var(--tap);
  border: 0; border-radius: 12px; padding: 10px 14px;
  background: var(--accent); color: #fff; font-size: 15px; font-weight: 650;
}
.nav-btn.ghost, .btn.ghost { background: #f2f4f8; color: #222; }
.nav-btn.active { outline: 2px solid #9db9ff; }
.btn:active, .nav-btn:active { background: var(--accent-pressed); }
.btn.big { width: 100%; font-size: 18px; min-height: 56px; }
.btn.secondary { background: #eef3ff; color: var(--accent); }
.btn.danger { background: var(--danger); }

.app { padding: 16px; max-width: 720px; margin: 0 auto; }
.card {
  background: #fff; border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px; box-shadow: var(--shadow);
}
.h1 { font-size: 1.4rem; margin: 0 0 4px; }
.sub { color: var(--muted); margin: 0 0 16px; font-size: 0.95rem; }
.stack { display: grid; gap: 12px; }

.pin-pad {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; max-width: 320px; margin: 0 auto;
}
.pin-display {
  letter-spacing: 0.35em; font-size: 1.8rem; text-align: center;
  min-height: 48px; margin-bottom: 12px; font-weight: 700;
}
.pin-key {
  min-height: 64px; border-radius: 16px; border: 1px solid var(--border);
  background: #f8f9fc; font-size: 1.4rem; font-weight: 700;
}

.input, .select, textarea {
  width: 100%; min-height: var(--tap); border: 1px solid var(--border);
  border-radius: 12px; padding: 12px 14px; font-size: 16px; background: #fff;
}
.label { display: grid; gap: 6px; font-size: 0.9rem; color: var(--muted); }
.row { display: flex; gap: 8px; flex-wrap: wrap; }
.row > * { flex: 1; }

.product-thumb {
  width: 100%; max-height: 220px; object-fit: contain; background: #f7f8fb;
  border-radius: 12px; border: 1px solid var(--border);
}
.qty-box { display: grid; gap: 10px; }
.qty-input { font-size: 2rem; text-align: center; font-weight: 800; }
.quick { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.list { display: grid; gap: 10px; }
.list-item {
  display: grid; grid-template-columns: 64px 1fr auto; gap: 10px; align-items: center;
  padding: 10px; border: 1px solid var(--border); border-radius: 14px; background: #fff;
  text-align: left; width: 100%;
}
.list-item img { width: 64px; height: 64px; object-fit: contain; background: #f7f8fb; border-radius: 10px; }
.badge {
  display: inline-block; padding: 4px 8px; border-radius: 999px;
  background: #eef3ff; color: var(--accent); font-size: 0.8rem; font-weight: 700;
}
.scanner-wrap {
  position: relative; overflow: hidden; border-radius: 16px; border: 1px solid var(--border);
  min-height: 280px; background: #000;
}
#qr-reader { width: 100%; }
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  background: #111; color: #fff; padding: 12px 16px; border-radius: 999px;
  z-index: 50; max-width: 90vw;
}
.offline-banner {
  background: #fff3cd; color: #664d03; text-align: center; padding: 8px; font-weight: 650;
}
.muted { color: var(--muted); }
.table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.table th, .table td { border-bottom: 1px solid var(--border); padding: 8px; text-align: left; }
.error { color: var(--danger); font-weight: 650; }
.ok { color: var(--ok); font-weight: 650; }

@media (max-width: 520px) {
  .topbar { align-items: flex-start; flex-direction: column; }
  .nav { width: 100%; }
}
