:root {
  color-scheme: dark;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #020304;
  color: #eef3f2;
  --auth-canvas: #020304;
  --auth-line: rgba(184, 205, 205, 0.22);
  --auth-line-soft: rgba(184, 205, 205, 0.08);
  --auth-led: #8bded6;
  --auth-muted: #9da8a7;
}

@property --auth-led-angle {
  syntax: "<angle>";
  inherits: false;
  initial-value: 0deg;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--auth-canvas);
}

.auth-gate {
  color-scheme: dark;
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  place-items: center;
  place-items: safe center;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding:
    max(1.5rem, env(safe-area-inset-top))
    max(1.5rem, env(safe-area-inset-right))
    max(1.5rem, env(safe-area-inset-bottom))
    max(1.5rem, env(safe-area-inset-left));
  background:
    radial-gradient(ellipse at 50% 46%, rgba(139, 222, 214, 0.055), transparent 42%),
    linear-gradient(180deg, #010203 0%, #07090a 48%, #020304 100%);
}

.auth-gate::before,
.auth-gate::after { content: ""; position: absolute; pointer-events: none; }

.auth-gate::before {
  inset: 0;
  background:
    linear-gradient(90deg, transparent 10%, var(--auth-line-soft) 10%, transparent calc(10% + 1px), transparent 90%, var(--auth-line-soft) 90%, transparent calc(90% + 1px)),
    linear-gradient(180deg, transparent 8%, var(--auth-line-soft) 8%, transparent calc(8% + 1px), transparent 92%, var(--auth-line-soft) 92%, transparent calc(92% + 1px));
  opacity: 0.65;
}

.auth-gate::after {
  width: min(72rem, 94vw);
  height: min(54rem, 92vh);
  border: 1px solid rgba(184, 205, 205, 0.045);
  box-shadow: inset 0 0 5rem rgba(139, 222, 214, 0.015);
}

.auth-glow {
  position: absolute;
  width: min(58rem, 90vw);
  height: min(46rem, 84vh);
  border: 1px solid rgba(139, 222, 214, 0.055);
  border-radius: 46%;
  background: radial-gradient(ellipse, rgba(139, 222, 214, 0.035), transparent 66%);
  box-shadow: 0 0 5rem rgba(139, 222, 214, 0.025), inset 0 0 5rem rgba(139, 222, 214, 0.02);
  pointer-events: none;
}

.auth-card {
  position: relative;
  display: grid;
  gap: 0.78rem;
  width: 100%;
  max-width: 29rem;
  min-width: 0;
  margin-inline: auto;
  padding: 2rem;
  overflow: hidden;
  border: 1px solid var(--auth-line);
  border-radius: 0.48rem;
  background: linear-gradient(115deg, rgba(255, 255, 255, 0.025), transparent 23%), linear-gradient(165deg, rgba(16, 20, 21, 0.99), rgba(5, 7, 8, 0.99));
  box-shadow: 0 2.4rem 7rem rgba(0, 0, 0, 0.72), inset 0 1px rgba(255, 255, 255, 0.035), inset 0 0 3.5rem rgba(255, 255, 255, 0.012);
}

.auth-login-card {
  justify-self: center;
  justify-items: stretch;
  align-content: center;
  min-height: min(48rem, calc(100dvh - 3rem - env(safe-area-inset-top) - env(safe-area-inset-bottom)));
  padding: clamp(2rem, 5vh, 3.4rem) clamp(1.5rem, 4vw, 2.75rem);
  text-align: center;
  isolation: isolate;
}

.auth-login-card::before,
.auth-login-card::after { content: ""; position: absolute; border-radius: inherit; pointer-events: none; }

.auth-login-card::before {
  z-index: 3;
  inset: 0;
  padding: 1px;
  background: conic-gradient(from var(--auth-led-angle), transparent 0 17%, rgba(139, 222, 214, 0.88) 21%, transparent 25% 66%, rgba(226, 242, 240, 0.5) 70%, transparent 74% 100%);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
}

.auth-login-card::after {
  z-index: 1;
  inset: 0.48rem;
  border: 1px solid rgba(184, 205, 205, 0.04);
  background: linear-gradient(90deg, var(--auth-led), transparent) 0 0 / 4.5rem 1px no-repeat, linear-gradient(270deg, rgba(238, 243, 242, 0.55), transparent) 100% 100% / 4.5rem 1px no-repeat;
  opacity: 0.48;
}

.auth-login-card > * {
  position: relative;
  z-index: 2;
  width: 100%;
  min-width: 0;
  margin-inline: auto;
}

.auth-brand-logo {
  display: block;
  width: min(12.5rem, 72%);
  height: auto;
  margin: 0 auto 0.15rem;
  filter: brightness(0) invert(1);
}

.auth-login-card .auth-brand-logo { width: 100%; max-width: none; margin-bottom: 0.1rem; }

.auth-kicker {
  margin: 0.2rem 0 -0.45rem;
  color: #b8c4c3;
  font-size: 0.7rem;
  font-weight: 760;
  letter-spacing: 0.12em;
  text-align: center;
  text-transform: uppercase;
}

.auth-login-card .auth-kicker { margin: 0 0 1.15rem; }
.auth-card h1 { margin: 0; font-size: 1.75rem; }
.auth-text { margin: 0 0 0.4rem; color: var(--auth-muted); line-height: 1.55; }
.auth-card label { font-size: 0.76rem; font-weight: 700; letter-spacing: 0.025em; }
.auth-login-card > label { text-align: center; }

.auth-card input,
.auth-card button { min-height: 3rem; border: 1px solid #354143; border-radius: 0.34rem; font: inherit; }

.auth-card input {
  padding: 0.7rem 0.85rem;
  background: #050708;
  color: #eef3f2;
  box-shadow: inset 0 0.4rem 1.2rem rgba(0, 0, 0, 0.42);
}

.auth-card input::placeholder { color: #6f7a79; }
.auth-login-card input { width: 100%; text-align: left; }
.auth-password-field { position: relative; }
.auth-password-field input { width: 100%; padding-right: 3.2rem; }
#authPassword::-ms-clear,
#authPassword::-ms-reveal { display: none; }

.auth-card .auth-password-toggle {
  position: absolute;
  top: 50%;
  right: 0.34rem;
  display: grid;
  place-items: center;
  width: 2.2rem;
  min-height: 2.2rem;
  margin: 0;
  padding: 0;
  transform: translateY(-50%);
  border-color: transparent;
  background: transparent;
  box-shadow: none;
  color: var(--auth-muted);
  font-size: 1rem;
  line-height: 1;
}

.auth-password-toggle svg { width: 1.25rem; height: 1.25rem; fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.7; }
.auth-password-toggle[aria-pressed="false"] .auth-password-eye-slash { display: none; }
.auth-card .auth-password-toggle:hover,
.auth-card .auth-password-toggle[aria-pressed="true"] { background: rgba(139, 222, 214, 0.08); color: #eef3f2; }

.auth-card button {
  margin-top: 0.3rem;
  background: linear-gradient(180deg, #eef3f2, #b8c2c1);
  color: #070909;
  box-shadow: 0 0.65rem 1.8rem rgba(0, 0, 0, 0.32), inset 0 1px rgba(255, 255, 255, 0.85);
  font-weight: 780;
  cursor: pointer;
}

.auth-card > button:hover { background: #f7fbfa; }
.auth-card button:disabled { cursor: wait; opacity: 0.62; }
.auth-card input:focus-visible,
.auth-card button:focus-visible { outline: 3px solid rgba(139, 222, 214, 0.3); outline-offset: 2px; }
.auth-card input:focus-visible { border-color: rgba(139, 222, 214, 0.72); }
.auth-error { min-height: 1.2rem; margin: 0; color: #ffaaaa; font-size: 0.8rem; }
.auth-login-card .auth-error:empty { display: none; }

@keyframes auth-led-orbit { to { --auth-led-angle: 360deg; } }
@keyframes auth-portal-breathe { 50% { opacity: 0.62; transform: scale(1.012); } }

@media (prefers-reduced-motion: no-preference) {
  .auth-login-card::before { animation: auth-led-orbit 13s linear infinite; }
  .auth-glow { animation: auth-portal-breathe 7s ease-in-out infinite; }
  .auth-card button { transition: background-color 160ms ease, border-color 160ms ease; }
}

@media (max-width: 620px) {
  .auth-gate { padding: max(0.7rem, env(safe-area-inset-top)) max(0.7rem, env(safe-area-inset-right)) max(0.7rem, env(safe-area-inset-bottom)) max(0.7rem, env(safe-area-inset-left)); }
  .auth-login-card {
    min-height: calc(100dvh - 1.4rem - env(safe-area-inset-top) - env(safe-area-inset-bottom));
    padding: clamp(1.55rem, 5vh, 2.8rem) clamp(1.15rem, 6vw, 2rem);
  }
}

@media (max-height: 42.5rem) {
  .auth-login-card { min-height: auto; align-content: start; padding-block: 1.35rem; }
  .auth-login-card .auth-brand-logo { width: min(100%, 23rem); }
  .auth-login-card .auth-kicker { margin-bottom: 0.4rem; }
}

@media (prefers-reduced-motion: reduce) {
  .auth-glow,
  .auth-login-card::before { animation: none; }
  .auth-card button { transition: none; }
}

@media (forced-colors: active) {
  .auth-gate,
  .auth-card,
  .auth-card input,
  .auth-card button { background: Canvas; color: CanvasText; }
  .auth-glow,
  .auth-gate::before,
  .auth-gate::after,
  .auth-login-card::before,
  .auth-login-card::after { display: none; }
  .auth-card,
  .auth-card input,
  .auth-card button { border: 1px solid CanvasText; }
}
/* Appended to auth-gate.css; scoped IDs outrank the later portal/fluid styles. */
#authForm.auth-login-card .auth-login-fields {
  --auth-sequence-control: 2.875rem;
  --auth-sequence-radius: 0.34rem;
  gap: 0.6rem;
}

/* Match the P..T outlines at x=56..1064 in the canonical 1100-wide wordmark. */
#authForm.auth-login-card .auth-brand-logo { width: 100%; color-scheme: only light; }
#authForm.auth-login-card .auth-brand-logo img { display: block; width: 100%; height: auto; }
/* Use the canonical alpha contour without browser image recoloring. The image
   retains its accessible name, intrinsic size and unsupported-mask fallback. */
@supports (mask-image: url("/auth-assets/planit-wordmark-clean.svg")) {
  #authForm.auth-login-card .auth-brand-logo {
    background: #fff;
    mask: url("/auth-assets/planit-wordmark-clean.svg") center / contain no-repeat;
    forced-color-adjust: none;
    filter: drop-shadow(0 0 0.42rem rgba(162, 229, 246, 0.26));
  }
  #authForm.auth-login-card .auth-brand-logo img { opacity: 0; }
}
#authForm.auth-login-card .auth-sequence-row,
#authForm.auth-login-card .auth-loading-progress {
  width: calc(100% * 1008 / 1100);
  margin-left: calc(100% * 56 / 1100);
}

#authForm.auth-login-card .auth-sequence-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) var(--auth-sequence-control);
  align-items: center;
  gap: 0.65rem;
  min-width: 0;
  height: var(--auth-sequence-control);
}

#authForm.auth-login-card .auth-sequence-fields {
  position: relative;
  min-width: 0;
  height: 100%;
}

/* Keep complete input geometry for autofill without exposing the inactive step. */
#authForm.auth-login-card .auth-login-step {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  clip-path: inset(50%);
  pointer-events: none;
}

#authForm.auth-login-card:not([data-auth-step="password"]) [data-auth-field="username"],
#authForm.auth-login-card[data-auth-step="password"] [data-auth-field="password"] {
  overflow: visible;
  clip-path: none;
  pointer-events: auto;
}

