:root,
html[data-theme="light"] {
  --rt-auth-bg: #f5fbff;
  --rt-auth-surface: #ffffff;
  --rt-auth-surface-soft: #eef8ff;
  --rt-auth-border: #cfe5f4;
  --rt-auth-text: #14304f;
  --rt-auth-muted: #607991;
  --rt-auth-heading: #073f7a;
  --rt-auth-primary: #078fd0;
  --rt-auth-primary-strong: #073f7a;
  --rt-auth-primary-soft: #e5f6ff;
  --rt-auth-accent: #00a6df;
  --rt-auth-accent-soft: #e3f8ff;
  --rt-auth-warm: #f4b33b;
  --rt-auth-danger: #d34242;
  --rt-auth-danger-soft: #fff0f0;
  --rt-auth-shadow: 0 24px 70px rgba(7, 63, 122, 0.15);
}

html[data-theme="dark"] {
  --rt-auth-bg: #061427;
  --rt-auth-surface: #0f243d;
  --rt-auth-surface-soft: #14314f;
  --rt-auth-border: #244d72;
  --rt-auth-text: #e8f0f7;
  --rt-auth-muted: #adc5d8;
  --rt-auth-heading: #f4f9ff;
  --rt-auth-primary: #28aee8;
  --rt-auth-primary-strong: #89ddff;
  --rt-auth-primary-soft: #0c3352;
  --rt-auth-accent: #5dcfff;
  --rt-auth-accent-soft: #0d3650;
  --rt-auth-warm: #f4c65a;
  --rt-auth-danger: #ff7777;
  --rt-auth-danger-soft: #3f1d24;
  --rt-auth-shadow: 0 28px 80px rgba(0, 0, 0, 0.44);
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body.rt-auth-page {
  background:
    linear-gradient(135deg, color-mix(in srgb, var(--rt-auth-primary-soft), transparent 20%), transparent 34%),
    linear-gradient(180deg, transparent, color-mix(in srgb, var(--rt-auth-accent-soft), transparent 24%)),
    var(--rt-auth-bg);
  color: var(--rt-auth-text);
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  margin: 0;
  min-height: 100vh;
  min-height: 100svh;
  overflow-x: hidden;
  text-rendering: geometricPrecision;
}

body.rt-auth-page::before {
  background-image:
    linear-gradient(color-mix(in srgb, var(--rt-auth-primary), transparent 91%) 1px, transparent 1px),
    linear-gradient(90deg, color-mix(in srgb, var(--rt-auth-primary), transparent 91%) 1px, transparent 1px);
  background-size: 42px 42px;
  content: "";
  inset: 0;
  opacity: 0.55;
  pointer-events: none;
  position: fixed;
}

body.rt-auth-page a {
  color: inherit;
  text-decoration: none;
}

body.rt-auth-page img {
  max-width: 100%;
}

.rt-login-screen {
  align-items: center;
  display: grid;
  justify-items: center;
  min-height: 100vh;
  min-height: 100svh;
  padding: 92px 18px 28px;
  position: relative;
  width: 100%;
}

.rt-auth-topbar {
  align-items: center;
  display: flex;
  justify-content: space-between;
  left: 22px;
  position: fixed;
  right: 22px;
  top: 18px;
  z-index: 5;
}

.rt-auth-logo {
  align-items: center;
  background: #ffffff;
  border: 1px solid color-mix(in srgb, var(--rt-auth-border), transparent 12%);
  border-radius: 8px;
  box-shadow: 0 10px 28px rgba(10, 40, 75, 0.08);
  display: inline-flex;
  padding: 7px 11px;
}

.rt-auth-logo img {
  display: block;
  height: 42px;
  object-fit: contain;
  width: auto;
}

.rt-auth-actions {
  align-items: center;
  display: flex;
  gap: 10px;
}

.rt-auth-home-link,
.rt-auth-theme-toggle {
  align-items: center;
  background: color-mix(in srgb, var(--rt-auth-surface), transparent 3%);
  border: 1px solid var(--rt-auth-border);
  border-radius: 8px;
  box-shadow: 0 10px 24px color-mix(in srgb, var(--rt-auth-text), transparent 92%);
  color: var(--rt-auth-heading);
  display: inline-flex;
  font-weight: 800;
  gap: 8px;
  justify-content: center;
  min-height: 42px;
  transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease, transform 0.2s ease;
}

.rt-auth-home-link {
  padding: 0 14px;
}

.rt-auth-theme-toggle {
  padding: 0;
  width: 42px;
}

.rt-auth-home-link:hover,
.rt-auth-theme-toggle:hover {
  background: var(--rt-auth-primary-soft);
  border-color: color-mix(in srgb, var(--rt-auth-primary), transparent 45%);
  color: var(--rt-auth-primary-strong);
  transform: translateY(-2px);
}

.rt-theme-sun {
  display: none;
}

html[data-theme="dark"] .rt-theme-sun {
  display: inline-flex;
}

html[data-theme="dark"] .rt-theme-moon {
  display: none;
}

.rt-auth-card {
  background: color-mix(in srgb, var(--rt-auth-surface), transparent 2%);
  border: 1px solid var(--rt-auth-border);
  border-radius: 8px;
  box-shadow: var(--rt-auth-shadow);
  max-width: 460px;
  padding: 30px;
  position: relative;
  width: min(100%, 460px);
  z-index: 1;
}

.rt-auth-card::before {
  background: linear-gradient(90deg, var(--rt-auth-primary), var(--rt-auth-accent), var(--rt-auth-warm));
  border-radius: 8px 8px 0 0;
  content: "";
  height: 4px;
  left: -1px;
  position: absolute;
  right: -1px;
  top: -1px;
}

.rt-auth-card-header {
  margin-bottom: 22px;
  text-align: center;
}

.rt-auth-mark {
  align-items: center;
  background: var(--rt-auth-primary-soft);
  border: 1px solid color-mix(in srgb, var(--rt-auth-primary), transparent 58%);
  border-radius: 8px;
  color: var(--rt-auth-primary-strong);
  display: inline-flex;
  font-size: 1.2rem;
  height: 46px;
  justify-content: center;
  margin-bottom: 14px;
  width: 46px;
}

.rt-auth-card h1 {
  color: var(--rt-auth-heading);
  font-family: "Nunito", "Inter", system-ui, sans-serif;
  font-size: 2rem;
  font-weight: 900;
  letter-spacing: 0;
  line-height: 1.12;
  margin: 0;
}

.rt-auth-card-header p {
  color: var(--rt-auth-muted);
  font-size: 0.98rem;
  line-height: 1.55;
  margin: 9px 0 0;
}

.rt-auth-copy {
  color: var(--rt-auth-muted);
  font-size: 0.96rem;
  line-height: 1.65;
  margin: 0;
  text-align: center;
}

.rt-auth-copy strong {
  color: var(--rt-auth-heading);
}

.rt-auth-messages {
  display: grid;
  gap: 10px;
  margin-bottom: 16px;
}

.rt-auth-alert {
  align-items: flex-start;
  background: var(--rt-auth-primary-soft);
  border: 1px solid color-mix(in srgb, var(--rt-auth-primary), transparent 62%);
  border-radius: 8px;
  color: var(--rt-auth-heading);
  display: flex;
  font-size: 0.92rem;
  gap: 10px;
  line-height: 1.45;
  padding: 12px 14px;
}

.rt-auth-alert i {
  color: var(--rt-auth-primary);
  flex: 0 0 auto;
  margin-top: 2px;
}

.rt-auth-alert-success {
  background: var(--rt-auth-accent-soft);
  border-color: color-mix(in srgb, var(--rt-auth-accent), transparent 58%);
}

.rt-auth-alert-success i {
  color: var(--rt-auth-accent);
}

.rt-auth-alert-error,
.rt-auth-alert-danger {
  background: var(--rt-auth-danger-soft);
  border-color: color-mix(in srgb, var(--rt-auth-danger), transparent 52%);
}

.rt-auth-alert-error i,
.rt-auth-alert-danger i {
  color: var(--rt-auth-danger);
}

.rt-auth-alert-warning {
  background: color-mix(in srgb, var(--rt-auth-warm), transparent 86%);
  border-color: color-mix(in srgb, var(--rt-auth-warm), transparent 52%);
}

.rt-auth-alert-warning i {
  color: var(--rt-auth-warm);
}

.rt-auth-form {
  display: grid;
  gap: 16px;
}

.rt-auth-mode {
  background: var(--rt-auth-surface-soft);
  border: 1px solid var(--rt-auth-border);
  border-radius: 8px;
  display: grid;
  gap: 6px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  padding: 6px;
}

.rt-auth-mode button {
  align-items: center;
  background: transparent;
  border: 0;
  border-radius: 6px;
  color: var(--rt-auth-muted);
  display: inline-flex;
  font: inherit;
  font-size: 0.91rem;
  font-weight: 800;
  gap: 8px;
  justify-content: center;
  min-height: 40px;
  padding: 0 10px;
  transition: background 0.2s ease, color 0.2s ease, box-shadow 0.2s ease;
  white-space: nowrap;
}

.rt-auth-mode button.is-active {
  background: var(--rt-auth-surface);
  box-shadow: 0 10px 22px color-mix(in srgb, var(--rt-auth-text), transparent 91%);
  color: var(--rt-auth-heading);
}

.rt-field {
  display: grid;
  gap: 8px;
}

.rt-field label {
  color: var(--rt-auth-heading);
  font-size: 0.9rem;
  font-weight: 800;
  margin: 0;
}

.rt-field-shell {
  align-items: center;
  background: var(--rt-auth-surface);
  border: 1px solid var(--rt-auth-border);
  border-radius: 8px;
  display: flex;
  gap: 10px;
  min-height: 50px;
  padding: 0 13px;
  transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
  width: 100%;
}

.rt-field-shell:focus-within {
  border-color: color-mix(in srgb, var(--rt-auth-primary), transparent 20%);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--rt-auth-primary), transparent 85%);
}

