:root {
  --page-bg: #f4f7fb;
  --surface: #ffffff;
  --text: #10203d;
  --text-secondary: #5f6b7d;
  --border: #d8dee8;
  --border-hover: #aab4c3;
  --focus: #246bfd;
  --accent: #df1733;
  --accent-hover: #c90f29;
  --danger: #d92d42;
  --success: #16a36a;
  --radius: 10px;
  --shadow: 0 18px 52px rgba(16, 32, 61, 0.09), 0 2px 8px rgba(16, 32, 61, 0.05);
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--page-bg);
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  background: var(--page-bg);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

button,
input {
  font: inherit;
}

button,
a,
input,
.agreement-label {
  -webkit-tap-highlight-color: transparent;
}

a {
  color: inherit;
  text-decoration: none;
}

.agreement-label a:hover {
  text-decoration: underline;
  text-underline-offset: 3px;
}

.page-main {
  min-height: calc(100vh - 44px);
  padding: 32px 24px 24px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.register-panel {
  width: min(100%, 648px);
  padding: 38px 44px 40px;
  border: 1px solid rgba(205, 213, 224, 0.9);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.panel-heading {
  margin-bottom: 28px;
  text-align: center;
}

.panel-heading h1,
.success-view h1 {
  margin: 0;
  color: #0b1c3a;
  font-size: clamp(28px, 3vw, 34px);
  font-weight: 700;
  line-height: 1.25;
  letter-spacing: -0.02em;
}

.form-field {
  margin-bottom: 17px;
}

.form-field label,
.captcha-label {
  display: block;
  margin-bottom: 7px;
  color: #1d2b43;
  font-size: 14px;
  font-weight: 600;
}

.form-field input,
.captcha-input {
  width: 100%;
  height: 48px;
  padding: 0 15px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  outline: none;
  background: #ffffff;
  color: var(--text);
  font-size: 14px;
  transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

.form-field input::placeholder,
.captcha-input::placeholder {
  color: #9aa3b2;
}

.form-field input:hover,
.captcha-input:hover {
  border-color: var(--border-hover);
}

.form-field input:focus,
.captcha-input:focus {
  border-color: var(--focus);
  box-shadow: 0 0 0 3px rgba(36, 107, 253, 0.12);
}

.form-field.has-error input,
.captcha-input.has-error {
  border-color: var(--danger);
}

.field-error {
  min-height: 17px;
  margin: 4px 0 -5px;
  color: var(--danger);
  font-size: 12px;
  line-height: 17px;
}

.code-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 144px;
  gap: 12px;
}

.code-button {
  height: 48px;
  padding: 0 14px;
  border: 1px solid #1e6bf0;
  border-radius: var(--radius);
  background: #ffffff;
  color: #1769e8;
  cursor: pointer;
  font-weight: 600;
  transition: background 160ms ease, color 160ms ease, border-color 160ms ease;
}

.code-button:hover:not(:disabled) {
  background: #f2f7ff;
}

.code-button:disabled {
  border-color: #d6dce5;
  background: #f7f8fa;
  color: #a1a9b5;
  cursor: not-allowed;
}

.password-wrap {
  position: relative;
}

.password-wrap input {
  padding-right: 48px;
}

.password-toggle {
  position: absolute;
  top: 5px;
  right: 6px;
  width: 38px;
  height: 38px;
  padding: 8px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #7b8798;
  cursor: pointer;
}

.password-toggle:hover {
  background: #f3f5f8;
  color: #33425a;
}

.password-toggle svg,
.dialog-close svg {
  display: block;
  width: 100%;
  height: 100%;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.agreement-field {
  margin: 2px 0 18px;
}

.agreement-label {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  color: #445066;
  cursor: pointer;
  line-height: 20px;
}

.agreement-label input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.checkbox-ui {
  flex: 0 0 auto;
  width: 18px;
  height: 18px;
  margin-top: 1px;
  border: 1px solid #9ba6b6;
  border-radius: 4px;
  background: #ffffff;
  transition: background 160ms ease, border-color 160ms ease, box-shadow 160ms ease;
}

.agreement-label input:focus-visible + .checkbox-ui {
  box-shadow: 0 0 0 3px rgba(36, 107, 253, 0.16);
}

.agreement-label input:checked + .checkbox-ui {
  border-color: var(--focus);
  background: var(--focus) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='m3.4 8.3 2.7 2.8 6-6.1' fill='none' stroke='white' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center/14px no-repeat;
}

.agreement-label a {
  color: #1769e8;
}

.agreement-field .field-error {
  margin-left: 28px;
}

.submit-button {
  width: 100%;
  min-height: 50px;
  padding: 0 22px;
  border: 0;
  border-radius: var(--radius);
  background: var(--accent);
  color: #ffffff;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.03em;
  box-shadow: 0 8px 18px rgba(223, 23, 51, 0.16);
  transition: background 160ms ease, transform 160ms ease, box-shadow 160ms ease;
}

.submit-button:hover:not(:disabled) {
  background: var(--accent-hover);
  box-shadow: 0 10px 22px rgba(223, 23, 51, 0.22);
  transform: translateY(-1px);
}

.submit-button:disabled {
  background: #eaa7b1;
  cursor: not-allowed;
  box-shadow: none;
}

.button-spinner {
  display: none;
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255, 255, 255, 0.45);
  border-top-color: #ffffff;
  border-radius: 50%;
  animation: spin 700ms linear infinite;
}

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

.success-view {
  min-height: 550px;
  padding: 76px 24px 28px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.success-view[hidden] {
  display: none;
}

.success-icon {
  width: 82px;
  height: 82px;
  margin-bottom: 28px;
  border-radius: 50%;
  background: #e8f8f1;
  color: var(--success);
  display: grid;
  place-items: center;
}

.success-icon svg {
  width: 48px;
  height: 48px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.success-view p {
  max-width: 360px;
  margin: 16px 0 34px;
  color: var(--text-secondary);
  font-size: 15px;
}

.success-login {
  max-width: 320px;
}

.site-footer {
  height: 44px;
  color: #7c8797;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1000;
  padding: 24px;
  background: rgba(7, 18, 38, 0.48);
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-backdrop[hidden],
.toast[hidden] {
  display: none;
}

.captcha-dialog {
  width: min(100%, 430px);
  padding: 26px;
  border-radius: 14px;
  background: #ffffff;
  box-shadow: 0 24px 70px rgba(7, 18, 38, 0.25);
}

.dialog-header {
  margin-bottom: 24px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.dialog-header h2 {
  margin: 0;
  color: #10203d;
  font-size: 20px;
  line-height: 1.3;
}

.dialog-header p {
  margin: 5px 0 0;
  color: var(--text-secondary);
  font-size: 13px;
}

.dialog-close {
  width: 34px;
  height: 34px;
  padding: 7px;
  border: 0;
  border-radius: 8px;
  background: #f2f4f7;
  color: #677386;
  cursor: pointer;
}

.captcha-image-row {
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 14px;
}

.captcha-image-box {
  position: relative;
  flex: 0 0 176px;
  height: 54px;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #f6f8fb;
  display: grid;
  place-items: center;
}

.captcha-image-box img {
  display: block;
  max-width: 100%;
  max-height: 100%;
}

.captcha-loading {
  position: absolute;
  color: #8792a2;
  font-size: 12px;
}

.refresh-button {
  padding: 8px 0;
  border: 0;
  background: transparent;
  color: #1769e8;
  cursor: pointer;
}

.captcha-error {
  margin-bottom: 2px;
}

.dialog-actions {
  margin-top: 22px;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.dialog-secondary,
.dialog-primary {
  min-width: 92px;
  height: 40px;
  padding: 0 16px;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 600;
}

.dialog-secondary {
  border: 1px solid var(--border);
  background: #ffffff;
  color: #47546a;
}

.dialog-primary {
  border: 1px solid var(--focus);
  background: var(--focus);
  color: #ffffff;
}

.dialog-primary:disabled,
.dialog-secondary:disabled {
  cursor: wait;
  opacity: 0.62;
}

.toast {
  position: fixed;
  top: 82px;
  left: 50%;
  z-index: 1100;
  max-width: calc(100vw - 40px);
  padding: 11px 16px;
  border: 1px solid #cfe4da;
  border-radius: 9px;
  background: #effaf5;
  color: #14704b;
  box-shadow: 0 10px 30px rgba(16, 32, 61, 0.13);
  font-weight: 500;
  transform: translateX(-50%);
}

.toast.is-error {
  border-color: #f2ccd2;
  background: #fff2f4;
  color: #ad1931;
}

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

@media (max-width: 720px) {
  html,
  body {
    background: #ffffff;
  }

  .page-main {
    min-height: auto;
    padding: 24px 20px 12px;
    align-items: flex-start;
  }

  .register-panel {
    padding: 4px 0 24px;
    border: 0;
    border-radius: 0;
    box-shadow: none;
  }

  .panel-heading {
    margin-bottom: 26px;
  }

  .panel-heading h1,
  .success-view h1 {
    font-size: 28px;
  }

  .site-footer {
    background: #ffffff;
  }

  .success-view {
    min-height: 500px;
    padding-top: 70px;
  }
}

@media (max-width: 420px) {
  .code-row {
    grid-template-columns: minmax(0, 1fr) 120px;
    gap: 9px;
  }

  .code-button {
    padding: 0 8px;
  }

  .captcha-dialog {
    padding: 22px 20px;
  }

  .captcha-image-row {
    align-items: flex-start;
    flex-direction: column;
    gap: 5px;
  }

  .captcha-image-box {
    width: 100%;
    flex-basis: 54px;
  }
}

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