:root {
  --bg: #f5f8ff;
  --surface: rgba(255, 255, 255, 0.92);
  --surface-strong: #ffffff;
  --line: #dce6fb;
  --text: #162033;
  --text-soft: #61708d;
  --text-faint: #8795b0;
  --blue: #3f7cff;
  --blue-dark: #2258d5;
  --blue-soft: #e8f0ff;
  --shadow-lg: 0 30px 80px rgba(48, 90, 170, 0.14);
  --shadow-md: 0 14px 34px rgba(48, 90, 170, 0.08);
  --radius-xl: 30px;
  --radius-lg: 18px;
  --font-family: "Segoe UI", "Be Vietnam Pro", system-ui, -apple-system, BlinkMacSystemFont, Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-family);
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(93, 139, 255, 0.18), transparent 28%),
    radial-gradient(circle at 88% 10%, rgba(106, 214, 255, 0.18), transparent 20%),
    linear-gradient(180deg, #fbfdff 0%, #f1f6ff 100%);
}

.login-page {
  min-height: 100vh;
  width: min(100% - 24px, 1180px);
  margin: 0 auto;
  padding: 24px 0 40px;
  display: grid;
  place-items: center;
}

.login-card {
  width: min(100%, 480px);
  padding: 30px;
  border-radius: var(--radius-xl);
  background: var(--surface);
  border: 1px solid rgba(255, 255, 255, 0.98);
  box-shadow: var(--shadow-lg);
  backdrop-filter: blur(18px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 14px;
}

.brand-mark {
  width: 52px;
  height: 52px;
  border-radius: 18px;
  display: grid;
  place-items: center;
  color: #ffffff;
  background: linear-gradient(135deg, #4e85ff 0%, #7b5cff 100%);
  box-shadow: 0 16px 28px rgba(78, 133, 255, 0.2);
}

.brand-mark svg {
  width: 24px;
  height: 24px;
}

.brand-copy {
  display: grid;
  gap: 4px;
}

.brand-copy strong {
  font-size: 1.9rem;
  line-height: 1;
  letter-spacing: -0.04em;
}

.brand-copy small {
  color: var(--text-soft);
  font-size: 0.94rem;
}

.login-header {
  margin-top: 28px;
}

.login-badge {
  display: inline-flex;
  padding: 8px 14px;
  border-radius: 999px;
  color: var(--blue-dark);
  background: var(--blue-soft);
  border: 1px solid #d2e0ff;
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.login-header h1 {
  margin: 18px 0 10px;
  font-size: clamp(2rem, 4vw, 2.7rem);
  line-height: 1.05;
  letter-spacing: -0.05em;
}

.login-header p {
  margin: 0;
  color: var(--text-soft);
  line-height: 1.75;
}

.auth-alert {
  margin-top: 22px;
  padding: 14px 16px;
  border: 1px solid #ffd6d6;
  border-radius: 18px;
  background: #fff6f6;
  color: #cf4444;
  font-size: 0.92rem;
  line-height: 1.65;
}

.login-form {
  display: grid;
  gap: 18px;
  margin-top: 28px;
}

.split-fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.field {
  display: grid;
  gap: 10px;
}

.field label {
  color: var(--text-faint);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.field-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.field-head a {
  color: var(--blue-dark);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 600;
}

.login-form input {
  width: 100%;
  height: 56px;
  padding: 0 16px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--line);
  background: var(--surface-strong);
  color: var(--text);
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.login-form input::placeholder {
  color: #98a5bd;
}

.login-form input:focus {
  border-color: #a9c5ff;
  box-shadow: 0 0 0 4px rgba(63, 124, 255, 0.12);
}

.login-form input.is-invalid {
  border-color: #ff6a6a;
  box-shadow: 0 0 0 4px rgba(255, 106, 106, 0.12);
}

.password-wrap {
  position: relative;
}

.password-wrap input {
  padding-right: 48px;
}

.password-strength {
  display: grid;
  gap: 8px;
  margin-top: 2px;
}

.password-strength-track {
  width: 100%;
  height: 8px;
  border-radius: 999px;
  background: #e6edf9;
  overflow: hidden;
}

.password-strength-fill {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: #b7c4dc;
  transition: width 0.24s ease, background-color 0.24s ease;
}

.password-strength-text {
  margin: 0;
  color: var(--text-faint);
  font-size: 0.84rem;
  line-height: 1.5;
}

.password-strength-text strong {
  color: var(--text-soft);
  font-weight: 800;
}

.password-strength[data-strength="weak"] .password-strength-fill {
  width: 33%;
  background: #ff6a6a;
}

.password-strength[data-strength="weak"] .password-strength-text strong {
  color: #d94141;
}

.password-strength[data-strength="medium"] .password-strength-fill {
  width: 66%;
  background: #ffb020;
}

.password-strength[data-strength="medium"] .password-strength-text strong {
  color: #d28a10;
}

.password-strength[data-strength="strong"] .password-strength-fill {
  width: 100%;
  background: #3ac779;
}

.password-strength[data-strength="strong"] .password-strength-text strong {
  color: #1f9d5b;
}

.password-match-message {
  margin: 2px 0 0;
  color: var(--text-faint);
  font-size: 0.84rem;
  line-height: 1.5;
}

.password-match-message strong {
  color: var(--text-soft);
  font-weight: 800;
}

.password-match-message[data-match="match"] strong {
  color: #1f9d5b;
}

.password-match-message[data-match="mismatch"] strong {
  color: #d94141;
}

.password-match-message[data-match="pending"] strong {
  color: #d28a10;
}

.field-error,
.terms-error-message {
  margin: -2px 0 0;
  color: #d94141;
  font-size: 0.84rem;
  font-weight: 600;
  line-height: 1.45;
}

.field-error:empty,
.terms-error-message:empty {
  display: none;
}

.input-icon,
.password-toggle {
  position: absolute;
  right: 16px;
  top: 50%;
  transform: translateY(-50%);
  display: inline-flex;
  color: #91a0bc;
}

.input-icon {
  pointer-events: none;
}

.password-toggle {
  width: 32px;
  height: 32px;
  align-items: center;
  justify-content: center;
  border: 0;
  padding: 0;
  border-radius: 999px;
  background: transparent;
  cursor: pointer;
  transition: background-color 0.2s ease, color 0.2s ease;
}

.password-toggle:hover {
  color: var(--blue-dark);
  background: #edf3ff;
}

.password-toggle.is-active {
  color: var(--blue-dark);
  background: #e8f0ff;
}

.input-icon svg,
.password-toggle svg {
  width: 18px;
  height: 18px;
}

.submit-button {
  width: 100%;
  height: 58px;
  border: 0;
  border-radius: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  color: #ffffff;
  background: linear-gradient(180deg, #4f86ff 0%, #306ef3 100%);
  box-shadow: 0 18px 34px rgba(48, 110, 243, 0.24);
  font-size: 1rem;
  font-weight: 800;
  cursor: pointer;
}

.submit-button.is-loading {
  opacity: 0.7;
  pointer-events: none;
}

.submit-button svg {
  width: 16px;
  height: 16px;
}

.helper-text {
  margin: -2px 0 0;
  color: var(--text-faint);
  font-size: 0.88rem;
  line-height: 1.6;
}

.check-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  color: var(--text-soft);
  font-size: 0.92rem;
  line-height: 1.6;
}

.check-row.is-invalid {
  padding: 12px 14px;
  border: 1px solid #ffd2d2;
  border-radius: 16px;
  background: #fff6f6;
}

.check-row input {
  width: 18px;
  height: 18px;
  margin-top: 2px;
  accent-color: var(--blue);
  flex: 0 0 auto;
}

.check-row a {
  color: var(--blue-dark);
  text-decoration: none;
  font-weight: 700;
}

.terms-modal {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 1000;
}

.terms-modal.is-open {
  display: flex;
}

.terms-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(18, 32, 51, 0.28);
  backdrop-filter: blur(6px);
}

.terms-dialog {
  position: relative;
  z-index: 1;
  width: min(100%, 720px);
  display: grid;
  gap: 16px;
  padding: 22px;
  border-radius: 24px;
  border: 1px solid rgba(255, 255, 255, 0.96);
  background: rgba(255, 255, 255, 0.96);
  box-shadow: var(--shadow-lg);
}

.terms-close {
  width: 38px;
  height: 38px;
  border: 0;
  border-radius: 999px;
  background: #edf3ff;
  color: var(--blue-dark);
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
}

.terms-panel-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
}

.terms-head-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 0 0 auto;
}

.terms-panel-head strong {
  display: block;
  font-size: 0.98rem;
}

.terms-panel-head p {
  margin: 6px 0 0;
  color: var(--text-soft);
  font-size: 0.9rem;
  line-height: 1.6;
}

.terms-timer {
  flex: 0 0 auto;
  min-width: 58px;
  text-align: center;
  padding: 8px 10px;
  border-radius: 999px;
  background: var(--blue-soft);
  color: var(--blue-dark);
  font-size: 0.9rem;
  font-weight: 800;
}

.terms-content {
  max-height: min(46vh, 360px);
  overflow-y: auto;
  padding-right: 6px;
}

.terms-content p {
  margin: 0 0 12px;
  color: var(--text-soft);
  font-size: 0.92rem;
  line-height: 1.75;
}

.terms-content p:last-child {
  margin-bottom: 0;
}

.terms-actions {
  display: flex;
  justify-content: flex-end;
}

.terms-button {
  min-height: 44px;
  padding: 0 18px;
  border: 0;
  border-radius: 14px;
  background: linear-gradient(180deg, #4f86ff 0%, #306ef3 100%);
  color: #ffffff;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 12px 24px rgba(48, 110, 243, 0.2);
}

.terms-button:disabled {
  background: #c7d6f6;
  color: #f8fbff;
  cursor: not-allowed;
  box-shadow: none;
}

.login-footer {
  margin-top: 22px;
  text-align: center;
}

.login-footer p {
  margin: 0;
  color: var(--text-soft);
}

.login-footer p a {
  color: var(--blue-dark);
  text-decoration: none;
  font-weight: 700;
}

.service-tags {
  display: flex;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 18px;
}

.service-tags span {
  padding: 9px 14px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.84);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-md);
  color: var(--text-soft);
  font-size: 0.88rem;
  font-weight: 600;
}

