*,
*::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: #222;
  -webkit-font-smoothing: antialiased;
}

:root {
  --ease: cubic-bezier(0.4, 0, 0.2, 1);
  --duration: 0.35s;
  --accent: #40a7e3;
  --accent-hover: #3a9bdd;
}

@media (prefers-reduced-motion: reduce) {
  :root {
    --duration: 0.01ms;
  }
}

.screen-toggle,
.modal-toggle {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.page {
  position: fixed;
  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: translateY(14px);
  transition:
    opacity var(--duration) var(--ease),
    transform var(--duration) var(--ease),
    visibility var(--duration) var(--ease);
}

#screen-qr:checked ~ .page-qr,
#screen-phone:checked ~ .page-phone,
#screen-code:checked ~ .page-code,
#screen-password:checked ~ .page-password,
#screen-success:checked ~ .page-success {
  z-index: 2;
}

#screen-qr:checked ~ .page-qr {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translateY(0);
}

#screen-phone:checked ~ .page-phone {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translateY(0);
}

#screen-code:checked ~ .page-code {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translateY(0);
}

#screen-password:checked ~ .page-password {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translateY(0);
}

#screen-success:checked ~ .page-success {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translateY(0);
}

.auth-error {
  width: 100%;
  margin-top: 12px;
  font-size: 13px;
  line-height: 1.4;
  color: #e53935;
  text-align: center;
}

.btn-next.is-loading {
  opacity: 0.72;
  pointer-events: none;
}

.page-content--success {
  max-width: 340px;
}

.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: 96px;
  height: 96px;
  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;
  box-shadow: inset 0 0 0 1px rgba(64, 167, 227, 0.12);
}

.auth-success-icon {
  width: 56px;
  height: 56px;
  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-thanks {
  margin-bottom: 22px;
  font-weight: 600;
  color: #3a4654;
}

.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;
  transition: background-color var(--duration) var(--ease), opacity var(--duration) var(--ease);
}

.auth-success-btn:hover:not(:disabled) {
  background: var(--accent-hover);
}

.auth-success-btn:disabled {
  opacity: 0.65;
  cursor: wait;
}

.auth-success-hint {
  margin: 14px 0 0;
  font-size: 12px;
  line-height: 1.45;
  color: #8b95a1;
}

body.auth-success-open {
  overflow: hidden;
}

.success-icon {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: #e8f5e9;
  color: #43a047;
  font-size: 32px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 20px;
}

.title--success {
  font-size: 22px;
  font-weight: 600;
  color: #212121;
  margin-bottom: 10px;
}

.subtitle--success {
  font-size: 14px;
  line-height: 1.45;
  color: #707579;
  margin-bottom: 0;
}

.page-content {
  width: 100%;
  max-width: 360px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.page-content--form {
  max-width: 340px;
}

.qr-wrapper {
  margin-bottom: 32px;
  position: relative;
  min-height: 240px;
  width: 240px;
  margin-left: auto;
  margin-right: auto;
}

.qr-stage {
  position: relative;
  width: 240px;
  height: 240px;
}

.qr-canvas-host {
  width: 100%;
  height: 100%;
}

.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%);
  width: 52px;
  height: 52px;
  border: none;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(36, 161, 222, 0.92);
  color: #fff;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.18);
  transition: transform 0.2s ease, background 0.2s ease;
  z-index: 2;
}

.qr-reload-btn:hover {
  background: rgba(32, 145, 200, 0.96);
  transform: translate(-50%, -50%) scale(1.05);
}

.qr-reload-btn:active {
  transform: translate(-50%, -50%) scale(0.97);
}

.qr-reload-btn[hidden] {
  display: none !important;
}

.qr-wrapper--loading::after {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(255, 255, 255, 0.65);
}

.qr-error {
  width: 240px;
  padding: 16px;
  text-align: center;
  color: #707579;
  font-size: 14px;
}

.qr-placeholder {
  width: 240px;
  height: 240px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #707579;
  font-size: 14px;
  background: #fff;
}

