@import url("https://fonts.googleapis.com/css2?family=Kanit:wght@300;400;500;600;700&display=swap");

:root {
  --login-primary: #2f963f;
  --login-primary-dark: #257d34;
  --login-heading: #064a5a;
  --login-accent: #81c060;
  --login-bg: #f5faf7;
  --login-border: #d8e0dd;
  --login-muted: #718096;
  --login-white: #fff;
  --login-error: #c53d42;
}

body.auth-locked {
  overflow: hidden;
}

html:has(body.auth-locked) {
  overflow: hidden;
}

.login-screen,
.login-screen * {
  box-sizing: border-box;
  font-family: "Kanit", sans-serif;
}

.login-screen {
  position: fixed;
  top: 50%;
  left: 50%;
  z-index: 10000;
  display: grid;
  grid-template-columns: minmax(0, 52%) minmax(0, 48%);
  width: min(1120px, calc(100vw - 48px));
  height: min(720px, calc(100vh - 48px));
  min-height: 0;
  padding: 0;
  overflow: hidden;
  border: 1px solid rgba(216, 224, 221, .8);
  border-radius: 28px;
  background: var(--login-white);
  box-shadow:
    0 28px 80px rgba(24, 73, 48, .16),
    0 0 0 100vmax rgba(245, 250, 247, .96);
  transform: translate(-50%, -50%);
  clip-path: inset(-100vmax);
}

.login-visual {
  position: relative;
  min-width: 0;
  height: 100%;
  overflow: hidden;
  background: #edf5f1;
}

.login-visual img {
  display: block;
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
}

.login-screen::before,
.login-screen::after {
  content: "";
  position: absolute;
  pointer-events: none;
  opacity: .45;
}

.login-screen::before {
  top: 18px;
  right: 5%;
  width: 130px;
  height: 130px;
  border: 12px solid rgba(129, 192, 96, .13);
  border-left-color: transparent;
  border-bottom-color: transparent;
  border-radius: 75% 0 75% 50%;
  transform: rotate(18deg);
}

.login-screen::after {
  right: 7%;
  bottom: 8%;
  width: 58px;
  height: 58px;
  background-image: radial-gradient(circle, rgba(47, 150, 63, .28) 2px, transparent 2.5px);
  background-size: 14px 14px;
}

.login-screen.is-hidden {
  display: none;
}

.login-card {
  position: relative;
  display: grid;
  align-content: center;
  justify-items: center;
  width: 100%;
  height: 100%;
  padding: 40px;
  border: 0;
  border-left: 1px solid rgba(216, 224, 221, .65);
  border-radius: 0;
  background: rgba(255, 255, 255, .98);
  box-shadow: none;
  margin: 0;
}

.login-card-header {
  width: min(360px, 100%);
  text-align: center;
}

.login-brand-logo {
  display: block;
  width: 160px;
  max-height: 76px;
  margin: 0 auto;
  object-fit: contain;
}

.login-card h1 {
  margin: 0;
  color: var(--login-heading);
  font-size: 20px;
  font-weight: 600;
  line-height: 1.15;
}

.login-card-header p {
  max-width: none;
  margin: 4px auto 0;
  color: #56677a;
  font-size: 11px;
  font-weight: 300;
  white-space: nowrap;
}

.login-card form {
  display: grid;
  gap: 10px;
  width: min(360px, 100%);
  margin-top: 20px;
}

.login-field {
  display: grid;
  gap: 0;
}

.login-input-wrap {
  position: relative;
  display: block;
}

.login-input-wrap > svg {
  position: absolute;
  top: 50%;
  left: 14px;
  z-index: 1;
  width: 16px;
  height: 16px;
  color: #657181;
  transform: translateY(-50%);
  pointer-events: none;
}

.login-card .login-input-wrap input {
  display: block;
  width: 100%;
  height: 40px;
  padding: 0 40px;
  border: 1px solid var(--login-border);
  border-radius: 9px;
  outline: none;
  background: var(--login-white);
  color: #20343c;
  font-size: 12px;
  font-weight: 300;
  transition: border-color .18s ease, box-shadow .18s ease;
}

.login-card .login-input-wrap input::placeholder {
  color: #9aa3af;
}

.login-card .login-input-wrap input:focus {
  border-color: var(--login-primary);
  box-shadow: 0 0 0 4px rgba(47, 150, 63, .12);
}

