:root {
  --primary: #2563eb;
  --primary-dark: #1e40af;
  --header-bg: linear-gradient(135deg, #1e3a8a 0%, #2563eb 100%);
  --secondary: #059669;
  --accent: #f59e0b;
  --danger: #ef4444;
  --bg: #f8fafc;
  --surface: #ffffff;
  --text-main: #0f172a;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --radius: 16px;
  --shadow-sm: 0 2px 6px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.1);
}

html, body {
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  background-color: var(--bg);
  color: var(--text-main);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  -webkit-tap-highlight-color: transparent;
  -webkit-font-smoothing: antialiased;
}

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

/* Slim Modern Blue Header */
.app-header {
  background: var(--header-bg);
  padding: 6px 16px;
  min-height: 40px;
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: 0 2px 8px rgba(30, 58, 138, 0.2);
  color: #ffffff;
}

.header-inner {
  max-width: 540px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand-badge {
  display: flex;
  align-items: center;
  gap: 8px;
}

.brand-logo-img {
  width: 26px;
  height: 26px;
  border-radius: 6px;
  object-fit: cover;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.35);
}

.brand-title {
  font-size: 0.92rem;
  font-weight: 700;
  color: #ffffff;
  letter-spacing: -0.1px;
  line-height: 1.1;
}

.brand-sub {
  font-size: 0.72rem;
  color: #bfdbfe;
  font-weight: 500;
  margin-top: 2px;
}

.header-status-badge {
  background: rgba(255, 255, 255, 0.18);
  backdrop-filter: blur(8px);
  color: #ffffff;
  padding: 5px 11px;
  border-radius: 20px;
  font-size: 0.72rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid rgba(255, 255, 255, 0.25);
}

.status-dot {
  width: 7px;
  height: 7px;
  background: #34d399;
  border-radius: 50%;
  box-shadow: 0 0 8px #34d399;
}

/* Container */
.container {
  max-width: 540px;
  width: 100%;
  margin: 0 auto;
  padding: 16px;
  flex: 1;
}

/* Form Card */
.form-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow-md);
  border: 1px solid var(--border);
  margin-bottom: 20px;
}

.card-top-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
  padding-bottom: 12px;
  border-bottom: 1px solid #f1f5f9;
}

.card-title-group {
  display: flex;
  flex-direction: column;
}

.card-title {
  font-size: 1.15rem;
  font-weight: 800;
  color: #1e3a8a;
  display: flex;
  align-items: center;
  gap: 6px;
}

.card-subtext {
  font-size: 0.72rem;
  color: var(--text-muted);
}

