:root {
  color-scheme: dark;
  --bg: #111827;
  --panel: rgba(17, 24, 39, 0.82);
  --panel-solid: #172033;
  --line: rgba(255, 255, 255, 0.16);
  --text: #f8fafc;
  --muted: #a8b3c7;
  --accent: #10b981;
  --accent-strong: #34d399;
  --warn: #f59e0b;
  --danger: #ef4444;
  --shadow: 0 20px 80px rgba(0, 0, 0, 0.34);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
  margin: 0;
  background: var(--bg);
  color: var(--text);
}

body {
  overflow-x: hidden;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  display: block;
  min-height: 100svh;
  background:
    linear-gradient(135deg, rgba(16, 185, 129, 0.12), rgba(59, 130, 246, 0.08)),
    #0f172a;
}

.scanner {
  position: relative;
  min-height: 100svh;
  overflow: hidden;
  background: #020617;
}

.camera,
.overlay {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.camera {
  object-fit: cover;
  background: #020617;
}

.overlay {
  pointer-events: none;
}

.topbar,
.controls,
.match-panel,
.camera-empty {
  position: absolute;
}

.topbar {
  z-index: 4;
}

.controls {
  z-index: 5;
}

.match-panel {
  z-index: 3;
}

.camera-empty {
  z-index: 10;
}

.topbar {
  top: max(18px, env(safe-area-inset-top));
  left: max(18px, env(safe-area-inset-left));
  right: max(18px, env(safe-area-inset-right));
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
}

.kicker {
  margin: 0 0 4px;
  color: var(--accent-strong);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(22px, 3vw, 36px);
  line-height: 1;
  letter-spacing: 0;
  text-shadow: 0 3px 20px rgba(0, 0, 0, 0.45);
}

.status-pill {
  flex: 0 0 auto;
  min-width: 126px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(15, 23, 42, 0.72);
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  text-align: center;
  backdrop-filter: blur(12px);
}

.status-pill.is-ready {
  color: #d1fae5;
  border-color: rgba(16, 185, 129, 0.46);
  background: rgba(6, 78, 59, 0.58);
}

.status-pill.is-error {
  color: #fee2e2;
  border-color: rgba(239, 68, 68, 0.42);
  background: rgba(127, 29, 29, 0.58);
}

.camera-empty {
  left: 50%;
  top: 50%;
  width: min(430px, calc(100vw - 36px));
  transform: translate(-50%, -50%);
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(15, 23, 42, 0.78);
  box-shadow: var(--shadow);
  text-align: center;
  backdrop-filter: blur(18px);
}

.camera-empty.is-hidden {
  display: none;
}

.camera-mark {
  width: 68px;
  height: 50px;
  margin: 0 auto 18px;
  border: 3px solid var(--accent-strong);
  border-radius: 8px;
  position: relative;
}

.camera-mark::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 18px;
  height: 18px;
  border: 3px solid var(--accent-strong);
  border-radius: 50%;
  transform: translate(-50%, -50%);
}

.camera-empty h2 {
  margin-bottom: 8px;
  font-size: 26px;
}

.camera-empty p {
  color: var(--muted);
  line-height: 1.5;
}

.camera-debug {
  display: none;
}

.primary-action,
.details-link,
.cart-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  border: 0;
  border-radius: 8px;
  padding: 0 18px;
  background: var(--accent);
  color: #032012;
  font-weight: 900;
  text-decoration: none;
}

.primary-action:disabled,
.cart-action:disabled {
  cursor: progress;
  opacity: 0.72;
}

.scan-frame {
  position: absolute;
  z-index: 1;
  left: var(--scan-left, 50%);
  top: var(--scan-top, 47%);
  width: var(--scan-size, min(62vh, 62vw));
  aspect-ratio: 1;
  transform: translate(-50%, -50%);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.08);
  pointer-events: none;
  opacity: 0;
  transition:
    left 220ms ease,
    top 220ms ease,
    width 220ms ease,
    opacity 180ms ease,
    border-color 180ms ease,
    box-shadow 180ms ease;
}

body.camera-active .scan-frame {
  opacity: 1;
}

.scan-frame span {
  position: absolute;
  width: 54px;
  height: 54px;
  border-color: var(--accent-strong);
  transition: border-color 180ms ease;
}

.scan-frame.is-searching {
  border-color: rgba(96, 165, 250, 0.5);
  box-shadow:
    0 0 0 1px rgba(96, 165, 250, 0.16),
    0 0 28px rgba(96, 165, 250, 0.18);
}

.scan-frame.is-qr {
  border-color: rgba(227, 6, 43, 0.78);
  box-shadow:
    0 0 0 1px rgba(227, 6, 43, 0.18),
    0 0 34px rgba(227, 6, 43, 0.34);
}

