* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

:root {
  --primary: #0066CC;
  --primary-dark: #0052A3;
  --primary-light: #3385D6;
  --success: #00875A;
  --success-light: #E3FCEF;
  --danger: #DE350B;
  --danger-light: #FFEBE6;
  --warning: #FF991F;
  --warning-light: #FFF0D6;
  --text-primary: #172B4D;
  --text-secondary: #5E6C84;
  --text-disabled: #A5ADBA;
  --bg-primary: #FAFBFC;
  --bg-secondary: #F4F5F7;
  --bg-white: #FFFFFF;
  --border: #DFE1E6;
  --border-focus: #4C9AFF;
}

/* Reset & Base */
html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.5;
  min-height: 100vh;
  overflow-x: hidden;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 16px;
}

@media (min-width: 768px) {
  .container {
    padding: 24px;
  }
}

/* Header */
.header {
  background: var(--bg-white);
  color: var(--text-primary);
  padding: 16px 20px;
  position: sticky;
  top: 0;
  z-index: 100;
  border-bottom: 2px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.header-left {
  flex: 1;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.header h1 {
  font-size: 20px;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: -0.01em;
}

.header .location-info {
  font-size: 14px;
  color: var(--text-secondary);
  margin-top: 4px;
  font-weight: 500;
}

.account-select {
  padding: 8px 12px;
  font-size: 14px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--bg-white);
  color: var(--text-primary);
  min-width: 180px;
  cursor: pointer;
}

.account-select:focus {
  outline: none;
  border-color: var(--border-focus);
}

.btn-icon {
  width: 36px;
  height: 36px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--bg-white);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s;
}

.btn-icon:hover {
  background: var(--bg-secondary);
  color: var(--text-primary);
  border-color: var(--text-secondary);
}

.btn-icon:active {
  transform: scale(0.95);
}

.btn-icon span {
  font-size: 18px;
  font-weight: 600;
}

@media (min-width: 768px) {
  .header {
    padding: 20px 24px;
  }

  .header h1 {
    font-size: 24px;
  }

  .account-select {
    min-width: 220px;
  }
}

/* Cards */
.card {
  background: var(--bg-white);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 20px;
  margin-bottom: 16px;
}

.card h2 {
  font-size: 18px;
  margin-bottom: 20px;
  color: var(--text-primary);
  font-weight: 600;
}

@media (min-width: 768px) {
  .card {
    padding: 24px;
    margin-bottom: 20px;
  }

  .card h2 {
    font-size: 20px;
    margin-bottom: 24px;
  }
}

/* Form Elements */
.form-group {
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  margin-bottom: 8px;
  font-weight: 600;
  color: var(--text-primary);
  font-size: 14px;
}

.form-group select,
.form-group input,
.scan-input input {
  width: 100%;
  padding: 12px 14px;
  border: 2px solid var(--border);
  border-radius: 4px;
  font-size: 14px;
  font-weight: 400;
  background: var(--bg-white);
  color: var(--text-primary);
  transition: border-color 0.2s ease;
  font-family: inherit;
}

.form-group select:focus,
.form-group input:focus,
.scan-input input:focus {
  outline: none;
  border-color: var(--border-focus);
}

.scan-input input {
  font-size: 16px;
  padding: 14px 16px;
  font-weight: 500;
}

@media (min-width: 768px) {
  .scan-input input {
    font-size: 18px;
    padding: 16px 18px;
  }
}

/* Buttons */
.btn {
  padding: 12px 20px;
  border: none;
  border-radius: 4px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.2s ease, transform 0.1s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-decoration: none;
  font-family: inherit;
  white-space: nowrap;
  min-height: 44px;
  line-height: 1;
}

.btn:active {
  transform: scale(0.98);
}

.btn-primary {
  background: var(--primary);
  color: var(--bg-white);
}

.btn-primary:hover {
  background: var(--primary-dark);
}

.btn-success {
  background: var(--success);
  color: var(--bg-white);
}

.btn-success:hover {
  background: #006644;
}

.btn-danger {
  background: var(--danger);
  color: var(--bg-white);
}

.btn-danger:hover {
  background: #BF2600;
}

.btn-secondary {
  background: var(--text-secondary);
  color: var(--bg-white);
}

.btn-secondary:hover {
  background: #42526E;
}

.btn-block {
  width: 100%;
  display: flex;
}

.btn-group {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  margin-top: 16px;
}

@media (min-width: 640px) {
  .btn-group {
    grid-template-columns: 1fr 1fr;
  }
}

@media (min-width: 768px) {
  .btn {
    padding: 14px 24px;
    font-size: 15px;
    min-height: 48px;
  }
}

/* Transfer & Product Lists */
.transfer-list,
.product-list {
  list-style: none;
}

