/* V19 authentication surfaces: shared responsive treatment for consumer and staff entry points. */
.auth-page {
  min-height: 100dvh;
  padding: max(24px, env(safe-area-inset-top)) max(24px, env(safe-area-inset-right))
    max(24px, env(safe-area-inset-bottom)) max(24px, env(safe-area-inset-left));
  display: grid;
  place-items: center;
  overflow-x: hidden;
  background:
    radial-gradient(circle at 12% 12%, rgba(221, 238, 226, 0.92), transparent 34%),
    radial-gradient(circle at 88% 84%, rgba(249, 228, 190, 0.65), transparent 29%), #f7f5ee;
}

.auth-shell {
  position: relative;
  width: min(960px, 100%);
  min-height: min(680px, calc(100dvh - 48px));
  display: grid;
  grid-template-columns: minmax(280px, 0.9fr) minmax(390px, 1.1fr);
  overflow: hidden;
  border: 1px solid rgba(29, 83, 58, 0.14);
  border-radius: 30px;
  background: #fff;
  box-shadow: 0 30px 90px rgba(27, 62, 47, 0.16);
}

/* Override the narrower legacy admin login card without weakening other cards. */
.auth-page .auth-shell.login-card {
  width: min(960px, 100%);
  padding: 0;
  border-radius: 30px;
}

