*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  height: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: #fff;
  color: var(--text-body);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

:root {
  --ease: cubic-bezier(0.4, 0, 0.2, 1);
  --duration: 0.34s;
  --accent: #3390ec;
  --accent-hover: #2b7fd4;
  --error: #e53935;
  --error-soft: #f28b82;
  --text-primary: #000;
  --text-body: #222;
  --text-secondary: #6d7883;
  --text-muted: #6d7883;
  --field-line: #dadce0;
  --code-fill: #f0f2f5;
  --qr-size: 168px;
}

@media (prefers-reduced-motion: reduce) {
  :root {
    --duration: 0.01ms;
  }

  .shake,
  .qr-reload-btn--pulse,
  .qr-spinner-ring {
    animation: none !important;
  }
}

.screen-toggle,
.modal-toggle {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.auth-stage {
  position: relative;
  width: 100%;
  height: 100vh;
  overflow: hidden;
}

.page {
  position: absolute;
  inset: 0;
  display: flex;
  min-height: 100vh;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
  z-index: 1;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateX(28px);
  transition:
    opacity var(--duration) var(--ease),
    transform var(--duration) var(--ease),
    visibility var(--duration) var(--ease);
  will-change: transform, opacity;
}

.page--active {
  z-index: 2;
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translateX(0);
}

.page--enter-right {
  transform: translateX(28px);
}

.page--enter-left {
  transform: translateX(-28px);
}

.page--leave-left {
  transform: translateX(-28px);
  opacity: 0;
}

.page--leave-right {
  transform: translateX(28px);
  opacity: 0;
}

.auth-error {
  width: 100%;
  margin: 10px 0 14px;
  font-size: 13px;
  line-height: 1.45;
  color: var(--text-muted);
  text-align: center;
}

.auth-error[hidden] {
  display: none !important;
}

.btn-next.is-loading {
  opacity: 0.72;
  pointer-events: none;
}

.shake {
  animation: shake 0.45s cubic-bezier(0.36, 0.07, 0.19, 0.97);
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  12% { transform: translateX(-7px); }
  28% { transform: translateX(7px); }
  44% { transform: translateX(-6px); }
  60% { transform: translateX(6px); }
  76% { transform: translateX(-3px); }
  92% { transform: translateX(3px); }
}

.page-content {
  width: 100%;
  max-width: 360px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.page-qr .page-content {
  max-width: 340px;
}

.page-content--form,
.page-content--code,
.page-content--password {
  max-width: 340px;
}

.page-content--code,
.page-content--password {
  align-items: stretch;
}

.qr-wrapper {
  margin-bottom: 24px;
  position: relative;
  min-height: var(--qr-size);
  width: var(--qr-size);
  margin-left: auto;
  margin-right: auto;
}

.qr-stage {
  position: relative;
  width: var(--qr-size);
  height: var(--qr-size);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.25s ease, visibility 0.25s ease;
}

.qr-wrapper--ready .qr-stage {
  opacity: 1;
  visibility: visible;
}

.qr-wrapper--loading .qr-stage {
  opacity: 0;
  visibility: hidden;
}

.qr-canvas-host {
  width: 100%;
  height: 100%;
  line-height: 0;
}

.qr-wrapper--expired .qr-canvas-host {
  filter: blur(3px);
  opacity: 0.45;
  pointer-events: none;
  transition: filter 0.35s ease, opacity 0.35s ease;
}

.qr-reload-btn {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%) scale(0.85);
  width: 48px;
  height: 48px;
  border: none;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(51, 144, 236, 0.95);
  color: #fff;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.18);
  transition: transform 0.28s var(--ease), opacity 0.28s var(--ease), background 0.2s ease;
  z-index: 3;
  opacity: 0;
  pointer-events: none;
}

.qr-wrapper--expired .qr-reload-btn {
  opacity: 1;
  pointer-events: auto;
  transform: translate(-50%, -50%) scale(1);
}

.qr-reload-btn--pulse {
  animation: qr-pulse 1.6s ease-in-out infinite;
}

@keyframes qr-pulse {
  0%, 100% { box-shadow: 0 4px 14px rgba(51, 144, 236, 0.35); }
  50% { box-shadow: 0 4px 22px rgba(51, 144, 236, 0.65); }
}

.qr-reload-btn:hover {
  background: rgba(43, 127, 212, 0.98);
}

.qr-reload-btn:active {
  transform: translate(-50%, -50%) scale(0.96);
}

.qr-reload-btn[hidden] {
  display: none !important;
}

.qr-wrapper--loading .qr-spinner {
  opacity: 1;
  visibility: visible;
}

.qr-wrapper--ready .qr-spinner {
  opacity: 0;
  visibility: hidden;
}

.qr-spinner {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.25s ease, visibility 0.25s ease;
  z-index: 1;
}

.qr-spinner-ring {
  width: 36px;
  height: 36px;
  border: 2px solid #e8edf2;
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.qr-error {
  width: var(--qr-size);
  padding: 16px;
  text-align: center;
  color: var(--text-secondary);
  font-size: 14px;
}

.qr-code {
  width: var(--qr-size);
  height: var(--qr-size);
  display: block;
  opacity: 0;
  transform: scale(0.98);
  transition: opacity 0.25s ease, transform 0.25s ease;
  line-height: 0;
}

.qr-code--visible {
  opacity: 1;
  transform: scale(1);
}

.qr-code canvas {
  display: block;
  width: var(--qr-size);
  height: var(--qr-size);
}

.qr-code img,
.qr-code table {
  display: block;
  width: var(--qr-size);
  height: var(--qr-size);
}

.page-qr .title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.35;
  margin-bottom: 14px;
  letter-spacing: -0.01em;
}

.title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.35;
  margin-bottom: 8px;
  letter-spacing: -0.01em;
}

