:root {
  --card: #ffffff;
  --surface: #f8f9fb;
  --body-bg: #eef0f5;
  --text-primary: #1a1d23;
  --text-secondary: #64748b;
  --text-tertiary: #94a3b8;
  --border: #e2e5ea;
  --accent: #3b82f6;
  --accent-hover: #2563eb;
  --accent-light: #eff6ff;
  --danger: #ef4444;
  --focus-ring: 0 0 0 3px rgba(59, 130, 246, .25);
  --shadow: 0 12px 36px rgba(15, 23, 42, .10);
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  color: var(--text-primary);
  background: var(--body-bg);
  font-family: system-ui, -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
}

button,
input {
  font: inherit;
}

.login-stage {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 48px 20px 96px;
}

.login-window {
  width: min(480px, 100%);
  min-height: 458px;
  padding: 0 48px 36px;
  border-radius: 16px;
  background: var(--card);
  box-shadow: var(--shadow);
}

.brand-space {
  height: 54px;
}

.brand {
  margin: 0;
  color: var(--accent);
  font-family: "SF Mono", Menlo, Consolas, monospace;
  font-size: clamp(36px, 9vw, 48px);
  font-weight: 400;
  line-height: 1;
  letter-spacing: 1px;
  text-align: center;
}

.subtitle {
  margin: 18px 0 24px;
  color: var(--text-secondary);
  font-size: 16px;
  text-align: center;
}

.login-form {
  display: grid;
  gap: 14px;
}

.role-fieldset {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.role-fieldset legend {
  margin-bottom: 10px;
  color: var(--text-secondary);
  font-size: 15px;
}

.role-options {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.role-option {
  min-width: 0;
  height: 42px;
  padding: 0 8px;
  overflow: hidden;
  color: var(--text-secondary);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 15px;
  cursor: pointer;
  text-overflow: ellipsis;
  white-space: nowrap;
  transition: color .15s ease, background-color .15s ease, border-color .15s ease, box-shadow .15s ease;
}

.role-option:hover {
  color: var(--accent-hover);
  border-color: var(--accent);
}

.role-option.active {
  color: var(--accent);
  background: var(--accent-light);
  border-color: var(--accent);
  font-weight: 600;
}

.role-option:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

.field {
  position: relative;
  display: block;
}

.field input {
  width: 100%;
  height: 44px;
  padding: 0 44px;
  color: var(--text-primary);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  outline: none;
  font-size: 16px;
  transition: border-color .15s ease, box-shadow .15s ease;
}

.field input::placeholder {
  color: var(--text-tertiary);
}

.field input:focus {
  border-color: var(--accent);
  box-shadow: var(--focus-ring);
}

.field input.invalid {
  border-color: var(--danger);
}

.field-icon,
.eye {
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.field-icon {
  position: absolute;
  z-index: 1;
  top: 13px;
  left: 13px;
  width: 18px;
  height: 18px;
  color: var(--text-tertiary);
  pointer-events: none;
}

.field:focus-within .field-icon {
  color: var(--accent);
}

.eye-button {
  position: absolute;
  top: 7px;
  right: 7px;
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  padding: 0;
  color: var(--text-tertiary);
  background: transparent;
  border: 0;
  border-radius: 6px;
  cursor: pointer;
}

.eye-button:hover,
.eye-button:focus-visible {
  color: var(--text-secondary);
  background: var(--surface);
  outline: none;
}

.eye {
  width: 18px;
  height: 18px;
}

.eye-closed {
  display: none;
}

.eye-button.showing .eye-open {
  display: none;
}

.eye-button.showing .eye-closed {
  display: block;
}

.form-message {
  min-height: 20px;
  margin: 0;
  color: var(--danger);
  font-size: 14px;
  line-height: 20px;
  text-align: center;
}

.login-button {
  width: 100%;
  height: 42px;
  color: #fff;
  background: var(--accent);
  border: 0;
  border-radius: 8px;
  font-size: 18px;
  font-weight: 600;
  cursor: pointer;
}

.login-button:hover {
  background: var(--accent-hover);
}

.login-button:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

.login-button:disabled {
  cursor: wait;
  opacity: .68;
}

.notice {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  margin: 24px 0 0;
  color: var(--text-tertiary);
  font-size: 13px;
}

.notice svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.footer {
  position: fixed;
  right: 20px;
  bottom: 26px;
  left: 20px;
  color: var(--text-tertiary);
  font-size: 13px;
  line-height: 1.5;
  text-align: center;
}

.footer a {
  color: var(--text-secondary);
  text-decoration: none;
}

.footer a:hover {
  color: var(--accent);
}

.separator {
  margin: 0 6px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 560px) {
  .login-stage {
    align-items: start;
    padding-top: 28px;
  }

  .login-window {
    padding-right: 24px;
    padding-left: 24px;
  }

  .role-option {
    padding: 0 5px;
    font-size: 14px;
  }

  .footer {
    position: static;
    padding: 0 20px 24px;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
  }
}
