/* Purple / white / green, mobile-first. Status colours are functional only. */
:root {
  --bg-canvas: #faf9fe;
  --sidebar-bg: #ffffff;
  --card-bg: #ffffff;
  --field-bg: #f4f1fd;
  --hover-bg: #ebe5fb;
  --border-color: #e7e2f7;
  --primary: #6c47e8;
  --primary-hover: #5a37d1;
  --accent: #6c47e8;
  --success: #12b76a;
  --warning: #f59e0b;
  --danger: #ef4444;
  --text: #1f1b2e;
  --text-muted: #6b6880;
}

* { box-sizing: border-box; margin: 0; padding: 0; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; }
html { -webkit-text-size-adjust: 100%; }
body { background: var(--bg-canvas); color: var(--text); min-height: 100vh; line-height: 1.5; }
img, video { max-width: 100%; }

/* Header + navigation (mobile: slide-down menu) */
.site-header { position: sticky; top: 0; z-index: 100; background: #fff; box-shadow: 0 4px 16px rgba(76, 48, 160, 0.07); }
.header-bar { display: flex; align-items: center; justify-content: space-between; max-width: 1100px; margin: 0 auto; padding: 0.5rem 1rem; min-height: 60px; }
.brand-title { font-size: 1.1rem; font-weight: 700; color: var(--text); display: flex; align-items: center; gap: 0.6rem; margin: 0; }
.brand-title i { color: var(--primary); }
.menu-btn { width: 44px; height: 44px; border: none; border-radius: 12px; background: var(--field-bg); color: var(--primary); font-size: 1.2rem; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; transition: background 0.2s; }
.menu-btn:hover { background: var(--hover-bg); }

.topnav { position: absolute; left: 0; right: 0; top: 100%; background: #fff; max-height: 0; overflow: hidden; visibility: hidden; transition: max-height 0.3s ease, visibility 0s linear 0.3s; box-shadow: 0 14px 24px rgba(76, 48, 160, 0.12); }
.topnav.open { max-height: 380px; visibility: visible; transition: max-height 0.3s ease; }
.nav-list { list-style: none; display: flex; flex-direction: column; gap: 0.25rem; padding: 0.5rem 1rem 1rem; margin: 0 auto; max-width: 1100px; }
.nav-item { display: flex; align-items: center; gap: 0.8rem; min-height: 48px; padding: 0.6rem 1rem; border-radius: 12px; color: var(--text-muted); font-size: 1rem; font-weight: 600; cursor: pointer; transition: background 0.2s, color 0.2s; }
.nav-item:hover { color: var(--text); background: var(--hover-bg); }
.nav-item.active { background: #efeafd; color: var(--primary-hover); }

main.main-viewport { max-width: 1100px; margin: 0 auto; padding: 1.25rem 1rem 2.5rem; }
.page-pane { display: none; }
.page-pane.active { display: block; animation: fadeIn 0.25s ease-in-out; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }

.pane-header { margin-bottom: 1.25rem; }
.pane-header h1 { font-size: 1.35rem; font-weight: 700; line-height: 1.25; }
.pane-header p { font-size: 0.92rem; color: var(--text-muted); margin-top: 0.35rem; }

.card { background: var(--card-bg); border: none; box-shadow: 0 2px 10px rgba(76, 48, 160, 0.07); border-radius: 16px; padding: 1.1rem; margin-bottom: 1.25rem; }
.form-grid { display: grid; grid-template-columns: 1fr; gap: 1rem; margin-bottom: 1rem; }
.form-group { display: flex; flex-direction: column; gap: 0.45rem; min-width: 0; }
label { font-size: 0.85rem; font-weight: 600; color: var(--text-muted); }
input, select { width: 100%; min-height: 48px; background: var(--field-bg); border: none; border-radius: 12px; padding: 0.8rem 1rem; color: var(--text); font-size: 1rem; outline: none; transition: box-shadow 0.2s, background 0.2s; }
input[type="checkbox"] { width: 20px; min-height: 0; height: 20px; padding: 0; accent-color: var(--primary); flex-shrink: 0; }
input:hover, select:hover { background: var(--hover-bg); }
input:focus, select:focus { box-shadow: 0 0 0 2px var(--accent); }
input.error-input, select.error-input { box-shadow: 0 0 0 2px var(--danger) !important; }

.upload-zone { display: grid; grid-template-columns: 1fr; gap: 1rem; margin: 1rem 0; }
.upload-box { border: none; background: var(--field-bg); border-radius: 14px; padding: 1.5rem 1rem; text-align: center; cursor: pointer; transition: background 0.2s, transform 0.2s; position: relative; overflow: hidden; min-height: 48px; }
.upload-box:hover { background: var(--hover-bg); transform: translateY(-2px); }
.upload-box.error-box { background: rgba(239, 68, 68, 0.1); }
.upload-box input { display: none; }
.upload-box i { font-size: 2.2rem; color: var(--accent); margin-bottom: 0.6rem; }

.preview-thumb { max-width: 100%; max-height: 140px; border-radius: 8px; margin-top: 0.75rem; object-fit: cover; display: none; }

.inline-error-banner { background: rgba(239, 68, 68, 0.12); border: none; color: #b91c1c; padding: 0.75rem 1rem; border-radius: 12px; font-size: 0.9rem; margin-bottom: 1rem; display: none; }
.inline-info-banner { background: rgba(108, 71, 232, 0.1); border: none; color: var(--primary-hover); padding: 0.75rem 1rem; border-radius: 12px; font-size: 0.9rem; margin-bottom: 1rem; display: none; }

/* Camera box: unchanged */
.cam-viewport { width: 100%; height: 420px; background: #000; border-radius: 16px; border: 1px solid #233457; position: relative; overflow: hidden; display: flex; flex-direction: column; align-items: center; justify-content: center; }
video { width: 100%; height: 100%; object-fit: cover; transform: scaleX(-1); }
#selfie-preview-img { width: 100%; height: 100%; object-fit: cover; display: none; }

/* The oval is not used (kept hidden because the script still sets its class). */
.smart-oval { display: none !important; }

.cam-error { display: none; position: absolute; inset: 0; z-index: 20; align-items: center; justify-content: center; background: rgba(8, 12, 24, 0.9); backdrop-filter: blur(6px); padding: 1rem; }
.cam-error.show { display: flex; }
.cam-error-card { text-align: center; max-width: 320px; }
.cam-error-icon { width: 56px; height: 56px; margin: 0 auto 0.9rem; border-radius: 50%; background: rgba(245, 158, 11, 0.15); color: var(--warning); display: flex; align-items: center; justify-content: center; font-size: 1.5rem; }
.cam-error-title { font-size: 1.15rem; font-weight: 700; color: #fff; margin-bottom: 0.35rem; }
.cam-error-hint { font-size: 0.92rem; color: #cbd5e1; margin-bottom: 1.1rem; }
.directive-box { position: absolute; top: 20px; max-width: calc(100% - 24px); text-align: center; background: rgba(12, 20, 41, 0.92); border: 1px solid rgba(255, 255, 255, 0.25); backdrop-filter: blur(10px); padding: 0.7rem 1.2rem; border-radius: 30px; font-size: 0.9rem; font-weight: 700; color: #fff; display: flex; align-items: center; gap: 0.6rem; z-index: 10; box-shadow: 0 4px 20px rgba(0, 0, 0, 0.6); }
.directive-box i { font-size: 1.1rem; color: #b9a6ff; }
.liveness-progress-bar { position: absolute; bottom: 25px; width: 75%; height: 8px; background: rgba(255, 255, 255, 0.2); border-radius: 10px; overflow: hidden; z-index: 10; }
.liveness-fill { height: 100%; width: 0%; background: var(--success); transition: width 0.3s; }

.btn-action { background: var(--primary); color: #fff; border: none; min-height: 48px; padding: 0.8rem 1.6rem; border-radius: 12px; font-size: 1rem; font-weight: 700; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem; transition: background 0.2s, transform 0.2s; }
.btn-action:hover { background: var(--primary-hover); transform: translateY(-1px); }
.btn-action:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }

.btn-secondary { background: #efeafd; color: var(--primary-hover); border: none; min-height: 48px; padding: 0.8rem 1.5rem; border-radius: 12px; font-size: 1rem; font-weight: 600; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem; transition: background 0.2s, color 0.2s; }
.btn-secondary:hover { background: #e2d9fb; }

.btn-retry { background: var(--warning); color: #000; border: none; min-height: 48px; padding: 0.8rem 1.6rem; border-radius: 12px; font-size: 1rem; font-weight: 800; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem; margin-top: 1.25rem; transition: filter 0.2s, transform 0.2s; }
.btn-retry:hover { filter: brightness(1.1); transform: translateY(-1px); }

.status-pill { display: inline-block; padding: 0.4rem 0.9rem; border-radius: 20px; font-size: 0.8rem; font-weight: 700; text-transform: uppercase; }
.status-processing { background: rgba(245, 158, 11, 0.15); color: var(--warning); }
.status-passed { background: rgba(18, 183, 106, 0.15); color: var(--success); }
.status-failed { background: rgba(239, 68, 68, 0.15); color: var(--danger); }

#status-card-body { overflow-wrap: break-word; }
.audit-grid { display: grid; grid-template-columns: 1fr; gap: 0.75rem; margin-top: 1.5rem; text-align: left; }
.audit-item { background: var(--field-bg); border: none; border-radius: 12px; padding: 0.85rem 1rem; display: flex; flex-wrap: wrap; gap: 0.4rem 0.75rem; justify-content: space-between; align-items: center; font-size: 0.9rem; min-width: 0; transition: background 0.2s; }
.audit-item:hover { background: var(--hover-bg); }
.audit-item.err { background: rgba(239, 68, 68, 0.12); }
.audit-item.ok { background: rgba(18, 183, 106, 0.12); }
.audit-item .btn-retry { margin-top: 0; min-height: 44px; padding: 0.5rem 1rem; font-size: 0.85rem; }

.cam-controls { display: flex; flex-direction: column; align-items: stretch; gap: 0.75rem; margin-top: 1.25rem; }
.cam-controls .btn-action, .cam-controls .btn-secondary { width: 100%; }
.btn-retry { max-width: 100%; }

/* Phones only: full-width touch buttons */
@media (max-width: 767px) {
  .card .btn-action, .card .btn-secondary, .card .btn-retry { width: 100%; }
  .cam-error-card .btn-action { width: auto; }
  .audit-item .btn-retry { width: 100%; }
}

/* Tablet and up: horizontal navigation below the header */
@media (min-width: 640px) {
  .form-grid, .upload-zone { grid-template-columns: 1fr 1fr; gap: 1.25rem; }
  .cam-controls { flex-direction: row; justify-content: center; align-items: center; }
  .cam-controls .btn-action, .cam-controls .btn-secondary { width: auto; }
}
@media (min-width: 768px) {
  .header-bar { padding: 0.5rem 1.5rem; }
  .menu-btn { display: none; }
  .topnav { position: static; max-height: none; visibility: visible; overflow-x: auto; box-shadow: none; background: #fff; border-radius: 0; }
  .nav-list { flex-direction: row; gap: 0.25rem; padding: 0 1.5rem; }
  .nav-item { white-space: nowrap; border-radius: 0; border-bottom: 3px solid transparent; min-height: 48px; padding: 0.6rem 0.8rem; font-size: 0.85rem; }
  .nav-item:hover { background: transparent; color: var(--primary); }
  .nav-item.active { background: transparent; color: var(--primary); border-bottom-color: var(--primary); }
  main.main-viewport { padding: 1.75rem 1.5rem 3rem; }
  .pane-header h1 { font-size: 1.5rem; }
  .card { padding: 1.5rem; }
  .audit-grid { grid-template-columns: repeat(3, 1fr); gap: 1rem; }
  .audit-item { font-size: 0.85rem; }
}
@media (min-width: 1024px) {
  .nav-item { padding: 0.6rem 1.2rem; font-size: 0.95rem; }
  main.main-viewport { padding: 2.5rem 2rem 3rem; }
  .pane-header h1 { font-size: 1.6rem; }
  .card { padding: 1.75rem; }
  .audit-item { font-size: 0.9rem; }
}

/* Face ring: oval with outer bars that turn green as liveness steps pass */
.kyc-ring { display: none; position: absolute; inset: 0; width: 100%; height: 100%; z-index: 5; pointer-events: none; }
.ring-oval { fill: none; stroke: rgba(255, 255, 255, 0.55); stroke-width: 2; }
.ring-bar { stroke: rgba(255, 255, 255, 0.28); stroke-width: 4; stroke-linecap: round; transition: stroke 0.2s; }
.ring-bar.on { stroke: #12b76a; }
#liveness-bar { display: none; }

/* Result rows: circle tick (theme purple) for passed, circle cross for failed */
.st { display: inline-flex; align-items: center; gap: 0.45rem; }
.st i { font-size: 1.15rem; }
.st-ok i { color: var(--primary); }
.st-bad i { color: var(--danger); }

/* Header without menu, page pills, back buttons */
.brand-title span { color: var(--primary); }
.page-pill { display: inline-flex; align-items: center; gap: 0.6rem; background: linear-gradient(135deg, #7a55f0, #5a37d1); color: #fff; font-weight: 700; font-size: 1rem; padding: 0.7rem 1.4rem; border-radius: 999px; box-shadow: 0 6px 16px rgba(108, 71, 232, 0.3); margin-bottom: 1.25rem; }
.btn-back { margin-top: 0.75rem; }
.cam-back { margin-top: 1rem; }
@media (min-width: 640px) {
  .btn-back { margin-top: 0; margin-left: 0.75rem; }
}

/* Field helper text */
.field-hint { display: flex; align-items: flex-start; gap: 0.55rem; margin-top: 0.5rem; padding: 0.65rem 0.9rem; background: var(--field-bg); border-radius: 10px; font-size: 0.85rem; line-height: 1.45; color: var(--text-muted); }
.field-hint:empty { display: none; }
.field-hint::before { content: "\f05a"; font-family: "Font Awesome 6 Free"; font-weight: 900; color: var(--primary); flex-shrink: 0; }

/* Success result */
.res { text-align: center; padding: 0.75rem 0 0.25rem; }
.res-badge { width: 88px; height: 88px; border-radius: 50%; margin: 0 auto 1.25rem; display: flex; align-items: center; justify-content: center; background: rgba(18, 183, 106, 0.15); box-shadow: 0 0 0 12px rgba(18, 183, 106, 0.08); }
.res-badge i { font-size: 2.6rem; color: var(--success); }
.res-title { font-size: 1.8rem; font-weight: 800; line-height: 1.2; color: var(--text); }
.res-title span { display: block; color: var(--success); }
.res-sub { color: var(--text-muted); font-size: 0.95rem; max-width: 420px; margin: 0.75rem auto 1.5rem; }
.res-grid { display: grid; grid-template-columns: 1fr; gap: 0.75rem; text-align: left; }
.res-item { display: flex; align-items: center; gap: 0.8rem; background: rgba(18, 183, 106, 0.1); border-radius: 14px; padding: 0.85rem 1rem; min-width: 0; }
.res-ico { width: 42px; height: 42px; flex-shrink: 0; border-radius: 50%; background: #ebe5fb; color: var(--primary); display: flex; align-items: center; justify-content: center; }
.res-name { font-weight: 700; font-size: 0.92rem; color: var(--text); }
.res-ok { display: flex; align-items: center; gap: 0.35rem; color: var(--success); font-weight: 700; font-size: 0.85rem; margin-top: 0.1rem; }
.res-foot { display: flex; align-items: center; justify-content: center; gap: 0.6rem; margin-top: 1.75rem; color: var(--text-muted); font-size: 0.85rem; }
.res-foot i { color: var(--primary); }
@media (min-width: 768px) { .res-grid { grid-template-columns: repeat(3, 1fr); gap: 1rem; } }


/* Processing spinner and failed result */
.proc { display: flex; flex-direction: column; align-items: center; gap: 1rem; padding: 2.5rem 0; }
.proc-spin { width: 64px; height: 64px; border-radius: 50%; border: 6px solid var(--field-bg); border-top-color: var(--primary); animation: kycspin 0.9s linear infinite; }
.proc-txt { font-weight: 700; color: var(--text); }
@keyframes kycspin { to { transform: rotate(360deg); } }
.res-badge-bad { background: rgba(239, 68, 68, 0.12); box-shadow: 0 0 0 12px rgba(239, 68, 68, 0.06); }
.res-badge-bad i { color: var(--danger); }
.res-fail .res-title span { color: var(--danger); }
.res-fail { padding-bottom: 0.5rem; }

/* Failure reasons on the result page */
.fail-reasons { list-style: none; margin: 1.25rem 0 0.5rem; padding: 0.9rem 1rem; background: rgba(239, 68, 68, 0.08); border-radius: 12px; color: #b91c1c; font-size: 0.92rem; line-height: 1.5; }
.fail-reasons li + li { margin-top: 0.4rem; }

/* Face ring dots: round dots, white outside the oval */
.kyc-ring { overflow: visible; }
.ring-mask { fill: #ffffff; }
.ring-bar { stroke: rgba(15, 23, 42, 0.2); stroke-width: 9; stroke-linecap: round; }
