:root {
  --accent: #4f7cff;
  --bg: #f4f6fb;
  --surface: #ffffff;
  --line: #e5e9f2;
  --ink: #1c2333;
  --muted: #6b7688;
  --ok: #16a34a;
  --warn: #d97706;
  --danger: #dc2626;
  --radius: 16px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background: linear-gradient(180deg, #eef1f9 0%, var(--bg) 240px);
  color: var(--ink);
  font-family: "PingFang SC", "Microsoft YaHei", "Segoe UI", system-ui, -apple-system, sans-serif;
  font-size: 15px;
  line-height: 1.6;
}

.mono, code {
  font-family: "JetBrains Mono", "SFMono-Regular", Consolas, monospace;
}

.page {
  max-width: 560px;
  margin: 0 auto;
  padding: 0 16px 48px;
}

/* ---------- 顶栏 ---------- */
.topbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 4px;
}
.brand-mark {
  width: 30px;
  height: 30px;
  border-radius: 9px;
  background: var(--accent);
  position: relative;
  flex: none;
}
.brand-mark::after {
  content: "";
  position: absolute;
  inset: 9px;
  border-radius: 50%;
  background: #fff;
}
.brand-name { font-weight: 700; font-size: 16px; }
.topnav {
  margin-left: auto;
  display: flex;
  gap: 4px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px;
}
.topnav a {
  text-decoration: none;
  color: var(--muted);
  font-size: 13.5px;
  font-weight: 500;
  padding: 4px 14px;
  border-radius: 999px;
}
.topnav a.active {
  background: var(--ink);
  color: #fff;
}

/* ---------- 卡片 ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 26px 24px;
  box-shadow: 0 8px 28px rgba(28, 35, 51, 0.05);
}

h2 { font-size: 19px; margin: 0 0 6px; }
.hint { color: var(--muted); font-size: 13.5px; margin: 0 0 16px; }
.hint.small { margin: 14px 0 0; font-size: 12.5px; }
.hint code {
  background: var(--bg);
  padding: 1px 6px;
  border-radius: 6px;
  font-size: 12.5px;
}
.hint a { color: var(--accent); text-decoration: none; }
.hint a:hover { text-decoration: underline; }

/* ---------- 步骤条 ---------- */
.steps {
  list-style: none;
  display: flex;
  align-items: center;
  gap: 0;
  padding: 0;
  margin: 0 0 24px;
  counter-reset: step;
}
.steps li {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13.5px;
  font-weight: 500;
  transition: color 0.25s;
}
.steps li i {
  font-style: normal;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  background: var(--surface);
  border: 2px solid var(--line);
  color: var(--muted);
  position: relative;
  flex: none;
  transition: background 0.25s, border-color 0.25s, box-shadow 0.25s;
}
.steps li.active { color: var(--ink); font-weight: 600; }
.steps li.active i {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 16%, transparent);
}
.steps li.done { color: var(--ink); }
.steps li.done i {
  background: var(--accent);
  border-color: var(--accent);
  font-size: 0;
}
.steps li.done i::after {
  content: "";
  width: 11px;
  height: 6px;
  border-left: 2.5px solid #fff;
  border-bottom: 2.5px solid #fff;
  transform: rotate(-45deg);
}
.steps li.bar {
  flex: 1;
  min-width: 24px;
  height: 3px;
  margin: 0 10px;
  background: var(--line);
  border-radius: 3px;
  transition: background 0.25s;
}
.steps li.bar.done { background: var(--accent); }

/* ---------- 表单 ---------- */
.input-row { display: flex; gap: 10px; }
.input-row input { flex: 1; }

input[type="text"], textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 15px;
  font-family: inherit;
  background: #fbfcfe;
  color: var(--ink);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
input[type="text"]:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent);
  background: #fff;
}
textarea { resize: vertical; font-size: 13px; font-family: "JetBrains Mono", Consolas, monospace; }