.scan-frame.is-visual {
  border-color: rgba(29, 44, 140, 0.7);
  box-shadow:
    0 0 0 1px rgba(29, 44, 140, 0.16),
    0 0 30px rgba(29, 44, 140, 0.22);
}

.scan-frame.is-uncertain {
  border-color: rgba(245, 158, 11, 0.84);
  box-shadow:
    0 0 0 1px rgba(245, 158, 11, 0.16),
    0 0 34px rgba(245, 158, 11, 0.28);
}

.scan-frame.is-confirmed {
  border-color: rgba(18, 183, 106, 0.86);
  box-shadow:
    0 0 0 1px rgba(18, 183, 106, 0.16),
    0 0 38px rgba(18, 183, 106, 0.36);
}

.scan-frame.is-confirmed.is-confirm-qr {
  border-color: rgba(227, 6, 43, 0.92);
  box-shadow:
    0 0 0 1px rgba(227, 6, 43, 0.2),
    0 0 42px rgba(227, 6, 43, 0.44);
}

.scan-frame.is-confirmed.is-confirm-visual {
  border-color: rgba(18, 183, 106, 0.92);
  box-shadow:
    0 0 0 1px rgba(18, 183, 106, 0.18),
    0 0 42px rgba(18, 183, 106, 0.4);
}

.scan-frame.is-searching span,
.scan-frame.is-visual span {
  border-color: #ffffff;
}

.scan-frame.is-uncertain span {
  border-color: var(--warn);
}

.scan-frame.is-qr span {
  border-color: var(--accent);
}

.scan-frame.is-confirmed span {
  border-color: #12b76a;
}

.scan-frame.is-confirmed.is-confirm-qr span {
  border-color: var(--accent);
}

.scan-frame.is-snap {
  animation: reticleSnap 420ms cubic-bezier(0.22, 1, 0.36, 1);
}

.scan-frame.is-snap.is-confirm-qr {
  animation: reticleQrSnap 360ms cubic-bezier(0.2, 1, 0.32, 1);
}

.scan-frame.is-uncertain .scan-beam {
  background: linear-gradient(90deg, transparent, rgba(245, 158, 11, 0.94), transparent);
  box-shadow: 0 0 18px rgba(245, 158, 11, 0.62);
  animation-duration: 2.8s;
}

.scan-beam {
  position: absolute;
  left: 10%;
  right: 10%;
  top: 12%;
  height: 3px;
  border-radius: 999px;
  background: linear-gradient(90deg, transparent, rgba(52, 211, 153, 0.95), transparent);
  box-shadow: 0 0 22px rgba(52, 211, 153, 0.9);
  animation: scanBeam 2.2s ease-in-out infinite;
}

@keyframes scanBeam {
  0% {
    transform: translateY(0);
    opacity: 0.25;
  }
  18%,
  82% {
    opacity: 1;
  }
  100% {
    transform: translateY(42vh);
    opacity: 0.25;
  }
}

@keyframes reticleSnap {
  0% {
    transform: translate(-50%, -50%) scale(0.92);
  }

  58% {
    transform: translate(-50%, -50%) scale(1.05);
  }

  100% {
    transform: translate(-50%, -50%) scale(1);
  }
}

@keyframes reticleQrSnap {
  0% {
    transform: translate(-50%, -50%) scale(0.88);
  }

  52% {
    transform: translate(-50%, -50%) scale(1.08);
  }

  100% {
    transform: translate(-50%, -50%) scale(1);
  }
}

@keyframes matchPanelEnter {
  0% {
    opacity: 0;
    transform: translate3d(var(--track-x, 0), calc(var(--track-y, 0) + 14px), 0) scale(0.96);
    filter: blur(2px);
  }

  100% {
    opacity: 1;
    transform: translate3d(var(--track-x, 0), var(--track-y, 0), 0) scale(1);
    filter: blur(0);
  }
}

.scan-frame span:nth-child(1) {
  left: -1px;
  top: -1px;
  border-top: 4px solid;
  border-left: 4px solid;
  border-radius: 8px 0 0;
}

.scan-frame span:nth-child(2) {
  right: -1px;
  top: -1px;
  border-top: 4px solid;
  border-right: 4px solid;
  border-radius: 0 8px 0 0;
}

.scan-frame span:nth-child(3) {
  right: -1px;
  bottom: -1px;
  border-right: 4px solid;
  border-bottom: 4px solid;
  border-radius: 0 0 8px;
}

.scan-frame span:nth-child(4) {
  left: -1px;
  bottom: -1px;
  border-left: 4px solid;
  border-bottom: 4px solid;
  border-radius: 0 0 0 8px;
}

.scan-status {
  position: absolute;
  z-index: 4;
  left: 50%;
  top: calc(47% + min(31vh, 31vw) + 16px);
  transform: translateX(-50%);
  min-width: 170px;
  max-width: calc(100vw - 36px);
  padding: 10px 14px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  background: rgba(15, 23, 42, 0.78);
  color: #f8fafc;
  font-size: 13px;
  font-weight: 900;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease, background 180ms ease;
  backdrop-filter: blur(12px);
}

