:root {
  --bg: #f5f6f8;
  --bg-soft: #f9fafb;
  --card: #ffffff;
  --card-2: #f3f4f6;
  --border: #e5e7eb;
  --border-strong: #d1d5db;
  --text: #111827;
  --text-dim: #4b5563;
  --text-mute: #9ca3af;
  --accent: #0f766e;
  --accent-hover: #0b5f59;
  --accent-soft: #f0fdfa;
  --accent-ring: rgba(13, 148, 136, 0.15);
  --ok: #15803d;
  --ok-soft: #f0fdf4;
  --ok-border: #bbf7d0;
  --warn: #b45309;
  --warn-soft: #fffbeb;
  --warn-border: #fde68a;
  --err: #b91c1c;
  --err-soft: #fef2f2;
  --err-border: #fecaca;
  --info: #1e40af;
  --info-soft: #eff6ff;
  --info-border: #bfdbfe;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.06);
  --shadow-lg: 0 10px 25px rgba(16, 24, 40, 0.1);
}

* { box-sizing: border-box; }
/* hidden 属性必须始终生效（防止类样式 display:grid 等覆盖导致未登录内容泄露） */
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  line-height: 1.6;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.container { width: min(1440px, 95vw); margin: 0 auto; }

/* ---- 顶栏 ---- */
.topbar {
  position: sticky; top: 0; z-index: 50;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.topbar-inner { display: flex; align-items: center; gap: 14px; padding: 12px 0; }
.logo { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 17px; letter-spacing: 0.2px; }
.logo-badge {
  width: 30px; height: 30px; border-radius: 8px;
  background: var(--text); color: #fff;
  display: grid; place-items: center; font-size: 15px; font-weight: 800;
}
.mode-badge {
  font-size: 11px; padding: 2px 9px; border-radius: 999px;
  border: 1px solid var(--warn-border); background: var(--warn-soft); color: var(--warn);
}
.topnav { margin-left: auto; display: flex; gap: 4px; }
.topnav a, .topnav button {
  background: none; border: 0; color: var(--text-dim); font-size: 14px;
  padding: 7px 13px; border-radius: 8px; cursor: pointer;
}
.topnav a:hover, .topnav button:hover { color: var(--text); background: var(--card-2); text-decoration: none; }
.topnav .active { color: var(--text); background: var(--card-2); font-weight: 600; }

/* ---- Hero ---- */
.hero { padding: 72px 0 12px; text-align: center; }
.hero h1 { margin: 0 0 10px; font-size: clamp(26px, 4.4vw, 38px); font-weight: 800; color: var(--text); }
.hero p { margin: 0; color: var(--text-dim); font-size: 15.5px; }
.hero .mode-line { margin-top: 14px; }

/* ---- CDK 绑定信息卡 ---- */
.cdk-info { border: 1px solid var(--accent); background: var(--accent-soft); border-radius: var(--radius); padding: 22px 28px; margin-bottom: 24px; }
.cdk-info .ci-row { display: flex; gap: 64px; flex-wrap: wrap; }
.cdk-info .ci-label { font-size: 12px; color: var(--text-mute); margin-bottom: 4px; }
.cdk-info .ci-plan { font-size: 19px; font-weight: 800; color: var(--text); }
.cdk-info .ci-region { font-size: 19px; font-weight: 800; color: var(--accent); }
.cdk-info .ci-region .ci-default { color: var(--text-dim); font-size: 16px; font-weight: 600; }
.cdk-info .ci-note { margin-top: 12px; padding-top: 12px; border-top: 1px dashed var(--border); font-size: 12.5px; color: var(--text-dim); }

/* ---- 主卡片 ---- */
.card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: 14px; box-shadow: var(--shadow);
}
.main-card { margin: 30px 0 70px; padding: 34px clamp(24px, 5vw, 60px) 42px; }