#authForm.auth-login-card .auth-login-step input {
  display: block;
  width: 100%;
  height: 100%;
  min-height: var(--auth-sequence-control);
  padding: 0.55rem 0.75rem;
  border-radius: var(--auth-sequence-radius);
  font-size: 1rem;
}

#authForm.auth-login-card .auth-password-field input { padding-right: 3.25rem; }
#authForm.auth-login-card #authPasswordToggle {
  width: 2.75rem;
  height: 2.75rem;
  min-height: 2.75rem;
  right: 0.2rem;
}

#authForm.auth-login-card #authSubmit {
  display: grid;
  place-items: center;
  width: var(--auth-sequence-control);
  height: var(--auth-sequence-control);
  min-height: var(--auth-sequence-control);
  margin: 0;
  padding: 0;
  border: 1px solid var(--auth-led);
  border-radius: var(--auth-sequence-radius);
  background: var(--auth-canvas);
  color: var(--auth-led);
  box-shadow: 0 0 0.8rem color-mix(in srgb, var(--auth-led) 12%, transparent);
  text-shadow: none;
  animation: none;
}

#authForm.auth-login-card #authSubmit svg {
  display: block;
  width: 1.5rem;
  height: 1.5rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

#authForm.auth-login-card #authSubmit:hover:not(:disabled) {
  background: color-mix(in srgb, var(--auth-led) 12%, var(--auth-canvas));
}

