/* 新版「候选发件」（/search-candidates）页面样式。外观按原型 prototypes/shadcn-style/search-candidates.html，只用 ds.css 的颜色变量。
   不再加载 legacy/search-candidates.css、legacy-tokens.css、legacy-modules.css：
   - 本页 DOM（模板 + legacy/search-candidates-app.js 生成）已改用原型 / ds.css 的类名，下面是原型 <style> 里的页面级规则；
   - 发信向导"发送时间"一步仍用旧版类名（search-candidate-schedule-*），在这里按原型风格重写；
   - 旧模块 sparkols_mail_admin.js 的模板编辑器（发信向导里"新建模板 / 编辑"打开，挂在 body 下的 #sparkols-mail-template-editor）
     生成的 DOM 不能改，文件末尾按原型风格重写，作用域限定在该编辑器内。
   层级：本页弹窗 .dialog 50+（外壳管理）< 模板编辑器 70 < UI.alert/confirm 75/80。 */

/* ---------- 摘要 / 筛选 / 操作行（原型 .summary / .filters / .actionbar） ---------- */
#page-search-candidates [hidden] { display: none !important; }
/* 摘要：一行数字，不再做成大方块（搜索结果方案 B） */
#page-search-candidates .summary { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 16px; margin-bottom: 12px; font-size: 13px; color: var(--muted-foreground); }
#page-search-candidates .summary .stat { display: inline-flex; align-items: baseline; gap: 4px; padding: 0; border: 0; background: none; }
#page-search-candidates .summary .stat span { font-size: 13px; }
#page-search-candidates .summary .stat b { display: inline; font-size: 15px; font-weight: 600; color: var(--foreground); letter-spacing: 0; }
#page-search-candidates .filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 8px; }
#page-search-candidates .filters select.input { width: auto; min-width: 130px; }
#page-search-candidates .filters .sc-search { width: 260px; max-width: 100%; }
#page-search-candidates .filters .sc-source-task { max-width: 240px; }
#page-search-candidates .filters .sc-min-median { width: 140px; }
#page-search-candidates .actionbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; font-size: 13px; }
#page-search-candidates .actionbar .end { margin-left: auto; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
#page-search-candidates .actionbar label { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }
#page-search-candidates .actionbar .sc-page-size { width: 68px; }
#page-search-candidates .sc-danger, .sc-dialog .sc-danger { color: var(--destructive); }

/* 国家/地区分类：details 折叠面板做成按钮下拉（原型 .geo） */
#page-search-candidates .geo { position: relative; }
#page-search-candidates .geo > summary { list-style: none; }
#page-search-candidates .geo > summary::-webkit-details-marker { display: none; }
#page-search-candidates .geo[open] > .popover { display: block; width: 420px; max-width: calc(100vw - 32px); padding: 12px; }
#page-search-candidates .geo .geo-note { margin: 0 0 8px; }
#page-search-candidates .geo .grp { font-size: 12px; color: var(--muted-foreground); margin: 8px 0 6px; }
#page-search-candidates .geo .grp:empty { margin: 6px 0 0; }
#page-search-candidates .geo .opts { display: flex; flex-wrap: wrap; gap: 4px 12px; }
#page-search-candidates .geo .opts label { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; cursor: pointer; }
#page-search-candidates .geo .geo-foot { display: flex; justify-content: flex-end; margin-top: 8px; }

