/* Sign-in page (accounts/login.html), account-setup page (mailer/account_setup.html) and the
   signed-in toolbar of portal_base.html. Builds on the tokens in design-system.css.
   .auth-body--ops recolours the sign-in page for the operations portal. */

.auth-body {
  min-height: 100vh;
  margin: 0;
  padding: 28px;
  display: grid;
  place-items: center;
  background:
    radial-gradient(circle at 8% 8%, rgba(80, 70, 229, 0.12), transparent 34%),
    radial-gradient(circle at 92% 88%, rgba(109, 40, 217, 0.08), transparent 34%),
    var(--bg);
}

.auth-shell {
  width: min(1120px, 100%);
  min-height: min(720px, calc(100vh - 56px));
  display: grid;
  grid-template-columns: minmax(0, 1.08fr) minmax(400px, 0.92fr);
  overflow: hidden;
  border: 1px solid rgba(11, 15, 26, 0.08);
  border-radius: 30px;
  background: var(--surface);
  box-shadow: var(--shadow-lg);
}

.auth-story {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  padding: clamp(40px, 6vw, 72px);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 48px;
  color: #fff;
  background:
    radial-gradient(circle at 78% 14%, rgba(255, 255, 255, 0.16), transparent 28%),
    radial-gradient(circle at 12% 86%, rgba(109, 40, 217, 0.8), transparent 40%),
    linear-gradient(145deg, #111827 0%, #24205f 52%, var(--brand) 100%);
}

.auth-body--ops .auth-story {
  background:
    radial-gradient(circle at 82% 18%, rgba(255, 255, 255, 0.12), transparent 28%),
    radial-gradient(circle at 8% 88%, rgba(14, 116, 144, 0.58), transparent 42%),
    linear-gradient(145deg, #0b1220 0%, #172554 52%, #3730a3 100%);
}

.auth-story::before,
.auth-story::after {
  content: "";
  position: absolute;
  z-index: -1;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 999px;
}

.auth-story::before {
  width: 360px;
  height: 360px;
  right: -190px;
  top: 23%;
}

.auth-story::after {
  width: 220px;
  height: 220px;
  right: -115px;
  top: calc(23% + 70px);
}

.auth-brand {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.025em;
}

.auth-brand__mark,
.portal-toolbar__mark {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  flex: none;
  border-radius: 11px;
  background: var(--brand);
  color: #fff;
  box-shadow: 0 8px 24px -10px rgba(80, 70, 229, 0.7);
}

.auth-brand__mark svg,
.portal-toolbar__mark svg {
  width: 23px;
  height: 23px;
}

.auth-brand--light .auth-brand__mark {
  background: rgba(255, 255, 255, 0.16);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.18);
  backdrop-filter: blur(8px);
}

.auth-story__copy {
  max-width: 510px;
  margin-top: clamp(72px, 12vh, 132px);
}

.auth-kicker {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  padding: 6px 10px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 999px;
  color: rgba(255, 255, 255, 0.82);
  background: rgba(255, 255, 255, 0.08);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.09em;
  line-height: 1.2;
  text-transform: uppercase;
}

.auth-story h1 {
  max-width: 500px;
  margin: 20px 0 18px;
  font-size: clamp(36px, 4.4vw, 56px);
  font-weight: 650;
  letter-spacing: -0.048em;
  line-height: 1.02;
}

.auth-story__copy p {
  max-width: 475px;
  margin: 0;
  color: rgba(255, 255, 255, 0.72);
  font-size: 15px;
  line-height: 1.65;
}

.auth-story__features {
  margin: 0;
  padding: 0;
  display: grid;
  gap: 13px;
  list-style: none;
}

.auth-story__features li {
  display: flex;
  align-items: center;
  gap: 12px;
  color: rgba(255, 255, 255, 0.83);
  font-size: 13px;
  line-height: 1.4;
}

.auth-story__features li span {
  min-width: 27px;
  color: rgba(255, 255, 255, 0.45);
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
}

.auth-story__foot {
  display: flex;
  align-items: center;
  gap: 9px;
  color: rgba(255, 255, 255, 0.56);
  font-size: 11.5px;
}

.auth-status-dot {
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: #6ee7b7;
  box-shadow: 0 0 0 4px rgba(110, 231, 183, 0.12);
}

.auth-panel {
  display: grid;
  place-items: center;
  padding: clamp(36px, 6vw, 72px);
  background: var(--surface);
}

.auth-panel__inner {
  width: min(100%, 390px);
}

.auth-panel__heading {
  margin-bottom: 32px;
}

.auth-panel__heading .auth-kicker {
  border-color: var(--hairline-strong);
  color: var(--brand);
  background: var(--brand-soft);
}

.auth-panel__heading .auth-kicker--ops {
  color: var(--info);
  background: var(--info-soft);
}

.auth-panel h2 {
  margin: 18px 0 9px;
  font-size: 30px;
  font-weight: 700;
  letter-spacing: -0.04em;
  line-height: 1.15;
}

.auth-panel__heading p,
.auth-panel__note {
  margin: 0;
  color: var(--text-2);
  font-size: 13.5px;
  line-height: 1.55;
}

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

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

.auth-field > label {
  color: var(--text-1);
  font-size: 12px;
  font-weight: 600;
}

.auth-field > input {
  width: 100%;
  height: 48px;
  box-sizing: border-box;
  padding: 0 14px;
  border: 1px solid var(--hairline-strong);
  border-radius: 13px;
  background: var(--surface);
  color: var(--text-1);
  font-size: 15px;
  transition: border-color 120ms ease, box-shadow 120ms ease, background-color 120ms ease;
}

.auth-field > input:hover:not(:disabled) {
  border-color: #b8b8b1;
}

.auth-field > input:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: var(--shadow-glow);
}

