:root {
  --bg: #f3f4f6; --card: #ffffff; --ink: #111827; --muted: #6b7280; --line: #e5e7eb;
  --green: #15803d; --green-bg: #dcfce7; --red: #b91c1c; --red-bg: #fee2e2;
  --amber: #b45309; --blue: #1d4ed8; --blue-bg: #dbeafe;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--ink);
  font: 18px/1.35 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
body { user-select: none; -webkit-user-select: none; }
.screen { display: none; min-height: 100%; }
.screen.on { display: flex; flex-direction: column; }
.center { flex: 1; display: flex; align-items: center; justify-content: center; padding: 24px; }
.card { background: var(--card); border-radius: 18px; padding: 32px; width: 100%; max-width: 520px;
  box-shadow: 0 2px 12px rgba(0,0,0,.08); }
h1 { font-size: 30px; margin: 0 0 6px; }
.sub { color: var(--muted); margin: 0 0 24px; }
.muted { color: var(--muted); font-size: 17px; }
button { font: inherit; border: 0; border-radius: 14px; cursor: pointer; font-weight: 700; }
button:disabled { opacity: .4; }
.big { width: 100%; font-size: 28px; padding: 26px; margin-top: 18px; color: #fff; }
.green { background: var(--green); color: #fff; } .red { background: var(--red); color: #fff; }
.amber { background: var(--amber); color: #fff; } .blue { background: var(--blue); color: #fff; }
.grey { background: #e5e7eb; color: var(--ink); }
.err { color: var(--red); font-weight: 600; min-height: 1.4em; margin-top: 12px; }
.link { background: none; color: var(--blue); font-weight: 600; padding: 8px; font-size: 18px; }
.status { margin-top: 14px; padding: 14px 16px; border-radius: 12px; background: var(--blue-bg); color: var(--blue); font-weight: 600; }
.demo { display: none; margin-top: 14px; padding: 10px 14px; border-radius: 10px; background: #fef3c7; color: #92400e; font-size: 15px; font-weight: 600; text-align: center; }

/* scan screen */
.top { display: flex; align-items: center; gap: 12px; padding: 12px 18px; background: #111827; color: #fff; }
.top .title { font-size: 22px; font-weight: 700; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top button { background: #374151; color: #fff; padding: 10px 16px; font-size: 17px; }
.sync { font-size: 14px; color: #9ca3af; }
.sync.bad { color: #fca5a5; font-weight: 700; }
.scanwrap { flex: 1; display: flex; flex-direction: column; gap: 14px; padding: 16px 18px; min-height: 0; }
.row2 { display: flex; gap: 14px; }
.qtybox { flex: 0 0 230px; background: var(--card); border: 3px solid var(--blue); border-radius: 16px;
  padding: 12px 16px; text-align: center; cursor: pointer; }
.qtybox .lbl { color: var(--muted); font-size: 16px; font-weight: 600; }
.qtybox .val { font-size: 52px; font-weight: 800; color: var(--blue); line-height: 1.1; }
.qtybox .hint { font-size: 14px; color: var(--muted); }
.qtybox.set { background: var(--blue-bg); }
.last { flex: 1; border-radius: 16px; padding: 14px 18px; display: flex; flex-direction: column; justify-content: center;
  background: var(--card); border: 3px dashed #cbd5e1; }
.last .l1 { font-size: 16px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.last .l2 { font-size: 30px; font-weight: 800; word-break: break-all; }
.last .l3 { font-size: 18px; }
.last.ok { background: var(--green-bg); border: 3px solid var(--green); }
.last.ok .l1 { color: var(--green); }
.last.bad { background: var(--red-bg); border: 3px solid var(--red); }
.last.bad .l1 { color: var(--red); }
.ready { display: inline-block; width: 12px; height: 12px; border-radius: 50%; background: var(--green);
  margin-right: 8px; animation: pulse 1.4s infinite; }
@keyframes pulse { 50% { opacity: .25; } }
.totals { font-size: 18px; color: var(--muted); font-weight: 600; }
.totals b { color: var(--ink); }
.list { flex: 1; min-height: 160px; overflow-y: auto; background: var(--card); border-radius: 16px; }
table { width: 100%; border-collapse: collapse; }
th { position: sticky; top: 0; background: #f9fafb; text-align: left; font-size: 15px; color: var(--muted);
  padding: 10px 14px; border-bottom: 2px solid var(--line); }
td { padding: 12px 14px; border-bottom: 1px solid var(--line); font-size: 20px; }
td.n { color: var(--muted); width: 56px; }
td.q { text-align: right; font-weight: 800; width: 110px; }
th.q { text-align: right; }
tr.unk td { background: var(--red-bg); color: var(--red); }
tr.new td { animation: flash 1s; }
@keyframes flash { from { background: #bbf7d0; } }
.empty { text-align: center; color: var(--muted); padding: 40px 10px; font-size: 20px; }
.bottom { display: flex; gap: 14px; padding: 0 18px 18px; }
.bottom button { flex: 1; font-size: 26px; padding: 24px; }

/* pop-ups */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.5); display: none; align-items: center;
  justify-content: center; padding: 20px; z-index: 10; }
.modal.on { display: flex; }
.modal .card { max-width: 460px; }
.modal h2 { margin: 0 0 8px; font-size: 26px; }
.modal p { margin: 0 0 8px; font-size: 20px; }
.btns { display: flex; gap: 12px; margin-top: 20px; }
.btns button { flex: 1; font-size: 22px; padding: 20px; }
.pad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 14px; }
.pad button { font-size: 30px; padding: 18px 0; background: #f3f4f6; color: var(--ink); }
.pad button.fn { font-size: 20px; background: #e5e7eb; }
input.qtyin { width: 100%; font-size: 48px; font-weight: 800; text-align: center; padding: 8px; border: 3px solid var(--blue);
  border-radius: 12px; color: var(--blue); user-select: text; -webkit-user-select: text; }
.spinner { width: 46px; height: 46px; border: 5px solid #e5e7eb; border-top-color: var(--green); border-radius: 50%;
  animation: spin 1s linear infinite; margin: 10px auto; }
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 700px) {
  .row2 { flex-direction: column; }
  .qtybox { flex: none; }
  .bottom button { font-size: 21px; padding: 20px 8px; }
}