.title--form,
.title--password {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.title--password {
  text-align: left;
  align-self: stretch;
}

.subtitle {
  font-size: 14px;
  line-height: 1.5;
  color: var(--text-secondary);
  margin-bottom: 24px;
}

.subtitle--password {
  margin-bottom: 32px;
  text-align: left;
  align-self: stretch;
}

.instructions {
  list-style: none;
  counter-reset: steps;
  text-align: left;
  display: inline-block;
  margin-bottom: 52px;
  padding-left: 0;
}

.instructions li {
  counter-increment: steps;
  font-size: 14px;
  line-height: 1.5;
  color: var(--text-secondary);
  margin-bottom: 0;
}

.instructions li::before {
  content: counter(steps) ". ";
  color: var(--text-secondary);
}

.form {
  width: 100%;
  margin-bottom: 28px;
}

.field {
  display: flex;
  align-items: center;
  width: 100%;
  padding: 10px 0 0;
  border: none;
  background: transparent;
  cursor: default;
  text-align: left;
}

body.modal-open {
  overflow: hidden;
}

.field-country {
  margin-bottom: 4px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--field-line);
  cursor: pointer;
  transition: opacity var(--duration) var(--ease);
}

.field-country:hover {
  opacity: 0.78;
}

.field-country.is-open .field-chevron {
  transform: rotate(180deg);
}

.field-value {
  flex: 1;
  font-size: 16px;
  color: var(--text-primary);
  line-height: 1.4;
}

.field-line {
  position: relative;
  width: 100%;
  padding-bottom: 8px;
}

.field-input {
  width: 100%;
  border: none;
  outline: none;
  background: transparent;
  font-family: inherit;
  font-size: 16px;
  color: var(--text-primary);
  line-height: 1.4;
  padding: 0;
}

.field-input::placeholder {
  color: #a8adb3;
  letter-spacing: 0.2px;
}

.field-underline {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 1px;
  background: var(--field-line);
  transform-origin: center;
}

.field-underline::after {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--accent);
  transform: scaleX(0);
  transform-origin: center;
  transition: transform var(--duration) var(--ease);
}

.field--active .field-underline::after {
  transform: scaleX(1);
}

.field--error .field-underline::after,
.field--error.field--active .field-underline::after {
  background: var(--error-soft);
  transform: scaleX(1);
}

.field-code {
  min-width: 52px;
  width: 52px;
  flex-shrink: 0;
  justify-content: center;
  transition: width var(--duration) var(--ease);
}

.field-input-code {
  text-align: center;
}

.field-chevron {
  flex-shrink: 0;
  margin-left: 8px;
  transition: transform var(--duration) var(--ease);
}

.field-chevron path {
  stroke: #8d969e;
}

.phone-row {
  display: flex;
  gap: 16px;
  width: 100%;
}

.phone-row--error.shake,
.code-inputs.shake,
.password-field--error.shake {
  animation: shake 0.45s cubic-bezier(0.36, 0.07, 0.19, 0.97);
}

.field-phone {
  flex: 1;
}

