:root {
  --bg: #0f1419;
  --surface: #1a2332;
  --border: #2d3a4f;
  --text: #e8edf5;
  --muted: #8b9cb3;
  --accent: #3b82f6;
  --success: #22c55e;
  --danger: #ef4444;
  --radius: 12px;
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: radial-gradient(ellipse at top, #1e293b 0%, var(--bg) 55%);
  color: var(--text);
}

.container {
  max-width: 880px;
  margin: 0 auto;
  padding: 2.5rem 1.25rem 4rem;
}

header {
  margin-bottom: 2rem;
}

.eyebrow {
  margin: 0 0 0.5rem;
  font-size: 0.8rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
}

h1 {
  margin: 0 0 0.75rem;
  font-size: clamp(1.75rem, 4vw, 2.25rem);
  font-weight: 700;
}

.subtitle {
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
  max-width: 60ch;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
}

.upload-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.upload-box {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 220px;
  padding: 1rem;
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
  overflow: hidden;
}

.upload-box:hover {
  border-color: var(--accent);
  background: rgba(59, 130, 246, 0.06);
}

.upload-box input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.selfie-box {
  cursor: default;
  padding-bottom: 0.75rem;
}

.selfie-box:hover {
  background: transparent;
}

.selfie-upload-area {
  position: relative;
  display: flex;
  flex: 1;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 180px;
  border-radius: calc(var(--radius) - 4px);
}

.camera-btn {
  position: relative;
  z-index: 2;
  width: calc(100% - 1rem);
  margin: 0.5rem 0 0;
  padding: 0.55rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(59, 130, 246, 0.12);
  color: var(--text);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s;
}

.camera-btn:hover {
  background: rgba(59, 130, 246, 0.22);
  border-color: var(--accent);
}

.camera-modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: rgba(0, 0, 0, 0.72);
  backdrop-filter: blur(4px);
}

.camera-dialog {
  width: min(480px, 100%);
  padding: 1.25rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.camera-dialog h2 {
  margin: 0 0 0.35rem;
  font-size: 1.1rem;
}

.camera-hint,
.liveness-hint {
  margin: 0 0 0.75rem;
  color: var(--muted);
  font-size: 0.88rem;
}

.liveness-hint.liveness-passed {
  color: var(--success);
  font-weight: 600;
}

.liveness-hint.liveness-hint-warning {
  color: var(--danger);
  font-weight: 600;
  animation: hint-warning-pulse 1.4s ease-in-out infinite;
}

@keyframes hint-warning-pulse {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.6;
  }
}

.liveness-steps {
  display: flex;
  justify-content: center;
  gap: 1.5rem;
  margin-bottom: 0.75rem;
}

.liveness-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  opacity: 0.45;
  transition: opacity 0.25s, transform 0.25s;
}

.liveness-step .step-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  font-size: 1.3rem;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border);
  transition: background 0.25s, border-color 0.25s, box-shadow 0.25s;
}

.liveness-step .step-label {
  font-size: 0.78rem;
  color: var(--muted);
  font-weight: 600;
}

.liveness-step.active {
  opacity: 1;
  transform: scale(1.08);
}

.liveness-step.active .step-icon {
  border-color: var(--accent);
  background: rgba(59, 130, 246, 0.18);
  box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.15);
  animation: step-pulse 1.3s ease-in-out infinite;
}

.liveness-step.done {
  opacity: 1;
}

.liveness-step.done .step-icon {
  border-color: var(--success);
  background: rgba(34, 197, 94, 0.18);
}

@keyframes step-pulse {
  0%, 100% {
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.15);
  }
  50% {
    box-shadow: 0 0 0 9px rgba(59, 130, 246, 0.04);
  }
}

.liveness-stage {
  position: relative;
  width: 220px;
  height: 220px;
  margin: 0.25rem auto 1rem;
}

.camera-circle {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  overflow: hidden;
  background: #000;
  box-shadow: 0 0 0 3px var(--border);
}

#camera-video {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scaleX(-1);
}

.document-stage {
  position: relative;
  width: 100%;
  max-width: 420px;
  aspect-ratio: 4 / 3;
  margin: 0.25rem auto 1rem;
  border-radius: calc(var(--radius) - 4px);
  overflow: hidden;
  background: #000;
  box-shadow: 0 0 0 3px var(--border);
}

#passport-camera-video {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.passport-guide {
  position: absolute;
  z-index: 2;
  left: 20%;
  top: 12%;
  width: 60%;
  aspect-ratio: 1.42;
  pointer-events: none;
  transition: left 0.15s ease, top 0.15s ease, width 0.15s ease, height 0.15s ease;
}

.passport-guide-side {
  position: absolute;
  display: block;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 0 0 1px rgba(15, 20, 25, 0.7), 0 0 10px rgba(255, 255, 255, 0.45);
  transition: background 0.16s ease, box-shadow 0.16s ease, transform 0.16s ease;
}

