* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --text-main: #1f2329;
  --text-sub: #8a919e;
  --border: #e5e8ef;
  --bg: #f4f6fb;
  --danger: #ef4444;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(600px 400px at 15% 10%, rgba(99, 102, 241, 0.10), transparent 60%),
    radial-gradient(500px 380px at 85% 90%, rgba(168, 85, 247, 0.08), transparent 60%),
    var(--bg);
  padding: 24px;
  color: var(--text-main);
}

.card {
  width: 100%;
  max-width: 400px;
  background: #fff;
  border-radius: 20px;
  box-shadow: 0 8px 40px rgba(31, 41, 55, 0.08);
  padding: 40px 36px 32px;
  animation: rise 0.4s ease;
}

@keyframes rise {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

/* 品牌 */
.brand { text-align: center; margin-bottom: 28px; }

.brand-mark {
  width: 48px;
  height: 48px;
  margin: 0 auto 14px;
  border-radius: 14px;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  color: #fff;
  font-size: 22px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 16px rgba(99, 102, 241, 0.35);
}

.brand h1 { font-size: 20px; font-weight: 700; letter-spacing: 0.5px; }
.brand p { font-size: 13px; color: var(--text-sub); margin-top: 4px; }

/* 选项卡 */
.tabs {
  display: flex;
  background: #f2f4f9;
  border-radius: 12px;
  padding: 4px;
  margin-bottom: 24px;
  position: relative;
}

.tab {
  flex: 1;
  text-align: center;
  padding: 9px 0;
  font-size: 14px;
  color: #6b7280;
  border-radius: 9px;
  cursor: pointer;
  transition: all 0.2s;
  user-select: none;
}

.tab.active {
  background: #fff;
  color: var(--primary);
  font-weight: 600;
  box-shadow: 0 2px 8px rgba(31, 41, 55, 0.08);
}

/* 表单 */
.form-item { margin-bottom: 16px; }

.form-item label {
  display: block;
  font-size: 13px;
  color: #4b5563;
  margin-bottom: 6px;
}

.input-wrap { position: relative; }

.input-wrap .icon {
  position: absolute;
  left: 13px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  color: #b0b7c3;
  pointer-events: none;
}

.form-item input {
  width: 100%;
  padding: 11px 14px 11px 38px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 14px;
  outline: none;
  background: #fbfcfe;
  transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
}

.form-item input:focus {
  border-color: var(--primary);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.12);
}

