/* ---------- 主题：经典绿（默认） / 绯红 / 经典蓝 ----------
   只替换品牌色系（主色、深色、浅底、描边、登录页渐变、主题圆点），
   语义色（成功/警告/危险）保持不变，避免换色后误读状态。
   主题写在 <html data-theme>，登录页与主界面一致；首帧前由 index.html 内联脚本先设好，避免闪色。 */
:root {
  --brand: #1f7a5a;
  --brand-dark: #17614a;
  --brand-soft: #e8f3ee;
  --brand-line: #cfe4da;
  --theme-dot: #34d399;
  --brand-ring: rgba(31, 122, 90, .10);
  --login-grad-a: #eef5f1;
  --login-grad-b: #dceae3;
  --bg: #f4f6f5;
  --card: #ffffff;
  --line: #e2e8e4;
  --line-soft: #eef2ef;
  --text: #1b2723;
  --muted: #6b7a73;
  --warn: #b45309;
  --warn-bg: #fdf6e7;
  --danger: #b42318;
  --danger-bg: #fdf0ef;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 40, 32, .04), 0 8px 24px rgba(16, 40, 32, .06);
}

/* 绯红：主色本身是红，危险操作改用更深的暗红并做成实心，避免和主按钮混淆 */
html[data-theme="red"] {
  --brand: #dc143c;
  --brand-dark: #b30f2f;
  --brand-soft: #fdeaee;
  --brand-line: #f7c9d4;
  --theme-dot: #ff6b85;
  --brand-ring: rgba(220, 20, 60, .12);
  --login-grad-a: #fdf0f2;
  --login-grad-b: #f8dde3;
  --danger: #7f1d1d;
  --danger-bg: #fbeaea;
}

/* 经典蓝：#0052d9 主色、#0034b5 按下态、浅蓝作底；危险操作仍是默认红，区分清楚 */
html[data-theme="blue"] {
  --brand: #0052d9;
  --brand-dark: #0034b5;
  --brand-soft: #e9efff;
  --brand-line: #c9d9f7;
  --theme-dot: #7fa9ff;
  --brand-ring: rgba(0, 82, 217, .12);
  --login-grad-a: #eef3fd;
  --login-grad-b: #d9e4fa;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font: 13px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
  color: var(--text);
  background: var(--bg);
}
h1 { font-size: 17px; margin: 0 0 2px; font-weight: 600; }
h2 { font-size: 15px; margin: 0 0 10px; font-weight: 600; }
h3 { font-size: 13px; margin: 0 0 8px; font-weight: 600; }
p { margin: 0; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.spacer { flex: 1; }
[hidden] { display: none !important; }

/* 登录页：账号 / 扫码 两个 Tab —— 下划线风格，选中项用主题色 + 粗底线 */
.login-tabs {
  display: flex; gap: 0; margin: 2px 0 20px;
  border-bottom: 2px solid var(--line); /* 未选中那半边露出的浅灰底线 */
}
.login-tab {
  flex: 1; height: 38px; padding: 0; border: 0; background: transparent;
  color: var(--muted); font: inherit; font-size: 15px; cursor: pointer;
  position: relative; transition: color .15s;
}
.login-tab:hover { color: var(--text); }
.login-tab::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: -2px;
  height: 3px; background: transparent; border-radius: 2px 2px 0 0;
  transition: background .15s;
}
.login-tab.active { color: var(--brand); font-weight: 600; }
.login-tab.active::after { background: var(--brand); }

/* 扫码登录 */
.qr-box { min-height: 260px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; }
.qr-frame {
  width: 232px; height: 232px; border: 1px solid var(--line); border-radius: 10px;
  background: #fff; display: flex; align-items: center; justify-content: center; overflow: hidden;
}
.qr-frame img { width: 232px; height: 232px; display: block; }
.qr-tip { color: var(--muted); font-size: 12.5px; }
.qr-meta { color: var(--muted); font-size: 12px; display: flex; gap: 6px; align-items: center; }
.qr-meta a { color: var(--brand); text-decoration: none; }
.qr-meta a:hover { text-decoration: underline; }
.qr-err { color: var(--danger); font-size: 12.5px; line-height: 1.7; text-align: center; }