.success-modal {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 1200;
}

.success-modal.is-open {
  display: flex;
}

.success-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(18, 32, 51, 0.34);
  backdrop-filter: blur(8px);
}

.success-dialog {
  position: relative;
  z-index: 1;
  width: min(100%, 360px);
  padding: 28px 24px 24px;
  border-radius: 28px;
  text-align: center;
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid rgba(255, 255, 255, 0.98);
  box-shadow: 0 30px 80px rgba(48, 90, 170, 0.2);
}

.success-icon {
  position: relative;
  width: 90px;
  height: 90px;
  margin: 0 auto 18px;
  display: grid;
  place-items: center;
}

.success-ring,
.success-ring::before,
.success-ring::after {
  position: absolute;
  inset: 0;
  border-radius: 999px;
}

.success-ring {
  background: radial-gradient(circle, rgba(43, 214, 108, 0.2) 0%, rgba(43, 214, 108, 0.04) 62%, transparent 64%);
  animation: pulseRing 1.8s ease-out infinite;
}

.success-ring::before,
.success-ring::after {
  content: "";
  border: 1px solid rgba(43, 214, 108, 0.28);
}

.success-ring::before {
  animation: scaleRing 1.8s ease-out infinite;
}

.success-ring::after {
  animation: scaleRing 1.8s ease-out 0.35s infinite;
}

