:root {
  color-scheme: light;
  --bg: #f5f7fb;
  --panel: #ffffff;
  --panel-soft: #f8fafc;
  --line: #d8e2ec;
  --line-strong: #b9c8d8;
  --text: #122033;
  --muted: #607086;
  --accent: #2563eb;
  --accent-strong: #1d4ed8;
  --accent-soft: #eaf1ff;
  --warn: #d97706;
  --warn-soft: #fff7ed;
  --danger: #dc2626;
  --danger-soft: #fef2f2;
  --shadow: 0 12px 34px rgba(15, 23, 42, 0.08);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  overflow-x: hidden;
}

button,
.home-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
  color: var(--text);
  font: inherit;
  font-weight: 700;
  text-decoration: none;
  touch-action: manipulation;
}

summary {
  cursor: pointer;
  font-weight: 800;
  list-style-position: inside;
}

button:disabled {
  background: #f1f5f9;
  border-color: #d8e2ec;
  color: #94a3b8;
  cursor: not-allowed;
  opacity: 1;
}

button.primary:disabled,
button.warning:disabled,
button.return-button:disabled,
button.danger:disabled {
  background: #f1f5f9;
  border-color: #d8e2ec;
  color: #94a3b8;
}

button.primary {
  background: var(--accent-strong);
  border-color: var(--accent);
  color: #ffffff;
}

button.return-button {
  background: var(--warn-soft);
  border-color: #fdba74;
  color: #9a3412;
}

button.danger {
  background: var(--danger-soft);
  border-color: #fecaca;
  color: #991b1b;
}

button.warning {
  background: var(--warn-soft);
  border-color: #fdba74;
  color: #9a3412;
}

dialog.bottom-sheet {
  width: min(720px, calc(100% - 20px));
  max-height: min(82vh, 760px);
  margin: auto auto 0;
  padding: 14px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 14px 14px 0 0;
  background: var(--panel);
  color: var(--text);
  box-shadow: var(--shadow);
}

dialog.bottom-sheet:not([open]) {
  display: none;
}

dialog.bottom-sheet[open] {
  display: grid;
  gap: 10px;
}

dialog.bottom-sheet::backdrop {
  background: rgba(15, 23, 42, 0.42);
}

.sheet-handle {
  width: 56px;
  height: 5px;
  margin: 0 auto 12px;
  border-radius: 999px;
  background: var(--line-strong);
}

.sheet-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.sheet-heading h2 {
  margin: 0;
  font-size: 18px;
  line-height: 1.2;
}

.sheet-heading-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
}

.sheet-heading button,
.sheet-heading-actions button {
  min-height: 38px;
  padding: 0 10px;
  font-size: 13px;
}

.scanner-shell {
  width: min(760px, 100%);
  margin: 0 auto;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.topbar,
.intent-context-panel,
.scan-feedback,
.controls,
.scanner-more-actions,
.review-panel,
.manual-panel,
.queue-panel,
.result-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

.intent-context-panel {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 10px;
  background: #eff6ff;
  border-color: #bfdbfe;
}

.intent-context-panel > div {
  min-width: 0;
}

.intent-context-panel strong,
.intent-context-panel span {
  display: block;
  overflow-wrap: anywhere;
}

.intent-context-panel strong {
  font-size: 16px;
  line-height: 1.22;
}

.intent-context-panel span {
  margin-top: 3px;
  color: #1e3a8a;
  font-size: 12px;
  line-height: 1.35;
}

.gtin-pair-scan-panel {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid #bfdbfe;
  border-radius: 12px;
  background: #eff6ff;
}

.gtin-pair-scan-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.gtin-pair-scan-head strong,
.gtin-pair-scan-head span {
  display: block;
}

.gtin-pair-scan-head strong {
  font-size: 15px;
  line-height: 1.25;
}

.gtin-pair-scan-head span {
  margin-top: 3px;
  color: #1e3a8a;
  font-size: 12px;
  line-height: 1.35;
}

.gtin-pair-toggle {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 40px;
  padding: 0 10px;
  border-radius: 999px;
  background: #ffffff;
  color: #1e3a8a;
  font-size: 13px;
  font-weight: 800;
  white-space: nowrap;
}

.gtin-pair-toggle input {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
}

.gtin-pair-candidate {
  padding-top: 2px;
}

.gtin-pair-reset {
  min-height: 40px;
  border: 0;
  border-radius: 12px;
  background: #dbeafe;
  color: #1d4ed8;
  font-size: 13px;
}

.gtin-workflow-panel {
  display: grid;
  gap: 10px;
}

body[data-settings-gtin-mode="true"] .result-panel,
body[data-settings-gtin-mode="true"] #operationReviewPanel,
body[data-settings-gtin-mode="true"] #openGtinMappingButton {
  display: none !important;
}

