/* Sign-in, account and app-access pages (#7494, #7499).
   Values are the Glass and Dark glass themes of the design (avanti-hub-glass-v4.html): the auth card
   (.authcard), fields (.field), buttons (.btn/.btn.acc), state icons (.stateico/.ico), the
   two-factor stepper (.wzs), the app chip (.contapp) and the logo tile (--lg-*). Before sign-in
   the theme follows the system light/dark setting: light -> Glass, dark -> Dark glass
   (data-mode on <html>, see _AuthHead). The page backgrounds match the app's ThemeBackdrop. */

:root,
:root[data-mode="glass"] {
  --ag-page: #cdb79c;
  --ag-modal: rgba(255, 250, 244, 0.76);
  --ag-input: rgba(255, 255, 255, 0.78);
  --ag-stroke: rgba(255, 255, 255, 0.5);
  --ag-line: rgba(30, 26, 22, 0.1);
  --ag-soft: rgba(255, 255, 255, 0.3);
  --ag-card-hi: rgba(255, 252, 248, 0.68);
  --ag-track: rgba(255, 255, 255, 0.55);
  --ag-ink: #1e1a16;
  --ag-ink2: rgba(30, 26, 22, 0.64);
  --ag-ink3: rgba(30, 26, 22, 0.42);
  --ag-shadow: 0 20px 60px rgba(60, 35, 15, 0.18), inset 0 1px 0 rgba(255, 255, 255, 0.6);
  --ag-blur: blur(26px) saturate(140%);
  --ag-accent: #ef6327;
  --ag-accent-soft: rgba(239, 99, 39, 0.15);
  --ag-accent-ink: #b8441a;
  --ag-primary: linear-gradient(180deg, #f58a55, #e2541c);
  --ag-primary-shadow: 0 10px 26px -8px rgba(226, 84, 28, 0.7), inset 0 1px 0 rgba(255, 255, 255, 0.35);
  --ag-ok: #2e9e5b;
  --ag-ok-soft: rgba(46, 158, 91, 0.15);
  --ag-bad: #d2452f;
  --ag-bad-soft: rgba(210, 69, 47, 0.14);
  --ag-warn: #a16c21;
  --ag-warn-soft: rgba(214, 150, 60, 0.16);
  --lg-t1: #f0743c;
  --lg-t2: #d9531f;
  --lg-m1: #fff;
  --lg-m2: #ffe2d2;
  color-scheme: light;
}

:root[data-mode="darkglass"] {
  --ag-page: #060607;
  --ag-modal: rgba(28, 29, 34, 0.88);
  --ag-input: rgba(255, 255, 255, 0.05);
  --ag-stroke: rgba(255, 255, 255, 0.09);
  --ag-line: rgba(255, 255, 255, 0.07);
  --ag-soft: rgba(255, 255, 255, 0.06);
  --ag-card-hi: rgba(62, 64, 72, 0.5);
  --ag-track: rgba(255, 255, 255, 0.08);
  --ag-ink: #f1f2f4;
  --ag-ink2: rgba(241, 242, 244, 0.62);
  --ag-ink3: rgba(241, 242, 244, 0.36);
  --ag-shadow: 0 24px 70px rgba(0, 0, 0, 0.55), inset 0 1px 0 rgba(255, 255, 255, 0.08);
  --ag-blur: blur(28px) saturate(135%);
  --ag-accent: #8ab4ff;
  --ag-accent-soft: rgba(138, 180, 255, 0.15);
  --ag-accent-ink: #a9c7ff;
  --ag-primary: linear-gradient(180deg, #8db1ff, #5e8bef);
  --ag-primary-shadow: 0 10px 24px -10px rgba(111, 155, 245, 0.8), inset 0 1px 0 rgba(255, 255, 255, 0.32);
  --ag-ok: #5ed3a8;
  --ag-ok-soft: rgba(94, 211, 168, 0.15);
  --ag-bad: #ff7b86;
  --ag-bad-soft: rgba(255, 123, 134, 0.15);
  --ag-warn: #e9bc63;
  --ag-warn-soft: rgba(233, 188, 99, 0.15);
  --lg-t1: #b5cdff;
  --lg-t2: #7da6ff;
  --lg-m1: #fff;
  --lg-m2: #e4ecff;
  color-scheme: dark;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
  margin: 0;
}

.ag-body {
  font-family: "DM Sans", system-ui, sans-serif;
  font-size: 14px;
  color: var(--ag-ink);
  background: var(--ag-page);
  -webkit-font-smoothing: antialiased;
}

:where(.ag-body) :where(button, input) {
  font: inherit;
  color: inherit;
}

.ag-body h1,
.ag-body h2,
.ag-body p {
  margin: 0;
}

/* ---------- page and card ---------- */
.ag-page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  padding: 16px;
}

.ag-card {
  position: relative;
  width: min(440px, 100%);
  padding: 34px;
  border-radius: 30px;
  background: var(--ag-modal);
  border: 1px solid var(--ag-stroke);
  box-shadow: var(--ag-shadow);
  backdrop-filter: var(--ag-blur);
  -webkit-backdrop-filter: var(--ag-blur);
}

.ag-card > * {
  animation: ag-rise 0.5s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

@keyframes ag-rise {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
}

@media (prefers-reduced-motion: reduce) {
  .ag-card > * {
    animation: none;
  }
}

.ag-help {
  font-size: 12px;
  color: var(--ag-ink3);
  text-align: center;
}

.ag-brand {
  display: flex;
  justify-content: center;
  margin-bottom: 22px;
}

.ag-brand a {
  display: grid;
  border-radius: 14px;
}

.ag-logo {
  width: 46px;
  height: 46px;
  filter: drop-shadow(0 4px 10px color-mix(in srgb, var(--lg-t2) 30%, transparent));
}

.ag-title {
  font-size: 24px;
  font-weight: 600;
  line-height: 1.25;
  letter-spacing: -0.03em;
  text-align: center;
}

.ag-sub {
  margin: 6px 0 24px !important;
  color: var(--ag-ink2);
  text-align: center;
  line-height: 1.5;
}

.ag-mini {
  font-size: 12px;
  color: var(--ag-ink2);
  line-height: 1.5;
}

/* ---------- fields ---------- */
.ag-field {
  margin-bottom: 14px;
}

.ag-field label {
  display: block;
  margin-bottom: 6px;
  font-size: 12px;
  font-weight: 600;
}

.ag-field input:not([type="checkbox"]) {
  width: 100%;
  height: 42px;
  padding: 0 14px;
  border-radius: 12px;
  border: 1px solid var(--ag-stroke);
  background: var(--ag-input);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.ag-field input::placeholder {
  color: var(--ag-ink3);
}

.ag-field input:focus {
  border-color: var(--ag-accent);
  box-shadow: 0 0 0 3px var(--ag-accent-soft);
}

.ag-field input.input-validation-error {
  border-color: var(--ag-bad);
  box-shadow: 0 0 0 3px var(--ag-bad-soft);
}

.ag-error,
.ag-field .field-validation-error {
  display: block;
  margin-top: 5px;
  font-size: 12px;
  color: var(--ag-bad);
}

.ag-error ul {
  margin: 0 0 14px;
  padding: 0;
  list-style: none;
}

.ag-error.validation-summary-valid,
.ag-error:empty {
  display: none;
}

/* Six-digit code: one real input drawn as the design's six boxes (.otp).
   The frame is a size container: boxes, gaps and digit spacing scale with its width
   (304px design width, narrower on phones, #7499), so all six boxes always fit. */
.ag-otp {
  --otp-box: min(44px, 100cqi * 44 / 304);
  --otp-step: min(52px, 100cqi * 52 / 304);
  position: relative;
  container-type: inline-size;
  width: 304px;
  max-width: 100%;
  height: 52px;
  margin: 0 auto 18px;
  /* clip, not hidden: a hidden frame still scrolls to the caret after the sixth digit (#7499);
     the margin keeps the focus ring of the outer boxes visible. */
  overflow: clip;
  overflow-clip-margin: 4px;
  border-radius: 12px;
}

.ag-otp > i {
  position: absolute;
  top: 0;
  width: var(--otp-box);
  height: 52px;
  border-radius: 12px;
  border: 1px solid var(--ag-stroke);
  background: var(--ag-input);
  pointer-events: none;
}

.ag-otp > i:nth-of-type(1) { left: 0; }
.ag-otp > i:nth-of-type(2) { left: var(--otp-step); }
.ag-otp > i:nth-of-type(3) { left: calc(var(--otp-step) * 2); }
.ag-otp > i:nth-of-type(4) { left: calc(var(--otp-step) * 3); }
.ag-otp > i:nth-of-type(5) { left: calc(var(--otp-step) * 4); }
.ag-otp > i:nth-of-type(6) { left: calc(var(--otp-step) * 5); }

.ag-otp:focus-within > i {
  border-color: var(--ag-accent);
  box-shadow: 0 0 0 3px var(--ag-accent-soft);
}

.ag-otp input {
  position: relative;
  /* Wider than the six boxes so the caret after the sixth digit never scrolls the text (#7499). */
  width: calc(100cqi + 56px);
  height: 52px;
  padding: 0 0 0 calc(var(--otp-box) / 2 - 0.5ch);
  border: 0;
  outline: none;
  background: transparent;
  font-family: ui-monospace, Menlo, monospace !important;
  font-size: 20px !important;
  font-weight: 600;
  letter-spacing: calc(var(--otp-step) - 1ch);
}

/* ---------- buttons and links ---------- */
.ag-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 16px;
  border-radius: 999px;
  border: 1px solid var(--ag-stroke);
  background: var(--ag-soft);
  font-size: 13px;
  font-weight: 600;
  color: var(--ag-ink);
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  transition: transform 0.15s, background-color 0.2s, opacity 0.2s;
}

.ag-btn:hover {
  background: var(--ag-card-hi);
}

.ag-btn:active {
  transform: scale(0.97);
}

.ag-btn:focus-visible,
.ag-link:focus-visible,
.ag-brand a:focus-visible {
  outline: 2px solid var(--ag-accent);
  outline-offset: 2px;
}

.ag-btn--acc {
  background: var(--ag-primary);
  background-origin: border-box;
  border-color: transparent;
  box-shadow: var(--ag-primary-shadow);
  color: #fff;
}

.ag-btn--acc:hover {
  background: var(--ag-primary);
  background-origin: border-box;
  filter: brightness(1.05);
}

.ag-btn:disabled {
  opacity: 0.45;
  cursor: default;
  transform: none;
}

.ag-btn--block {
  width: 100%;
  padding: 12px;
}

.ag-btn .ag-i {
  width: 16px;
  height: 16px;
}

.ag-alt {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 14px;
  font-size: 12px;
}

.ag-link {
  padding: 0;
  border: 0;
  background: none;
  font-weight: 600;
  color: var(--ag-ink2);
  text-decoration: none;
  cursor: pointer;
}

.ag-link:hover {
  color: var(--ag-ink);
}

.ag-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* Remember me / I saved my codes: the design's .set row with a .toggle switch. */
.ag-set {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 0 14px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.ag-set span {
  flex: 1;
}

.ag-set input {
  appearance: none;
  position: relative;
  flex: none;
  width: 40px;
  height: 24px;
  margin: 0;
  border-radius: 999px;
  border: 1px solid var(--ag-stroke);
  background: var(--ag-track);
  cursor: pointer;
  transition: background-color 0.25s;
}

.ag-set input::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25);
  transition: left 0.3s cubic-bezier(0.3, 1.4, 0.5, 1);
}

.ag-set input:checked {
  background: var(--ag-accent);
  border-color: var(--ag-accent);
}

.ag-set input:checked::after {
  left: 18px;
}

.ag-set input:focus-visible {
  outline: 2px solid var(--ag-accent);
  outline-offset: 2px;
}

/* ---------- state icon, details, app chip, spinner ---------- */
.ag-i {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex: none;
}

.ag-state {
  width: 60px;
  height: 60px;
  margin: 0 auto 16px;
  display: grid;
  place-items: center;
  border-radius: 18px;
  background: var(--ag-soft);
}

.ag-state .ag-i {
  width: 26px;
  height: 26px;
}

.ag-state--bad {
  background: var(--ag-bad-soft);
  color: var(--ag-bad);
}

.ag-state--ok {
  background: var(--ag-ok-soft);
  color: var(--ag-ok);
}

.ag-state--acc {
  background: var(--ag-accent-soft);
  color: var(--ag-accent);
}

.ag-state--warn {
  background: var(--ag-warn-soft);
  color: var(--ag-warn);
}

.ag-details {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 6px 14px;
  margin: 0 0 18px;
  padding: 12px 14px;
  border-radius: 14px;
  background: var(--ag-soft);
  font-size: 12.5px;
}

.ag-details dt {
  color: var(--ag-ink3);
}

.ag-details dd {
  margin: 0;
  font-weight: 600;
  overflow-wrap: anywhere;
}

.ag-chip {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin: 4px 0 18px;
  padding: 8px 12px;
  border-radius: 12px;
  background: var(--ag-soft);
  font-size: 13px;
}

.ag-chip b {
  font-weight: 600;
}

/* App tile in the chip (the design's .contapp .logo.sm). */
.ag-chip i {
  width: 26px;
  height: 26px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--ag-accent-soft);
  color: var(--ag-accent);
  font-size: 11px;
  font-style: normal;
  font-weight: 700;
  text-transform: uppercase;
}