.tabs { display: flex; gap: 6px; border-bottom: 1px solid var(--border); margin-bottom: 24px; }
.tabs button {
  background: none; border: 0; color: var(--text-dim); font-size: 15px; font-weight: 600;
  padding: 9px 16px 12px; cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tabs button.active { color: var(--accent); border-bottom-color: var(--accent); }

/* ---- 步骤 ---- */
.steps { display: flex; margin: 0 0 34px; }
.step { flex: 1; text-align: center; position: relative; color: var(--text-mute); font-size: 13px; }
.step::before {
  content: attr(data-n); display: grid; place-items: center;
  width: 28px; height: 28px; margin: 0 auto 6px; border-radius: 50%;
  background: var(--card); border: 1px solid var(--border-strong); font-weight: 600; font-size: 13px;
}
.step::after {
  content: ""; position: absolute; top: 14px; left: calc(-50% + 18px); right: calc(50% + 18px);
  height: 2px; background: var(--border);
}
.step:first-child::after { display: none; }
.step.on { color: var(--text); font-weight: 600; }
.step.on::before { background: var(--accent); border-color: var(--accent); color: #fff; }
.step.done::before { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); content: "✓"; }
.step.done::after { background: var(--accent); }

/* ---- 表单 ---- */
.field { margin-bottom: 22px; }
.field label { display: block; font-size: 13.5px; font-weight: 600; color: var(--text-dim); margin-bottom: 7px; }
.field input[type="text"], .field input[type="password"], .field select, .field textarea {
  width: 100%; background: var(--card); border: 1px solid var(--border-strong);
  border-radius: 8px; color: var(--text); font-size: 14.5px; padding: 11px 13px;
  outline: none; transition: 0.15s; font-family: inherit;
}
.field textarea { min-height: 150px; resize: vertical; font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 12.5px; line-height: 1.55; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-ring); }
.field .hint { font-size: 12.5px; color: var(--text-mute); margin-top: 6px; }
.input-row { display: flex; gap: 10px; }
.input-row input { flex: 1; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  background: var(--accent); color: #fff; border: 1px solid transparent; border-radius: 8px;
  font-size: 15px; font-weight: 600; padding: 11px 24px; cursor: pointer; transition: 0.15s;
}
.btn:hover:not(:disabled) { background: var(--accent-hover); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn.block { width: 100%; }
.btn.ghost { background: var(--card); border-color: var(--border-strong); color: var(--text); }
.btn.ghost:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); background: var(--card); }
.btn.sm { padding: 7px 13px; font-size: 13px; border-radius: 7px; }
.btn.warn { background: #d97706; }
.btn.warn:hover:not(:disabled) { background: #b45309; }

.checkbox-row { display: flex; align-items: flex-start; gap: 10px; font-size: 13.5px; color: var(--text-dim); margin: 6px 0 18px; }
.checkbox-row input { margin-top: 4px; accent-color: var(--accent); width: 16px; height: 16px; }

/* ---- 提示条 ---- */
.alert { border-radius: 8px; padding: 13px 18px; font-size: 14px; margin-bottom: 20px; border: 1px solid; }
.alert.ok { background: var(--ok-soft); border-color: var(--ok-border); color: var(--ok); }
.alert.warn { background: var(--warn-soft); border-color: var(--warn-border); color: var(--warn); }
.alert.err { background: var(--err-soft); border-color: var(--err-border); color: var(--err); }
.alert.info { background: var(--info-soft); border-color: var(--info-border); color: var(--info); }

/* ---- 订单状态 ---- */
.order-head { display: flex; flex-wrap: wrap; gap: 8px 18px; align-items: center; margin-bottom: 4px; }
.order-head .oid { font-family: ui-monospace, Consolas, monospace; font-size: 15px; font-weight: 700; }
.order-head .oplan { color: var(--text-dim); font-size: 13.5px; }
.order-head .right { margin-left: auto; }

.status-pill { display: inline-flex; align-items: center; gap: 7px; font-size: 13px; font-weight: 600; border-radius: 999px; padding: 4px 13px; }
.status-pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.status-pill.processing { background: var(--warn-soft); color: var(--warn); border: 1px solid var(--warn-border); }
.status-pill.processing::before { animation: pulse 1.2s infinite; }
.status-pill.succeeded { background: var(--ok-soft); color: var(--ok); border: 1px solid var(--ok-border); }
.status-pill.failed { background: var(--err-soft); color: var(--err); border: 1px solid var(--err-border); }
@keyframes pulse { 50% { opacity: 0.25; } }

.timeline { display: flex; margin: 24px 0 6px; }
.tl { flex: 1; text-align: center; position: relative; font-size: 12.5px; color: var(--text-mute); }
.tl i {
  display: grid; place-items: center; width: 24px; height: 24px; margin: 0 auto 5px;
  border-radius: 50%; background: var(--card); border: 1px solid var(--border-strong);
  font-style: normal; font-size: 12px;
}
.tl::after { content: ""; position: absolute; top: 12px; left: calc(-50% + 15px); right: calc(50% + 15px); height: 2px; background: var(--border); }
.tl:first-child::after { display: none; }
.tl.done { color: var(--text-dim); }
.tl.done i { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.tl.done::after { background: var(--accent); }
.tl.now { color: var(--warn); font-weight: 600; }
.tl.now i { border-color: var(--warn); color: var(--warn); animation: pulse 1.2s infinite; }

.kv { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px 32px; margin: 18px 0; }
.kv .k { font-size: 12px; color: var(--text-mute); }
.kv .v { font-size: 14.5px; margin-top: 2px; word-break: break-all; }

/* ---- 开通进度条 ---- */
.progress-wrap { margin: 2px 0 20px; }
.progress-top { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 7px; gap: 12px; }
.progress-label { font-size: 14px; font-weight: 700; color: var(--text); }
.progress-pct { font-size: 13px; color: var(--text-mute); font-variant-numeric: tabular-nums; white-space: nowrap; }
.progress-track { height: 8px; background: var(--card-2); border: 1px solid var(--border); border-radius: 999px; overflow: hidden; }
.progress-fill {
  height: 100%; width: 0; background: var(--accent); border-radius: 999px;
  transition: width 0.9s cubic-bezier(0.22, 0.61, 0.36, 1); position: relative; overflow: hidden;
}
/* 活跃时的高光扫过，表示任务进行中 */
.progress-fill.active::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent 0%, rgba(255, 255, 255, 0.45) 50%, transparent 100%);
  animation: sweep 1.6s ease-in-out infinite;
}
.progress-fill.ok { background: var(--ok); }
.progress-fill.bad { background: var(--err); }
@keyframes sweep { 0% { transform: translateX(-100%); } 100% { transform: translateX(100%); } }

/* 阶段文字后的动态省略点 */
.tdots i { font-style: normal; font-weight: 800; color: var(--accent); animation: tdots-blink 1.2s infinite; }
.tdots i:nth-child(2) { animation-delay: 0.2s; }
.tdots i:nth-child(3) { animation-delay: 0.4s; }
@keyframes tdots-blink { 0%, 60%, 100% { opacity: 0.15; } 30% { opacity: 1; } }

/* ---- Session 目标账号确认 ---- */
.session-preview { border: 1px solid var(--accent); background: var(--accent-soft); border-radius: var(--radius); padding: 16px 18px; margin: 0 0 18px; }
.session-preview .sp-label { font-size: 12.5px; color: var(--text-mute); margin-bottom: 4px; }
.session-preview .sp-email { font-size: 17px; font-weight: 800; color: var(--text); word-break: break-all; }
.session-preview .sp-email.no-email { color: var(--warn); font-size: 15px; font-weight: 700; }
.session-preview .sp-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: 14px; flex-wrap: wrap; }
.session-preview .sp-tip { font-size: 12.5px; color: var(--text-dim); }
.session-preview .sp-confirmed { font-size: 13px; font-weight: 700; color: var(--ok); }

