:root {
  --brand: #0d9488;
  --brand-deep: #0f766e;
  --brand-hover: #0a665f;
  --brand-soft: #ecfdf5;
  --background: #f5f6f8;
  --paper: #ffffff;
  --surface: #f7f8fa;
  --line: #e4e7eb;
  --line-strong: #cfd5dc;
  --text: #1f2328;
  --text-secondary: #4a535d;
  --muted: #66707a;
  --danger: #c92a2a;
  --danger-soft: #fff5f5;
  color-scheme: light;
  font-synthesis: none;
}

* { box-sizing: border-box; }
html { min-width: 320px; min-height: 100%; }
body {
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0;
  background: var(--background);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

button, input { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { color: inherit; }
svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
[hidden] { display: none !important; }

:focus-visible {
  outline: 3px solid rgba(13, 148, 136, .2);
  outline-offset: 2px;
}

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  min-height: 64px;
  padding: 0 24px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, .96);
}

.brand,
.back-link {
  display: inline-flex;
  align-items: center;
  color: var(--text);
  text-decoration: none;
}

.brand { gap: 10px; font-size: 15px; font-weight: 720; }
.brand img { display: block; width: 34px; height: 34px; }
.back-link {
  gap: 6px;
  min-height: 38px;
  padding: 0 9px;
  border-radius: 7px;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 600;
}
.back-link:hover { background: var(--surface); color: var(--text); }
.back-link svg { width: 16px; height: 16px; }

.auth-shell {
  display: grid;
  justify-items: center;
  align-content: center;
  min-height: calc(100vh - 64px);
  min-height: calc(100dvh - 64px);
  padding: 48px 20px 40px;
}

.auth-panel {
  width: min(100%, 440px);
  padding: 32px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--paper);
}

.panel-heading {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr);
  align-items: start;
  gap: 14px;
}

.heading-icon {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 10px;
  background: var(--brand-soft);
  color: var(--brand-deep);
}
.heading-icon svg { width: 21px; height: 21px; }

.section-label {
  margin: 1px 0 4px;
  color: var(--brand-deep);
  font-size: 12px;
  font-weight: 700;
}

h1 {
  margin: 0;
  font-size: 22px;
  font-weight: 730;
  line-height: 1.35;
  letter-spacing: 0;
  text-wrap: balance;
}

.heading-copy {
  margin: 8px 0 0;
  color: var(--muted);
  line-height: 1.65;
  text-wrap: pretty;
}

.status-placeholder {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 48px;
  margin-top: 28px;
  padding: 0 14px;
  border-radius: 8px;
  background: var(--surface);
  color: var(--text-secondary);
  font-size: 13px;
}

.loading-spinner,
.button-spinner {
  width: 17px;
  height: 17px;
  flex: 0 0 auto;
  border: 2px solid #cbd5d4;
  border-top-color: var(--brand-deep);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}

#authForm { margin-top: 28px; }
.field-group + .field-group { margin-top: 18px; }
.field-group > label {
  display: block;
  margin-bottom: 7px;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 650;
}

.password-field { position: relative; }
.password-field input {
  width: 100%;
  height: 46px;
  padding: 0 46px 0 13px;
  border: 1px solid var(--line-strong);
  border-radius: 9px;
  background: var(--paper);
  color: var(--text);
  outline: 0;
  transition: border-color .16s ease, box-shadow .16s ease;
}
.password-field input:hover { border-color: #aeb6bf; }
.password-field input:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(13, 148, 136, .12);
}
.password-field input[aria-invalid="true"] {
  border-color: var(--danger);
  box-shadow: 0 0 0 3px rgba(201, 42, 42, .09);
}

.visibility-button {
  position: absolute;
  top: 5px;
  right: 5px;
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}
.visibility-button:hover { background: var(--surface); color: var(--text); }
.visibility-button svg { width: 17px; height: 17px; }
.visibility-button .eye-closed { display: none; }
.visibility-button.is-visible .eye-open { display: none; }
.visibility-button.is-visible .eye-closed { display: block; }

.field-hint {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.form-message {
  margin-top: 18px;
  padding: 10px 12px;
  border: 1px solid #f3c2c2;
  border-radius: 8px;
  background: var(--danger-soft);
  color: #9f2020;
  font-size: 13px;
  line-height: 1.5;
}

.submit-button,
.retry-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  border-radius: 9px;
  font-weight: 700;
  cursor: pointer;
}

.submit-button {
  width: 100%;
  margin-top: 22px;
  padding: 0 16px;
  border: 1px solid var(--brand-deep);
  background: var(--brand-deep);
  color: #fff;
  transition: background-color .16s ease, border-color .16s ease;
}
.submit-button:hover { border-color: var(--brand-hover); background: var(--brand-hover); }
.submit-button:active { background: #075b55; }
.submit-button:disabled { cursor: wait; opacity: .72; }
.submit-button .button-spinner { display: none; border-color: rgba(255,255,255,.38); border-top-color: #fff; }
.submit-button.is-loading .button-spinner { display: block; }
.submit-button.is-loading .button-icon { display: none; }
.button-icon { width: 17px; height: 17px; }

.retry-button {
  width: 100%;
  margin-top: 22px;
  padding: 0 14px;
  border: 1px solid var(--line-strong);
  background: var(--paper);
}
.retry-button:hover { border-color: var(--brand); background: var(--brand-soft); color: var(--brand-deep); }

.security-note {
  display: flex;
  align-items: center;
  gap: 7px;
  margin: 18px 0 0;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}
.security-note svg { width: 15px; height: 15px; color: var(--brand-deep); }

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

@media (max-width: 560px) {
  .site-header { min-height: 58px; padding: 0 16px; }
  .brand img { width: 32px; height: 32px; }
  .back-link { padding: 0 4px; }
  .auth-shell {
    align-content: start;
    min-height: calc(100vh - 58px);
    min-height: calc(100dvh - 58px);
    padding: 28px 16px 32px;
  }
  .auth-panel { padding: 24px 20px; border-radius: 10px; }
  .panel-heading { grid-template-columns: 40px minmax(0, 1fr); gap: 12px; }
  .heading-icon { width: 40px; height: 40px; border-radius: 9px; }
  h1 { font-size: 20px; }
  .heading-copy { margin-top: 6px; }
  #authForm, .status-placeholder { margin-top: 24px; }
  .security-note { max-width: 300px; justify-content: center; }
}

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