/* ---------- 候选卡片（原型 .cand-grid / .cc） ---------- */
#page-search-candidates .cand-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 12px; }
#page-search-candidates .cand-grid[aria-busy="true"] { opacity: .6; transition: opacity .15s; }
#page-search-candidates .sc-span { grid-column: 1 / -1; }
#page-search-candidates .cc { padding: 14px; display: flex; flex-direction: column; gap: 10px; min-width: 0; }
#page-search-candidates .cc.selected { border-color: var(--primary); box-shadow: 0 0 0 1px var(--primary); }
#page-search-candidates .cc-head { display: flex; gap: 10px; align-items: center; min-width: 0; }
#page-search-candidates .cc-head .checkbox { flex: none; }
#page-search-candidates .cc-head .avatar { width: 40px; height: 40px; font-size: 14px; }
#page-search-candidates .cc-avatar-link { flex: none; border-radius: 50%; color: inherit; text-decoration: none; }
#page-search-candidates .cc-head .avatar { position: relative; overflow: hidden; }
#page-search-candidates .cc-head .avatar img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
#page-search-candidates .cc-name { flex: 1; min-width: 0; }
#page-search-candidates .cc-name strong { display: flex; align-items: center; gap: 2px; min-width: 0; font-weight: 600; font-size: 14px; }
#page-search-candidates .cc-name strong a { color: inherit; text-decoration: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
#page-search-candidates .cc-name strong svg { width: 13px; height: 13px; flex: none; color: var(--muted-foreground); }
#page-search-candidates .cc-name strong a:hover { text-decoration: underline; }
#page-search-candidates .cc-name small { display: block; color: var(--muted-foreground); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* 状态短标签：一行，图标 + 2~4 个字；缺少邮箱仍用提醒色（同旧版） */
#page-search-candidates .cc-state { display: flex; flex-wrap: wrap; gap: 4px; }
#page-search-candidates .cc-chip { display: inline-flex; align-items: center; gap: 4px; height: 22px; padding: 0 7px; border-radius: 6px; font-size: 12px; font-weight: 500; white-space: nowrap; background: var(--secondary); color: var(--foreground-2); text-decoration: none; }
#page-search-candidates .cc-chip svg { width: 13px; height: 13px; flex: none; }
#page-search-candidates .cc-chip.tone-success { background: var(--success-soft); color: var(--success); }
#page-search-candidates .cc-chip.tone-warning { background: var(--warning-soft); color: var(--warning); }
#page-search-candidates .cc-chip.tone-danger { background: var(--destructive-soft); color: var(--destructive); }
#page-search-candidates .cc-chip.tone-muted { background: transparent; border: 1px solid var(--border); color: var(--muted-foreground); }
#page-search-candidates a.cc-chip { color: var(--success); }
#page-search-candidates .sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
/* 固定指标条：粉丝 | 均播 | 中位 | 互动率 */
#page-search-candidates .cc-kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); border: 1px solid var(--border); border-radius: var(--radius); }
#page-search-candidates .cc-kpis > div { padding: 6px 8px; min-width: 0; }
#page-search-candidates .cc-kpis > div + div { border-left: 1px solid var(--border); }
#page-search-candidates .cc-kpis span { display: block; font-size: 11px; color: var(--muted-foreground); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#page-search-candidates .cc-kpis b { display: block; font-size: 15px; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#page-search-candidates .cc-kpis b.is-empty { color: var(--muted-foreground); font-weight: 500; font-size: 13px; }
#page-search-candidates .cc-tags { display: flex; flex-wrap: wrap; gap: 4px; max-height: 44px; overflow: hidden; }
#page-search-candidates .cc-tags .badge { height: 20px; padding: 0 6px; font-size: 11px; }
#page-search-candidates .cc-alert { padding: 8px 12px; font-size: 13px; }
#page-search-candidates .cc-alert svg { width: 16px; height: 16px; flex: none; color: var(--warning); }
#page-search-candidates .cc-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; font-size: 13px; min-width: 0; }
#page-search-candidates .cc-row > span:first-child { color: var(--muted-foreground); font-size: 12px; width: 56px; flex-shrink: 0; }
#page-search-candidates .cc-row > .sparkols-creator-tags-cell { flex: 1; min-height: 24px; }
/* 来源一行：来源任务 · 搜索词 · 加入时间（完整内容在 title） */
#page-search-candidates .cc-src { display: flex; align-items: center; gap: 4px; font-size: 12px; color: var(--muted-foreground); min-width: 0; }
#page-search-candidates .cc-src svg { width: 13px; height: 13px; flex: none; }
#page-search-candidates .cc-src span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#page-search-candidates .cc-actions { display: flex; align-items: center; justify-content: flex-end; gap: 6px; flex-wrap: nowrap; border-top: 1px solid var(--border); padding-top: 10px; margin-top: auto; } /* 卡片等高时操作栏贴底对齐 */
#page-search-candidates .cc-actions .btn { flex-shrink: 0; }

/* 分页（原型 .pagination） */
#page-search-candidates .pagination { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; justify-content: center; margin-top: 16px; }
#page-search-candidates .pagination .pagination-summary { font-size: 13px; margin-right: 8px; }
#page-search-candidates .pagination .btn.active { background: var(--primary); color: var(--primary-foreground); }