.captcha-box {
  border: 1px solid var(--warn-border); background: var(--warn-soft);
  border-radius: var(--radius); padding: 20px; text-align: center; margin: 18px 0;
}
.captcha-box h3 { margin: 0 0 6px; color: var(--warn); font-size: 16px; }
.captcha-box p { margin: 0 0 14px; color: var(--text-dim); font-size: 13.5px; }

.result-panel { border-radius: var(--radius); padding: 22px; margin-top: 18px; text-align: center; border: 1px solid; }
.result-panel.ok { background: var(--ok-soft); border-color: var(--ok-border); }
.result-panel.bad { background: var(--err-soft); border-color: var(--err-border); }
.result-panel .big { font-size: 19px; font-weight: 700; margin-bottom: 6px; }
.result-panel.ok .big { color: var(--ok); }
.result-panel.bad .big { color: var(--err); }

/* ---- 弹窗 ---- */
.modal-mask {
  position: fixed; inset: 0; background: rgba(17, 24, 39, 0.45);
  display: none; align-items: center; justify-content: center; z-index: 100; padding: 20px;
}
.modal-mask.show { display: flex; }
.modal {
  width: min(640px, 94vw); max-height: 86vh; overflow: auto;
  background: var(--card); border: 1px solid var(--border); border-radius: 14px; padding: 24px;
  box-shadow: var(--shadow-lg);
}
.modal h3 { margin: 0 0 4px; font-size: 17px; }
.modal .sub { color: var(--text-mute); font-size: 12.5px; margin-bottom: 14px; }
.modal pre {
  background: var(--bg-soft); border: 1px solid var(--border); border-radius: 8px;
  padding: 14px; font-size: 12px; overflow: auto; max-height: 46vh;
  font-family: ui-monospace, Consolas, monospace; white-space: pre-wrap; word-break: break-all;
}
.modal .row { display: flex; gap: 10px; justify-content: flex-end; margin-top: 16px; }