body.camera-active .scan-status {
  opacity: 1;
}

.scan-status.is-good {
  background: rgba(6, 78, 59, 0.84);
  border-color: rgba(52, 211, 153, 0.58);
}

.scan-status.is-checking {
  background: rgba(30, 64, 175, 0.82);
  border-color: rgba(96, 165, 250, 0.58);
}

.scan-status.is-unknown {
  background: rgba(120, 53, 15, 0.82);
  border-color: rgba(245, 158, 11, 0.58);
}

.controls {
  display: grid;
  gap: 10px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease;
}

body.camera-active .controls {
  opacity: 1;
  pointer-events: auto;
}

.icon-button {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(15, 23, 42, 0.78);
  color: var(--text);
  font-size: 20px;
  font-weight: 900;
  line-height: 1;
  text-decoration: none;
  backdrop-filter: blur(14px);
}

.icon-button.is-active {
  border-color: rgba(16, 185, 129, 0.62);
  color: var(--accent-strong);
}

.icon-button.is-hidden {
  display: none;
}

.match-panel {
  left: var(--ar-left, max(18px, env(safe-area-inset-left)));
  top: var(--ar-top, auto);
  right: auto;
  bottom: auto;
  display: grid;
  grid-template-columns: 96px minmax(0, 1fr);
  gap: 14px;
  width: min(386px, calc(100vw - 28px));
  padding: 12px;
  border: 1px solid rgba(52, 211, 153, 0.48);
  border-radius: 12px;
  background: rgba(15, 23, 42, 0.9);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.match-panel.is-opening {
  animation: matchPanelEnter 480ms cubic-bezier(0.22, 1, 0.36, 1);
}

.match-panel::after {
  content: "";
  position: absolute;
  left: var(--ar-anchor, 50%);
  bottom: -18px;
  width: 2px;
  height: 18px;
  background: var(--accent-strong);
  box-shadow: 0 0 14px rgba(52, 211, 153, 0.9);
}

.scan-history {
  position: absolute;
  z-index: 7;
  left: max(18px, env(safe-area-inset-left));
  right: max(18px, env(safe-area-inset-right));
  bottom: max(18px, env(safe-area-inset-bottom));
  display: grid;
  justify-items: center;
  gap: 10px;
  pointer-events: none;
}

.tray-backdrop {
  position: fixed;
  z-index: 0;
  inset: 0;
  border: 0;
  background: rgba(2, 6, 23, 0.2);
  pointer-events: auto;
}

.tray-backdrop.is-hidden {
  display: none;
}

.scan-shelf {
  position: relative;
  z-index: 1;
  width: min(540px, 100%);
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(15, 23, 42, 0.78);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
  pointer-events: auto;
  animation: trayModalIn 180ms ease-out;
}

.scan-shelf.is-hidden {
  display: none;
}

.scan-shelf-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.scan-shelf-head strong {
  font-size: 12px;
  letter-spacing: 0;
}

.scan-shelf-head a {
  color: var(--accent-strong);
  font-size: 12px;
  font-weight: 850;
  text-decoration: none;
}

.scan-history-list {
  display: grid;
  gap: 8px;
  max-width: 100%;
  max-height: 220px;
  overflow: auto;
}

.history-item {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr);
  grid-template-rows: auto auto;
  column-gap: 8px;
  align-items: center;
  width: 100%;
  min-height: 54px;
  padding: 7px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(15, 23, 42, 0.82);
  color: var(--text);
  text-align: left;
  pointer-events: auto;
  backdrop-filter: blur(14px);
}

.history-item img {
  grid-row: 1 / 3;
  width: 38px;
  height: 38px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
  object-fit: cover;
}

.history-item span,
.history-item strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-item span {
  font-size: 12px;
  font-weight: 850;
}

.history-item strong {
  color: var(--accent-strong);
  font-size: 10px;
  letter-spacing: 0;
  text-transform: uppercase;
}

.tray-empty {
  min-height: 40px;
  display: grid;
  align-items: center;
  padding: 0 10px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

.tray-close {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.9);
  color: var(--text);
}