.success-check {
  position: relative;
  z-index: 1;
  width: 56px;
  height: 56px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  color: #ffffff;
  background: linear-gradient(180deg, #2fdd72 0%, #18ba57 100%);
  box-shadow: 0 16px 32px rgba(24, 186, 87, 0.28);
}

.success-check svg {
  width: 28px;
  height: 28px;
  stroke-dasharray: 40;
  stroke-dashoffset: 40;
  animation: drawCheck 0.7s ease forwards 0.25s;
}

.success-dialog h2 {
  margin: 0;
  font-size: 1.5rem;
  line-height: 1.15;
}

.success-dialog p {
  margin: 10px 0 0;
  color: var(--text-soft);
  line-height: 1.7;
}

.success-progress {
  position: relative;
  height: 6px;
  margin-top: 18px;
  border-radius: 999px;
  overflow: hidden;
  background: #e7eefc;
}

.success-progress::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(90deg, #2ed76d 0%, #63f29a 100%);
  transform-origin: left center;
  animation: loadingBar 1.6s linear forwards;
}

@keyframes drawCheck {
  to {
    stroke-dashoffset: 0;
  }
}

@keyframes pulseRing {
  0%,
  100% {
    transform: scale(0.98);
    opacity: 0.9;
  }

  50% {
    transform: scale(1.05);
    opacity: 1;
  }
}

@keyframes scaleRing {
  0% {
    transform: scale(0.8);
    opacity: 0.4;
  }

  100% {
    transform: scale(1.2);
    opacity: 0;
  }
}

@keyframes loadingBar {
  from {
    transform: scaleX(0);
  }

  to {
    transform: scaleX(1);
  }
}

@media (max-width: 640px) {
  .login-page {
    width: calc(100% - 20px);
    padding: 16px 0 24px;
  }

  .login-card {
    padding: 22px 16px;
    border-radius: 24px;
  }

  .field-head {
    flex-direction: column;
    align-items: flex-start;
  }

  .split-fields {
    grid-template-columns: 1fr;
    gap: 18px;
  }

  .terms-panel-head {
    flex-direction: column;
  }

  .terms-head-actions {
    width: 100%;
    justify-content: space-between;
  }

  .terms-actions {
    justify-content: stretch;
  }

  .terms-button {
    width: 100%;
  }

  .terms-dialog {
    padding: 20px 16px 16px;
    border-radius: 22px;
  }

  .success-dialog {
    padding: 24px 18px 20px;
    border-radius: 24px;
  }
}
