:root {
  --ink: #14233a;
  --muted: #5b6b82;
  --line: #d9e0ea;
  /* EnBright Collect "Southern Ocean" palette — see docs/EnBright_Collect_Brand_Guidelines_v1.html */
  --navy: #1e3a5f;
  --navy-hover: #16314f;
  --dark: #0e1e33;
  --dark-mid: #162845;
  --ice: #e6eef8;
  --blue: #4a90d9;
  --blue-pale: #a3caf0;
  --brand: var(--navy);
  --brand-ink: #ffffff;
  --bg: #f4f6fa;
  --field-bg: #f7f9fb;
  --danger: #b42318;
  --danger-bg: #fef3f2;
  --notice: #05603a;
  --notice-bg: #ecfdf3;
  --warning: #b54708;
  --warning-bg: #fffaeb;
  --info: var(--navy);
  --info-bg: var(--ice);
  --ring: 0 0 0 3px rgba(74, 144, 217, 0.18);
  --font: "Satoshi", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

/* Some elements toggled via the `hidden` attribute also carry a display class
   (e.g. .field-hint is flex); author display rules beat the UA's [hidden]. */
[hidden] { display: none !important; }

body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--brand); }

/* ───────────────────────── Auth shell (sign-in, MFA, password, signup) ──────
   The dark "Southern Ocean" canvas is scoped to .auth-shell so it never bleeds
   into other pages sharing this stylesheet. */
.auth-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2.5rem 1.25rem;
  background:
    radial-gradient(ellipse 80% 60% at 50% -10%, rgba(74, 144, 217, 0.20), transparent 60%),
    radial-gradient(ellipse 70% 55% at 50% 115%, rgba(74, 144, 217, 0.12), transparent 55%),
    linear-gradient(180deg, var(--dark) 0%, var(--dark-mid) 55%, var(--navy) 100%);
}

.auth-stack {
  width: 100%;
  max-width: 27rem;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 1.75rem;
}
.auth-stack .brand-logo { justify-content: center; gap: 0.7rem; }
.auth-stack .brand-logo__mark { width: 40px; height: 40px; }
.auth-stack .brand-logo__word { font-size: 1.7rem; }

.auth-card {
  width: 100%;
  background: #fff;
  border-radius: 16px;
  padding: 2.25rem;
  box-shadow:
    0 24px 60px -22px rgba(8, 18, 33, 0.55),
    0 8px 20px -14px rgba(8, 18, 33, 0.45);
}

.auth-card h1 {
  margin: 0 0 0.35rem;
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--navy);
}
.auth-card .lede { margin: 0 0 1.5rem; color: var(--muted); font-size: 0.95rem; }
.auth-card a { color: var(--blue); font-weight: 600; text-decoration: none; }
.auth-card a:hover { text-decoration: underline; }

.auth-footer {
  text-align: center;
  font-size: 0.8rem;
  color: var(--blue-pale);
  line-height: 1.7;
}
.auth-footer a { color: #fff; font-weight: 600; text-decoration: none; }
.auth-footer a:hover { text-decoration: underline; }

/* ───────────────────────── Brand logo lockup (shared/_brand_logo) ────────── */
.brand-logo {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  line-height: 1;
}
.brand-logo__mark { display: block; flex: none; }
.brand-logo__word {
  font-family: var(--font);
  font-size: 1.5rem;
  letter-spacing: -0.01em;
  white-space: nowrap;
}
.brand-logo__en { font-weight: 500; color: var(--muted); }
.brand-logo__collect { font-weight: 700; color: var(--navy); }
.brand-logo--dark .brand-logo__en { color: var(--blue-pale); }
.brand-logo--dark .brand-logo__collect { color: var(--ice); }
.brand-logo__tag {
  align-self: center;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--navy);
  background: var(--ice);
  padding: 0.2rem 0.5rem;
  border-radius: 999px;
}

/* ───────────────────────── Form fields ──────────────────────────────────── */
.field { margin-bottom: 1.1rem; }
.field label { display: block; font-weight: 600; margin-bottom: 0.4rem; font-size: 0.875rem; }

/* Label with an inline action on the right ("Forgot password?"). */
.field__label-row { display: flex; align-items: baseline; justify-content: space-between; gap: 0.75rem; margin-bottom: 0.4rem; }
.field__label-row label { margin-bottom: 0; }
.auth-card .field__forgot { font-size: 0.8rem; white-space: nowrap; }

