:root {
  --auth-ink: #102a36;
  --auth-muted: #5d7079;
  --auth-brand: #0b6d87;
  --auth-brand-dark: #075369;
  --auth-soft: #eaf7fa;
  --auth-border: #c7dce3;
  --auth-surface: #ffffff;
  --auth-danger: #a32929;
  --auth-success: #17663d;
}

body.auth-page {
  min-height: 100vh;
  margin: 0;
  color: var(--auth-ink);
  background:
    radial-gradient(circle at 8% 8%, rgba(41, 157, 187, .16), transparent 30%),
    radial-gradient(circle at 92% 88%, rgba(64, 92, 167, .12), transparent 32%),
    #f4f8fb;
  font-family: "IBM Plex Sans Thai", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.auth-skip-link {
  position: fixed;
  top: .65rem;
  left: .65rem;
  z-index: 4000;
  transform: translateY(-170%);
  padding: .55rem .75rem;
  color: #fff;
  border-radius: 8px;
  background: var(--auth-brand-dark);
  font-weight: 750;
}
.auth-skip-link:focus { color: #fff; transform: translateY(0); }

.auth-shell {
  display: grid;
  width: min(1040px, calc(100% - 32px));
  min-height: 100vh;
  margin: 0 auto;
  grid-template-columns: minmax(280px, .78fr) minmax(420px, 1.22fr);
  align-items: center;
  gap: clamp(1rem, 4vw, 3.25rem);
  padding: 32px 0;
}

.auth-intro { padding: clamp(.25rem, 2vw, 1.2rem); }
.auth-kicker {
  display: inline-flex;
  align-items: center;
  gap: .45rem;
  padding: .38rem .68rem;
  color: var(--auth-brand-dark);
  border: 1px solid #b9dce5;
  border-radius: 999px;
  background: rgba(255,255,255,.72);
  font-size: .76rem;
  font-weight: 800;
}
.auth-kicker svg { width: 17px; height: 17px; }
.auth-title { margin: 1rem 0 .6rem; font-size: clamp(2rem, 6vw, 3.5rem); font-weight: 850; line-height: 1.08; letter-spacing: -.025em; }
.auth-lead { max-width: 540px; margin: 0; color: var(--auth-muted); font-size: 1rem; line-height: 1.7; }
.auth-method-list { display: grid; gap: .55rem; margin: 1.35rem 0 0; padding: 0; list-style: none; }
.auth-method-list li { display: flex; align-items: center; gap: .65rem; color: #294651; font-size: .9rem; font-weight: 650; }
.auth-method-icon {
  display: inline-grid;
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  place-items: center;
  color: var(--auth-brand);
  border: 1px solid #c8e2e9;
  border-radius: 10px;
  background: rgba(255,255,255,.78);
}
.auth-method-icon svg { width: 18px; height: 18px; }

.auth-card {
  overflow: hidden;
  border: 1px solid rgba(172, 201, 211, .78);
  border-radius: 22px;
  background: rgba(255,255,255,.96);
  box-shadow: 0 24px 70px rgba(27, 62, 78, .14);
}
.auth-card-header { padding: clamp(1.1rem, 3vw, 1.65rem) clamp(1rem, 4vw, 1.8rem) .85rem; }
.auth-card-header h1 { margin: 0; font-size: 1.45rem; font-weight: 850; }
.auth-card-header p { margin: .35rem 0 0; color: var(--auth-muted); line-height: 1.55; }
.auth-card-body { padding: 0 clamp(1rem, 4vw, 1.8rem) clamp(1.2rem, 4vw, 1.8rem); }

.auth-tabs {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: .4rem;
  margin-bottom: 1rem;
  padding: .3rem;
  border-radius: 13px;
  background: #edf4f6;
}
.auth-tab {
  min-height: 46px;
  padding: .6rem .75rem;
  color: #435c65;
  border: 0;
  border-radius: 10px;
  background: transparent;
  font-weight: 800;
  cursor: pointer;
  transition: color .18s ease, background-color .18s ease, box-shadow .18s ease;
}
.auth-tab[aria-selected="true"] { color: var(--auth-brand-dark); background: #fff; box-shadow: 0 3px 12px rgba(30,71,87,.1); }
.auth-tab:disabled { cursor: not-allowed; opacity: .52; }
.auth-tab:focus-visible { outline: 3px solid rgba(11,109,135,.26); outline-offset: 2px; }
.auth-panel[hidden] { display: none !important; }

.auth-label { display: block; margin-bottom: .4rem; font-size: .9rem; font-weight: 800; }
.auth-control {
  width: 100%;
  min-height: 48px;
  padding: .68rem .8rem;
  color: var(--auth-ink);
  border: 1px solid #adc9d2;
  border-radius: 11px;
  background: #fff;
}
.auth-control:focus { border-color: var(--auth-brand); outline: 0; box-shadow: 0 0 0 .22rem rgba(11,109,135,.14); }
.auth-control::placeholder { color: #8c9aa0; }
.auth-control[aria-invalid="true"] { border-color: var(--auth-danger); }
.auth-password-wrap { position: relative; }
.auth-password-wrap .auth-control { padding-right: 5.2rem; }
.auth-password-toggle {
  position: absolute;
  right: .35rem;
  top: 50%;
  min-width: 64px;
  min-height: 40px;
  transform: translateY(-50%);
  color: var(--auth-brand-dark);
  border: 0;
  border-radius: 8px;
  background: transparent;
  font-size: .78rem;
  font-weight: 800;
  cursor: pointer;
}
.auth-password-toggle:hover { background: var(--auth-soft); }
.auth-password-toggle:focus-visible { outline: 3px solid rgba(11,109,135,.26); outline-offset: 1px; }
.auth-field + .auth-field { margin-top: .9rem; }
.auth-help { margin: .45rem 0 0; color: var(--auth-muted); font-size: .8rem; line-height: 1.5; }
.auth-error { margin: .35rem 0 0; color: var(--auth-danger); font-size: .8rem; font-weight: 700; }

.auth-submit {
  display: inline-flex;
  width: 100%;
  min-height: 50px;
  align-items: center;
  justify-content: center;
  gap: .5rem;
  margin-top: 1rem;
  padding: .7rem 1rem;
  color: #fff;
  border: 1px solid var(--auth-brand);
  border-radius: 11px;
  background: var(--auth-brand);
  font-weight: 850;
  cursor: pointer;
  transition: background-color .18s ease, border-color .18s ease, box-shadow .18s ease;
}
.auth-submit:hover { color: #fff; border-color: var(--auth-brand-dark); background: var(--auth-brand-dark); }
.auth-submit:focus-visible { outline: 3px solid rgba(11,109,135,.26); outline-offset: 3px; }
.auth-submit:disabled { cursor: wait; opacity: .62; }
.auth-submit svg { width: 19px; height: 19px; }

.auth-status { margin: 0 0 1rem; border: 0; border-left: 4px solid currentColor; }
.auth-status[hidden] { display: none; }
.auth-otp-step { margin-top: .95rem; padding-top: .95rem; border-top: 1px solid #e0ebef; }
.auth-otp-step[hidden] { display: none; }
.auth-otp-meta { display: flex; flex-wrap: wrap; justify-content: space-between; gap: .4rem; margin-top: .45rem; color: var(--auth-muted); font-size: .78rem; }

.auth-qr-note {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: .75rem;
  margin-top: 1rem;
  padding: .85rem;
  border: 1px solid #c9e1e8;
  border-radius: 13px;
  background: var(--auth-soft);
}
.auth-qr-note svg { width: 24px; height: 24px; color: var(--auth-brand-dark); }
.auth-qr-note strong { display: block; }
.auth-qr-note p { margin: .22rem 0 .55rem; color: var(--auth-muted); font-size: .82rem; line-height: 1.5; }
.auth-qr-note a { color: var(--auth-brand-dark); font-size: .83rem; font-weight: 850; }
.auth-footer { display: flex; flex-wrap: wrap; justify-content: center; gap: .45rem 1rem; margin-top: 1rem; font-size: .84rem; }
.auth-footer a { color: var(--auth-brand-dark); font-weight: 750; }

.qr-confirm-shell { grid-template-columns: minmax(0, 1fr); width: min(560px, calc(100% - 24px)); }
.qr-confirm-card { padding: clamp(1.2rem, 5vw, 2rem); text-align: center; }
.qr-confirm-icon {
  display: inline-grid;
  width: 64px;
  height: 64px;
  place-items: center;
  color: var(--auth-brand);
  border: 1px solid #bddde6;
  border-radius: 18px;
  background: var(--auth-soft);
}
.qr-confirm-icon svg { width: 34px; height: 34px; }
.qr-confirm-card h1 { margin: 1rem 0 .4rem; font-size: 1.55rem; font-weight: 850; }
.qr-confirm-card > p { color: var(--auth-muted); line-height: 1.6; }
.qr-account {
  margin: 1rem 0;
  padding: .85rem;
  border: 1px solid var(--auth-border);
  border-radius: 13px;
  background: #f8fbfc;
  text-align: left;
}
.qr-account span { display: block; color: var(--auth-muted); font-size: .76rem; }
.qr-account strong { display: block; margin-top: .15rem; overflow-wrap: anywhere; }
.qr-expiry { color: #7b5900; font-size: .82rem; font-weight: 700; }

@media (max-width: 820px) {
  .auth-shell { width: min(600px, calc(100% - 24px)); grid-template-columns: 1fr; align-content: center; gap: 1rem; padding: 24px 0; }
  .auth-intro { padding: 0 .35rem; }
  .auth-title { font-size: clamp(1.85rem, 9vw, 2.65rem); }
  .auth-method-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 520px) {
  .auth-shell { width: min(100% - 16px, 480px); padding: 12px 0 24px; }
  .auth-intro { padding: .4rem; }
  .auth-lead { font-size: .92rem; }
  .auth-method-list { grid-template-columns: 1fr; margin-top: .9rem; }
  .auth-method-list li { font-size: .84rem; }
  .auth-card { border-radius: 17px; }
  .auth-tabs { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  .auth-tab, .auth-submit { transition-duration: .01ms !important; }
  html:focus-within { scroll-behavior: auto; }
}


/* ===== P7+: Forgot Password CTA links ===== */
.auth-method-cta {
  margin-top: .5rem;
  padding: 0;
  list-style: none;
}
.auth-method-cta a {
  display: flex;
  align-items: center;
  gap: .65rem;
  padding: .8rem 1rem;
  color: #fff;
  border-radius: 10px;
  background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
  font-weight: 700;
  text-decoration: none;
  box-shadow: 0 4px 14px rgba(245, 158, 11, 0.28);
  transition: transform .15s, box-shadow .15s;
}
.auth-method-cta a:hover {
  color: #fff;
  transform: translateY(-1px);
  box-shadow: 0 6px 18px rgba(245, 158, 11, 0.4);
}
.auth-method-cta a strong {
  color: #fff;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.auth-method-cta .auth-method-icon {
  background: rgba(255, 255, 255, 0.22);
  color: #fff;
  border: 0;
  box-shadow: none;
}

.auth-forgot-row {
  display: flex;
  justify-content: flex-end;
  margin-top: .55rem;
}
.auth-forgot-link {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  color: var(--auth-brand-dark);
  font-size: .85rem;
  font-weight: 700;
  text-decoration: none;
  padding: .3rem .55rem;
  border-radius: 6px;
  transition: background-color .15s;
}
.auth-forgot-link:hover {
  color: var(--auth-brand-dark);
  background: var(--auth-soft);
  text-decoration: underline;
}
.auth-forgot-link svg {
  width: 14px;
  height: 14px;
}

.auth-footer-highlight {
  color: var(--auth-brand-dark) !important;
  font-weight: 800 !important;
  padding: .25rem .55rem;
  background: var(--auth-soft);
  border-radius: 6px;
  margin-left: -.15rem;
}
.auth-footer-highlight:hover {
  background: #d6edf3;
}

@media (max-width: 600px) {
  .auth-forgot-row { justify-content: center; }
  .auth-footer-highlight { display: inline-block; margin: .25rem 0; }
}


/* ===== Big Forgot Password Button (inline in form) ===== */
.auth-forgot-row {
  display: block;
  margin: 1rem 0 0.25rem;
}
.auth-forgot-btn {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  padding: 14px 18px;
  color: #fff !important;
  border-radius: 12px;
  background: linear-gradient(135deg, #f59e0b 0%, #ef4444 100%);
  text-decoration: none !important;
  font-weight: 700;
  box-shadow: 0 6px 18px rgba(245, 158, 11, 0.3);
  transition: transform 0.2s ease, box-shadow 0.2s ease, filter 0.2s ease;
  position: relative;
  overflow: hidden;
}
.auth-forgot-btn::before {
  content: "";
  position: absolute;
  top: 0; left: -100%;
  width: 100%; height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,.25), transparent);
  transition: left 0.5s ease;
}
.auth-forgot-btn:hover {
  color: #fff !important;
  transform: translateY(-2px);
  box-shadow: 0 10px 24px rgba(245, 158, 11, 0.45);
  filter: brightness(1.05);
}
.auth-forgot-btn:hover::before {
  left: 100%;
}
.auth-forgot-btn:active {
  transform: translateY(0);
}
.auth-forgot-btn-icon {
  flex: 0 0 44px;
  width: 44px; height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.25);
  border-radius: 10px;
  flex-shrink: 0;
}
.auth-forgot-btn-icon svg {
  width: 24px;
  height: 24px;
  color: #fff;
}
.auth-forgot-btn-text {
  flex: 1;
  text-align: left;
  line-height: 1.25;
  min-width: 0;
}
.auth-forgot-btn-title {
  display: block;
  font-size: 1.05rem;
  font-weight: 800;
  color: #fff;
}
.auth-forgot-btn-sub {
  display: block;
  font-size: 0.78rem;
  color: rgba(255, 255, 255, 0.9);
  margin-top: 2px;
  font-weight: 500;
  white-space: normal;
}
.auth-forgot-btn-arrow {
  flex: 0 0 28px;
  font-size: 1.4rem;
  font-weight: 700;
  color: #fff;
  text-align: right;
  transition: transform 0.2s ease;
}
.auth-forgot-btn:hover .auth-forgot-btn-arrow {
  transform: translateX(4px);
}

@media (max-width: 600px) {
  .auth-forgot-btn { padding: 12px 14px; gap: 10px; }
  .auth-forgot-btn-icon { flex: 0 0 38px; width: 38px; height: 38px; }
  .auth-forgot-btn-title { font-size: 0.95rem; }
  .auth-forgot-btn-sub { font-size: 0.72rem; }
}