.tray-close svg,
.scan-toolbar svg {
  width: 24px;
  height: 24px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.tray-buy {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 44px;
  margin-top: 10px;
  border: 0;
  border-radius: 12px;
  background: var(--accent-strong);
  color: #ffffff;
  font-size: 14px;
  font-weight: 900;
  box-shadow: 0 10px 22px rgba(227, 6, 43, 0.22);
}

.tray-buy:disabled {
  cursor: default;
  opacity: 0.5;
}

.scan-toolbar {
  position: relative;
  z-index: 2;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 58px minmax(0, 1fr);
  align-items: end;
  gap: 8px;
  width: min(360px, 100%);
  min-height: 62px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(15, 23, 42, 0.82);
  box-shadow: 0 14px 34px rgba(2, 6, 23, 0.26);
  backdrop-filter: blur(18px);
  pointer-events: auto;
}

.scan-toolbar-item,
.scan-toolbar-camera {
  position: relative;
  border: 0;
  color: var(--text);
}

.scan-toolbar-item {
  display: grid;
  justify-items: center;
  gap: 2px;
  min-height: 46px;
  padding: 5px 4px;
  border-radius: 12px;
  background: transparent;
}

.scan-toolbar-item span {
  display: grid;
  place-items: center;
  line-height: 1;
}

.scan-toolbar-item strong {
  font-size: 10px;
  line-height: 1;
}

.scan-toolbar-item em {
  position: absolute;
  top: 2px;
  right: 10px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--accent-strong);
  color: #ffffff;
  font-size: 10px;
  font-style: normal;
  font-weight: 900;
  line-height: 18px;
}

.scan-toolbar-item.is-active {
  background: rgba(255, 255, 255, 0.1);
}

.scan-toolbar-camera {
  display: grid;
  place-items: center;
  width: 58px;
  height: 58px;
  border-radius: 999px;
  background: var(--accent-strong);
  color: #ffffff;
  box-shadow: 0 12px 28px rgba(227, 6, 43, 0.32);
}

.scan-toolbar-camera span {
  display: grid;
  place-items: center;
  line-height: 1;
}

.scan-toolbar-camera svg {
  width: 31px;
  height: 31px;
}

@keyframes trayModalIn {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.match-panel.is-hidden {
  display: none;
}

.match-media {
  width: 96px;
  aspect-ratio: 1;
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.92);
}

.match-media img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.match-copy {
  min-width: 0;
}

.match-head {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: center;
}

.confidence,
.code,
.facts dt,
.product-card small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.confidence {
  max-width: 168px;
  padding: 4px 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.confidence.is-good {
  color: var(--accent-strong);
}

.confidence.is-low {
  color: var(--warn);
}

.match-copy h2 {
  margin: 7px 0 8px;
  font-size: 16px;
  line-height: 1.15;
  overflow-wrap: anywhere;
}

.match-copy p {
  display: none;
  margin-bottom: 12px;
  color: #d9e2f1;
  line-height: 1.4;
}

.facts {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  margin: 0 0 10px;
}

.facts div {
  min-width: 0;
  padding: 7px 9px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.05);
}

.facts div:nth-child(3) {
  display: none;
}

.facts div:first-child {
  grid-row: span 2;
}

.facts dt,
.facts dd {
  margin: 0;
}

.facts dd {
  margin-top: 3px;
  font-weight: 900;
  overflow-wrap: anywhere;
}

.facts div:first-child dd {
  font-size: 20px;
  line-height: 1.05;
}

#matchStock {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 2px 8px;
  border-radius: 999px;
}

#matchStock.is-available {
  background: rgba(18, 183, 106, 0.14);
  color: #12b76a;
}

#matchStock.is-unavailable {
  background: rgba(245, 158, 11, 0.14);
  color: var(--warn);
}

.catalog-panel {
  display: none;
  flex-direction: column;
  gap: 16px;
  max-height: 100vh;
  padding: 18px;
  border-left: 1px solid var(--line);
  background: var(--panel-solid);
  overflow: auto;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
}

.panel-header h2 {
  margin: 0;
  font-size: 22px;
}

#productCount {
  min-width: 44px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  text-align: center;
  font-weight: 900;
}

.search-field {
  display: grid;
  gap: 6px;
}

.search-field span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.search-field input {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  background: rgba(2, 6, 23, 0.36);
  color: var(--text);
  outline: none;
}

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

.candidate {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 10px;
  border: 1px solid rgba(16, 185, 129, 0.28);
  border-radius: 8px;
  background: rgba(16, 185, 129, 0.08);
  color: #d1fae5;
  font-size: 13px;
}

.product-list {
  display: grid;
  gap: 10px;
}

.product-card {
  display: grid;
  grid-template-columns: 58px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  width: 100%;
  min-height: 76px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  text-align: left;
}

.product-card:hover,
.product-card.is-selected {
  border-color: rgba(52, 211, 153, 0.64);
  background: rgba(16, 185, 129, 0.1);
}

.product-card img {
  width: 58px;
  height: 58px;
  border-radius: 8px;
  object-fit: cover;
  background: rgba(255, 255, 255, 0.06);
}

.product-card strong {
  display: block;
  margin-bottom: 5px;
  line-height: 1.22;
  overflow-wrap: anywhere;
}

.product-card small {
  display: block;
  line-height: 1.35;
}

@media (max-width: 920px) {
  .app-shell {
    min-height: 100svh;
  }

  .scanner {
    min-height: 100svh;
  }

  .scan-frame {
    width: min(68vw, 46vh);
  }
}

