:root {
  --auth-bg: #f4f6f9;
  --auth-card: #ffffff;
  --auth-soft: #f8fafc;
  --auth-soft-2: #f1f5f9;
  --auth-line: #e6eaf0;
  --auth-line-strong: #cbd5e1;
  --auth-text: #0f172a;
  --auth-strong: #334155;
  --auth-muted: #64748b;
  --auth-subtle: #94a3b8;
  --auth-red: #e11d48;
  --auth-red-bright: #f43f5e;
  --auth-red-soft: #fff1f2;
  --auth-red-line: #fecdd3;
  --auth-blue: #2563eb;
  --auth-blue-soft: #eff6ff;
  --auth-green: #10b981;
  --auth-green-soft: #ecfdf5;
  --auth-danger: #be123c;
  --auth-danger-soft: #fff1f2;
  --auth-shadow: 0 34px 80px -38px rgba(15, 23, 42, .38), 0 16px 34px -24px rgba(15, 23, 42, .22);
}

:root[data-theme='dark'] {
  --auth-bg: #0b1017;
  --auth-card: #131a24;
  --auth-soft: #111823;
  --auth-soft-2: #1a2330;
  --auth-line: #243040;
  --auth-line-strong: #33415a;
  --auth-text: #e8eef6;
  --auth-strong: #c3cfdf;
  --auth-muted: #8496ac;
  --auth-subtle: #6b7d94;
  --auth-red: #ff5c7a;
  --auth-red-bright: #ff7a92;
  --auth-red-soft: #2a151c;
  --auth-red-line: #4a2230;
  --auth-blue: #7fa1f5;
  --auth-blue-soft: #152036;
  --auth-green: #34d399;
  --auth-green-soft: #0f2a20;
  --auth-danger: #ff8098;
  --auth-danger-soft: #2a151c;
  --auth-shadow: 0 34px 90px -36px rgba(0, 0, 0, .82), 0 16px 36px -24px rgba(0, 0, 0, .68);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    --auth-bg: #0b1017;
    --auth-card: #131a24;
    --auth-soft: #111823;
    --auth-soft-2: #1a2330;
    --auth-line: #243040;
    --auth-line-strong: #33415a;
    --auth-text: #e8eef6;
    --auth-strong: #c3cfdf;
    --auth-muted: #8496ac;
    --auth-subtle: #6b7d94;
    --auth-red: #ff5c7a;
    --auth-red-bright: #ff7a92;
    --auth-red-soft: #2a151c;
    --auth-red-line: #4a2230;
    --auth-blue: #7fa1f5;
    --auth-blue-soft: #152036;
    --auth-green: #34d399;
    --auth-green-soft: #0f2a20;
    --auth-danger: #ff8098;
    --auth-danger-soft: #2a151c;
    --auth-shadow: 0 34px 90px -36px rgba(0, 0, 0, .82), 0 16px 36px -24px rgba(0, 0, 0, .68);
  }
}

* { box-sizing: border-box; }

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

body.login-page {
  min-height: 100dvh;
  background: var(--auth-bg);
  color: var(--auth-text);
  font-family: "Plus Jakarta Sans", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}

button,
input,
select { font: inherit; }

button,
a,
select { -webkit-tap-highlight-color: transparent; }

button { color: inherit; }

.ico {
  width: 1em;
  height: 1em;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--auth-blue) 58%, transparent);
  outline-offset: 3px;
}

.auth-shell {
  width: 100%;
  min-height: 100dvh;
  display: grid;
  grid-template-columns: minmax(390px, .9fr) minmax(520px, 1.1fr);
}

.auth-showcase {
  position: relative;
  isolation: isolate;
  min-height: 100dvh;
  overflow: hidden;
  padding: clamp(30px, 4.2vw, 68px);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  color: #f8fafc;
  background:
    radial-gradient(circle at 20% 18%, rgba(244, 63, 94, .22), transparent 32%),
    radial-gradient(circle at 82% 76%, rgba(37, 99, 235, .17), transparent 37%),
    linear-gradient(145deg, #111827 0%, #121b2b 58%, #0b1017 100%);
}

.auth-showcase::before,
.auth-showcase::after {
  content: "";
  position: absolute;
  z-index: -1;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, .075);
}

.auth-showcase::before {
  width: min(44vw, 660px);
  aspect-ratio: 1;
  right: -31%;
  top: 17%;
  box-shadow: 0 0 0 58px rgba(255, 255, 255, .018), 0 0 0 120px rgba(255, 255, 255, .012);
}

