/* Shared web sign-in shell. Colors/spacing follow admin.css and organisation.css,
   which reuse the mobile fallback tokens documented in docs/DESIGN.md. */

.auth-sign-in-page {
  --auth-text: #1f2937;
  --auth-muted: #4b5563;
  --auth-border: #e5ded4;
  --auth-accent: #c16e46;
  --auth-primary: #191919;
  --auth-primary-text: #fff;
  --auth-focus: #84b8a1;
  --auth-surface: #fff;
  --auth-input-bg: #fcfaf7;
  --auth-danger: #b42318;
  --auth-danger-bg: #fff0ed;
  box-sizing: border-box;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  margin: 0;
  background: var(--auth-surface);
  color: var(--auth-text);
  font-family: Alexandria, sans-serif;
  font-size: 14px;
  line-height: 24px;
  -webkit-font-smoothing: antialiased;
}

.auth-sign-in-page *,
.auth-sign-in-page *::before,
.auth-sign-in-page *::after { box-sizing: border-box; }

.auth-sign-in-page h1,
.auth-sign-in-page p { margin: 0; }

.auth-sign-in-page a { color: inherit; text-decoration: none; }

.auth-sign-in-page button,
.auth-sign-in-page input { font: inherit; }

.auth-sign-in-page :focus-visible {
  outline: 3px solid var(--auth-focus);
  outline-offset: 3px;
}

.auth-skip {
  position: fixed;
  inset-block-start: -100px;
  inset-inline-start: 16px;
  z-index: 100;
  padding: 12px 24px;
  background: var(--auth-primary);
  color: var(--auth-primary-text) !important;
  border-radius: 8px;
}

.auth-skip:focus { inset-block-start: 16px; }

.auth-sign-in-header {
  flex-shrink: 0;
  padding: 28px 48px 0;
}

.auth-logo-link {
  display: inline-block;
  width: fit-content;
}

.auth-sign-in-header img {
  display: block;
  width: 148px;
  height: auto;
  object-fit: contain;
}

.auth-sign-in-body {
  flex: 1 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: safe center;
  width: 100%;
  padding: 24px 24px 16px;
}

.auth-sign-in {
  width: 400px;
  max-width: 100%;
}

.auth-eyebrow {
  font-size: 10px;
  line-height: 20px;
  font-weight: 600;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--auth-muted);
}

.auth-sign-in h1 {
  margin-block: 6px 10px;
  font-size: 32px;
  line-height: 40px;
  font-weight: 600;
  letter-spacing: -0.8px;
  overflow-wrap: anywhere;
}

.auth-sign-in-description {
  color: var(--auth-muted);
  font-size: 14px;
  line-height: 24px;
}

.auth-sign-in-error {
  margin-block-start: 20px !important;
  padding: 12px 16px;
  border: 1px solid #b4231820;
  border-radius: 16px;
  background: var(--auth-danger-bg);
  color: var(--auth-danger);
  font-size: 12px;
  line-height: 20px;
}

.auth-sign-in-form {
  display: grid;
  gap: 18px;
  margin-block-start: 32px;
}

.auth-field { min-width: 0; }

.auth-field label {
  display: block;
  margin-block-end: 8px;
  font-size: 13px;
  line-height: 22px;
  font-weight: 600;
  color: var(--auth-text);
}

.auth-sign-in-page .auth-input {
  width: 100%;
  min-height: 52px;
  height: auto;
  padding: 12px 18px;
  border: 1px solid var(--auth-border);
  border-radius: 9999px;
  background: var(--auth-input-bg);
  color: var(--auth-text);
  box-shadow: none;
  font-size: 14px;
  line-height: 22px;
}