.auth-story {
  position: relative;
  min-width: 0;
  padding: clamp(38px, 5vw, 66px);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  color: #fff;
  background:
    radial-gradient(circle at 82% 18%, rgba(247, 207, 132, 0.34), transparent 24%),
    linear-gradient(155deg, #1b6748 0%, #12432f 58%, #0d3324 100%);
}

.auth-story::after {
  content: '';
  position: absolute;
  right: -58px;
  bottom: -72px;
  width: 240px;
  height: 240px;
  border: 42px solid rgba(255, 255, 255, 0.055);
  border-radius: 50%;
}

.auth-brand {
  position: relative;
  z-index: 1;
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: inherit;
  text-decoration: none;
}

.auth-brand__mark {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 15px;
  color: #174d37;
  background: #f4d7a2;
  font-size: 22px;
  font-weight: 900;
}

.auth-brand__mark :is(svg, .ui-icon) {
  width: 27px;
  height: 27px;
}

.auth-brand strong {
  display: block;
  color: inherit;
  font-size: 18px;
}

.auth-brand small {
  display: block;
  margin-top: 3px;
  color: rgba(255, 255, 255, 0.68);
  font-size: 11px;
}

.auth-story__content {
  position: relative;
  z-index: 1;
  margin: clamp(46px, 10vh, 94px) 0;
}

.auth-kicker {
  margin: 0 0 13px;
  color: #f4d7a2;
  font-size: 11px;
  font-weight: 850;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.auth-story h1 {
  max-width: 9em;
  margin: 0;
  color: #fff;
  font-family: 'Songti SC', 'STSong', serif;
  font-size: clamp(34px, 4.2vw, 52px);
  line-height: 1.16;
  letter-spacing: -0.045em;
}

.auth-story__copy {
  max-width: 31em;
  margin: 18px 0 0;
  color: rgba(255, 255, 255, 0.72);
  font-size: 13px;
  line-height: 1.8;
}

.auth-benefits {
  position: relative;
  z-index: 1;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 11px;
  list-style: none;
}

.auth-benefits li {
  display: flex;
  align-items: center;
  gap: 10px;
  color: rgba(255, 255, 255, 0.82);
  font-size: 12px;
  font-weight: 650;
}

.auth-benefits li::before {
  content: '✓';
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border-radius: 50%;
  color: #174d37;
  background: #f4d7a2;
  font-size: 12px;
  font-weight: 900;
}

.auth-form-panel {
  position: relative;
  min-width: 0;
  padding: clamp(38px, 5vw, 70px);
  display: flex;
  flex-direction: column;
  justify-content: center;
  background: #fff;
}

.auth-form-panel .modal-close {
  top: 20px;
  right: 22px;
  width: 44px;
  height: 44px;
  padding: 0;
  display: grid;
  place-items: center;
  border-radius: 50%;
  font-size: 26px;
}

.auth-form-panel .modal-close:hover {
  color: #153e2d;
  background: #eef5f0;
}

.auth-mode {
  width: fit-content;
  margin: 0 0 20px;
  padding: 7px 12px;
  border: 1px solid #d8e6dc;
  border-radius: 999px;
  color: #1b6748;
  background: #f0f7f2;
  font-size: 11px;
  font-weight: 850;
  letter-spacing: 0.04em;
}

.auth-form-panel h2,
.auth-form-panel h1 {
  margin: 0;
  color: #173d31;
  font-family: 'Songti SC', 'STSong', serif;
  font-size: clamp(29px, 3vw, 38px);
  line-height: 1.22;
  letter-spacing: -0.035em;
}

.auth-form-panel > p,
.auth-form-intro {
  margin: 12px 0 0;
  color: #708077;
  font-size: 13px;
  line-height: 1.75;
}

.auth-form-panel form {
  width: 100%;
  margin-top: 28px;
  display: grid;
  gap: 17px;
}

.auth-form-panel form label {
  display: grid;
  gap: 8px;
  color: #334d40;
  font-size: 12px;
  font-weight: 800;
}

.auth-form-panel form input {
  width: 100%;
  min-width: 0;
  min-height: 50px;
  padding: 0 15px;
  border: 1px solid #ccd9d1;
  border-radius: 12px;
  outline: 0;
  color: #17231d;
  background: #fff;
  font-size: 16px;
}

.auth-form-panel form input:focus-visible {
  border-color: #1b6748;
  box-shadow: 0 0 0 4px rgba(27, 103, 72, 0.11);
}

.auth-form-panel :is(.code-row, .code-grid) {
  margin-top: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 126px;
  align-items: end;
  gap: 10px;
}

.auth-form-panel :is(.code-row, .code-grid) > button {
  width: 100%;
  min-height: 50px;
  height: 50px;
  padding: 0 12px;
  border: 1px solid #c5d8cc;
  border-radius: 12px;
  color: #17563d;
  background: #edf6f0;
  cursor: pointer;
  font-size: 12px;
  font-weight: 800;
}

.auth-form-panel :is(.code-row, .code-grid) > button:hover:not(:disabled) {
  border-color: #1b6748;
  background: #e3f1e8;
}

.auth-form-panel :is(.submit-login, .primary, .primary-button) {
  width: 100%;
  min-height: 50px;
  padding: 12px 18px;
  border: 0;
  border-radius: 12px;
  color: #fff;
  background: #176b45;
  box-shadow: 0 10px 24px rgba(23, 107, 69, 0.18);
  cursor: pointer;
  font-size: 14px;
  font-weight: 850;
}

.auth-form-panel :is(.submit-login, .primary, .primary-button):hover:not(:disabled) {
  background: #0f5737;
}

.auth-form-panel button:disabled,
.auth-form-panel input:disabled {
  cursor: not-allowed;
  opacity: 0.56;
}

.auth-form-panel :is(.form-help, .form-message) {
  min-height: 20px;
  margin: -2px 0 0;
  color: #718078;
  font-size: 11px;
  line-height: 1.6;
}

.auth-form-panel :is(.form-help, .form-message).error {
  color: #aa4136;
}

.auth-terms {
  margin: 18px 0 0;
  color: #829087;
  font-size: 11px;
  line-height: 1.65;
  text-align: center;
}

.auth-terms a,
.auth-links a {
  color: #176b45;
  font-weight: 750;
  text-decoration: none;
}

.auth-terms a:hover,
.auth-links a:hover {
  text-decoration: underline;
}

.auth-links,
.login-links.auth-links {
  margin-top: 22px;
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 10px 22px;
  color: #176b45;
  font-size: 12px;
  font-weight: 750;
}

.modal-backdrop:has(.auth-shell) {
  padding: max(16px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right))
    max(16px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  overflow: auto;
}

.modal-backdrop[hidden]:has(.auth-shell) {
  display: none !important;
}

.modal-backdrop .auth-shell {
  min-height: min(650px, calc(100dvh - 32px));
}

@media (max-width: 767px) {
  .auth-page {
    padding: 0;
    place-items: stretch;
    background: #fff;
  }

  .auth-shell,
  .modal-backdrop .auth-shell {
    width: 100%;
    min-height: 100dvh;
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
    border: 0;
    border-radius: 0;
    box-shadow: none;
  }

  .auth-page .auth-shell.login-card {
    width: 100%;
    padding: 0;
    border: 0;
    border-radius: 0;
  }

  .auth-story {
    min-height: 188px;
    padding: max(24px, env(safe-area-inset-top)) max(22px, env(safe-area-inset-right)) 26px
      max(22px, env(safe-area-inset-left));
  }

  .auth-brand__mark {
    width: 42px;
    height: 42px;
    border-radius: 13px;
  }

  .auth-story__content {
    margin: 34px 0 0;
  }

  .auth-story h1 {
    max-width: none;
    font-size: clamp(28px, 8.4vw, 38px);
  }

  .auth-story__copy {
    margin-top: 10px;
    font-size: 12px;
    line-height: 1.65;
  }

  .auth-benefits {
    display: none;
  }

  .auth-form-panel {
    padding: 30px max(22px, env(safe-area-inset-right)) max(30px, env(safe-area-inset-bottom))
      max(22px, env(safe-area-inset-left));
    justify-content: flex-start;
  }

  .auth-form-panel .modal-close {
    position: fixed;
    top: max(15px, env(safe-area-inset-top));
    right: max(15px, env(safe-area-inset-right));
    z-index: 2;
    color: #fff;
    background: rgba(8, 39, 27, 0.36);
  }

  .auth-mode {
    margin-bottom: 15px;
  }

  .auth-form-panel form {
    margin-top: 24px;
  }

  .modal-backdrop:has(.auth-shell) {
    padding: 0;
    display: block;
    background: #fff;
  }
}

@media (max-width: 374px) {
  .auth-story {
    min-height: 214px;
    padding-inline: 18px;
  }

  .auth-brand small,
  .auth-story__copy {
    display: none;
  }

  .auth-story__content {
    margin-top: 24px;
  }

  .auth-form-panel {
    padding: 24px 18px max(24px, env(safe-area-inset-bottom));
  }

  .auth-form-panel :is(.code-row, .code-grid) {
    grid-template-columns: 1fr;
  }
}

@media (max-height: 500px) and (orientation: landscape) {
  .auth-page,
  .modal-backdrop:has(.auth-shell) {
    display: block;
    overflow: auto;
  }

  .auth-shell,
  .modal-backdrop .auth-shell {
    min-height: 100dvh;
    grid-template-columns: minmax(230px, 0.7fr) minmax(390px, 1.3fr);
    grid-template-rows: auto;
  }

  .auth-story {
    min-height: 100dvh;
  }

  .auth-story__content {
    margin: 34px 0;
  }

  .auth-benefits {
    display: none;
  }

  .auth-form-panel {
    min-height: 100dvh;
    padding-block: 28px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .auth-shell *,
  .auth-shell *::before,
  .auth-shell *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}

/* V22 authentication single-viewport contract. Keep the existing account and staff flows while
   making every primary control visible without page or panel scrolling. */
.auth-shell,
.auth-page .auth-shell.login-card,
.modal-backdrop .auth-shell {
  width: min(clamp(820px, 72vw, 980px), calc(100vw - 32px));
  height: min(620px, calc(100dvh - 32px));
  min-height: 0;
  max-height: calc(100dvh - 32px);
  padding: 0;
  grid-template-columns: minmax(280px, 0.4fr) minmax(430px, 0.6fr);
}

.auth-story {
  min-height: 0;
  padding: clamp(28px, 3.2vw, 42px);
}

.auth-story__content {
  margin: clamp(24px, 5vh, 46px) 0;
}

.auth-story h1 {
  max-width: 12em;
  font-size: clamp(30px, 3vw, 40px);
  line-height: 1.18;
}

.auth-story__copy {
  margin-top: 12px;
  line-height: 1.6;
}

.auth-story__trust {
  position: relative;
  z-index: 1;
  margin: 0;
  color: rgba(255, 255, 255, 0.72);
  font-size: 11px;
  line-height: 1.6;
}

.auth-benefits {
  gap: 8px;
}

.auth-form-panel {
  min-height: 0;
  padding: 28px clamp(34px, 4vw, 52px);
  overflow: hidden;
}

.auth-form-panel .modal-close {
  top: 12px;
  right: 14px;
}

.auth-mode {
  margin-bottom: 10px;
  padding: 5px 10px;
}

.auth-form-panel h2,
.auth-form-panel h1 {
  font-size: clamp(26px, 2.5vw, 32px);
}

.auth-form-panel > p,
.auth-form-intro {
  margin-top: 6px;
  line-height: 1.55;
}

.auth-form-panel form {
  margin-top: 14px;
  gap: 10px;
}

.auth-form-panel form label {
  gap: 5px;
}

.auth-form-panel form input,
.auth-form-panel :is(.code-row, .code-grid) > button,
.auth-form-panel :is(.submit-login, .primary, .primary-button) {
  min-height: 48px;
  height: 48px;
}

.auth-form-panel :is(.form-help, .form-message) {
  min-height: 16px;
  line-height: 1.4;
}

.auth-links,
.login-links.auth-links {
  margin-top: 12px;
}

.auth-caps-lock {
  min-height: 16px;
  margin: -2px 0 0;
  color: #9a5a14;
  font-size: 11px;
  font-weight: 750;
}

.modal-backdrop:has(.auth-shell) {
  height: var(--auth-viewport-height, var(--v18-viewport-height, 100dvh));
  max-height: var(--auth-viewport-height, var(--v18-viewport-height, 100dvh));
  overflow: hidden;
}

@media (max-width: 767px) {
  .auth-page,
  .modal-backdrop:has(.auth-shell) {
    height: var(--auth-viewport-height, var(--v18-viewport-height, 100dvh));
    min-height: 0;
    max-height: var(--auth-viewport-height, var(--v18-viewport-height, 100dvh));
    overflow: hidden;
  }

  .login-screen.auth-page,
  .auth-page {
    padding: 0;
  }

  .auth-shell,
  .auth-page .auth-shell.login-card,
  .modal-backdrop .auth-shell {
    width: 100%;
    height: var(--auth-viewport-height, var(--v18-viewport-height, 100dvh));
    min-height: 0;
    max-height: var(--auth-viewport-height, var(--v18-viewport-height, 100dvh));
    grid-template-columns: 1fr;
    grid-template-rows: 68px minmax(0, 1fr);
  }

  .auth-story {
    min-height: 0;
    padding: max(10px, env(safe-area-inset-top)) max(58px, env(safe-area-inset-right)) 10px
      max(16px, env(safe-area-inset-left));
    justify-content: center;
  }

  .auth-brand {
    gap: 9px;
  }

  .auth-brand__mark {
    width: 38px;
    height: 38px;
  }

  .auth-brand strong {
    font-size: 16px;
  }

  .auth-story__content,
  .auth-story__trust,
  .auth-benefits {
    display: none;
  }

  .auth-form-panel {
    min-height: 0;
    padding: 10px max(16px, env(safe-area-inset-right)) max(10px, env(safe-area-inset-bottom))
      max(16px, env(safe-area-inset-left));
    justify-content: flex-start;
    overflow: hidden;
  }

  .auth-form-panel .modal-close {
    position: fixed;
    top: max(10px, env(safe-area-inset-top));
    right: max(10px, env(safe-area-inset-right));
  }

  .auth-mode {
    margin-bottom: 5px;
    padding: 4px 9px;
  }

  .auth-form-panel h2,
  .auth-form-panel h1 {
    font-size: 24px;
    line-height: 1.18;
  }

  .auth-form-panel > p,
  .auth-form-intro {
    margin-top: 3px;
    font-size: 11px;
    line-height: 1.35;
  }

  .auth-form-panel form {
    margin-top: 8px;
    gap: 7px;
  }

  .auth-form-panel form label {
    gap: 3px;
  }

  .auth-form-panel form input,
  .auth-form-panel :is(.code-row, .code-grid) > button,
  .auth-form-panel :is(.submit-login, .primary, .primary-button) {
    min-height: 44px;
    height: 44px;
  }

  .auth-form-panel :is(.code-row, .code-grid) {
    grid-template-columns: minmax(0, 1fr) minmax(102px, 0.44fr);
    gap: 7px;
  }

  .auth-links,
  .login-links.auth-links {
    margin-top: 7px;
    gap: 6px 16px;
  }
}

@media (max-width: 767px) and (max-height: 650px) {
  .auth-shell,
  .auth-page .auth-shell.login-card,
  .modal-backdrop .auth-shell {
    grid-template-rows: 56px minmax(0, 1fr);
  }

  .auth-brand small,
  #login-description,
  #oauth-login-help {
    display: none;
  }

  .auth-form-panel {
    padding-top: 7px;
  }
}

.modal-backdrop.auth-keyboard-open .auth-shell,
body[data-v18-keyboard='open'] .modal-backdrop:has(.auth-shell) .auth-shell {
  grid-template-columns: 1fr;
  grid-template-rows: minmax(0, 1fr);
}

.modal-backdrop.auth-keyboard-open
  :is(
    .auth-story,
    .auth-mode,
    .auth-form-panel > h2,
    #login-description,
    .auth-provider-section,
    .auth-terms
  ),
body[data-v18-keyboard='open']
  .modal-backdrop:has(.auth-shell)
  :is(
    .auth-story,
    .auth-mode,
    .auth-form-panel > h2,
    #login-description,
    .auth-provider-section,
    .auth-terms
  ) {
  display: none;
}

.modal-backdrop.auth-keyboard-open .auth-form-panel,
body[data-v18-keyboard='open'] .modal-backdrop:has(.auth-shell) .auth-form-panel {
  min-height: 0;
  padding: 8px max(14px, env(safe-area-inset-right)) 8px max(14px, env(safe-area-inset-left));
  justify-content: center;
}

.modal-backdrop.auth-keyboard-open .auth-method-tabs,
.modal-backdrop.auth-keyboard-open .auth-form-panel form,
body[data-v18-keyboard='open'] .modal-backdrop:has(.auth-shell) .auth-method-tabs,
body[data-v18-keyboard='open'] .modal-backdrop:has(.auth-shell) .auth-form-panel form {
  margin-top: 6px;
}

@media (max-height: 500px) and (orientation: landscape) {
  .auth-page,
  .modal-backdrop:has(.auth-shell) {
    display: grid;
    place-items: center;
    overflow: hidden;
  }

  .auth-shell,
  .auth-page .auth-shell.login-card,
  .modal-backdrop .auth-shell {
    width: min(860px, 100%);
    height: 100dvh;
    min-height: 0;
    grid-template-columns: minmax(210px, 0.34fr) minmax(390px, 0.66fr);
  }

  .auth-story,
  .auth-form-panel {
    min-height: 0;
  }

  .auth-story__content,
  .auth-benefits {
    display: none;
  }
}