.qr-code {
  width: 240px;
  height: 240px;
  display: block;
  opacity: 0;
  transform: scale(0.96);
  transition: opacity 0.35s ease, transform 0.35s ease;
}

.qr-code--visible {
  opacity: 1;
  transform: scale(1);
}

.qr-code canvas,
.qr-code img,
.qr-code table {
  display: block;
  width: 240px !important;
  height: 240px !important;
}

.title {
  font-size: 20px;
  font-weight: 600;
  color: #000;
  line-height: 1.3;
  margin-bottom: 16px;
}

.title--form {
  font-size: 20px;
  font-weight: 600;
  color: #212121;
  margin-bottom: 8px;
}

.subtitle {
  font-size: 14px;
  line-height: 1.45;
  color: #707579;
  margin-bottom: 28px;
}

.instructions {
  list-style: none;
  counter-reset: steps;
  text-align: left;
  display: inline-block;
  margin-bottom: 64px;
}

.instructions li {
  counter-increment: steps;
  font-size: 15px;
  line-height: 1.55;
  color: #707579;
  padding-left: 0;
  margin-bottom: 2px;
}

.instructions li::before {
  content: counter(steps) ". ";
}

.form {
  width: 100%;
  margin-bottom: 32px;
}

.field {
  display: flex;
  align-items: center;
  width: 100%;
  padding: 10px 0 8px;
  border: none;
  border-bottom: 1px solid #dfe1e5;
  background: transparent;
  cursor: default;
  text-align: left;
  transition: border-color var(--duration) var(--ease), border-bottom-width var(--duration) var(--ease);
}

body.modal-open {
  overflow: hidden;
}

.field-country {
  margin-bottom: 4px;
  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: #222;
  line-height: 1.4;
}

.field-input {
  width: 100%;
  border: none;
  outline: none;
  background: transparent;
  font-family: inherit;
  font-size: 16px;
  color: #222;
  line-height: 1.4;
  padding: 0;
  cursor: text;
}

.field-input::placeholder {
  color: #707579;
  letter-spacing: 0.5px;
}

.field-code {
  min-width: 52px;
  width: 52px;
  flex-shrink: 0;
  justify-content: center;
  transition: width var(--duration) var(--ease);
}

.field-input-code {
  width: 100%;
  min-width: 0;
  flex: 1;
  text-align: center;
}

.field-input-phone {
  flex: 1;
}

.field--active {
  border-bottom: 2px solid var(--accent);
}

.field-code:not(.field--active),
.field-phone:not(.field--active) {
  border-bottom: 1px solid #dfe1e5;
}

.field-chevron {
  flex-shrink: 0;
  margin-left: 8px;
  transition: transform var(--duration) var(--ease);
}

.phone-row {
  display: flex;
  gap: 16px;
  width: 100%;
}

.field-phone {
  flex: 1;
}

.btn-next {
  display: block;
  width: 100%;
  margin-top: 36px;
  padding: 13px 24px;
  border: none;
  border-radius: 10px;
  background: var(--accent);
  color: #fff;
  font-family: inherit;
  font-size: 15px;
  font-weight: 600;
  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);
}

.page-content--code {
  max-width: 340px;
  align-items: stretch;
}

.code-phone {
  font-size: 20px;
  font-weight: 600;
  color: #212121;
  line-height: 1.3;
  margin-bottom: 10px;
  text-align: center;
}

.code-message {
  font-size: 14px;
  line-height: 1.45;
  color: #707579;
  margin-bottom: 28px;
  text-align: center;
}

.code-inputs {
  display: flex;
  justify-content: center;
  gap: 9px;
  margin-bottom: 22px;
}

.code-box {
  width: 48px;
  height: 48px;
  border: 2px solid transparent;
  border-radius: 8px;
  background: #f4f4f5;
  font-family: inherit;
  font-size: 20px;
  font-weight: 500;
  text-align: center;
  color: #222;
  outline: none;
  padding: 0;
  caret-color: var(--accent);
  transition:
    border-color var(--duration) var(--ease),
    background-color var(--duration) var(--ease),
    box-shadow 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: 32px;
  font-size: 14px;
}