@media (max-width: 640px) {
  h1 {
    font-size: 22px;
  }

  .topbar {
    align-items: flex-start;
  }

  .status-pill {
    min-width: 104px;
    padding: 8px 9px;
    font-size: 11px;
  }

  .controls {
    top: auto;
    right: max(14px, env(safe-area-inset-right));
    bottom: max(18px, env(safe-area-inset-bottom));
    grid-auto-flow: column;
    grid-template-columns: repeat(3, 44px);
  }

  .icon-button {
    width: 44px;
    height: 44px;
  }

  .match-panel {
    grid-template-columns: 96px minmax(0, 1fr);
    gap: 12px;
    padding: 12px;
  }

  .match-media {
    width: 96px;
  }

  .match-copy h2 {
    font-size: 16px;
  }

  .match-copy p {
    display: none;
  }

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

  .match-actions {
    grid-column: 1 / -1;
  }

  .details-link,
  .cart-action {
    min-height: 38px;
    width: 100%;
  }
}

/* CDO ecommerce visual layer. CSS only: no scan/camera behavior changes. */
:root {
  color-scheme: light;
  --bg: #ffffff;
  --panel: rgba(255, 255, 255, 0.92);
  --panel-solid: #ffffff;
  --line: rgba(29, 44, 140, 0.14);
  --text: #1d2c8c;
  --muted: #667085;
  --accent: #e3062b;
  --accent-strong: #e3062b;
  --warn: #f79009;
  --danger: #e3062b;
  --cdo-blue: #1d2c8c;
  --cdo-blue-strong: #24379f;
  --cdo-surface: #eef2ff;
  --shadow: 0 18px 48px rgba(29, 44, 140, 0.18);
  font-family: Inter, Manrope, Poppins, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

html,
body {
  background:
    linear-gradient(180deg, rgba(29, 44, 140, 0.08), transparent 300px),
    linear-gradient(135deg, rgba(227, 6, 43, 0.06), transparent 360px),
    #ffffff;
  color: var(--text);
}

.app-shell {
  width: min(100%, 920px);
  margin: 0 auto;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 0 0 1px rgba(29, 44, 140, 0.06);
}

.scanner {
  background:
    linear-gradient(180deg, rgba(29, 44, 140, 0.08), transparent 280px),
    #ffffff;
}

.scanner::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background:
    linear-gradient(180deg, rgba(7, 12, 45, 0.58), rgba(7, 12, 45, 0.14) 34%, rgba(7, 12, 45, 0.5)),
    linear-gradient(135deg, rgba(29, 44, 140, 0.32), rgba(227, 6, 43, 0.18));
  opacity: 0;
  transition: opacity 180ms ease;
}

body.camera-active .scanner::before {
  opacity: 0;
}

.camera {
  background:
    linear-gradient(135deg, rgba(29, 44, 140, 0.1), rgba(227, 6, 43, 0.06)),
    #f8faff;
}

.topbar {
  z-index: 6;
  top: max(12px, env(safe-area-inset-top));
  left: 50%;
  right: auto;
  width: min(360px, calc(100vw - 28px));
  transform: translateX(-50%);
  display: block;
  align-items: center;
}

.topbar > div:first-child {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  min-width: 0;
  min-height: 50px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 10px 24px rgba(29, 44, 140, 0.12);
  backdrop-filter: blur(18px);
}

.topbar .controls {
  position: static;
  display: none;
  grid-auto-flow: column;
  grid-template-columns: repeat(3, 34px);
  gap: 6px;
  opacity: 1;
  pointer-events: auto;
  transition: none;
}

body.camera-active .topbar .status-pill {
  display: none;
}

body.camera-active .topbar .controls {
  display: grid;
}

.topbar > div:first-child::before {
  content: "";
  display: block;
  flex: 0 0 auto;
  width: clamp(96px, 26vw, 126px);
  height: 34px;
  background: url("/Logo-co-png.png") left center / contain no-repeat;
}

.kicker {
  display: none;
}

.topbar h1 {
  display: none;
}

.status-pill {
  display: grid;
  place-items: center;
  min-width: 108px;
  max-width: 118px;
  min-height: 34px;
  padding: 7px 9px;
  border-color: var(--line);
  border-radius: 12px;
  background: rgba(29, 44, 140, 0.06);
  color: var(--muted);
  font-size: 11px;
  line-height: 1.15;
  box-shadow: none;
}

.status-pill.is-ready {
  color: #067647;
  border-color: #abefc6;
  background: #dcfae6;
}

.status-pill.is-error {
  color: #b42318;
  border-color: #fecdca;
  background: #fef3f2;
}

.topbar .icon-button {
  width: 34px;
  height: 34px;
  border-radius: 12px;
  background: rgba(29, 44, 140, 0.06);
  color: var(--cdo-blue);
  font-size: 16px;
  box-shadow: none;
}

