:root {
  --primary: #4d7cff;
  --primary-dark: #2f55c9;
  --surface: rgba(255, 255, 255, 0.92);
  --surface-alt: rgba(241, 245, 255, 0.78);
  --border: rgba(148, 163, 184, 0.32);
  --text: #1f2937;
  --muted: #6b7280;
  --danger: #dc2626;
  font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(1.75rem, 5vw, 3rem);
  background: radial-gradient(circle at 12% 18%, rgba(77, 124, 255, 0.18), transparent 42%),
              radial-gradient(circle at 88% 82%, rgba(56, 189, 248, 0.18), transparent 46%),
              #eef2ff;
  color: var(--text);
}

.container {
  width: 100%;
  display: flex;
  justify-content: center;
}

article {
  width: min(420px, 92vw);
  background: var(--surface);
  border-radius: 1.4rem;
  border: 1px solid var(--border);
  padding: clamp(2.1rem, 4vw, 2.85rem);
  box-shadow: 0 34px 90px -42px rgba(15, 23, 42, 0.55);
  display: flex;
  flex-direction: column;
  gap: 1.6rem;
  align-items: stretch;
  position: relative;
  overflow: hidden;
}

article::before,
article::after {
  content: '';
  position: absolute;
  border-radius: 999px;
  filter: blur(70px);
  opacity: 0.45;
  pointer-events: none;
}

article::before {
  width: 180px;
  height: 180px;
  background: rgba(77, 124, 255, 0.28);
  top: -70px;
  right: -60px;
}

article::after {
  width: 200px;
  height: 200px;
  background: rgba(56, 189, 248, 0.3);
  bottom: -90px;
  left: -70px;
}

form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  position: relative;
  z-index: 1;
}

form h2 {
  margin: 0;
  font-size: clamp(1.02rem, 1.5vw, 1.28rem);
  line-height: 1.18;
  font-weight: 600;
  text-align: center;
  color: var(--text);
  letter-spacing: 0.01em;
}

.system-title {
  display: flex;
  justify-content: center;
  margin: -0.55rem 0 0.3rem;
}

.system-title img {
  width: clamp(82px, 20vw, 104px);
  height: auto;
  border-radius: 1rem;
  padding: 0;
  background: transparent;
  border: none;
  box-shadow: none;
}

article > p:not(.footer) {
  margin: 0;
  text-align: center;
  font-size: 0.92rem;
  color: var(--muted);
}

#errorBox {
  display: none;
  margin: -0.2rem 0 0;
  padding: 0.85rem 1rem;
  border-radius: 0.95rem;
  border: 1px solid rgba(220, 38, 38, 0.28);
  background: rgba(254, 226, 226, 0.72);
  color: var(--danger);
  font-weight: 600;
  text-align: center;
}

#errorBox:empty {
  display: none !important;
}

.input-group {
  position: relative;
  display: flex;
  flex-direction: column;
}

.input-group input {
  width: 100%;
  border: 1px solid rgba(148, 163, 184, 0.45);
  border-radius: 0.95rem;
  padding: 0.95rem 1rem;
  font-size: 0.98rem;
  background: rgba(255, 255, 255, 0.96);
  color: var(--text);
  transition: border 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.input-group input::placeholder {
  color: transparent;
}

.input-group label {
  position: absolute;
  top: 50%;
  left: 1rem;
  transform: translateY(-50%);
  font-size: 0.98rem;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.96);
  padding: 0 0.4rem;
  pointer-events: none;
  transition: all 0.2s ease;
}

.input-group input:focus {
  outline: none;
  border-color: rgba(77, 124, 255, 0.75);
  box-shadow: 0 0 0 4px rgba(77, 124, 255, 0.22);
  background: rgba(255, 255, 255, 1);
}

.input-group input:focus + label,
.input-group input:not(:placeholder-shown) + label {
  top: 0;
  transform: translateY(-50%) scale(0.92);
  font-size: 0.8rem;
  color: var(--primary);
}

.toggle-password {
  position: absolute;
  right: 0.9rem;
  top: 50%;
  transform: translateY(-50%);
  border: none;
  background: transparent;
  color: var(--primary);
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
  padding: 0.3rem 0.45rem;
  border-radius: 0.6rem;
  transition: background 0.18s ease, color 0.18s ease;
}

.toggle-password:hover,
.toggle-password:focus-visible {
  background: rgba(77, 124, 255, 0.14);
  color: var(--primary-dark);
}

.submit {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  border: none;
  border-radius: 0.95rem;
  padding: 0.95rem 1.2rem;
  font-size: 1rem;
  font-weight: 600;
  color: #fff;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  cursor: pointer;
  box-shadow: 0 22px 46px -26px rgba(47, 85, 201, 0.75);
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.submit:hover,
.submit:focus-visible {
  transform: translateY(-1px);
  box-shadow: 0 26px 52px -28px rgba(47, 85, 201, 0.82);
}

.submit.is-loading {
  opacity: 0.7;
  pointer-events: none;
}

a {
  color: var(--primary);
  text-decoration: none;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  transition: opacity 0.18s ease, transform 0.18s ease;
}

a i {
  font-size: 1rem;
}

a:hover,
a:focus-visible {
  opacity: 0.82;
  transform: translateX(2px);
}

.footer {
  margin: 0;
  font-size: 0.82rem;
  color: var(--muted);
  text-align: center;
}

input.valid {
  border-color: rgba(22, 163, 74, 0.75) !important;
  box-shadow: 0 0 0 4px rgba(22, 163, 74, 0.2) !important;
}

input.invalid {
  border-color: rgba(220, 38, 38, 0.78) !important;
  box-shadow: 0 0 0 4px rgba(220, 38, 38, 0.18) !important;
}

#loadingOverlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(15, 23, 42, 0.32);
  backdrop-filter: blur(6px);
  z-index: 2000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.24s ease;
}

#loadingOverlay.active {
  opacity: 1;
  pointer-events: auto;
}

#loadingOverlay[hidden] {
  display: none !important;
}

#loadingOverlay .overlay-inner {
  background: rgba(15, 23, 42, 0.9);
  color: #e2e8f0;
  padding: 2.1rem 2.6rem;
  border-radius: 1.15rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  align-items: center;
  min-width: 240px;
  text-align: center;
  box-shadow: 0 32px 72px -36px rgba(15, 23, 42, 0.7);
}

.spinner {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  border: 5px solid rgba(226, 232, 240, 0.35);
  border-top-color: #fff;
  animation: loginSpin 0.82s linear infinite;
}

@keyframes loginSpin {
  to { transform: rotate(360deg); }
}

#loadingText {
  margin: 0;
  font-weight: 600;
  letter-spacing: 0.02em;
}

@media (max-width: 540px) {
  body {
    padding: 1.5rem;
  }

  article {
    padding: 1.9rem;
    border-radius: 1.2rem;
  }

  .system-title img {
    width: 82px;
  }
}

@media (max-width: 420px) {
  .toggle-password {
    right: 0.75rem;
  }
}
