/* Auth layout hotfix v6 — additive overrides only. Must load LAST in index.html. */

@media (max-width: 1512px) and (min-width: 901px) {
  /* Left: brand block anchored to bottom, full headline size */
  html.ui-v2 .auth-brand,
  body[data-ui-v2="1"] .auth-brand {
    display: flex !important;
    flex-direction: column !important;
    justify-content: flex-end !important;
    align-items: stretch !important;
    padding: 24px 28px clamp(32px, 5vh, 56px) !important;
    padding-top: 24px !important;
    min-height: 0 !important;
    height: 100% !important;
  }

  html.ui-v2 .auth-brand-inner,
  body[data-ui-v2="1"] .auth-brand-inner {
    margin-top: auto !important;
    justify-content: flex-end !important;
    height: auto !important;
    flex: 0 0 auto !important;
    max-height: none !important;
    padding-bottom: 0 !important;
    gap: clamp(16px, 2.4vh, 24px) !important;
  }

  html.ui-v2 .auth-brand-copy h1,
  html.ui-v2 .auth-brand .auth-brand-copy h1,
  body[data-ui-v2="1"] .auth-brand-copy h1 {
    font-size: clamp(32px, 3.8vw, 44px) !important;
    line-height: 1.08 !important;
  }

  html.ui-v2 .auth-brand-description {
    font-size: 15px !important;
    line-height: 1.5 !important;
    -webkit-line-clamp: 4;
  }

  /*
   * Right: vertical center — grid + place-items beats flex-start/safe-center
   * conflicts from ui-v3 @media (max-height) rules loaded earlier.
   */
  html.ui-v2 .auth-workspace,
  body[data-ui-v2="1"] .auth-workspace {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) !important;
    grid-template-rows: minmax(0, 1fr) !important;
    place-items: center !important;
    align-content: center !important;
    align-self: stretch !important;
    box-sizing: border-box !important;
    width: 100% !important;
    height: 100% !important;
    min-height: 0 !important;
    max-height: 100% !important;
    padding: clamp(12px, 2vh, 24px) clamp(14px, 2.4vw, 26px) !important;
    overflow-x: hidden !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch;
  }

  html.ui-v2 .auth-card-stage,
  body[data-ui-v2="1"] .auth-card-stage {
    grid-row: 1 !important;
    grid-column: 1 !important;
    place-self: center !important;
    align-items: center !important;
    width: min(400px, 100%) !important;
    max-width: min(400px, 100%) !important;
    margin: 0 !important;
    padding: 0 !important;
  }

  html.ui-v2 .auth-pane:not(.auth-pane-wide),
  body[data-ui-v2="1"] .auth-pane:not(.auth-pane-wide),
  html.ui-v2 .auth-card {
    padding: 14px 16px 12px !important;
    border-radius: calc(var(--radius-ui) + 2px);
  }

  html.ui-v2 .auth-pane .overline {
    font-size: 10px !important;
    letter-spacing: 0.12em !important;
    margin: 0 0 2px !important;
  }

  html.ui-v2 .auth-pane h2,
  html.ui-v2 .auth-card h2 {
    font-size: 20px !important;
    margin: 0 0 2px !important;
    line-height: 1.15 !important;
  }

  html.ui-v2 .auth-locale-slot,
  html.ui-v2 .auth-locale-combobox {
    margin-bottom: 4px !important;
  }

  html.ui-v2 .auth-pane .auth-form {
    gap: 6px !important;
  }

  html.ui-v2 .auth-pane .auth-form .button-primary {
    margin-top: 2px !important;
  }

  html.ui-v2 .auth-workspace .field > span,
  html.ui-v2 .auth-pane label > span,
  html.ui-v2 .auth-locale-combobox > span {
    font-size: 12px !important;
  }

  html.ui-v2 .auth-workspace .control,
  body[data-ui-v2="1"] .auth-workspace .control,
  html.ui-v2 .auth-workspace .auth-locale-combobox .merphi-combobox-trigger {
    min-height: 38px !important;
    font-size: 14px !important;
    padding-top: 6px !important;
    padding-bottom: 6px !important;
  }

  html.ui-v2 .auth-workspace .button-primary,
  html.ui-v2 .auth-workspace .button-secondary,
  html.ui-v2 .auth-workspace .button-ghost {
    min-height: 38px !important;
    font-size: 14px !important;
    padding-top: 8px !important;
    padding-bottom: 8px !important;
  }

  html.ui-v2 .auth-secondary-actions {
    gap: 6px !important;
    margin-top: 6px !important;
  }

  html.ui-v2 .auth-secondary-actions .auth-separator {
    margin: 0 !important;
    font-size: 10px !important;
    letter-spacing: 0.1em !important;
  }

  html.ui-v2 #login-captcha:not(.hidden) {
    margin-top: 2px !important;
    min-height: 58px !important;
  }

  html.ui-v2 #captcha-widget {
    min-height: 54px !important;
  }
}

