:root {
  --ink: #1d2a36; --paper: #f3f5f4; --muted: #5b6770; --line: #d8dedb;
  --in: #16875a; --out: #2656c9; --warn: #b87a00; --bad: #b3372d;
  --font: "Segoe UI Rounded", "SF Pro Rounded", ui-rounded, "Segoe UI", system-ui, -apple-system, Arial, sans-serif;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; font-family: var(--font); background: var(--paper); color: var(--ink); overflow: hidden; user-select: none; -webkit-user-select: none; }

/* Status bar: tells staff at a glance whether a scan will register. */
.status { height: 52px; display: flex; align-items: center; justify-content: space-between; padding: 0 1.25rem; padding-top: env(safe-area-inset-top); font-weight: 700; font-size: 1.1rem; color: #fff; cursor: pointer; }
.status.ready { background: var(--in); }
.status.paused { background: var(--bad); }
.status.offline { background: var(--warn); }
.status-right { font-weight: 600; font-variant-numeric: tabular-nums; }

main.idle { height: calc(100% - 52px); display: grid; grid-template-columns: 1fr minmax(280px, 30%); }
.idle-main { display: flex; flex-direction: column; justify-content: center; padding: 3rem clamp(1.5rem, 5vw, 5rem); }
.where { color: var(--muted); font-size: 1.1rem; margin: 0 0 .75rem; }
.prompt { font-size: clamp(3rem, 8vw, 6.5rem); line-height: 1; margin: 0; letter-spacing: -.02em; }
.count { font-size: 1.4rem; color: var(--muted); margin: 2rem 0 0; }
.count b { color: var(--ink); font-size: 2.2rem; }

.side { background: #fff; border-left: 1px solid var(--line); padding: 1.25rem; overflow-y: auto; display: flex; flex-direction: column; }
.side h2 { font-size: 1rem; margin: 0 0 .6rem; color: var(--muted); font-weight: 600; }
.recent { list-style: none; margin: 0; padding: 0; flex: 1; }
.recent li { display: flex; justify-content: space-between; gap: .5rem; padding: .55rem 0; border-bottom: 1px solid var(--line); font-size: 1.05rem; }
.recent li.empty { color: var(--muted); border: 0; }
.recent .kind { font-weight: 700; font-size: .85rem; padding: .1rem .5rem; border-radius: 999px; white-space: nowrap; }
.recent .in { background: #e3f3eb; color: var(--in); }
.recent .out { background: #e6ecfa; color: var(--out); }
.recent .already { background: #fcf1d9; color: var(--warn); }
.recent .unknown, .recent .removed { background: #fbe7e5; color: var(--bad); }
.recent .t { color: var(--muted); font-variant-numeric: tabular-nums; font-size: .95rem; }

.undo { display: flex; align-items: center; justify-content: space-between; gap: .5rem; background: var(--ink); color: #fff; border-radius: 8px; padding: .6rem .8rem; margin-bottom: .75rem; }
.undo button { font: inherit; font-weight: 700; background: #fff; color: var(--ink); border: 0; border-radius: 6px; padding: .45rem 1rem; cursor: pointer; }

.eod { background: #fcf1d9; border: 2px solid var(--warn); border-radius: 8px; padding: .8rem; margin-bottom: 1rem; }
.eod h2 { color: var(--warn); margin: 0; font-size: 1.1rem; }
.eod p { margin: .2rem 0 .5rem; font-size: .95rem; }
.eod ul { margin: 0; padding-left: 1.1rem; font-size: 1.05rem; }

.tools { display: flex; gap: .5rem; margin-top: 1rem; }
.tools button, .camera-tools button { font: inherit; font-size: .9rem; padding: .5rem .8rem; border-radius: 6px; border: 1px solid var(--line); background: #fff; color: var(--ink); cursor: pointer; }

/* The full-screen result after each scan. */
.flash { position: fixed; inset: 0; display: flex; flex-direction: column; justify-content: center; padding: 0 clamp(1.5rem, 7vw, 7rem); color: #fff; z-index: 10; }
.flash[hidden] { display: none; }
.flash.in { background: var(--in); }
.flash.out { background: var(--out); }
.flash.already, .flash.queued { background: var(--warn); }
.flash.unknown, .flash.removed, .flash.error { background: var(--bad); }
.flash p { margin: 0; }
.flash-head { font-size: clamp(1.6rem, 3.5vw, 2.6rem); font-weight: 600; opacity: .92; }
.flash-name { font-size: clamp(3.5rem, 11vw, 9rem); font-weight: 800; line-height: 1.02; letter-spacing: -.02em; margin: .3rem 0 1rem !important; word-break: break-word; }
.flash-subjects span { display: inline-block; font-size: clamp(1.2rem, 2.6vw, 2rem); font-weight: 700; background: rgba(255,255,255,.2); border: 2px solid rgba(255,255,255,.6); border-radius: 999px; padding: .2rem 1.1rem; margin: 0 .6rem .5rem 0; }
.flash-note { font-size: clamp(1.2rem, 2.4vw, 1.8rem); margin-top: .8rem !important; opacity: .95; }
.flash.show { animation: pop .18s ease-out; }
@keyframes pop { from { transform: scale(1.03); opacity: .6; } to { transform: none; opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .flash.show { animation: none; } }

.camera { position: fixed; inset: 0; background: rgba(29,42,54,.96); z-index: 5; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1rem; }
.camera[hidden] { display: none; }
#reader { width: min(520px, 90vw); background: #000; border-radius: 8px; overflow: hidden; }
.camera-tools { display: flex; gap: .5rem; }

@media (max-width: 800px) {
  main.idle { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .idle-main { padding: 2rem 1.5rem; }
  .side { border-left: 0; border-top: 1px solid var(--line); }
}

/* Pairing page */
body.pair { display: flex; align-items: center; justify-content: center; overflow: auto; padding: 1rem; }
.pairbox { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 2rem; max-width: 460px; width: 100%; }
.pairbox h1 { margin: 0 0 .5rem; font-size: 1.6rem; }
.pairbox input { display: block; width: 100%; font: inherit; font-size: 2.4rem; text-align: center; letter-spacing: .4rem; padding: .5rem; margin: 1rem 0; border: 2px solid var(--line); border-radius: 8px; }
.pairbox button { width: 100%; font: inherit; font-weight: 700; font-size: 1.1rem; padding: .8rem; border: 0; border-radius: 8px; background: var(--ink); color: #fff; cursor: pointer; }
.pair-error { background: #fbe7e5; color: var(--bad); padding: .6rem .8rem; border-radius: 6px; }
.small { font-size: .9rem; color: var(--muted); }