.ag-spin {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 2px solid color-mix(in srgb, var(--ag-accent) 30%, transparent);
  border-top-color: var(--ag-accent);
  animation: ag-spin 0.7s linear infinite;
}

@keyframes ag-spin {
  to {
    transform: rotate(360deg);
  }
}

/* ---------- two-factor setup ---------- */
.ag-steps {
  display: flex;
  align-items: center;
  margin: 0 0 22px;
  padding: 10px 12px;
  border-radius: 16px;
  border: 1px solid var(--ag-stroke);
  background: var(--ag-soft);
  list-style: none;
}

.ag-step {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: none;
  font-size: 12px;
  font-weight: 600;
  color: var(--ag-ink2);
}

.ag-step i {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: 1px solid var(--ag-stroke);
  background: var(--ag-card-hi);
  font-style: normal;
}

.ag-step i .ag-i {
  width: 13px;
  height: 13px;
}

.ag-step--done i {
  background: var(--ag-ok-soft);
  border-color: transparent;
  color: var(--ag-ok);
}

.ag-step--on {
  color: var(--ag-ink);
}

.ag-step--on i {
  background: var(--ag-accent);
  border-color: var(--ag-accent);
  color: #fff;
}

.ag-step-line {
  flex: 1;
  min-width: 12px;
  height: 2px;
  margin: 0 8px;
  border-radius: 2px;
  background: var(--ag-stroke);
}