/* Override ui-v3 short-height padding that pins the card to the top */
@media (max-height: 900px) and (min-width: 901px) and (max-width: 1512px) {
  html.ui-v2 .auth-workspace,
  body[data-ui-v2="1"] .auth-workspace {
    padding-top: clamp(12px, 2vh, 24px) !important;
    padding-bottom: clamp(12px, 2vh, 24px) !important;
  }
}

/* Very short height only: allow top scroll instead of clipping */
@media (max-height: 680px) and (min-width: 901px) {
  html.ui-v2 .auth-workspace,
  body[data-ui-v2="1"] .auth-workspace {
    place-items: start !important;
    align-content: start !important;
    padding-top: 8px !important;
    padding-bottom: 12px !important;
  }

  html.ui-v2 .auth-card-stage,
  body[data-ui-v2="1"] .auth-card-stage {
    place-self: start center !important;
  }
}

@media (max-width: 390px) {
  html.ui-v2 .invite-welcome-points,
  body[data-ui-v2="1"] .invite-welcome-points {
    gap: 12px !important;
  }

  html.ui-v2 .invite-step-intro,
  body[data-ui-v2="1"] .invite-step-intro {
    gap: 8px !important;
    margin: 16px 0 12px !important;
  }

  html.ui-v2 .invite-journey-dots,
  body[data-ui-v2="1"] .invite-journey-dots {
    display: none !important;
  }
}

/* Auth refresh v7 — spacious sign-in, responsive TOTP setup and OTP entry. */
html.ui-v2 .auth-workspace,
body[data-ui-v2="1"] .auth-workspace {
  background:
    radial-gradient(circle at 88% 8%, rgba(249, 99, 2, 0.09), transparent 28%),
    radial-gradient(circle at 12% 92%, rgba(9, 10, 13, 0.05), transparent 34%),
    var(--canvas);
}

html.ui-v2 .auth-card-stage,
body[data-ui-v2="1"] .auth-card-stage {
  width: min(620px, 100%) !important;
  max-width: min(620px, 100%) !important;
}

html.ui-v2 .auth-pane:not(.auth-pane-wide),
body[data-ui-v2="1"] .auth-pane:not(.auth-pane-wide),
html.ui-v2 .auth-card {
  width: min(460px, 100%);
  min-width: 0;
  padding: clamp(24px, 3vw, 34px);
  border: 1px solid rgba(199, 206, 216, 0.76);
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 24px 64px rgba(17, 19, 24, 0.12), 0 2px 8px rgba(17, 19, 24, 0.04);
  backdrop-filter: blur(18px);
}

html.ui-v2 #login-2fa-pane {
  width: min(500px, 100%);
}

html.ui-v2 #login-totp-enroll-pane {
  width: min(620px, 100%);
}

html.ui-v2 .auth-card-intro,
html.ui-v2 .auth-security-header {
  margin-bottom: 20px;
}

html.ui-v2 .auth-card-intro .overline,
html.ui-v2 .auth-security-header .overline {
  margin: 0 0 6px;
}

html.ui-v2 .auth-card-intro h2,
html.ui-v2 .auth-security-header h2 {
  margin-bottom: 8px !important;
}

html.ui-v2 .auth-card-subtitle,
html.ui-v2 .auth-security-header .field-help {
  margin: 0;
  color: var(--text-secondary);
  line-height: 1.55;
  overflow-wrap: anywhere;
}

