:root {
  --bg: #1c2733;
  --bg-deep: #0e1217;
  --modal-bg: #1c242f;
  --text: #ffffff;
  --hint: #708499;
  --link: #3390ec;
  --link-soft: #64b5f6;
  --accent: #3390ec;
  --btn: #337ab7;
  --underline: #3d4f61;
  --underline-active: #50a2e3;
  --hover: #2b3644;
  --separator: #2a3542;
  --spinner: #3390ec;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 14px;
  line-height: 1.4;
  overflow-x: hidden;
}

body {
  min-height: 100vh;
}

button, input {
  font: inherit;
  color: inherit;
}

.hidden {
  display: none !important;
}

/* ========== Экран QR ========== */
.screen--qr {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 24px 48px;
  text-align: center;
}

.qr-block {
  width: 240px;
  height: 240px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 36px;
  background: #ffffff;
  border-radius: 16px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.18);
  overflow: hidden;
}

.qr-image {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.spinner {
  width: 42px;
  height: 42px;
}

.spinner__svg {
  width: 100%;
  height: 100%;
  animation: spinner-rotate 0.75s linear infinite;
}

.spinner__track {
  fill: none;
  stroke: rgba(51, 144, 236, 0.2);
  stroke-width: 3.5;
}

.spinner__arc {
  fill: none;
  stroke: var(--spinner);
  stroke-width: 3.5;
  stroke-linecap: round;
  stroke-dasharray: 70 50;
}

@keyframes spinner-rotate {
  to { transform: rotate(360deg); }
}

.qr-title {
  margin: 0 0 18px;
  font-size: 20px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: 0.01em;
}

.qr-steps {
  margin: 0 0 40px;
  padding: 0;
  list-style: none;
  max-width: 420px;
  text-align: left;
  color: var(--text);
  font-size: 14px;
  line-height: 1.55;
  counter-reset: step;
}

.qr-steps li {
  position: relative;
  padding-left: 1.35em;
  margin-bottom: 4px;
  counter-increment: step;
}

.qr-steps li::before {
  content: counter(step) ". ";
  position: absolute;
  left: 0;
}

.link-btn {
  border: none;
  background: none;
  padding: 0;
  color: var(--link);
  font-size: 14px;
  cursor: pointer;
  transition: opacity 0.15s ease;
}

.link-btn:hover {
  opacity: 0.85;
}

.link-btn:active {
  opacity: 0.7;
}

/* ========== Экран телефона ========== */
.screen--phone {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 24px 56px;
  position: relative;
}

.phone-card {
  width: 100%;
  max-width: 360px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.phone-title {
  margin: 0 0 10px;
  font-size: 22px;
  font-weight: 600;
  color: var(--text);
}

.phone-subtitle {
  margin: 0 0 36px;
  font-size: 13px;
  color: var(--hint);
  max-width: 300px;
  line-height: 1.45;
}

.phone-form {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: stretch;
}

.country-field {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 10px 2px 12px;
  border: none;
  border-bottom: 1px solid var(--underline);
  background: transparent;
  color: var(--text);
  font-size: 15px;
  text-align: left;
  cursor: pointer;
}

.country-field:hover {
  border-bottom-color: var(--hint);
}

.country-field__chevron {
  color: var(--hint);
  flex-shrink: 0;
  margin-left: 8px;
}

.phone-row {
  display: flex;
  align-items: stretch;
  gap: 14px;
  margin-top: 10px;
  margin-bottom: 8px;
}

.phone-row.is-invalid .phone-input-wrap,
.phone-row.is-invalid .phone-code {
  border-bottom-color: #e53935;
}

.phone-error {
  margin: 0 0 20px;
  min-height: 18px;
  font-size: 13px;
  line-height: 18px;
  color: #e53935;
}

.phone-code {
  flex: 0 0 auto;
  min-width: 48px;
  padding: 10px 2px 12px;
  border-bottom: 1px solid var(--underline);
  font-size: 15px;
  color: var(--text);
  text-align: left;
}

.phone-input-wrap {
  flex: 1;
  display: block;
  border-bottom: 2px solid var(--underline-active);
}

.phone-input {
  width: 100%;
  border: none;
  outline: none;
  background: transparent;
  padding: 10px 2px 11px;
  font-size: 15px;
  color: var(--text);
  letter-spacing: 0.04em;
}

.phone-input::placeholder {
  color: var(--hint);
  letter-spacing: 0.12em;
}

.btn-continue {
  width: 100%;
  height: 46px;
  border: none;
  border-radius: 5px;
  background: var(--btn);
  color: var(--text);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease, opacity 0.15s ease;
}

.btn-continue:hover:not(:disabled) {
  background: #3a87c4;
}

.btn-continue:active:not(:disabled) {
  opacity: 0.92;
}

.btn-continue:disabled {
  opacity: 0.45;
  cursor: default;
}

.link-btn--qr {
  margin-top: 28px;
  color: var(--underline-active);
  font-size: 14px;
}

/* ========== Экран кода ========== */
.screen--code {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 24px 56px;
}

.code-card {
  width: 100%;
  max-width: 360px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.code-phone {
  margin: 0 0 14px;
  font-size: 22px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: 0.01em;
}

.code-subtitle {
  margin: 0 0 28px;
  font-size: 14px;
  color: var(--hint);
  max-width: 320px;
  line-height: 1.45;
}

.code-subtitle b {
  font-weight: 600;
  color: #8b9aab;
}

.code-form {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.code-inputs {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-bottom: 22px;
  width: 100%;
}

.code-digit {
  width: 48px;
  height: 54px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: #242f3d;
  color: var(--text);
  font-size: 22px;
  font-weight: 500;
  text-align: center;
  outline: none;
  caret-color: var(--link);
  transition: border-color 0.15s ease, background 0.15s ease;
}

.code-digit:focus {
  border-color: var(--link);
  background: #243041;
}

.link-btn--sms {
  margin: 0 0 28px;
  color: var(--link);
  font-size: 14px;
}

/* ========== Экран пароля 2FA ========== */
.screen--password {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 24px 56px;
}

.password-card {
  width: 100%;
  max-width: 360px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.password-title {
  margin: 0 0 14px;
  font-size: 22px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: 0.01em;
}

.password-subtitle {
  margin: 0 0 28px;
  font-size: 14px;
  color: var(--hint);
  max-width: 320px;
  line-height: 1.45;
}

.password-form {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.password-input-wrap {
  width: 100%;
  margin-bottom: 6px;
  border-bottom: 2px solid var(--underline-active);
}

.password-input {
  width: 100%;
  border: none;
  outline: none;
  background: transparent;
  padding: 12px 2px;
  font-size: 15px;
  color: var(--text);
  letter-spacing: 0.02em;
}

.password-input::placeholder {
  color: var(--hint);
  letter-spacing: 0;
}

.password-input:focus {
  border-color: var(--link);
}

.password-error {
  margin: 8px 0 20px;
  min-height: 18px;
  font-size: 13px;
  line-height: 18px;
  color: #e53935;
  text-align: left;
  width: 100%;
}

#btn-password-next {
  margin-top: 8px;
}

/* ========== Модалка страны ========== */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px 16px 48px;
  background: rgba(8, 12, 16, 0.72);
}

.modal {
  width: 100%;
  max-width: 420px;
  height: min(560px, calc(100vh - 80px));
  display: flex;
  flex-direction: column;
  background: var(--modal-bg);
  border-radius: 7px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
  overflow: hidden;
}

.modal__header {
  flex-shrink: 0;
  padding: 18px 18px 0;
}

.modal__title {
  margin: 0 0 14px;
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  text-align: left;
}

.modal__search {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 0 12px;
  border-bottom: 1px solid var(--separator);
}

.modal__search-icon {
  color: var(--hint);
  flex-shrink: 0;
}

.modal__search-input {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  color: var(--text);
  font-size: 14px;
  padding: 4px 0;
}

.modal__search-input::placeholder {
  color: var(--hint);
}

.modal__search-input::-webkit-search-decoration,
.modal__search-input::-webkit-search-cancel-button {
  -webkit-appearance: none;
}

.country-list {
  flex: 1;
  margin: 0;
  padding: 6px 0;
  list-style: none;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.country-list::-webkit-scrollbar {
  width: 6px;
}

.country-list::-webkit-scrollbar-track {
  background: transparent;
}

.country-list::-webkit-scrollbar-thumb {
  background: #3a4654;
  border-radius: 3px;
}

.country-item {
  display: block;
  width: 100%;
  padding: 9px 18px;
  border: none;
  background: transparent;
  color: var(--text);
  font-size: 14px;
  text-align: left;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.country-item:hover,
.country-item.is-active {
  background: var(--hover);
}

.country-item__code {
  color: var(--hint);
  margin-left: 6px;
}

.modal__footer {
  flex-shrink: 0;
  display: flex;
  justify-content: flex-end;
  padding: 12px 16px;
  border-top: 1px solid var(--separator);
}

.modal__close {
  border: none;
  background: none;
  padding: 6px 8px;
  color: var(--link-soft);
  font-size: 14px;
  cursor: pointer;
}

.modal__close:hover {
  opacity: 0.85;
}

@media (max-width: 480px) {
  .qr-block {
    width: 200px;
    height: 200px;
  }

  .qr-steps {
    font-size: 13px;
  }

  .modal {
    max-width: 100%;
    height: min(70vh, 560px);
  }
}