.auth-field > input[aria-invalid="true"] {
  border-color: rgba(185, 28, 28, 0.55);
  background: var(--danger-soft);
}

.auth-field > input:disabled {
  cursor: not-allowed;
  opacity: 0.58;
  background: var(--surface-2);
}

.auth-field__errors,
.auth-field__errors .errorlist {
  margin: 0;
  padding: 0;
  color: var(--danger);
  font-size: 12px;
  line-height: 1.45;
  list-style: none;
}

.auth-submit {
  width: 100%;
  min-height: 48px;
  margin-top: 4px;
  padding: 0 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  border: 0;
  border-radius: 13px;
  background: var(--brand);
  color: #fff;
  box-shadow: 0 10px 24px -12px rgba(80, 70, 229, 0.85);
  cursor: pointer;
  font-size: 14px;
  font-weight: 650;
  transition: transform 80ms ease, background-color 120ms ease, box-shadow 120ms ease;
}

.auth-body--ops .auth-submit {
  background: #3730a3;
}

.auth-submit:hover:not(:disabled) {
  background: var(--brand-hover);
  box-shadow: 0 13px 28px -13px rgba(80, 70, 229, 0.95);
}

.auth-submit:active:not(:disabled) {
  transform: scale(0.99);
}

.auth-submit:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 3px;
}

.auth-submit:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

.auth-submit svg {
  width: 18px;
  height: 18px;
}

.auth-alert {
  margin: 0 0 22px;
  padding: 13px 14px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  border: 1px solid rgba(185, 28, 28, 0.16);
  border-radius: 13px;
  background: var(--danger-soft);
  color: var(--danger);
  font-size: 12.5px;
  line-height: 1.45;
}

.auth-alert--locked {
  border-color: rgba(180, 83, 9, 0.18);
  background: var(--warning-soft);
  color: var(--warning);
}

.auth-alert > svg {
  width: 18px;
  height: 18px;
  flex: none;
  margin-top: 1px;
}

.auth-alert strong,
.auth-alert span {
  display: block;
}

.auth-alert strong {
  margin-bottom: 2px;
  color: var(--text-1);
  font-weight: 650;
}

.auth-alert .errorlist {
  margin: 2px 0 0;
  padding: 0;
  list-style: none;
}

.auth-panel__note {
  margin-top: 28px;
  padding-top: 22px;
  border-top: 1px solid var(--hairline);
  color: var(--text-3);
  font-size: 11.5px;
  text-align: center;
}

/* Signed-in toolbar on Django-template pages (portal_base.html). */
.portal-toolbar {
  position: relative;
  z-index: 20;
  border-bottom: 1px solid var(--hairline);
  background: rgba(255, 255, 255, 0.94);
  box-shadow: var(--shadow-sm);
}

.portal-toolbar__inner {
  width: 100%;
  min-height: 58px;
  padding: 10px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  box-sizing: border-box;
}

.portal-toolbar__brand,
.portal-toolbar__account {
  min-width: 0;
  display: flex;
  align-items: center;
}

.portal-toolbar__brand {
  gap: 10px;
}

.portal-toolbar__wordmark {
  color: var(--text-1);
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.025em;
}

.portal-toolbar__divider {
  width: 1px;
  height: 20px;
  margin: 0 2px;
  background: var(--hairline-strong);
}

