:root {
  --blue: #50A2FF; /* deliberate: public pages run the lighter primary (styles.css uses #3b82f6) */
  /* --blue-dark removed: unused, and it held the navy while styles.css's
     --blue-dark is a darker blue — same-name-different-concept hazard. */
  --blue-mid: #1d4ed8;
  --navy: #020C45;
  /* Same value as styles.css:--ink. Duplicated because these pages do NOT load styles.css:
     a custom property is inherited through the DOM, not shared between stylesheets, so a
     var(--ink) here would be invalid-at-computed-value-time and silently fall back to
     `inherit`. Keep in step with styles.css. */
  --ink: #020C45;
  --bg: #f0f5ff;
  --white: #ffffff;
  --gray-light: #e4ecf9;
  --gray-mid: #c0cfe8;
  --text: #020C45;
  --text-muted: #5a6a8a;
  --radius: 10px;
  --shadow: 0 4px 20px rgba(2,12,69,0.09);
  --error: #ef4444;
  --error-bg: #fef2f2;
  --success: #008000;
  --success-bg: #e6faf3;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: 'DM Sans', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ── NAV ── */
nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 40px;
  background: var(--white);
  border-bottom: 1px solid var(--gray-light);
  box-shadow: 0 2px 12px rgba(2,12,69,0.07);
  position: sticky; /* parity with the sign-up page nav */
  top: 0;
  z-index: 100;
}
.logo {
  font-family: 'Sora', sans-serif;
  font-weight: 700;
  font-size: 1.25rem;
  color: var(--ink);
  display: flex;
  align-items: center;
  gap: 6px;
  text-decoration: none;
}
.logo .check { color: var(--blue); }
.nav-links { display: flex; gap: 28px; list-style: none; }
.nav-links a {
  text-decoration: none;
  color: var(--text-muted);
  font-size: 0.9rem;
  font-weight: 500;
  transition: color 0.2s;
}
.nav-links a:hover { color: var(--ink); }

/* ── MAIN ── */
main {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 48px 24px;
}

.auth-shell {
  display: grid;
  grid-template-columns: 1fr 1fr;
  max-width: 900px;
  width: 100%;
  background: var(--white);
  border-radius: 16px;
  box-shadow: 0 16px 60px rgba(2,12,69,0.12);
  overflow: hidden;
  border: 1.5px solid var(--gray-light);
}

/* ── LEFT PANEL ── */
.auth-panel-left {
  background: var(--navy);
  padding: 52px 44px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  position: relative;
  overflow: hidden;
}

.auth-panel-left::before {
  content: '';
  position: absolute;
  top: -80px; right: -80px;
  width: 260px; height: 260px;
  border-radius: 50%;
  background: rgba(80,162,255,0.12);
}
.auth-panel-left::after {
  content: '';
  position: absolute;
  bottom: -60px; left: -60px;
  width: 200px; height: 200px;
  border-radius: 50%;
  background: rgba(80,162,255,0.07);
}

.panel-logo {
  font-family: 'Sora', sans-serif;
  font-weight: 700;
  font-size: 1.25rem;
  color: #ffffff;
  display: flex;
  align-items: center;
  gap: 6px;
  text-decoration: none;
  position: relative;
  z-index: 1;
}
.panel-logo .check { color: var(--blue); }

.panel-content {
  position: relative;
  z-index: 1;
}

.panel-headline {
  font-family: 'Sora', sans-serif;
  font-size: 1.65rem;
  font-weight: 700;
  color: #ffffff;
  line-height: 1.3;
  margin-bottom: 16px;
}
.panel-headline span { color: var(--blue); }

.panel-sub {
  font-size: 0.92rem;
  color: rgba(255,255,255,0.6);
  line-height: 1.6;
  margin-bottom: 32px;
}

.panel-stats {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.stat-item {
  display: flex;
  align-items: center;
  gap: 12px;
}
.stat-icon {
  width: 36px; height: 36px;
  border-radius: 8px;
  background: rgba(80,162,255,0.15);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.stat-icon svg { color: var(--blue); }
.stat-text { font-size: 0.85rem; color: rgba(255,255,255,0.7); }
.stat-text strong { color: #ffffff; display: block; font-size: 0.9rem; }

/* ── RIGHT PANEL ── */
.auth-panel-right {
  padding: 52px 48px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.form-eyebrow {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--blue);
  margin-bottom: 8px;
}

.form-title {
  font-family: 'Sora', sans-serif;
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--ink);
  margin-bottom: 6px;
}

.form-subtitle {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-bottom: 32px;
}
.form-subtitle a {
  color: var(--blue);
  text-decoration: none;
  font-weight: 600;
}
.form-subtitle a:hover { text-decoration: underline; }

.form-support {
  font-size: 0.8rem;
  color: var(--text-muted);
  text-align: center;
  margin-top: 20px;
}
.form-support a {
  color: var(--blue);
  text-decoration: none;
  font-weight: 600;
}
.form-support a:hover { text-decoration: underline; }

/* ── FORM ── */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 18px;
}

.form-group label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--ink);
}

.input-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.input-wrap svg.input-icon {
  position: absolute;
  left: 14px;
  color: var(--text-muted);
  pointer-events: none;
  transition: color 0.2s;
}

.input-wrap input {
  width: 100%;
  border: 1.5px solid var(--gray-mid);
  border-radius: 8px;
  padding: 11px 14px 11px 40px;
  font-family: 'DM Sans', sans-serif;
  font-size: 0.93rem;
  color: var(--text);
  background: var(--white);
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.input-wrap input:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(80,162,255,0.15);
}

.input-wrap input:focus + svg.input-icon,
.input-wrap:focus-within svg.input-icon {
  color: var(--blue);
}