.form-item input::placeholder { color: #c0c6d1; }

/* 验证码行 */
.code-row { display: flex; gap: 10px; }

.code-row .input-wrap { flex: 1; }

.btn-code {
  flex-shrink: 0;
  width: 112px;
  border: 1px solid var(--primary);
  background: #fff;
  color: var(--primary);
  border-radius: 10px;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-code:hover:not(:disabled) { background: rgba(79, 70, 229, 0.06); }
.btn-code:disabled { border-color: var(--border); color: var(--text-sub); cursor: not-allowed; }

/* 按钮 */
.btn {
  width: 100%;
  padding: 12px;
  border: none;
  border-radius: 10px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, opacity 0.2s, transform 0.1s;
}

.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.6; cursor: not-allowed; }

.btn-primary {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 4px 12px rgba(79, 70, 229, 0.3);
}

.btn-primary:hover:not(:disabled) { background: var(--primary-hover); }

.btn-github {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: #24292f;
  color: #fff;
}

.btn-github:hover:not(:disabled) { background: #1b1f23; }

.btn-github svg { width: 18px; height: 18px; fill: currentColor; }

.btn-outline {
  background: #fff;
  color: var(--primary);
  border: 1px solid var(--primary);
}

.btn-danger { background: var(--danger); color: #fff; }

/* 分隔线 */
.divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 20px 0;
  font-size: 12px;
  color: var(--text-sub);
}

.divider::before,
.divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* 消息提示 */
.message {
  display: none;
  padding: 10px 14px;
  border-radius: 10px;
  font-size: 13px;
  margin-bottom: 16px;
  word-break: break-all;
}

.message.error { display: block; background: #fef2f2; color: #dc2626; }
.message.success { display: block; background: #f0fdf4; color: #16a34a; }
.message.info { display: block; background: #eff6ff; color: #2563eb; }

/* 协议提示 */
.agreement {
  text-align: center;
  font-size: 12px;
  color: var(--text-sub);
  margin-top: 18px;
}

.agreement a { color: var(--primary); text-decoration: none; }

/* 登录成功面板 */
.profile { display: none; }
.profile.show { display: block; }
.auth-panel.hide { display: none; }

.avatar {
  width: 68px;
  height: 68px;
  border-radius: 50%;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  color: #fff;
  font-size: 28px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 14px;
  box-shadow: 0 6px 16px rgba(99, 102, 241, 0.35);
}

.profile-name {
  text-align: center;
  font-size: 18px;
  font-weight: 600;
}

.profile-email {
  text-align: center;
  font-size: 13px;
  color: var(--text-sub);
  margin: 4px 0 24px;
  word-break: break-all;
}

.btn-group { display: flex; flex-direction: column; gap: 10px; }

/* ---------- MFA 第二步验证面板 ---------- */
.mfa-panel { text-align: center; }
.mfa-icon { font-size: 40px; margin-bottom: 8px; }
.mfa-title { font-size: 18px; font-weight: 700; margin-bottom: 6px; }
.mfa-desc { font-size: 13px; color: var(--text-sub); margin-bottom: 20px; }

#mfaCode, #mfaBackupCode {
  text-align: center;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 6px;
  padding-left: 14px;
  font-variant-numeric: tabular-nums;
}

.mfa-backup { margin-top: 14px; }
.mfa-backup-input { margin-top: 16px; padding-top: 16px; border-top: 1px dashed var(--border); }
.link-btn {
  background: none; border: none; color: var(--primary);
  font-size: 13px; cursor: pointer; padding: 4px 8px;
}
.link-btn:hover { text-decoration: underline; }
.back-link { margin-top: 20px; }

/* ---------- TOTP 管理卡片 ---------- */
.totp-card {
  background: #f8f9fd;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  margin: 20px 0;
  text-align: left;
}
.totp-card-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 6px;
}
.totp-card-title { font-size: 14px; font-weight: 600; }
.totp-card-desc { font-size: 12px; color: var(--text-sub); margin-bottom: 12px; line-height: 1.5; }

.badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}
.badge.off { background: #f1f5f9; color: #64748b; }
.badge.on { background: #dcfce7; color: #16a34a; }

/* ---------- 弹窗 ---------- */
.modal {
  position: fixed; inset: 0; z-index: 100;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.modal-mask {
  position: absolute; inset: 0;
  background: rgba(15, 23, 42, 0.5);
  backdrop-filter: blur(2px);
}
.modal-box {
  position: relative;
  width: 100%; max-width: 380px;
  background: #fff;
  border-radius: 16px;
  padding: 24px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.2);
  animation: rise 0.3s ease;
}
.modal-title { font-size: 17px; font-weight: 700; margin-bottom: 6px; }
.modal-sub { font-size: 13px; color: var(--text-sub); margin-bottom: 18px; line-height: 1.5; }
.modal-close {
  width: 100%; margin-top: 10px;
  background: none; border: none; color: var(--text-sub);
  font-size: 13px; cursor: pointer; padding: 8px;
}
.modal-close:hover { color: var(--text-main); }

/* 二维码 */
.qr-wrap {
  display: flex; justify-content: center;
  padding: 16px; background: #fff;
  border: 1px solid var(--border); border-radius: 12px;
  margin-bottom: 14px;
}
.qr-wrap img { width: 200px; height: 200px; display: block; }

.secret-row {
  display: flex; align-items: center; gap: 8px;
  background: #f8f9fd; border-radius: 8px;
  padding: 10px 12px; margin-bottom: 16px;
  font-size: 13px;
}
.secret-label { color: var(--text-sub); flex-shrink: 0; }
.secret-row code {
  flex: 1; font-family: monospace; word-break: break-all;
  color: var(--text-main);
}
.copy-btn {
  flex-shrink: 0;
  border: 1px solid var(--primary); background: #fff;
  color: var(--primary); border-radius: 6px;
  padding: 4px 10px; font-size: 12px; cursor: pointer;
}
.copy-btn:hover { background: rgba(79,70,229,0.06); }

/* 备份码 */
.backup-warn { color: #b45309; }
.backup-list {
  display: grid; grid-template-columns: 1fr 1fr; gap: 8px;
  margin-bottom: 18px;
}
.backup-list .code-item {
  font-family: monospace; font-size: 14px;
  background: #f8f9fd; border: 1px solid var(--border);
  border-radius: 8px; padding: 8px; text-align: center;
  letter-spacing: 1px;
}