.topbar .icon-button.is-active {
  background: var(--accent);
  color: #ffffff;
}

.topbar .icon-button.is-hidden {
  display: none;
}

.camera-empty {
  z-index: 8;
  width: min(430px, calc(100vw - 32px));
  padding: 24px;
  border-color: rgba(29, 44, 140, 0.14);
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.94);
  color: var(--cdo-blue);
  box-shadow: var(--shadow);
}

.camera-empty::before {
  content: none;
}

.camera-empty h2 {
  margin-bottom: 8px;
  color: var(--cdo-blue);
  font-size: 28px;
  line-height: 1.05;
}

.camera-empty p {
  color: var(--muted);
  font-size: 15px;
}

.camera-mark {
  width: 78px;
  height: 78px;
  margin-bottom: 16px;
  border: 0;
  border-radius: 22px;
  background:
    linear-gradient(135deg, rgba(29, 44, 140, 0.12), rgba(227, 6, 43, 0.08)),
    #eef2ff;
}

.camera-mark::before {
  width: 38px;
  height: 38px;
  border: 0;
  border-radius: 10px;
  background: var(--cdo-blue);
  box-shadow:
    -18px -18px 0 -12px var(--accent),
    18px -18px 0 -12px var(--accent),
    -18px 18px 0 -12px var(--accent),
    18px 18px 0 -12px var(--accent);
}

.camera-debug {
  display: none;
}

.primary-action,
.details-link,
.cart-action {
  min-height: 48px;
  border-radius: 14px;
  background: var(--accent);
  color: #ffffff;
  box-shadow: 0 12px 24px rgba(227, 6, 43, 0.24);
}

.scan-frame {
  z-index: 2;
  width: var(--scan-size, min(58vh, 72vw));
  border-color: rgba(255, 255, 255, 0.34);
  border-radius: 22px;
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.1),
    0 16px 44px rgba(0, 0, 0, 0.18);
}

.scan-frame span {
  border-color: #ffffff;
}

.scan-frame.is-uncertain {
  border-color: rgba(245, 158, 11, 0.88);
  box-shadow:
    0 0 0 1px rgba(245, 158, 11, 0.16),
    0 16px 44px rgba(245, 158, 11, 0.22);
}

.scan-frame.is-uncertain span {
  border-color: #f59e0b;
}

.scan-beam {
  background: linear-gradient(90deg, transparent, rgba(227, 6, 43, 0.98), transparent);
  box-shadow: 0 0 22px rgba(227, 6, 43, 0.8);
}

.scan-status {
  z-index: 5;
  border-color: rgba(255, 255, 255, 0.46);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.9);
  color: var(--cdo-blue);
  box-shadow: 0 10px 24px rgba(29, 44, 140, 0.16);
}

.scan-status.is-good {
  color: #067647;
  border-color: #abefc6;
  background: #dcfae6;
}

.scan-status.is-checking {
  color: var(--cdo-blue);
  border-color: rgba(29, 44, 140, 0.24);
  background: #eef2ff;
}

.scan-status.is-unknown {
  color: #b54708;
  border-color: #fedf89;
  background: #fffaeb;
}

.scan-status.is-uncertain {
  color: #b54708;
  border-color: #fedf89;
  background: #fffaeb;
}

.controls {
  z-index: 6;
  right: max(12px, env(safe-area-inset-right));
  top: calc(max(12px, env(safe-area-inset-top)) + 84px);
}

.icon-button {
  width: 46px;
  height: 46px;
  border-color: rgba(29, 44, 140, 0.14);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.92);
  color: var(--cdo-blue);
  box-shadow: 0 10px 22px rgba(29, 44, 140, 0.16);
}

.icon-button.is-active {
  border-color: transparent;
  background: var(--accent);
  color: #ffffff;
}

.match-panel {
  z-index: 6;
  position: absolute;
  grid-template-columns: 108px minmax(0, 1fr);
  gap: 13px;
  width: min(412px, calc(100vw - 24px));
  padding: 12px;
  border-color: rgba(29, 44, 140, 0.14);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.96);
  color: var(--cdo-blue);
  box-shadow: var(--shadow);
  transform: translate3d(var(--track-x, 0), var(--track-y, 0), 0);
  transition: transform 140ms linear;
  will-change: transform, opacity;
}

.match-close {
  position: absolute;
  top: 8px;
  right: 8px;
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border: 1px solid rgba(29, 44, 140, 0.14);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.92);
  color: var(--cdo-blue);
  box-shadow: 0 8px 18px rgba(29, 44, 140, 0.12);
}

.match-close svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.4;
  stroke-linecap: round;
}

.match-copy {
  padding-right: 26px;
}

.match-panel::after {
  background: var(--accent);
  box-shadow: 0 0 14px rgba(227, 6, 43, 0.56);
}