/* Fix icon order - icon before input in DOM but visually positioned absolute */
.input-wrap input::placeholder { color: var(--text-muted); opacity: 0.7; }

/* Password toggle */
.pw-toggle {
  position: absolute;
  right: 12px;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  padding: 4px;
  transition: color 0.2s;
  z-index: 1;
}
.pw-toggle:hover { color: var(--ink); }

.input-wrap input[type="password"],
.input-wrap input[data-type="password"] {
  padding-right: 44px;
}

/* Error state */
.input-wrap.error input {
  border-color: var(--error);
  box-shadow: 0 0 0 3px rgba(239,68,68,0.1);
}
.field-error {
  font-size: 0.78rem;
  color: var(--error);
  display: none;
  align-items: center;
  gap: 4px;
}
.field-error.visible { display: flex; }

/* Remember + forgot row */
.form-row-between {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
}
.remember-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  color: var(--text-muted);
  cursor: pointer;
}
.remember-label input[type="checkbox"] {
  width: 15px; height: 15px;
  accent-color: var(--blue);
  cursor: pointer;
}
.forgot-link {
  font-size: 0.85rem;
  color: var(--blue);
  text-decoration: none;
  font-weight: 500;
}
.forgot-link:hover { text-decoration: underline; }

/* Two-factor step: the remember-device label is much longer than "Remember me",
   so this row breathes — the link wraps onto its own line when space runs out
   instead of both fragments breaking mid-phrase, and the checkbox stays pinned
   to the label's first line rather than floating between wrapped lines. */
.mfa-options-row {
  flex-wrap: wrap;
  row-gap: 12px;
  margin-top: 6px;
}
.mfa-options-row .remember-label {
  align-items: flex-start;
  line-height: 1.4;
}
.mfa-options-row .remember-label input[type="checkbox"] {
  flex: none;
  margin-top: 2px;
}
.mfa-options-row .forgot-link { white-space: nowrap; }

/* Submit button */
.btn-submit {
  width: 100%;
  padding: 13px;
  background: var(--navy);
  color: #ffffff;
  border: none;
  border-radius: 8px;
  font-family: 'DM Sans', sans-serif;
  font-size: 0.97rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.2s, transform 0.15s, box-shadow 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  position: relative;
  overflow: hidden;
}
.btn-submit:hover:not(:disabled) {
  background: #0a1a5c;
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(2,12,69,0.25);
}
.btn-submit:disabled {
  opacity: 0.7;
  cursor: not-allowed;
  transform: none;
}

/* Spinner */
.spinner {
  width: 18px; height: 18px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  display: none;
}
.btn-submit.loading .spinner { display: block; }
.btn-submit.loading .btn-label { display: none; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Global alert */
.form-alert {
  border-radius: 8px;
  padding: 12px 14px;
  font-size: 0.88rem;
  display: none;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 18px;
  line-height: 1.4;
}
.form-alert.visible { display: flex; }
.form-alert.error { background: var(--error-bg); color: #991b1b; border: 1px solid rgba(239,68,68,0.25); }
.form-alert.success { background: var(--success-bg); color: #065f46; border: 1px solid rgba(0,194,122,0.3); }
.form-alert svg { flex-shrink: 0; margin-top: 1px; }

/* Divider */
.divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 20px 0;
  color: var(--gray-mid);
  font-size: 0.8rem;
}
.divider::before, .divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--gray-light);
}

/* Social / alternate sign in - UI only, backend TBD */
.btn-alt-signin {
  width: 100%;
  padding: 11px;
  background: var(--white);
  color: var(--text);
  border: 1.5px solid var(--gray-mid);
  border-radius: 8px;
  font-family: 'DM Sans', sans-serif;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: border-color 0.2s, box-shadow 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}
.btn-alt-signin:hover {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(80,162,255,0.1);
}

/* ── FOOTER ── */
footer {
  background: var(--navy);
  color: rgba(255,255,255,0.6);
  text-align: center;
  padding: 22px;
  font-size: 0.85rem;
}
footer a { color: var(--blue); text-decoration: none; }

/* ── RESPONSIVE ── */
@media (max-width: 700px) {
  nav { padding: 14px 20px; }
  .auth-shell { grid-template-columns: 1fr; }
  .auth-panel-left { display: none; }
  .auth-panel-right { padding: 36px 28px; }
}
/* ---------- Dark mode — toggled by JS/theme.js ---------- */
body.dark {
  --bg: #0b1226;
  --white: #111a38;           /* surface flips; always-white text is literal #ffffff */
  --gray-bg: #0e1832;
  --gray-light: #26325c;
  --gray-mid: #34426e;
  --border: #26325c;
  --text: #dbe4f8;
  --ink: #e8eefc;
  --text-muted: #93a3c8;
  --blue-pale: rgba(59,130,246,0.16);
  --shadow: 0 4px 24px rgba(0,0,0,0.4);
  /* --navy is NOT flipped: it is the bg of heroes/footers/panels (already dark) */
  background: #0b1226;
  color: #dbe4f8;
}
body.dark h1, body.dark h2, body.dark h3, body.dark h4, body.dark h5 { color: #e8eefc; }
/* ── QA dark-mode accessibility fixes (login is self-contained → repaint nav + field labels) ── */
body.dark { color-scheme: dark; }
body.dark nav { background: #111a38; border-bottom-color: #26325c; }
body.dark nav .logo { color: #ffffff; }
body.dark .nav-links a { color: var(--text, #dbe4f8); }
body.dark .nav-links a:hover, body.dark .nav-links a.active { color: #50A2FF; }
body.dark .form-group label { color: #dbe4f8; }
body.dark .pw-toggle:hover { color: #e8eefc; }
