:root {
  --bg: #f4f5f8;
  --card: #ffffff;
  --text: #171a21;
  --sub: #6b7280;
  --hint: #9aa1ad;
  --line: #ebedf2;
  --accent: #2f6bff;
  --accent-soft: #eaf1ff;
  --ok: #12a150;
  --warn: #d97706;
  --danger: #d93a3a;
  --radius: 14px;
  --shadow: 0 2px 10px rgba(20, 24, 40, 0.05);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }

/* ---------- 顶部 ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--line);
}
.topbar-inner {
  max-width: 720px;
  margin: 0 auto;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.logo {
  width: 30px; height: 30px; border-radius: 9px;
  background: linear-gradient(135deg, #2f6bff, #7c5cff);
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 700; font-size: 15px;
  flex: none;
}
.brand-name { font-weight: 700; font-size: 16px; letter-spacing: .2px; }
.brand-slogan { font-size: 12px; color: var(--hint); margin-top: 1px; }
.topbar-spacer { flex: 1; }

.page {
  max-width: 720px;
  margin: 0 auto;
  padding: 16px 16px 96px;
}

/* ---------- 卡片 ---------- */
.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  margin-bottom: 14px;
}
.card-title {
  font-size: 15px;
  font-weight: 650;
  margin: 0 0 4px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.card-desc { font-size: 12.5px; color: var(--hint); margin: 0 0 14px; line-height: 1.5; }

/* ---------- 表单 ---------- */
.label { display: block; font-size: 13px; color: var(--sub); margin: 0 0 6px; font-weight: 550; }
.hint { font-size: 12px; color: var(--hint); font-weight: 400; }

textarea, input[type="text"], input[type="number"], input[type="password"], select {
  width: 100%;
  border: 1px solid var(--line);
  background: #fbfbfd;
  border-radius: 11px;
  padding: 11px 12px;
  font-size: 15px;
  color: var(--text);
  font-family: inherit;
  outline: none;
  transition: border-color .15s, background .15s;
}
textarea:focus, input:focus, select:focus { border-color: var(--accent); background: #fff; }
textarea { min-height: 180px; resize: vertical; line-height: 1.7; }

/* ---------- 按钮 ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: none;
  border-radius: 11px;
  padding: 12px 18px;
  font-size: 15px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  background: #eef0f5;
  color: var(--text);
  white-space: nowrap;
  transition: opacity .15s, transform .06s;
}
.btn:active { transform: scale(.985); }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.btn-primary { background: linear-gradient(135deg, #2f6bff, #5b5bff); color: #fff; }
.btn-block { display: flex; width: 100%; }
.btn-sm { padding: 8px 14px; font-size: 13px; border-radius: 9px; }
.btn-ghost { background: #fff; border: 1px solid var(--line); }

/* ---------- 字数档位 ---------- */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 999px;
  padding: 7px 15px;
  font-size: 13.5px;
  color: var(--sub);
  cursor: pointer;
  transition: all .15s;
}
.chip.active { background: var(--accent-soft); border-color: #b9cdfd; color: var(--accent); font-weight: 600; }

/* ---------- 勾选 ---------- */
.check {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  font-size: 13.5px;
  color: var(--sub);
  cursor: pointer;
  user-select: none;
}
.check input { width: 17px; height: 17px; accent-color: var(--accent); margin: 2px 0 0; flex: none; }

/* ---------- 结果 ---------- */
.result-text {
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 15.5px;
  line-height: 1.85;
  color: #1f232b;
  max-height: 62vh;
  overflow: auto;
}
.result-meta {
  display: flex; flex-wrap: wrap; gap: 10px;
  font-size: 12px; color: var(--hint);
  padding: 10px 0 0; border-top: 1px solid var(--line); margin-top: 12px;
}

/* ---------- 列表 ---------- */
.list { margin: 0; padding: 0; list-style: none; }
.row {
  display: flex; align-items: center; gap: 12px;
  padding: 13px 0;
  border-bottom: 1px solid var(--line);
}
.row:last-child { border-bottom: none; }
.row-main { flex: 1; min-width: 0; }
.row-title {
  font-size: 14.5px; font-weight: 550;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.row-sub { font-size: 12px; color: var(--hint); margin-top: 2px; }
.row-side { text-align: right; flex: none; font-size: 13px; }
.amount-neg { color: var(--danger); font-weight: 600; }
.amount-pos { color: var(--ok); font-weight: 600; }

.empty { text-align: center; color: var(--hint); font-size: 13.5px; padding: 36px 0; }

/* ---------- 积分条 ---------- */
.balance-bar {
  display: flex; align-items: center; gap: 10px;
  background: linear-gradient(135deg, #22305c, #2f4b8f);
  color: #fff;
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 14px;
}
.balance-num { font-size: 26px; font-weight: 700; line-height: 1.1; }
.balance-label { font-size: 12px; opacity: .75; }
.balance-bar .btn { background: rgba(255,255,255,.16); color: #fff; border: 1px solid rgba(255,255,255,.24); }

/* ---------- 底部导航 ---------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  background: rgba(255,255,255,.96);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
  display: flex;
  padding: 6px 0 calc(6px + env(safe-area-inset-bottom));
}
.tabbar a {
  flex: 1; text-align: center;
  font-size: 11.5px; color: var(--hint);
  padding: 5px 0;
}
.tabbar a .ti { display: block; font-size: 19px; line-height: 1.3; }
.tabbar a.active { color: var(--accent); font-weight: 600; }

/* ---------- 提示 ---------- */
.toast {
  position: fixed; left: 50%; bottom: 96px; transform: translateX(-50%);
  background: rgba(23,26,33,.92); color: #fff;
  padding: 10px 18px; border-radius: 10px; font-size: 13.5px;
  z-index: 100; opacity: 0; pointer-events: none;
  transition: opacity .2s, bottom .2s; max-width: 84vw; text-align: center;
}
.toast.show { opacity: 1; bottom: 106px; }
.toast.warn { background: rgba(180,83,9,.94); }
.toast.err { background: rgba(185,28,28,.94); }

.loading-mask {
  position: fixed; inset: 0; background: rgba(255,255,255,.72);
  display: none; align-items: center; justify-content: center; z-index: 90;
  flex-direction: column; gap: 14px;
}
.loading-mask.show { display: flex; }
.spinner {
  width: 34px; height: 34px; border-radius: 50%;
  border: 3px solid #dbe2f5; border-top-color: var(--accent);
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- 弹层 ---------- */
.sheet-mask {
  position: fixed; inset: 0; background: rgba(15,18,26,.42);
  display: none; z-index: 80;
}
.sheet-mask.show { display: block; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 81;
  background: #fff; border-radius: 18px 18px 0 0;
  max-height: 82vh; overflow: auto;
  transform: translateY(100%); transition: transform .24s cubic-bezier(.22,.8,.3,1);
  padding: 18px 16px calc(20px + env(safe-area-inset-bottom));
}
.sheet.show { transform: translateY(0); }
.sheet-head { display: flex; align-items: center; margin-bottom: 12px; }
.sheet-head h3 { margin: 0; font-size: 16px; flex: 1; }

/* ---------- 后台 ---------- */
.admin-wrap { display: flex; min-height: 100vh; }
.admin-side {
  width: 210px; flex: none; background: #fff; border-right: 1px solid var(--line);
  padding: 16px 10px; position: sticky; top: 0; height: 100vh; overflow: auto;
}
.admin-side h1 { font-size: 15px; margin: 0 0 14px; padding: 0 10px; }
.admin-nav { list-style: none; margin: 0; padding: 0; }
.admin-nav a {
  display: block; padding: 9px 12px; border-radius: 9px;
  font-size: 13.5px; color: var(--sub); margin-bottom: 2px;
}
.admin-nav a.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.admin-main { flex: 1; padding: 20px 24px 80px; max-width: 1000px; }
.admin-section { display: none; }
.admin-section.active { display: block; }
.field-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.field { margin-bottom: 14px; }
.save-bar {
  position: fixed; left: 210px; right: 0; bottom: 0;
  background: rgba(255,255,255,.96); backdrop-filter: blur(10px);
  border-top: 1px solid var(--line);
  padding: 12px 24px; display: flex; gap: 10px; align-items: center; z-index: 20;
}
.save-tip { font-size: 12.5px; color: var(--hint); flex: 1; }

table.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
table.tbl th {
  text-align: left; font-weight: 600; color: var(--sub);
  padding: 8px 10px; border-bottom: 1px solid var(--line); font-size: 12.5px;
}
table.tbl td { padding: 9px 10px; border-bottom: 1px solid var(--line); }
table.tbl input, table.tbl select { padding: 6px 8px; font-size: 13px; }

@media (max-width: 760px) {
  .admin-wrap { flex-direction: column; }
  .admin-side { width: 100%; height: auto; position: static; border-right: none; border-bottom: 1px solid var(--line); }
  .admin-nav { display: flex; flex-wrap: wrap; gap: 4px; }
  .admin-nav a { padding: 7px 10px; font-size: 12.5px; }
  .admin-main { padding: 14px 14px 90px; }
  .field-grid { grid-template-columns: 1fr; }
  .save-bar { left: 0; padding: 10px 14px; }
}

/* ---------- 处理记录：列表 ---------- */
.tbl-records td { vertical-align: middle; }
.tbl-records .recrow { cursor: pointer; transition: background .12s; }
.tbl-records .recrow:hover { background: var(--accent-soft); }
.rcol-title {
  max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.rcol-words { white-space: nowrap; font-variant-numeric: tabular-nums; }
.rcol-words b { font-weight: 600; }
.rarrow { color: var(--hint); margin: 0 5px; font-weight: 400; }
.rcol-model { font-size: 12.5px; line-height: 1.35; max-width: 190px; }
.rcol-model .rmuted { color: var(--hint); font-size: 11.5px; word-break: break-all; }
.rmuted { color: var(--hint); }
.rtag {
  display: inline-block; padding: 1px 7px; border-radius: 20px; font-size: 11.5px; font-weight: 600;
}
.rtag-ok { background: #e7f7ee; color: var(--ok); }
.rtag-fail { background: #fdecec; color: var(--danger); }
.btn-mini {
  padding: 4px 10px; font-size: 12px; border-radius: 7px; background: #fff; border: 1px solid var(--line);
  color: var(--sub); cursor: pointer;
}
.btn-mini:hover { border-color: var(--accent); color: var(--accent); }

/* ---------- 处理记录：详情弹层 ---------- */
.rmask {
  display: none; position: fixed; inset: 0; background: rgba(18, 22, 34, .45); z-index: 300;
  backdrop-filter: blur(2px);
}
.rmask.show { display: block; }
.rmodal {
  display: none; position: fixed; z-index: 301;
  left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: min(980px, 94vw); max-height: 90vh;
  background: var(--card); border-radius: 16px; box-shadow: 0 20px 60px rgba(15, 20, 40, .22);
  overflow: hidden; flex-direction: column;
}
.rmodal.show { display: flex; }
.rmodal-head {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 16px 20px; border-bottom: 1px solid var(--line); background: #fff;
}
.rmodal-headmain { flex: 1; min-width: 0; }
.rmodal-title {
  font-size: 16px; font-weight: 650; line-height: 1.35;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.rmodal-sub { font-size: 12.5px; color: var(--hint); margin-top: 4px; }
.rmodal-body { padding: 14px 20px 20px; overflow-y: auto; flex: 1; }

.rmeta {
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1px;
  background: var(--line); border: 1px solid var(--line); border-radius: 10px; overflow: hidden;
  margin-bottom: 14px;
}
.rmeta-item { background: #fff; padding: 9px 12px; min-width: 0; }
.rmeta-k { font-size: 11.5px; color: var(--hint); margin-bottom: 2px; }
.rmeta-v { font-size: 13px; font-weight: 600; word-break: break-word; line-height: 1.45; }
.rmeta-v code { font-size: 12px; background: #f4f5f8; padding: 1px 5px; border-radius: 4px; font-weight: 500; }

.rtabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 12px; }
.rtab {
  border: none; background: transparent; padding: 8px 14px; font-size: 13.5px; cursor: pointer;
  color: var(--sub); border-bottom: 2px solid transparent; margin-bottom: -1px; font-family: inherit;
}
.rtab.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }

.rpane { display: none; }
.rpane.active { display: block; }
.rpane-bar {
  display: flex; align-items: center; gap: 10px; justify-content: space-between;
  margin-bottom: 8px; font-size: 12px;
}
.rtext {
  margin: 0; padding: 14px 16px; background: #f8f9fc; border: 1px solid var(--line); border-radius: 10px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "PingFang SC", monospace;
  font-size: 13px; line-height: 1.75; white-space: pre-wrap; word-break: break-word;
  color: var(--text); max-height: 46vh; overflow: auto;
}

.rtable { width: 100%; border-collapse: collapse; font-size: 13px; }
.rtable th, .rtable td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.rtable > tbody > tr > th { width: 130px; color: var(--sub); font-weight: 600; background: #fafbfd; white-space: nowrap; }
.rtable > thead > tr > th { color: var(--sub); font-size: 12px; background: #fafbfd; }
.rtable code { font-size: 12px; background: #f4f5f8; padding: 1px 5px; border-radius: 4px; }

@media (max-width: 760px) {
  /* 宽表在窄屏会横向溢出 → 整行退回纵向流，别用 :has()（Chrome<105 整条规则会丢） */
  .tbl-records thead { display: none; }
  .tbl-records tr { display: flex; flex-wrap: wrap; padding: 10px 4px; border-bottom: 1px solid var(--line); gap: 4px 12px; }
  .tbl-records td { border: none; padding: 2px 6px; display: block; flex: 0 0 auto; }
  .tbl-records .rcol-title { max-width: none; white-space: normal; flex: 1 1 100%; font-weight: 600; }
  .rmeta { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .rmodal { width: 96vw; max-height: 94vh; }
  .rmodal-body { padding: 12px 14px 16px; }
  .rtext { max-height: 40vh; font-size: 12.5px; }
}

/* ---------- 三级 AI 通道（主用 / 备用 / 备用2） ---------- */
.ai-tiers {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}
.ai-tier {
  border: 1px solid var(--line);
  border-top: 3px solid var(--accent);
  border-radius: 10px;
  padding: 14px 14px 4px;
  background: #fcfdff;
  min-width: 0;
}
.ai-tier-2 { border-top-color: var(--warn); }
.ai-tier-3 { border-top-color: var(--hint); }
.ai-tier-title {
  margin: 0 0 12px;
  font-size: 14.5px;
  font-weight: 650;
  display: flex;
  flex-direction: column;
  gap: 3px;
  line-height: 1.4;
}
.ai-tier-note {
  font-size: 11.5px;
  font-weight: 400;
  color: var(--hint);
}
.ai-tier .field { margin-bottom: 10px; }
.ai-tier .field:last-child { margin-bottom: 0; }
.ai-tier input, .ai-tier select { width: 100%; }

.ai-policy {
  padding: 12px 14px;
  border: 1px dashed var(--line);
  border-radius: 10px;
  background: #fafbfd;
  margin-bottom: 14px;
}
.ai-policy .hint { font-weight: 400; color: var(--hint); font-size: 12px; }

@media (max-width: 980px) {
  .ai-tiers { grid-template-columns: 1fr; }
}

/* 列表里的通道级别小标 */
.rtag-tier {
  display: inline-block; padding: 0 5px; margin-right: 5px; border-radius: 4px;
  font-size: 10.5px; font-weight: 700; line-height: 1.6; vertical-align: 1px;
}
.rtag-tier-p { background: var(--accent-soft); color: var(--accent); }
.rtag-tier-b { background: #fdf2e3; color: var(--warn); }
.rtag-tier-b2 { background: #f0f1f4; color: var(--sub); }

/* 密钥框：输入 + 显示/隐藏 */
.key-row { display: flex; gap: 8px; align-items: stretch; }
.key-row input { flex: 1; min-width: 0; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12.5px; }
.key-eye { flex: 0 0 auto; white-space: nowrap; }

/* ---------- 等待进度条 ---------- */
/* 进度面板：独立白卡，别让进度条浮在正文上 */
.loading-mask .prog-wrap { display: none; width: min(320px, 80vw); text-align: center; }
.loading-mask.with-progress {
  background: rgba(246, 247, 251, .93);
  backdrop-filter: blur(6px);
}
.loading-mask.with-progress .prog-wrap {
  display: block;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 24px 22px 20px;
  box-shadow: 0 14px 44px rgba(20, 24, 40, .13);
}
.loading-mask.with-progress .spinner { display: none; }
.loading-mask.with-progress .loading-text { display: none; }

.prog-title { font-size: 14.5px; font-weight: 650; color: var(--text); margin-bottom: 10px; }

.prog-pct { font-size: 26px; font-weight: 700; color: var(--accent); line-height: 1.2; }
.prog-pct b { font-variant-numeric: tabular-nums; }
.prog-pct i { font-size: 14px; font-style: normal; font-weight: 600; margin-left: 2px; }

.prog-track {
  height: 8px; border-radius: 99px; background: #e3e8f4; overflow: hidden; margin: 10px 0 9px;
}
.prog-bar {
  height: 100%; width: 0; border-radius: 99px;
  background: linear-gradient(90deg, #2f6bff, #6b8bff);
  transition: width .25s linear;
  position: relative;
}
/* 走到哪都带一点流动感，避免「卡住了」的错觉 */
.prog-bar::after {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,.42), transparent);
  animation: progSheen 1.5s linear infinite;
}
@keyframes progSheen { from { transform: translateX(-100%); } to { transform: translateX(100%); } }
.loading-mask.prog-done .prog-bar { background: linear-gradient(90deg, #12a150, #3ec97c); }
.loading-mask.prog-done .prog-bar::after { display: none; }
.loading-mask.prog-done .prog-pct { color: var(--ok); }

.prog-sub { font-size: 12.5px; color: var(--sub); font-variant-numeric: tabular-nums; }
.prog-hint { font-size: 11.5px; color: var(--hint); margin-top: 6px; }

/* 多把 Key 的文本域 + 遮罩态 */
.key-row textarea {
  flex: 1; min-width: 0; resize: vertical; min-height: 62px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px; line-height: 1.5;
  padding: 8px 10px; border: 1px solid var(--line); border-radius: 9px; background: #fff;
  color: var(--text);
}
.key-row textarea.masked { -webkit-text-security: disc; text-security: disc; }

/* ---------- 合规：AI 生成标识 ---------- */
.ai-declare {
  font-size: 12.5px;
  color: var(--hint, #9aa1ad);
  line-height: 1.6;
  margin: -6px 0 12px;
}
.ai-tag {
  display: inline-block;
  font-size: 12px;
  line-height: 1.7;
  padding: 1px 9px;
  margin-bottom: 10px;
  border-radius: 999px;
  background: #eef3ff;
  color: #2f6bff;
  border: 1px solid #d6e2ff;
}
.ai-notice {
  font-size: 12px;
  color: var(--hint, #9aa1ad);
  line-height: 1.7;
  margin-top: 10px;
  padding: 9px 12px;
  background: #f7f8fb;
  border-radius: 8px;
}

/* ---------- 上架合规：强制生效项（不可配置） ---------- */
/* 用「锁定」的视觉语言，让运营一眼看出这不是开关，别再去找勾选框 */
.policy-lock {
  margin-top: 14px;
  border: 1px solid var(--line, #e5e7ef);
  border-radius: 10px;
  overflow: hidden;
}
.policy-row {
  display: flex;
  gap: 14px;
  padding: 12px 14px;
  border-top: 1px solid var(--line, #e5e7ef);
  background: #fbfcfe;
}
.policy-row:first-child { border-top: 0; }
.policy-k {
  flex: 0 0 92px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--sub, #6b7280);
  line-height: 1.8;
}
.policy-v {
  flex: 1;
  min-width: 0;
  font-size: 12.5px;
  line-height: 1.8;
  color: var(--text, #1f232b);
}
.policy-v .hint { margin-left: 8px; color: var(--hint, #9aa1ad); }
/* 后台预览用的胶囊：与前台同款，但去掉为正文留的底边距 */
.policy-v .ai-tag { margin-bottom: 0; }
