:root {
  --bg: #F8F7F4;
  --text: #171717;
  --muted: #595959;
  --accent: #15956F;
  --accent-dark: #117A5C;
  --field-bg: #FFFFFF;
  --border: #E4E2DC;
  --border-strong: #CFCCC4;
  --disabled-bg: #D8D8D6;
  --disabled-text: #8C8C8C;
  --radius: 9px;
  --field-height: 64px;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--text);
}

.page {
  min-height: 100dvh;
  max-width: 480px;
  margin: 0 auto;
  padding: 48px 24px max(24px, env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 40px;
}

/* ----- Form group ----- */
.form-group { margin-bottom: 26px; }

.label {
  display: block;
  font-size: 15px;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 10px;
}

.field-row {
  display: flex;
  gap: 10px;
}

/* Shared field control (concept style) */
.wrap {
  display: flex;
  align-items: center;
  background: var(--field-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  height: var(--field-height);
  padding: 0 16px;
}
.wrap > input {
  border: none;
  outline: none;
  background: transparent;
  font-size: 16px;
  color: var(--text);
  font-family: inherit;
  width: 100%;
  min-width: 0;
  height: 100%;
}
.wrap > input::placeholder { color: #B6B3A8; }
.wrap:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(21, 149, 111, 0.16);
}
.wrap:has(> input:hover), .wrap:hover { border-color: var(--border-strong); }

/* Country selector (custom dropdown) */
.country-wrap {
  position: relative;
  flex: 0 0 96px;
  height: var(--field-height);
}
.country-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  width: 100%;
  height: 100%;
  background: var(--field-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  cursor: pointer;
  user-select: none;
  font-family: inherit;
  font-size: 16px;
  color: var(--text);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.country-btn:hover { border-color: var(--border-strong); }
.country-btn:focus-visible {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(21, 149, 111, 0.16);
  outline: none;
}
.country-flag {
  width: 26px;
  height: 18px;
  border-radius: 3px;
  object-fit: cover;
  display: block;
  background: #eee;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.06);
}
.country-chevron {
  width: 9px;
  height: 9px;
  border-right: 1.5px solid var(--muted);
  border-bottom: 1.5px solid var(--muted);
  transform: rotate(45deg) translate(-1px, -1px);
  flex-shrink: 0;
}
.country-menu {
  position: absolute;
  top: calc(var(--field-height) + 8px);
  left: 0;
  min-width: 260px;
  max-height: 300px;
  overflow: auto;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 12px 30px -10px rgba(0, 0, 0, 0.25);
  z-index: 50;
  padding: 6px;
  display: none;
}
.country-menu.open { display: block; }
.country-option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 10px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 15px;
  color: var(--text);
}
.country-option img.flag {
  width: 26px;
  height: 18px;
  border-radius: 3px;
  object-fit: cover;
  flex-shrink: 0;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.06);
}
.country-option .opt-name { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.country-option .opt-code { color: var(--muted); font-weight: 600; }
.country-option:hover, .country-option.highlight { background: rgba(21, 149, 111, 0.10); }
.country-option.active { background: rgba(21, 149, 111, 0.16); }

/* Phone number */
.phone-wrap { flex: 1; min-width: 0; gap: 9px; padding: 0 16px 0 16px; }
.phone-wrap input { font-weight: 500; }
.dial-code {
  color: var(--text);
  font-weight: 600;
  font-size: 16px;
  white-space: nowrap;
  flex-shrink: 0;
}

/* Password with reveal */
.password-wrap { position: relative; }
.password-wrap .wrap { width: 100%; padding-right: 52px; }
.password-toggle {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  width: 44px;
  height: 44px;
  min-width: 48px;
  background: transparent;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
}
.password-toggle:hover { color: var(--text); }
.password-toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.password-toggle svg { width: 22px; height: 22px; }

/* Recovery link */
.recovery {
  margin-top: 18px;
  font-size: 14px;
  color: var(--muted);
}
.recovery a {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 2px;
  font-weight: 500;
}
.recovery a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

/* Flexible spacer pushes actions to the bottom */
.spacer { flex: 1; }

/* Bottom action area */
.actions { margin-top: auto; }

.btn {
  position: relative;
  width: 100%;
  height: 64px;
  border-radius: 999px;
  border: none;
  font-size: 18px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease, transform 0.05s ease, box-shadow 0.15s ease;
}
.btn > .btn-label { position: relative; z-index: 1; }
.btn:disabled {
  background: var(--disabled-bg);
  color: var(--disabled-text);
  cursor: not-allowed;
}
.btn:not(:disabled) {
  background: var(--accent);
  color: #FFFFFF;
}
.btn:not(:disabled):hover { background: var(--accent-dark); }
.btn:not(:disabled):active { transform: scale(0.99); }
.btn:not(:disabled):focus-visible {
  outline: 2px solid var(--accent-dark);
  outline-offset: 3px;
}
.btn.loading {
  background: var(--disabled-bg);
  color: var(--disabled-text);
  cursor: progress;
}
.btn.loading .btn-label {
  visibility: hidden;
}
.btn.spinner::before {
  content: '';
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 18px;
  height: 18px;
  border: 2px solid transparent;
  border-top-color: currentColor;
  border-right-color: currentColor;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin {
  from { transform: translate(-50%, -50%) rotate(0deg); }
  to { transform: translate(-50%, -50%) rotate(360deg); }
}

.btn-margin { margin-top: 30px; }

.signup {
  margin-top: 22px;
  padding-bottom: env(safe-area-inset-bottom);
  text-align: center;
  font-size: 15px;
  color: var(--muted);
}
.signup a {
  color: var(--accent);
  font-weight: 600;
  text-decoration: none;
}
.signup a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

/* Error / status line (hidden unless needed) */
#step-status {
  margin-top: 16px;
  font-size: 14px;
  min-height: 18px;
  color: var(--muted);
}
#step-status.error { color: #C03A2B; }
#step-status.success { color: var(--accent); }

#step-status-otp {
  margin-top: 16px;
  font-size: 14px;
  min-height: 18px;
  color: var(--muted);
}
#step-status-otp.error { color: #C03A2B; }
#step-status-otp.success { color: var(--accent); }

#step-status-liveness {
  margin-top: 16px;
  font-size: 14px;
  min-height: 18px;
  color: var(--muted);
}
#step-status-liveness.error { color: #C03A2B; }
#step-status-liveness.success { color: var(--accent); }

#sumsub-websdk-container {
  margin-top: 20px;
  min-height: 360px;
}

.step { display: none; }
.step.active { display: block; }

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

@media (min-width: 480px) {
  .page { padding-top: 96px; }
}