html.ui-v2 .auth-security-header {
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr);
  gap: 14px;
  align-items: start;
}

html.ui-v2 .auth-security-icon {
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  border: 1px solid color-mix(in srgb, var(--brand-orange) 24%, var(--border));
  border-radius: 16px;
  color: var(--brand-orange);
  background: linear-gradient(145deg, #fff 0%, var(--brand-orange-soft) 100%);
  box-shadow: inset 0 1px 0 #fff, 0 10px 22px rgba(249, 99, 2, 0.11);
}

html.ui-v2 .auth-security-icon svg {
  width: 25px;
  height: 25px;
  stroke-width: 1.8;
}

html.ui-v2 .auth-code-field {
  gap: 8px;
}

html.ui-v2 .auth-code-help {
  margin: 0;
  font-size: 12px;
  color: var(--text-secondary);
}

html.ui-v2 .auth-otp-shell {
  position: relative;
  display: block;
  width: 100%;
  min-width: 0;
  cursor: text;
}

html.ui-v2 .auth-otp-input {
  position: absolute;
  inset: 0;
  z-index: 2;
  width: 100%;
  height: 100%;
  min-height: 58px;
  margin: 0;
  border: 0;
  border-radius: 14px;
  padding: 0;
  opacity: 0;
  background: transparent;
  color: transparent;
  caret-color: transparent;
  font-size: 16px;
}

html.ui-v2 .auth-otp-input:focus {
  outline: none;
}

html.ui-v2 .auth-otp-slots {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: clamp(5px, 1.5vw, 10px);
  width: 100%;
}

html.ui-v2 .auth-otp-slots > span {
  display: grid;
  place-items: center;
  min-width: 0;
  height: 58px;
  border: 1px solid var(--border);
  border-radius: 13px;
  background: var(--surface-secondary);
  color: var(--text-primary);
  font-family: var(--font-heading);
  font-size: 23px;
  font-weight: 700;
  line-height: 1;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.84);
  transition: border-color 150ms ease, box-shadow 150ms ease, background 150ms ease, transform 150ms ease;
}

html.ui-v2 .auth-otp-slots > span.is-filled {
  border-color: color-mix(in srgb, var(--brand-orange) 44%, var(--border));
  background: #fff;
}

html.ui-v2 .auth-otp-shell.is-focused .auth-otp-slots > span.is-active,
html.ui-v2 .auth-otp-shell.is-focused .auth-otp-slots > span:first-child:last-child {
  border-color: var(--brand-orange);
  box-shadow: 0 0 0 3px var(--brand-orange-focus);
  transform: translateY(-1px);
}

html.ui-v2 .auth-otp-shell[data-mode="recovery"] .auth-otp-slots {
  display: none;
}

html.ui-v2 .auth-otp-shell[data-mode="recovery"] .auth-otp-input {
  position: static;
  min-height: 48px;
  border: 1px solid var(--border);
  padding: 10px 13px;
  opacity: 1;
  color: var(--text-primary);
  caret-color: var(--text-primary);
  background: #fff;
  font-family: var(--font-body);
  font-size: 16px;
}

html.ui-v2 .auth-otp-shell[data-mode="recovery"].is-focused .auth-otp-input {
  border-color: var(--brand-orange);
  box-shadow: 0 0 0 4px var(--brand-orange-focus);
}

html.ui-v2 .auth-setup-steps {
  display: grid;
  gap: 0;
  width: 100%;
}

html.ui-v2 .auth-setup-step {
  position: relative;
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  gap: 13px;
  padding: 0 0 24px;
}

html.ui-v2 .auth-setup-step:last-child {
  padding-bottom: 0;
}

html.ui-v2 .auth-setup-step:not(:last-child)::after {
  content: "";
  position: absolute;
  top: 34px;
  bottom: 0;
  left: 16px;
  width: 1px;
  background: linear-gradient(var(--border), color-mix(in srgb, var(--brand-orange) 24%, var(--border)));
}

html.ui-v2 .auth-step-number {
  position: relative;
  z-index: 1;
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: #fff;
  color: var(--text-primary);
  font-size: 13px;
  font-weight: 750;
  box-shadow: 0 4px 12px rgba(17, 19, 24, 0.07);
}

