:root {
  --bg: #f5f5f5;
  --surface: #ffffff;
  --text: #121212;
  --muted: #666666;
  --border: #dddddd;
  --success: #0f8a4b;
  --danger: #666666;
  --danger-red: #c62828;
  --primary: #111111;
  --warning: #b54708;
  --radius: 18px;
  --shadow: 0 12px 30px rgba(0, 0, 0, 0.08);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--text); font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
html, body {
  touch-action: manipulation;
  -webkit-text-size-adjust: 100%;
}
button,
input,
select,
a,
.scan-fab,
.overlay-close-btn,
.action-dock,
.list-step-btn,
.menu-btn {
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

button, input, select { font: inherit; }
body { min-height: 100vh; }
body.scanner-open { overflow: hidden; }

.app-shell {
  max-width: 760px;
  margin: 0 auto;
  padding: 18px 16px 110px;
}

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

h1, h2, h3, p { margin: 0; }
.eyebrow { font-size: 12px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); margin-bottom: 6px; }
.muted { color: var(--muted); }

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
}

.hidden { display: none !important; }

.controls {
  display: grid;
  gap: 10px;
  grid-template-columns: 1fr;
}

input, select {
  width: 100%;
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 12px;
  padding: 14px 14px;
}

.summary-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 14px 0 10px;
}

.badge {
  background: #efefef;
  color: #333;
  border-radius: 999px;
  padding: 8px 12px;
  font-size: 13px;
}

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

.inventory-item {
  position: relative;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px;
  display: grid;
  gap: 10px;
}

.inventory-top {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
}

.inventory-name { font-weight: 700; }
.inventory-code, .inventory-ean { color: var(--muted); font-size: 14px; }
.inventory-ean { display: flex; align-items: center; gap: 8px; }
.inventory-right {
  display: flex;
  align-items: center;
  gap: 6px;
}
.menu-btn {
  width: 28px;
  height: 28px;
  border-radius: 0;
  background: transparent;
  color: #111;
  font-size: 22px;
  line-height: 1;
  padding: 0;
}
.item-menu {
  position: absolute;
  top: 44px;
  right: 14px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 6px;
  min-width: 132px;
  z-index: 10;
}
.item-menu button {
  width: 100%;
  text-align: left;
  background: transparent;
  color: var(--danger);
  padding: 10px 12px;
  border-radius: 10px;
}
.item-menu button:hover { background: #f7f7f7; }

.list-stock-controls {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px 6px;
  background: #fff;
}
.list-step-btn {
  min-width: 28px;
  height: 28px;
  border-radius: 999px;
  padding: 0;
  background: transparent;
  color: var(--text);
  font-size: 18px;
  line-height: 1;
}
.list-step-btn--minus,
.list-step-btn--plus { background: transparent; }
.list-step-btn:disabled {
  opacity: 0.4;
}
.list-stock-value {
  min-width: 24px;
  text-align: center;
  font-weight: 700;
  font-size: 15px;
}

.scanner-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: var(--bg);
  padding-top: calc(18px + env(safe-area-inset-top));
}

.scanner-overlay__content {
  height: 100%;
  overflow-y: auto;
  padding: 0 16px calc(24px + env(safe-area-inset-bottom));
}

.overlay-close-btn {
  position: fixed;
  top: calc(12px + env(safe-area-inset-top));
  right: 16px;
  z-index: 130;
  background: rgba(17, 17, 17, 0.92);
  color: #fff;
  border: 0;
  border-radius: 999px;
  padding: 12px 16px;
  box-shadow: var(--shadow);
}

.scanner-intro {
  padding-top: 52px;
  margin-bottom: 12px;
}

.mode-chip {
  display: inline-block;
  border-radius: 999px;
  padding: 8px 12px;
  font-size: 12px;
  font-weight: 700;
  margin-bottom: 10px;
  color: #fff;
}
.mode-chip--increase { background: var(--success); }
.mode-chip--decrease { background: var(--danger-red); }

.reader {
  overflow: hidden;
  border-radius: 16px;
  background: #000;
  min-height: 280px;
}

.reader video { border-radius: 16px; }
.scan-status {
  margin-top: 10px;
  color: var(--muted);
  font-size: 14px;
}