.match-media {
  width: 108px;
  border-color: var(--line);
  border-radius: 14px;
  background: linear-gradient(180deg, #ffffff, var(--cdo-surface));
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.72);
}

.confidence,
.code,
.facts dt,
.product-card small {
  color: var(--muted);
}

.confidence {
  color: var(--cdo-blue);
  background: rgba(29, 44, 140, 0.07);
}

.match-panel.is-qr-match .confidence {
  color: #ffffff;
  background: var(--accent);
}

.match-panel.is-visual-match .confidence {
  color: var(--cdo-blue);
  background: #eef2ff;
}

.confidence.is-good {
  color: #067647;
}

.match-panel.is-qr-match .confidence.is-good {
  color: #ffffff;
}

.confidence.is-low {
  color: #b54708;
}

.match-copy h2 {
  color: var(--cdo-blue);
  margin: 7px 0 9px;
  font-size: 15px;
  font-weight: 950;
}

.match-head {
  min-height: 26px;
}

.code {
  flex: 0 1 auto;
  max-width: 82px;
  overflow: hidden;
  text-align: right;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.facts {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: stretch;
}

.facts div {
  border-color: var(--line);
  border-radius: 12px;
  background: rgba(29, 44, 140, 0.06);
}

.facts dd {
  color: var(--cdo-blue);
}

.facts div:first-child {
  background: #ffffff;
  border-color: rgba(227, 6, 43, 0.16);
}

.facts div:first-child dt {
  color: var(--accent);
}

.facts div:first-child dd {
  color: var(--accent);
  font-size: 22px;
  letter-spacing: 0;
}

#matchStock {
  background: rgba(29, 44, 140, 0.07);
  color: var(--cdo-blue);
}

#matchStock.is-available {
  background: #dcfae6;
  color: #067647;
}

#matchStock.is-unavailable {
  background: #fffaeb;
  color: #b54708;
}

.match-actions {
  display: grid;
  grid-template-columns: minmax(0, 0.85fr) minmax(0, 1.15fr);
  gap: 8px;
}

.details-link,
.cart-action {
  min-height: 40px;
  padding: 0 14px;
  border-radius: 12px;
  font-size: 13px;
  line-height: 1.1;
  text-align: center;
}

.details-link {
  border: 1px solid rgba(29, 44, 140, 0.16);
  background: #ffffff;
  color: var(--cdo-blue);
  box-shadow: none;
}

.cart-action {
  border: 0;
  background: var(--accent);
  color: #ffffff;
  box-shadow: 0 10px 22px rgba(227, 6, 43, 0.22);
}

.cart-action.is-added {
  background: #067647;
  box-shadow: 0 10px 22px rgba(6, 118, 71, 0.2);
}

.match-panel {
  grid-template-columns: 118px minmax(0, 1fr);
  width: min(560px, calc(100vw - 24px));
  gap: 14px;
  padding: 16px;
}

.match-media {
  width: 118px;
}

.match-copy {
  min-width: 0;
  padding-right: 28px;
}

.match-copy h2 {
  max-width: calc(100% - 10px);
  margin-top: 5px;
  margin-bottom: 10px;
  font-size: clamp(16px, 3.7vw, 20px);
  line-height: 1.12;
}

.facts {
  grid-template-columns: minmax(132px, 1fr) minmax(120px, 0.9fr);
  gap: 10px;
  margin-bottom: 12px;
}

.facts div:first-child {
  grid-row: auto;
}

.facts div {
  display: grid;
  align-content: center;
  min-height: 78px;
  padding: 10px 12px;
}

.facts dd {
  overflow-wrap: normal;
  word-break: normal;
}

.facts div:first-child dd {
  font-size: clamp(24px, 5.8vw, 32px);
  line-height: 1;
  white-space: nowrap;
}

#matchStock {
  justify-self: start;
  min-height: 34px;
  padding: 4px 10px;
  border-radius: 10px;
  font-size: clamp(18px, 4.6vw, 24px);
  white-space: nowrap;
}

.match-actions {
  grid-template-columns: minmax(118px, 0.9fr) minmax(156px, 1.1fr);
  gap: 10px;
}

.details-link,
.cart-action {
  min-height: 48px;
  padding: 0 16px;
  font-size: clamp(15px, 3.8vw, 18px);
}

.cart-action.is-error {
  background: #b42318;
  box-shadow: 0 10px 22px rgba(180, 35, 24, 0.18);
}

.scan-history {
  z-index: 5;
}

.scan-shelf {
  border-color: rgba(29, 44, 140, 0.12);
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 12px 26px rgba(29, 44, 140, 0.14);
}

.scan-shelf-head strong {
  color: var(--cdo-blue);
}

.tray-close {
  color: var(--cdo-blue);
}