/* ---------- 按钮 ---------- */
.btn {
  border: none;
  border-radius: 12px;
  padding: 12px 22px;
  font-size: 14.5px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: opacity 0.15s, transform 0.05s;
  white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn.primary { background: var(--accent); color: #fff; }
.btn.ghost { background: var(--bg); color: var(--ink); border: 1px solid var(--line); }
.btn.danger { background: var(--danger); color: #fff; }
.btn.full { width: 100%; margin-top: 12px; }
.btn-row {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 18px;
}
.btn.loading {
  position: relative;
  color: transparent !important;
  pointer-events: none;
}
.btn.loading::after {
  content: "";
  position: absolute;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255,255,255,0.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  left: calc(50% - 8px);
  top: calc(50% - 8px);
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- 卡密信息 / 汇总 ---------- */
.card-info {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
  margin-bottom: 14px;
  font-size: 13.5px;
}
.card-info .row { display: flex; justify-content: space-between; gap: 12px; }
.card-info .row + .row { margin-top: 6px; }
.card-info .k { color: var(--muted); flex: none; }

.summary {
  margin: 0 0 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
}
.summary .row {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  padding: 10px 14px;
  font-size: 13.5px;
}
.summary .row + .row { border-top: 1px solid var(--line); }
.summary .k { color: var(--muted); flex: none; }
.summary .v { text-align: right; word-break: break-all; }

.session-status {
  margin-top: 10px;
  font-size: 13.5px;
  padding: 10px 14px;
  border-radius: 12px;
}
.session-status.ok {
  background: #ecfdf3;
  color: var(--ok);
  border: 1px solid #b7ebc6;
  display: flex;
  align-items: flex-start;
  gap: 8px;
}
.session-status .ss-text { flex: 1; white-space: pre-line; }
.session-status .copy-btn { margin-top: 2px; color: var(--ok); }
.session-status .copy-btn:hover { background: rgba(22, 163, 74, 0.08); }
.session-status.bad { background: #fef2f2; color: var(--danger); border: 1px solid #fecaca; }

.confirm-warn {
  background: #fffbeb;
  border: 1px solid #fde68a;
  color: #92400e;
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 13.5px;
  margin-bottom: 4px;
}

/* ---------- 徽标 ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  font-weight: 600;
  padding: 2px 10px;
  border-radius: 999px;
}
.badge.ok { background: #ecfdf3; color: var(--ok); }
.badge.muted { background: var(--bg); color: var(--muted); border: 1px solid var(--line); }
.badge.warn { background: #fffbeb; color: var(--warn); }
.badge .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.pulse .dot { animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: 0.25; } }

/* ---------- 查询 ---------- */
.lookup-tabs { display: flex; gap: 6px; margin: 16px 0 10px; }
.tab {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--muted);
  border-radius: 999px;
  padding: 4px 14px;
  font-size: 13px;
  cursor: pointer;
  font-family: inherit;
}
.tab.active { background: var(--ink); color: #fff; border-color: var(--ink); }
.tab-count {
  font-style: normal;
  font-size: 11px;
  font-weight: 700;
  margin-left: 5px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--bg);
  color: var(--muted);
}
.tab.active .tab-count { background: rgba(255, 255, 255, 0.22); color: #fff; }

.copy-unused {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 0 0 12px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  border-radius: 10px;
  padding: 7px 14px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
  transition: border-color 0.15s, color 0.15s;
}
.copy-unused:hover { border-color: var(--accent); color: var(--accent); }
.copy-unused:active { transform: translateY(1px); }

.lookup-list { display: flex; flex-direction: column; gap: 8px; }
.lookup-item {
  display: flex;
  flex-direction: column;
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 14px;
  font-size: 13.5px;
  min-width: 0;
}
.lookup-item .li-top { display: flex; align-items: center; gap: 8px; }
.lookup-item .code {
  font-weight: 600;
  letter-spacing: 0.5px;
  min-width: 0;
  overflow-wrap: anywhere;
}
.lookup-item .li-top .badge { margin-left: auto; flex: none; }
.lookup-item .li-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 8px;
  color: var(--muted);
  font-size: 12.5px;
  border-top: 1px dashed var(--line);
  padding-top: 6px;
}
.lookup-item .li-email { overflow-wrap: anywhere; }
.lookup-item .used-at { margin-left: auto; flex: none; }
.copy-btn {
  border: none;
  background: none;
  color: var(--muted);
  cursor: pointer;
  padding: 3px;
  display: inline-flex;
  align-items: center;
  border-radius: 5px;
  flex: none;
  transition: color 0.15s, background 0.15s;
}
.copy-btn:hover { color: var(--accent); background: var(--bg); }
.copy-btn:active { transform: translateY(1px); }
.lookup-item a { color: var(--accent); text-decoration: none; font-weight: 600; }

/* ---------- 进度 ---------- */
.progress-state { text-align: center; padding: 26px 0 8px; }
.progress-state p { margin: 14px 0 0; font-weight: 600; }
.ring { width: 78px; height: 78px; margin: 0 auto; position: relative; }
.ring svg { width: 100%; height: 100%; display: block; transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 6; }
.ring-bg { stroke: var(--line); }
.ring-fg {
  stroke: var(--accent);
  stroke-linecap: round;
  stroke-dasharray: 213.63;
  stroke-dashoffset: 213.63;
  transition: stroke-dashoffset 0.8s ease, stroke 0.3s;
}
.ring-num {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 700;
  color: var(--ink);
}
.progress-state.done .ring-fg { stroke: var(--ok); }
.progress-state.done .ring-num { color: var(--ok); }
.progress-state.fail .ring-fg { stroke: var(--danger); }
.progress-state.fail .ring-num { color: var(--danger); }
.progress-state.fail { color: var(--danger); }
.progress-state.done.ok { color: var(--ok); }

.progress-detail { margin-top: 14px; }

/* ---------- 其他 ---------- */
.footer {
  text-align: center;
  color: var(--muted);
  font-size: 12.5px;
  padding-top: 28px;
}
.hidden { display: none !important; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 36px;
  transform: translateX(-50%);
  background: var(--ink);
  color: #fff;
  padding: 10px 18px;
  border-radius: 12px;
  font-size: 13.5px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.25);
  z-index: 99;
  max-width: 86vw;
}

@media (max-width: 480px) {
  .card { padding: 20px 16px; }
  .input-row { flex-direction: column; }
  .btn-row { flex-wrap: wrap; }
}