.auth-sign-in-page .auth-input::placeholder { color: #6b7280; }

.auth-sign-in-page .auth-input[aria-invalid="true"] {
  border-color: #b4231860;
  background: #fffaf9;
}

.auth-password-wrap { position: relative; }

.auth-password-wrap .auth-input { padding-inline-end: 52px; }

.auth-password-toggle {
  position: absolute;
  inset-inline-end: 8px;
  inset-block-start: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 9999px;
  background: transparent;
  color: var(--auth-muted);
  cursor: pointer;
}

.auth-password-toggle:hover { color: var(--auth-text); }

.auth-sign-in-options {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.auth-remember,
.auth-terms {
  display: inline-flex;
  align-items: flex-start;
  gap: 10px;
  color: var(--auth-muted);
  font-size: 13px;
  line-height: 20px;
  cursor: pointer;
  user-select: none;
}

.auth-remember input,
.auth-terms input[type="checkbox"] {
  width: 18px;
  height: 18px;
  margin: 2px 0 0;
  flex-shrink: 0;
  border: 1px solid var(--auth-border);
  border-radius: 4px;
  accent-color: var(--auth-primary);
  cursor: pointer;
}

.auth-terms .auth-text-link {
  font-size: inherit;
  line-height: inherit;
}

.auth-sign-in-page .auth-submit:disabled {
  opacity: 0.7;
  cursor: wait;
}

.auth-text-link {
  color: var(--auth-accent) !important;
  font-size: 13px;
  line-height: 20px;
  font-weight: 600;
}

.auth-text-link:hover { text-decoration: underline !important; }

.auth-sign-in-page .auth-submit {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 56px;
  height: auto;
  padding: 14px 24px;
  border: 1px solid var(--auth-primary);
  border-radius: 9999px;
  background: var(--auth-primary);
  color: var(--auth-primary-text);
  font-size: 16px;
  line-height: 24px;
  font-weight: 600;
  box-shadow: none;
  cursor: pointer;
}

.auth-sign-in-page .auth-submit:hover { background: #333; border-color: #333; }

.auth-sign-in-note,
.auth-sign-in-register {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-block-start: 28px !important;
  padding-block-start: 20px;
  border-block-start: 1px solid var(--auth-border);
  color: var(--auth-muted);
  font-size: 13px;
  line-height: 22px;
  text-align: center;
}

.auth-sign-in-note svg {
  width: 14px;
  height: 14px;
}

.auth-sign-in-footer {
  flex-shrink: 0;
  padding: 16px 24px 28px;
  text-align: center;
  color: var(--auth-muted);
  font-size: 11px;
  line-height: 18px;
}

.auth-sign-in-footer span + span::before {
  content: "·";
  margin-inline: 8px;
  color: var(--auth-border);
}

.auth-back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-block-end: 28px;
  color: var(--auth-muted) !important;
  font-size: 13px;
  line-height: 20px;
  font-weight: 500;
}

.auth-back-link svg {
  width: 16px;
  height: 16px;
}

.auth-back-link:hover { color: var(--auth-text) !important; }

.auth-label-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-block-end: 8px;
}

.auth-label-row label { margin-block-end: 0; }

.auth-field-hint {
  color: var(--auth-muted);
  font-size: 12px;
  line-height: 18px;
  font-weight: 500;
}

.auth-otp {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 10px;
}

.auth-otp-digit {
  width: 100%;
  min-height: 56px;
  padding: 10px 0;
  border: 1px solid var(--auth-border);
  border-radius: 16px;
  background: var(--auth-surface);
  color: var(--auth-text);
  text-align: center;
  font-size: 20px;
  line-height: 28px;
  font-weight: 600;
  caret-color: var(--auth-primary);
}

.auth-otp-digit:focus {
  outline: none;
  border-color: var(--auth-focus);
  box-shadow: 0 0 0 1px var(--auth-focus);
}

.auth-sign-in-page .auth-otp-input {
  justify-content: center;
  gap: 12px;
  margin-block-start: 4px;
}

.auth-sign-in-page .auth-otp-group {
  gap: 8px;
  border: 0;
  background: transparent;
  box-shadow: none;
}

.auth-sign-in-page .auth-otp-slot {
  width: 48px;
  height: 56px;
  border: 1px solid var(--auth-border);
  border-radius: 16px;
  background: var(--auth-surface);
  color: var(--auth-text);
  box-shadow: none;
  font-size: 20px;
  line-height: 28px;
  font-weight: 600;
}

.auth-sign-in-page .auth-otp-input input:focus,
.auth-sign-in-page .auth-otp-input input:focus-visible {
  outline: none;
  box-shadow: none;
}

.auth-sign-in-page .auth-otp-slot[data-active="true"] {
  z-index: 1;
  border-color: var(--auth-border);
  outline: none;
  box-shadow: none;
}

.auth-sign-in-page .auth-otp-slot[aria-invalid="true"] {
  border-color: var(--auth-danger);
  background: var(--auth-danger-bg);
}

.auth-sign-in-page .auth-otp-slot[data-caret="true"]::after {
  content: "";
  position: absolute;
  width: 1px;
  height: 22px;
  background: var(--auth-primary);
  animation: auth-caret-blink 1s steps(1) infinite;
}

.auth-sign-in-page .auth-otp-separator {
  color: var(--auth-muted);
}

.auth-sign-in .auth-resend { margin-block-start: 18px; }

.auth-sign-in-register form,
.auth-inline-form {
  display: inline;
  margin: 0;
}

@keyframes auth-caret-blink {
  0%, 70%, 100% { opacity: 1; }
  20%, 50% { opacity: 0; }
}

.auth-resend {
  margin: 0;
  text-align: center;
  color: var(--auth-muted);
  font-size: 13px;
  line-height: 20px;
}

.auth-resend-waiting,
.auth-resend-ready { margin: 0; }

.auth-resend-button {
  display: inline;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
  font: inherit;
}

.auth-success {
  display: grid;
  justify-items: center;
  text-align: center;
  gap: 0;
}

.auth-success .auth-eyebrow { margin-block-start: 20px; }

.auth-success h1 { margin-block: 6px 10px; }

.auth-success-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  border: 1px solid var(--auth-border);
  border-radius: 14px;
  color: #176b4d;
  background: var(--auth-surface);
}

.auth-success-icon svg {
  width: 22px;
  height: 22px;
}

.auth-sign-in-page a.auth-submit-link {
  margin-block-start: 32px;
  color: var(--auth-primary-text) !important;
}

.auth-sign-in-page a.auth-submit-link:hover {
  background: #333;
  border-color: #333;
  text-decoration: none !important;
}

.auth-sign-in-description strong {
  color: var(--auth-text);
  font-weight: 600;
}

@media (max-width: 600px) {
  .auth-sign-in-header { padding: 20px 24px 0; }
  .auth-sign-in-header img { width: 128px; }
  .auth-sign-in-body { padding: 24px 20px 32px; justify-content: flex-start; padding-block-start: 48px; }
  .auth-sign-in h1 { font-size: 28px; line-height: 36px; }
  .auth-sign-in-form { margin-block-start: 32px; gap: 18px; }
  .auth-sign-in-options { align-items: flex-start; }
  .auth-otp { gap: 8px; }
  .auth-otp-digit { min-height: 48px; font-size: 18px; border-radius: 14px; }
  .auth-sign-in-page .auth-otp-slot { width: 42px; height: 48px; border-radius: 14px; font-size: 18px; }
}

@media (prefers-reduced-motion: reduce) {
  .auth-sign-in-page *,
  .auth-sign-in-page *::before,
  .auth-sign-in-page *::after {
    transition: none !important;
    animation: none !important;
    scroll-behavior: auto !important;
  }
}