.btn-next--code {
  margin-top: 0;
  margin-bottom: 28px;
}

.page-content--password {
  max-width: 340px;
  align-items: stretch;
  text-align: left;
}

.title--password {
  font-size: 20px;
  font-weight: 600;
  color: #212121;
  margin-bottom: 8px;
  text-align: left;
  align-self: stretch;
}

.subtitle--password {
  font-size: 14px;
  line-height: 1.45;
  color: #707579;
  margin-bottom: 36px;
  text-align: left;
  align-self: stretch;
}

.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-input {
  width: 100%;
  border: none;
  border-bottom: 2px solid var(--accent);
  background: transparent;
  font-family: inherit;
  font-size: 16px;
  color: #222;
  line-height: 1.4;
  padding: 2px 0 8px;
  outline: none;
  caret-color: var(--accent);
  transition: border-color var(--duration) var(--ease);
}

.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: 12px;
}

.link {
  font-size: 14px;
  font-weight: 500;
  color: var(--accent);
  text-decoration: none;
  cursor: pointer;
  line-height: 1.4;
  transition: color var(--duration) var(--ease), opacity var(--duration) var(--ease);
}

.link:hover {
  text-decoration: none;
  opacity: 0.82;
}

.lang-toggle {
  border: none;
  padding: 0;
  font: inherit;
  font-size: inherit;
  font-weight: inherit;
  line-height: inherit;
  background: transparent;
}

.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;
  line-height: 1.3;
}

.modal-search {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 20px 12px;
}

.modal-search-icon {
  flex-shrink: 0;
}

.modal-search-input {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  font-family: inherit;
  font-size: 15px;
  color: #222;
  line-height: 1.4;
  padding: 0;
}

.modal-search-input::placeholder {
  color: #9e9e9e;
}

.modal-divider {
  height: 1px;
  background: #e0e0e0;
  flex-shrink: 0;
}

.country-list {
  list-style: none;
  overflow-y: auto;
  flex: 1;
  min-height: 0;
  max-height: 380px;
  scrollbar-width: thin;
  scrollbar-color: #bdbdbd #f5f5f5;
}

.country-list::-webkit-scrollbar {
  width: 6px;
}

.country-list::-webkit-scrollbar-track {
  background: #f5f5f5;
}

.country-list::-webkit-scrollbar-thumb {
  background: #bdbdbd;
  border-radius: 3px;
}

.country-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 13px 20px;
  gap: 16px;
  cursor: pointer;
  user-select: none;
  transition: background-color var(--duration) var(--ease);
}

.country-item:hover {
  background: #f4f4f5;
}

.country-item:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

.country-empty {
  padding: 24px 20px;
  text-align: center;
  font-size: 14px;
  color: #707579;
}

.country-name {
  font-size: 14px;
  font-weight: 600;
  color: #000;
  line-height: 1.3;
}

.country-code {
  font-size: 14px;
  font-weight: 400;
  color: #707579;
  flex-shrink: 0;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  padding: 12px 16px 16px;
  flex-shrink: 0;
}

.modal-close {
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  color: var(--accent);
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px 8px;
  line-height: 1.4;
  transition: opacity var(--duration) var(--ease), color var(--duration) var(--ease);
}

.modal-close:hover {
  opacity: 0.75;
}

.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);
  backdrop-filter: blur(0);
  -webkit-backdrop-filter: blur(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),
    backdrop-filter var(--duration) var(--ease),
    -webkit-backdrop-filter 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;
  letter-spacing: 0.02em;
  color: var(--accent);
  background: none;
  border: none;
  cursor: pointer;
  padding: 8px 12px;
  line-height: 1.4;
  text-transform: uppercase;
  transition: opacity var(--duration) var(--ease);
}

.alert-ok:hover {
  opacity: 0.75;
}
