*, *::before, *::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #f3f4f6;
}

.form-wrapper {
  width: 100%;
  max-width: 900px;
}

.card {
  background: #ffffff;
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.08);
  border: 1px solid #e5e7eb;
  padding: 24px 24px 16px;
}

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

/* Logo standard: 2x size (120px height, 400px max-width) - Global standard for all forms */
.company-logo-container {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
}

.company-logo {
  /* 2x standard size: 60px * 2 = 120px */
  height: 120px;
  width: auto;
  max-width: 400px;
  object-fit: contain;
  filter: brightness(0) invert(1);
}

body.light .company-logo {
  filter: none;
}

/* Responsive adjustments for smaller screens */
@media (max-width: 1024px) {
  .company-logo {
    height: 100px;
    max-width: 350px;
  }
}

@media (max-width: 768px) {
  .company-logo {
    height: 80px;
    max-width: 280px;
  }
}

@media (max-width: 480px) {
  .company-logo {
    height: 60px;
    max-width: 200px;
  }
}

.company-th {
  font-size: 14px;
  color: #fff;
  line-height: 1.4;
}

.form-title-container {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 12px;
  min-width: 200px;
}

.form-title {
  font-weight: 600;
  font-size: 16px;
  margin-top: 4px;
  color: #111827;
  text-align: right;
  width: 100%;
}

.user-portal-btn {
  display: flex !important;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white !important;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
  width: auto;
  min-width: 180px;
  visibility: visible !important;
  opacity: 1 !important;
}

.user-portal-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.user-portal-btn:active {
  transform: translateY(0);
}

.portal-icon {
  font-size: 18px;
}

.portal-text {
  white-space: nowrap;
}

/* Portal Access Modal */
.portal-access-modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  z-index: 10000;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.portal-access-modal.show {
  display: flex;
}

.portal-access-modal-content {
  background: white;
  border-radius: 16px;
  width: 100%;
  max-width: 600px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  animation: modalSlideIn 0.3s ease;
}

@keyframes modalSlideIn {
  from {
    opacity: 0;
    transform: translateY(-20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.portal-access-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 24px;
  border-bottom: 1px solid #e5e7eb;
}

.portal-access-header h2 {
  margin: 0;
  font-size: 20px;
  font-weight: 600;
  color: #111827;
}

.portal-close-btn {
  background: none;
  border: none;
  font-size: 28px;
  color: #6b7280;
  cursor: pointer;
  padding: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  transition: all 0.2s;
}

.portal-close-btn:hover {
  background: #f3f4f6;
  color: #111827;
}

.portal-access-body {
  padding: 24px;
}

.portal-instruction {
  text-align: center;
  color: #4b5563;
  margin-bottom: 24px;
  font-size: 15px;
  line-height: 1.6;
}

.portal-scanner-container {
  position: relative;
  width: 100%;
  height: 300px;
  background: #000;
  border-radius: 12px;
  overflow: hidden;
  margin-bottom: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.portal-scanner-container video {
  position: absolute !important;
  top: 0 !important;
  left: 0 !important;
  width: 100% !important;
  height: 100% !important;
  object-fit: cover !important;
  z-index: 1 !important;
  display: block !important;
  visibility: visible !important;
  opacity: 1 !important;
  background: #000 !important;
}

.portal-scanner-container canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 2;
  pointer-events: none;
}

.portal-scanner-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: #9ca3af;
}

.portal-scanner-icon {
  font-size: 48px;
  margin-bottom: 12px;
}

.portal-scanner-video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scaleX(1);
}

.portal-scanner-canvas {
  display: none;
}

.portal-scanner-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  z-index: 10;
}

.portal-scanner-frame {
  width: 80%;
  max-width: 300px;
  height: 150px;
  border: 2px solid #3b82f6;
  border-radius: 8px;
  position: relative;
  box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.5);
}

.portal-scanner-corner {
  position: absolute;
  width: 24px;
  height: 24px;
  border: 3px solid #3b82f6;
}

.portal-scanner-corner-tl {
  top: -3px;
  left: -3px;
  border-right: none;
  border-bottom: none;
  border-top-left-radius: 8px;
}

.portal-scanner-corner-tr {
  top: -3px;
  right: -3px;
  border-left: none;
  border-bottom: none;
  border-top-right-radius: 8px;
}

.portal-scanner-corner-bl {
  bottom: -3px;
  left: -3px;
  border-right: none;
  border-top: none;
  border-bottom-left-radius: 8px;
}