html.ui-v2 .auth-step-copy {
  min-width: 0;
  padding-top: 4px;
}

html.ui-v2 .auth-step-copy h3 {
  margin: 0 0 4px;
  font-size: 15px;
  line-height: 1.35;
}

html.ui-v2 .auth-step-copy > p {
  margin: 0 0 12px;
  color: var(--text-secondary);
  font-size: 13px;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

html.ui-v2 .auth-setup-scan {
  display: grid;
  grid-template-columns: 158px minmax(0, 1fr);
  gap: 14px;
  align-items: stretch;
}

html.ui-v2 .auth-qr-frame {
  display: grid;
  place-items: center;
  width: 158px;
  height: 158px;
  padding: 9px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: #fff;
  box-shadow: 0 8px 22px rgba(17, 19, 24, 0.07);
}

html.ui-v2 .auth-qr-frame .totp-qr {
  width: 138px;
  height: 138px;
  border: 0;
  border-radius: 10px;
  object-fit: contain;
  background: #fff;
}

html.ui-v2 .auth-manual-key {
  display: flex;
  min-width: 0;
  flex-direction: column;
  justify-content: center;
  gap: 9px;
  padding: 14px;
  border: 1px solid var(--border-soft);
  border-radius: 16px;
  background: var(--surface-secondary);
}

html.ui-v2 .auth-manual-key small {
  color: var(--text-secondary);
  font-size: 12px;
  line-height: 1.4;
}

html.ui-v2 .auth-manual-key code {
  display: block;
  min-width: 0;
  color: var(--text-primary);
  font-size: 13px;
  font-weight: 700;
  line-height: 1.5;
  overflow-wrap: anywhere;
  user-select: all;
}

html.ui-v2 .auth-copy-key {
  align-self: flex-start;
  min-height: 38px !important;
  padding: 7px 10px !important;
  border-radius: 10px !important;
  font-size: 12px !important;
}

html.ui-v2 .auth-copy-key svg {
  width: 15px;
  height: 15px;
}

html.ui-v2 .auth-setup-step .auth-code-field {
  margin: 4px 0 14px;
}

html.ui-v2 .security-totp-panel .auth-setup-steps,
html.ui-v2 #invite-totp-panel .auth-setup-steps {
  max-width: 680px;
  margin-top: 18px;
  padding: clamp(16px, 2vw, 22px);
  border: 1px solid var(--border-soft);
  border-radius: 20px;
  background: #fff;
}

@media (min-width: 901px) and (max-width: 1512px) {
  html.ui-v2 .auth-card-stage,
  body[data-ui-v2="1"] .auth-card-stage {
    width: min(560px, 100%) !important;
    max-width: min(560px, 100%) !important;
  }

  html.ui-v2 .auth-pane:not(.auth-pane-wide),
  body[data-ui-v2="1"] .auth-pane:not(.auth-pane-wide),
  html.ui-v2 .auth-card {
    width: min(440px, 100%) !important;
    padding: clamp(20px, 2.2vw, 28px) !important;
    border-radius: 22px;
  }

  html.ui-v2 #login-2fa-pane {
    width: min(480px, 100%) !important;
  }

  html.ui-v2 #login-totp-enroll-pane {
    width: min(560px, 100%) !important;
  }

  html.ui-v2 .auth-workspace .control,
  body[data-ui-v2="1"] .auth-workspace .control,
  html.ui-v2 .auth-workspace .auth-locale-combobox .merphi-combobox-trigger,
  html.ui-v2 .auth-workspace .button-primary,
  html.ui-v2 .auth-workspace .button-secondary,
  html.ui-v2 .auth-workspace .button-ghost {
    min-height: 44px !important;
  }
}

