:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #f1f3f5;
  --border: rgba(15, 23, 42, 0.12);
  --border-strong: rgba(15, 23, 42, 0.24);
  --text: #0f172a;
  --text-2: #475569;
  --text-3: #94a3b8;
  --brand: #1d4ed8;
  --brand-dark: #1e40af;
  --brand-soft: #eff6ff;
  --ok: #15803d;
  --ok-soft: #f0fdf4;
  --warn: #b45309;
  --warn-soft: #fffbeb;
  --err: #b91c1c;
  --err-soft: #fef2f2;
  --radius: 12px;
  --radius-sm: 8px;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-size: 14px;
  line-height: 1.6;
}

.wrap { max-width: 960px; margin: 0 auto; padding: 0 20px; }

/* ---------- 顶栏 ---------- */

.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  margin-bottom: 24px;
}

.topbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding-top: 16px;
  padding-bottom: 16px;
  flex-wrap: wrap;
}

.brand { display: flex; align-items: center; gap: 12px; }

.brand-mark {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: var(--brand);
  position: relative;
  flex-shrink: 0;
}
.brand-mark::after {
  content: "";
  position: absolute;
  left: 11px;
  top: 8px;
  width: 14px;
  height: 11px;
  border: 2px solid #fff;
  border-radius: 3px;
  border-top-width: 4px;
}

.brand h1 { font-size: 16px; font-weight: 500; margin: 0; }
.brand p { font-size: 12px; color: var(--text-2); margin: 0; }

.auth-area { display: flex; align-items: center; gap: 10px; }

.user-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-2);
}

.avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--brand-soft);
  color: var(--brand);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 500;
  font-size: 13px;
}

/* ---------- 卡片 ---------- */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 20px;
}

.card h2 { font-size: 15px; font-weight: 500; margin: 0 0 4px; }
.card h3 { font-size: 14px; font-weight: 500; margin: 0 0 10px; }

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.card-head h2 { margin: 0; }

.muted { color: var(--text-2); font-size: 13px; margin: 0 0 12px; }

/* ---------- 步骤条 ---------- */

.steps {
  display: flex;
  gap: 8px;
  margin: 16px 0 20px;
  flex-wrap: wrap;
}

.step {
  font-size: 12px;
  color: var(--text-3);
  padding: 4px 12px;
  border-radius: 20px;
  background: var(--surface-2);
}
.step.active { color: var(--brand); background: var(--brand-soft); }

/* ---------- 表单 ---------- */

.field { display: block; margin-bottom: 16px; }
.field > span {
  display: block;
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 6px;
}

input[type="text"],
input[type="email"],
input[type="tel"],
input[type="password"],
select,
textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
}

textarea { resize: vertical; font-family: var(--mono); font-size: 13px; }

input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--brand);
  outline-offset: -1px;
  border-color: var(--brand);
}

.row { display: flex; gap: 10px; align-items: center; }
.row input { flex: 1; }

.hint {
  font-size: 12px;
  color: var(--text-2);
  margin: -8px 0 14px;
  line-height: 1.6;
}

.hint code, .record-item code, .meta-row code {
  background: var(--surface-2);
  padding: 1px 5px;
  border-radius: 4px;
  font-family: var(--mono);
  font-size: 12px;
  word-break: break-all;
}

.field-error { color: var(--err); font-size: 12px; margin: -10px 0 12px; }
.auth-error {
  color: var(--err);
  background: var(--err-soft);
  border: 1px solid rgba(185, 28, 28, 0.2);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 13px;
  margin-top: 14px;
}

/* ---------- 按钮 ---------- */

.btn {
  padding: 9px 18px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-size: 14px;
  font-family: inherit;
  cursor: pointer;
  transition: background-color 0.15s, border-color 0.15s;
}

.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-dark); }
.btn-primary:disabled { background: var(--text-3); cursor: not-allowed; }

.btn-ghost {
  background: var(--surface);
  border-color: var(--border-strong);
  color: var(--text);
}
.btn-ghost:hover { background: var(--surface-2); }

.btn-sm { padding: 5px 12px; font-size: 12px; }

.btn.danger { color: var(--err); border-color: rgba(185, 28, 28, 0.25); }

.btn-row { display: flex; gap: 10px; margin-top: 20px; flex-wrap: wrap; }

/* ---------- 选项 ---------- */

.option-list { display: grid; gap: 10px; margin-bottom: 20px; }

.option {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  background: var(--surface);
}
.option:hover { border-color: var(--border-strong); background: var(--surface-2); }
.option input { margin-top: 3px; accent-color: var(--brand); }
.option strong { font-weight: 500; font-size: 14px; }
.option p { margin: 2px 0 0; font-size: 12px; }

/* ---------- 登录 ---------- */

.auth-card { max-width: 480px; }

.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--border);
  margin: 16px 0 18px;
  flex-wrap: wrap;
}

