:root {
  color-scheme: light;
  --ink: #231b17;
  --muted: #746a64;
  --accent: #9f2e22;
  --accent-dark: #7c2118;
  --cream: #f6f1eb;
  --card: #fff;
  --line: #e4dcd4;
  --success: #1f7a45;
  --danger: #aa2e25;
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--cream); color: var(--ink); min-height: 100vh; }
button, input { font: inherit; }
button { min-height: 48px; border-radius: 12px; border: 1px solid var(--line); cursor: pointer; }
button:disabled { cursor: wait; opacity: .58; }
.hidden { display: none !important; }

.scanner-shell { width: min(100%, 560px); margin: 0 auto; padding: env(safe-area-inset-top) 12px 0; }
.scanner-header { align-items: center; display: grid; gap: 10px; grid-template-columns: 46px 1fr 48px; padding: 14px 2px 12px; }
.scanner-header img { width: 46px; height: 46px; object-fit: contain; }
.scanner-header h1 { font-size: 20px; line-height: 1.15; margin: 0; }
.scanner-header p { color: var(--muted); font-size: 13px; margin: 4px 0 0; overflow-wrap: anywhere; }
.icon-button { background: #fff; color: var(--ink); font-size: 24px; padding: 0; width: 48px; }
.scanner-status-row { align-items: stretch; display: grid; gap: 10px; grid-template-columns: 1fr auto; margin-bottom: 12px; }
.global-status { background: #ece5de; border-radius: 10px; color: var(--muted); font-size: 14px; padding: 10px 12px; }
.global-status.error { background: #fbe8e6; color: var(--danger); }
.global-status.success { background: #e5f5ea; color: var(--success); }
.scanner-settings-button { font-size: 22px; min-height: 40px; width: 48px; }
.completion-toast {
  background: rgba(25, 81, 48, .97);
  border-radius: 16px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, .24);
  color: #fff;
  font-size: 17px;
  font-weight: 750;
  left: 50%;
  max-width: calc(100% - 32px);
  padding: 18px 22px;
  pointer-events: none;
  position: fixed;
  text-align: center;
  top: 50%;
  transform: translate(-50%, -50%);
  width: max-content;
  z-index: 80;
}

.activation-card { background: #fff; border: 1px solid var(--line); border-radius: 16px; padding: 18px; }
.activation-card h2 { font-size: 20px; margin: 0; }
.activation-card p { color: var(--muted); font-size: 14px; line-height: 1.45; margin: 8px 0 16px; }
.activation-card form { display: grid; gap: 10px; }
.activation-card label { font-size: 14px; font-weight: 700; }
.activation-card input { border: 1px solid var(--line); border-radius: 12px; min-height: 48px; padding: 0 12px; width: 100%; }
.activation-card input:focus { border-color: var(--accent); outline: 3px solid rgba(159,46,34,.14); }
.activation-card .primary-button { width: 100%; }

.section-heading { align-items: center; display: flex; justify-content: space-between; margin: 4px 2px 10px; }
.section-heading h2 { font-size: 20px; margin: 0; }
.section-heading p { color: var(--muted); font-size: 13px; margin: 0; text-align: right; }
.acts-list { display: grid; gap: 10px; }
.act-card { background: var(--card); border: 1px solid var(--line); border-radius: 16px; color: inherit; display: grid; gap: 10px; padding: 14px; text-align: left; width: 100%; }
.act-card-top { align-items: center; display: flex; justify-content: space-between; }
.act-number { font-size: 19px; font-weight: 750; }
.act-action { color: var(--accent); font-size: 13px; font-weight: 700; text-align: right; }
.act-products { display: grid; font-size: 14px; gap: 3px; }
.act-products span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.act-progress { color: var(--muted); font-size: 14px; }
.act-progress strong { color: var(--accent); }
.empty-card { background: #fff; border: 1px dashed #cfc4ba; border-radius: 16px; color: var(--muted); padding: 28px 16px; text-align: center; }

.release-toolbar { align-items: center; display: grid; gap: 10px; grid-template-columns: auto 1fr 48px; margin-bottom: 10px; }
.release-toolbar strong, .release-toolbar span { display: block; }
.release-toolbar span { color: var(--muted); font-size: 13px; margin-top: 3px; }
.brakerage-button { color: var(--accent); font-size: 28px; font-weight: 500; }
.scan-row .brakerage-mark { color: var(--accent); margin-left: 3px; }
.secondary-button { background: #fff; color: var(--ink); padding: 0 14px; }
.primary-button, .complete-button { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 700; padding: 0 18px; }
.primary-button:hover, .complete-button:hover { background: var(--accent-dark); }

.camera-card { background: #17120f; border-radius: 16px; color: #fff; overflow: hidden; position: relative; }
.camera-view { aspect-ratio: 4 / 3; position: relative; }
.camera-view video { height: 100%; object-fit: cover; width: 100%; }
.scan-guide { border: 2px solid rgba(255,255,255,.85); border-radius: 12px; height: 37%; left: 8%; position: absolute; top: 31%; width: 84%; }
.scan-guide span { background: #e34837; box-shadow: 0 0 8px #e34837; height: 2px; left: 4%; position: absolute; right: 4%; top: 50%; }
.camera-placeholder { align-items: center; aspect-ratio: 16 / 8; display: flex; flex-direction: column; justify-content: center; padding: 20px; text-align: center; }
.camera-placeholder p { color: #cfc6c0; margin: 8px 0 0; }
.barcode-icon { font-size: 54px; line-height: 1; }
.camera-card .primary-button { border-radius: 0; width: 100%; }

.release-summary { color: var(--muted); font-size: 14px; padding: 12px 2px 8px; }
.release-items { display: grid; gap: 10px; }
.release-item { background: #fff; border: 1px solid var(--line); border-radius: 16px; overflow: hidden; }
.release-item.complete { background: rgba(203, 239, 213, .6); border-color: rgba(31, 122, 69, .35); }
.release-item.complete .metric { background: rgba(255, 255, 255, .66); }
.release-item-main { padding: 14px; }
.item-heading { display: flex; gap: 8px; justify-content: space-between; }
.item-heading h3 { font-size: 16px; margin: 0; overflow-wrap: anywhere; }
.item-code { color: var(--muted); flex: none; font-size: 12px; }
.item-metrics { display: grid; gap: 7px; grid-template-columns: 1fr 1fr; margin-top: 12px; }
.metric { background: #f7f4f1; border-radius: 10px; padding: 9px; }
.metric span { color: var(--muted); display: block; font-size: 11px; }
.metric strong { display: block; font-size: 15px; margin-top: 3px; }
.metric.pending strong { color: var(--danger); }
.metric.complete strong { color: var(--success); }
.scan-details { border-top: 1px solid var(--line); }
.scan-details summary { cursor: pointer; min-height: 48px; padding: 14px; }
.scan-list { display: grid; gap: 1px; padding: 0 10px 10px; }
.scan-row { align-items: center; background: #f8f5f2; border-radius: 9px; display: grid; gap: 7px; grid-template-columns: 1fr auto 44px; margin-top: 6px; padding: 7px 7px 7px 10px; }
.scan-row small { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.scan-row button { background: #fff; color: var(--danger); min-height: 44px; padding: 0; width: 44px; }
.no-scans { color: var(--muted); padding: 0 14px 14px; }

.bottom-spacer { height: 92px; }
.bottom-action { background: rgba(246,241,235,.94); bottom: 0; left: 0; padding: 10px max(12px, env(safe-area-inset-left)) calc(10px + env(safe-area-inset-bottom)); position: fixed; right: 0; z-index: 20; }
.complete-button { display: block; margin: 0 auto; max-width: 536px; width: 100%; }
.complete-button.ready { background: var(--success); border-color: var(--success); }
.complete-button.ready:hover { background: #176337; }
.toast { background: rgba(25,81,48,.96); border-radius: 14px; color: #fff; font-weight: 700; left: 50%; max-width: calc(100% - 30px); padding: 14px 18px; position: absolute; text-align: center; top: 50%; transform: translate(-50%, -50%); width: max-content; z-index: 10; }
.toast.error { background: rgba(151,37,31,.97); }

.modal { align-items: flex-end; background: rgba(20,15,12,.58); display: flex; inset: 0; justify-content: center; padding: 12px; position: fixed; z-index: 60; }
.modal-sheet { background: #fff; border-radius: 20px; max-height: 85vh; max-width: 540px; overflow-y: auto; padding: 20px; width: 100%; }
.modal.camera-centered .modal-sheet { left: 50%; max-width: min(520px, calc(100% - 24px)); position: fixed; top: var(--camera-modal-center, 50%); transform: translate(-50%, -50%); }
.modal-sheet h2 { font-size: 20px; margin: 0 0 12px; }
.modal-sheet p { color: var(--muted); margin: 8px 0; }
.scanner-mode-label { color: var(--muted); display: block; font-size: 13px; font-weight: 700; margin-bottom: 10px; }
.scanner-modes { background: #f0ece8; border-radius: 14px; display: grid; gap: 6px; grid-template-columns: repeat(3, 1fr); padding: 4px; }
.scanner-modes input { opacity: 0; pointer-events: none; position: absolute; }
.scanner-modes label { border-radius: 10px; cursor: pointer; font-weight: 750; min-height: 44px; padding: 12px 6px; text-align: center; }
.scanner-modes input:checked + label { background: #fff; color: var(--accent); box-shadow: 0 2px 8px rgba(35, 27, 23, .12); }
.scanner-modes input:focus-visible + label { outline: 3px solid rgba(159, 46, 34, .22); }
.deviation-list { display: grid; gap: 8px; margin: 12px 0; }
.deviation-row { background: #fff4dc; border-radius: 10px; padding: 10px; }
.deviation-row strong, .deviation-row span { display: block; }
.deviation-row span { color: #775a22; font-size: 13px; margin-top: 4px; }
.modal-actions { display: grid; gap: 8px; grid-template-columns: 1fr 1fr; margin-top: 16px; }

@media (min-width: 600px) {
  .scanner-shell { padding-left: 0; padding-right: 0; }
  .bottom-action { left: 50%; right: auto; transform: translateX(-50%); width: 584px; }
}