#authForm.auth-login-card #authBack {
  justify-self: center;
  min-height: 2.75rem;
  max-width: 100%;
  margin: 0;
  padding: 0.45rem 0.75rem;
  border-color: transparent;
  background: transparent;
  color: var(--auth-muted);
  box-shadow: none;
  font-size: 0.8rem;
  visibility: hidden;
  pointer-events: none;
}

#authForm.auth-login-card[data-auth-step="password"] #authBack {
  visibility: visible;
  pointer-events: auto;
}

#authForm.auth-login-card #authBack:hover:not(:disabled) { color: var(--auth-led); }
#authForm.auth-login-card .auth-login-feedback {
  display: grid;
  min-width: 0;
  height: 4.5em;
  overflow-y: auto;
  font-size: 0.8rem;
  line-height: 1.5;
}

#authForm.auth-login-card .auth-loading-status,
#authForm.auth-login-card .auth-error {
  grid-area: 1 / 1;
  position: static;
  display: block;
  width: auto;
  height: auto;
  min-height: 0;
  margin: 0;
  overflow: visible;
  clip-path: none;
  line-height: inherit;
}

#authForm.auth-login-card .auth-loading-status { color: var(--auth-muted); }
#authForm.auth-login-card .auth-error:empty { display: block; visibility: hidden; }
#authForm.auth-login-card .auth-loading-progress {
  position: relative;
  height: 0.2rem;
  overflow: hidden;
  border-radius: 999px;
  background: var(--auth-line-soft);
  visibility: hidden;
}