.auth-showcase::after {
  width: 210px;
  aspect-ratio: 1;
  left: -110px;
  bottom: -72px;
  box-shadow: 0 0 0 44px rgba(244, 63, 94, .025);
}

.auth-brand,
.auth-mobile-brand {
  display: flex;
  align-items: center;
  gap: 13px;
}

.auth-brand-mark {
  width: 46px;
  height: 46px;
  border-radius: 13px;
  display: grid;
  place-items: center;
  color: #fff;
  background: linear-gradient(145deg, var(--auth-red-bright), #d91343);
  box-shadow: 0 15px 34px rgba(225, 29, 72, .28);
}

.auth-brand-mark .ico { width: 26px; height: 26px; }
.auth-brand-copy strong { display: block; font-size: 16px; line-height: 1.2; }
.auth-brand-copy span { display: block; margin-top: 3px; color: #9fb0c6; font-size: 11px; }

.auth-story { max-width: 540px; padding: 52px 0; }
.auth-eyebrow {
  display: block;
  margin-bottom: 14px;
  color: #fda4af;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .13em;
  text-transform: uppercase;
}

.auth-story h1 {
  max-width: 520px;
  margin: 0;
  font-size: clamp(34px, 3.6vw, 54px);
  line-height: 1.08;
  letter-spacing: -.038em;
}

.auth-story > p {
  max-width: 555px;
  margin: 22px 0 0;
  color: #bac7d8;
  font-size: clamp(14px, 1.15vw, 17px);
  line-height: 1.7;
}

.auth-principles {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 36px;
}

.auth-principle {
  min-width: 0;
  padding: 15px;
  border: 1px solid rgba(255, 255, 255, .09);
  border-radius: 13px;
  background: rgba(255, 255, 255, .045);
  backdrop-filter: blur(12px);
}

.auth-principle .ico { width: 18px; height: 18px; color: #fb7185; }
.auth-principle strong { display: block; margin-top: 11px; font-size: 11.5px; }
.auth-principle span { display: block; margin-top: 4px; color: #93a4ba; font-size: 9.5px; line-height: 1.45; }

.auth-showcase-footer { color: #75879d; font-size: 10px; letter-spacing: .04em; }

.auth-entry {
  min-height: 100dvh;
  min-width: 0;
  padding: clamp(22px, 3vw, 46px);
  display: flex;
  flex-direction: column;
  background:
    radial-gradient(circle at 94% 4%, color-mix(in srgb, var(--auth-red-soft) 70%, transparent), transparent 24%),
    var(--auth-bg);
}

.login-toprow {
  min-height: 42px;
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 9px;
}

.login-toprow select,
.login-toprow .theme-toggle,
.pwa-install-btn {
  min-height: 38px;
  padding: 0 12px;
  border: 1px solid var(--auth-line);
  border-radius: 10px;
  background: var(--auth-card);
  color: var(--auth-strong);
  font-size: 11px;
  font-weight: 700;
  box-shadow: 0 1px 2px rgba(15, 23, 42, .025);
}

.login-toprow .theme-toggle { cursor: pointer; }
.login-toprow select { min-width: 116px; cursor: pointer; outline: 0; }
.pwa-install-btn { display: none; cursor: pointer; }
.pwa-install-btn.visible { display: inline-flex; align-items: center; justify-content: center; }

.auth-mobile-brand { display: none; }

.auth-entry-inner {
  width: 100%;
  max-width: 510px;
  min-width: 0;
  margin: auto;
  padding: clamp(24px, 5vh, 52px) 0;
}

.login-container {
  width: 100%;
  min-width: 0;
  padding: clamp(28px, 4vw, 46px);
  border: 1px solid var(--auth-line);
  border-radius: 20px;
  background: var(--auth-card);
  box-shadow: var(--auth-shadow);
}

.login-header { margin-bottom: 30px; }
.login-header .auth-eyebrow { margin-bottom: 10px; color: var(--auth-red); }
.login-header h1 {
  margin: 0;
  color: var(--auth-text);
  font-size: clamp(29px, 3vw, 38px);
  line-height: 1.12;
  letter-spacing: -.035em;
}
.login-header p { margin: 9px 0 0; color: var(--auth-muted); font-size: 13px; line-height: 1.55; }

.error-message {
  display: none;
  margin: 0 0 18px;
  padding: 12px 14px;
  border: 1px solid var(--auth-red-line);
  border-radius: 10px;
  background: var(--auth-danger-soft);
  color: var(--auth-danger);
  font-size: 11.5px;
  font-weight: 650;
  line-height: 1.5;
}
.error-message.show { display: block; }
.error-message.notice { border-color: color-mix(in srgb, var(--auth-blue) 34%, var(--auth-line)); background: var(--auth-blue-soft); color: var(--auth-blue); }

.form-group { margin-bottom: 17px; }
.form-group label {
  display: block;
  margin-bottom: 7px;
  color: var(--auth-strong);
  font-size: 11.5px;
  font-weight: 800;
}

.form-group input,
.form-group select {
  width: 100%;
  max-width: 100%;
  min-height: 48px;
  padding: 0 14px;
  border: 1px solid var(--auth-line-strong);
  border-radius: 10px;
  outline: 0;
  background: var(--auth-soft);
  color: var(--auth-text);
  font-size: 13px;
  transition: border-color .16s ease, box-shadow .16s ease, background .16s ease;
}

.form-group input::placeholder { color: var(--auth-subtle); }
.form-group input:focus,
.form-group select:focus {
  border-color: var(--auth-blue);
  background: var(--auth-card);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--auth-blue) 12%, transparent);
}

.login-options {
  margin: 0 0 21px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  min-width: 0;
}

.remember-option { display: flex; align-items: center; gap: 9px; min-width: 0; }
.remember-option input { width: 17px; height: 17px; margin: 0; accent-color: var(--auth-red); }
.remember-option label { margin: 0; color: var(--auth-muted); font-size: 11px; cursor: pointer; }

.login-link {
  color: var(--auth-blue);
  font-size: 11px;
  font-weight: 750;
  text-decoration: none;
}
.login-link:hover { text-decoration: underline; }

.btn-login,
.btn-o365,
.btn-secondary {
  min-height: 48px;
  border-radius: 10px;
  border: 1px solid transparent;
  padding: 0 17px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 800;
  transition: transform .16s ease, box-shadow .16s ease, background .16s ease, border-color .16s ease;
}

.btn-login {
  width: 100%;
  background: linear-gradient(135deg, var(--auth-red-bright), var(--auth-red));
  color: #fff;
  box-shadow: 0 12px 24px -15px rgba(225, 29, 72, .75);
}
.btn-login:hover:not(:disabled) { transform: translateY(-1px); box-shadow: 0 17px 28px -16px rgba(225, 29, 72, .8); }
.btn-login:active:not(:disabled) { transform: translateY(0); }
.btn-login:disabled { opacity: .58; cursor: not-allowed; }

.divider {
  margin: 23px 0 15px;
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--auth-subtle);
  font-size: 9.5px;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
}
.divider::before,
.divider::after { content: ""; flex: 1; height: 1px; background: var(--auth-line); }

.btn-o365 {
  display: none;
  width: 100%;
  background: var(--auth-text);
  color: var(--auth-card);
}
.btn-o365:hover { transform: translateY(-1px); box-shadow: 0 13px 25px -17px rgba(15, 23, 42, .78); }

.sms-entry { margin-top: 11px; text-align: center; }
.sms-entry .login-link {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 12px;
  color: var(--auth-strong);
}
.sms-entry .ico { color: var(--auth-red); }

.login-security-note {
  margin-top: 21px;
  padding-top: 18px;
  border-top: 1px solid var(--auth-line);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: var(--auth-muted);
  font-size: 9.7px;
  line-height: 1.45;
  text-align: center;
}
.login-security-note .ico { width: 14px; height: 14px; color: var(--auth-green); }

.loading {
  display: inline-block;
  width: 14px;
  height: 14px;
  margin-right: 8px;
  vertical-align: -2px;
  border: 2px solid rgba(255, 255, 255, .35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: auth-spin .65s linear infinite;
}
@keyframes auth-spin { to { transform: rotate(360deg); } }

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(8, 15, 27, .62);
  backdrop-filter: blur(8px);
}

.login-page .modal {
  width: min(100%, 470px);
  max-height: min(88dvh, 760px);
  overflow-y: auto;
  padding: clamp(23px, 4vw, 32px);
  border: 1px solid var(--auth-line);
  border-radius: 18px;
  background: var(--auth-card);
  color: var(--auth-text);
  box-shadow: var(--auth-shadow);
}

.login-page .modal h3 { margin: 0; color: var(--auth-text); font-size: 21px; letter-spacing: -.025em; }
.modal-heading { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 18px; }
.modal-heading-icon {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  flex: none;
  border-radius: 10px;
  background: var(--auth-red-soft);
  color: var(--auth-red);
}
.modal-heading-icon .ico { width: 18px; height: 18px; }
.modal-heading p { margin: 5px 0 0; color: var(--auth-muted); font-size: 11px; line-height: 1.55; }
.muted { color: var(--auth-muted); font-size: 11px; line-height: 1.55; }
#smsError:not(:empty) { margin: 0 0 14px; padding: 10px 12px; border-radius: 9px; background: var(--auth-danger-soft); color: var(--auth-danger); font-size: 11px; }

.modal .modal-actions { display: flex; justify-content: flex-end; gap: 9px; margin-top: 20px; }
.btn-secondary { border-color: var(--auth-line); background: var(--auth-soft); color: var(--auth-strong); }
.btn-secondary:hover { border-color: var(--auth-line-strong); background: var(--auth-soft-2); }
.modal .btn-login { width: auto; min-width: 128px; }
.otp-input { text-align: center; letter-spacing: .28em; font-size: 19px !important; font-weight: 800; }
.reset-status { margin: 2px 0 16px; padding: 11px 12px; border-radius: 9px; background: var(--auth-soft); }
.reset-action-group { display: flex; gap: 8px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

@media (max-width: 1040px) {
  .auth-shell { grid-template-columns: minmax(330px, .72fr) minmax(500px, 1.28fr); }
  .auth-showcase { padding: 34px; }
  .auth-principles { grid-template-columns: 1fr; max-width: 330px; }
  .auth-principle { display: grid; grid-template-columns: 22px 1fr; column-gap: 9px; }
  .auth-principle strong { margin-top: 0; }
  .auth-principle span { grid-column: 2; }
}

@media (max-width: 820px) {
  .auth-shell { display: block; }
  .auth-showcase { display: none; }
  .auth-entry { min-height: 100dvh; padding: 20px; }
  .auth-mobile-brand { display: flex; margin-right: auto; order: -2; }
  .auth-mobile-brand .auth-brand-mark { width: 38px; height: 38px; border-radius: 10px; }
  .auth-mobile-brand .auth-brand-mark .ico { width: 21px; height: 21px; }
  .auth-mobile-brand .auth-brand-copy strong { font-size: 13px; }
  .auth-mobile-brand .auth-brand-copy span { color: var(--auth-muted); font-size: 9px; }
  .login-toprow { justify-content: flex-end; flex-wrap: wrap; }
  .auth-entry-inner { width: 100%; max-width: 540px; }
}

@media (max-width: 560px) {
  html,
  body.login-page,
  .auth-shell,
  .auth-entry { width: 100%; max-width: 100vw; min-width: 0; overflow-x: hidden; }
  .auth-entry { padding: 14px; }
  .login-toprow { width: 100%; max-width: 100%; min-width: 0; align-items: stretch; gap: 7px; }
  .auth-mobile-brand { width: 100%; margin-bottom: 7px; }
  .login-toprow select,
  .login-toprow .theme-toggle,
  .pwa-install-btn { min-width: 0; min-height: 36px; flex: 1 1 100px; }
  .auth-entry-inner { padding: 18px 0 12px; }
  .login-container { width: 100%; max-width: 100%; min-width: 0; padding: 26px 21px; border-radius: 16px; }
  .login-header { margin-bottom: 24px; }
  .login-header h1 { font-size: 29px; }
  .login-options { align-items: flex-start; flex-wrap: wrap; }
  .remember-option label,
  .login-link { font-size: 10px; }
  .remember-option label { line-height: 1.35; }
  .login-options > .login-link { flex: none; white-space: nowrap; }
  .login-security-note span { min-width: 0; overflow-wrap: anywhere; }
  .modal-overlay { padding: 10px; align-items: flex-end; }
  .login-page .modal { width: 100%; max-height: 92dvh; padding: 24px 20px; border-radius: 18px 18px 12px 12px; }
  .modal .modal-actions { align-items: stretch; flex-direction: column-reverse; }
  .modal .btn-login,
  .modal .btn-secondary { width: 100% !important; }
  .reset-action-group { flex-direction: column; width: 100%; }
}

@media (max-height: 730px) and (min-width: 821px) {
  .auth-story { padding: 22px 0; }
  .auth-principles { margin-top: 22px; }
  .auth-entry-inner { padding: 18px 0; }
  .login-container { padding-top: 28px; padding-bottom: 28px; }
  .login-header { margin-bottom: 20px; }
  .form-group { margin-bottom: 13px; }
  .form-group input { min-height: 44px; }
}
