:root {
  --petrol: #0d3b44;
  --petrol-2: #14525d;
  --ink: #132024;
  --paper: #f3f1ec;
  --card: #fff;
  --line: #d9d5cc;
  --mute: #5d6b6e;
  --amber: #f2a516;
  --ok: #13a55a;
  --bad: #d93025;
  --serif: 'Iowan Old Style', 'Charter', 'Source Serif Pro', Georgia, serif;
  --mono: 'JetBrains Mono', 'IBM Plex Mono', ui-monospace, monospace;
  --r: 14px;
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
  color: var(--ink);
  font: 16px/1.5 var(--mono);
  background:
    radial-gradient(120% 60% at 0 0, #e7ece9, transparent 60%),
    repeating-linear-gradient(0deg, transparent 0 23px, #0d3b440a 23px 24px), var(--paper);
  min-height: 100vh;
}
.sr {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}
.bar {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: center;
  justify-content: space-between;
  padding: 1rem clamp(1rem, 4vw, 3rem);
  background: var(--petrol);
  color: #eef4f3;
}
h1 {
  margin: 0;
  font: 600 1.7rem/1 var(--serif);
  letter-spacing: -0.02em;
}
h1 b {
  color: var(--amber);
}
h2 {
  margin: 0;
  font: 600 1.4rem var(--serif);
}
.modes {
  display: flex;
  background: #0006;
  border-radius: 999px;
  padding: 4px;
}
.modes button {
  border: 0;
  background: none;
  color: #cfe0de;
  padding: 0.6rem 1.1rem;
  border-radius: 999px;
  font: 600 0.9rem var(--mono);
  cursor: pointer;
  min-height: 44px;
}
.modes button[aria-pressed='true'] {
  background: var(--amber);
  color: var(--ink);
}
button,
.btn {
  min-height: 48px;
  padding: 0.7rem 1.2rem;
  border: 2px solid var(--petrol);
  border-radius: 10px;
  background: var(--card);
  color: var(--petrol);
  font: 700 0.95rem var(--mono);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
.primary {
  background: var(--petrol);
  color: #fff;
}
:focus-visible {
  outline: 3px solid var(--amber);
  outline-offset: 3px;
}
.work {
  display: grid;
  gap: 1.5rem;
  padding: 1.5rem clamp(1rem, 4vw, 3rem);
  grid-template-columns: minmax(0, 1fr);
}
@media (min-width: 960px) {
  .work {
    grid-template-columns: minmax(0, 5fr) minmax(0, 6fr);
    gap: 2.5rem;
  }
}
.input,
.readout {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: clamp(1rem, 2.5vw, 1.75rem);
  box-shadow:
    0 1px 0 #fff inset,
    0 18px 40px -28px #0d3b4466;
}
.drop {
  display: grid;
  place-items: center;
  gap: 0.35rem;
  text-align: center;
  min-height: 300px;
  border: 2px dashed var(--petrol-2);
  border-radius: var(--r);
  cursor: pointer;
  background: linear-gradient(160deg, #f6faf9, #eaf1ef);
  transition:
    background 0.2s,
    border-color 0.2s;
}
.drop:hover,
.drop.over,
.drop:focus-within {
  border-color: var(--amber);
  background: #fff8ea;
}
.drop strong {
  font: 600 1.6rem var(--serif);
}
.drop span {
  color: var(--mute);
}
.drop-mark {
  font-size: 2.4rem;
  width: 72px;
  height: 72px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--petrol);
  color: var(--amber);
}
.hint {
  margin: 0 0 1rem;
  color: var(--mute);
  font-size: 0.9rem;
}
.viewer {
  position: relative;
  aspect-ratio: 3/4;
  max-height: 60vh;
  background: #071f24;
  border-radius: var(--r);
  overflow: hidden;
}
video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.guide {
  position: absolute;
  inset: 18% 12%;
  border: 3px solid var(--amber);
  border-radius: 12px;
  box-shadow: 0 0 0 999px #0007;
}
#live-feedback {
  position: absolute;
  left: 50%;
  bottom: 1rem;
  transform: translateX(-50%);
  margin: 0;
  padding: 0.55rem 1.1rem;
  border-radius: 999px;
  background: #0d3b44e6;
  color: #fff;
  font-weight: 700;
  white-space: nowrap;
}
#live-feedback[data-state='moving'] {
  background: #4a5559;
}
#live-feedback[data-state='scanning'] {
  background: var(--amber);
  color: var(--ink);
}
#live-feedback[data-state='success'] {
  background: var(--ok);
}
#live-feedback[data-state='failure'] {
  background: var(--bad);
}
.viewer:has([data-state='success']) .guide {
  border-color: var(--ok);
}
.viewer:has([data-state='failure']) .guide {
  border-color: var(--bad);
}
.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-top: 1rem;
}
.controls > * {
  flex: 1 1 auto;
}
.summary {
  display: flex;
  gap: 1.5rem;
  margin: 1rem 0 0;
}
.summary dt {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--mute);
}
.summary dd {
  margin: 0;
  font: 600 2rem/1 var(--serif);
}
.readout-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}
#status {
  margin: 0.75rem 0 0;
  padding-left: 0.75rem;
  border-left: 3px solid var(--amber);
}
.queue {
  margin: 0.25rem 0 1rem;
  color: var(--mute);
  font-size: 0.85rem;
}
.table-wrap {
  overflow-x: auto;
}
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}
th {
  text-align: left;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--mute);
  border-bottom: 2px solid var(--petrol);
  padding: 0.5rem;
}
td {
  padding: 0.6rem 0.5rem;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}
