:root {
  color-scheme: light dark;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
}

body {
  margin: 0;
  min-height: 100vh;
  display: grid;
  place-items: center;
  background: #0f172a;
  color: #e2e8f0;
}

.card {
  width: min(560px, 92vw);
  background: #1e293b;
  border-radius: 14px;
  padding: 28px 32px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
}

h1 {
  margin: 0 0 8px;
  font-size: 1.4rem;
}

.hint {
  color: #94a3b8;
  font-size: 0.92rem;
  margin: 0 0 18px;
}

kbd {
  background: #334155;
  border-radius: 4px;
  padding: 1px 6px;
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 0.85em;
}

form {
  display: flex;
  gap: 8px;
}

input[type='text'],
input[type='file'] {
  flex: 1;
  padding: 12px 14px;
  border-radius: 8px;
  border: 1px solid #334155;
  background: #0f172a;
  color: inherit;
  font-size: 1rem;
}

button {
  padding: 12px 18px;
  border-radius: 8px;
  border: 0;
  background: #2563eb;
  color: white;
  font-weight: 600;
  cursor: pointer;
}
button:hover { background: #1d4ed8; }

.status {
  margin-top: 14px;
  min-height: 1.4em;
  font-size: 0.95rem;
  color: #cbd5e1;
}
.status[data-kind='ok']  { color: #4ade80; }
.status[data-kind='err'] { color: #f87171; }

.mode {
  border: 1px solid #334155;
  border-radius: 8px;
  padding: 8px 14px 10px;
  margin: 0 0 14px;
  color: #cbd5e1;
  font-size: 0.9rem;
}
.mode legend {
  padding: 0 6px;
  color: #94a3b8;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.mode label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-right: 16px;
  cursor: pointer;
}

.usb-panel {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 0 0 14px;
  padding: 10px 12px;
  background: #0f172a;
  border: 1px solid #334155;
  border-radius: 8px;
  font-size: 0.9rem;
}
.usb-row {
  display: flex;
  align-items: center;
  gap: 10px;
}
.usb-row select {
  flex: 1;
  padding: 8px 10px;
  border-radius: 6px;
  border: 1px solid #334155;
  background: #0f172a;
  color: inherit;
  font-size: 0.85rem;
}
.usb-panel button {
  padding: 8px 14px;
  font-size: 0.85rem;
  background: #0ea5e9;
}
.usb-panel button:hover { background: #0284c7; }
.usb-panel span { color: #cbd5e1; flex: 1; }

.scanner-panel {
  margin: 0 0 14px;
  padding: 10px 12px;
  background: #0f172a;
  border: 1px solid #334155;
  border-radius: 8px;
  font-size: 0.9rem;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.scanner-row {
  display: flex;
  align-items: center;
  gap: 10px;
}
.scanner-panel button {
  padding: 8px 14px;
  font-size: 0.85rem;
  background: #16a34a;
}
.scanner-panel button:hover { background: #15803d; }
.scanner-panel button:disabled { background: #334155; cursor: not-allowed; }
.scan-state { color: #cbd5e1; flex: 1; font-size: 0.85rem; }
.scan-viewport {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 3;
  background: #000;
  border-radius: 8px;
  overflow: hidden;
}
.scan-viewport video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.scan-reticle {
  position: absolute;
  inset: 18% 12%;
  border: 2px solid rgba(34, 197, 94, 0.85);
  border-radius: 8px;
  box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.25) inset;
  pointer-events: none;
}
.scan-hit {
  position: absolute;
  inset: 0;
  background: rgba(34, 197, 94, 0.35);
  pointer-events: none;
  opacity: 0;
}
.scan-hit.show {
  animation: scan-hit-flash 0.6s ease-out;
}
@keyframes scan-hit-flash {
  0%   { opacity: 0.9; }
  100% { opacity: 0; }
}

.upload {
  margin-top: 22px;
  border-top: 1px solid #334155;
  padding-top: 16px;
}
.upload summary {
  cursor: pointer;
  color: #93c5fd;
  margin-bottom: 12px;
}
.upload form {
  flex-direction: column;
  align-items: stretch;
}
.upload label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.85rem;
  color: #94a3b8;
  margin-bottom: 8px;
}

#print-frame {
  position: fixed;
  width: 0;
  height: 0;
  border: 0;
  visibility: hidden;
}

.labels-panel {
  margin: 18px 0 4px;
  border: 1px solid #334155;
  border-radius: 8px;
  background: #0f172a;
}
.labels-panel summary {
  cursor: pointer;
  list-style: none;
  padding: 10px 14px;
  color: #93c5fd;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  gap: 10px;
}
.labels-panel summary::-webkit-details-marker { display: none; }
.labels-panel summary::before {
  content: '▸';
  display: inline-block;
  transition: transform 0.15s;
  color: #94a3b8;
}
.labels-panel[open] summary::before { transform: rotate(90deg); }
.labels-panel summary #labels-count {
  color: #e2e8f0;
  font-weight: 600;
}
.labels-panel summary button {
  margin-left: auto;
  padding: 4px 10px;
  font-size: 0.78rem;
  background: #334155;
}
.labels-panel summary button:hover { background: #475569; }
.labels-list {
  padding: 0 14px 12px;
  max-height: 320px;
  overflow: auto;
}
.labels-empty {
  color: #94a3b8;
  font-size: 0.85rem;
  margin: 6px 0;
}
.labels-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
  color: #cbd5e1;
}
.labels-table th,
.labels-table td {
  padding: 6px 8px;
  border-bottom: 1px solid #1e293b;
  text-align: left;
  vertical-align: middle;
}
.labels-table th {
  color: #94a3b8;
  font-weight: 500;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  position: sticky;
  top: 0;
  background: #0f172a;
}
.labels-table td.num, .labels-table th.num { text-align: right; font-variant-numeric: tabular-nums; }
.labels-table td.date { color: #94a3b8; font-size: 0.78rem; white-space: nowrap; }
.label-pick {
  background: transparent;
  color: #93c5fd;
  border: 0;
  padding: 2px 4px;
  font: inherit;
  font-family: ui-monospace, Menlo, Consolas, monospace;
  cursor: pointer;
  text-align: left;
}
.label-pick:hover { color: #bfdbfe; text-decoration: underline; background: transparent; }
.fmt-pill {
  display: inline-block;
  padding: 1px 6px;
  margin-right: 4px;
  border-radius: 4px;
  background: #1e293b;
  color: #cbd5e1;
  font-size: 0.7rem;
  font-family: ui-monospace, Menlo, Consolas, monospace;
}