.portal-scanner-corner-br {
  bottom: -3px;
  right: -3px;
  border-left: none;
  border-top: none;
  border-bottom-right-radius: 8px;
}

.portal-scanner-line {
  position: absolute;
  top: 50%;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(to right, transparent, #3b82f6, transparent);
  animation: scanLine 2s linear infinite;
}

@keyframes scanLine {
  0%, 100% {
    transform: translateY(-75px);
  }
  50% {
    transform: translateY(75px);
  }
}

.portal-scanner-instruction {
  margin-top: 20px;
  color: white;
  font-size: 14px;
  text-align: center;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
}

.portal-access-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
}

.portal-status {
  margin-top: 16px;
  text-align: center;
  font-size: 14px;
  color: #6b7280;
  min-height: 20px;
}

hr.divider {
  border: none;
  border-top: 1px solid #e5e7eb;
  margin: 8px 0 16px;
}

.success-message {
  display: none;
}

.modal-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  padding: 16px;
  animation: fadeIn 0.3s ease;
}

.modal-overlay.show {
  display: flex;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal-content {
  background: #ffffff;
  border-radius: 16px;
  padding: 32px;
  max-width: 400px;
  width: 100%;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  text-align: center;
  animation: slideUp 0.3s ease;
}

@keyframes slideUp {
  from {
    transform: translateY(20px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.modal-icon {
  width: 64px;
  height: 64px;
  margin: 0 auto 20px;
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
  color: #ffffff;
}

.modal-title {
  font-size: 24px;
  font-weight: 700;
  color: #111827;
  margin-bottom: 12px;
}

.modal-message {
  font-size: 16px;
  color: #6b7280;
  margin-bottom: 24px;
  line-height: 1.5;
}

.modal-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
}

.modal-actions button {
  min-width: 120px;
}

.form-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr);
  gap: 16px 24px;
}

@media (max-width: 720px) {
  .card {
    padding: 18px 16px 12px;
  }
  .form-grid {
    grid-template-columns: minmax(0, 1fr);
  }
  .company-logo {
    height: 45px;
    max-width: 150px;
  }
  .card-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }
}

.section {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.section-title {
  font-size: 14px;
  font-weight: 600;
  color: #111827;
  margin-bottom: 2px;
}

.field-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
  position: relative;
}

label {
  font-size: 13px;
  color: #374151;
}

.label-main {
  font-weight: 500;
}

/* Autocomplete Styles */
.autocomplete-wrapper {
  position: relative;
  width: 100%;
}

.autocomplete-dropdown {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: #ffffff;
  border: 1px solid #d1d5db;
  border-top: none;
  border-radius: 0 0 8px 8px;
  max-height: 300px;
  overflow-y: auto;
  z-index: 1000;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
  margin-top: -1px;
}

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

.autocomplete-item {
  padding: 10px 12px;
  cursor: pointer;
  border-bottom: 1px solid #f3f4f6;
  transition: background-color 0.15s ease;
}

.autocomplete-item:hover,
.autocomplete-item.highlighted {
  background-color: #eff6ff;
}

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

.autocomplete-item-name {
  font-weight: 500;
  color: #111827;
  font-size: 14px;
  margin-bottom: 2px;
}

.autocomplete-item-details {
  font-size: 12px;
  color: #6b7280;
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.autocomplete-item-detail {
  display: flex;
  align-items: center;
  gap: 4px;
}

.autocomplete-item-detail strong {
  color: #4b5563;
}

input[type="text"],
input[type="date"],
input[type="time"],
textarea {
  width: 100%;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid #d1d5db;
  font-size: 13px;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
  background: #f9fafb;
}

input:focus,
textarea:focus {
  border-color: #2563eb;
  box-shadow: 0 0 0 1px rgba(37, 99, 235, 0.12);
  background: #ffffff;
}

input.error,
textarea.error {
  border-color: #ef4444;
  box-shadow: 0 0 0 1px rgba(239, 68, 68, 0.12);
}

input[readonly] {
  background-color: #f3f4f6;
  cursor: not-allowed;
}

.error-message {
  color: #ef4444;
  font-size: 12px;
  margin-top: 4px;
  display: none;
}

.error-message.show {
  display: block;
}

.checkbox-group.error {
  border-color: #ef4444;
  background: #fef2f2;
}

textarea {
  resize: vertical;
  min-height: 80px;
}

.checkbox-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid #e5e7eb;
  background: #f9fafb;
}

