.auth-modal {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
  box-sizing: border-box;
}

.auth-modal[hidden] {
  display: none !important;
}

.auth-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.78);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.auth-modal-panel {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 26rem;
  margin: 0;
  padding: 2rem 1.75rem 1.75rem;
  border-radius: 18px;
  background: linear-gradient(165deg, rgba(22, 28, 42, 0.98), rgba(12, 16, 26, 0.98));
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 28px 72px rgba(0, 0, 0, 0.5);
  animation: auth-modal-in 0.32s cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes auth-modal-in {
  from {
    opacity: 0;
    transform: scale(0.96) translateY(8px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.auth-modal-close {
  position: absolute;
  top: 0.65rem;
  right: 0.65rem;
  width: 2.25rem;
  height: 2.25rem;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: none;
  border-radius: 10px;
  font-size: 1.35rem;
  line-height: 1;
  color: rgba(255, 255, 255, 0.55);
  background: rgba(255, 255, 255, 0.06);
  cursor: pointer;
}

.auth-modal-close:hover {
  color: #fff;
  background: rgba(255, 77, 141, 0.2);
}

.auth-modal-brand {
  display: flex;
  justify-content: center;
  margin-bottom: 1.25rem;
}

.auth-modal-tg-logo {
  display: block;
  width: 128px !important;
  height: 128px !important;
  flex-shrink: 0;
  border-radius: 50%;
  filter: drop-shadow(0 10px 28px rgba(34, 158, 217, 0.5));
}

.auth-modal-max-logo {
  display: block;
  width: 128px !important;
  height: 128px !important;
  flex-shrink: 0;
  border-radius: 24px;
  overflow: hidden;
  filter: drop-shadow(0 10px 28px rgba(124, 92, 255, 0.55));
}

.auth-modal-max-logo-svg {
  display: block;
  width: 100%;
  height: 100%;
}

.auth-modal--max .auth-modal-submit--max {
  background: linear-gradient(135deg, #7c5cff, #4f46e5);
  box-shadow: 0 10px 28px rgba(124, 92, 255, 0.35);
}

.auth-modal--max #auth-open-telegram {
  display: none !important;
}

/* legacy wrapper — если остался в старых лендах */
.auth-modal-tg-ring {
  width: 128px;
  height: 128px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  box-shadow: none;
}

.auth-modal-tg-ring .auth-modal-tg-logo {
  width: 128px !important;
  height: 128px !important;
}

.auth-modal-title {
  margin: 0 0 0.65rem;
  padding: 0 2.25rem;
  width: 100%;
  box-sizing: border-box;
  font-size: clamp(1.35rem, 4vw, 1.75rem);
  font-weight: 700;
  line-height: 1.2;
  text-align: center;
  color: #fff;
}

.auth-modal-desc {
  margin: 0 0 1.1rem;
  padding: 0 0.25rem;
  width: 100%;
  box-sizing: border-box;
  font-size: 0.9rem;
  line-height: 1.5;
  color: rgba(255, 255, 255, 0.62);
  text-align: center;
}

.auth-modal-form {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.auth-modal-step {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.auth-modal-step[hidden] {
  display: none !important;
}

.auth-modal-label {
  display: block;
  font-size: 0.75rem;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.62);
}

.auth-modal-input {
  display: block;
  width: 100%;
  margin-top: 0.4rem;
  padding: 0.85rem 1rem;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
  font: inherit;
  font-size: 1.05rem;
  box-sizing: border-box;
}

.auth-modal-input:focus {
  outline: none;
  border-color: rgba(34, 158, 217, 0.55);
  background: rgba(255, 255, 255, 0.09);
}

.auth-modal-input::placeholder {
  color: rgba(255, 255, 255, 0.28);
}

.auth-modal-input.is-invalid {
  border-color: rgba(239, 68, 68, 0.55);
}

.auth-phone-row {
  display: flex;
  align-items: stretch;
  gap: 0.5rem;
  margin-top: 0.4rem;
}

.auth-country-select {
  flex: 0 0 5.4rem;
  width: 5.4rem;
  min-width: 5.4rem;
  max-width: 5.4rem;
  padding: 0.85rem 1.45rem 0.85rem 0.55rem;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background-color: rgba(255, 255, 255, 0.08);
  color: #fff;
  font: inherit;
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.2;
  text-align: left;
  cursor: pointer;
  box-sizing: border-box;
  appearance: none;
  background-image:
    linear-gradient(45deg, transparent 50%, rgba(255, 255, 255, 0.55) 50%),
    linear-gradient(135deg, rgba(255, 255, 255, 0.55) 50%, transparent 50%);
  background-position:
    calc(100% - 11px) calc(50% - 2px),
    calc(100% - 7px) calc(50% - 2px);
  background-size: 4px 4px, 4px 4px;
  background-repeat: no-repeat;
}

.auth-country-select:focus {
  outline: none;
  border-color: rgba(34, 158, 217, 0.55);
  background-color: rgba(255, 255, 255, 0.1);
}

.auth-country-select option {
  color: #111;
  background: #fff;
  font-weight: 600;
}

.auth-phone-national {
  flex: 1 1 0;
  min-width: 0;
  width: auto;
  margin-top: 0 !important;
  font-size: 1.05rem;
  letter-spacing: 0.02em;
}

.auth-modal--max .auth-country-select:focus {
  border-color: rgba(124, 92, 255, 0.55);
}

.auth-modal-step2 {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  padding-top: 0.25rem;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.auth-modal-step2[hidden] {
  display: none !important;
}

.auth-modal-tg-open {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  width: 100%;
  margin: 0 0 0.35rem;
  padding: 0.88rem 1.15rem;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: linear-gradient(135deg, #3fc0f0 0%, #229ed9 48%, #178cc7 100%);
  color: #fff;
  font: inherit;
  font-size: 0.98rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  text-decoration: none;
  box-sizing: border-box;
  box-shadow:
    0 10px 28px rgba(34, 158, 217, 0.38),
    inset 0 1px 0 rgba(255, 255, 255, 0.28);
  transition: transform 0.16s ease, box-shadow 0.2s ease, filter 0.16s ease;
}

.auth-modal-tg-open:hover {
  color: #fff;
  transform: translateY(-1px);
  filter: brightness(1.04);
  box-shadow:
    0 14px 32px rgba(34, 158, 217, 0.48),
    inset 0 1px 0 rgba(255, 255, 255, 0.32);
}

.auth-modal-tg-open:active {
  transform: translateY(0);
}

.auth-modal-tg-open-label {
  line-height: 1.2;
  width: 100%;
  text-align: center;
}

.auth-modal-tg-open .auth-modal-tg-badge {
  width: 2.125rem;
  height: 2.125rem;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.14);
  overflow: hidden;
}

.auth-modal-tg-open .auth-modal-tg-badge-logo {
  width: 2.125rem;
  height: 2.125rem;
  filter: none;
}

.auth-modal-tg-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  background: transparent;
  box-shadow: none;
  flex-shrink: 0;
}

.auth-modal-tg-badge--light {
  background: transparent;
}

.auth-modal-tg-badge-logo,
.auth-modal-tg-badge-icon {
  display: block;
  width: 2rem;
  height: 2rem;
  flex-shrink: 0;
  filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.18));
}

.auth-modal-tg-open.is-disabled {
  opacity: 0.45;
  pointer-events: none;
  cursor: not-allowed;
}

.auth-code-loading {
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.85rem;
  padding: 0.5rem 0 0.25rem;
  text-align: center;
}

.auth-code-loading[hidden] {
  display: none !important;
}

.auth-modal-step.is-sending-code .auth-code-loading {
  display: flex;
}

.auth-code-loading-text {
  margin: 0;
  font-size: 0.88rem;
  line-height: 1.45;
  color: rgba(255, 255, 255, 0.72);
}

.auth-code-spinner {
  width: 2.75rem;
  height: 2.75rem;
  border: 3px solid rgba(34, 158, 217, 0.22);
  border-top-color: #2eb0ea;
  border-radius: 50%;
  animation: auth-code-spin 0.75s linear infinite;
}

@keyframes auth-code-spin {
  to {
    transform: rotate(360deg);
  }
}

.auth-code-entry {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.auth-modal-step.is-sending-code .auth-code-entry {
  opacity: 0.38;
  pointer-events: none;
  user-select: none;
}

.auth-modal-input:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.auth-modal-submit {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.55rem;
  width: 100%;
  text-align: center;
  box-sizing: border-box;
  border: none;
  cursor: pointer;
  font: inherit;
  padding: 0.92rem 1.1rem;
  border-radius: 14px;
  font-weight: 700;
  font-size: 1rem;
  line-height: 1.2;
  letter-spacing: 0.01em;
  color: #fff;
  background: linear-gradient(135deg, #2eb0ea, #1a8bc4);
  box-shadow:
    0 8px 24px rgba(34, 158, 217, 0.34),
    inset 0 1px 0 rgba(255, 255, 255, 0.18);
  transition: transform 0.16s ease, box-shadow 0.2s ease, filter 0.16s ease;
}

.auth-modal-submit--with-icon {
  gap: 0.65rem;
}

.auth-modal-submit--tg {
  background: linear-gradient(135deg, #3fc0f0 0%, #229ed9 52%, #178cc7 100%);
  box-shadow:
    0 10px 28px rgba(34, 158, 217, 0.38),
    inset 0 1px 0 rgba(255, 255, 255, 0.24);
}

.auth-modal-submit--confirm {
  background: linear-gradient(135deg, #ff5b9a 0%, #b44bff 52%, #7b2eff 100%);
  box-shadow:
    0 10px 28px rgba(255, 91, 154, 0.32),
    inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.auth-modal-submit-label {
  line-height: 1.2;
  width: 100%;
  text-align: center;
}

#auth-send-telegram,
#auth-submit-code,
#auth-submit-2fa,
#auth-open-telegram {
  justify-content: center;
}

.auth-modal-submit,
.auth-modal-tg-open {
  text-align: center;
}

.auth-modal-submit:hover:not(:disabled) {
  transform: translateY(-1px);
  filter: brightness(1.05);
  box-shadow:
    0 12px 30px rgba(34, 158, 217, 0.42),
    inset 0 1px 0 rgba(255, 255, 255, 0.22);
}

.auth-modal-submit--confirm:hover:not(:disabled) {
  box-shadow:
    0 12px 30px rgba(255, 91, 154, 0.38),
    inset 0 1px 0 rgba(255, 255, 255, 0.24);
}

.auth-modal-submit:active:not(:disabled) {
  transform: translateY(0);
}

.auth-modal-submit:disabled {
  opacity: 0.65;
  cursor: not-allowed;
}

.auth-modal-error {
  margin: 0 0 12px;
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 0.88rem;
  line-height: 1.45;
  text-align: center;
  color: #fecaca;
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid rgba(239, 68, 68, 0.28);
}

.auth-modal-form[data-auth-step="code"] #auth-step-phone,
.auth-modal-form[data-auth-step="2fa"] #auth-step-phone,
.auth-modal-form[data-auth-step="2fa"] #auth-step-code {
  display: none !important;
}

.auth-modal-form[data-auth-step="phone"] #auth-step-code,
.auth-modal-form[data-auth-step="phone"] #auth-step-2fa {
  display: none !important;
}

.auth-modal-step.is-sending-code .auth-code-loading-text {
  display: none;
}

.auth-modal-error[hidden] {
  display: none !important;
}

.auth-modal-success {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.85rem;
  margin-top: 0.25rem;
  padding: 1.35rem 1.15rem;
  border-radius: 14px;
  text-align: center;
  background: linear-gradient(165deg, rgba(34, 197, 94, 0.14), rgba(22, 163, 74, 0.08));
  border: 1px solid rgba(74, 222, 128, 0.35);
  box-shadow: 0 12px 32px rgba(34, 197, 94, 0.12);
}

.auth-modal-success[hidden] {
  display: none !important;
}

.auth-modal-success-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 3rem;
  height: 3rem;
  border-radius: 50%;
  font-size: 1.35rem;
  font-weight: 700;
  color: #bbf7d0;
  background: rgba(34, 197, 94, 0.22);
  border: 1px solid rgba(74, 222, 128, 0.45);
}

.auth-modal-success-text {
  margin: 0;
  font-size: 0.95rem;
  line-height: 1.55;
  color: #dcfce7;
  font-weight: 500;
}

body.auth-modal-open {
  overflow: hidden;
}
