.active-scan-panel {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface, #fff);
}

.active-scan-panel[hidden] { display: none; }
.active-scan-copy strong,
.active-scan-copy small { display: block; }
.active-scan-copy strong { font-size: 15px; }
.active-scan-copy small { margin-top: 3px; color: var(--muted); font-size: 12px; }
.active-scan-copy small b { color: var(--text); font-variant-numeric: tabular-nums; }
.active-scan-copy small span { margin: 0 4px; }
.browser-scan-connection {
  width: fit-content;
  max-width: 100%;
  margin-top: 8px;
  padding: 5px 8px;
  border-radius: 7px;
  color: #9a5b05;
  background: #fff2d8;
  font-size: 12px;
  font-weight: 750;
  line-height: 1.25;
}
.browser-scan-connection[hidden] { display: none; }
.browser-scan-connection::before {
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-right: 6px;
  border-radius: 50%;
  background: currentColor;
  content: "";
  vertical-align: 1px;
}
.browser-scan-connection.is-offline,
.browser-scan-connection.has-errors {
  color: #a72d34;
  background: #fde7e8;
}
.browser-scan-connection.is-syncing {
  color: #1765b5;
  background: #e5f1ff;
}
.camera-scan-connection {
  color: #ffd181;
  background: rgba(174, 101, 0, .26);
}
.camera-scan-connection.is-offline,
.camera-scan-connection.has-errors {
  color: #ff9ca2;
  background: rgba(179, 38, 47, .28);
}
.camera-scan-connection.is-syncing {
  color: #91c8ff;
  background: rgba(35, 112, 191, .26);
}

.camera-scan-action,
.camera-duplicate-confirm {
  min-height: 44px;
  border: 0;
  border-radius: 9px;
  color: #fff;
  background: var(--primary);
  font: inherit;
  font-size: 13px;
  font-weight: 750;
}

