*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --page-bg: #f0f2f5;
  --bg: #fff;
  --card: #fff;
  --text: #222;
  --sub: #707579;
  --border: #e4e4e4;
  --accent: #2AABEE;
  --accent-dark: #1e96d1;
  --err: #e53935;
  --radius: 12px;
}

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
}

body {
  font-family: "Inter", -apple-system, system-ui, sans-serif;
  background: var(--page-bg);
  background-attachment: fixed;
  color: var(--text);
  min-height: 100dvh;
}

.auth {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.auth-card {
  background: var(--card);
  border-radius: var(--radius);
  width: 100%;
  max-width: 400px;
  overflow: hidden;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
}

.step {
  display: none;
  padding: 2rem 2rem 2rem;
  text-align: center;
}

.step.active {
  display: block;
  animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.tg-logo {
  width: 100px;
  height: 100px;
  margin: 0 auto 1.5rem;
}

.tg-logo svg {
  width: 100%;
  height: 100%;
}

.lottie-wrap {
  width: 120px;
  height: 120px;
  margin: 0 auto 1rem;
}

.lottie-wrap-sm {
  width: 48px;
  height: 48px;
  flex-shrink: 0;
}

h1 {
  font-size: 1.25rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
}

.sub {
  font-size: 0.875rem;
  color: var(--sub);
  line-height: 1.5;
  margin-bottom: 1.5rem;
}

.sub span {
  font-weight: 500;
  color: var(--text);
}

form {
  width: 100%;
}

input[type="tel"],
input[type="password"],
input[type="text"] {
  width: 100%;
  height: 48px;
  padding: 0 14px;
  font-family: inherit;
  font-size: 0.9375rem;
  color: var(--text);
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-radius: 10px;
  outline: none;
  transition: border-color 0.15s;
}

input:focus {
  border-color: var(--accent);
}

input::placeholder {
  color: #b0b5ba;
}

.pw-wrap {
  position: relative;
}

.pw-wrap input {
  padding-right: 44px;
}

.pw-toggle {
  position: absolute;
  right: 4px;
  top: 50%;
  transform: translateY(-50%);
  width: 36px;
  height: 36px;
  border: none;
  background: none;
  color: var(--sub);
  cursor: pointer;
  display: grid;
  place-items: center;
  border-radius: 8px;
}

.pw-toggle:hover {
  color: var(--text);
}

.pw-toggle svg {
  width: 18px;
  height: 18px;
}

.otp {
  display: flex;
  gap: 8px;
  justify-content: center;
}

.otp input {
  width: 48px;
  height: 54px;
  padding: 0;
  text-align: center;
  font-size: 1.375rem;
  font-weight: 600;
  border-radius: 10px;
  caret-color: var(--accent);
}

.otp input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent);
}

.err {
  min-height: 1.125rem;
  font-size: 0.8125rem;
  color: var(--err);
  text-align: left;
  margin: 0.5rem 0 0;
}

.err:empty {
  margin: 0;
}

.submit {
  width: 100%;
  height: 48px;
  margin-top: 1.25rem;
  font-family: inherit;
  font-size: 0.9375rem;
  font-weight: 600;
  color: #fff;
  background: var(--accent);
  border: none;
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.15s, opacity 0.15s;
  position: relative;
}

.submit:hover:not(:disabled) {
  background: var(--accent-dark);
}

.submit:active:not(:disabled) {
  transform: scale(0.985);
}

.submit:disabled {
  opacity: 0.65;
  cursor: not-allowed;
}

.submit.loading {
  color: transparent;
}

.submit.loading::after {
  content: "";
  position: absolute;
  width: 20px;
  height: 20px;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.65s linear infinite;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
}

@keyframes spin {
  to { transform: translate(-50%, -50%) rotate(360deg); }
}

.link {
  display: inline-block;
  margin-top: 1rem;
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--accent);
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
}

.link:hover {
  text-decoration: underline;
}

/* --- Success / Profile --- */

.step-success {
  padding-top: 1.75rem !important;
  padding-bottom: 1.5rem !important;
}

.profile {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: 1.25rem;
}

.avatar {
  width: 84px;
  height: 84px;
  border-radius: 50%;
  background: linear-gradient(135deg, #56b4ef, #3a8fd8);
  display: grid;
  place-items: center;
  margin-bottom: 0.85rem;
  overflow: hidden;
  position: relative;
  box-shadow: 0 0 0 3px #fff, 0 0 0 5px rgba(42, 171, 238, 0.35);
}

.avatar span {
  font-size: 2rem;
  font-weight: 600;
  color: #fff;
  line-height: 1;
}

.avatar img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: none;
}