.field input,
.field select {
  width: 100%;
  padding: 0.7rem 0.8rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: 1rem;
  font-family: inherit;
  background: #fff;
  color: var(--ink);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.field input::placeholder { color: #9aa7b8; }
.field input:focus,
.field select:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: var(--ring);
}
.field input:read-only,
.field input:disabled { background: var(--field-bg); color: var(--muted); }

/* Failed sign-in: both fields are flagged (the message never says which was
   wrong); the focus ring stays the usual blue. */
.field input.input--error { border-color: var(--danger); }

/* Large, spaced rendering for the 6-digit one-time code. */
.field input.otp-input {
  font-size: 1.5rem;
  font-weight: 600;
  letter-spacing: 0.5em;
  text-align: center;
  text-indent: 0.5em; /* re-centre against the trailing letter-spacing */
  font-variant-numeric: tabular-nums;
}

/* Field affixes (the show/hide button wraps the input via auth_pages.js). */
.input-affix { position: relative; display: block; }
.input-affix input { padding-right: 3rem; }
.password-toggle {
  position: absolute;
  top: 50%;
  right: 0.4rem;
  transform: translateY(-50%);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.2rem;
  height: 2.2rem;
  padding: 0;
  border: none;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  border-radius: 8px;
}
.password-toggle:hover { color: var(--navy); background: var(--field-bg); }
.password-toggle:focus-visible { outline: none; box-shadow: 0 0 0 3px rgba(74, 144, 217, 0.3); }
.password-toggle svg { width: 1.2rem; height: 1.2rem; display: block; }

.field-hint {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  margin-top: 0.45rem;
  font-size: 0.8rem;
  color: var(--muted);
}
.field-hint__tick { opacity: 0; transition: opacity 0.15s ease; }
.field-hint.is-met { color: var(--notice); }
.field-hint.is-met .field-hint__tick { opacity: 1; }
.field-hint--warning { color: var(--warning); }

/* ───────────────────────── Remembered account (sign-in) ──────────────────── */
.identity {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.55rem 0.8rem;
  margin-bottom: 1.1rem;
}
.identity__avatar {
  flex: none;
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  background: var(--ice);
  color: var(--navy);
  display: grid;
  place-items: center;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}
.identity__email {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 600;
  font-size: 0.9rem;
}
.auth-card a.identity__switch { margin-left: auto; flex: none; font-size: 0.8rem; }

/* ───────────────────────── Step indicator (MFA challenge) ────────────────── */
.step-indicator { display: flex; align-items: center; gap: 0.4rem; margin: 0 0 0.75rem; }
.step-indicator__dot { width: 8px; height: 8px; border-radius: 50%; background: var(--line); }
.step-indicator__dot--done { background: var(--blue); }
.step-indicator__dot--current { background: #fff; border: 2px solid var(--blue); }
.step-indicator__label {
  margin-left: 0.2rem;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

/* Link-styled button (e.g. "Use a recovery code instead"), injected by JS. */
.auth-alt { margin: -0.25rem 0 1.1rem; font-size: 0.875rem; color: var(--muted); }
.linklike {
  background: none;
  border: none;
  padding: 0;
  margin: 0;
  font: inherit;
  color: var(--blue);
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
}
.linklike:hover { text-decoration: underline; }
.linklike:focus-visible { outline: none; box-shadow: var(--ring); border-radius: 4px; }

/* ───────────────────────── Buttons ──────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  border: 1px solid transparent;
  background: var(--brand);
  color: var(--brand-ink);
  padding: 0.7rem 1rem;
  border-radius: 10px;
  font-size: 0.95rem;
  font-weight: 600;
  font-family: inherit;
  line-height: 1.2;
  text-align: center;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease, opacity 0.15s ease;
}
.btn:hover { background: var(--navy-hover); }
.btn:focus-visible { outline: none; box-shadow: 0 0 0 3px rgba(74, 144, 217, 0.35); }
.btn--block { width: 100%; }
.btn--ghost { background: #fff; color: var(--ink); border-color: var(--line); }
.btn--ghost:hover { background: var(--field-bg); }
.btn--danger { background: var(--danger-bg); color: var(--danger); border-color: #f3c0bb; }
.btn--danger:hover { background: #fce4e2; }
.btn.is-disabled,
.btn:disabled,
.btn[aria-disabled="true"] { opacity: 0.5; pointer-events: none; }

/* Pending-submit spinner (auth_pages.js swaps it in after submit). */
.btn__spinner {
  width: 1em;
  height: 1em;
  flex: none;
  border: 2px solid rgba(255, 255, 255, 0.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: btn-spin 0.8s linear infinite;
}
@keyframes btn-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  .btn__spinner { animation: none; }
}

/* ───────────────────────── Flash & errors ───────────────────────────────── */
.flash { padding: 0.75rem 0.9rem; border-radius: 10px; margin-bottom: 1.1rem; font-size: 0.9rem; }
.flash--alert { background: var(--danger-bg); color: var(--danger); }
.flash--notice { background: var(--notice-bg); color: var(--notice); }
.flash--warning { background: var(--warning-bg); color: var(--warning); }
.flash--info { background: var(--info-bg); color: var(--info); }

.errors { background: var(--danger-bg); color: var(--danger); padding: 0.75rem 0.9rem; border-radius: 10px; margin-bottom: 1.1rem; font-size: 0.9rem; }
.errors ul { margin: 0.25rem 0 0; padding-left: 1.1rem; }

.muted { color: var(--muted); font-size: 0.9rem; }
.stack > * + * { margin-top: 0.75rem; }

/* ───────────────────────── MFA enrolment (QR + setup key) ────────────────── */
.steps { margin: 0 0 1.5rem; padding-left: 1.2rem; color: var(--muted); font-size: 0.9rem; }
.steps li { margin-bottom: 0.3rem; }

.qr-code { display: flex; justify-content: center; margin: 0 0 1.25rem; }
.qr-code__frame {
  width: 200px;
  height: 200px;
  padding: 0.85rem;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: 0 1px 2px rgba(20, 35, 58, 0.06);
}
.qr-code__svg { width: 100%; height: 100%; display: block; }

.disclosure { margin: 0 0 1.4rem; }
.disclosure > summary {
  cursor: pointer;
  color: var(--blue);
  font-weight: 600;
  font-size: 0.9rem;
  list-style: none;
}
.disclosure > summary::-webkit-details-marker { display: none; }
.disclosure[open] > summary { margin-bottom: 0.6rem; }

/* ───────────────────────── Recovery codes (post-enrolment) ───────────────── */
.recovery-codes {
  list-style: none;
  margin: 0 0 1rem;
  padding: 1rem 1.1rem;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem 1rem;
  background: var(--field-bg);
  border: 1px solid var(--line);
  border-radius: 12px;
  font-family: var(--mono);
  font-size: 0.95rem;
}
.recovery-codes li { padding: 0.15rem 0; letter-spacing: 0.03em; }

.recovery-actions { display: flex; gap: 0.5rem; margin-bottom: 1.25rem; }
.recovery-actions .btn { flex: 1; }

.ack {
  display: flex;
  gap: 0.55rem;
  align-items: flex-start;
  margin-bottom: 1.1rem;
  font-size: 0.9rem;
  color: var(--ink);
}
.ack input { margin-top: 0.15rem; width: 1rem; height: 1rem; flex: none; }

/* ───────────────────────── Admin tables & badges ────────────────────────── */
table.users { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
table.users th, table.users td { text-align: left; padding: 0.6rem 0.5rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.users th { color: var(--muted); font-weight: 600; }

.badge { display: inline-block; padding: 0.1rem 0.5rem; border-radius: 999px; font-size: 0.75rem; font-weight: 600; background: #eef2f7; color: var(--muted); }
.badge--locked { background: var(--danger-bg); color: var(--danger); }
.badge--disabled { background: #f1eef7; color: #6941c6; }

.row-actions { display: flex; flex-wrap: wrap; gap: 0.35rem; }
.row-actions form { display: inline; }
.row-actions .btn { padding: 0.3rem 0.55rem; font-size: 0.8rem; }

@media (max-width: 480px) {
  .auth-card { padding: 1.6rem 1.4rem; }
  .recovery-codes { grid-template-columns: 1fr; }
  .recovery-actions { flex-direction: column; }
}