/* 登录 */
.login-wrap {
  min-height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--login-grad-a) 0%, var(--login-grad-b) 100%);
  padding: 24px;
}
.login-card {
  width: 380px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 26px 26px 20px;
  box-shadow: var(--shadow);
}
.login-brand { display: flex; gap: 12px; align-items: center; margin-bottom: 22px; }
.brand-mark {
  width: 42px; height: 42px; border-radius: 12px;
  background: var(--brand); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; font-weight: 600; flex: none;
}
.brand-mark.sm { width: 26px; height: 26px; border-radius: 8px; font-size: 14px; }
.login-card label { display: block; font-size: 12px; color: var(--muted); margin: 10px 0 5px; }
.login-card input { width: 100%; }
.login-msg { min-height: 18px; margin-top: 10px; color: var(--danger); font-size: 12px; }

/* 顶栏 */
/* 顶栏：跟随主题填充主色（与 seedTesting 一致） */
.topbar {
  height: 56px; display: flex; align-items: center; gap: 12px;
  padding: 0 16px; background: var(--brand); color: #fff;
  border-bottom: 1px solid var(--brand-dark);
  box-shadow: 0 1px 6px rgba(16, 24, 40, .10);
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 14px; color: #fff; }
.topbar .brand-mark.sm { background: rgba(255, 255, 255, .96); color: var(--brand); }
.icon-btn {
  width: 30px; height: 30px; border: 1px solid transparent; border-radius: 8px;
  background: rgba(255, 255, 255, .16); color: #fff; font-size: 15px; cursor: pointer;
}
.icon-btn:hover { background: rgba(255, 255, 255, .30); border-color: transparent; color: #fff; }

/* 主题切换：顶栏右侧小胶囊，点击依次 经典绿 → 绯红 → 经典蓝 */
.theme-toggle {
  display: inline-flex; align-items: center; gap: 7px; height: 28px;
  padding: 0 12px; border-radius: 14px; cursor: pointer;
  border: 1px solid transparent; background: rgba(255, 255, 255, .16);
  color: #fff; font: inherit; font-size: 12.5px; white-space: nowrap;
}
.theme-toggle:hover { background: rgba(255, 255, 255, .30); }
.theme-toggle .theme-dot {
  width: 10px; height: 10px; border-radius: 50%; background: var(--theme-dot);
  box-shadow: 0 0 0 2px rgba(255, 255, 255, .35); flex: none;
}
.topbar .user-pill {
  padding: 4px 12px; border-radius: 14px; font-size: 12.5px;
  background: rgba(255, 255, 255, .16); color: #fff; white-space: nowrap;
}
.topbar .btn.ghost.sm {
  color: #fff; border-color: rgba(255, 255, 255, .45); background: transparent;
}
.topbar .btn.ghost.sm:hover { background: rgba(255, 255, 255, .18); color: #fff; }

#app { height: 100%; display: flex; flex-direction: column; }
.main-row { flex: 1; display: flex; min-height: 0; }

/* 侧栏：带图标的菜单，选中行左侧有主题色竖条 */
.sidebar {
  width: 216px; flex: none; background: var(--card); border-right: 1px solid var(--line);
  padding: 10px 0; overflow-y: auto; overflow-x: hidden; transition: width .16s ease;
}
.menu-group {
  margin: 12px 0 4px; padding: 0 18px; font-size: 11px; color: #93a29a;
  letter-spacing: .04em; white-space: nowrap;
}
.menu-group:first-child { margin-top: 2px; }
.menu-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 16px; color: #34443c; border-left: 3px solid transparent;
  cursor: pointer; text-decoration: none; white-space: nowrap;
}
.menu-item:hover { background: var(--line-soft); }
.menu-item.active {
  background: var(--brand-soft); color: var(--brand-dark);
  border-left-color: var(--brand); font-weight: 600;
}
.menu-icon { width: 18px; flex: none; text-align: center; color: #8b9a93; font-size: 14px; line-height: 1; }
.menu-item.active .menu-icon { color: var(--brand); }
.menu-text { overflow: hidden; text-overflow: ellipsis; }

/* 折叠：只留图标，正文区自动变宽（悬停看名称） */
.sidebar.collapsed { width: 56px; padding: 10px 0; overflow: hidden; }
.sidebar.collapsed .menu-group {
  padding: 0; margin: 10px 12px 6px; font-size: 0; height: 1px; background: var(--line-soft);
}
.sidebar.collapsed .menu-group:first-child { display: none; }
.sidebar.collapsed .menu-item { justify-content: center; padding: 9px 0; }
.sidebar.collapsed .menu-text { display: none; }
.sidebar.collapsed .menu-icon { width: auto; font-size: 15px; }

/* 内容区 */
.content { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.tabs {
  height: 36px; flex: none; display: flex; align-items: flex-end; gap: 2px;
  padding: 0 10px; background: var(--card); border-bottom: 1px solid var(--line);
  overflow-x: auto; overflow-y: hidden;
}
.tab {
  display: flex; align-items: center; gap: 6px;
  padding: 6px 12px; border: 1px solid transparent; border-bottom: 0;
  border-radius: 8px 8px 0 0; color: var(--muted); cursor: pointer; white-space: nowrap;
}
.tab.active { background: var(--bg); border-color: var(--line); color: var(--brand-dark); font-weight: 600; }
.tab .x { color: #9aa8a1; font-size: 11px; padding: 0 2px; }
.tab .x:hover { color: var(--danger); }
.view { flex: 1; overflow: auto; padding: 16px 18px 22px; }

/* 页头 */
.page-head { display: flex; align-items: flex-end; gap: 12px; margin-bottom: 12px; }
.page-head .sub { color: var(--muted); font-size: 12px; margin-top: 1px; }

/* 卡片与表单 */
.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 12px;
}
.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 10px; }
/* 「指派给我」的范围提示条 */
.mine-hint {
  margin: -2px 0 8px; padding: 7px 10px; border-radius: 8px;
  background: var(--brand-soft); border: 1px solid var(--brand-line);
  color: var(--brand-dark); font-size: 12.5px; line-height: 1.6;
}
.mine-hint b { font-weight: 600; }
.assign-tag { color: var(--brand-dark); opacity: .85; }

/* 长文本列单行省略：项目名/模板/批号一长就把行高撑成好几行，列表会变得很难扫。
   用固定宽度的内层容器做省略（直接在 td 上设 max-width 会把列压塌）。 */
.cell-clip { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cell-clip > div { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* 文件抽屉：按「生成版本」分组，版本头一行，最新版高亮 */
table.grid tr.ver-row > td {
  background: #f7f9f8; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line);
  padding: 7px 10px;
}
table.grid tr.ver-row.latest > td { background: var(--brand-soft); }
.ver-head { display: flex; align-items: center; gap: 8px; white-space: nowrap; }
.ver-badge {
  display: inline-block; padding: 0 7px; border-radius: 999px; font-size: 11.5px; font-weight: 600;
  background: #e6ebef; color: #4b5b55;
}
.ver-badge.cur { background: var(--brand); color: #fff; }
.ver-tag { font-size: 11.5px; color: var(--brand-dark); font-weight: 600; }
table.grid tr.ver-file > td { background: var(--card); }

/* 项目 / 模板列：项目名与模板状态同一行，状态用小一号字跟在后面（缺模板标橙加粗） */
.rec-itemline { display: flex; align-items: baseline; gap: 6px; min-width: 0; }
.rec-item {
  flex: 0 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-size: 13px; color: var(--text);
}
.rec-tpl {
  flex: none; max-width: 78px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-size: 11.5px; color: var(--muted);
}
.rec-tpl.warn { color: var(--warn); font-weight: 600; }

/* 记录清单「状态 / 操作」列：一行显示，任何窗口宽度下都不折行 */
.rec-ops { display: flex; align-items: center; gap: 8px; white-space: nowrap; }
.rec-ops > * { flex: none; }
.rec-ops .badge { white-space: nowrap; }

.quick-items {
  display: flex; flex-wrap: wrap; gap: 6px; align-items: center;
  padding-top: 8px; border-top: 1px dashed var(--line-soft);
}
.chip {
  height: 24px; padding: 0 10px; border-radius: 12px; cursor: pointer;
  border: 1px solid var(--brand-line); background: var(--brand-soft); color: var(--brand-dark);
  font: inherit; font-size: 12px; line-height: 1; white-space: nowrap;
  transition: background .12s, border-color .12s;
}
.chip:hover { background: var(--brand-soft); border-color: var(--brand); filter: brightness(.97); }
.chip:active { transform: translateY(1px); }
.quick-config { margin-left: 6px; font-size: 12px; }

/* 常用项目配置弹窗里的有序清单 */
.ci-rows { border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.ci-row {
  display: flex; align-items: center; gap: 10px; padding: 7px 10px;
  border-bottom: 1px solid var(--line-soft); background: #fff;
}
.ci-row:last-child { border-bottom: 0; }
.ci-row:hover { background: #fafcfb; }
.ci-idx { width: 18px; flex: none; color: var(--muted); font-size: 11.5px; text-align: right; }
.ci-name { flex: 1; min-width: 0; word-break: break-all; font-size: 13px; }
.ci-ops { display: flex; gap: 10px; flex: none; font-size: 12px; }

/* 清单 / 快速模式切换 */
.mode-switch { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.mode-switch button {
  height: 28px; padding: 0 13px; border: 0; background: #fff; color: var(--muted);
  font: inherit; font-size: 12.5px; cursor: pointer;
}
.mode-switch button + button { border-left: 1px solid var(--line); }
.mode-switch button.on { background: var(--brand); color: #fff; font-weight: 500; }

/* 快速模式：项目 + 样品编号 */
.q-card { padding: 12px 14px; }
.q-step { display: flex; align-items: center; gap: 8px; margin-bottom: 9px; }
.q-step b { font-size: 13px; font-weight: 500; }
.q-no {
  width: 18px; height: 18px; border-radius: 50%; flex: none;
  background: var(--brand-soft); color: var(--brand-dark);
  font-size: 11px; line-height: 18px; text-align: center;
}
.q-items { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; min-height: 24px; align-items: center; }
.q-tag {
  display: inline-flex; align-items: center; gap: 6px; padding: 3px 9px; border-radius: 12px;
  background: var(--brand-soft); color: var(--brand-dark); border: 1px solid var(--brand-line); font-size: 12px;
}
.q-tag-x { cursor: pointer; color: var(--brand); font-size: 13px; line-height: 1; }
.q-tag-x:hover { color: var(--danger); }
.q-additem { display: flex; gap: 8px; }
.q-common { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 8px; }
.q-actions { display: flex; align-items: center; gap: 10px; margin-top: 10px; }
.q-check { display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--text); }
.q-check input { height: auto; }
#q-samples { width: 100%; min-height: 78px; font-family: var(--font-mono); font-size: 12.5px; line-height: 1.7; }

/* 单个编号输入 + 自动完成下拉 */
.q-pick { position: relative; margin-bottom: 8px; }
.q-sug {
  position: absolute; left: 0; right: 0; top: 34px; z-index: 12;
  background: #fff; border: 1px solid var(--brand-line); border-radius: 8px;
  box-shadow: 0 8px 22px rgba(16, 40, 32, .12); overflow: hidden;
}
.q-sug-item {
  display: flex; align-items: center; gap: 10px; padding: 7px 10px; cursor: pointer;
  border-bottom: 1px solid var(--line-soft);
}
.q-sug-item:last-of-type { border-bottom: 0; }
.q-sug-item.on, .q-sug-item:hover { background: var(--brand-soft); }
.q-sug-no { font-size: 12.5px; font-weight: 500; color: var(--brand-dark); width: 122px; flex: none; }
.q-sug-herb { font-size: 13px; width: 92px; flex: none; }
.q-sug-attach { font-size: 12px; color: var(--muted); flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.q-sug-date { font-size: 11.5px; color: var(--muted); flex: none; }
.q-sug-added { font-size: 11px; color: var(--brand-dark); background: var(--brand-soft); border: 1px solid var(--brand-line); border-radius: 9px; padding: 0 7px; flex: none; }
.q-sug-tip { padding: 6px 10px; font-size: 11.5px; color: var(--warn); background: var(--warn-bg); }
.q-sug-empty { padding: 9px 12px; font-size: 12px; color: var(--muted); }


.q-result-card { margin-top: 10px; padding: 0; overflow: hidden; }
.q-summary { display: flex; flex-wrap: wrap; align-items: center; gap: 14px; padding: 9px 14px; background: #f7f9f8; border-bottom: 1px solid var(--line-soft); font-size: 12.5px; }
.q-summary b { font-weight: 500; }
.q-sum-ok b { color: var(--brand-dark); }
.q-sum-warn b { color: var(--warn); }
.q-sum-idle b { color: var(--muted); }
.q-warn { margin: 10px 14px 0; padding: 8px 10px; border-radius: 8px; background: var(--danger-bg); color: var(--danger); font-size: 12.5px; line-height: 1.9; }
.q-warn .link { color: var(--danger); text-decoration: underline; margin-left: 10px; }
.q-note { margin: 10px 14px 0; padding: 8px 10px; border-radius: 8px; background: var(--warn-bg); color: #6b4a12; font-size: 12.5px; line-height: 1.9; }
.q-mi { display: inline-block; margin-right: 10px; white-space: nowrap; }
.q-foot {
  display: flex; align-items: center; gap: 10px; padding: 9px 14px;
  border-top: 1px solid var(--line-soft); background: var(--brand-soft); font-size: 12.5px;
}
.q-foot b { font-weight: 500; }
.q-foot-tip { color: var(--warn); font-size: 12px; }
.field { display: flex; align-items: center; gap: 6px; }
.field > span { color: var(--muted); font-size: 12px; white-space: nowrap; }
input, select, textarea {
  height: 30px; padding: 4px 9px; border: 1px solid var(--line); border-radius: 7px;
  background: #fff; color: var(--text); font: inherit; outline: none;
}
/* 复选框/单选框跟随主题色：浏览器默认的蓝色和绿/红主题不搭 */
input[type="checkbox"], input[type="radio"] { accent-color: var(--brand); }
input:focus, select:focus, textarea:focus {
  border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-ring, rgba(31, 122, 90, .10));
}
input::placeholder { color: #a7b3ac; }
textarea { height: auto; min-height: 64px; resize: vertical; }

.btn {
  height: 30px; padding: 0 12px; border-radius: 7px; border: 1px solid var(--line);
  background: #fff; color: var(--text); cursor: pointer; font: inherit; white-space: nowrap;
  display: inline-flex; align-items: center; justify-content: center; gap: 5px;
}
.btn:hover { border-color: var(--brand-line); color: var(--brand-dark); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-dark); border-color: var(--brand-dark); color: #fff; }
.btn.danger { color: var(--danger); border-color: #f0cfcb; background: var(--danger-bg); }
.btn.ghost { border-color: transparent; background: transparent; color: var(--muted); }
.btn.ghost:hover { background: var(--line-soft); }
.btn.sm { height: 26px; padding: 0 9px; font-size: 12px; }
.btn.block { width: 100%; margin-top: 16px; height: 34px; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.link { color: var(--brand); cursor: pointer; text-decoration: none; }
.link:hover { text-decoration: underline; }
.link.danger { color: var(--danger); }
.link.disabled { color: var(--muted); cursor: not-allowed; opacity: .45; }
.link.disabled:hover { text-decoration: none; }

/* 表格 */
.table-wrap { overflow: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--card); }
table.grid { width: 100%; border-collapse: separate; border-spacing: 0; min-width: 900px; }
table.grid th {
  position: sticky; top: 0; z-index: 1;
  background: #f7f9f8; color: var(--muted); font-weight: 600; font-size: 12px;
  text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--line); white-space: nowrap;
}
table.grid td { padding: 9px 10px; border-bottom: 1px solid var(--line-soft); vertical-align: top; }
table.grid tr:last-child td { border-bottom: 0; }
table.grid tbody tr:hover { background: #fafcfb; }
table.grid tr.warn-row { background: var(--warn-bg); }
table.grid tr.warn-row:hover { background: #fbf1dd; }
/* 生成记录：一个任务多份文件时展开的子行，每份单独给预览/下载 */
table.grid tr.sub-row > td { background: #fafcfb; padding: 8px 12px 10px 40px; border-bottom: 1px solid var(--line-soft); }
.file-lines { display: flex; flex-direction: column; gap: 5px; }
.file-line { display: flex; align-items: center; gap: 10px; }
.file-line-idx { width: 16px; flex: none; color: var(--muted); font-size: 11.5px; }
.file-line-name { flex: 1; min-width: 0; word-break: break-all; font-size: 12.5px; }

.cell-main { font-weight: 500; }
.cell-sub { color: var(--muted); font-size: 11.5px; margin-top: 1px; }
.nowrap { white-space: nowrap; }
/* 微信绑定列：徽标和 openid 必须同一行，列宽不够时截断 openid 而不是换行 */
.bind-cell { display: inline-flex; align-items: center; gap: 6px; max-width: 100%; vertical-align: middle; }
.bind-openid { font-size: 11.5px; color: var(--muted); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* 关键操作列固定在右侧：表格宽于容器时横向滚动，操作仍然点得到 */
table.grid .sticky-right {
  position: sticky; right: 0; z-index: 2; background: var(--card);
  box-shadow: -8px 0 8px -8px rgba(16, 40, 32, .12);
}
table.grid tbody tr:hover .sticky-right { background: #fafcfb; }
table.grid tr.warn-row .sticky-right { background: var(--warn-bg); }
table.grid tr.warn-row:hover .sticky-right { background: #fbf1dd; }
table.grid thead th.sticky-right { z-index: 3; background: #f7f9f8; }

/* 当前操作过的行：比 hover 更明显，左侧一条主题色，便于在长列表里找回刚点的那行。
   放在 warn-row / sticky-right 之后，确保即使行本身是浅黄也能看出选中。 */
table.grid tbody tr.rec-active { background: var(--brand-soft); }
table.grid tbody tr.rec-active:hover { background: var(--brand-soft); filter: brightness(.985); }
table.grid tbody tr.rec-active > td:first-child { box-shadow: inset 3px 0 0 var(--brand); }
table.grid tbody tr.rec-active .sticky-right { background: var(--brand-soft); }
.ellipsis { max-width: 240px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.badge {
  display: inline-block; padding: 1px 7px; border-radius: 999px; font-size: 11.5px;
  background: var(--line-soft); color: var(--muted); white-space: nowrap;
}
/* 「可生成」是待办状态，用蓝色与「已生成」的绿区分开；同样是固定语义色，不随主题变 */
.badge.info { background: #e8f0fe; color: #1d4ed8; }

/* 「成功/已生成」是状态语义，固定绿色，不随主题变——红主题下变红会被误读成失败 */
.badge.ok { background: #e6f4ec; color: #17614a; }
.badge.warn { background: var(--warn-bg); color: var(--warn); }
.badge.err { background: var(--danger-bg); color: var(--danger); }

.pager { display: flex; align-items: center; gap: 8px; padding: 10px 2px 0; }
.pager .pages { display: flex; gap: 4px; }
.page-btn {
  min-width: 28px; height: 28px; padding: 0 8px; border-radius: 7px;
  border: 1px solid var(--line); background: #fff; cursor: pointer; color: var(--text);
}
.page-btn.active { border-color: var(--brand); color: var(--brand-dark); background: var(--brand-soft); font-weight: 600; }
.page-btn:disabled { opacity: .45; cursor: not-allowed; }

.empty { padding: 44px 12px; text-align: center; color: var(--muted); }
.empty b { display: block; color: var(--text); margin-bottom: 4px; font-weight: 600; }
.loading { padding: 34px; text-align: center; color: var(--muted); }

/* 抽屉 / 弹窗 */
.overlay { position: fixed; inset: 0; background: rgba(18, 32, 26, .28); z-index: 40; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: 760px; max-width: 94vw;
  background: var(--card); z-index: 50; border-left: 1px solid var(--line);
  display: flex; flex-direction: column; box-shadow: -12px 0 32px rgba(16,40,32,.10);
}
.drawer-head { padding: 14px 16px; border-bottom: 1px solid var(--line); display: flex; align-items: flex-start; gap: 10px; }
.drawer-body { flex: 1; overflow: auto; padding: 14px 16px; }
.drawer-foot { padding: 12px 16px; border-top: 1px solid var(--line); display: flex; gap: 8px; justify-content: flex-end; }
.drawer .close { margin-left: auto; }

.modal-wrap { position: fixed; inset: 0; z-index: 60; display: flex; align-items: center; justify-content: center; padding: 20px; }
.modal {
  width: 520px; max-width: 96vw; max-height: 90vh;
  /* 表单较长时只让正文滚动，头尾始终可见（否则小屏上「保存」会被挤出可视区） */
  display: flex; flex-direction: column; overflow: hidden;
  background: var(--card); border-radius: 12px; border: 1px solid var(--line);
  box-shadow: var(--shadow);
}
.modal-head { padding: 14px 16px; border-bottom: 1px solid var(--line); display: flex; align-items: center; flex: none; background: var(--card); }
.modal-body { padding: 14px 16px; flex: 1; overflow: auto; overflow-wrap: anywhere; }
.modal-foot { padding: 12px 16px; border-top: 1px solid var(--line); display: flex; gap: 8px; justify-content: flex-end; flex: none; background: var(--card); border-radius: 0 0 12px 12px; }
.form-row { margin-bottom: 10px; }
.form-row label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.form-row input, .form-row select, .form-row textarea { width: 100%; }
.form-hint { font-size: 11.5px; color: var(--muted); margin-top: 4px; }

/* 变量预览表 */
table.vars { width: 100%; border-collapse: collapse; }
table.vars th { text-align: left; font-size: 11.5px; color: var(--muted); padding: 6px 8px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: #f7f9f8; }
table.vars td { padding: 6px 8px; border-bottom: 1px solid var(--line-soft); font-size: 12px; }
table.vars td.empty-val { background: var(--warn-bg); color: var(--warn); }
.mono { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 11.5px; }

.toasts { position: fixed; top: 64px; right: 18px; z-index: 80; display: flex; flex-direction: column; gap: 8px; }
.toast {
  min-width: 220px; max-width: 360px; padding: 9px 12px; border-radius: 9px;
  background: #fff; border: 1px solid var(--line); box-shadow: var(--shadow); font-size: 12.5px;
  animation: slide-in .18s ease;
}
.toast.ok { border-left: 3px solid #17614a; }
.toast.err { border-left: 3px solid var(--danger); }
@keyframes slide-in { from { transform: translateX(12px); opacity: 0; } to { transform: none; opacity: 1; } }

.dropzone {
  border: 1.5px dashed var(--brand-line); border-radius: 10px; padding: 22px;
  text-align: center; color: var(--muted); background: #fbfdfc; cursor: pointer;
}
.dropzone:hover, .dropzone.hover { border-color: var(--brand); background: var(--brand-soft); }
.kv { display: grid; grid-template-columns: 92px 1fr; gap: 6px 10px; font-size: 12.5px; }
.kv .k { color: var(--muted); }

@media (max-width: 1280px) {
  .drawer { width: 660px; }
}
@media (max-width: 1100px) {
  .sidebar { width: 176px; }
  .drawer { width: 560px; }
}