.login-card .login-input-wrap input[aria-invalid="true"] {
  border-color: var(--login-error);
  box-shadow: 0 0 0 3px rgba(197, 61, 66, .1);
}

.login-card .password-toggle {
  position: absolute;
  top: 50%;
  right: 6px;
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: #657181;
  cursor: pointer;
  transform: translateY(-50%);
}

.login-card .password-toggle:hover,
.login-card .password-toggle:focus-visible {
  background: #f0f7f2;
  color: var(--login-primary);
  outline: none;
}

.password-toggle svg {
  width: 16px;
  height: 16px;
}

.field-error {
  min-height: 0;
  color: var(--login-error);
  font-size: 12px;
}

.field-error:not(:empty) {
  margin-top: 6px;
}

.login-options {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.remember-login {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  color: #526172;
  font-size: 14px;
  cursor: pointer;
}

.login-card .remember-login > span {
  display: inline;
  margin: 0;
  color: #526172;
  font-size: 14px;
  font-weight: 400;
}

.login-card .remember-login input {
  appearance: none;
  display: grid;
  place-content: center;
  width: 20px;
  height: 20px;
  margin: 0;
  border: 1px solid #73c485;
  border-radius: 4px;
  background: #fff;
  cursor: pointer;
}

.login-card .remember-login input::after {
  content: "";
  width: 9px;
  height: 5px;
  border-left: 2px solid #fff;
  border-bottom: 2px solid #fff;
  transform: rotate(-45deg) scale(0);
  margin-top: -2px;
}

.login-card .remember-login input:checked {
  border-color: var(--login-primary);
  background: var(--login-primary);
}

.login-card .remember-login input:checked::after {
  transform: rotate(-45deg) scale(1);
}

.forgot-password {
  color: var(--login-primary);
  font-size: 14px;
  font-weight: 500;
  text-decoration: none;
}

.forgot-password:hover,
.forgot-password:focus-visible {
  color: var(--login-primary-dark);
  text-decoration: underline;
}

.login-error {
  min-height: 0;
  margin: -4px 0 0;
  color: var(--login-error);
  font-size: 12px;
  text-align: center;
}

.login-error:empty {
  display: none !important;
}

.login-error:not(:empty) {
  display: block;
  min-height: 18px;
}

.login-card .login-submit {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  width: 100%;
  height: 44px;
  margin-top: 2px;
  border: 0;
  border-radius: 12px;
  background: var(--login-primary);
  box-shadow: 0 10px 24px rgba(47, 150, 63, .2);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background .18s ease, transform .18s ease, box-shadow .18s ease;
}

.login-card .login-submit:hover:not(:disabled) {
  background: var(--login-primary-dark);
  box-shadow: 0 13px 28px rgba(47, 150, 63, .26);
  transform: translateY(-1px);
}

.login-card .login-submit:focus-visible {
  outline: 3px solid rgba(129, 192, 96, .45);
  outline-offset: 3px;
}

.login-card .login-submit:disabled {
  cursor: wait;
  opacity: .72;
}

.login-submit svg {
  width: 18px;
  height: 18px;
}

.login-spinner {
  display: none;
  width: 20px;
  height: 20px;
  border: 2px solid rgba(255, 255, 255, .45);
  border-top-color: #fff;
  border-radius: 50%;
  animation: login-spin .7s linear infinite;
}

.login-submit.is-loading .login-spinner {
  display: block;
}

.login-submit.is-loading > svg {
  display: none;
}

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

@media (max-width: 900px) and (min-width: 701px) {
  .login-screen {
    grid-template-columns: minmax(280px, 44%) minmax(0, 56%);
    width: calc(100vw - 32px);
    height: min(640px, calc(100vh - 32px));
    border-radius: 22px;
  }

  .login-card {
    padding: 28px;
  }
}

@media (max-width: 700px) {
  .login-screen {
    grid-template-columns: 1fr;
    width: min(380px, calc(100vw - 28px));
    height: auto;
    min-height: 0;
    max-height: calc(100vh - 28px);
    padding: 0;
    overflow-y: auto;
    border-radius: 22px;
  }

  .login-visual {
    display: none;
  }

  .login-card {
    width: 100%;
    height: auto;
    min-height: 0;
    padding: 28px 22px 26px;
    border-left: 0;
    border-radius: 0;
    box-shadow: none;
    margin: 0;
  }

  .login-brand-logo {
    width: 150px;
    margin-bottom: 8px;
  }

  .login-card h1 {
    font-size: 19px;
  }

  .login-card form {
    margin-top: 17px;
  }
}

@media (max-height: 760px) and (min-width: 701px) {
  .login-card {
    padding-top: 24px;
    padding-bottom: 20px;
  }

  .login-brand-logo {
    width: 150px;
    max-height: 68px;
    margin-bottom: 6px;
  }

  .login-card h1 {
    font-size: 20px;
  }

  .login-card-header p {
    margin-top: 5px;
    font-size: 16px;
  }

  .login-card form {
    margin-top: 15px;
    gap: 6px;
  }

  .login-field {
    gap: 5px;
  }

  .field-error {
    min-height: 10px;
  }

  .login-card .login-input-wrap input {
    height: 48px;
  }

  .login-card .login-submit {
    height: 50px;
  }

}

@media (prefers-reduced-motion: reduce) {
  .login-card *,
  .login-card *::before,
  .login-card *::after {
    scroll-behavior: auto !important;
    transition: none !important;
    animation-duration: .01ms !important;
  }
}

/* Final centered login layout */
.login-screen {
  position: fixed;
  inset: 0;
  display: grid;
  grid-template-columns: 1fr;
  place-items: center;
  width: auto;
  height: auto;
  min-height: 100vh;
  padding: 24px;
  overflow-y: auto;
  border: 0;
  border-radius: 0;
  background:
    radial-gradient(circle at 86% 14%, rgba(129, 192, 96, .16), transparent 26%),
    linear-gradient(145deg, #dfe9e2 0%, #eef5f0 48%, #d8e5dc 100%);
  box-shadow: none;
  transform: none;
  clip-path: none;
}

.login-card {
  display: block;
  width: min(360px, 100%);
  height: auto;
  padding: 38px 38px 34px;
  border: 1px solid rgba(216, 224, 221, .9);
  border-radius: 22px;
  background: rgba(255, 255, 255, .98);
  box-shadow: 0 24px 60px rgba(24, 73, 48, .14);
}

.login-card-header,
.login-card form {
  width: 100%;
}

.login-card-header {
  text-align: left;
}

.login-brand-logo {
  width: 190px;
  max-height: 92px;
  margin-bottom: 12px;
}

.login-card h1 {
  color: var(--login-primary);
  font-size: 28px;
  font-weight: 500;
  line-height: 1.2;
}

.login-card-header p {
  margin: 3px 0 0;
  color: var(--login-muted);
  font-size: 11px;
  white-space: normal;
}

.login-card form {
  gap: 11px;
  margin-top: 22px;
}

.login-field {
  gap: 0;
}

.login-field-label {
  color: #20343c;
  font-size: 13px;
  font-weight: 500;
}

.field-error:empty {
  display: none;
}

.login-card .login-input-wrap input {
  height: 44px;
  padding-left: 42px;
  border-radius: 8px;
  font-size: 12px;
}

.login-input-wrap > svg {
  left: 16px;
  width: 18px;
  height: 18px;
}

.login-card .remember-login {
  gap: 8px;
  width: fit-content;
  font-size: 12px;
}

.login-card .remember-login > span {
  font-size: 12px;
}

.login-card .remember-login input {
  width: 16px;
  height: 16px;
}

.login-card .login-submit {
  height: 45px;
  margin-top: 6px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
}

.login-footer {
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px solid #e4e9e7;
  color: var(--login-muted);
  font-size: 11px;
  text-align: center;
}

@media (max-width: 700px) {
  .login-screen {
    padding: 16px;
  }

  .login-card {
    width: min(350px, 100%);
    padding: 32px 28px 30px;
    border-radius: 20px;
  }

  .login-card h1 {
    font-size: 26px;
  }
}

@media (max-height: 700px) and (min-width: 701px) {
  .login-card {
    padding-top: 28px;
    padding-bottom: 26px;
  }

  .login-card h1 {
    font-size: 24px;
  }

  .login-card form {
    margin-top: 18px;
    gap: 9px;
  }

  .login-card .login-input-wrap input {
    height: 42px;
  }

  .login-card .login-submit {
    height: 44px;
  }

  .login-footer {
    margin-top: 15px;
    padding-top: 12px;
  }
}