.passport-guide-top,
.passport-guide-bottom {
  left: 0;
  width: 100%;
  height: 4px;
}

.passport-guide-left,
.passport-guide-right {
  top: 0;
  width: 4px;
  height: 100%;
}

.passport-guide-top {
  top: 0;
}

.passport-guide-right {
  right: 0;
}

.passport-guide-bottom {
  bottom: 0;
}

.passport-guide-left {
  left: 0;
}

.passport-guide-side.is-detected {
  background: var(--success);
  box-shadow: 0 0 0 1px rgba(15, 20, 25, 0.7), 0 0 13px rgba(34, 197, 94, 0.9);
  transform: scale(1.025);
}

.passport-guide.is-ready .passport-guide-side {
  background: var(--success);
  box-shadow: 0 0 0 1px rgba(15, 20, 25, 0.7), 0 0 15px rgba(34, 197, 94, 1);
}

.passport-guide.is-capturing .passport-guide-side {
  animation: passport-capture-flash 0.28s ease-in-out 2;
}

.passport-overlap-badge {
  position: absolute;
  left: 50%;
  top: calc(100% + 9px);
  padding: 0.25rem 0.55rem;
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 999px;
  background: rgba(15, 20, 25, 0.8);
  color: #fff;
  font-size: 0.72rem;
  font-weight: 700;
  line-height: 1;
  white-space: nowrap;
  transform: translateX(-50%);
  backdrop-filter: blur(4px);
}

.passport-overlap-badge.is-ready {
  border-color: var(--success);
  background: rgba(20, 83, 45, 0.9);
}

.passport-camera-actions {
  justify-content: center;
}

.passport-camera-actions .camera-primary,
.passport-camera-actions .camera-secondary {
  flex: 0 1 180px;
}

@keyframes passport-capture-flash {
  50% {
    background: #fff;
    box-shadow: 0 0 22px rgba(255, 255, 255, 1);
  }
}

.liveness-subs {
  display: flex;
  justify-content: center;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
  min-height: 28px;
}

.sub-chip {
  padding: 0.3rem 0.8rem;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 600;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border);
  color: var(--muted);
  transition: background 0.25s, border-color 0.25s, color 0.25s;
}

.sub-chip.done {
  background: rgba(34, 197, 94, 0.18);
  border-color: var(--success);
  color: var(--success);
}

.camera-actions {
  display: flex;
  gap: 0.65rem;
  margin-top: 1rem;
}

.camera-primary,
.camera-secondary {
  flex: 1;
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
}

.camera-primary {
  border: none;
  background: var(--accent);
  color: white;
}

.camera-primary:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.camera-secondary {
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
}

.upload-label {
  position: absolute;
  top: 0.75rem;
  left: 0.75rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--muted);
  z-index: 1;
}

.placeholder {
  color: var(--muted);
  font-size: 0.95rem;
  text-align: center;
  padding: 2rem 1rem 0;
}

.preview {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: calc(var(--radius) - 4px);
}

.verify-status {
  margin: 0.5rem 0 0;
  padding: 0.4rem 0.6rem;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 600;
  text-align: center;
}

.verify-status.verify-pending {
  color: var(--muted);
  background: rgba(139, 156, 179, 0.12);
}

.verify-status.verify-ok {
  color: var(--success);
  background: rgba(34, 197, 94, 0.12);
}

.verify-status.verify-fail {
  color: var(--danger);
  background: rgba(239, 68, 68, 0.12);
}

.passport-inspection {
  margin-top: 1.25rem;
}

.age-photo-requirement {
  margin-top: 1.25rem;
  border-color: rgba(245, 158, 11, 0.6);
  background: linear-gradient(145deg, rgba(245, 158, 11, 0.1), rgba(15, 20, 25, 0.96));
}

.age-photo-message {
  margin: 0.75rem 0 1rem;
  color: var(--text);
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.5;
}

.age-photo-content {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(150px, 220px);
  align-items: center;
  gap: 1rem;
}

.age-photo-preview-wrap {
  min-width: 0;
}

.age-photo-content .passport-cropped-preview,
.age-photo-content .passport-crop-placeholder {
  max-height: 280px;
}

.passport-camera-purpose {
  margin: 0 0 0.85rem;
  padding: 0.65rem 0.8rem;
  border: 1px solid rgba(245, 158, 11, 0.65);
  border-radius: 10px;
  background: rgba(245, 158, 11, 0.12);
  color: #fbbf24;
  font-weight: 700;
  line-height: 1.4;
  text-align: center;
}

.passport-inspection-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.35rem;
}

.passport-inspection-heading .comparison-title {
  margin-bottom: 0;
}

.passport-inspection-status {
  flex: 0 0 auto;
  padding: 0.3rem 0.65rem;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 700;
}