.checkbox-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: #374151;
}

.checkbox-item input[type="checkbox"] {
  width: 14px;
  height: 14px;
}

.inline-row {
  display: flex;
  gap: 8px;
}

.inline-row > .field-group {
  flex: 1;
}

.approvals {
  margin-top: 12px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  font-size: 13px;
}

@media (max-width: 640px) {
  .approvals {
    grid-template-columns: minmax(0, 1fr);
  }
}

.signature-box {
  border-radius: 8px;
  border: 1px dashed #d1d5db;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: #f9fafb;
}

.signature-line {
  border-bottom: 1px solid #d1d5db;
  height: 26px;
  margin-bottom: 2px;
}

.signature-label-row {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 11px;
  color: #6b7280;
}

.signature-date {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
}

.signature-date input[type="date"] {
  padding: 4px 8px;
  font-size: 12px;
  border-radius: 6px;
  background: #f9fafb;
}

.card-footer {
  margin-top: 18px;
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 12px;
  font-size: 11px;
  color: #6b7280;
  flex-wrap: wrap;
}

.actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

button {
  border: none;
  border-radius: 999px;
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: transform 0.08s ease, box-shadow 0.08s ease, background-color 0.12s ease, opacity 0.12s ease;
}

button:active {
  transform: translateY(1px);
  box-shadow: none;
}

.btn-primary {
  background: #2563eb;
  color: #ffffff;
  box-shadow: 0 4px 10px rgba(37, 99, 235, 0.3);
}

.btn-primary:hover {
  background: #1d4ed8;
}

.btn-secondary {
  background: #e5e7eb;
  color: #111827;
}

.btn-secondary:hover {
  background: #d1d5db;
}

.btn-test {
  background: #10b981;
  color: #ffffff;
  box-shadow: 0 4px 10px rgba(16, 185, 129, 0.3);
}

.btn-test:hover {
  background: #059669;
}

.btn-test:disabled {
  background: #9ca3af;
  cursor: not-allowed;
  box-shadow: none;
}

/* Barcode Scan Result Popup */
.barcode-scan-popup {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  pointer-events: none;
  animation: fadeIn 0.3s ease;
}

.barcode-scan-popup.show {
  display: flex;
  pointer-events: auto;
}

.barcode-scan-popup.success {
  background: rgba(16, 185, 129, 0.95);
  backdrop-filter: blur(8px);
}

.barcode-scan-popup.error {
  background: rgba(239, 68, 68, 0.95);
  backdrop-filter: blur(8px);
}

.barcode-scan-popup-content {
  background: #ffffff;
  border-radius: 24px;
  padding: 32px;
  max-width: 400px;
  width: 90%;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  animation: slideUp 0.4s ease;
  transform: scale(0.9);
  animation-fill-mode: forwards;
}

.barcode-scan-popup.show .barcode-scan-popup-content {
  animation: slideUpScale 0.4s ease forwards;
}

.barcode-scan-icon {
  width: 80px;
  height: 80px;
  margin: 0 auto 20px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 40px;
  font-weight: bold;
  animation: scaleIn 0.3s ease 0.2s both;
}

.barcode-scan-popup.success .barcode-scan-icon {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  color: #ffffff;
}

.barcode-scan-popup.error .barcode-scan-icon {
  background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
  color: #ffffff;
}

.barcode-scan-title {
  font-size: 24px;
  font-weight: 700;
  color: #111827;
  margin-bottom: 12px;
  animation: fadeInUp 0.3s ease 0.3s both;
}

.barcode-scan-message {
  font-size: 16px;
  color: #6b7280;
  margin-bottom: 16px;
  line-height: 1.5;
  animation: fadeInUp 0.3s ease 0.4s both;
}

.barcode-scan-code {
  font-size: 18px;
  font-weight: 600;
  color: #111827;
  background: #f3f4f6;
  padding: 12px 20px;
  border-radius: 12px;
  font-family: 'Courier New', monospace;
  letter-spacing: 2px;
  animation: fadeInUp 0.3s ease 0.5s both;
}

@keyframes slideUpScale {
  0% {
    transform: translateY(30px) scale(0.9);
    opacity: 0;
  }
  100% {
    transform: translateY(0) scale(1);
    opacity: 1;
  }
}

