:root,
:root[data-theme="dark"] {
  color-scheme: dark;
  --auth-ink: #f2f4f2;
  --auth-muted: #8f9a9b;
  --auth-faint: #5d6769;
  --auth-canvas: #0d1317;
  --auth-panel: #162127;
  --auth-control: #111b20;
  --auth-line: #2a373b;
  --auth-coral: #ff826d;
  --auth-coral-strong: #ff9a85;
  --auth-blue: #7bb5ff;
  --auth-lime: #c7eb76;
  --auth-shadow: 0 24px 54px rgba(0, 0, 0, .34);
  --auth-scroll-track: rgba(255, 255, 255, .025);
  --auth-scroll-thumb: #405156;
  font-family: "DM Sans", Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--auth-canvas);
  color: var(--auth-ink);
}

:root[data-theme="light"] {
  color-scheme: light;
  --auth-ink: #192427;
  --auth-muted: #687779;
  --auth-faint: #829090;
  --auth-canvas: #f2f4ef;
  --auth-panel: #ffffff;
  --auth-control: #f4f7f3;
  --auth-line: #d8e0dc;
  --auth-coral: #ff826d;
  --auth-scroll-track: rgba(25, 36, 39, .035);
  --auth-scroll-thumb: #a9b9b3;
  --auth-coral-strong: #db664f;
  --auth-blue: #7bb5ff;
  --auth-lime: #c7eb76;
  --auth-shadow: 0 20px 44px rgba(17, 36, 38, .12);
}

