@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@400;500;700&family=IBM+Plex+Mono:wght@500&display=swap');

:root {
  --bg-0: #f7f7f2;
  --bg-1: #ffffff;
  --ink-0: #0f1720;
  --ink-1: #415269;
  --line: #d7dde7;
  --brand: #0f766e;
  --brand-soft: #d7f7f0;
  --danger: #b42318;
  --warning: #b54708;
  --success: #027a48;
  --info: #1d4ed8;
  --shadow: 0 24px 60px rgba(14, 28, 46, 0.14);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  min-height: 100vh;
  background:
    radial-gradient(1200px 500px at -10% -10%, #d0efe9 0%, transparent 60%),
    radial-gradient(900px 500px at 105% 100%, #fbe8d0 0%, transparent 60%),
    linear-gradient(180deg, var(--bg-0) 0%, #eef1f6 100%);
  color: var(--ink-0);
  font-family: 'Space Grotesk', 'Segoe UI', sans-serif;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px 18px;
}

body.is-redirecting {
  overflow: hidden;
}

.background-pattern {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
}

.background-pattern::before,
.background-pattern::after {
  content: '';
  position: absolute;
  border-radius: 999px;
  opacity: 0.45;
  filter: blur(20px);
}

.background-pattern::before {
  width: 260px;
  height: 260px;
  background: #c2ede4;
  top: 7%;
  right: 8%;
}

.background-pattern::after {
  width: 180px;
  height: 180px;
  background: #ffdcb5;
  bottom: 8%;
  left: 10%;
}

.login-wrapper {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 470px;
}

.login-card {
  background: linear-gradient(180deg, #ffffff 0%, #fdfefe 100%);
  border: 1px solid #e4eaf1;
  border-radius: 20px;
  box-shadow: var(--shadow);
  overflow: hidden;
  transform-origin: top center;
  animation: card-in 420ms cubic-bezier(0.18, 0.79, 0.28, 1);
}

@keyframes card-in {
  from {
    opacity: 0;
    transform: translateY(16px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.login-header {
  position: relative;
  padding: 30px 30px 22px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(140deg, #f5fbfa 0%, #f8f8ff 100%);
}

.logo-container {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}

.logo-icon {
  color: var(--brand);
  font-size: 34px;
}

.logo-text {
  font-size: 30px;
  letter-spacing: 0.02em;
  font-weight: 700;
}

.header-subtitle {
  text-align: center;
  color: var(--ink-1);
  font-size: 14px;
  margin-bottom: 16px;
}

.info-box {
  background: var(--brand-soft);
  border: 1px solid #9adfd2;
  border-radius: 12px;
  padding: 10px 12px;
}

.info-text {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #0f4e49;
  font-size: 13px;
  font-weight: 500;
}

.login-content {
  padding: 26px 30px;
}

.alert-container {
  margin-bottom: 14px;
}

.alert {
  border-radius: 12px;
  border: 1px solid transparent;
  padding: 10px 12px;
  font-size: 14px;
  line-height: 1.35;
}

.alert-success {
  background: #ecfdf3;
  border-color: #8be3bb;
  color: var(--success);
}

.alert-error {
  background: #fff0ef;
  border-color: #f5b4ae;
  color: var(--danger);
}

.alert-warning {
  background: #fff7ed;
  border-color: #f8cc9b;
  color: var(--warning);
}

.alert-info {
  background: #eff6ff;
  border-color: #b4d0ff;
  color: var(--info);
}

.form-group {
  margin-bottom: 14px;
}

.input-label {
  display: block;
  margin-bottom: 7px;
  color: var(--ink-1);
  font-size: 13px;
  font-weight: 600;
}

.input-label i {
  color: var(--brand);
  margin-right: 8px;
}

.input-field {
  width: 100%;
  height: 46px;
  border-radius: 12px;
  border: 1px solid #c8d2e1;
  background: #ffffff;
  color: var(--ink-0);
  padding: 0 14px;
  font-size: 15px;
  transition: border-color 120ms ease, box-shadow 120ms ease;
}

.input-field::placeholder {
  color: #98a6ba;
}

.input-field:focus {
  outline: none;
  border-color: #22a28c;
  box-shadow: 0 0 0 4px rgba(34, 162, 140, 0.15);
}

.divider {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 10px;
  align-items: center;
  margin: 16px 0;
}

.divider-line {
  height: 1px;
  background: var(--line);
}

.divider-text {
  color: #70809a;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-weight: 700;
}

.captcha-container {
  background: #f8fafc;
  border: 1px solid #dde5f0;
  border-radius: 12px;
  padding: 14px;
}

.captcha-question {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 23px;
  letter-spacing: 0.05em;
  text-align: center;
  color: #143f56;
  margin-bottom: 10px;
}

.captcha-answer-wrapper {
  margin-bottom: 10px;
}

.turnstile-widget {
  min-height: 65px;
  display: flex;
  justify-content: center;
  align-items: center;
}

.captcha-container.captcha-shake {
  animation: captcha-shake 320ms ease;
}

@keyframes captcha-shake {
  0%,
  100% { transform: translateX(0); }
  20% { transform: translateX(-6px); }
  40% { transform: translateX(6px); }
  60% { transform: translateX(-5px); }
  80% { transform: translateX(5px); }
}

.input-field.text-center {
  text-align: center;
  font-size: 20px;
}

.captcha-refresh-btn {
  width: 100%;
  height: 40px;
  border: 1px solid #c2cfdf;
  border-radius: 10px;
  background: #ffffff;
  color: #33506d;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.captcha-refresh-btn:hover {
  background: #f3f7fc;
}

.attempts-indicator {
  min-height: 20px;
  margin-top: 6px;
  color: #7f6949;
  font-size: 13px;
}

.btn-login {
  width: 100%;
  height: 48px;
  margin-top: 10px;
  border: none;
  border-radius: 12px;
  color: #ffffff;
  background: linear-gradient(140deg, #0f766e 0%, #0f4b61 100%);
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 140ms ease, box-shadow 140ms ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.btn-login:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 8px 20px rgba(15, 118, 110, 0.3);
}

.btn-login:disabled {
  opacity: 0.65;
  cursor: not-allowed;
}

.remember-me-wrapper {
  margin-top: 12px;
}

.checkbox-label {
  display: inline-flex;
  gap: 8px;
  align-items: center;
  font-size: 14px;
  color: var(--ink-1);
}

.checkbox-label input[type='checkbox'] {
  accent-color: var(--brand);
}

#totp-step {
  border: 1px solid #c5d4ea;
  background: #f6f9ff;
  border-radius: 12px;
  padding: 14px;
  margin-top: 8px;
}

.totp-text {
  font-size: 14px;
  color: #38516d;
  margin-bottom: 10px;
}

.totp-row {
  display: flex;
  gap: 8px;
}

.totp-input {
  flex: 1;
  height: 44px;
  border: 1px solid #b3c5df;
  border-radius: 10px;
  text-align: center;
  letter-spacing: 0.25em;
  font-size: 20px;
  font-family: 'IBM Plex Mono', monospace;
}

.totp-input:focus {
  outline: none;
  box-shadow: 0 0 0 4px rgba(29, 78, 216, 0.15);
  border-color: #1d4ed8;
}

.totp-btn {
  height: 44px;
  padding: 0 14px;
  border: none;
  border-radius: 10px;
  background: #1d4ed8;
  color: #ffffff;
  font-weight: 700;
  cursor: pointer;
}

.totp-help {
  margin-top: 8px;
  font-size: 12px;
  color: #64748b;
}

.login-footer {
  border-top: 1px solid var(--line);
  background: #fbfcff;
  padding: 18px 30px;
}

.security-features {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 12px;
}

.security-feature {
  display: flex;
  gap: 8px;
  align-items: center;
  color: #4c5f79;
  font-size: 13px;
}

.security-feature i {
  color: var(--success);
}

.security-status {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px dashed #d3dbe7;
  color: #6a7b93;
  font-size: 12px;
  text-align: center;
}

.login-info {
  margin-top: 14px;
  text-align: center;
  color: #67758a;
  font-size: 12px;
}

.login-info #timestamp {
  margin-top: 4px;
  display: block;
  color: #7f8da1;
}

.panel-loading-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 260ms ease;
  background:
    radial-gradient(900px 420px at 20% 15%, rgba(94, 234, 212, 0.18) 0%, transparent 60%),
    radial-gradient(900px 420px at 90% 95%, rgba(251, 191, 36, 0.14) 0%, transparent 60%),
    rgba(9, 21, 35, 0.84);
  backdrop-filter: blur(8px);
}

.panel-loading-overlay.is-visible {
  opacity: 1;
  pointer-events: all;
}

.panel-loading-card {
  width: min(440px, 100%);
  border-radius: 16px;
  border: 1px solid rgba(195, 213, 236, 0.35);
  background: linear-gradient(180deg, rgba(13, 28, 46, 0.92) 0%, rgba(12, 21, 37, 0.96) 100%);
  color: #e7eef9;
  padding: 24px;
  box-shadow: 0 22px 65px rgba(3, 8, 16, 0.5);
}

.panel-loading-card h3 {
  font-size: 24px;
  line-height: 1.2;
  margin: 8px 0 6px;
}

.panel-loading-card p {
  color: #bed1ec;
  font-size: 14px;
  margin-bottom: 14px;
}

.panel-loading-spinner {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, 0.2);
  border-top-color: #5eead4;
  animation: panel-spin 820ms linear infinite;
}

@keyframes panel-spin {
  to { transform: rotate(360deg); }
}

.panel-loading-progress {
  height: 9px;
  border-radius: 999px;
  overflow: hidden;
  background: rgba(171, 190, 216, 0.25);
}

.panel-loading-progress span {
  display: block;
  height: 100%;
  width: 35%;
  border-radius: inherit;
  background: linear-gradient(90deg, #2dd4bf 0%, #38bdf8 100%);
  animation: panel-progress 1s ease-in-out infinite;
}

@keyframes panel-progress {
  0% { transform: translateX(-120%); }
  100% { transform: translateX(320%); }
}

@media (max-width: 540px) {
  body {
    padding: 16px 12px;
  }

  .login-header,
  .login-content,
  .login-footer {
    padding-left: 18px;
    padding-right: 18px;
  }

  .logo-text {
    font-size: 26px;
  }

  .security-features {
    grid-template-columns: 1fr;
  }

  .totp-row {
    flex-direction: column;
  }

  .panel-loading-card h3 {
    font-size: 21px;
  }
}