.ag-step-line--on {
  background: var(--ag-accent);
}

.ag-setup {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 16px;
}

.ag-qr {
  flex: none;
  width: 150px;
  height: 150px;
  padding: 13px;
  border-radius: 16px;
  background: #fff;
}

.ag-qr img,
.ag-qr canvas {
  display: block;
  width: 124px !important;
  height: 124px !important;
}

.ag-key {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
}

.ag-key code,
.ag-codes code {
  font-family: ui-monospace, Menlo, monospace;
  font-size: 12px;
  letter-spacing: 0.06em;
}

.ag-key code {
  padding: 7px 10px;
  border-radius: 999px;
  border: 1px solid var(--ag-stroke);
  background: var(--ag-soft);
  overflow-wrap: anywhere;
}

.ag-iconbtn {
  width: 30px;
  height: 30px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: 1px solid var(--ag-stroke);
  background: var(--ag-soft);
  color: var(--ag-ink);
  cursor: pointer;
}

.ag-iconbtn .ag-i {
  width: 15px;
  height: 15px;
}

.ag-codes {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

.ag-codes code {
  padding: 8px 10px;
  border-radius: 10px;
  background: var(--ag-soft);
  font-size: 13px;
  text-align: center;
}

.ag-tools {
  display: flex;
  gap: 8px;
  margin: 14px 0;
}

.ag-feedback:empty {
  display: none;
}

.ag-feedback {
  margin: -6px 0 12px !important;
  font-size: 12px;
  color: var(--ag-ok);
}

.ag-note {
  margin: 0 0 14px !important;
  font-size: 12px;
  color: var(--ag-ink3);
  line-height: 1.5;
}

@media (max-width: 760px) {
  .ag-card {
    padding: 24px;
  }
}

@media (max-width: 400px) {
  .ag-setup {
    flex-direction: column;
  }
}

.ag-center {
  text-align: center;
}

/* ---------- page background (same as the app ThemeBackdrop, #7499) ---------- */
.ag-backdrop {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
}

/* Glass: warm blurred interior photo made of radial gradients. */

.ag-backdrop__photo {
  position: absolute;
  inset: -60px;
  filter: blur(34px) saturate(0.8) brightness(1.03);
  transform: scale(1.05);
  background: radial-gradient(
      16% 26% at 50% 30%,
      #4a3a2f 0 50%,
      transparent 75%
    ),
    radial-gradient(30% 45% at 82% 28%, #fff4e2 0%, transparent 70%),
    radial-gradient(14% 26% at 8% 52%, #56603f 0%, transparent 70%),
    radial-gradient(10% 20% at 94% 60%, #4d5a3a 0%, transparent 70%),
    radial-gradient(12% 12% at 20% 22%, #ffd9a1 0%, transparent 70%),
    radial-gradient(40% 18% at 50% 74%, #8a5b3b 0%, transparent 75%),
    linear-gradient(180deg, #eadbc6 0%, #dcc5a8 52%, #9b6e4c 66%, #6e4a32 100%);
}

.ag-backdrop__photo::after {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(
    120% 90% at 50% 40%,
    transparent 50%,
    rgb(40 25 15 / 0.35)
  );
}

/* Dark glass: dark ribbons, spheres and glass bubbles. */

.ag-backdrop__ribbons {
  position: absolute;
  inset: -40px;
  width: calc(100% + 80px);
  height: calc(100% + 80px);
}

.ag-backdrop__bubble {
  position: absolute;
  border-radius: 50%;
  background: radial-gradient(
    circle at 30% 25%,
    rgb(255 255 255 / 0.75) 0,
    rgb(255 255 255 / 0.75) 3%,
    rgb(255 255 255 / 0.14) 11%,
    rgb(255 255 255 / 0.03) 38%,
    rgb(255 255 255 / 0) 62%,
    rgb(255 255 255 / 0.12) 90%,
    rgb(255 255 255 / 0.3) 100%
  );
  box-shadow:
    inset 0 0 0 1px rgb(255 255 255 / 0.16),
    inset 0 -10px 22px rgb(255 255 255 / 0.05);
  backdrop-filter: blur(2px) brightness(1.35);
  -webkit-backdrop-filter: blur(2px) brightness(1.35);
}

/* Only the active theme's layer is shown. */
.ag-backdrop__dark {
  position: absolute;
  inset: 0;
  display: none;
}

:root[data-mode="darkglass"] .ag-backdrop__photo {
  display: none;
}

:root[data-mode="darkglass"] .ag-backdrop__dark {
  display: block;
}

.ag-page {
  position: relative;
  z-index: 1;
}