@keyframes scaleIn {
  0% {
    transform: scale(0);
    opacity: 0;
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

@keyframes fadeInUp {
  0% {
    transform: translateY(10px);
    opacity: 0;
  }
  100% {
    transform: translateY(0);
    opacity: 1;
  }
}

/* Print styles */
@media print {
  body {
    background: #ffffff;
    padding: 0;
  }
  .card {
    box-shadow: none;
    border-radius: 0;
    border: none;
  }
  .company-logo {
    height: 50px;
    max-width: 180px;
  }
  .actions,
  .success-message,
  .modal-overlay,
  .autocomplete-dropdown,
  .barcode-scanner-section {
    display: none !important;
  }
}

/* Barcode Scanner Styles */
.barcode-scanner-section {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid #e5e7eb;
}

.barcode-scanner-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.scanner-controls {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  flex-wrap: wrap;
}

.btn-camera-switch {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 8px 16px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.btn-camera-switch:hover {
  background: linear-gradient(135deg, #764ba2 0%, #667eea 100%);
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

.btn-camera-switch:active {
  transform: translateY(0);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.btn-camera-switch:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.btn-camera-switch span {
  display: inline-block;
}

#switchCameraIcon {
  font-size: 1.1rem;
}

@media (max-width: 768px) {
  .barcode-scanner-header {
    flex-direction: column;
    align-items: stretch;
  }
  
  .scanner-controls {
    width: 100%;
    justify-content: space-between;
  }
  
  .btn-camera-switch {
    flex: 1;
    justify-content: center;
  }
}

.btn-scanner-toggle {
  padding: 8px 16px;
  border: 1px solid #2563eb;
  border-radius: 8px;
  background: #2563eb;
  color: #ffffff;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.btn-scanner-toggle:hover {
  background: #1d4ed8;
  transform: translateY(-1px);
  box-shadow: 0 2px 4px rgba(37, 99, 235, 0.3);
}

.btn-scanner-toggle.active {
  background: #ef4444;
  border-color: #ef4444;
}

.btn-scanner-toggle.active:hover {
  background: #dc2626;
}

.barcode-scanner-container {
  position: relative;
  width: 100%;
  max-width: 100%;
  min-height: 240px;
  aspect-ratio: 4 / 3;
  background: #f9fafb;
  border-radius: 8px;
  overflow: hidden;
  border: 2px solid #e5e7eb;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 50px;
  margin-top: 20px;
}

.scanner-placeholder {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
  text-align: center;
  z-index: 5;
}

.scanner-placeholder-icon {
  font-size: 48px;
  margin-bottom: 12px;
  opacity: 0.6;
}

.scanner-placeholder-text {
  font-size: 14px;
  font-weight: 500;
  color: #374151;
  margin-bottom: 8px;
}

.scanner-placeholder-hint {
  font-size: 12px;
  color: #6b7280;
  line-height: 1.5;
}

.scanner-video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  /* Removed mirroring - barcodes/QR codes need to be readable */
}

.scanner-canvas {
  display: none;
}

.scanner-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  z-index: 10;
  padding: 60px 20px 40px 20px;
  box-sizing: border-box;
}

.scanner-frame {
  position: relative;
  width: 85%;
  max-width: 400px;
  height: 200px;
  border: 2px solid rgba(37, 99, 235, 0.8);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.3);
  margin: 0 auto;
  flex-shrink: 0;
}

.scanner-corner {
  position: absolute;
  width: 24px;
  height: 24px;
  border: 3px solid #10b981;
}

.scanner-corner-tl {
  top: -3px;
  left: -3px;
  border-right: none;
  border-bottom: none;
  border-top-left-radius: 8px;
}

.scanner-corner-tr {
  top: -3px;
  right: -3px;
  border-left: none;
  border-bottom: none;
  border-top-right-radius: 8px;
}

.scanner-corner-bl {
  bottom: -3px;
  left: -3px;
  border-right: none;
  border-top: none;
  border-bottom-left-radius: 8px;
}

.scanner-corner-br {
  bottom: -3px;
  right: -3px;
  border-left: none;
  border-top: none;
  border-bottom-right-radius: 8px;
}

.scanner-line {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(to right, transparent, #10b981, transparent);
  animation: scanner-line 2s ease-in-out infinite;
  transform-origin: center;
}

@keyframes scanner-line {
  0% {
    top: 0;
    opacity: 0;
  }
  10% {
    opacity: 1;
  }
  90% {
    opacity: 1;
  }
  100% {
    top: 100%;
    opacity: 0;
  }
}

.scanner-instruction {
  margin-top: 24px;
  color: #ffffff;
  font-size: 13px;
  text-align: center;
  background: rgba(0, 0, 0, 0.6);
  padding: 8px 16px;
  border-radius: 20px;
  backdrop-filter: blur(4px);
  flex-shrink: 0;
  line-height: 1.5;
  max-width: 90%;
  word-wrap: break-word;
}

.scanner-status {
  position: absolute;
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
  padding: 8px 16px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
  z-index: 20;
  display: none;
  white-space: nowrap;
  max-width: 90%;
  text-align: center;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  pointer-events: none;
}

.scanner-status.success {
  display: block;
  background: #10b981;
  color: #ffffff;
  animation: scanner-success 0.5s ease;
}

.scanner-status.error {
  display: block;
  background: #ef4444;
  color: #ffffff;
  animation: scanner-error 0.5s ease;
}

.scanner-status.info {
  display: block;
  background: #3b82f6;
  color: #ffffff;
  animation: scanner-info 0.5s ease;
}

@keyframes scanner-success {
  0% {
    transform: translateX(-50%) scale(0.8);
    opacity: 0;
  }
  50% {
    transform: translateX(-50%) scale(1.1);
  }
  100% {
    transform: translateX(-50%) scale(1);
    opacity: 1;
  }
}

@keyframes scanner-error {
  0%, 100% {
    transform: translateX(-50%);
  }
  25%, 75% {
    transform: translateX(-52%);
  }
  50% {
    transform: translateX(-48%);
  }
}

@keyframes scanner-info {
  0% {
    transform: translateX(-50%) scale(0.9);
    opacity: 0;
  }
  100% {
    transform: translateX(-50%) scale(1);
    opacity: 1;
  }
}

/* Scanner Status Overlay */
/* IMPORTANT: z-index is lower than scanner-overlay to ensure aiming box is always visible */
.scanner-status-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: none; /* Hidden by default, only shown for success/error/cooldown */
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
  z-index: 5; /* Lower than scanner-overlay (z-index: 10) to keep aiming box visible */
  border-radius: 12px;
  transition: opacity 0.3s ease;
  pointer-events: none; /* Allow clicks to pass through when hidden */
}

.scanner-status-overlay.scanning {
  background: rgba(59, 130, 246, 0.8);
}

.scanner-status-overlay.success {
  background: rgba(16, 185, 129, 0.9);
}

.scanner-status-overlay.error {
  background: rgba(239, 68, 68, 0.9);
}

.scanner-status-overlay.cooldown {
  background: rgba(107, 114, 128, 0.8);
}

.scanner-status-icon {
  font-size: 64px;
  margin-bottom: 16px;
  animation: pulse 1.5s ease-in-out infinite;
}

.scanner-status-overlay.success .scanner-status-icon {
  animation: success-bounce 0.6s ease;
}

.scanner-status-overlay.error .scanner-status-icon {
  animation: error-shake 0.5s ease;
}

.scanner-status-text {
  font-size: 18px;
  font-weight: 600;
  color: #ffffff;
  text-align: center;
  padding: 0 20px;
  line-height: 1.5;
}

/* Cooldown Timer */
.scanner-cooldown {
  margin-top: 24px;
  text-align: center;
  color: #ffffff;
}

.cooldown-label {
  font-size: 14px;
  margin-bottom: 8px;
  opacity: 0.9;
}

.cooldown-timer {
  font-size: 48px;
  font-weight: 700;
  line-height: 1;
  margin: 8px 0;
  animation: countdown-pulse 1s ease-in-out infinite;
}

.cooldown-seconds {
  font-size: 12px;
  opacity: 0.8;
}

@keyframes pulse {
  0%, 100% {
    transform: scale(1);
    opacity: 1;
  }
  50% {
    transform: scale(1.1);
    opacity: 0.8;
  }
}

@keyframes success-bounce {
  0% {
    transform: scale(0);
  }
  50% {
    transform: scale(1.2);
  }
  100% {
    transform: scale(1);
  }
}

@keyframes error-shake {
  0%, 100% {
    transform: translateX(0);
  }
  25% {
    transform: translateX(-10px);
  }
  75% {
    transform: translateX(10px);
  }
}

@keyframes countdown-pulse {
  0%, 100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.1);
  }
}