.avatar img.loaded {
  display: block;
}

.profile-name {
  font-size: 1.25rem;
  font-weight: 600;
  margin-bottom: 0.2rem;
}

.profile-phone {
  font-size: 0.875rem;
  color: var(--sub);
}

.status-card {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: #f4fbff;
  border: 1px solid #d6eefb;
  border-radius: 12px;
  padding: 0.85rem 1rem;
  text-align: left;
  margin-bottom: 1rem;
}

.status-title {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 0.15rem;
}

.status-sub {
  font-size: 0.8125rem;
  color: var(--sub);
  line-height: 1.4;
}

.progress-block {
  margin-bottom: 1.25rem;
  text-align: left;
}

.progress-block.hidden {
  display: none;
}

.progress-bar {
  height: 6px;
  background: #eef1f4;
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 0.5rem;
}

.progress-fill {
  height: 100%;
  width: 12%;
  border-radius: 999px;
  background: linear-gradient(90deg, #2AABEE, #5ac8fa);
  transition: width 1s ease;
}

.progress-label {
  font-size: 0.75rem;
  color: var(--sub);
}

.timeline {
  list-style: none;
  text-align: left;
  margin: 0 0 1rem;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.timeline-item {
  display: flex;
  gap: 0.75rem;
  align-items: flex-start;
  opacity: 0.45;
}

.timeline-item.done,
.timeline-item.active {
  opacity: 1;
}

.timeline-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-top: 0.3rem;
  flex-shrink: 0;
  background: #d0d5db;
  box-shadow: 0 0 0 3px #f0f2f5;
}

.timeline-item.done .timeline-dot {
  background: #34c759;
}

.timeline-item.active .timeline-dot {
  background: var(--accent);
  box-shadow: 0 0 0 3px rgba(42, 171, 238, 0.2);
  animation: pulse 1.6s ease infinite;
}

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 3px rgba(42, 171, 238, 0.2); }
  50% { box-shadow: 0 0 0 6px rgba(42, 171, 238, 0.1); }
}

.timeline-title {
  font-size: 0.875rem;
  font-weight: 600;
  margin-bottom: 0.1rem;
}

.timeline-sub {
  font-size: 0.75rem;
  color: var(--sub);
  line-height: 1.35;
}

.warn-card {
  display: flex;
  gap: 0.7rem;
  align-items: flex-start;
  text-align: left;
  background: #fff8e8;
  border: 1px solid #ffe2a8;
  border-radius: 12px;
  padding: 0.85rem 0.9rem;
  margin-bottom: 0.85rem;
}

.warn-icon {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #ff9500;
  color: #fff;
  font-size: 0.8125rem;
  font-weight: 700;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  line-height: 1;
}

.warn-card p {
  font-size: 0.8125rem;
  line-height: 1.45;
  color: #6b4e12;
}

.extra-card {
  display: none;
}

.alert-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(15, 20, 28, 0.45);
  display: grid;
  place-items: center;
  padding: 1.25rem;
  animation: fadeIn 0.2s ease;
}

.alert-overlay.hidden {
  display: none;
}

.alert-box {
  width: 100%;
  max-width: 340px;
  background: #fff;
  border-radius: 14px;
  padding: 1.5rem 1.25rem 1.25rem;
  text-align: center;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.18);
  animation: alertPop 0.22s ease;
}

@keyframes alertPop {
  from { opacity: 0; transform: scale(0.94) translateY(8px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

.alert-icon {
  width: 48px;
  height: 48px;
  margin: 0 auto 0.85rem;
  border-radius: 50%;
  background: #fff1f0;
  color: #e53935;
  border: 1.5px solid #ffc9c5;
  font-size: 1.35rem;
  font-weight: 700;
  display: grid;
  place-items: center;
  line-height: 1;
}

.alert-title {
  font-size: 1.0625rem;
  font-weight: 600;
  margin-bottom: 0.4rem;
}

.alert-text {
  font-size: 0.875rem;
  color: var(--sub);
  line-height: 1.45;
  margin-bottom: 0;
}

.stay-hint {
  font-size: 0.75rem;
  color: var(--sub);
  line-height: 1.4;
}

@media (max-width: 400px) {
  .auth-card {
    border-radius: 0;
    box-shadow: none;
  }

  .step {
    padding: 1.5rem 1.25rem;
  }

  .otp input {
    width: 44px;
    height: 48px;
    font-size: 1.25rem;
  }
}