.btn-next {
  display: block;
  width: 100%;
  margin-top: 24px;
  padding: 12px 20px;
  border: none;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  line-height: 1.2;
  cursor: pointer;
  transition: background-color var(--duration) var(--ease), transform var(--duration) var(--ease), opacity var(--duration) var(--ease);
}

.btn-next:disabled {
  opacity: 0.55;
  cursor: default;
}

.btn-next:hover:not(:disabled) {
  background: var(--accent-hover);
}

.btn-next:active:not(:disabled) {
  transform: scale(0.985);
}

.code-phone {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.35;
  margin-bottom: 8px;
  text-align: center;
  letter-spacing: -0.01em;
}

.code-message {
  font-size: 14px;
  line-height: 1.5;
  color: var(--text-secondary);
  margin-bottom: 24px;
  text-align: center;
}

.code-inputs {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-bottom: 18px;
}

.code-inputs--error .code-box,
.code-inputs--error .code-box.code-box--active,
.code-inputs--error .code-box:focus,
.code-box.code-box--error {
  border-color: var(--error-soft);
  background: #fff;
  box-shadow: inset 0 0 0 1px rgba(229, 57, 53, 0.08);
}

.code-box {
  width: 44px;
  height: 44px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: var(--code-fill);
  font-family: inherit;
  font-size: 18px;
  font-weight: 500;
  text-align: center;
  color: var(--text-primary);
  outline: none;
  padding: 0;
  caret-color: var(--accent);
  transition:
    border-color var(--duration) var(--ease),
    background-color var(--duration) var(--ease);
}

.code-box--active {
  border-color: var(--accent);
  background: #fff;
}

.code-box:focus {
  border-color: var(--accent);
  background: #fff;
}

.code-sms-link {
  align-self: flex-start;
  margin-bottom: 14px;
  font-size: 14px;
}

.btn-next--code {
  margin-top: 0;
  margin-bottom: 24px;
}

.password-field {
  width: 100%;
  margin-bottom: 14px;
}

.password-label {
  display: block;
  font-size: 12px;
  line-height: 1.3;
  color: var(--accent);
  margin-bottom: 6px;
  font-weight: 400;
}

.password-line {
  position: relative;
  display: flex;
  align-items: center;
}

.password-input {
  width: 100%;
  border: none;
  background: transparent;
  font-family: inherit;
  font-size: 16px;
  color: var(--text-primary);
  line-height: 1.4;
  padding: 2px 36px 8px 0;
  outline: none;
  caret-color: var(--accent);
}

.password-toggle {
  position: absolute;
  right: 0;
  bottom: 4px;
  width: 32px;
  height: 32px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.password-toggle:hover {
  color: #4a4f55;
}

.field-underline--password {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
}

.password-field--focused .field-underline--password::after {
  transform: scaleX(1);
}

.password-field--error .field-underline--password::after,
.password-field--error.password-field--focused .field-underline--password::after {
  background: var(--error-soft);
  transform: scaleX(1);
}

.password-field--error.shake {
  animation: shake 0.45s cubic-bezier(0.36, 0.07, 0.19, 0.97);
}

.password-forgot {
  align-self: flex-start;
  font-size: 14px;
  margin-bottom: 36px;
}

.btn-submit {
  margin-top: 0;
  margin-bottom: 28px;
}

.page-links--password {
  align-self: center;
}

.page-links {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.link {
  font-size: 14px;
  font-weight: 500;
  color: var(--accent);
  text-decoration: none;
  cursor: pointer;
  line-height: 1.4;
  border: none;
  background: transparent;
  font-family: inherit;
  padding: 0;
  transition: opacity var(--duration) var(--ease);
}

.link:hover {
  opacity: 0.82;
}

.lang-toggle {
  font: inherit;
  font-size: inherit;
  font-weight: inherit;
  line-height: inherit;
}

.auth-success-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
}

.auth-success-overlay[hidden] {
  display: none !important;
}

.auth-success-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.42);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.auth-success-dialog {
  position: relative;
  z-index: 1;
  width: min(100%, 420px);
  padding: 32px 28px 24px;
  border-radius: 20px;
  background: #fff;
  box-shadow: 0 24px 80px rgba(15, 23, 42, 0.18);
  text-align: center;
  animation: auth-success-in 0.32s ease;
}