/* Sleek Compact Scan Button */
.btn-compact-scan {
  background: #eff6ff;
  border: 1.5px solid #3b82f6;
  border-radius: 10px;
  padding: 7px 12px;
  display: flex;
  align-items: center;
  gap: 6px;
  color: #1d4ed8;
  font-weight: 800;
  font-size: 0.8rem;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-compact-scan:active {
  background: #dbeafe;
  transform: scale(0.97);
}

/* Inputs */
.input-stack {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 14px;
}

.input-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.input-label {
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.4px;
  color: #475569;
  text-transform: uppercase;
}

.input-box-wrap {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
}

.input-icon {
  position: absolute;
  left: 12px;
  color: #64748b;
  font-size: 16px;
  pointer-events: none;
}

.input-field {
  width: 100%;
  height: 44px;
  padding: 0 36px 0 38px;
  background: #f8fafc;
  border: 1.5px solid #cbd5e1;
  border-radius: 10px;
  font-size: 0.95rem;
  font-weight: 700;
  color: #0f172a;
  outline: none;
  transition: all 0.2s;
  font-family: monospace, sans-serif;
  letter-spacing: 0.5px;
}

.input-field:focus {
  background: #ffffff;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.clear-btn {
  position: absolute;
  right: 10px;
  background: none;
  border: none;
  color: #94a3b8;
  cursor: pointer;
  padding: 4px;
  font-size: 14px;
  display: none;
}

.input-field:not(:placeholder-shown) + .clear-btn {
  display: block;
}

/* Captcha Blocks - Mobile Responsive (Never Overflows) */
.captcha-box {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 11px 12px;
  margin-bottom: 12px;
}

.captcha-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.captcha-title {
  font-size: 0.72rem;
  font-weight: 800;
  color: #334155;
  text-transform: uppercase;
}

.auto-badge {
  background: #dcfce7;
  color: #166534;
  font-size: 0.65rem;
  padding: 2px 7px;
  border-radius: 6px;
  font-weight: 700;
}

.captcha-controls-row {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
}

.captcha-img-holder {
  background: #ffffff;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  height: 40px;
  flex: 1.2;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  padding: 2px;
}

.captcha-img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.refresh-captcha-btn {
  background: #e2e8f0;
  border: none;
  border-radius: 8px;
  width: 38px;
  height: 40px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: #334155;
  font-size: 16px;
}

.captcha-input {
  flex: 1;
  min-width: 0;
  height: 40px;
  padding: 0 8px;
  background: #ffffff;
  border: 1.5px solid #cbd5e1;
  border-radius: 8px;
  font-size: 0.95rem;
  font-weight: 800;
  letter-spacing: 1.5px;
  text-align: center;
  outline: none;
  text-transform: lowercase;
}

.captcha-input:focus {
  border-color: var(--primary);
}

/* Primary Action Button */
.btn-primary {
  width: 100%;
  height: 48px;
  background: linear-gradient(135deg, #1d4ed8, #2563eb);
  color: #ffffff;
  border: none;
  border-radius: 12px;
  font-size: 1rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(37, 99, 235, 0.35);
  margin-top: 4px;
  transition: all 0.2s;
}

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

/* Status Error Box */
.status-error-box {
  display: none;
  background: #fef2f2;
  border: 1.5px solid #f87171;
  border-radius: 12px;
  padding: 13px 15px;
  margin-top: 14px;
  color: #991b1b;
  font-size: 0.88rem;
  font-weight: 600;
  line-height: 1.4;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  animation: fadeIn 0.3s ease;
  box-shadow: 0 2px 8px rgba(239, 68, 68, 0.12);
}

.status-error-box span {
  font-size: 1.2rem;
  flex-shrink: 0;
}

/* Results Display */
.result-section {
  display: none;
  margin-bottom: 24px;
  animation: fadeIn 0.3s ease;
}

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

.result-card-container {
  background: #ffffff;
  border-radius: var(--radius);
  border: 1px solid #cbd5e1;
  padding: 16px;
  box-shadow: var(--shadow-lg);
}

.result-top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 2px solid #f97316;
  padding-bottom: 12px;
  margin-bottom: 14px;
}

.result-brand-box {
  display: flex;
  align-items: center;
  gap: 10px;
}

.report-badge-icon {
  background: #e6f7ec;
  color: #10b981;
  width: 38px;
  height: 38px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
}

.result-brand-title {
  font-size: 1.08rem;
  font-weight: 900;
  color: #1e3a8a;
  letter-spacing: -0.3px;
}

.result-brand-subtitle {
  font-size: 0.68rem;
  font-weight: 700;
  color: #059669;
}

.status-badge-live {
  background: #d1fae5;
  color: #065f46;
  padding: 3px 8px;
  border-radius: 20px;
  font-size: 0.68rem;
  font-weight: 800;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.checked-time {
  font-size: 0.65rem;
  color: #64748b;
  text-align: right;
  margin-top: 3px;
}

/* Applicant Info Strip */
.applicant-info-card {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 12px 14px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 16px;
}

.info-item-label {
  font-size: 0.65rem;
  font-weight: 800;
  color: #64748b;
  text-transform: uppercase;
  margin-bottom: 2px;
}

.info-item-value {
  font-size: 0.9rem;
  font-weight: 800;
  color: #0f172a;
  word-break: break-word;
}

.val-blue { color: #2563eb; }
.val-purple { color: #7c3aed; }
.val-green { color: #059669; }

/* Status Cards Grid */
.status-cards-grid {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 14px;
}

.portal-status-card {
  border: 2px solid #10b981;
  border-radius: 16px;
  padding: 16px;
  background: linear-gradient(180deg, #ecfdf5 0%, #ffffff 70%);
  box-shadow: 0 4px 18px rgba(16, 185, 129, 0.12);
  transition: all 0.3s ease;
}

.portal-status-card.theme-success {
  border-color: #10b981;
  background: linear-gradient(180deg, #ecfdf5 0%, #ffffff 70%);
}

.portal-status-card.theme-pending {
  border-color: #3b82f6;
  background: linear-gradient(180deg, #eff6ff 0%, #ffffff 70%);
}

.portal-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.portal-header-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #dcfce7;
  color: #15803d;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.6px;
  text-transform: uppercase;
}

.pulse-dot {
  width: 7px;
  height: 7px;
  background-color: #16a34a;
  border-radius: 50%;
  display: inline-block;
  box-shadow: 0 0 0 2px rgba(22, 163, 74, 0.25);
}

.status-main-msg {
  font-size: 1.12rem;
  font-weight: 900;
  color: #15803d;
  line-height: 1.35;
  margin: 6px 0 10px 0;
  display: flex;
  align-items: center;
  gap: 8px;
  letter-spacing: -0.2px;
}

.status-msg-box {
  background: #f0fdf4;
  border: 1.5px solid #86efac;
  border-left: 5px solid #16a34a;
  border-radius: 10px;
  padding: 13px 15px;
  box-shadow: 0 2px 8px rgba(22, 163, 74, 0.06);
}

.status-sub-msg {
  font-size: 0.88rem;
  font-weight: 600;
  color: #14532d;
  line-height: 1.55;
  margin: 0;
}

.ivac-tracker-card {
  border: 1.5px solid #cbd5e1;
  border-radius: 16px;
  padding: 16px;
  background: #ffffff;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.04);
}

.ivac-card-header {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.98rem;
  font-weight: 800;
  margin-bottom: 12px;
  color: #1e3a8a;
}

/* Delivery Progress */
.progress-header-row {
  background: #f1f5f9;
  padding: 7px 10px;
  border-radius: 8px;
  margin-bottom: 10px;
}

.progress-label-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.68rem;
  font-weight: 800;
  color: #334155;
  margin-bottom: 5px;
}

.progress-bar-track {
  width: 100%;
  height: 7px;
  background: #e2e8f0;
  border-radius: 4px;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #10b981, #059669);
  border-radius: 4px;
  transition: width 0.6s ease;
}

/* Steps Table */
.steps-table {
  width: 100%;
  border-collapse: collapse;
}

.steps-table th {
  background: #eff6ff;
  color: #2563eb;
  font-size: 0.68rem;
  font-weight: 800;
  text-align: left;
  padding: 6px 8px;
}

.steps-table td {
  padding: 7px 8px;
  font-size: 0.78rem;
  border-bottom: 1px solid #f1f5f9;
  color: #1e293b;
}

.badge-done {
  background: #a7f3d0;
  color: #065f46;
  font-weight: 800;
  font-size: 0.65rem;
  padding: 2px 7px;
  border-radius: 5px;
}

.badge-pending {
  background: #e2e8f0;
  color: #64748b;
  font-weight: 800;
  font-size: 0.65rem;
  padding: 2px 7px;
  border-radius: 5px;
}

.result-footer-actions {
  display: flex;
  gap: 10px;
  margin-top: 12px;
}

.btn-secondary {
  flex: 1;
  background: #f1f5f9;
  border: 1px solid #cbd5e1;
  color: #1e293b;
  border-radius: 10px;
  padding: 10px;
  font-weight: 700;
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  cursor: pointer;
}

/* Scanner Modal */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(15, 23, 42, 0.78);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 16px;
}

.modal-card {
  background: #ffffff;
  width: 100%;
  max-width: 520px;
  border-radius: 24px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  position: relative;
  max-height: 94vh;
  overflow-y: auto;
  box-shadow: 0 25px 60px -15px rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(226, 232, 240, 0.9);
}

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

.modal-title-wrap {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.modal-title {
  font-size: 1.15rem;
  font-weight: 800;
  color: #0f172a;
  display: flex;
  align-items: center;
  gap: 8px;
  letter-spacing: -0.2px;
}

.modal-icon-badge {
  font-size: 1.1rem;
}

.modal-desc {
  font-size: 0.78rem;
  color: #64748b;
  line-height: 1.4;
  font-weight: 500;
}

.btn-close-modal {
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
  border-radius: 50%;
  width: 32px;
  height: 32px;
  min-width: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 13px;
  color: #64748b;
  transition: all 0.2s;
}

.btn-close-modal:hover {
  background: #e2e8f0;
  color: #0f172a;
  transform: scale(1.05);
}

/* Much Bigger, Immersive Viewfinder */
.viewfinder-box {
  position: relative;
  width: 100%;
  height: 380px;
  min-height: 320px;
  background: #090d16;
  border-radius: 18px;
  overflow: hidden;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: inset 0 0 24px rgba(0, 0, 0, 0.7), 0 4px 20px rgba(0, 0, 0, 0.15);
}

@media (max-width: 480px) {
  .viewfinder-box {
    height: 48vh;
    min-height: 300px;
    max-height: 420px;
  }
}

#scanner-video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.scan-target-frame {
  position: absolute;
  width: 88%;
  height: 84%;
  border: 1.5px solid rgba(56, 189, 248, 0.35);
  border-radius: 16px;
  box-shadow: 0 0 0 4000px rgba(9, 13, 22, 0.55);
  pointer-events: none;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
}

/* High-Tech HUD Corners */
.corner-tl {
  position: absolute;
  top: -2px;
  left: -2px;
  width: 24px;
  height: 24px;
  border-top: 3.5px solid #38bdf8;
  border-left: 3.5px solid #38bdf8;
  border-top-left-radius: 14px;
}

.corner-tr {
  position: absolute;
  top: -2px;
  right: -2px;
  width: 24px;
  height: 24px;
  border-top: 3.5px solid #38bdf8;
  border-right: 3.5px solid #38bdf8;
  border-top-right-radius: 14px;
}

.corner-bl {
  position: absolute;
  bottom: -2px;
  left: -2px;
  width: 24px;
  height: 24px;
  border-bottom: 3.5px solid #38bdf8;
  border-left: 3.5px solid #38bdf8;
  border-bottom-left-radius: 14px;
}

.corner-br {
  position: absolute;
  bottom: -2px;
  right: -2px;
  width: 24px;
  height: 24px;
  border-bottom: 3.5px solid #38bdf8;
  border-right: 3.5px solid #38bdf8;
  border-bottom-right-radius: 14px;
}

.frame-guide-badge {
  margin-top: 14px;
  background: rgba(15, 23, 42, 0.78);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  border: 1px solid rgba(56, 189, 248, 0.35);
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 0.74rem;
  color: #bae6fd;
  font-weight: 600;
  letter-spacing: 0.2px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
}

.scan-laser-line {
  position: absolute;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, transparent, #38bdf8 25%, #60a5fa 50%, #38bdf8 75%, transparent);
  box-shadow: 0 0 16px #38bdf8, 0 0 30px #0284c7;
  animation: scanLaser 2.4s infinite alternate ease-in-out;
}

@keyframes scanLaser {
  0% { top: 8px; }
  100% { top: calc(100% - 12px); }
}

.scanner-hint-box {
  background: #f0f9ff;
  border: 1px solid #bae6fd;
  border-radius: 10px;
  padding: 9px 12px;
  font-size: 0.78rem;
  color: #0369a1;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  line-height: 1.4;
  font-weight: 600;
}

.hint-dot {
  width: 8px;
  height: 8px;
  min-width: 8px;
  background: #0ea5e9;
  border-radius: 50%;
  animation: pulseDot 1.5s infinite;
}

.modal-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

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

.btn-capture {
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  color: white;
  border: none;
  border-radius: 12px;
  height: 48px;
  font-weight: 800;
  font-size: 0.95rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(37, 99, 235, 0.35);
  transition: all 0.15s ease;
}

.btn-capture:hover:not(:disabled) {
  background: linear-gradient(135deg, #1d4ed8, #1e40af);
  box-shadow: 0 6px 18px rgba(37, 99, 235, 0.45);
  transform: translateY(-1px);
}

.btn-capture:active:not(:disabled) {
  transform: translateY(1px);
}

.btn-capture:disabled {
  opacity: 0.7;
  cursor: not-allowed;
}

.btn-camera-switch {
  background: #f8fafc;
  border: 1.5px solid #cbd5e1;
  border-radius: 11px;
  height: 42px;
  color: #334155;
  font-weight: 700;
  font-size: 0.82rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-camera-switch:hover {
  background: #f1f5f9;
  border-color: #94a3b8;
}

.file-upload-label {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: #f8fafc;
  border: 1.5px dashed #94a3b8;
  border-radius: 11px;
  height: 42px;
  color: #1e293b;
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s ease;
}

.file-upload-label:hover {
  background: #eff6ff;
  border-color: #3b82f6;
  color: #1d4ed8;
}

/* Auto-fill flash animation for input fields */
@keyframes fieldAutoFilled {
  0% {
    border-color: #10b981;
    box-shadow: 0 0 0 4px rgba(16, 185, 129, 0.35);
    background-color: #f0fdf4;
  }
  50% {
    border-color: #10b981;
    box-shadow: 0 0 0 6px rgba(16, 185, 129, 0.25);
    background-color: #f0fdf4;
  }
  100% {
    border-color: #cbd5e1;
    box-shadow: none;
    background-color: #ffffff;
  }
}

.field-autofill-flash {
  animation: fieldAutoFilled 2.2s ease-out;
}

/* Toast */
.toast-container {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 90%;
  max-width: 380px;
  pointer-events: none;
}

.toast {
  background: #1e293b;
  color: white;
  padding: 10px 16px;
  border-radius: 25px;
  font-size: 0.82rem;
  font-weight: 600;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: center;
}

.toast.success { background: #065f46; }
.toast.error { background: #991b1b; }

.spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-radius: 50%;
  border-top-color: #ffffff;
  animation: spin 0.8s linear infinite;
}

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