* {
  scrollbar-width: thin;
  scrollbar-color: var(--auth-scroll-thumb) var(--auth-scroll-track);
}
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-track { background: var(--auth-scroll-track); }
*::-webkit-scrollbar-thumb {
  border: 3px solid transparent;
  border-radius: 999px;
  background: var(--auth-scroll-thumb);
  background-clip: padding-box;
}
*::-webkit-scrollbar-thumb:hover { background-color: var(--auth-coral); }
*::-webkit-scrollbar-corner { background: transparent; }

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body.auth-page {
  position: relative;
  display: grid;
  min-height: 100vh;
  min-height: 100dvh;
  place-items: center;
  margin: 0;
  padding: 30px 24px;
  color: var(--auth-ink);
  background:
    radial-gradient(circle at 72% -10%, #20343b 0, transparent 32%),
    var(--auth-canvas);
}

body.auth-page::before {
  position: fixed;
  z-index: 0;
  inset: 0;
  content: "";
  pointer-events: none;
  opacity: .4;
  background-image:
    linear-gradient(rgba(11, 37, 41, .035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(11, 37, 41, .035) 1px, transparent 1px);
  background-size: 54px 54px;
  -webkit-mask-image: linear-gradient(#000, transparent 85%);
  mask-image: linear-gradient(#000, transparent 85%);
}

:root[data-theme="dark"] body.auth-page::before {
  opacity: .22;
  background-image:
    linear-gradient(rgba(255, 255, 255, .024) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, .024) 1px, transparent 1px);
}

.auth-shell { position: relative; z-index: 1; width: min(448px, 100%); }
.auth-shell.auth-shell-wide { width: min(570px, 100%); }
.auth-topline { display: flex; align-items: center; justify-content: space-between; gap: 18px; margin: 0 0 18px; }
.auth-brand { display: flex; align-items: center; gap: 11px; min-width: 0; }
.auth-mark { display: block; width: 42px; height: 42px; flex: 0 0 auto; object-fit: contain; filter: drop-shadow(0 8px 15px color-mix(in srgb, var(--auth-coral) 22%, transparent)); }
.auth-brand strong { display: block; color: var(--auth-ink); font-family: "Space Grotesk", "DM Sans", Inter, sans-serif; font-size: 17px; letter-spacing: -.05em; }
.auth-brand span { display: block; margin-top: 3px; color: var(--auth-faint); font-family: "DM Mono", ui-monospace, monospace; font-size: 8px; font-weight: 600; letter-spacing: .13em; text-transform: uppercase; }

.auth-theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  min-height: 34px;
  border: 1px solid var(--auth-line);
  border-radius: 9px;
  padding: 0;
  color: var(--auth-muted);
  background: color-mix(in srgb, var(--auth-panel) 88%, transparent);
  font: 600 10px/1 "DM Mono", ui-monospace, monospace;
  transition: border-color .15s ease, color .15s ease, background .15s ease;
}
.auth-theme-toggle:hover { border-color: var(--auth-coral); color: var(--auth-coral); background: color-mix(in srgb, var(--auth-coral) 8%, var(--auth-panel)); }
.auth-theme-toggle:focus-visible { outline: 3px solid color-mix(in srgb, var(--auth-coral) 42%, transparent); outline-offset: 2px; }
.auth-theme-toggle > span:first-child { color: var(--auth-coral); font-size: 15px; line-height: 1; }
.auth-actions { display: flex; align-items: center; gap: 8px; }
.auth-language { display: flex; align-items: center; gap: 6px; color: var(--auth-faint); font: 700 9px/1 "DM Mono", ui-monospace, monospace; text-transform: uppercase; letter-spacing: .08em; }
.auth-language select { min-height: 34px; border: 1px solid var(--auth-line); border-radius: 8px; padding: 0 6px; color: var(--auth-ink); background: var(--auth-control); font: 700 10px/1 "DM Mono", ui-monospace, monospace; }
.auth-language select:focus-visible { outline: 3px solid color-mix(in srgb, var(--auth-coral) 42%, transparent); outline-offset: 2px; }

.auth-card {
  overflow: hidden;
  border: 1px solid var(--auth-line);
  border-radius: 16px;
  padding: 30px;
  background: color-mix(in srgb, var(--auth-panel) 94%, transparent);
  box-shadow: var(--auth-shadow);
}
.auth-card::before { content: ""; display: block; width: 44px; height: 3px; margin-bottom: 23px; border-radius: 999px; background: linear-gradient(90deg, var(--auth-coral), var(--auth-blue)); }
.auth-card h1 { margin: 0; color: var(--auth-ink); font-family: "Space Grotesk", "DM Sans", Inter, sans-serif; font-size: clamp(24px, 5vw, 29px); letter-spacing: -.055em; line-height: 1.08; }
.auth-card > p { margin: 10px 0 0; color: var(--auth-muted); font-size: 13px; line-height: 1.6; }
.auth-card form { display: grid; gap: 16px; margin-top: 25px; }
/* Browser stylesheet precedence may otherwise let the form grid override the
 * semantic hidden attribute.  The MFA form must be impossible to see or
 * focus until the server has issued an MFA challenge after password proof. */
.auth-card form[hidden] { display: none !important; }
.auth-card label { display: grid; gap: 7px; color: var(--auth-ink); font-size: 12px; font-weight: 700; }
.auth-card input {
  width: 100%;
  min-height: 45px;
  border: 1px solid var(--auth-line);
  border-radius: 9px;
  padding: 11px 12px;
  color: var(--auth-ink);
  background: var(--auth-control);
  font: inherit;
  font-size: 14px;
  outline: 0;
  transition: border-color .15s ease, box-shadow .15s ease, background .15s ease;
}
/* Coral is the call-to-action colour. Keyboard focus gets an independent blue
 * ring, so an untouched field never reads like a warning or error state. */
.auth-card input:focus { border-color: var(--auth-blue); background: var(--auth-panel); box-shadow: 0 0 0 4px color-mix(in srgb, var(--auth-blue) 20%, transparent); }
.auth-card input::placeholder { color: var(--auth-faint); opacity: 1; }
.auth-card .password-wrap { position: relative; }
.auth-card .password-wrap input { padding-right: 90px; }
.auth-card .reveal { position: absolute; top: 50%; right: 7px; transform: translateY(-50%); border: 0; border-radius: 6px; padding: 6px 7px; color: var(--auth-coral); background: transparent; font: 700 10px/1 "DM Mono", ui-monospace, monospace; }
.auth-card .reveal:hover { background: color-mix(in srgb, var(--auth-coral) 10%, transparent); }
.auth-card .submit {
  min-height: 45px;
  border: 1px solid var(--auth-coral);
  border-radius: 9px;
  padding: 11px 14px;
  color: #2a1816;
  background: var(--auth-coral);
  box-shadow: 0 8px 20px color-mix(in srgb, var(--auth-coral) 23%, transparent), inset 0 1px rgba(255, 255, 255, .24);
  font: inherit;
  font-size: 13px;
  font-weight: 800;
  transition: transform .15s ease, background .15s ease, box-shadow .15s ease;
}
.auth-card .submit:hover { transform: translateY(-1px); background: var(--auth-coral-strong); box-shadow: 0 11px 23px color-mix(in srgb, var(--auth-coral) 29%, transparent); }
.auth-card .submit:focus-visible { outline: 3px solid color-mix(in srgb, var(--auth-coral) 45%, transparent); outline-offset: 2px; }
.auth-card .submit:disabled { cursor: wait; opacity: .62; transform: none; box-shadow: none; }

.auth-card .message { min-height: 20px; margin-top: 17px; color: #bd5448; font-size: 12px; line-height: 1.5; }
.auth-card .message.info, .auth-card .hint { color: var(--auth-muted); }
.auth-card .notice, .auth-card .hint {
  margin-top: 18px;
  border: 1px solid color-mix(in srgb, var(--auth-blue) 31%, var(--auth-line));
  border-radius: 10px;
  padding: 12px;
  color: var(--auth-muted);
  background: color-mix(in srgb, var(--auth-blue) 8%, var(--auth-panel));
  font-size: 12px;
  line-height: 1.55;
}
.auth-card .error { margin-top: 16px; color: #bd5448; font-size: 12px; line-height: 1.5; white-space: pre-wrap; }
.auth-card .success { margin-top: 16px; color: #6a914f; font-size: 12px; line-height: 1.5; white-space: pre-wrap; }
.auth-card details { margin-top: 22px; border-top: 1px solid var(--auth-line); padding-top: 16px; color: var(--auth-muted); font-size: 12px; line-height: 1.55; }
.auth-card summary { cursor: pointer; color: var(--auth-coral); font-weight: 800; }
.auth-card .reset { display: inline-block; margin-top: 17px; border: 0; padding: 0; color: var(--auth-muted); background: transparent; font: inherit; font-size: 12px; text-decoration: none; cursor: pointer; }
.auth-card .reset:hover { color: var(--auth-coral); }
.auth-footer { margin-top: 19px; color: var(--auth-faint); font: 10px/1.5 "DM Mono", ui-monospace, monospace; text-align: center; }

.setup-certificate-choice { grid-template-columns: auto 1fr; align-items: center; gap: 9px !important; padding: 11px 12px; border: 1px solid color-mix(in srgb, var(--auth-blue) 34%, var(--auth-line)); border-radius: 10px; background: color-mix(in srgb, var(--auth-blue) 8%, var(--auth-panel)); }
.setup-certificate-choice input { width: 17px; min-height: 17px; margin: 0; accent-color: var(--auth-coral); }
.setup-progress { position: fixed; z-index: 20; inset: 0; display: grid; place-items: center; padding: 24px; background: color-mix(in srgb, var(--auth-canvas) 76%, transparent); backdrop-filter: blur(8px); }
.setup-progress[hidden] { display: none; }
.setup-progress-card { width: min(500px, 100%); border: 1px solid var(--auth-line); border-radius: 16px; padding: 25px; background: var(--auth-panel); box-shadow: var(--auth-shadow); }
.setup-progress-eyebrow { margin: 0 0 7px; color: var(--auth-coral); font: 700 9px/1 "DM Mono", ui-monospace, monospace; letter-spacing: .12em; text-transform: uppercase; }
.setup-progress h2 { margin: 0; color: var(--auth-ink); font-family: "Space Grotesk", "DM Sans", Inter, sans-serif; font-size: 22px; letter-spacing: -.045em; }
.setup-progress .auth-help { margin: 10px 0 0; }
.setup-progress-steps { display: grid; gap: 8px; margin: 20px 0 0; padding: 0; list-style: none; }
.setup-progress-steps li { display: grid; grid-template-columns: 17px 1fr; gap: 9px; align-items: start; min-height: 42px; padding: 10px; border: 1px solid var(--auth-line); border-radius: 9px; color: var(--auth-muted); background: var(--auth-control); font-size: 12px; line-height: 1.45; }
.setup-progress-steps li::before { content: "•"; display: grid; place-items: center; width: 17px; height: 17px; border: 1px solid var(--auth-faint); border-radius: 50%; color: var(--auth-faint); font-weight: 800; }
.setup-progress-steps li[data-state="complete"] { border-color: color-mix(in srgb, var(--auth-lime) 45%, var(--auth-line)); color: var(--auth-ink); }
.setup-progress-steps li[data-state="complete"]::before { content: "✓"; border-color: var(--auth-lime); color: var(--auth-lime); }
.setup-progress-steps li[data-state="active"] { border-color: color-mix(in srgb, var(--auth-blue) 55%, var(--auth-line)); color: var(--auth-ink); }
.setup-progress-steps li[data-state="active"]::before { content: "…"; border-color: var(--auth-blue); color: var(--auth-blue); }
.setup-progress-steps li[data-state="error"] { border-color: color-mix(in srgb, var(--auth-coral) 60%, var(--auth-line)); color: var(--auth-ink); }
.setup-progress-steps li[data-state="error"]::before { content: "!"; border-color: var(--auth-coral); color: var(--auth-coral); }
.setup-progress-actions { display: flex; justify-content: flex-end; gap: 9px; margin-top: 20px; }
.setup-progress-actions button:not(.submit) { min-height: 40px; border: 1px solid var(--auth-line); border-radius: 9px; padding: 9px 12px; color: var(--auth-ink); background: var(--auth-control); font: 700 12px/1 "DM Sans", sans-serif; }
.setup-progress-actions .submit { min-height: 40px; }

@media (max-width: 520px) {
  body.auth-page { padding: 20px 14px; }
  .auth-card { padding: 23px 19px; border-radius: 14px; }
  .auth-topline { align-items: flex-start; }
  .auth-theme-toggle { flex: 0 0 auto; }
}