/* Standard theme toggle + header actions */
.header-actions, .header-right, .header-status-indicators {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.theme-toggle-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.5rem;
  height: 2.5rem;
  padding: 0;
  border-radius: 8px;
  border: 1px solid rgba(124,127,133,0.45);
  background: rgba(193,196,200,0.18);
  color: inherit;
  cursor: pointer;
}
.theme-toggle-btn:hover {
  background: rgba(193,196,200,0.28);
}
.theme-toggle-btn:focus-visible {
  outline: 2px solid rgba(123,127,133,0.7);
  outline-offset: 2px;
}
.theme-icon-light { display: none; }
.theme-icon-dark { display: inline; }
body.light .theme-icon-light { display: inline; }
body.light .theme-icon-dark { display: none; }
body.light {
  background-color: #f5f6f7 !important;
  color: #2b2e33 !important;
}


/* Stock-transfer receive brand token overrides */
:root {
  --background: 210 8% 11%;
  --foreground: 210 6% 96%;
  --card: 210 8% 14%;
  --card-foreground: 210 6% 96%;
  --primary: 210 6% 77%;
  --primary-foreground: 210 8% 11%;
  --secondary: 210 7% 18%;
  --secondary-foreground: 210 6% 96%;
  --muted: 210 7% 18%;
  --muted-foreground: 210 4% 64%;
  --border: 210 6% 22%;
  --input: 210 7% 18%;
  --ring: 210 6% 77%;
}