.transfer-item {
  background: var(--bg-white);
  border: 2px solid var(--border);
  border-radius: 4px;
  padding: 16px;
  margin-bottom: 12px;
  cursor: pointer;
  transition: border-color 0.2s ease, background-color 0.2s ease;
}

.transfer-item:hover {
  border-color: var(--primary);
  background: var(--bg-secondary);
}

.transfer-item:active {
  background: var(--border);
}

.transfer-item .transfer-id {
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 8px;
  font-size: 16px;
}

.transfer-item .transfer-info {
  font-size: 14px;
  color: var(--text-secondary);
  font-weight: 400;
}

.product-item {
  background: var(--bg-white);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 16px;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 16px;
}

.product-image {
  width: 60px;
  height: 60px;
  min-width: 60px;
  object-fit: cover;
  border-radius: 4px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
}

@media (min-width: 768px) {
  .product-image {
    width: 80px;
    height: 80px;
    min-width: 80px;
  }
}

.product-info {
  flex: 1;
  min-width: 0;
}

.product-sku {
  font-weight: 700;
  color: var(--text-primary);
  font-size: 15px;
}

.product-title {
  font-size: 14px;
  color: var(--text-secondary);
  margin: 4px 0 8px;
  font-weight: 400;
}

.product-quantities {
  display: flex;
  gap: 8px;
  font-size: 13px;
  flex-wrap: wrap;
}

.quantity-badge {
  padding: 4px 10px;
  border-radius: 4px;
  font-weight: 600;
  white-space: nowrap;
}

.quantity-expected {
  background: #DEEBFF;
  color: var(--primary-dark);
}

.quantity-received {
  background: var(--success-light);
  color: var(--success);
}

/* Quantity Editor */
.quantity-editor {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin: 24px 0;
}

.quantity-editor button {
  width: 48px;
  height: 48px;
  min-width: 48px;
  border: none;
  background: var(--primary);
  color: var(--bg-white);
  border-radius: 4px;
  font-size: 24px;
  cursor: pointer;
  font-weight: 600;
  transition: background-color 0.2s ease;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

.quantity-editor button:hover {
  background: var(--primary-dark);
}

.quantity-editor button:active {
  background: var(--primary-light);
}

.quantity-editor input {
  width: 80px;
  text-align: center;
  font-size: 24px;
  font-weight: 700;
  padding: 10px;
  border: 2px solid var(--border);
  border-radius: 4px;
  background: var(--bg-white);
  color: var(--primary);
}

.quantity-editor input:focus {
  border-color: var(--border-focus);
  outline: none;
}

@media (min-width: 768px) {
  .quantity-editor button {
    width: 56px;
    height: 56px;
    min-width: 56px;
  }

  .quantity-editor input {
    width: 100px;
    font-size: 28px;
    padding: 12px;
  }
}

.product-detail {
  text-align: center;
}

.product-detail .product-image {
  width: 160px;
  height: 160px;
  min-width: 160px;
  margin: 20px auto;
}

.product-detail .product-sku {
  font-size: 20px;
  margin-bottom: 8px;
}

.product-detail .product-title {
  font-size: 16px;
  margin-bottom: 20px;
}

/* Alerts */
.alert {
  padding: 16px;
  border-radius: 4px;
  margin-bottom: 16px;
  font-weight: 500;
  font-size: 14px;
  border: 2px solid;
}

.alert-success {
  background: var(--success-light);
  color: var(--success);
  border-color: var(--success);
}

.alert-error {
  background: var(--danger-light);
  color: var(--danger);
  border-color: var(--danger);
}

.alert-warning {
  background: var(--warning-light);
  color: #974F0C;
  border-color: var(--warning);
}

/* Checkbox */
.checkbox-group {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 16px 0;
  padding: 14px;
  background: var(--bg-secondary);
  border-radius: 4px;
  border: 1px solid var(--border);
}

.checkbox-group input[type="checkbox"] {
  width: 20px;
  height: 20px;
  min-width: 20px;
  cursor: pointer;
  accent-color: var(--primary);
}

.checkbox-group label {
  margin: 0;
  cursor: pointer;
  font-weight: 500;
  color: var(--text-primary);
  font-size: 14px;
}

/* Progress */
.progress-bar {
  background: var(--bg-secondary);
  border-radius: 4px;
  height: 8px;
  overflow: hidden;
  margin: 16px 0;
  border: 1px solid var(--border);
}

.progress-fill {
  background: var(--success);
  height: 100%;
  transition: width 0.3s ease;
}

/* Stats */
.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin: 16px 0;
}

.stat-item {
  background: var(--bg-white);
  padding: 16px;
  border-radius: 4px;
  text-align: center;
  border: 1px solid var(--border);
}

