*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Helvetica Neue', Arial, sans-serif;
  background: #f2f2f2;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 1.5rem 1rem 3rem;
  color: #1a1a2e;
}

.card {
  background: #fff;
  border-radius: 18px;
  box-shadow: 0 4px 28px rgba(0,0,0,0.08);
  padding: 2rem 1.5rem;
  width: 100%;
  max-width: 480px;
}

h1 {
  font-size: 1.35rem;
  font-weight: 700;
  color: #1a1a2e;
  margin-bottom: 1.5rem;
  text-align: center;
}

.field-group { margin-bottom: 1.25rem; }

label {
  display: block;
  font-size: 0.875rem;
  font-weight: 600;
  color: #555;
  margin-bottom: 0.4rem;
}

input[type="text"],
input[type="tel"] {
  width: 100%;
  padding: 0.8rem 1rem;
  border: 1.5px solid #dde1e7;
  border-radius: 10px;
  font-size: 1rem;
  color: #1a1a2e;
  background: #fafbfc;
  transition: border-color 0.2s;
  font-family: inherit;
  direction: ltr;
  text-align: right;
}

input:focus {
  outline: none;
  border-color: #111;
  background: #fff;
}

.action-row {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  margin-top: 1.5rem;
}

/* Small manual button */
.btn-manual {
  align-self: flex-start;
  padding: 0.5rem 1.4rem;
  background: #fff;
  border: 1.5px solid #111;
  border-radius: 8px;
  color: #111;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s, color 0.15s;
}
.btn-manual:hover { background: #111; color: #fff; }
.btn-manual:disabled { opacity: 0.5; cursor: not-allowed; }

/* Large camera / shipping button */
.btn-camera {
  width: 100%;
  padding: 1.6rem 1rem;
  background: #111;
  border: none;
  border-radius: 16px;
  color: #fff;
  font-size: 1.15rem;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.65rem;
  transition: opacity 0.15s, transform 0.1s;
  box-shadow: 0 6px 20px rgba(0,0,0,0.22);
}
.btn-camera:hover { opacity: 0.91; }
.btn-camera:active { transform: scale(0.984); }
.btn-camera:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-camera svg { width: 62px; height: 62px; }

/* Modal overlay */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.52);
  z-index: 100;
  align-items: flex-end;
  justify-content: center;
}
.modal-overlay.open { display: flex; }

.modal {
  background: #fff;
  border-radius: 22px 22px 0 0;
  width: 100%;
  max-width: 480px;
  padding: 1.75rem 1.5rem 2.25rem;
  max-height: 92vh;
  overflow-y: auto;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.3rem;
}
.modal-title { font-size: 1.1rem; font-weight: 700; }

.btn-close {
  background: none;
  border: none;
  cursor: pointer;
  color: #999;
  font-size: 1.35rem;
  line-height: 1;
  padding: 0.2rem 0.3rem;
}

.btn-primary {
  width: 100%;
  padding: 0.9rem;
  background: #111;
  border: none;
  border-radius: 10px;
  color: #fff;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  margin-top: 1rem;
  transition: opacity 0.15s;
}
.btn-primary:hover { opacity: 0.85; }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-secondary {
  width: 100%;
  padding: 0.9rem;
  background: #fff;
  border: 1.5px solid #dde1e7;
  border-radius: 10px;
  color: #555;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  margin-top: 0.55rem;
  transition: background 0.15s;
}
.btn-secondary:hover { background: #f5f5f5; }

/* Image preview */
.image-preview-wrap {
  width: 100%;
  border-radius: 12px;
  overflow: hidden;
  margin-bottom: 0.85rem;
  background: #f0f0f0;
  aspect-ratio: 4/3;
  display: flex;
  align-items: center;
  justify-content: center;
}
.image-preview-wrap img { width: 100%; height: 100%; object-fit: contain; }

/* Results */
.results-section {
  margin-top: 1.75rem;
  width: 100%;
  max-width: 480px;
}
.results-title {
  font-size: 0.8rem;
  font-weight: 700;
  color: #999;
  margin-bottom: 0.75rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}
.result-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.8rem 1rem;
  border-radius: 10px;
  margin-bottom: 0.5rem;
  font-size: 0.875rem;
  font-weight: 500;
}
.result-item.success { background: #f0fdf4; color: #15803d; border: 1px solid #bbf7d0; }
.result-item.failure { background: #fef2f2; color: #b91c1c; border: 1px solid #fecaca; }
.result-icon { font-size: 1.15rem; flex-shrink: 0; }
.result-info { flex: 1; min-width: 0; }
.result-label { font-weight: 600; }
.result-time { font-size: 0.75rem; opacity: 0.7; margin-top: 0.1rem; }

/* Spinner */
@keyframes spin { to { transform: rotate(360deg); } }
.spinner {
  width: 17px; height: 17px;
  border: 2.5px solid rgba(255,255,255,0.35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.65s linear infinite;
  display: inline-block;
  vertical-align: middle;
  margin-inline-start: 0.5rem;
}

#cameraInput { display: none; }

/* Toast notification */
.toast {
  position: fixed;
  top: -80px;
  left: 50%;
  transform: translateX(-50%);
  background: #c0392b;
  color: #fff;
  padding: 0.85rem 1.4rem;
  border-radius: 12px;
  font-size: 0.92rem;
  font-weight: 600;
  box-shadow: 0 6px 24px rgba(0,0,0,0.22);
  z-index: 200;
  white-space: nowrap;
  transition: top 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
  pointer-events: none;
  text-align: center;
}
.toast.show { top: 1rem; }

/* LTR inputs */
#phone, #shipmentNumber {
  direction: ltr;
  text-align: left;
}