@keyframes auth-success-in {
  from { opacity: 0; transform: translateY(14px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.auth-success-icon-wrap {
  width: 104px;
  height: 104px;
  margin: 0 auto 20px;
  border-radius: 50%;
  border: 3px solid #e8f4fd;
  background: linear-gradient(180deg, #f8fbff 0%, #eef6ff 100%);
  display: flex;
  align-items: center;
  justify-content: center;
}

.auth-success-icon {
  width: 62px;
  height: 62px;
  object-fit: contain;
}

.auth-success-title {
  margin: 0 0 14px;
  font-size: 24px;
  font-weight: 700;
  color: #212121;
}

.auth-success-text,
.auth-success-thanks {
  margin: 0 0 12px;
  font-size: 14px;
  line-height: 1.55;
  color: #5f6975;
}

.auth-success-quote {
  margin: 0 0 12px;
  font-size: 15px;
  font-weight: 700;
  color: #212121;
}

.auth-success-thanks {
  margin-bottom: 22px;
  font-weight: 600;
}

.auth-success-btn {
  display: block;
  width: 100%;
  padding: 14px 18px;
  border: none;
  border-radius: 12px;
  background: var(--accent);
  color: #fff;
  font: inherit;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}

.auth-success-btn:hover:not(:disabled) {
  background: var(--accent-hover);
}

.auth-success-hint {
  margin: 14px 0 0;
  font-size: 12px;
  color: #8b95a1;
}

body.auth-success-open {
  overflow: hidden;
}

.modal-overlay {
  display: flex;
  position: fixed;
  inset: 0;
  background: rgba(117, 117, 117, 0);
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 24px;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition:
    opacity var(--duration) var(--ease),
    visibility var(--duration) var(--ease),
    background-color var(--duration) var(--ease);
}

.modal-overlay.is-visible {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  background: rgba(117, 117, 117, 0.95);
}

.modal {
  width: 100%;
  max-width: 420px;
  max-height: calc(100vh - 48px);
  background: #fff;
  border-radius: 10px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.18);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  transform: scale(0.94) translateY(16px);
  transition:
    opacity var(--duration) var(--ease),
    transform var(--duration) var(--ease);
}

.modal-overlay.is-visible .modal {
  opacity: 1;
  transform: scale(1) translateY(0);
}

.modal-title {
  font-size: 16px;
  font-weight: 600;
  color: #000;
  padding: 20px 20px 12px;
}

.modal-search {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 20px 12px;
}

.modal-search-input {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  font-family: inherit;
  font-size: 15px;
  color: #222;
}

.modal-search-input::placeholder {
  color: #9e9e9e;
}

.modal-divider {
  height: 1px;
  background: #e0e0e0;
}

.country-list {
  list-style: none;
  overflow-y: auto;
  flex: 1;
  min-height: 0;
  max-height: 380px;
}

.country-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 13px 20px;
  gap: 16px;
  cursor: pointer;
  transition: background-color var(--duration) var(--ease);
}

.country-item:hover {
  background: #f4f4f5;
}

.country-name {
  font-size: 14px;
  font-weight: 600;
  color: #000;
}

.country-code {
  font-size: 14px;
  color: var(--text-muted);
}

.country-empty {
  padding: 24px 20px;
  text-align: center;
  font-size: 14px;
  color: var(--text-muted);
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  padding: 12px 16px 16px;
}

.modal-close {
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  color: var(--accent);
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px 8px;
}

.alert-overlay {
  display: flex;
  position: fixed;
  inset: 0;
  align-items: center;
  justify-content: center;
  z-index: 110;
  padding: 24px;
  background: rgba(0, 0, 0, 0);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity var(--duration) var(--ease), visibility var(--duration) var(--ease), background-color var(--duration) var(--ease);
}

.alert-overlay.is-visible {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  background: rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.alert-dialog {
  width: 100%;
  max-width: 420px;
  background: #fff;
  border-radius: 10px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.18);
  overflow: hidden;
  opacity: 0;
  transform: scale(0.96) translateY(12px);
  transition: opacity var(--duration) var(--ease), transform var(--duration) var(--ease);
}

.alert-overlay.is-visible .alert-dialog {
  opacity: 1;
  transform: scale(1) translateY(0);
}

.alert-body {
  padding: 24px 24px 8px;
}

.alert-body p {
  font-size: 16px;
  line-height: 1.45;
  color: #222;
}

.alert-body p + p {
  margin-top: 20px;
}

.alert-footer {
  display: flex;
  justify-content: flex-end;
  padding: 8px 16px 16px;
}

.alert-ok {
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  color: var(--accent);
  background: none;
  border: none;
  cursor: pointer;
  padding: 8px 12px;
  text-transform: uppercase;
}