#authForm.auth-login-card .auth-loading-progress::after {
  content: "";
  position: absolute;
  inset: 0;
  width: 36%;
  border-radius: inherit;
  background: var(--auth-led);
  box-shadow: 0 0 0.55rem var(--auth-led);
}

.auth-portal-pending #authForm.auth-login-card .auth-loading-progress,
.auth-startup-pending #authForm.auth-login-card .auth-loading-progress { visibility: visible; }
.auth-startup-pending #authForm.auth-login-card .auth-sequence-row,
.auth-startup-pending #authForm.auth-login-card #authBack { visibility: hidden; pointer-events: none; }

@keyframes auth-sequence-loading { from { transform: translateX(-100%); } to { transform: translateX(280%); } }
@media (prefers-reduced-motion: no-preference) {
  .auth-portal-pending #authForm.auth-login-card .auth-loading-progress::after,
  .auth-startup-pending #authForm.auth-login-card .auth-loading-progress::after {
    animation: auth-sequence-loading 1.7s ease-in-out infinite;
  }
}

@media (prefers-reduced-motion: reduce) {
  #authForm.auth-login-card .auth-loading-progress::after { width: 100%; animation: none; }
}

@media (forced-colors: active) {
  #authForm.auth-login-card #authSubmit { border-color: ButtonText; background: ButtonFace; color: ButtonText; box-shadow: none; }
  #authForm.auth-login-card #authBack { color: ButtonText; }
  #authForm.auth-login-card .auth-loading-progress { outline: 1px solid CanvasText; background: Canvas; }
  #authForm.auth-login-card .auth-loading-progress::after { background: Highlight; box-shadow: none; }
  #authForm.auth-login-card .auth-loading-status { color: CanvasText; }
}

/* Keep the login surface when Safari/Chromium paint saved credentials. */
@media (forced-colors: none) {
  #authForm.auth-login-card input:autofill {
    box-shadow: inset 0 0 0 100px #050708;
    color: #eef3f2;
    caret-color: #eef3f2;
  }
  #authForm.auth-login-card input:-webkit-autofill {
    -webkit-box-shadow: inset 0 0 0 100px #050708;
    -webkit-text-fill-color: #eef3f2;
    caret-color: #eef3f2;
  }
}

/* Footer stays in normal flow, including short viewports and recovery forms. */
.auth-public-footer {
  min-width: 0;
  padding-top: 0.5rem;
  border-top: 1px solid rgba(157, 211, 222, 0.16);
}
.auth-public-information {
  display: flex; flex-wrap: wrap; justify-content: center; gap: 0.1rem 1rem;
  font-size: 0.75rem;
}
.auth-public-information a {
  display: inline-flex; align-items: center; min-height: 2.75rem; color: var(--auth-muted);
}
.auth-public-information a:focus-visible { outline: 2px solid var(--auth-led); outline-offset: 2px; }
@media (forced-colors: active) {
  .auth-public-footer { border-top-color: CanvasText; }
  .auth-public-information a { color: LinkText; }
}
.auth-gate #authForm[hidden],
.auth-registration-card [hidden] { display: none !important; }
.auth-registration-card { gap: 1rem; z-index: 1; }
.auth-registration-card h1 { margin: 0; font-size: 1.4rem; }
.auth-registration-card p { margin: 0; color: var(--auth-muted); line-height: 1.5; }
.auth-registration-fields { display: grid; gap: 0.85rem; min-width: 0; }
.auth-registration-card label { display: grid; gap: 0.35rem; min-width: 0; text-align: left; }
.auth-registration-card input { width: 100%; min-width: 0; min-height: 2.75rem; }
.auth-registration-card small { color: var(--auth-muted); font-size: 0.75rem; line-height: 1.45; }
.auth-registration-status { display: block; line-height: 1.5; overflow-wrap: anywhere; }
.auth-registration-status:empty { display: none; }
.auth-registration-card button, #authRegisterOpen { min-height: 2.75rem; }
.auth-registration-back, #authRegisterOpen { background: transparent; color: var(--auth-muted); }
.auth-registration-card :focus-visible, #authRegisterOpen:focus-visible {
  outline: 2px solid var(--auth-led); outline-offset: 2px;
}
@media (max-width: 480px) {
  .auth-registration-card { padding: 1.15rem; }
}