:root {
  --color-brand: #0891b2;
  --color-brand-dark: #0e7490;
  --color-brand-soft: #cffafe;
  --color-surface: #ffffff;
  --color-background: #f0fdfa;
  --color-border: #cfe7ea;
  --color-text: #1f2937;
  --font-interface: "Noto Sans Thai", "Inter", "Leelawadee UI", sans-serif;
}

html {
  min-height: 100%;
}

body {
  min-height: 100%;
  margin: 0;
  background: var(--color-background);
  color: var(--color-text);
  font-family: var(--font-interface);
  font-feature-settings: "kern";
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

svg {
  stroke-linecap: round;
  stroke-linejoin: round;
}

::selection {
  background: var(--color-brand-soft);
  color: #164e63;
}

[hidden] {
  display: none !important;
}

body::before {
  position: fixed;
  inset: 0;
  z-index: -2;
  content: "";
  pointer-events: none;
  background:
    radial-gradient(circle at 9% 8%, rgba(34, 211, 238, .12), transparent 30rem),
    radial-gradient(circle at 94% 84%, rgba(45, 212, 191, .11), transparent 28rem),
    linear-gradient(135deg, #effcfd 0%, #fbfefe 52%, #f4fbfc 100%);
}

.dot-grid {
  background-image: radial-gradient(rgba(8, 145, 178, .11) .75px, transparent .75px);
  background-size: 20px 20px;
  -webkit-mask-image: linear-gradient(to bottom right, black, transparent 72%);
  mask-image: linear-gradient(to bottom right, black, transparent 72%);
}

.login-shell {
  display: grid;
  width: 100%;
  max-width: 1120px;
  align-items: center;
  gap: clamp(4.5rem, 7vw, 7.5rem);
}

.field {
  box-sizing: border-box;
  width: 100%;
  height: 3rem;
  border: 1px solid var(--color-border);
  border-radius: .75rem;
  background: var(--color-surface);
  color: #1e293b;
  font-size: .875rem;
  outline: none;
  transition:
    border-color 180ms ease,
    box-shadow 180ms ease;
}

.field::placeholder {
  color: #94a3b8;
}

.field:hover {
  border-color: #a9ced4;
}

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

.field:-webkit-autofill,
.field:-webkit-autofill:hover,
.field:-webkit-autofill:active {
  border-color: var(--color-border);
  background: var(--color-surface);
  -webkit-box-shadow: 0 0 0 1000px var(--color-surface) inset;
  box-shadow: 0 0 0 1000px var(--color-surface) inset;
  -webkit-text-fill-color: #1e293b;
  caret-color: #1e293b;
}

.field:-webkit-autofill:focus {
  border-color: var(--color-brand);
  -webkit-box-shadow:
    0 0 0 1000px var(--color-surface) inset,
    0 0 0 3px var(--color-brand-soft);
  box-shadow:
    0 0 0 1000px var(--color-surface) inset,
    0 0 0 3px var(--color-brand-soft);
}

.field:autofill {
  background: var(--color-surface);
  color: #1e293b;
}

/* เบราว์เซอร์ไม่ยิง input event ตอน autofill — ใช้ animation เป็นสัญญาณให้ JS รู้แทน */
@keyframes field-autofill-start {
  from { outline-color: transparent; }
  to { outline-color: transparent; }
}

.field:-webkit-autofill {
  animation: field-autofill-start 1ms;
}

.field::-ms-reveal,
.field::-ms-clear {
  display: none;
}

/* ห้ามใช้ :read-only ที่นี่ — ช่อง input ตั้ง readonly ไว้ตั้งแต่แรกเพื่อกัน autofill */
.field:disabled {
  cursor: not-allowed;
  background: #f8fafc;
  opacity: .72;
}

.label {
  display: block;
  margin-bottom: .5rem;
  color: #334155;
  font-size: .8125rem;
  font-weight: 500;
}

.login-button {
  display: inline-flex;
  width: 100%;
  height: 3rem;
  align-items: center;
  justify-content: center;
  gap: .5rem;
  border: 1px solid var(--color-brand);
  border-radius: .75rem;
  background: var(--color-brand);
  box-shadow: 0 5px 18px rgba(8, 145, 178, .2);
  color: #ffffff;
  font-size: .875rem;
  font-weight: 600;
  transition:
    background-color 180ms ease,
    border-color 180ms ease,
    box-shadow 180ms ease,
    transform 180ms ease;
}

.login-button:hover {
  border-color: var(--color-brand-dark);
  background: var(--color-brand-dark);
  box-shadow: 0 10px 28px rgba(8, 145, 178, .25);
  transform: translateY(-1px);
}

.login-button:focus-visible,
.icon-button:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--color-brand-soft);
}