.result-card {
  margin-top: 14px;
}

.overlay-scroll-area {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  margin-bottom: 16px;
}

.overlay-scroll-area--with-actions {
  padding-bottom: 110px;
}

.product-meta {
  display: grid;
  gap: 12px;
  grid-template-columns: 1fr 1fr;
  margin-bottom: 14px;
}
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.label { color: var(--muted); font-size: 12px; margin-bottom: 4px; }
.value { font-weight: 600; word-break: break-word; }

.item-form { margin-top: 14px; }
.form-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  margin-bottom: 12px;
}
.item-form label span { display: block; margin-bottom: 6px; font-size: 14px; }

button {
  border: 0;
  border-radius: 14px;
  padding: 14px 16px;
  cursor: pointer;
}
.primary-btn, .icon-btn { background: var(--primary); color: #fff; }
.primary-action-btn, .secondary-action-btn, .left-action-btn { color: #fff; flex: 1; font-weight: 700; }
.left-action-btn { background: #000000; }
.primary-action-btn.mode-increase,
.secondary-action-btn.mode-increase { background: var(--success); }
.primary-action-btn.mode-decrease,
.secondary-action-btn.mode-decrease { background: var(--danger); }

.icon-btn { width: 46px; height: 46px; padding: 0; font-size: 22px; }

.scan-launchers {
  position: fixed;
  left: 16px;
  right: 16px;
  bottom: calc(14px + env(safe-area-inset-bottom));
  z-index: 20;
  display: flex;
  gap: 10px;
}
.scan-fab {
  flex: 1;
  box-shadow: var(--shadow);
  font-weight: 700;
}
.scan-fab--danger { background: var(--danger-red); color: #fff; }
.scan-fab--success { background: var(--success); color: #fff; }

.action-dock {
  position: fixed;
  left: 16px;
  right: 16px;
  bottom: calc(14px + env(safe-area-inset-bottom));
  z-index: 120;
  display: flex;
  gap: 10px;
}
.action-dock--single {
  justify-content: flex-end;
}
.action-dock--right {
  left: auto;
  right: 16px;
}
.action-dock--right .primary-btn {
  width: auto;
  max-width: min(320px, calc(100vw - 32px));
}

.message-area {
  position: sticky;
  top: 12px;
  z-index: 15;
  margin-bottom: 12px;
  border-radius: 14px;
  padding: 12px 14px;
  box-shadow: var(--shadow);
}
.message-success { background: #e7f7ee; color: #0f6b3a; }
.message-warning { background: #fff1e6; color: #9a4d00; }
.message-error { background: #fde8e8; color: #a32020; }

@media (min-width: 700px) {
  .controls { grid-template-columns: 1fr 220px; }
  .form-grid { grid-template-columns: 1fr 1fr; }
}


.scanner-overlay.flash-success {
  animation: scannerFlashGreen 320ms ease-out;
}

@keyframes scannerFlashGreen {
  0% { background: rgba(15, 138, 75, 0.55); }
  100% { background: var(--bg); }
}


.scan-launchers--triple .scan-fab {
  min-width: 0;
}
.scan-fab--find {
  background: #000000;
  color: #fff;
}
.inventory-item.is-highlighted {
  border-color: #000000;
  box-shadow: 0 0 0 3px rgba(111, 136, 163, 0.22), var(--shadow);
}


.ean-with-color {
  display: flex;
  align-items: center;
  gap: 8px;
}

.color-swatch {
  width: 14px;
  height: 14px;
  min-width: 14px;
  border-radius: 3px;
  border: 1px solid rgba(0,0,0,0.12);
  background: #e9e9e9;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.2);
}

.color-swatch--large {
  width: 16px;
  height: 16px;
  min-width: 16px;
}


.inventory-item.is-light-card {
  background: #f2f2f2;
  border-color: #dedede;
}

.inventory-item.is-light-card .list-stock-controls {
  background: #f2f2f2;
  border-color: #d4d4d4;
}

.inventory-item.is-light-card .item-menu {
  background: #f2f2f2;
}

.inventory-item.is-light-card .color-swatch {
  border-color: rgba(0,0,0,0.18);
}


.search-wrap {
  position: relative;
}

.search-wrap input {
  padding-right: 46px;
}

.clear-search-btn {
  position: absolute;
  top: 50%;
  right: 10px;
  transform: translateY(-50%);
  width: 28px;
  height: 28px;
  padding: 0;
  border-radius: 999px;
  background: #efefef;
  color: #333;
  font-size: 20px;
  line-height: 1;
}

.action-dock--stepper {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
}

.scanner-qty-display {
  min-width: 72px;
  text-align: center;
  font-size: 24px;
  font-weight: 700;
  color: var(--text);
  background: rgba(255,255,255,0.96);
  border-radius: 14px;
  padding: 12px 14px;
  box-shadow: var(--shadow);
}

.pending-confirm-wrap {
  margin-top: 6px;
  display: flex;
  justify-content: flex-end;
}

.pending-confirm-btn {
  padding: 8px 12px;
  border-radius: 10px;
  background: var(--primary);
  color: #fff;
  font-size: 13px;
}

.app-header h1 {
  font-size: 20px;
  line-height: 1.2;
}


.floating-page-up {
  position: fixed;
  top: calc(12px + env(safe-area-inset-top));
  right: 16px;
  z-index: 90;
  width: 46px;
  height: 46px;
  padding: 0;
  border-radius: 14px;
  background: var(--primary);
  color: #fff;
  box-shadow: var(--shadow);
}

.floating-page-up.hidden {
  display: none !important;
}

.inventory-item.is-blk-light {
  background: #f2f2f2;
  border-color: #dedede;
}

.inventory-item.is-blk-light .list-stock-controls {
  background: #f2f2f2;
  border-color: #d4d4d4;
}

.inventory-item.is-blk-light .item-menu {
  background: #f2f2f2;
}

.inventory-item.is-blk-light .color-swatch {
  border-color: rgba(0,0,0,0.18);
}

.app-header h1 {
  font-size: 20px;
  line-height: 1.2;
}


/* Capture flow */
.scanner-actions-stack {
  position: fixed;
  left: 16px;
  right: 16px;
  bottom: calc(14px + env(safe-area-inset-bottom));
  z-index: 121;
  display: grid;
  gap: 10px;
}

.action-dock--stepper {
  position: static;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
}

.save-all-scan-btn {
  width: 100%;
  box-shadow: var(--shadow);
  font-weight: 700;
  color: #fff;
}

.save-all-scan-btn.mode-increase {
  background: var(--success);
}

.save-all-scan-btn.mode-decrease {
  background: var(--danger);
}

.save-all-scan-btn:disabled,
.overlay-close-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.left-action-btn,
.primary-action-btn {
  background: #000000 !important;
  color: #fff;
}

.app-header h1 {
  font-size: 20px;
  line-height: 1.2;
}


.scanner-dual-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.half-btn {
  width: 100%;
  box-shadow: var(--shadow);
  font-weight: 700;
  background: #ffffff;
  color: var(--text);
  border: 1px solid var(--border);
}

.half-btn--primary {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

.half-btn:disabled,
.half-btn--primary:disabled,
.overlay-close-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.reader.is-hidden {
  display: none !important;
}


.persistent-checkout-dock {
  position: fixed;
  left: 16px;
  right: 16px;
  bottom: calc(14px + env(safe-area-inset-bottom));
  z-index: 122;
}

.persistent-checkout-dock .half-btn {
  width: 50%;
  margin-left: 0;
}


.action-dock--dual {
  display: grid;
  grid-template-columns: 1fr 1fr;
}


.half-btn--confirm {
  background: #111111;
  color: #fff;
  border-color: #111111;
}

.half-btn--check {
  background: #ffffff;
  color: var(--text);
  border: 1px solid var(--border);
}


.message-info {
  background: #eef3ff;
  color: #1f3a75;
}

button:disabled,
input:disabled,
select:disabled,
textarea:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}


.pending-confirm-btn:disabled {
  background: rgba(17, 17, 17, 0.35);
  color: rgba(255, 255, 255, 0.9);
  cursor: not-allowed;
}

.mode-chip--find { background: #111111; }