td[data-field='item'] {
  font-family: var(--serif);
  font-size: 1.05rem;
}
td[data-field='status'] {
  font-weight: 700;
}
tr[data-status='ok'] td[data-field='status'],
td[data-field='status'].ok {
  color: var(--ok);
}
tr[data-status='fail'] td[data-field='status'],
td[data-field='status'].fail {
  color: var(--bad);
}
td[data-field='image'] button {
  padding: 0;
  min-height: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  width: 56px;
  height: 56px;
}
td[data-field='image'] img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.empty {
  display: grid;
  gap: 0.25rem;
  padding: 2.5rem 1rem;
  text-align: center;
  color: var(--mute);
}
.empty strong {
  font: 600 1.3rem var(--serif);
  color: var(--ink);
}
#rows:not(:empty) + *,
.table-wrap:has(#rows:not(:empty)) .empty {
  display: none;
}
dialog {
  border: 0;
  border-radius: var(--r);
  padding: 1rem;
  max-width: min(92vw, 720px);
}
dialog::backdrop {
  background: #071f24cc;
}
dialog img {
  max-width: 100%;
  max-height: 70vh;
  display: block;
  border-radius: 8px;
}
figure {
  margin: 0 0 1rem;
}
figcaption {
  margin-top: 0.5rem;
  color: var(--mute);
}
@media (max-width: 640px) {
  thead {
    display: none;
  }
  table,
  tbody,
  tr,
  td {
    display: block;
  }
  tr {
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 0.5rem;
    margin-bottom: 0.75rem;
  }
  td {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    border: 0;
    padding: 0.35rem 0.25rem;
  }
  td[data-field]::before {
    content: attr(data-field);
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--mute);
  }
  td[data-field='confidence']::before {
    content: 'OCR conf.';
  }
}
@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
  }
}
[hidden] {
  display: none !important;
}
.input,
.readout {
  min-width: 0;
  align-self: start;
}
.drop {
  align-content: center;
  gap: 0.55rem;
}
.drop .drop-mark {
  color: var(--amber);
  margin-bottom: 0.65rem;
}
.queue:empty {
  margin: 0;
}
.table-wrap {
  margin-top: 1rem;
}
.viewer {
  aspect-ratio: 4/3;
  width: 100%;
}
video {
  object-fit: contain;
}
.guide {
  inset: 8% 6%;
  pointer-events: none;
  box-shadow: none;
  border-style: dashed;
}
#live-feedback {
  max-width: 96%;
  white-space: normal;
  text-align: center;
  width: max-content;
}
td[data-field='image'] button {
  width: auto;
  height: auto;
  min-height: 38px;
  max-width: 12rem;
  padding: 0.3rem 0.5rem;
  text-align: left;
  overflow-wrap: anywhere;
  font: inherit;
  color: var(--petrol);
}
td[data-field='barcode'] {
  overflow-wrap: anywhere;
}
td[data-field='status'].fail {
  color: #a21f18;
}
.sr:focus {
  outline: 0;
}
.btn:focus-within,
.drop:focus-within {
  outline: 3px solid var(--amber);
}