.gtin-status-card,
.gtin-room-panel {
  display: grid;
  gap: 9px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--panel);
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

.gtin-status-card strong {
  display: block;
  font-size: 18px;
  line-height: 1.25;
}

.gtin-status-card span,
.gtin-status-card small {
  display: block;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}

.gtin-room-head {
  display: grid;
  gap: 10px;
}

.gtin-room-head h2 {
  margin: 0;
  font-size: 18px;
  line-height: 1.25;
}

.gtin-room-head span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

.gtin-room-head button {
  min-height: 44px;
  border: 0;
  border-radius: 14px;
  background: #f3f4f6;
  font-size: 14px;
  white-space: nowrap;
}

.gtin-room-list {
  display: grid;
  gap: 8px;
}

.gtin-room-row {
  width: 100%;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 8px;
  align-items: center;
  min-height: 68px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel-soft);
  text-align: left;
}

.gtin-room-row strong,
.gtin-room-row small {
  display: block;
  overflow-wrap: anywhere;
}

.gtin-room-row strong {
  font-size: 15px;
  line-height: 1.25;
}

.gtin-room-row small {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.gtin-room-chevron {
  color: var(--muted);
  font-size: 22px;
  line-height: 1;
}

.gtin-room-detail-sheet .sheet-heading span {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

.gtin-room-detail-body {
  display: grid;
  gap: 12px;
  margin-top: 12px;
}

.gtin-room-detail-section {
  display: grid;
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel-soft);
}

.gtin-room-detail-section h3 {
  margin: 0;
  font-size: 15px;
}

.gtin-room-evidence summary {
  font-size: 14px;
}

.gtin-review-sheet .sheet-heading span {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

.gtin-review-section {
  display: grid;
  gap: 9px;
  margin-top: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--panel-soft);
}

.gtin-review-section h3 {
  margin: 0;
  font-size: 15px;
  line-height: 1.3;
}

.gtin-evidence-list {
  margin: 0;
  padding-left: 18px;
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 12px;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

@media (min-width: 560px) {
  .gtin-room-head {
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
  }

  #gtinRoomDetailSheet .scan-detail-actions {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

.context-change-link {
  min-height: 34px;
  padding: 0 10px;
  border: 1px solid #bfdbfe;
  border-radius: 8px;
  background: #ffffff;
  color: var(--accent-strong);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 800;
  line-height: 1;
  text-decoration: none;
  white-space: nowrap;
}

.intent-picker {
  position: relative;
  flex: 0 0 auto;
}

.intent-picker > summary {
  list-style: none;
}

.intent-picker > summary::-webkit-details-marker {
  display: none;
}

.intent-picker-list {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 20;
  width: min(240px, calc(100vw - 32px));
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
  padding: 8px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.intent-picker-list button {
  min-height: 36px;
  padding: 0 8px;
  font-size: 12px;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.intent-picker-list button[data-active="true"] {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.scan-feedback {
  display: grid;
  gap: 2px;
  padding: 9px 10px;
  border-width: 1px;
}

.scan-feedback strong {
  font-size: 17px;
  line-height: 1.2;
}

.scan-feedback span {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.scan-feedback[data-state="idle"] {
  border-color: var(--line);
  background: var(--panel);
}

.scan-feedback[data-state="success"] {
  border-color: #86efac;
  background: #f0fdf4;
}

.scan-feedback[data-state="success"] strong {
  color: #047857;
}

.scan-feedback[data-state="error"] {
  border-color: #fecaca;
  background: var(--danger-soft);
}

.scan-feedback[data-state="error"] strong {
  color: #b91c1c;
}

body[data-scan-state="success"] .camera-panel {
  border-color: #22c55e;
}

body[data-scan-state="error"] .camera-panel {
  border-color: var(--danger);
}

.toast {
  position: fixed;
  left: 14px;
  right: 14px;
  bottom: 14px;
  z-index: 50;
  width: min(520px, calc(100% - 28px));
  margin: 0 auto;
  padding: 12px 14px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: #111827;
  color: #ffffff;
  font-weight: 800;
  box-shadow: var(--shadow);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px;
}

.topbar > div {
  display: grid;
  grid-template-columns: auto minmax(0, max-content);
  grid-template-areas:
    "eyebrow eyebrow"
    "title badge";
  align-items: center;
  column-gap: 8px;
  row-gap: 3px;
  min-width: 0;
}

.topbar .eyebrow {
  grid-area: eyebrow;
  margin: 0;
  line-height: 1;
}

.topbar h1 {
  grid-area: title;
}

.topbar .mode-badge {
  grid-area: badge;
}

.home-link {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  padding: 0 10px;
  font-size: 14px;
  line-height: 1.15;
  white-space: nowrap;
}

.scanner-back-button {
  min-width: 92px;
}

.eyebrow,
.label {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: 21px;
  line-height: 1.1;
}

.mode-badge {
  max-width: 100%;
  width: fit-content;
  margin: 0;
  border: 1px solid #93c5fd;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  padding: 4px 8px;
  font-size: 11px;
  font-weight: 800;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.mode-badge[data-empty="true"] {
  border-color: var(--line);
  background: var(--panel-soft);
  color: var(--muted);
}

.pill {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 10px;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.camera-panel {
  position: relative;
  min-height: 300px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #020705;
}

video {
  width: 100%;
  height: min(52vh, 500px);
  min-height: 300px;
  display: block;
  object-fit: cover;
}

.reticle {
  position: absolute;
  left: 50%;
  top: 50%;
  width: min(72%, 360px);
  height: min(40%, 220px);
  transform: translate(-50%, -50%);
  border: 2px solid rgba(84, 212, 143, 0.9);
  border-radius: 8px;
  box-shadow: 0 0 0 999px rgba(0, 0, 0, 0.22);
}

.status {
  position: absolute;
  left: 10px;
  right: 10px;
  bottom: 10px;
  padding: 8px 10px;
  border-radius: 8px;
  background: rgba(3, 8, 6, 0.84);
  color: #e2e8f0;
  font-size: 14px;
}

.controls,
.handoff-panel {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.result-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.scan-detail-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

#gtinRoomDetailSheet .scan-detail-actions {
  grid-template-columns: 1fr;
}

#gtinRoomDetailSheet .scan-detail-actions button {
  min-height: 44px;
  white-space: nowrap;
}

.handoff-panel {
  margin-top: 10px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

body[data-camera-active="true"] #startButton,
body:not([data-camera-active="true"]) #stopButton {
  display: none;
}

.review-panel,
.manual-panel {
  display: grid;
  gap: 10px;
}

.scanner-more-actions,
.manual-entry-details {
  display: block;
}

.scanner-more-actions > summary,
.manual-entry-details > summary {
  min-height: 48px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: var(--text);
}

.scanner-more-actions > summary,
.manual-entry-details > summary {
  color: var(--accent-strong);
}

.review-text {
  margin: 0;
  color: var(--muted);
}

.review-actions {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 0.7fr);
  gap: 8px;
}

.manual-panel textarea {
  width: 100%;
  resize: vertical;
  min-height: 74px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--text);
  font: inherit;
  padding: 10px;
}

.panel-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

.queue-list {
  list-style: none;
  margin: 10px 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.queue-item {
  display: grid;
  gap: 10px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
  cursor: pointer;
}

.queue-item[data-selected="true"] {
  border-color: #2563eb;
  background: #eff6ff;
  box-shadow: inset 3px 0 0 #2563eb;
}

.queue-item:focus-visible {
  outline: 3px solid rgba(37, 99, 235, 0.22);
  outline-offset: 2px;
}

.queue-meta {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.queue-raw {
  color: var(--accent-strong);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.queue-details {
  color: var(--muted);
  font-size: 12px;
}

.queue-verify {
  width: fit-content;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 8px;
  color: var(--muted);
  font-size: 12px;
}

.queue-verify.matched,
.queue-verify.registered,
.queue-verify.success,
.queue-verify.info {
  color: #1d4ed8;
  border-color: #93c5fd;
  background: var(--accent-soft);
}

.queue-verify.unregistered,
.queue-verify.ambiguous,
.queue-verify.error,
.queue-verify.warning {
  color: #991b1b;
  border-color: #fecaca;
  background: var(--danger-soft);
}

.empty-state {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

.scan-card,
pre {
  margin: 0;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
  padding: 10px;
  font-size: 13px;
}

.scan-card {
  display: grid;
  gap: 10px;
}

.placeholder-card {
  color: var(--muted);
}

.scan-card-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-weight: 800;
}

.scan-card-title small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.selected-scan-summary {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
}

.selected-scan-token {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #ffffff;
  color: var(--text);
  padding: 6px 8px;
  font-size: 12px;
  font-weight: 800;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.selected-scan-identity {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.scan-field-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.scan-field {
  min-height: 58px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.scan-field span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.scan-field strong {
  display: block;
  margin-top: 4px;
  overflow-wrap: anywhere;
  font-size: 15px;
}

.scan-field.important {
  border-color: #93c5fd;
  background: var(--accent-soft);
}

.scan-field.warn {
  border-color: #fdba74;
  background: var(--warn-soft);
}

.raw-text {
  max-height: 70px;
  overflow: auto;
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  font-size: 12px;
}

.operation-review-panel {
  display: grid;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  padding: 10px;
}

.operation-review-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.operation-review-heading h3 {
  margin: 2px 0 0;
  font-size: 16px;
}

.operation-plan-state {
  flex: 0 0 auto;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #f8fafc;
  color: var(--muted);
  padding: 5px 8px;
  font-size: 12px;
  font-weight: 800;
}

.operation-plan-state[data-state="ok"] {
  border-color: #93c5fd;
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.operation-plan-state[data-state="pending"] {
  border-color: #fdba74;
  background: var(--warn-soft);
  color: #92400e;
}

.operation-plan-state[data-state="warn"],
.operation-plan-state[data-state="error"] {
  border-color: #fecaca;
  background: var(--danger-soft);
  color: #991b1b;
}

.operation-change-summary {
  display: grid;
  gap: 6px;
}

.operation-summary-row {
  display: grid;
  grid-template-columns: minmax(86px, auto) minmax(0, 1fr);
  gap: 8px;
  align-items: start;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
  padding: 8px;
}

.operation-summary-row span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.operation-summary-row strong {
  overflow-wrap: anywhere;
  font-size: 13px;
}

.operation-summary-row.important {
  border-color: #93c5fd;
  background: var(--accent-soft);
}

.operation-summary-row.warn {
  border-color: #fdba74;
  background: var(--warn-soft);
}

.operation-advanced-details {
  border: 0;
  padding: 0;
}

.operation-advanced-details > summary {
  cursor: pointer;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.mapping-panel {
  gap: 10px;
}

.mapping-panel h2 {
  margin: 0;
  font-size: 17px;
}

.mapping-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 96px;
  gap: 8px;
  align-items: end;
}

.mapping-grid label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}

.mapping-grid input {
  min-height: 46px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--text);
  font: inherit;
  padding: 0 12px;
}

.mapping-results {
  display: grid;
  gap: 8px;
}

.mapping-group-panel {
  display: grid;
  gap: 8px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
}

.mapping-group-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}

.mapping-group-row > span {
  min-width: 64px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.mapping-group-chip {
  min-height: 32px;
  padding: 0 9px;
  border-radius: 999px;
  background: #ffffff;
  color: var(--text);
  font-size: 12px;
}

.mapping-group-chip[data-active="true"] {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.mapping-choice {
  display: grid;
  gap: 3px;
  width: 100%;
  min-height: 58px;
  padding: 9px 10px;
  justify-items: start;
  text-align: left;
}

.mapping-choice[data-selected="true"] {
  border-color: #93c5fd;
  background: var(--accent-soft);
}

.mapping-choice span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.mapping-choice small {
  color: #1e3a8a;
  font-size: 11px;
  font-weight: 700;
  line-height: 1.3;
}

.mapping-selection {
  display: grid;
  gap: 4px;
  border: 1px solid #93c5fd;
  border-radius: 8px;
  background: var(--accent-soft);
  padding: 10px;
}

.mapping-selection strong {
  overflow-wrap: anywhere;
  font-size: 15px;
}

.mapping-selection span {
  color: #1e3a8a;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.mapping-message {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

pre {
  white-space: pre-wrap;
  word-break: break-word;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}

@media (max-width: 640px) {
  .scanner-shell {
    padding: 8px;
    gap: 8px;
  }

  .topbar,
  .intent-context-panel,
  .scan-feedback {
    padding: 8px 10px;
  }

  h1 {
    font-size: 20px;
  }

  .scanner-back-button {
    min-width: 84px;
  }

  .home-link {
    min-height: 38px;
    font-size: 13px;
  }

  .controls,
  .handoff-panel,
  .review-actions,
  .scan-field-grid,
  .operation-summary-row,
  .mapping-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .queue-item {
    grid-template-columns: 1fr;
  }

  .intent-context-panel {
    align-items: flex-start;
    flex-direction: row;
  }
}

@media (max-width: 380px) {
  .controls,
  .handoff-panel,
  .review-actions,
  .scan-field-grid,
  .operation-summary-row,
  .mapping-grid {
    grid-template-columns: 1fr;
  }
}

/* NOVA scanner visual polish v2: selected-scan UI only, no intent contract changes. */
:root {
  --surface: #ffffff;
  --surface-soft: #f8fafc;
  --text: #111827;
  --text-sub: #6b7280;
  --text-muted: #9ca3af;
  --line: #e5e7eb;
  --line-soft: #f1f5f9;
  --primary: #2563eb;
  --primary-soft: #eff6ff;
  --warning: #f59e0b;
  --warning-soft: #fffbeb;
  --danger: #ef4444;
  --danger-soft: #fef2f2;
  --success: #10b981;
  --success-soft: #ecfdf5;
  --radius-card: 20px;
  --radius-sheet: 24px;
  --radius-button: 14px;
  --radius-chip: 999px;
  --panel: var(--surface);
  --panel-soft: var(--surface-soft);
  --muted: var(--text-sub);
  --accent: var(--primary);
  --accent-strong: #1d4ed8;
  --accent-soft: var(--primary-soft);
  --warn: var(--warning);
  --warn-soft: var(--warning-soft);
  --shadow: 0 -12px 34px rgba(15, 23, 42, 0.12);
}

body {
  color: var(--text);
}

button,
.home-link {
  border: 0;
  border-radius: var(--radius-button);
  background: #f3f4f6;
  color: var(--text);
  font-size: 15px;
  font-weight: 700;
  box-shadow: none;
}

button.primary {
  min-height: 48px;
  background: var(--primary);
  color: #ffffff;
  font-weight: 800;
}

button.warning,
button.return-button,
.context-change-link,
.home-link {
  background: #f3f4f6;
  color: var(--text);
}

button.danger {
  background: var(--danger-soft);
  color: #b91c1c;
  font-weight: 800;
}

button:disabled,
button.primary:disabled,
button.warning:disabled,
button.return-button:disabled,
button.danger:disabled {
  background: #f3f4f6;
  color: var(--text-muted);
}

.scanner-shell {
  gap: 10px;
  padding: 8px;
}

.topbar,
.intent-context-panel,
.scan-feedback,
.controls,
.scanner-more-actions,
.review-panel,
.manual-panel,
.queue-panel,
.result-panel,
.operation-review-panel,
.scan-card,
.mapping-group-panel,
.mapping-selection {
  border: 0;
  border-radius: var(--radius-card);
  background: var(--surface);
  box-shadow: none;
}

.topbar {
  min-height: 58px;
  padding: 10px 12px;
}

.topbar > div {
  grid-template-columns: auto minmax(0, 1fr);
}

.eyebrow,
.label {
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 600;
  line-height: 1.3;
  text-transform: none;
}

h1 {
  font-size: 22px;
  font-weight: 800;
  line-height: 1.2;
}

.mode-badge,
.pill,
.queue-verify,
.operation-plan-state {
  min-height: 24px;
  padding: 3px 9px;
  border: 0;
  border-radius: var(--radius-chip);
  background: #f3f4f6;
  color: var(--text-sub);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.mode-badge {
  max-width: min(160px, 100%);
}

.intent-context-panel {
  align-items: center;
  padding: 10px 12px;
  background: var(--primary-soft);
}

.intent-context-panel strong {
  font-size: 15px;
  line-height: 1.25;
}

.intent-context-panel span {
  color: var(--text-sub);
  font-size: 12px;
}

.context-change-link {
  min-height: 36px;
  border-radius: 12px;
  color: var(--primary);
}

.intent-picker-list {
  border: 0;
  border-radius: 16px;
  box-shadow: 0 10px 26px rgba(15, 23, 42, 0.12);
}

.intent-picker-list button {
  min-height: 40px;
  border-radius: 12px;
}

.scan-feedback {
  padding: 10px 12px;
}

.scan-feedback strong {
  font-size: 16px;
}

.scan-feedback span,
.review-text,
.mapping-message,
.empty-state,
.queue-details,
.selected-scan-identity {
  color: var(--text-sub);
  font-size: 13px;
  line-height: 1.45;
}

.scan-feedback[data-state="success"] {
  background: var(--success-soft);
}

.scan-feedback[data-state="success"] strong {
  color: #047857;
}

.scan-feedback[data-state="error"] {
  background: var(--danger-soft);
}

.camera-panel {
  min-height: 260px;
  border: 0;
  border-radius: var(--radius-card);
}

video {
  height: min(48vh, 460px);
  min-height: 260px;
}

.reticle,
.status {
  border-radius: 14px;
}

.controls {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  padding: 8px;
}

.handoff-panel,
.scan-detail-actions,
.result-actions,
.review-actions {
  grid-template-columns: 1fr;
  gap: 8px;
}

.scanner-more-actions > summary,
.manual-entry-details > summary {
  min-height: 44px;
  color: var(--text);
}

.manual-panel textarea,
.mapping-grid input,
input,
select,
textarea {
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: var(--radius-button);
  color: var(--text);
  font-size: 15px;
}

dialog.bottom-sheet {
  width: min(720px, calc(100% - 16px));
  max-height: 86dvh;
  margin: auto auto 8px;
  padding: 16px;
  border: 0;
  border-radius: var(--radius-sheet) var(--radius-sheet) 0 0;
  box-shadow: var(--shadow);
}

.sheet-heading {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  margin-bottom: 14px;
}

.sheet-heading h2,
.mapping-panel h2 {
  font-size: 20px;
  line-height: 1.25;
}

.sheet-heading button,
.sheet-heading-actions button {
  min-height: 40px;
  border-radius: 12px;
  background: transparent;
  color: var(--text-sub);
}

.queue-list {
  gap: 10px;
}

.queue-item {
  gap: 8px;
  padding: 14px;
  border: 0;
  border-radius: var(--radius-card);
  background: var(--surface-soft);
}

.queue-item[data-selected="true"] {
  background: var(--primary-soft);
  box-shadow: inset 4px 0 0 var(--primary);
}

.queue-title {
  color: var(--text);
  font-size: 15px;
  font-weight: 800;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.queue-raw {
  color: var(--text-sub);
  font-family: inherit;
  font-size: 12px;
}

.queue-meta {
  gap: 6px;
}

.queue-verify {
  width: fit-content;
}

.queue-verify.matched,
.queue-verify.registered {
  background: var(--primary-soft);
  color: var(--primary);
}

.queue-verify.unregistered,
.queue-verify.ambiguous {
  background: var(--warning-soft);
  color: #92400e;
}

.queue-verify.error {
  background: var(--danger-soft);
  color: #b91c1c;
}

.scan-card {
  padding: 12px;
}

.scan-card-title {
  align-items: flex-start;
}

.selected-scan-summary,
.scan-field-grid {
  grid-template-columns: 1fr;
  gap: 8px;
}

.selected-scan-token,
.scan-field,
.operation-summary-row {
  border: 0;
  border-radius: 14px;
  background: var(--surface-soft);
}

.scan-field.important,
.operation-summary-row.important {
  background: var(--primary-soft);
}

.scan-field.warn,
.operation-summary-row.warn {
  background: var(--warning-soft);
}

.operation-review-heading {
  align-items: flex-start;
}

.operation-plan-state[data-state="ok"] {
  background: var(--success-soft);
  color: #047857;
}

.operation-plan-state[data-state="pending"],
.operation-plan-state[data-state="warn"] {
  background: var(--warning-soft);
  color: #92400e;
}

.operation-plan-state[data-state="error"] {
  background: var(--danger-soft);
  color: #b91c1c;
}

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

.mapping-choice {
  border: 0;
  border-radius: 16px;
  background: var(--surface-soft);
}

.mapping-choice[data-selected="true"] {
  background: var(--primary-soft);
}

.mapping-group-chip {
  border: 0;
  border-radius: var(--radius-chip);
}

@media (min-width: 560px) {
  .handoff-panel,
  .scan-detail-actions,
  .result-actions,
  .review-actions,
  .scan-field-grid,
  .selected-scan-summary,
  .mapping-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 559px) {
  .scanner-shell {
    padding: 8px;
  }

  .topbar,
  .intent-context-panel {
    align-items: stretch;
  }

  .topbar {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .scanner-back-button {
    min-width: 78px;
  }

  .intent-context-panel {
    gap: 8px;
  }

  .intent-picker-list {
    grid-template-columns: 1fr;
  }

  .controls,
  .handoff-panel,
  .scan-detail-actions,
  .result-actions,
  .review-actions,
  .scan-field-grid,
  .selected-scan-summary,
  .operation-summary-row,
  .mapping-grid {
    grid-template-columns: 1fr;
  }
}