.camera-scan-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 15px;
}
.camera-scan-action svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; }
.camera-scan-action:disabled {
  cursor: not-allowed;
  color: var(--muted);
  background: var(--field, #f1f3f6);
  opacity: 1;
}

.camera-scanner-dialog {
  width: min(560px, calc(100vw - 24px));
  padding: 0;
  overflow: hidden;
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 18px;
  color: #fff;
  background: #070b12;
  box-shadow: 0 30px 90px rgba(0,0,0,.55);
}
.camera-scanner-dialog::backdrop { background: rgba(2,5,11,.78); backdrop-filter: blur(8px); }
.camera-scanner-shell > header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 16px 17px;
}
.camera-scanner-shell header strong,
.camera-scanner-shell header small { display: block; }
.camera-scanner-shell header strong { font-size: 17px; }
.camera-scanner-shell header small { margin-top: 3px; color: #9ca7b8; font-size: 12px; }
.camera-scanner-shell header button {
  width: 38px;
  height: 38px;
  border: 0;
  border-radius: 9px;
  color: #dce2ec;
  background: rgba(255,255,255,.09);
  font-size: 26px;
}
.camera-scanner-stage {
  position: relative;
  min-height: 360px;
  overflow: hidden;
  background: #020408;
  isolation: isolate;
}
.camera-scanner-stage video {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  min-height: 360px;
  max-width: none;
  max-height: none;
  object-fit: cover !important;
  object-position: 50% 50%;
  transform: translateZ(0);
}
.camera-scanner-frame {
  position: absolute;
  z-index: 2;
  top: 50%;
  left: 50%;
  width: min(78%, 390px);
  aspect-ratio: 1.55;
  border: 2px solid rgba(255,255,255,.86);
  border-radius: 14px;
  box-shadow: 0 0 0 999px rgba(0,0,0,.27);
  transform: translate(-50%, -50%);
  pointer-events: none;
}
#camera-scanner-loading {
  position: absolute;
  z-index: 3;
  top: 50%;
  left: 50%;
  display: grid;
  justify-items: center;
  gap: 10px;
  color: #fff;
  font-size: 13px;
  transform: translate(-50%, -50%);
  pointer-events: none;
}
#camera-scanner-loading[hidden] { display: none; }
#camera-scanner-loading i {
  width: 28px;
  height: 28px;
  border: 3px solid rgba(255,255,255,.22);
  border-top-color: #fff;
  border-radius: 50%;
  animation: scanner-spin .8s linear infinite;
}
@keyframes scanner-spin { to { transform: rotate(360deg); } }
.camera-scan-success-signal {
  position: absolute;
  z-index: 4;
  top: 50%;
  left: 50%;
  display: grid;
  justify-items: center;
  gap: 10px;
  min-width: 176px;
  padding: 22px 28px;
  border: 1px solid rgba(108, 244, 187, .55);
  border-radius: 18px;
  color: #eafff7;
  background: rgba(9, 105, 72, .90);
  box-shadow: 0 18px 60px rgba(0, 0, 0, .42), 0 0 0 999px rgba(5, 35, 25, .16);
  opacity: 0;
  transform: translate(-50%, -50%) scale(.78);
  pointer-events: none;
}
.camera-scan-success-signal[hidden] { display: none; }
.camera-scan-success-signal.show {
  animation: camera-scan-accepted .82s cubic-bezier(.2, .85, .22, 1) both;
}
.camera-scan-success-signal span {
  display: grid;
  place-items: center;
  width: 58px;
  height: 58px;
  border-radius: 50%;
  color: #087750;
  background: #b9f8dc;
  font-size: 35px;
  font-weight: 900;
  line-height: 1;
}
.camera-scan-success-signal strong { font-size: 18px; }
@keyframes camera-scan-accepted {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(.78); filter: blur(5px); }
  18%, 68% { opacity: 1; transform: translate(-50%, -50%) scale(1); filter: blur(0); }
  100% { opacity: 0; transform: translate(-50%, -50%) scale(1.06); filter: blur(2px); }
}
.camera-scan-feedback {
  min-height: 66px;
  padding: 13px 17px;
  border-top: 1px solid rgba(255,255,255,.09);
  background: rgba(255,255,255,.05);
  transition: background .18s ease;
}
.camera-scan-feedback strong,
.camera-scan-feedback small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.camera-scan-feedback strong { font-size: 14px; }
.camera-scan-feedback small { margin-top: 3px; color: #aeb7c6; font-size: 12px; }
.camera-scan-feedback.success { background: rgba(21,152,106,.23); }
.camera-scan-feedback.queued { background: rgba(21,152,106,.23); }
.camera-scan-feedback.duplicate { background: rgba(208,54,61,.30); }
.camera-scan-feedback.error { background: rgba(208,54,61,.22); }
.camera-duplicate-confirm { width: calc(100% - 34px); margin: 0 17px 16px; background: #d0363d; }

[data-theme="dark"] .active-scan-panel {
  --surface: #111317;
  --field: #191c22;
}
[data-theme="dark"] .active-scan-panel .browser-scan-connection {
  color: #ffd181;
  background: rgba(174, 101, 0, .22);
}
[data-theme="dark"] .active-scan-panel .browser-scan-connection.is-offline,
[data-theme="dark"] .active-scan-panel .browser-scan-connection.has-errors {
  color: #ff9ca2;
  background: rgba(179, 38, 47, .24);
}
[data-theme="dark"] .active-scan-panel .browser-scan-connection.is-syncing {
  color: #91c8ff;
  background: rgba(35, 112, 191, .22);
}

@media (max-width: 760px) {
  .active-scan-panel { grid-template-columns: 1fr; }
  .camera-scan-action { min-height: 52px; font-size: 15px; }
  .camera-scanner-dialog {
    position: fixed;
    inset: 0;
    width: 100vw;
    max-width: none;
    height: 100dvh;
    max-height: none;
    margin: 0;
    border: 0;
    border-radius: 0;
  }
  .camera-scanner-shell > header {
    padding-top: max(16px, env(safe-area-inset-top));
  }
  .camera-scanner-shell {
    width: 100%;
    height: 100%;
    min-height: 0;
    display: grid;
    grid-template-rows: auto minmax(0, 1fr) auto auto;
    overflow: hidden;
  }
  .camera-scanner-stage {
    width: 100%;
    min-width: 0;
    min-height: 0;
  }
  .camera-scanner-stage video {
    width: 100%;
    min-width: 100%;
    min-height: 100%;
  }
}