.rt-field-shell > i {
  color: var(--rt-auth-primary);
  flex: 0 0 auto;
  font-size: 1rem;
}

.rt-input {
  background: transparent;
  border: 0;
  color: var(--rt-auth-text);
  flex: 1 1 auto;
  font: inherit;
  font-size: 0.98rem;
  min-height: 48px;
  min-width: 0;
  outline: 0;
  width: 100%;
}

.rt-input::placeholder {
  color: color-mix(in srgb, var(--rt-auth-muted), transparent 22%);
}

.rt-field-action {
  align-items: center;
  background: transparent;
  border: 0;
  border-radius: 6px;
  color: var(--rt-auth-muted);
  display: inline-flex;
  flex: 0 0 auto;
  height: 34px;
  justify-content: center;
  padding: 0;
  transition: background 0.2s ease, color 0.2s ease;
  width: 34px;
}

.rt-field-action:hover {
  background: var(--rt-auth-primary-soft);
  color: var(--rt-auth-primary-strong);
}

.rt-otp-row {
  align-items: stretch;
  display: grid;
  gap: 10px;
  grid-template-columns: minmax(0, 1fr) 106px;
}

.rt-otp-button {
  align-items: center;
  background: var(--rt-auth-accent);
  border: 1px solid color-mix(in srgb, var(--rt-auth-accent), #000 10%);
  border-radius: 8px;
  color: #ffffff;
  display: inline-flex;
  font: inherit;
  font-size: 0.95rem;
  font-weight: 900;
  gap: 8px;
  justify-content: center;
  min-height: 50px;
  padding: 0 12px;
  transition: background 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
  white-space: nowrap;
}

.rt-otp-button:hover {
  background: color-mix(in srgb, var(--rt-auth-accent), #05251d 10%);
  box-shadow: 0 14px 24px color-mix(in srgb, var(--rt-auth-accent), transparent 72%);
  transform: translateY(-2px);
}

.rt-otp-button:disabled {
  cursor: wait;
  opacity: 0.72;
  transform: none;
}

.rt-inline-message {
  color: var(--rt-auth-muted);
  font-size: 0.86rem;
  min-height: 18px;
}

.rt-inline-message.is-success {
  color: var(--rt-auth-accent);
}

.rt-inline-message.is-error {
  color: var(--rt-auth-danger);
}

.rt-auth-field-error,
.rt-auth-form .errorlist {
  color: var(--rt-auth-danger);
  font-size: 0.84rem;
  line-height: 1.45;
  list-style: none;
  margin: 0;
  padding: 0;
}

.rt-auth-help {
  color: var(--rt-auth-muted);
  font-size: 0.82rem;
  line-height: 1.5;
}

.rt-auth-help ul {
  margin: 8px 0 0;
  padding-left: 18px;
}

.rt-auth-form-meta {
  align-items: center;
  color: var(--rt-auth-muted);
  display: flex;
  font-size: 0.86rem;
  gap: 12px;
  justify-content: space-between;
}

.rt-auth-form-meta a {
  color: var(--rt-auth-primary-strong);
  font-weight: 900;
  white-space: nowrap;
}

.rt-auth-form-meta a:hover {
  color: var(--rt-auth-primary);
}

.rt-auth-submit {
  align-items: center;
  background: linear-gradient(135deg, var(--rt-auth-primary-strong), var(--rt-auth-primary));
  border: 0;
  border-radius: 8px;
  box-shadow: 0 18px 30px color-mix(in srgb, var(--rt-auth-primary), transparent 68%);
  color: #ffffff;
  display: inline-flex;
  font: inherit;
  font-size: 1rem;
  font-weight: 900;
  gap: 10px;
  justify-content: center;
  min-height: 52px;
  padding: 0 18px;
  transition: box-shadow 0.2s ease, transform 0.2s ease;
  width: 100%;
}

.rt-auth-submit:hover {
  box-shadow: 0 20px 34px color-mix(in srgb, var(--rt-auth-primary), transparent 58%);
  transform: translateY(-2px);
}

.rt-auth-link-button {
  align-items: center;
  background: var(--rt-auth-primary-soft);
  border: 1px solid color-mix(in srgb, var(--rt-auth-primary), transparent 55%);
  border-radius: 8px;
  color: var(--rt-auth-primary-strong);
  display: inline-flex;
  font-weight: 900;
  gap: 9px;
  justify-content: center;
  min-height: 50px;
  padding: 0 18px;
  transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease, transform 0.2s ease;
  width: 100%;
}

.rt-auth-link-button:hover {
  background: color-mix(in srgb, var(--rt-auth-primary-soft), var(--rt-auth-surface) 28%);
  border-color: color-mix(in srgb, var(--rt-auth-primary), transparent 25%);
  color: var(--rt-auth-primary-strong);
  transform: translateY(-2px);
}

.rt-auth-action-stack {
  display: grid;
  gap: 10px;
}

.rt-auth-form[data-mode="password"] [data-otp-group],
.rt-auth-form[data-mode="otp"] [data-password-group] {
  display: none;
}

.rt-auth-form[data-mode="otp"] [data-mode-note] {
  color: var(--rt-auth-accent);
}

html[data-theme="dark"] .rt-auth-logo {
  background: #ffffff;
  border-color: rgba(255, 255, 255, 0.22);
}

@media (max-height: 760px) and (min-width: 720px) {
  .rt-login-screen {
    align-items: start;
    padding-top: 84px;
  }

  .rt-auth-card {
    padding: 24px;
  }

  .rt-auth-card h1 {
    font-size: 1.72rem;
  }

  .rt-auth-card-header {
    margin-bottom: 16px;
  }

  .rt-auth-form {
    gap: 12px;
  }
}

@media (max-height: 650px) {
  .rt-login-screen {
    align-items: start;
    padding-top: 74px;
  }

  .rt-auth-topbar {
    top: 10px;
  }

  .rt-auth-logo img {
    height: 34px;
  }

  .rt-auth-card {
    padding: 18px;
  }

  .rt-auth-card-header {
    margin-bottom: 12px;
  }

  .rt-auth-card-header p,
  .rt-auth-mark {
    display: none;
  }

  .rt-auth-form {
    gap: 10px;
  }

  .rt-field-shell,
  .rt-otp-button {
    min-height: 46px;
  }

  .rt-input {
    min-height: 44px;
  }

  .rt-auth-submit {
    min-height: 48px;
  }
}

@media (max-width: 640px) {
  .rt-login-screen {
    align-items: start;
    padding: 82px 12px 18px;
  }

  .rt-auth-topbar {
    left: 12px;
    right: 12px;
    top: 12px;
  }

  .rt-auth-logo {
    padding: 6px 8px;
  }

  .rt-auth-logo img {
    height: 36px;
  }

  .rt-auth-home-link span {
    display: none;
  }

  .rt-auth-home-link,
  .rt-auth-theme-toggle {
    min-height: 40px;
    width: 40px;
  }

  .rt-auth-home-link {
    padding: 0;
  }

  .rt-auth-card {
    padding: 22px 16px;
    width: 100%;
  }

  .rt-auth-card h1 {
    font-size: 1.56rem;
  }

  .rt-auth-mark {
    height: 42px;
    margin-bottom: 12px;
    width: 42px;
  }

  .rt-auth-mode button {
    font-size: 0.86rem;
    min-height: 38px;
    padding: 0 8px;
  }

  .rt-auth-form-meta {
    align-items: flex-start;
    flex-direction: column;
    gap: 8px;
  }
}

@media (max-width: 420px) {
  .rt-login-screen {
    padding-left: 10px;
    padding-right: 10px;
  }

  .rt-auth-card {
    padding: 20px 14px;
  }

  .rt-otp-row {
    grid-template-columns: 1fr;
  }

  .rt-otp-button {
    width: 100%;
  }
}

@media (max-width: 350px) {
  .rt-auth-mode {
    grid-template-columns: 1fr;
  }

  .rt-auth-mode button {
    justify-content: flex-start;
  }
}