body.light {
  --background: 210 20% 98%;
  --foreground: 210 10% 12%;
  --card: 0 0% 100%;
  --card-foreground: 210 10% 12%;
  --primary: 210 12% 30%;
  --primary-foreground: 0 0% 100%;
  --secondary: 210 16% 93%;
  --secondary-foreground: 210 10% 12%;
  --muted: 210 16% 93%;
  --muted-foreground: 210 8% 46%;
  --border: 210 14% 86%;
  --input: 0 0% 100%;
  --ring: 210 12% 30%;
}

body {
  background: hsl(var(--background)) !important;
  color: hsl(var(--foreground)) !important;
}

.card,
.portal-access-modal-content,
.modal-content,
.barcode-scan-popup-content {
  background: hsl(var(--card)) !important;
  color: hsl(var(--card-foreground)) !important;
  border-color: hsl(var(--border)) !important;
}

hr.divider,
.barcode-scanner-section,
.portal-access-header,
.signature-box,
.scanner-frame,
.checkbox-group {
  border-color: hsl(var(--border)) !important;
}

label,
.section-title,
.modal-title,
.barcode-scan-title,
.autocomplete-item-name,
.scanner-placeholder-text {
  color: hsl(var(--foreground)) !important;
}

.company-th,
.portal-instruction,
.modal-message,
.barcode-scan-message,
.scanner-placeholder-hint,
.autocomplete-item-details,
.signature-label-row,
.card-footer,
.error-message {
  color: hsl(var(--muted-foreground)) !important;
}

input[type="text"],
input[type="date"],
input[type="time"],
textarea,
.autocomplete-dropdown,
input[readonly] {
  background: hsl(var(--input)) !important;
  color: hsl(var(--foreground)) !important;
  border-color: hsl(var(--border)) !important;
}

input:focus,
textarea:focus {
  border-color: hsl(var(--ring)) !important;
  box-shadow: 0 0 0 1px hsl(var(--ring) / 0.22) !important;
}

.btn-primary,
.btn-scanner-toggle,
.btn-camera-switch {
  background: hsl(var(--primary)) !important;
  color: hsl(var(--primary-foreground)) !important;
  border-color: hsl(var(--primary)) !important;
}

.btn-primary:hover,
.btn-scanner-toggle:hover,
.btn-camera-switch:hover {
  background: hsl(var(--primary) / 0.9) !important;
}

.btn-secondary {
  background: hsl(var(--secondary)) !important;
  color: hsl(var(--secondary-foreground)) !important;
  border-color: hsl(var(--border)) !important;
}

.btn-secondary:hover {
  background: hsl(var(--secondary) / 0.84) !important;
}

/* artinian-site-footer — copyright on all form pages */
.artinian-site-footer {
  text-align: center;
  padding: 14px 12px 10px;
  margin-top: 32px;
  border-top: 1px solid hsl(var(--border) / 0.6);
  font-size: 0.75rem;
  letter-spacing: 0.02em;
  color: hsl(var(--muted-foreground));
}
.artinian-site-footer p { margin: 0; }