.stat-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--primary);
  line-height: 1;
}

.stat-label {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 6px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

@media (min-width: 768px) {
  .stats {
    gap: 16px;
  }

  .stat-item {
    padding: 20px;
  }

  .stat-value {
    font-size: 36px;
  }

  .stat-label {
    font-size: 13px;
    margin-top: 8px;
  }
}

/* Scanner */
#scannerVideo {
  display: block;
  width: 100%;
  height: auto;
  min-height: 280px;
  background: #000;
  border-radius: 4px;
  border: 2px solid var(--border);
}

@media (min-width: 768px) {
  #scannerVideo {
    min-height: 400px;
  }
}

.scanner-instructions {
  text-align: center;
  padding: 16px;
  background: var(--bg-secondary);
  border-radius: 4px;
  margin: 16px 0;
  border: 1px solid var(--border);
}

.scanner-instructions strong {
  color: var(--text-primary);
  font-size: 16px;
  display: block;
  margin-bottom: 6px;
  font-weight: 600;
}

.scanner-instructions small {
  color: var(--text-secondary);
  font-weight: 400;
  font-size: 13px;
}

.last-detected-code {
  position: absolute;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--success);
  color: var(--bg-white);
  padding: 14px 24px;
  border-radius: 4px;
  font-size: 18px;
  font-weight: 700;
  z-index: 100;
  border: 2px solid var(--bg-white);
  animation: fadeInScale 0.3s ease-out;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

@keyframes fadeInScale {
  from {
    opacity: 0;
    transform: translateX(-50%) scale(0.9);
  }
  to {
    opacity: 1;
    transform: translateX(-50%) scale(1);
  }
}

@media (min-width: 768px) {
  .last-detected-code {
    font-size: 22px;
    padding: 16px 32px;
    top: 30px;
  }
}

.hidden {
  display: none !important;
}

/* Scan Overlay */
#scanOverlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

#scanOverlay > div:first-child {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  border: 3px solid var(--success);
  width: 80%;
  max-width: 300px;
  height: 150px;
  border-radius: 8px;
  box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.5);
}

#scanOverlay > div:last-child {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 80%;
  max-width: 300px;
  height: 2px;
  background: var(--success);
  animation: scanLine 2s ease-in-out infinite;
  box-shadow: 0 0 8px var(--success);
}

@keyframes scanLine {
  0%, 100% {
    transform: translate(-50%, -75px);
    opacity: 0.7;
  }
  50% {
    transform: translate(-50%, 75px);
    opacity: 1;
  }
}

/* Loading State */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
  color: var(--text-secondary);
}

.spinner {
  width: 20px;
  height: 20px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  margin-right: 10px;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* Empty States */
.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-secondary);
}

.empty-state-icon {
  font-size: 48px;
  margin-bottom: 16px;
  opacity: 0.3;
}

.empty-state-text {
  font-size: 16px;
  font-weight: 500;
}

/* Touch Optimizations */
@media (hover: none) and (pointer: coarse) {
  .btn {
    min-height: 48px;
  }

  .transfer-item {
    padding: 18px;
  }

  .checkbox-group input[type="checkbox"] {
    width: 24px;
    height: 24px;
    min-width: 24px;
  }
}

/* High Contrast Support */
@media (prefers-contrast: high) {
  .card,
  .transfer-item,
  .product-item {
    border-width: 2px;
  }

  .btn {
    border: 2px solid transparent;
  }

  .btn-primary {
    border-color: var(--primary-dark);
  }
}

/* Print Styles */
/* Autocomplete Dropdown */
.autocomplete-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: var(--bg-white);
  border: 1px solid var(--border);
  border-top: none;
  border-radius: 0 0 8px 8px;
  max-height: 300px;
  overflow-y: auto;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
  z-index: 100;
  display: none;
}

.autocomplete-dropdown.active {
  display: block;
}

.autocomplete-item {
  padding: 12px 16px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  transition: background 0.2s;
}

.autocomplete-item:last-child {
  border-bottom: none;
}

.autocomplete-item:hover {
  background: var(--bg-secondary);
}

.autocomplete-item-title {
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.autocomplete-item-subtitle {
  font-size: 13px;
  color: var(--text-secondary);
}

.autocomplete-item-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 500;
  margin-left: 8px;
}

.autocomplete-item-badge.pending {
  background: var(--warning-light);
  color: var(--warning);
}

.autocomplete-item-badge.in-transit {
  background: #E3F2FD;
  color: #1976D2;
}

.autocomplete-item-badge.received {
  background: var(--success-light);
  color: var(--success);
}

@media print {
  .header,
  .btn,
  #camera-scanner {
    display: none;
  }

  .card {
    border: 2px solid #000;
    page-break-inside: avoid;
  }
}