.login-button:active {
  transform: translateY(0);
}

.login-button:disabled {
  pointer-events: none;
  opacity: .65;
}

.icon-button {
  display: inline-flex;
  width: 2.25rem;
  height: 2.25rem;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: .5rem;
  background: transparent;
  color: #94a3b8;
  transition:
    background-color 180ms ease,
    color 180ms ease;
}

.icon-button:hover {
  background: #f5f5f4;
  color: #334155;
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: .875rem;
}

.brand-icon {
  display: flex;
  width: 3.5rem;
  height: 3.5rem;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  border-radius: 1rem;
  background: var(--color-brand);
  box-shadow: 0 12px 28px rgba(8, 145, 178, .18);
  color: #ffffff;
}

.brand-icon svg {
  width: 1.5rem;
  height: 1.5rem;
}

.brand-name {
  margin: 0;
  color: #0f172a;
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: -.02em;
}

.brand-subtitle {
  margin: .1rem 0 0;
  color: #64748b;
  font-size: .8rem;
}

.system-badge {
  display: inline-flex;
  align-items: center;
  gap: .55rem;
  margin-top: 4.25rem;
  border: 1px solid rgba(8, 145, 178, .18);
  border-radius: 999px;
  background: rgba(236, 254, 255, .72);
  padding: .5rem .85rem;
  color: #0e7490;
  font-size: .75rem;
  font-weight: 500;
}

.system-badge span {
  width: .45rem;
  height: .45rem;
  border-radius: 999px;
  background: #14b8a6;
  box-shadow: 0 0 0 4px rgba(20, 184, 166, .1);
}

.login-card {
  width: 100%;
  max-width: 460px;
  justify-self: end;
  border: 1px solid rgba(207, 231, 234, .95);
  border-radius: 26px;
  background: rgba(255, 255, 255, .96);
  padding: 2.5rem;
  box-shadow:
    0 28px 70px rgba(8, 145, 178, .09),
    0 2px 6px rgba(15, 23, 42, .025);
  backdrop-filter: blur(12px);
  animation: card-in 420ms cubic-bezier(.2, .8, .2, 1) both;
}

.brand-intro {
  width: 100%;
  max-width: 540px;
  animation: intro-in 480ms 80ms cubic-bezier(.2, .8, .2, 1) both;
}

.brand-copy {
  margin-top: 1.75rem;
  max-width: 34rem;
}

.brand-title {
  margin: 0;
  color: #0f172a;
  font-size: clamp(2.45rem, 3vw, 3rem);
  font-weight: 600;
  letter-spacing: -.045em;
  line-height: 1.15;
}

.brand-title span {
  color: var(--color-brand);
}

.brand-description {
  max-width: 29rem;
  margin: 1.5rem 0 0;
  color: #64748b;
  font-size: .95rem;
  line-height: 1.85;
}

.access-note {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  margin-top: 2.5rem;
  color: #94a3b8;
  font-size: .75rem;
}

.spinner {
  animation: spin .75s linear infinite;
}

@keyframes card-in {
  from {
    opacity: 0;
    transform: translateY(10px) scale(.99);
  }

  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

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

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

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

@media (min-width: 1024px) {
  .login-shell {
    grid-template-columns: minmax(0, 1fr) 460px;
  }
}

@media (max-width: 1023px) {
  .login-shell {
    display: block;
    max-width: 460px;
  }

  .login-card {
    justify-self: auto;
  }
}

@media (max-width: 639px) {
  .login-card {
    border-radius: 22px;
    padding: 1.5rem;
  }
}

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