/* ---- Toast ---- */
.toast-wrap { position: fixed; top: 24px; left: 50%; transform: translateX(-50%); z-index: 200; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast {
  background: #111827; color: #f9fafb;
  border-radius: 8px; padding: 11px 20px; font-size: 14px; box-shadow: var(--shadow-lg);
  animation: slideDown 0.25s ease; max-width: 88vw;
}
.toast.ok { background: #14532d; }
.toast.err { background: #7f1d1d; }
@keyframes slideDown { from { opacity: 0; transform: translateY(-10px); } }

/* ---- 折叠帮助 ---- */
details.help { border: 1px solid var(--border); border-radius: 8px; padding: 11px 15px; margin-bottom: 18px; background: var(--bg-soft); }
details.help summary { cursor: pointer; font-size: 13.5px; font-weight: 600; color: var(--text-dim); }
details.help .body { font-size: 13px; color: var(--text-dim); padding-top: 10px; }
details.help code { background: var(--card-2); border-radius: 5px; padding: 1px 6px; font-size: 12px; color: var(--accent); }
details.help ol { margin: 8px 0; padding-left: 22px; }

/* ---- 订单列表 ---- */
.order-item {
  display: flex; flex-wrap: wrap; gap: 6px 18px; align-items: center;
  border: 1px solid var(--border); border-radius: var(--radius); padding: 13px 16px; margin-bottom: 10px;
  cursor: pointer; transition: 0.15s; background: var(--card);
}
.order-item:hover { border-color: var(--accent); }
.order-item .oid { font-family: ui-monospace, Consolas, monospace; font-weight: 700; font-size: 13.5px; }
.order-item .meta { color: var(--text-mute); font-size: 12.5px; }
.order-item .right { margin-left: auto; }

.footer { text-align: center; color: var(--text-mute); font-size: 12.5px; padding: 28px 0 38px; }

.spin {
  display: inline-block; width: 14px; height: 14px; vertical-align: -2px;
  border: 2px solid color-mix(in srgb, currentColor 30%, transparent);
  border-top-color: currentColor; border-radius: 50%; animation: rot 0.7s linear infinite;
}
@keyframes rot { to { transform: rotate(360deg); } }

.muted { color: var(--text-mute); }
.mono { font-family: ui-monospace, Consolas, monospace; }
.mt8 { margin-top: 8px; } .mt16 { margin-top: 16px; } .mt24 { margin-top: 24px; }

/* ---- 管理端 ---- */
.admin-shell { display: grid; grid-template-columns: 220px 1fr; gap: 26px; margin: 30px 0 70px; }
.admin-side { background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 12px; height: fit-content; position: sticky; top: 76px; box-shadow: var(--shadow); }
.admin-side button {
  display: block; width: 100%; text-align: left; background: none; border: 0; color: var(--text-dim);
  font-size: 14px; font-weight: 600; padding: 10px 13px; border-radius: 8px; cursor: pointer; margin-bottom: 2px;
}
.admin-side button:hover { background: var(--card-2); color: var(--text); }
.admin-side button.active { background: var(--accent-soft); color: var(--accent); }
.admin-main { min-width: 0; }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; margin-bottom: 24px; }
.stat { background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 15px 17px; box-shadow: var(--shadow); }
.stat .n { font-size: 25px; font-weight: 800; }
.stat .l { color: var(--text-mute); font-size: 12.5px; margin-top: 1px; }
.stat .n.ok { color: var(--ok); } .stat .n.warn { color: var(--warn); } .stat .n.err { color: var(--err); }

.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: 12px; background: var(--card); box-shadow: var(--shadow); }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th { text-align: left; color: var(--text-mute); font-weight: 600; padding: 11px 14px; border-bottom: 1px solid var(--border); white-space: nowrap; background: var(--bg-soft); }
.tbl td { padding: 10px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl tbody tr:hover td, .tbl tr:hover td { background: #fafafa; }
.tbl .mono { font-size: 12px; }

.toolbar { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; margin-bottom: 18px; }
.toolbar select, .toolbar input {
  background: var(--card); border: 1px solid var(--border-strong); border-radius: 8px;
  color: var(--text); font-size: 13px; padding: 8px 11px; outline: none;
}
/* 卡选择框：按内容自适应宽度，禁止被工具栏压缩截断 */
#genCard { flex: 0 0 auto; min-width: 0; }
.toolbar select:focus, .toolbar input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-ring); }
.pager { display: flex; gap: 8px; align-items: center; justify-content: flex-end; margin-top: 14px; font-size: 13px; color: var(--text-dim); }

.tag { display: inline-block; font-size: 11.5px; font-weight: 600; border-radius: 999px; padding: 2px 10px; }
.tag.green { background: var(--ok-soft); color: var(--ok); border: 1px solid var(--ok-border); }
.tag.amber { background: var(--warn-soft); color: var(--warn); border: 1px solid var(--warn-border); }
.tag.red { background: var(--err-soft); color: var(--err); border: 1px solid var(--err-border); }
.tag.gray { background: var(--card-2); color: var(--text-dim); border: 1px solid var(--border); }

.login-box { width: min(400px, 92vw); margin: 9vh auto 0; padding: 32px; text-align: center; }
.login-box h2 { margin: 0 0 4px; }
.login-box .sub { color: var(--text-mute); font-size: 13px; margin-bottom: 22px; }

.detail-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 10px 24px; font-size: 13.5px; }
.detail-grid .k { color: var(--text-mute); font-size: 12px; }
.detail-grid .v { word-break: break-all; }

@media (max-width: 760px) {
  .admin-shell { grid-template-columns: 1fr; }
  .admin-side { position: static; display: flex; flex-wrap: wrap; gap: 6px; }
  .admin-side button { width: auto; margin-bottom: 0; }
  .steps { flex-wrap: wrap; gap: 10px; }
}