.tab {
  padding: 8px 14px;
  border: none;
  background: none;
  color: var(--text-2);
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.tab.active { color: var(--brand); border-bottom-color: var(--brand); }

.auth-pane .btn { width: 100%; margin-top: 12px; }
.auth-pane .row { margin-top: 8px; }
.auth-pane .row .btn { width: auto; margin-top: 0; white-space: nowrap; }

/* ---------- 状态 ---------- */

.status-box {
  display: flex;
  gap: 14px;
  align-items: center;
  padding: 18px;
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  margin-bottom: 20px;
}

.spinner {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid var(--border-strong);
  border-top-color: var(--brand);
  animation: spin 0.8s linear infinite;
  flex-shrink: 0;
}

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

@media (prefers-reduced-motion: reduce) {
  .spinner { animation: none; }
}

.status-box strong { font-weight: 500; }
.status-box p { margin: 2px 0 0; font-size: 12px; }

/* ---------- 手动验证记录 ---------- */

.record-group {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px;
  margin-bottom: 12px;
  background: var(--surface-2);
}

.record-group-head .record-row:last-child { margin-bottom: 0; }

.record-note {
  margin: 10px 0 0;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  background: #fff7e6;
  color: #8a5a00;
  font-size: 12px;
  line-height: 1.6;
}

.record-item {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px;
  margin-top: 10px;
  background: var(--surface);
}

.record-item:first-of-type { margin-top: 12px; }

.record-row {
  display: flex;
  gap: 12px;
  align-items: baseline;
  margin-bottom: 6px;
  flex-wrap: wrap;
}

.record-label {
  font-size: 12px;
  color: var(--text-2);
  min-width: 64px;
  flex-shrink: 0;
}

.record-value { font-family: var(--mono); word-break: break-all; }

/* ---------- 结果 ---------- */

.result-meta {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.meta-row {
  display: flex;
  gap: 16px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  flex-wrap: wrap;
}
.meta-row:last-child { border-bottom: none; }
.meta-row > span:first-child {
  color: var(--text-2);
  min-width: 80px;
  flex-shrink: 0;
}

.error-text {
  background: var(--err-soft);
  border: 1px solid rgba(185, 28, 28, 0.2);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--err);
  white-space: pre-wrap;
  word-break: break-word;
  overflow-x: auto;
}
.error-text.small { font-size: 11px; margin: 8px 0 0; }

/* 结果页：证书链 / 私钥内容 + 一键复制 */
.cert-block {
  margin-top: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.cert-block-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 12px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  font-weight: 600;
}
.cert-content {
  margin: 0;
  padding: 12px 14px;
  max-height: 220px;
  overflow: auto;
  font-family: var(--mono);
  font-size: 11.5px;
  line-height: 1.55;
  color: var(--text);
  white-space: pre;
  word-break: normal;
  background: var(--surface);
}
.cert-note {
  margin: 0;
  padding: 10px 14px;
  font-size: 12px;
  color: var(--warn);
  background: var(--warn-soft);
  border-top: 1px solid var(--border);
}

/* ---------- 证书列表 ---------- */

.cert-item {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  margin-bottom: 12px;
}

.cert-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}

.cert-head strong { font-weight: 500; word-break: break-all; }
.cert-head p { margin: 2px 0 0; font-size: 12px; }

.cert-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.badge {
  font-size: 12px;
  padding: 2px 10px;
  border-radius: 20px;
  white-space: nowrap;
  flex-shrink: 0;
}
.badge-valid { background: var(--ok-soft); color: var(--ok); }
.badge-pending, .badge-awaiting_dns { background: var(--warn-soft); color: var(--warn); }
.badge-failed, .badge-revoked { background: var(--err-soft); color: var(--err); }

/* ---------- 部署指引 ---------- */

.guide-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 16px;
}

.guide-item h3 { margin-bottom: 8px; }

.code-block {
  background: #0f172a;
  color: #e2e8f0;
  padding: 14px;
  border-radius: var(--radius-sm);
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.6;
  overflow-x: auto;
  margin: 0;
}

/* ---------- 域名预览 ---------- */

.domain-preview:empty { display: none; }
.domain-preview { margin: -8px 0 16px; }

.preview-ok {
  font-size: 12px;
  color: var(--ok);
  background: var(--ok-soft);
  border: 1px solid rgba(21, 128, 61, 0.2);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  margin: 0 0 6px;
}

.preview-bad {
  font-size: 12px;
  color: var(--err);
  background: var(--err-soft);
  border: 1px solid rgba(185, 28, 28, 0.2);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  margin: 0 0 6px;
}

/* ---------- 页脚 ---------- */

.footer {
  padding: 8px 20px 40px;
  color: var(--text-3);
  font-size: 12px;
}
.footer p { margin: 0; }

@media (max-width: 640px) {
  .card { padding: 18px; }
  .topbar-inner { align-items: flex-start; }
}
