:root {
  --bg: #0f172a; --panel: #1e293b; --line: #334155; --text: #f1f5f9; --dim: #94a3b8;
  --accent: #38bdf8; --good: #22c55e; --warn: #f59e0b; --bad: #ef4444;
  --radius: 14px;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text);
  font: 17px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
body { padding: 0 16px calc(96px + env(safe-area-inset-bottom)); max-width: 640px; margin: 0 auto; }
h1 { font-size: 1.25rem; margin: 0; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hidden { display: none !important; }
.screen { padding-top: 4px; }
.bar { display: flex; align-items: center; gap: 8px; margin: 8px 0 14px; }
.hint { color: var(--dim); font-size: .9rem; }
.center { text-align: center; min-height: 1.4em; }
.stack { display: grid; gap: 12px; margin-top: 16px; }
.row { display: flex; gap: 8px; align-items: center; }
.panel { background: var(--panel); border-radius: var(--radius); padding: 14px; margin: 12px 0; }
.panel label { display: block; font-weight: 600; margin-bottom: 8px; }
input[type=text] { flex: 1; min-width: 0; font-size: 1.05rem; padding: 12px; border-radius: 10px;
  border: 1px solid var(--line); background: #0b1220; color: var(--text); }
input[type=file] { color: var(--text); max-width: 100%; }
.btn { appearance: none; border: 0; border-radius: 12px; padding: 12px 16px; font: inherit; font-weight: 600;
  background: var(--accent); color: #04121d; cursor: pointer; text-align: center; }
.btn:disabled { opacity: .5; }
.btn.secondary { background: var(--line); color: var(--text); }
.btn.ghost { background: transparent; color: var(--accent); padding: 8px; }
.btn.small { font-size: .95rem; }
.btn.big { font-size: 1.15rem; padding: 18px; }
.btn.full, .file-btn { display: block; width: 100%; }
.file-btn { margin: 14px 0 6px; }
.cards { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.card { background: var(--panel); border-radius: var(--radius); padding: 14px; margin-bottom: 10px;
  border-left: 5px solid var(--line); }
.card .btn { margin-top: 10px; }
.clickable { cursor: pointer; }
.good-card { border-left-color: var(--good); }
.warn-card { border-left-color: var(--warn); }
.bad-card { border-left-color: var(--bad); }
.c-title { font-weight: 700; font-size: 1.1rem; }
.c-meta { color: var(--dim); margin-top: 2px; }
.bad { color: var(--bad); }
.badge { display: inline-block; font-size: .75rem; font-weight: 700; padding: 3px 8px; border-radius: 999px;
  text-transform: uppercase; letter-spacing: .03em; margin-bottom: 6px; }
.badge.good { background: #14532d; color: #bbf7d0; }
.badge.warn { background: #713f12; color: #fde68a; }
.badge.bad { background: #7f1d1d; color: #fecaca; }
.r-name { font-size: 1.6rem; font-weight: 800; line-height: 1.15; }
.r-line { font-size: 1.15rem; margin-top: 4px; }
.r-sub { color: var(--dim); margin-top: 2px; }
.r-mac { font-family: ui-monospace, Consolas, monospace; color: var(--dim); margin-top: 8px; letter-spacing: .03em; }
.label-state { margin: 10px 0 0; color: var(--dim); }
.label-state.done { color: var(--good); font-weight: 600; }
.job-state .job { margin-top: 10px; padding: 10px 12px; border-radius: 10px; background: #0b1220; }
.job.good { color: var(--good); font-weight: 700; }
.job.bad { color: #fecaca; background: #450a0a; }
.progress { background: var(--panel); border-radius: var(--radius); padding: 12px 14px; }
.progress-row { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 8px; font-weight: 600; }
.progress-track { height: 10px; background: #0b1220; border-radius: 999px; overflow: hidden; }
.progress-fill { height: 100%; width: 0; background: var(--good); transition: width .3s; }
.pill { font-size: .78rem; padding: 3px 9px; border-radius: 999px; background: var(--line); white-space: nowrap; }
.pill.ok { background: #14532d; color: #bbf7d0; }
.pill.bad { background: #7f1d1d; color: #fecaca; }
.stats { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; margin: 10px 0; }
.stats dt { color: var(--dim); }
.stats dd { margin: 0; font-weight: 700; text-align: right; }
.warn-list { padding-left: 18px; color: #fde68a; font-size: .9rem; }
.sticky-bottom { position: fixed; left: 0; right: 0; bottom: 0; padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  background: linear-gradient(transparent, var(--bg) 30%); max-width: 640px; margin: 0 auto; }

/* ---- live camera ---- */
.video-wrap { position: relative; margin: 12px 0 8px; border-radius: var(--radius); overflow: hidden;
  background: #000; aspect-ratio: 4 / 3; }
.video-wrap video { width: 100%; height: 100%; object-fit: cover; display: block; }
/* Aiming box: matches the decoder's center crop (10% in from the sides, 20%
   from top/bottom), drawn a little tighter so the barcode lands inside it. */
.reticle { position: absolute; left: 12%; right: 12%; top: 32%; bottom: 32%;
  border: 3px solid var(--accent); border-radius: 10px; box-shadow: 0 0 0 9999px rgba(0, 0, 0, .35); }
.live-hint { position: absolute; left: 0; right: 0; bottom: 8px; text-align: center; font-size: .9rem;
  color: #fff; text-shadow: 0 1px 3px #000; padding: 0 12px; }
#live-result:not(:empty) { margin-bottom: 10px; }
#btn-live, #btn-stop-live { margin-top: 10px; }

/* ---- auto-print toggle ---- */
.toggle { display: flex; align-items: center; gap: 10px; margin: 12px 0 0; padding: 10px 14px;
  background: var(--panel); border-radius: var(--radius); }
.toggle input { width: 22px; height: 22px; accent-color: var(--good); flex: none; }

/* ---- print status strip ---- */
.print-strip { margin: 10px 0 0; display: grid; gap: 6px; }
.strip-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 12px;
  border-radius: 10px; background: var(--panel); font-size: .95rem; }
.strip-row.good { color: #bbf7d0; }
.strip-row.bad { background: #450a0a; color: #fecaca; }
.strip-row .btn { padding: 6px 12px; flex: none; }
.label-state .count { display: inline-block; margin-left: 6px; padding: 1px 8px; border-radius: 999px;
  background: #14532d; color: #bbf7d0; font-size: .8rem; }
.label-state .history { margin: 6px 0 0; padding-left: 18px; color: var(--dim); font-weight: 400; font-size: .85rem; }

/* ---- login / account ---- */
.brand { font-size: 2.2rem; font-weight: 800; letter-spacing: -.02em; text-align: center; margin: 48px 0 8px; }
#login-form input, #password-form input { width: 100%; margin-bottom: 12px; font-size: 1.05rem; padding: 12px;
  border-radius: 10px; border: 1px solid var(--line); background: #0b1220; color: var(--text); }
.error-text { color: #fecaca; background: #450a0a; padding: 8px 12px; border-radius: 10px; }
.ok-text { color: #bbf7d0; background: #14532d; padding: 8px 12px; border-radius: 10px; }
#btn-logout { margin-top: 8px; }