@media (max-width: 900px) {
  html.ui-v2 .auth-brand,
  body[data-ui-v2="1"] .auth-brand {
    height: 190px;
    min-height: 190px;
    max-height: 190px;
  }

  html.ui-v2 .auth-workspace,
  body[data-ui-v2="1"] .auth-workspace {
    padding: 18px 14px calc(26px + env(safe-area-inset-bottom, 0px));
  }

  html.ui-v2 .auth-card-stage,
  body[data-ui-v2="1"] .auth-card-stage {
    width: min(620px, 100%) !important;
    max-width: min(620px, 100%) !important;
    padding: 0;
  }

  html.ui-v2 .auth-pane:not(.auth-pane-wide),
  body[data-ui-v2="1"] .auth-pane:not(.auth-pane-wide),
  html.ui-v2 .auth-card,
  html.ui-v2 .auth-pane-wide {
    padding: 22px 18px;
    border-radius: 20px;
  }
}

@media (max-width: 560px) {
  html.ui-v2 .auth-setup-scan {
    grid-template-columns: minmax(0, 1fr);
  }

  html.ui-v2 .auth-qr-frame {
    justify-self: center;
  }

  html.ui-v2 .auth-otp-slots > span {
    height: clamp(46px, 14vw, 56px);
    border-radius: 11px;
    font-size: 20px;
  }

  html.ui-v2 .auth-security-header {
    grid-template-columns: 44px minmax(0, 1fr);
    gap: 12px;
  }

  html.ui-v2 .auth-security-icon {
    width: 44px;
    height: 44px;
    border-radius: 14px;
  }
}

@media (max-width: 390px) {
  html.ui-v2 .auth-brand,
  body[data-ui-v2="1"] .auth-brand {
    height: 148px;
    min-height: 148px;
    max-height: 148px;
  }

  html.ui-v2 .auth-brand-description {
    display: none;
  }

  html.ui-v2 .auth-workspace,
  body[data-ui-v2="1"] .auth-workspace {
    padding-inline: 10px;
  }

  html.ui-v2 .auth-pane:not(.auth-pane-wide),
  body[data-ui-v2="1"] .auth-pane:not(.auth-pane-wide),
  html.ui-v2 .auth-card,
  html.ui-v2 .auth-pane-wide {
    padding: 20px 14px;
    border-radius: 18px;
  }

  html.ui-v2 .auth-otp-slots {
    gap: 5px;
  }

  html.ui-v2 .auth-setup-step {
    grid-template-columns: 30px minmax(0, 1fr);
    gap: 10px;
  }

  html.ui-v2 .auth-step-number {
    width: 30px;
    height: 30px;
  }

  html.ui-v2 .auth-setup-step:not(:last-child)::after {
    top: 30px;
    left: 14px;
  }
}

/* Auth polish v8 — the mobile hero shows only the complete logo, and the
   password reveal button sits inside the field instead of over its border. */
html.ui-v2 .auth-workspace .password-control .icon-button,
body[data-ui-v2="1"] .auth-workspace .password-control .icon-button {
  top: 50%;
  right: 6px;
  width: 36px;
  height: 36px;
  min-height: 0 !important;
  padding: 0;
  transform: translateY(-50%);
  border: 0;
  border-radius: 10px;
  background: transparent;
  box-shadow: none;
}

html.ui-v2 .auth-workspace .password-control .icon-button:hover,
html.ui-v2 .auth-workspace .password-control .icon-button:focus-visible {
  background: rgba(17, 24, 39, 0.06);
}

html.ui-v2 .auth-workspace .password-control .control {
  padding-right: 50px !important;
}

@media (max-width: 900px) {
  html.ui-v2 .auth-brand,
  body[data-ui-v2="1"] .auth-brand {
    height: 136px !important;
    min-height: 136px !important;
    max-height: 136px !important;
  }

  html.ui-v2 .auth-brand-inner,
  body[data-ui-v2="1"] .auth-brand-inner {
    position: absolute !important;
    left: 20px;
    right: 20px;
    bottom: 20px;
    z-index: 2;
    height: auto !important;
    margin: 0 !important;
    padding: 0 !important;
  }

  html.ui-v2 .auth-brand-copy,
  html.ui-v2 .auth-brand-foot {
    display: none !important;
  }

  html.ui-v2 .auth-brand-wordmark {
    display: block;
    width: min(180px, 52vw) !important;
    height: auto !important;
    max-height: none !important;
  }
}

/* Self-service partner applications are paused: the "New partner / Apply" entry stays in the markup, hidden. */
[data-registration-entry] {
  display: none !important;
}