/* ---------- 弹窗共用（导入邮箱 / 编辑资料 / 发信向导，已挂到 body 下） ---------- */
.sc-dialog { max-height: calc(100vh - 32px); overflow: auto; }
.sc-dialog h2.sc-dialog-title { margin-bottom: 4px; padding-right: 32px; }
.sc-dialog .sc-dialog-sub { margin: 0 0 16px; font-size: 13px; }
.sc-dialog .field .hint { line-height: 1.5; }
.sc-dialog .input:disabled { background: var(--muted); cursor: not-allowed; }
.sc-dialog textarea.input, .sc-dialog .sc-textarea { height: auto; min-height: 96px; padding: 8px 12px; resize: vertical; font: inherit; }
.sc-dialog .empty b { color: var(--foreground); font-weight: 500; }
.sc-dialog .empty.is-error b { color: var(--destructive); }
.sc-dialog .empty .btn { margin-top: 4px; }

/* 导入收件人邮箱：原型 .drop */
.sc-dialog .drop { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 16px; border: 1px dashed var(--input); border-radius: var(--radius); }
.sc-dialog .drop > svg { width: 24px; height: 24px; color: var(--muted-foreground); flex: none; }
.sc-dialog .drop .drop-main { flex: 1; min-width: 180px; }
.sc-dialog .drop .drop-main b { font-weight: 500; overflow-wrap: anywhere; }
.sc-dialog .search-candidate-email-import-status { font-size: 12px; color: var(--muted-foreground); line-height: 1.5; }
.sc-dialog .search-candidate-email-import-status.is-success { color: var(--success); }
.sc-dialog .search-candidate-email-import-status.is-error { color: var(--destructive); }
.sc-dialog .search-candidate-email-import-template-busy { pointer-events: none; opacity: .6; cursor: progress; }
/* 11-19 导入结果：缺字段的行在预览里直接补（待补全），补齐后变成可导入 */
.sc-dialog .search-candidate-email-import-result { display: grid; gap: 10px; margin-top: 12px; }
.sc-dialog .search-candidate-email-import-skipped { font-size: 12px; color: var(--muted-foreground); }
.sc-dialog .search-candidate-email-import-skipped ul { margin: 2px 0 0; padding-left: 18px; max-height: 96px; overflow: auto; line-height: 1.6; }
.sc-dialog .search-candidate-email-import-preview { border: 1px solid var(--border); border-radius: var(--radius); max-height: 320px; overflow: auto; font-size: 12px; }
.sc-dialog .search-candidate-email-import-row { display: grid; grid-template-columns: minmax(130px, 1.2fr) 76px minmax(96px, 1fr) minmax(110px, 1.2fr) 136px 52px; gap: 8px; align-items: center; padding: 7px 10px; border-bottom: 1px solid var(--border); }
.sc-dialog .search-candidate-email-import-row:last-child { border-bottom: 0; }
.sc-dialog .search-candidate-email-import-row > * { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sc-dialog .search-candidate-email-import-row > span:has(> .input) { overflow: visible; }
.sc-dialog .search-candidate-email-import-row .input { width: 100%; }
.sc-dialog .search-candidate-email-import-row.is-pending { background: color-mix(in srgb, var(--warning) 8%, transparent); }
.sc-dialog .search-candidate-email-import-row[aria-busy="true"] { opacity: .7; }
.sc-dialog .search-candidate-email-import-row a { color: var(--muted-foreground); }
.sc-dialog .search-candidate-email-import-row-note { grid-column: 1 / -1; color: var(--destructive); white-space: normal !important; }
.sc-dialog .search-candidate-email-import-tag { justify-self: end; padding: 1px 6px; border-radius: 999px; background: color-mix(in srgb, var(--success) 14%, transparent); color: var(--success); font-size: 11px; }
.sc-dialog .search-candidate-email-import-tag.is-pending { background: color-mix(in srgb, var(--warning) 18%, transparent); color: var(--warning); }
.sc-dialog .search-candidate-email-import-more { padding: 7px 10px; color: var(--muted-foreground); }
/* 11-21 数据原则 5：国家 + 粉丝数一格（库里带出的直接显示，缺的出输入框） */
.sc-dialog .search-candidate-email-import-cf { display: flex; gap: 6px; align-items: center; overflow: visible !important; }
.sc-dialog .search-candidate-email-import-cf > * { flex: 1 1 0; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.sc-dialog .search-candidate-email-import-cf > span:first-child { flex: 0 0 auto; }
@media (max-width: 640px) {
  .sc-dialog .search-candidate-email-import-row { grid-template-columns: minmax(0, 1fr) auto; row-gap: 4px; }
  .sc-dialog .search-candidate-email-import-row > :nth-child(2) { grid-column: 2; grid-row: 1; }
  .sc-dialog .search-candidate-email-import-row > :nth-child(3) { grid-column: 1; grid-row: 2; }
  .sc-dialog .search-candidate-email-import-row > :nth-child(6) { grid-column: 2; grid-row: 2; }
  .sc-dialog .search-candidate-email-import-row > :nth-child(4) { grid-column: 1 / -1; grid-row: 3; }
  .sc-dialog .search-candidate-email-import-row > :nth-child(5) { grid-column: 1 / -1; grid-row: 4; }
  .sc-dialog .search-candidate-email-import-row.is-pending > :nth-child(2) { grid-column: 1 / -1; grid-row: 2; }
  .sc-dialog .search-candidate-email-import-row.is-pending > :nth-child(3) { grid-column: 1 / -1; grid-row: 3; }
  .sc-dialog .search-candidate-email-import-row.is-pending > :nth-child(4) { grid-column: 1 / -1; grid-row: 4; }
  .sc-dialog .search-candidate-email-import-row.is-pending > :nth-child(5) { grid-column: 1 / -1; grid-row: 5; }
  .sc-dialog .search-candidate-email-import-row.is-pending > :nth-child(6) { grid-column: 2; grid-row: 1; }
  .sc-dialog .search-candidate-email-import-row-note { grid-row: 6; }
}

/* ---------- 发信向导（原型 #dialog-mail） ---------- */
.sc-mail-dialog:focus { outline: none; }
.sc-mail-dialog .steps { flex-wrap: nowrap; }
.sc-mail-dialog .sc-mail-foot { flex-wrap: wrap; align-items: center; }
.sc-mail-dialog .sc-mail-options { display: flex; gap: 12px; flex-wrap: wrap; margin-right: auto; font-size: 13px; color: var(--muted-foreground); }
.sc-mail-dialog .sc-mail-options label { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }
.sc-mail-dialog .alert svg { width: 16px; height: 16px; flex: none; color: var(--warning); }

/* 第 1 步：发件邮箱 + 模板卡（原型 .tpl；选中样式跟随单选框） */
.sc-mail-dialog .tpl-label { font-weight: 500; font-size: 14px; margin-bottom: 8px; }
.sc-mail-dialog .tpl { display: flex; gap: 8px; align-items: flex-start; padding: 12px; border: 1px solid var(--border); border-radius: var(--radius); }
.sc-mail-dialog .tpl + .tpl { margin-top: 8px; }
.sc-mail-dialog .tpl:hover { background: color-mix(in srgb, var(--muted) 60%, transparent); }
.sc-mail-dialog .tpl:has(input:checked) { border-color: var(--primary); box-shadow: 0 0 0 1px var(--primary); }
.sc-mail-dialog .tpl > label { display: flex; gap: 12px; align-items: flex-start; flex: 1; min-width: 0; cursor: pointer; }
.sc-mail-dialog .tpl input { margin-top: 3px; accent-color: var(--primary); flex: none; }
.sc-mail-dialog .tpl label > div { flex: 1; min-width: 0; }
.sc-mail-dialog .tpl b { font-weight: 500; }
.sc-mail-dialog .tpl small { display: block; margin-top: 2px; color: var(--muted-foreground); font-size: 12px; overflow-wrap: anywhere; }

/* 第 2 步：变量映射（原型 .map-grid） */
.sc-mail-dialog .mail-intro { display: grid; gap: 2px; margin-bottom: 16px; }
.sc-mail-dialog .mail-intro b { font-weight: 500; }
.sc-mail-dialog .map-grid { display: grid; grid-template-columns: 160px 1fr; gap: 8px 12px; align-items: start; }
.sc-mail-dialog .map-grid .head { font-size: 12px; color: var(--muted-foreground); font-weight: 500; }
.sc-mail-dialog .map-row { display: contents; }
.sc-mail-dialog .map-row > .code { justify-self: start; margin-top: 6px; overflow-wrap: anywhere; }
.sc-mail-dialog .map-cell { display: grid; gap: 4px; min-width: 0; }

/* 第 3 步：发送前预览（原型 .preview） */
.sc-mail-dialog .mail-pv-head { align-items: flex-start; }
.sc-mail-dialog .mail-pv-text { display: grid; gap: 2px; flex: 1; min-width: 0; font-size: 13px; }
.sc-mail-dialog .mail-pv-text b { font-weight: 500; }
.sc-mail-dialog .mail-pv-head .btn { flex: none; }
.sc-mail-dialog .mail-pv-skipped { border: 1px solid var(--border); border-radius: var(--radius); padding: 8px 12px; font-size: 13px; }
.sc-mail-dialog .mail-pv-skipped summary { cursor: pointer; font-weight: 500; }
.sc-mail-dialog .mail-pv-skipped ul { margin: 8px 0 0; padding-left: 18px; display: grid; gap: 4px; max-height: 180px; overflow: auto; }
.sc-mail-dialog .mail-pv-skipped li { overflow-wrap: anywhere; }
.sc-mail-dialog .mail-pv-skipped b { font-weight: 500; }
.sc-mail-dialog .preview { border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.sc-mail-dialog .preview .dl { padding: 12px 16px 0; margin-bottom: 12px; }
.sc-mail-dialog .preview .dl b { font-weight: 500; }
/* 邮件正文是收件人看到的 HTML 邮件，按邮件客户端惯例在白底上渲染（深色模式下也保持白底，避免正文黑字看不清） */
.sc-mail-dialog .preview-frame { display: block; width: 100%; height: 260px; border: 0; border-top: 1px solid var(--border); background: white; }

/* 第 4 步：发送时间（旧版类名，按原型风格重写） */
.sc-mail-dialog .search-candidate-schedule { display: grid; gap: 8px; }
.sc-mail-dialog .search-candidate-schedule-option { display: flex; gap: 10px; align-items: center; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius); cursor: pointer; font-size: 14px; }
.sc-mail-dialog .search-candidate-schedule-option:hover { background: color-mix(in srgb, var(--muted) 60%, transparent); }
.sc-mail-dialog .search-candidate-schedule-option.is-active { border-color: var(--primary); box-shadow: 0 0 0 1px var(--primary); }
.sc-mail-dialog .search-candidate-schedule-option input { accent-color: var(--primary); margin: 0; }
.sc-mail-dialog .search-candidate-schedule-panel { display: grid; gap: 10px; padding: 4px 4px 8px 34px; }
.sc-mail-dialog .search-candidate-schedule-row { display: grid; grid-template-columns: 96px minmax(0, 1fr); gap: 10px; align-items: center; font-size: 13px; color: var(--muted-foreground); }
.sc-mail-dialog .search-candidate-schedule-row input[type=date] { width: 170px; }
.sc-mail-dialog .search-candidate-schedule-row select { width: 220px; max-width: 100%; }
.sc-mail-dialog .search-candidate-schedule-window { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.sc-mail-dialog .search-candidate-schedule-window input { width: 120px; }
.sc-mail-dialog .search-candidate-schedule-window em { font-style: normal; }
.sc-mail-dialog .search-candidate-schedule-estimate { border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 12px; font-size: 13px; color: var(--muted-foreground); }
.sc-mail-dialog .search-candidate-schedule-estimate table { width: 100%; border-collapse: collapse; table-layout: fixed; }
.sc-mail-dialog .search-candidate-schedule-estimate td { padding: 6px 0; border-bottom: 1px solid var(--border); color: var(--foreground); }
.sc-mail-dialog .search-candidate-schedule-estimate td:nth-child(2) { text-align: right; width: 80px; font-variant-numeric: tabular-nums; }
.sc-mail-dialog .search-candidate-schedule-estimate td:nth-child(3) { text-align: right; width: 190px; color: var(--muted-foreground); }
.sc-mail-dialog .search-candidate-schedule-summary { margin-bottom: 6px; }
.sc-mail-dialog .search-candidate-schedule-summary b,
.sc-mail-dialog .search-candidate-schedule-eta b { color: var(--foreground); font-weight: 600; }
.sc-mail-dialog .search-candidate-reach { border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 12px; margin-bottom: 12px; font-size: 13px; color: var(--muted-foreground); }
.sc-mail-dialog .search-candidate-reach-main { font-size: 14px; color: var(--foreground); }
.sc-mail-dialog .search-candidate-reach-main b { font-size: 18px; font-weight: 600; font-variant-numeric: tabular-nums; }
.sc-mail-dialog .search-candidate-reach-main span { color: var(--muted-foreground); }
.sc-mail-dialog .search-candidate-reach-note { margin-top: 4px; }
.sc-mail-dialog .search-candidate-reach-parts { grid-template-columns: repeat(4, 1fr); margin: 8px 0 0; }
@media (max-width: 640px) { .sc-mail-dialog .search-candidate-reach-parts { grid-template-columns: repeat(2, 1fr); } }
.sc-mail-dialog .search-candidate-reach-parts .stat b { font-size: 16px; }
.sc-mail-dialog .search-candidate-reach.is-error { color: var(--destructive); }
.sc-mail-dialog .search-candidate-schedule-eta { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-top: 10px; }

/* ---------- 窄屏 ---------- */
@media (max-width: 900px) {
  #page-search-candidates .actionbar .end { margin-left: 0; width: 100%; }
}
@media (max-width: 640px) {
  #page-search-candidates .filters .sc-search, #page-search-candidates .filters select.input { width: 100%; max-width: none; }
  #page-search-candidates .cand-grid { grid-template-columns: minmax(0, 1fr); }
  .sc-dialog .form-grid { grid-template-columns: minmax(0, 1fr); }
  .sc-mail-dialog .map-grid { grid-template-columns: minmax(0, 1fr); }
  .sc-mail-dialog .map-grid .head:nth-child(2) { display: none; }
  .sc-mail-dialog .search-candidate-schedule-panel { padding-left: 0; }
  .sc-mail-dialog .search-candidate-schedule-row { grid-template-columns: minmax(0, 1fr); }
  .sc-mail-dialog .steps > div { font-size: 12px; }
}

/* ---------- 旧模块：邮件模板编辑器（sparkols_mail_admin.js openSparkolsMailTemplateEditor，挂在 body 下） ----------
   结构：.sparkols-template-editor-modal > .sparkols-template-editor-card（头部 → AI 草稿 → 基本信息 → 语言版本 → 底部按钮） */
#sparkols-mail-template-editor.sparkols-template-editor-modal { position: fixed; inset: 0; z-index: 70; display: flex; align-items: center; justify-content: center; padding: 16px; background: var(--overlay); }
#sparkols-mail-template-editor .sparkols-template-editor-card { width: min(1180px, 100%); max-height: calc(100vh - 32px); display: flex; flex-direction: column; gap: 12px; overflow: auto; padding: 24px; border: 1px solid var(--border); border-radius: 12px; background: var(--background); color: var(--foreground); box-shadow: var(--shadow-lg); }
#sparkols-mail-template-editor .sparkols-template-editor-head { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
#sparkols-mail-template-editor .sparkols-template-editor-head b { display: block; font-size: 18px; font-weight: 600; }
#sparkols-mail-template-editor .sparkols-template-editor-head span { display: block; margin-top: 4px; color: var(--muted-foreground); font-size: 13px; }
#sparkols-mail-template-editor .sparkols-template-editor-actions { display: flex; justify-content: flex-end; align-items: center; gap: 8px; flex-wrap: wrap; padding-top: 4px; }
/* 旧版按钮 / 输入框 → ds.css 的 .btn / .input 外观 */
#sparkols-mail-template-editor :is(.sparkols-btn, .sparkols-btn-xs) {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 32px; padding: 0 12px;
  border: 1px solid transparent; border-radius: var(--radius); background: var(--primary); color: var(--primary-foreground);
  box-shadow: var(--shadow-sm); font: inherit; font-size: 13px; font-weight: 500; white-space: nowrap; cursor: pointer;
}
#sparkols-mail-template-editor :is(.sparkols-btn, .sparkols-btn-xs):hover { opacity: .9; }
#sparkols-mail-template-editor .sparkols-btn-secondary { background: var(--background); color: var(--foreground); border-color: var(--input); }
#sparkols-mail-template-editor .sparkols-btn-secondary:hover { opacity: 1; background: var(--accent); }
#sparkols-mail-template-editor :is(.sparkols-btn, .sparkols-btn-xs):disabled { opacity: .5; cursor: not-allowed; }
#sparkols-mail-template-editor :is(.sparkols-input, .sparkols-textarea) {
  width: 100%; height: 36px; padding: 0 12px; border: 1px solid var(--input); border-radius: 6px;
  background: transparent; color: var(--foreground); box-shadow: var(--shadow-sm); font: inherit; font-size: 14px;
}
#sparkols-mail-template-editor :is(.sparkols-textarea, textarea.sparkols-input) { height: auto; min-height: 72px; padding: 8px 12px; resize: vertical; }
#sparkols-mail-template-editor :is(.sparkols-input, .sparkols-textarea):focus { outline: none; border-color: var(--ring); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ring) 35%, transparent); }
#sparkols-mail-template-editor .sparkols-muted { color: var(--muted-foreground); }
/* 区块 */
#sparkols-mail-template-editor :is(.sparkols-mail-template-ai-panel, .sparkols-mail-template-editor-section) { padding: 16px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--card); }
#sparkols-mail-template-editor .sparkols-mail-template-ai-panel { background: var(--soft); }
#sparkols-mail-template-editor :is(.sparkols-mail-template-ai-head, .sparkols-mail-template-section-head) { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
#sparkols-mail-template-editor .sparkols-mail-template-ai-head { margin-bottom: 10px; }
#sparkols-mail-template-editor :is(.sparkols-mail-template-ai-head, .sparkols-mail-template-section-head) b { display: block; font-size: 14px; font-weight: 600; }
#sparkols-mail-template-editor :is(.sparkols-mail-template-ai-head, .sparkols-mail-template-section-head) span { display: block; margin-top: 2px; color: var(--muted-foreground); font-size: 12px; }
#sparkols-mail-template-editor .sparkols-mail-template-ai-controls { display: grid; grid-template-columns: minmax(220px, 320px) minmax(0, 1fr); gap: 12px; margin-top: 10px; align-items: start; }
#sparkols-mail-template-editor :is(.sparkols-mail-template-ai-controls, .sparkols-mail-template-form-grid, .sparkols-mail-template-version-fields) label { display: flex; min-width: 0; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 500; }
#sparkols-mail-template-editor .sparkols-mail-template-field-label { margin-bottom: 6px; font-size: 13px; font-weight: 500; }
#sparkols-mail-template-editor .sparkols-mail-template-lang-picker { display: flex; flex-wrap: wrap; gap: 8px 12px; padding: 10px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--background); }
#sparkols-mail-template-editor .sparkols-mail-template-ai-controls label.sparkols-mail-template-lang-option,
#sparkols-mail-template-editor .sparkols-mail-template-lang-option { display: inline-flex; flex-direction: row; align-items: center; gap: 6px; font-size: 12px; font-weight: 400; cursor: pointer; white-space: nowrap; }
#sparkols-mail-template-editor :is(.sparkols-mail-template-lang-option, .sparkols-mail-template-inline-check) input { width: 16px; height: 16px; margin: 0; flex: none; accent-color: var(--primary); }
#sparkols-mail-template-editor .sparkols-mail-template-ai-status { margin-top: 8px; font-size: 12px; }
#sparkols-mail-template-editor .sparkols-mail-template-form-grid { display: grid; grid-template-columns: minmax(170px, 220px) minmax(240px, 1fr) minmax(160px, 190px) minmax(150px, auto); gap: 12px; align-items: end; }
#sparkols-mail-template-editor .sparkols-mail-template-form-grid label.sparkols-mail-template-inline-check { flex-direction: row; align-items: center; gap: 8px; height: 36px; cursor: pointer; }
/* 语言版本卡片：预览 / 编辑切换（data-view-mode） */
#sparkols-mail-template-editor .sparkols-mail-template-version-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 12px; margin-top: 12px; }
#sparkols-mail-template-editor .sparkols-mail-template-version { display: flex; flex-direction: column; gap: 10px; min-width: 0; overflow: hidden; padding: 12px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--soft); }
#sparkols-mail-template-editor .sparkols-mail-template-version-head { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: start; gap: 10px; min-height: 40px; }
#sparkols-mail-template-editor .sparkols-mail-template-version-preview-heading { grid-column: 1; min-width: 0; padding-top: 2px; }
#sparkols-mail-template-editor .sparkols-mail-template-version-preview-heading span { display: block; color: var(--brand); font-size: 11px; font-weight: 600; }
#sparkols-mail-template-editor .sparkols-mail-template-version-preview-heading strong { display: block; margin-top: 2px; overflow: hidden; font-size: 13px; font-weight: 500; text-overflow: ellipsis; white-space: nowrap; }
#sparkols-mail-template-editor .sparkols-mail-template-version-actions { grid-column: 2; display: flex; align-items: center; justify-content: flex-end; gap: 8px; white-space: nowrap; }
#sparkols-mail-template-editor .sparkols-mail-template-version-switch { display: inline-flex; padding: 2px; border-radius: var(--radius); background: var(--muted); }
#sparkols-mail-template-editor .sparkols-mail-template-version-switch button { height: 28px; padding: 0 10px; border: 0; background: transparent; color: var(--muted-foreground); box-shadow: none; }
#sparkols-mail-template-editor .sparkols-mail-template-version-switch button.is-active { background: var(--background); color: var(--foreground); box-shadow: var(--shadow-sm); }
#sparkols-mail-template-editor .sparkols-mail-template-version-fields { display: grid; grid-template-columns: minmax(120px, .75fr) minmax(0, 1.25fr); gap: 12px; min-width: 0; }
#sparkols-mail-template-editor .sparkols-mail-template-version textarea { min-height: 190px; }
#sparkols-mail-template-editor .sparkols-mail-template-version-frame { display: block; width: 100%; height: 300px; border: 1px solid var(--border); border-radius: var(--radius); background: white; } /* 邮件正文预览：同发信向导，白底渲染 */
#sparkols-mail-template-editor .sparkols-mail-template-version[data-view-mode='preview'] :is(.sparkols-mail-template-version-fields, .sparkols-mail-template-version-edit) { display: none; }
#sparkols-mail-template-editor .sparkols-mail-template-version[data-view-mode='edit'] :is(.sparkols-mail-template-version-preview-heading, .sparkols-mail-template-version-preview) { display: none; }
#sparkols-mail-template-editor .sparkols-mail-template-save-status { margin-right: auto; font-size: 13px; color: var(--muted-foreground); }
#sparkols-mail-template-editor .sparkols-mail-template-save-status.is-success { color: var(--success); }
#sparkols-mail-template-editor .sparkols-mail-template-save-status.is-error { color: var(--destructive); }
#sparkols-mail-template-editor [hidden] { display: none !important; }
@media (max-width: 900px) {
  #sparkols-mail-template-editor :is(.sparkols-mail-template-ai-controls, .sparkols-mail-template-form-grid, .sparkols-mail-template-version-list) { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 560px) {
  #sparkols-mail-template-editor .sparkols-template-editor-card { padding: 16px; }
  #sparkols-mail-template-editor .sparkols-mail-template-version-head { grid-template-columns: minmax(0, 1fr); }
  #sparkols-mail-template-editor .sparkols-mail-template-version-actions { grid-column: 1; justify-content: space-between; }
  #sparkols-mail-template-editor .sparkols-mail-template-version-fields { grid-template-columns: minmax(0, 1fr); }
  #sparkols-mail-template-editor .sparkols-mail-template-version-frame { height: 260px; }
}

/* ---------- 列表方式（需求 ⑤，11-11）：固定 25 条一页，勾选 / 锁定 / 标签编辑与卡片相同 ---------- */
#page-search-candidates .sc-view button { display: inline-flex; align-items: center; gap: 5px; height: 26px; padding: 0 10px; font-size: 12px; }
#page-search-candidates .sc-view button svg { width: 13px; height: 13px; }
#page-search-candidates .cand-table { display: block; }
#page-search-candidates .cand-table[aria-busy="true"] { opacity: .6; transition: opacity .15s; }
#page-search-candidates .sc-table { width: 100%; min-width: 1180px; border-collapse: collapse; font-size: 13px; }
#page-search-candidates .sc-table td { vertical-align: middle; white-space: nowrap; }
#page-search-candidates .sc-table tr.selected td { background: color-mix(in srgb, var(--brand) 6%, var(--card)); }
#page-search-candidates .sc-table td.is-empty { color: var(--muted-foreground); }
#page-search-candidates .sc-who { display: flex; align-items: center; gap: 8px; min-width: 0; max-width: 240px; }
#page-search-candidates .sc-who .avatar { position: relative; overflow: hidden; flex: none; width: 28px; height: 28px; font-size: 11px; }
#page-search-candidates .sc-who .avatar img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
#page-search-candidates .sc-who .cc-name strong { font-size: 13px; }
#page-search-candidates .sc-table .cc-state { flex-wrap: nowrap; }
#page-search-candidates .sc-tags-td { min-width: 160px; max-width: 260px; white-space: normal; }
#page-search-candidates .sc-src { max-width: 180px; overflow: hidden; text-overflow: ellipsis; color: var(--foreground-2); }
#page-search-candidates .sc-time { color: var(--muted-foreground); font-variant-numeric: tabular-nums; }
#page-search-candidates .sc-table .col-actions { width: 104px; }
#page-search-candidates .sc-row-actions { display: flex; justify-content: flex-end; gap: 2px; }

/* 未回复自动跟进（发送时间一步，11-16） */
.sc-mail-dialog .search-candidate-followup { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--border); }