.portal-toolbar__surface {
  overflow: hidden;
  color: var(--text-2);
  font-size: 12px;
  font-weight: 500;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.portal-toolbar__account {
  justify-content: flex-end;
  gap: 12px;
}

.portal-toolbar__user {
  max-width: 220px;
  overflow: hidden;
  color: var(--text-2);
  font-size: 12px;
  font-weight: 500;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.portal-toolbar__signout {
  padding: 7px 11px;
  border: 1px solid var(--hairline-strong);
  border-radius: 9px;
  background: var(--surface);
  color: var(--text-2);
  cursor: pointer;
  font: inherit;
  font-size: 11.5px;
  font-weight: 600;
  transition: background-color 120ms ease, color 120ms ease, border-color 120ms ease;
}

.portal-toolbar__signout:hover {
  border-color: #b8b8b1;
  background: var(--surface-2);
  color: var(--text-1);
}

.portal-toolbar__signout:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

/* Tablet: stack the story panel above the form. */
@media (max-width: 860px) {
  .auth-body {
    padding: 18px;
    place-items: start center;
  }

  .auth-shell {
    min-height: calc(100vh - 36px);
    grid-template-columns: 1fr;
  }

  .auth-story {
    min-height: auto;
    padding: 34px;
    gap: 30px;
  }

  .auth-story__copy {
    margin-top: 50px;
  }

  .auth-story h1 {
    max-width: 620px;
    font-size: clamp(32px, 7vw, 48px);
  }

  .auth-story__features {
    grid-template-columns: repeat(3, 1fr);
    gap: 18px;
  }

  .auth-story__features li {
    align-items: flex-start;
  }

  .auth-story__foot {
    display: none;
  }

  .auth-panel {
    padding: 48px 34px 42px;
  }
}

/* Phone: full-bleed card, no feature list, toolbar wraps onto two rows. */
@media (max-width: 600px) {
  .auth-body {
    padding: 0;
    display: block;
    background: var(--surface);
  }

  .auth-shell {
    min-height: 100vh;
    border: 0;
    border-radius: 0;
    box-shadow: none;
  }

  .auth-story {
    padding: 26px 22px 30px;
    border-radius: 0 0 26px 26px;
  }

  .auth-story__copy {
    margin-top: 42px;
  }

  .auth-story h1 {
    margin: 16px 0 12px;
    font-size: 34px;
  }

  .auth-story__copy p {
    font-size: 13.5px;
    line-height: 1.55;
  }

  .auth-story__features {
    display: none;
  }

  .auth-panel {
    padding: 36px 22px 30px;
  }

  .auth-panel__heading {
    margin-bottom: 26px;
  }

  .auth-panel h2 {
    font-size: 27px;
  }

  .portal-toolbar__inner {
    min-height: 0;
    padding: 10px 16px;
    flex-wrap: wrap;
    gap: 9px 14px;
  }

  .portal-toolbar__mark {
    width: 30px;
    height: 30px;
    border-radius: 9px;
  }

  .portal-toolbar__mark svg {
    width: 20px;
    height: 20px;
  }

  .portal-toolbar__account {
    width: 100%;
    padding-top: 8px;
    border-top: 1px solid var(--hairline);
    justify-content: space-between;
  }

  .portal-toolbar__user {
    max-width: calc(100vw - 120px);
  }
}

@media (prefers-reduced-motion: reduce) {
  .auth-field > input,
  .auth-submit,
  .portal-toolbar__signout {
    transition: none;
  }
}

/* Two-factor setup page (accounts/two_factor.html). */
.auth-steps { margin: 0 0 12px 18px; padding: 0; font-size: 13px; line-height: 1.5; color: var(--text-2, #475569); }
.auth-qr { display: flex; justify-content: center; margin: 8px 0; }
.auth-qr svg { width: 200px; height: 200px; }
.auth-secret { font-size: 12px; text-align: center; word-break: break-all; color: var(--text-2, #475569); }
.auth-codes { list-style: none; display: grid; grid-template-columns: 1fr 1fr; gap: 6px; padding: 0; margin: 12px 0 18px; font-family: 'JetBrains Mono', monospace; font-size: 14px; }
.auth-codes li { padding: 6px 8px; border: 1px solid var(--hairline, #e5e7eb); border-radius: 8px; text-align: center; }
.auth-link { background: none; border: 0; padding: 0; color: inherit; text-decoration: underline; cursor: pointer; font: inherit; }
a.auth-submit { display: flex; justify-content: center; text-decoration: none; }

/* Forgot password (accounts/forgot.html) and the notices shown on the sign-in page. */
.auth-forgot { display: block; margin: -6px 0 18px; font-size: 12.5px; color: var(--brand, #4338ca); text-align: right; }
.auth-notice { margin: 0 0 22px; padding: 13px 14px; border: 1px solid rgba(21, 128, 61, 0.18); border-radius: 13px; background: var(--success-soft, #ecfdf5); color: var(--text-1); font-size: 12.5px; line-height: 1.45; }
.auth-back { display: block; margin-top: 18px; font-size: 12.5px; color: var(--brand, #4338ca); text-align: center; }
