.scanner_shell {
  position: relative;
  background: #1a1a1a;
  border-radius: 10px;
  overflow: hidden;
  width: 100%;
  aspect-ratio: 4 / 3;
  max-height: 320px;
}

.scanner_video {
  width: 100%;
  height: 100%;
  display: block;

  // The react-qr-reader v3 renders a <video> + an overlay <canvas>/<div>.
  // Force it to fill the shell so we never get whitespace around the feed.
  > section,
  > section > div,
  video {
    width: 100% !important;
    height: 100% !important;
    object-fit: cover !important;
  }
}

.scanner_loading {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  color: #fff;
  font-size: 13px;
  background: rgba(0, 0, 0, 0.55);
  z-index: 2;
}

.scanner_error {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: #fff;
  font-size: 13px;
  background: rgba(40, 0, 0, 0.7);
  text-align: center;
  padding: 16px;
  z-index: 2;
}

.scanner_reticle {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 60%;
  max-width: 220px;
  aspect-ratio: 1;
  transform: translate(-50%, -50%);
  border: 2px solid rgba(255, 255, 255, 0.8);
  border-radius: 12px;
  pointer-events: none;
  box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.25);
  z-index: 1;
}

// Camera-frame flash overlays
.flash {
  position: absolute;
  inset: 0;
  z-index: 3;
  pointer-events: none;
  opacity: 0;
  animation: flashFade 360ms ease-out forwards;
}

.flash_success {
  background: rgba(82, 196, 26, 0.55);
}

.flash_error {
  background: rgba(255, 77, 79, 0.55);
  animation-duration: 480ms;
}

.flash_duplicate {
  background: rgba(250, 219, 20, 0.45);
}

@keyframes flashFade {
  0% { opacity: 0; }
  20% { opacity: 1; }
  100% { opacity: 0; }
}

// Overlay controls
.overlay_top {
  position: absolute;
  top: 8px;
  left: 8px;
  right: 8px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  z-index: 4;
  pointer-events: none; // children re-enable
}

.overlay_top > * {
  pointer-events: auto;
}

.overlay_counter {
  background: rgba(0, 0, 0, 0.6);
  color: #fff;
  font-size: 16px;
  font-weight: 600;
  padding: 4px 12px;
  border-radius: 14px;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.2px;
}

.overlay_counter_collector {
  font-size: 14px;
}

.overlay_icon_btn {
  background: rgba(0, 0, 0, 0.6);
  color: #fff;
  border: none;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 120ms ease;
  padding: 0;

  &:hover,
  &:focus {
    background: rgba(0, 0, 0, 0.8);
    color: #fff;
  }

  &:disabled {
    opacity: 0.5;
    cursor: not-allowed;
  }
}

.overlay_btn_group {
  display: inline-flex;
  gap: 6px;
}

// Bottom toast over camera
.toast {
  position: absolute;
  left: 50%;
  bottom: 12px;
  transform: translateX(-50%);
  max-width: calc(100% - 24px);
  padding: 6px 12px;
  border-radius: 18px;
  font-size: 13px;
  font-family: monospace;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  z-index: 4;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  animation: toastIn 220ms ease-out;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}

.toast_success {
  background: #52c41a;
  color: #fff;
}

.toast_error {
  background: #ff4d4f;
  color: #fff;
}

.toast_duplicate {
  background: #faad14;
  color: #fff;
}

@keyframes toastIn {
  from { opacity: 0; transform: translate(-50%, 10px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

// Body sections (below camera)
.section_status {
  margin-top: 10px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-family: monospace;
  min-height: 22px;
  color: #595959;
}

.section_status_label {
  font-weight: 600;
  color: #262626;
}

.collapsible_toggle {
  margin-top: 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  background: #fafafa;
  border: 1px solid #f0f0f0;
  border-radius: 6px;
  padding: 8px 12px;
  cursor: pointer;
  font-size: 13px;
  color: #262626;
  transition: background 120ms ease;

  &:hover {
    background: #f0f0f0;
  }
}

.collapsible_toggle_label {
  display: flex;
  align-items: center;
  gap: 8px;
}

.collapsible_body {
  border: 1px solid #f0f0f0;
  border-top: none;
  border-radius: 0 0 6px 6px;
  padding: 10px 12px;
  background: #fff;
  margin-top: -1px; // hugs the toggle
}

.checklist_grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 6px 12px;
  max-height: 180px;
  overflow-y: auto;
}

.checklist_item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: monospace;
  font-size: 12.5px;
}

.checklist_item_confirmed {
  color: #52c41a;
}

.checklist_item_pending {
  color: #8c8c8c;
}

.collector_tags_wrapper {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  max-height: 140px;
  overflow-y: auto;
}

.collector_tag {
  font-family: monospace;
  font-size: 12.5px;
}

.manual_entry_row {
  display: flex;
  gap: 8px;
}

.footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 16px;
}

.footer_button {
  min-width: 100px;
  min-height: 36px; // ≥44 with padding for touch targets on tablet
}

@media (max-width: 576px) {
  .scanner_shell {
    aspect-ratio: 1 / 1;
    max-height: none;
  }

  .checklist_grid {
    grid-template-columns: 1fr 1fr;
  }

  .overlay_counter {
    font-size: 14px;
  }
}