.history-item {
  border-color: rgba(29, 44, 140, 0.12);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.94);
  color: var(--cdo-blue);
  box-shadow: 0 12px 26px rgba(29, 44, 140, 0.14);
}

.history-item img {
  border: 1px solid var(--line);
  background: var(--cdo-surface);
  object-fit: contain;
}

.history-item strong {
  color: var(--accent);
}

.scan-toolbar {
  border-color: rgba(29, 44, 140, 0.12);
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 12px 28px rgba(29, 44, 140, 0.16);
}

.scan-toolbar-item,
.scan-toolbar-camera {
  color: var(--cdo-blue);
}

.scan-toolbar-item.is-active {
  background: rgba(29, 44, 140, 0.07);
}

.scan-toolbar-camera {
  background: var(--accent);
  color: #ffffff;
}

@media (max-width: 680px) {
  .topbar {
    width: min(342px, calc(100vw - 28px));
  }

  .topbar > div:first-child {
    min-height: 48px;
    padding: 7px 10px;
  }

  .topbar > div:first-child::before {
    width: 104px;
    height: 32px;
  }

  .status-pill {
    min-width: 96px;
    max-width: 104px;
    min-height: 34px;
    padding: 6px 8px;
    font-size: 10px;
  }

  .topbar .controls {
    grid-template-columns: repeat(3, 32px);
    gap: 5px;
  }

  .topbar .icon-button {
    width: 32px;
    height: 32px;
    font-size: 15px;
  }

  .scan-history {
    bottom: max(10px, env(safe-area-inset-bottom));
  }

  .scan-history-list {
    max-width: 100%;
    overflow: hidden;
  }

  .scan-shelf {
    width: min(392px, calc(100vw - 20px));
    padding: 8px;
    border-radius: 14px;
  }

  .scan-toolbar {
    width: min(342px, calc(100vw - 28px));
    min-height: 58px;
  }

  .history-item {
    width: 100%;
    grid-template-columns: 34px minmax(0, 1fr);
    min-height: 50px;
    padding: 6px;
  }

  .history-item img {
    width: 34px;
    height: 34px;
  }

  .scan-status {
    top: calc(47% + min(36vh, 42vw) + 14px);
  }

  .camera-empty {
    padding: 22px 18px;
  }

  .match-panel {
    grid-template-columns: 96px minmax(0, 1fr);
    width: min(560px, calc(100vw - 18px));
    padding: 12px;
    gap: 10px;
  }

  .match-media {
    width: 96px;
  }

  .match-copy {
    padding-right: 24px;
  }

  .match-copy h2 {
    font-size: clamp(15px, 4.2vw, 18px);
  }

  .facts {
    grid-template-columns: minmax(118px, 1fr) minmax(108px, 0.86fr);
    gap: 8px;
  }

  .facts div {
    min-height: 70px;
    padding: 8px 10px;
  }

  .facts div:first-child dd {
    font-size: clamp(22px, 5.8vw, 28px);
  }

  #matchStock {
    font-size: clamp(16px, 4.4vw, 21px);
  }

  .match-actions {
    grid-template-columns: minmax(104px, 0.9fr) minmax(136px, 1.1fr);
    gap: 8px;
  }

  .details-link,
  .cart-action {
    min-height: 46px;
    padding: 0 12px;
    font-size: clamp(14px, 3.8vw, 17px);
  }
}

.match-panel.is-dismissing {
  pointer-events: none;
  animation: matchPanelDismiss var(--match-dismiss-duration, 360ms) cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

@keyframes matchPanelDismiss {
  0% {
    opacity: 1;
    transform: translate3d(var(--track-x, 0), var(--track-y, 0), 0) scale(1);
    filter: blur(0);
  }

  100% {
    opacity: 0;
    transform: translate3d(
      calc(var(--track-x, 0px) + var(--dismiss-x, 0px)),
      calc(var(--track-y, 0px) + var(--dismiss-y, 34px)),
      0
    ) scale(0.94);
    filter: blur(3px);
  }
}

@media (prefers-reduced-motion: reduce) {
  .match-panel.is-dismissing {
    animation-duration: 1ms;
  }
}

/* Keep every cart item reachable, including on small touch screens. */
.scan-history.is-panel-open {
  z-index: 11;
}

.is-cart-panel .scan-history-list {
  max-height: min(220px, 36vh);
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.cart-item-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
}

.cart-item-row .history-item {
  min-width: 0;
}

.cart-remove {
  min-height: 44px;
  padding: 8px 10px;
  border: 1px solid rgba(227, 6, 43, 0.2);
  border-radius: 10px;
  background: #fff1f3;
  color: #b42318;
  font: inherit;
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
}

.cart-remove:focus-visible {
  outline: 3px solid var(--cdo-blue);
  outline-offset: 2px;
}

.cart-feedback {
  margin: 0 0 8px;
  color: var(--cdo-blue);
  font-size: 12px;
  overflow-wrap: anywhere;
}