.passport-inspection-status.verify-pending {
  color: var(--muted);
  background: rgba(139, 156, 179, 0.12);
}

.passport-inspection-status.verify-ok {
  color: var(--success);
  background: rgba(34, 197, 94, 0.12);
}

.passport-inspection-status.verify-fail {
  color: var(--danger);
  background: rgba(239, 68, 68, 0.12);
}

.passport-inspection-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 0.9fr);
  gap: 1.25rem;
}

.passport-inspection-column {
  min-width: 0;
}

.passport-inspection-column h3 {
  margin: 0 0 0.65rem;
  font-size: 0.9rem;
  color: var(--muted);
}

.passport-cropped-preview {
  display: block;
  width: 100%;
  height: auto;
  max-height: 380px;
  object-fit: contain;
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) - 4px);
  background: #0b1018;
}

.passport-crop-placeholder {
  display: grid;
  min-height: 180px;
  margin: 0;
  place-items: center;
  padding: 1rem;
  border: 1px dashed var(--danger);
  border-radius: calc(var(--radius) - 4px);
  color: #fca5a5;
  text-align: center;
}

.passport-ocr-text {
  min-height: 180px;
  max-height: 320px;
  margin: 0;
  overflow: auto;
  padding: 0.85rem;
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) - 4px);
  background: #0b1018;
  color: var(--text);
  font: 0.8rem/1.45 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.passport-ocr-meta,
.passport-coverage-status {
  margin: 0.55rem 0 0;
  font-size: 0.82rem;
  line-height: 1.45;
}

.passport-ocr-meta {
  color: var(--muted);
}

.passport-coverage-status.coverage-ok {
  color: var(--success);
}

.passport-coverage-status.coverage-fail {
  color: var(--danger);
}

@media (max-width: 680px) {
  .passport-inspection-grid {
    grid-template-columns: 1fr;
  }

  .age-photo-content {
    grid-template-columns: 1fr;
  }

  .passport-inspection-heading {
    align-items: flex-start;
    flex-direction: column;
  }
}

.hidden {
  display: none !important;
}

button[type="submit"] {
  width: 100%;
  padding: 0.9rem 1.25rem;
  border: none;
  border-radius: var(--radius);
  background: var(--accent);
  color: white;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.2s;
}

button[type="submit"]:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.selfie-snapshots {
  margin-top: 1.25rem;
}

.selfie-snapshots-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: 0.85rem;
  margin: 0.75rem 0 1rem;
}

.selfie-snapshot-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
}

.selfie-snapshot-card img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: calc(var(--radius) - 4px);
  border: 2px solid var(--border);
}

.selfie-snapshot-label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: capitalize;
}

.selfie-snapshots-pairwise {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.pairwise-row {
  padding: 0.45rem 0.75rem;
  border-radius: 8px;
  font-size: 0.85rem;
  font-variant-numeric: tabular-nums;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
}

.pairwise-row.match {
  color: var(--success);
  border-color: rgba(34, 197, 94, 0.4);
}

.pairwise-row.no-match {
  color: var(--danger);
  border-color: rgba(239, 68, 68, 0.4);
}

.result {
  margin-top: 1.25rem;
}

.badge {
  display: inline-block;
  padding: 0.4rem 0.85rem;
  border-radius: 999px;
  font-weight: 700;
  font-size: 0.9rem;
  margin-bottom: 1rem;
}

.badge.match {
  background: rgba(34, 197, 94, 0.15);
  color: var(--success);
}

.badge.no-match {
  background: rgba(239, 68, 68, 0.15);
  color: var(--danger);
}

.metric {
  display: flex;
  justify-content: space-between;
  padding: 0.65rem 0;
  border-bottom: 1px solid var(--border);
}

.metric-label {
  color: var(--muted);
}

.metric-value {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.comparison {
  margin-top: 1.25rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border);
}

.comparison-title {
  margin: 0 0 0.35rem;
  font-size: 1rem;
}

.comparison-hint {
  margin: 0 0 1rem;
  color: var(--muted);
  font-size: 0.88rem;
}

.comparison-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1.25rem;
}

.comparison-item h3 {
  margin: 0 0 0.65rem;
  font-size: 0.95rem;
}

.annotated-canvas,
.face-crop {
  display: block;
  width: 100%;
  height: auto;
  border-radius: calc(var(--radius) - 4px);
  background: #0b1018;
}

.annotated-canvas {
  border: 1px solid var(--border);
}

.face-crop {
  max-width: 180px;
  margin-top: 0.35rem;
  border: 2px solid var(--success);
}

.crop-label {
  margin: 0.75rem 0 0;
  font-size: 0.8rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.face-meta {
  margin: 0.5rem 0 0;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.5;
}

.error {
  margin-top: 1rem;
  padding: 0.85rem 1rem;
  border-radius: var(--radius);
  background: rgba(239, 68, 68, 0.12);
  color: #fca5a5;
}
