* { margin: 0; padding: 0; box-sizing: border-box; }
:root{
  --primary:#2563eb; --primary-d:#1d4ed8; --bg:#f5f7fa; --surface:#fff;
  --text:#1f2937; --muted:#6b7280; --line:#e5e7eb; --danger:#dc2626;
  --green:#059669; --amber:#d97706; --shadow:0 1px 3px rgba(0,0,0,.08);
}
body{ font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","Microsoft YaHei",sans-serif;
  background:var(--bg); color:var(--text); font-size:14px; line-height:1.5; }
.hidden{ display:none !important; }
button,input,select,textarea{ font-family:inherit; font-size:inherit; }

/* ---------- 登录 ---------- */
.login-page{ min-height:100vh; display:flex; align-items:center; justify-content:center;
  background:linear-gradient(135deg,#1e3a8a 0%,#2563eb 55%,#3b82f6 100%); }
.login-card{ width:400px; background:#fff; border-radius:16px; padding:40px; box-shadow:0 20px 60px rgba(0,0,0,.25); text-align:center; }
.login-logo{ display:block; width:126px; height:auto; margin:0 auto 16px; }
.login-card h1{ font-size:22px; margin-bottom:6px; }
.login-sub{ color:var(--muted); margin-bottom:28px; font-size:13px; }
.login-card label{ display:block; text-align:left; color:var(--muted); margin-bottom:8px; font-size:13px; }
.login-card input{ width:100%; padding:12px 14px; border:1px solid var(--line); border-radius:8px; margin-bottom:14px; }
.login-card input:focus{ outline:none; border-color:var(--primary); }
.login-tip{ margin-top:20px; color:#9ca3af; font-size:12px; }

/* ---------- 布局 ---------- */
.app{ display:flex; min-height:100vh; }
.sidebar{ width:230px; background:#111827; color:#d1d5db; display:flex; flex-direction:column; position:fixed; height:100vh; }
.brand{ display:flex; flex-direction:row; align-items:center; gap:11px; padding:16px 20px; border-bottom:1px solid #1f2937; }
.brand-logo{ width:44px; height:auto; display:block; flex:none; }
.brand-name{ color:#fff; font-weight:600; font-size:15px; }
.brand-sub{ font-size:10px; color:#6b7280; letter-spacing:.5px; }
.nav{ padding:16px 12px; flex:1; }
.nav-item{ width:100%; display:flex; align-items:center; gap:12px; padding:11px 14px; margin-bottom:4px;
  background:transparent; color:#9ca3af; border:none; border-radius:8px; cursor:pointer; text-align:left; }
.nav-item:hover{ background:#1f2937; color:#fff; }
.nav-item.active{ background:var(--primary); color:#fff; }
.nav-item .ico{ font-size:16px; width:20px; text-align:center; }
.sidebar-foot{ padding:16px; border-top:1px solid #1f2937; }
.user-box{ display:flex; align-items:center; gap:10px; margin-bottom:12px; }
.avatar{ width:36px; height:36px; border-radius:50%; background:#374151; color:#fff;
  display:flex; align-items:center; justify-content:center; font-weight:600; }
.user-name{ color:#fff; font-size:13px; }
.user-role{ font-size:11px; color:#6b7280; }
.logout-btn{ width:100%; padding:8px; background:#1f2937; color:#9ca3af; border:none; border-radius:6px; cursor:pointer; }
.logout-btn:hover{ background:#374151; color:#fff; }

.main{ margin-left:230px; flex:1; width:calc(100% - 230px); }
.topbar{ height:72px; background:#fff; border-bottom:1px solid var(--line); padding:0 28px;
  display:flex; align-items:center; justify-content:space-between; position:sticky; top:0; z-index:5; }
.topbar h2{ font-size:19px; }
.topbar p{ color:var(--muted); font-size:12px; }
.topbar-actions{ display:flex; align-items:center; gap:12px; }
.scope-badge{ padding:5px 12px; background:#eff6ff; color:var(--primary); border-radius:20px; font-size:12px; font-weight:500; }
.content{ padding:24px 28px; }

/* ---------- 通用组件 ---------- */
.btn{ padding:9px 16px; border:1px solid var(--line); background:#fff; color:var(--text);
  border-radius:7px; cursor:pointer; font-weight:500; }
.btn:hover{ background:#f9fafb; }
.btn.primary{ background:var(--primary); color:#fff; border-color:var(--primary); }
.btn.primary:hover{ background:var(--primary-d); }
.btn.danger{ background:var(--danger); color:#fff; border-color:var(--danger); }
.btn.ghost{ background:transparent; border:none; color:var(--primary); }
.btn.block{ width:100%; margin-top:4px; }
.btn.sm{ padding:5px 10px; font-size:12px; }
input,select,textarea{ padding:9px 11px; border:1px solid var(--line); border-radius:7px; background:#fff; color:var(--text); }
input:focus,select:focus,textarea:focus{ outline:none; border-color:var(--primary); }
.select{ min-width:130px; }
.input{ min-width:130px; padding:8px 10px; border:1px solid var(--line); border-radius:6px; background:var(--surface); color:var(--text); font-size:13px; }
.input:focus{ outline:none; border-color:var(--primary); }
.search{ min-width:240px; }
.search-field-select{ min-width:112px; }
.cust-stats{ display:flex; gap:10px; flex-wrap:wrap; margin-bottom:16px; }
.cust-stat{ flex:1 1 150px; min-width:140px; text-align:left; padding:12px 16px; border:1px solid var(--line); border-radius:9px; background:#fff; cursor:pointer; transition:border-color .15s,background .15s; }
.cust-stat:hover{ border-color:var(--primary); }
.cust-stat.active{ border-color:var(--primary); background:var(--primary); }
.cust-stat.active .stat-n,.cust-stat.active .stat-label{ color:#fff; }
.cust-stat .stat-n{ font-size:22px; font-weight:700; color:var(--text); line-height:1.2; }
.cust-stat .stat-label{ font-size:12px; color:var(--muted); margin-top:4px; }
.muted{ color:var(--muted); font-size:12px; }
.muted.small{ font-size:11px; }
.error-msg{ color:var(--danger); font-size:13px; margin-top:12px; }

/* ---------- KPI ---------- */
.kpi-grid{ display:grid; grid-template-columns:repeat(auto-fit,minmax(180px,1fr)); gap:16px; margin-bottom:20px; }
.kpi-card{ background:#fff; border-radius:10px; padding:18px 20px; box-shadow:var(--shadow); border-left:3px solid var(--primary); }
.kpi-card .label{ color:var(--muted); font-size:12px; }
.kpi-card .value{ font-size:28px; font-weight:700; margin-top:6px; }
.kpi-card .sub{ font-size:11px; color:#9ca3af; margin-top:4px; }
.kpi-card.green{ border-left-color:var(--green); }
.kpi-card.amber{ border-left-color:var(--amber); }
.kpi-card.red{ border-left-color:var(--danger); }

/* ---------- 面板/表格 ---------- */
.panel{ background:#fff; border-radius:10px; box-shadow:var(--shadow); margin-bottom:20px; overflow:hidden; }
.panel-head{ display:flex; align-items:center; justify-content:space-between; padding:16px 20px; border-bottom:1px solid var(--line); }
.panel-head h3{ font-size:15px; }
.table-wrap{ overflow-x:auto; }
.table{ width:100%; border-collapse:collapse; }
.table th{ background:#f9fafb; text-align:left; padding:11px 14px; font-size:12px; color:var(--muted); font-weight:600; white-space:nowrap; border-bottom:1px solid var(--line); }
.table td{ padding:11px 14px; border-bottom:1px solid #f3f4f6; font-size:13px; }
.table .cust-name-col{ width:170px; max-width:170px; min-width:150px; }
.table .cust-name-col b, .table .cust-name-col .muted{ display:block; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; max-width:142px; }
/* 客户管理：来源/等级列收窄，单行省略，悬停看全文 */
.table .cust-src-col{ width:78px; max-width:78px; min-width:64px; }
.table .cust-src-col{ display:table-cell; }
.table td.cust-src-col{ overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.table .cust-level-col{ width:66px; max-width:66px; min-width:56px; }
.table td.cust-level-col{ overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.table .cust-contact-col{ width:20ch; max-width:20ch; min-width:14ch; }
.table td.cust-contact-col{ overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
#campaignTable .cc-name, #campaignTable .cc-subject, #campaignTable .cc-body{ padding-left:8px; padding-right:8px; }
#campaignTable .cc-name b{ display:block; max-width:120px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
#campaignTable .cc-subject span{ display:block; max-width:130px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
#campaignTable .cc-body span{ display:block; max-width:150px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
/* 开发信表：固定列宽，长内容不挤占其它列，超出窗口横向滚动 */
#campaignTable{ table-layout:fixed; width:100%; min-width:1120px; }
body:not(.is-master) #campaignTable{ min-width:1030px; } /* 业务员隐藏负责人列 */
#campaignTable th, #campaignTable td{ overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
#campaignTable th:nth-child(1), #campaignTable td:nth-child(1){ width:150px; }
#campaignTable th:nth-child(2), #campaignTable td:nth-child(2){ width:90px; }
#campaignTable th:nth-child(3), #campaignTable td:nth-child(3){ width:70px; }
#campaignTable th:nth-child(4), #campaignTable td:nth-child(4){ width:180px; }
#campaignTable th:nth-child(5), #campaignTable td:nth-child(5){ width:200px; }
#campaignTable th:nth-child(6), #campaignTable td:nth-child(6){ width:80px; }
#campaignTable th:nth-child(7), #campaignTable td:nth-child(7){ width:90px; }
#campaignTable th:nth-child(8), #campaignTable td:nth-child(8){ width:260px; }
/* 覆盖旧的 cc 内部 max-width 限制，让省略号跟随新列宽 */
#campaignTable .cc-name b{ max-width:100%; }
#campaignTable .cc-subject span{ max-width:100%; }
#campaignTable .cc-body span{ max-width:100%; }
/* 操作列四按钮强制横排 */
#campaignTable td:last-child{ white-space:nowrap; }
#campaignTable td:last-child .btn{ margin-right:4px; }
#campaignTable td:last-child .btn:last-child{ margin-right:0; }
/* 收件登记表：8列按比例铺满容器，修正日期/客户/邮箱被挤换行、按钮竖排错排 */
#incomingTable{ table-layout:fixed; width:100%; }
#incomingTable th, #incomingTable td{
  box-sizing:border-box; min-width:0; max-width:none;
  padding-left:10px; padding-right:10px;
  overflow:hidden; text-overflow:ellipsis; white-space:nowrap;
}
#incomingTable th:nth-child(1), #incomingTable td:nth-child(1){ width:11%; }  /* 日期：完整显示2026-12-01 */
#incomingTable th:nth-child(2), #incomingTable td:nth-child(2){ width:11%; }  /* 客户 */
#incomingTable th:nth-child(3), #incomingTable td:nth-child(3){ width:19%; }  /* 主题 */
#incomingTable th:nth-child(4), #incomingTable td:nth-child(4){ width:14%; }  /* 发件人 */
#incomingTable th:nth-child(5), #incomingTable td:nth-child(5){ width:16%; }  /* 正文摘要 */
#incomingTable th:nth-child(6), #incomingTable td:nth-child(6){ width:6%; }   /* 来源 */
#incomingTable th:nth-child(7), #incomingTable td:nth-child(7){ width:7%; }   /* 负责人 */
#incomingTable th:nth-child(8), #incomingTable td:nth-child(8){ width:16%; }  /* 操作：3按钮横排 */
/* 业务员视图隐藏负责人列后，把省下的6%补给日期和主题，避免右侧留白 */
body:not(.is-master) #incomingTable th:nth-child(1), body:not(.is-master) #incomingTable td:nth-child(1){ width:13%; }
body:not(.is-master) #incomingTable th:nth-child(3), body:not(.is-master) #incomingTable td:nth-child(3){ width:24%; }
/* 操作列按钮横排、整体靠右对齐（表头同步右对齐） */
#incomingTable th:last-child, #incomingTable td:last-child{ white-space:nowrap; text-align:right; }
#incomingTable td:last-child .btn{ margin-right:2px; padding:4px 6px; font-size:12px; }
#incomingTable td:last-child .btn:last-child{ margin-right:0; }
.table tr:hover td{ background:#fafbfc; }
.table tr:last-child td{ border-bottom:none; }
.table .master-col{ display:none; }
body.is-master .table .master-col{ display:table-cell; }
/* 客户管理表：按比例自适应列宽，铺满容器、左右留白，底部不出现横向滚动 */
#customerTable{ table-layout:fixed; width:100%; }
#customerTable th, #customerTable td{ overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
#customerTable thead th, #customerTable tbody td{
  box-sizing:border-box; max-width:none; min-width:0;
}
#customerTable th:nth-child(1), #customerTable td:nth-child(1){ width:15.5%; }
#customerTable th:nth-child(2), #customerTable td:nth-child(2){ width:9%; }
#customerTable th:nth-child(3), #customerTable td:nth-child(3){ width:8%; }
#customerTable th:nth-child(4), #customerTable td:nth-child(4){ width:6.5%; }
#customerTable th:nth-child(5), #customerTable td:nth-child(5){ width:14.5%; }
#customerTable th:nth-child(6), #customerTable td:nth-child(6){ width:6.5%; }
#customerTable th:nth-child(7), #customerTable td:nth-child(7){ width:6%; }
#customerTable th:nth-child(8), #customerTable td:nth-child(8){ width:7%; }
#customerTable th:nth-child(9), #customerTable td:nth-child(9){ width:6%; }
#customerTable th:nth-child(10), #customerTable td:nth-child(10){ width:7%; }
#customerTable th:nth-child(11), #customerTable td:nth-child(11){ width:14%; }
/* 覆盖旧的来源/等级/联系人窄列限制 */
#customerTable th.cust-src-col, #customerTable td.cust-src-col{ width:6.5%; max-width:6.5%; min-width:0; }
#customerTable th.cust-level-col, #customerTable td.cust-level-col{ width:6%; max-width:6%; min-width:0; }
#customerTable th.cust-contact-col, #customerTable td.cust-contact-col{ width:8%; max-width:8%; min-width:0; }
/* 操作列三按钮强制横排、压紧、整体靠右对齐（表头同步右对齐） */
#customerTable th:last-child, #customerTable td:last-child{ white-space:nowrap; text-align:right; }
#customerTable td:last-child .btn{ margin-right:2px; padding:4px 6px; font-size:12px; }
#customerTable td:last-child .btn:last-child{ margin-right:0; }
/* 跟进记录表：固定比例列宽铺满，跟进内容/反馈默认收起3行、点展开看全文 */
#followupTable{ table-layout:fixed; width:100%; }
#followupTable th, #followupTable td{ box-sizing:border-box; min-width:0; overflow:hidden; padding-left:10px; padding-right:10px; }
#followupTable th:nth-child(1), #followupTable td:nth-child(1){ width:11%; }  /* 日期 */
#followupTable th:nth-child(2), #followupTable td:nth-child(2){ width:14%; }  /* 客户名称 */
#followupTable th:nth-child(3), #followupTable td:nth-child(3){ width:6%; }   /* 方式 */
#followupTable th:nth-child(4), #followupTable td:nth-child(4){ width:21%; }  /* 跟进内容 */
#followupTable th:nth-child(5), #followupTable td:nth-child(5){ width:20%; }  /* 反馈/下一步 */
#followupTable th:nth-child(6), #followupTable td:nth-child(6){ width:10%; }  /* 结果 */
#followupTable th:nth-child(7), #followupTable td:nth-child(7){ width:7%; }   /* 负责人 */
#followupTable th:nth-child(8), #followupTable td:nth-child(8){ width:11%; }  /* 操作 */
body:not(.is-master) #followupTable th:nth-child(4), body:not(.is-master) #followupTable td:nth-child(4){ width:23%; }
body:not(.is-master) #followupTable th:nth-child(5), body:not(.is-master) #followupTable td:nth-child(5){ width:22%; }
/* 日期/客户/方式/结果/负责人 单行显示，超出省略号不折行错排 */
#followupTable td:nth-child(1), #followupTable td:nth-child(2), #followupTable td:nth-child(3),
#followupTable td:nth-child(6), #followupTable td:nth-child(7){ white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
/* 内容单元格：默认3行收缩，超长省略号；展开后显示全部、可换行 */
#followupTable .fu-txt{ white-space:normal; word-break:break-word; line-height:1.5; }
#followupTable .fu-txt.clamp{
  display:-webkit-box; -webkit-line-clamp:3; -webkit-box-orient:vertical; overflow:hidden;
}
#followupTable .fu-txt.open{ display:block; }
#followupTable .fu-more{
  display:inline-block; margin-top:4px; padding:0; border:none; background:none;
  color:var(--primary); font-size:12px; cursor:pointer;
}
#followupTable .fu-more:hover{ text-decoration:underline; }
/* 操作列按钮横排、整体靠右对齐（表头同步右对齐） */
#followupTable th:last-child, #followupTable td:last-child{ white-space:nowrap; text-align:right; }
#followupTable td:last-child .btn{ margin-right:2px; padding:4px 6px; font-size:12px; }
#followupTable td:last-child .btn:last-child{ margin-right:0; }
/* 线索审核表：10列固定比例铺满（含背调简述），全部单行省略，防止长文本挤窄操作列 */
#leadTable{ table-layout:fixed; width:100%; }
#leadTable th, #leadTable td{
  box-sizing:border-box; min-width:0; padding-left:10px; padding-right:10px;
  overflow:hidden; text-overflow:ellipsis; white-space:nowrap;
}
#leadTable th:nth-child(1), #leadTable td:nth-child(1){ width:7%; }   /* 客户等级 */
#leadTable th:nth-child(2), #leadTable td:nth-child(2){ width:12%; }  /* 公司名称 */
#leadTable th:nth-child(3), #leadTable td:nth-child(3){ width:8%; }   /* 国家/区域 */
#leadTable th:nth-child(4), #leadTable td:nth-child(4){ width:8.5%; } /* 产品 */
#leadTable th:nth-child(5), #leadTable td:nth-child(5){ width:6.5%; } /* 联系人 */
#leadTable th:nth-child(6), #leadTable td:nth-child(6){ width:10.5%; }/* 邮箱 */
#leadTable th:nth-child(7), #leadTable td:nth-child(7){ width:5%; }   /* 官网 */
#leadTable th:nth-child(8), #leadTable td:nth-child(8){ width:17%; }  /* 背调简述 */
#leadTable th:nth-child(9), #leadTable td:nth-child(9){ width:14%; }  /* 入选理由 */
#leadTable th:nth-child(10), #leadTable td:nth-child(10){ width:12%; } /* 操作：入库/忽略横排 */
#leadTable td:nth-child(10) .btn{ margin-right:2px; padding:4px 6px; font-size:12px; }
#leadTable td:nth-child(10) .btn:last-child{ margin-right:0; }
#leadTable th:last-child, #leadTable td:last-child{ text-align:right; }
.master-panel{ padding-bottom:20px; }
.master-panel p{ padding:0 20px; }
.toolbar{ display:flex; gap:10px; margin-bottom:16px; flex-wrap:wrap; align-items:center; }
.pagination{ display:flex; gap:6px; justify-content:center; padding:14px; }
.pagination button{ padding:5px 11px; border:1px solid var(--line); background:#fff; border-radius:6px; cursor:pointer; }
.pagination button.active{ background:var(--primary); color:#fff; border-color:var(--primary); }
.pagination button.pg-nav{ color:var(--muted); }
.pagination button:disabled{ opacity:.4; cursor:not-allowed; }
.pagination .pg-dots{ padding:5px 2px; color:var(--muted); }
.pagination .pg-info{ margin-left:auto; padding-left:16px; font-size:12px; color:var(--muted); align-self:center; white-space:nowrap; }

/* 标签 */
.tag{ display:inline-block; padding:3px 9px; border-radius:5px; font-size:11px; white-space:nowrap; }
.tag.blue{ background:#eff6ff; color:#1d4ed8; }
.tag.green{ background:#ecfdf5; color:#047857; }
.tag.amber{ background:#fffbeb; color:#b45309; }
.tag.red{ background:#fef2f2; color:#b91c1c; }
.tag.gray{ background:#f3f4f6; color:#4b5563; }
.tag.purple{ background:#f5f3ff; color:#6d28d9; }

/* 线索审核-背调简述：跟随列宽单行省略，hover 显示全文 */
.dd-brief{ display:block; max-width:100%; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; vertical-align:bottom; color:var(--text,#334155); font-size:12px; }

/* 待办/动态 */
.feed{ padding:8px 20px 16px; }
.feed-item{ display:flex; gap:12px; padding:10px 0; border-bottom:1px solid #f3f4f6; }
.feed-item:last-child{ border-bottom:none; }
.feed-dot{ width:8px; height:8px; border-radius:50%; background:var(--primary); margin-top:6px; flex-shrink:0; }
.feed-main{ flex:1; }
.feed-title{ font-size:13px; }
.feed-meta{ color:var(--muted); font-size:11px; margin-top:2px; }

/* ---------- 邮件中心 ---------- */
.mail-tabs{ display:flex; gap:4px; border-bottom:1px solid var(--line); margin-bottom:16px; }
.mail-tab{ padding:10px 20px; background:none; border:none; border-bottom:2px solid transparent; cursor:pointer; color:var(--muted); font-size:14px; }
.mail-tab:hover{ color:var(--text); }
.mail-tab.active{ color:var(--primary); border-bottom-color:var(--primary); font-weight:500; }
.mail-notice{ background:#eff6ff; color:#1d4ed8; padding:11px 16px; border-radius:8px; font-size:12px; line-height:1.6; margin-bottom:16px; }
/* 批量生成开发信：与收件登记/发件台账一致的一行 toolbar 排版 */
.campaign-toolbar{ margin-bottom:16px; }
.campaign-toolbar .select{ min-width:120px; }
.campaign-toolbar input.input{ min-width:150px; }
.campaign-toolbar input[type=date]{ min-width:140px; }
.campaign-toolbar #genStatus{ margin-left:auto; }
.signature-preview{ padding:12px; background:#f9fafb; border:1px solid var(--line); border-radius:7px; font-size:12px; white-space:pre-wrap; color:var(--muted); min-height:40px; }
.mail-detail{ font-size:13px; line-height:1.7; }
.mail-detail .md-row{ margin-bottom:10px; }
.mail-detail .md-label{ color:var(--muted); font-size:12px; }
.mail-detail .md-body{ white-space:pre-wrap; background:#f9fafb; padding:14px; border-radius:7px; border:1px solid var(--line); margin-top:6px; }
.status-tag{ display:inline-block; padding:3px 9px; border-radius:5px; font-size:11px; }
.status-tag.draft{ background:#f3f4f6; color:#4b5563; }
.status-tag.planned{ background:#fffbeb; color:#b45309; }
.status-tag.sent{ background:#ecfdf5; color:#047857; }
.status-tag.received{ background:#eff6ff; color:#1d4ed8; }

/* ---------- 自动找客规则页 ---------- */
.rule-grid{ display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:16px; align-items:stretch; }
.rule-grid > .rule-card:nth-child(1),
.rule-grid > .rule-card:nth-child(2){ height:430px; }
.rule-card{ display:flex; flex-direction:column; }
.rule-card .panel-head{ padding:13px 18px; flex:none; }
.rule-body{ padding:14px 18px 18px; flex:1; min-height:0; }
.rule-item{ display:flex; gap:12px; padding:7px 0; border-bottom:1px dashed var(--line); font-size:12.5px; line-height:1.55; }
.rule-item:last-child{ border-bottom:none; }
.rule-k{ flex:0 0 76px; color:var(--muted); }
.rule-v{ flex:1; color:var(--text); }
.rule-step{ position:relative; padding:7px 0 7px 30px; font-size:12.5px; line-height:1.55; }
.rule-step b{ position:absolute; left:0; top:7px; width:19px; height:19px; border-radius:50%; background:var(--primary); color:#fff; font-size:11px; display:flex; align-items:center; justify-content:center; font-weight:500; }
.kw-list{ display:flex; flex-wrap:wrap; gap:8px; }
.kw{ display:inline-block; padding:5px 10px; background:#f3f6ff; border:1px solid #dbe6ff; color:#1d4ed8; border-radius:6px; font-size:11.5px; font-family:ui-monospace,Menlo,Consolas,monospace; }
.rule-kpi{ display:flex; gap:8px; margin-bottom:14px; flex-wrap:wrap; }
.rule-kpi .kp{ flex:1; min-width:70px; background:var(--bg); border-radius:8px; padding:10px 8px; text-align:center; }
.rule-kpi .kp-n{ display:block; font-size:20px; font-weight:500; color:var(--primary); }
.rule-kpi .kp-l{ display:block; font-size:11px; color:var(--muted); margin-top:2px; }
.rule-note{ font-size:11.5px; line-height:1.6; margin-top:10px; }
/* 自动归档页 */
.arc-meta{ display:flex; flex-direction:column; gap:2px; margin-top:4px; }
.arc-meta .rule-item{ border-bottom:1px dashed var(--line); padding:7px 0; }
.arc-meta .rule-item:last-child{ border-bottom:none; }
.arc-meta .rule-k{ min-width:96px; }
#mailSub-archive .panel{ margin-bottom:16px; }
#mailSub-archive .rule-kpi .kp-n{ font-variant-numeric:tabular-nums; }
.af-savebar{ display:flex; align-items:center; justify-content:space-between; gap:16px; background:#fff; border:1px solid var(--line); border-left:4px solid var(--green); border-radius:9px; padding:12px 18px; margin-bottom:16px; box-shadow:var(--shadow); }
.af-savebar.dirty{ border-left-color:var(--amber); background:#fffbeb; }
.af-save-status{ font-size:13px; font-weight:500; }
.af-save-status.saved{ color:var(--green); }
.af-save-status.unsaved{ color:var(--amber); }
.rule-span2{ grid-column:1/-1; }
/* 全球扫描进度页 */
.scan-control{ display:flex; align-items:center; justify-content:space-between; gap:16px; background:var(--card,#fff); border:1px solid var(--line); border-left:4px solid var(--green); border-radius:9px; padding:12px 18px; margin-bottom:14px; box-shadow:var(--shadow); }
.scan-control.paused{ border-left-color:var(--muted); }
.scan-control-info{ display:flex; flex-direction:column; gap:4px; }
.scan-control-label{ font-size:13.5px; font-weight:600; }
.scan-control-desc{ font-size:11.5px; color:var(--muted); }
.scan-control-right{ display:flex; align-items:center; gap:12px; }
.scan-switch{ position:relative; display:inline-block; width:46px; height:25px; flex:0 0 auto; }
.scan-switch input{ opacity:0; width:0; height:0; }
.scan-slider{ position:absolute; inset:0; background:var(--line); border-radius:25px; transition:background .2s; cursor:pointer; }
.scan-slider:before{ content:""; position:absolute; width:19px; height:19px; left:3px; top:3px; background:#fff; border-radius:50%; transition:transform .2s; box-shadow:0 1px 3px rgba(0,0,0,.25); }
.scan-switch input:checked + .scan-slider{ background:var(--green); }
.scan-switch input:checked + .scan-slider:before{ transform:translateX(21px); }
.scan-switch input:disabled + .scan-slider{ opacity:.5; cursor:not-allowed; }
.scan-kpis{ display:grid; grid-template-columns:repeat(4,minmax(0,1fr)); gap:12px; margin-bottom:14px; }
.scan-kpis .kp{ background:var(--muted); border-radius:8px; padding:14px 16px; text-align:center; }
.scan-kpis .kp-n{ display:block; font-size:22px; font-weight:600; line-height:1.1; color:#fff; }
.scan-kpis .kp-l{ display:block; font-size:11.5px; color:rgba(255,255,255,.82); margin-top:6px; }
.scan-panel{ margin-bottom:14px; }
.scan-panel .panel-head{ display:flex; align-items:center; justify-content:space-between; }
.scan-head-actions{ display:flex; align-items:center; gap:12px; }
.scan-body{ padding:14px 18px 18px; }
.scan-progress-bar{ height:12px; border-radius:6px; background:var(--line); overflow:hidden; display:flex; }
.scan-progress-bar i{ display:block; height:100%; }
.scan-progress-legend{ display:flex; gap:16px; margin-top:10px; font-size:11.5px; color:var(--muted); flex-wrap:wrap; }
.scan-progress-legend b{ display:inline-block; width:9px; height:9px; border-radius:2px; margin-right:5px; vertical-align:middle; }
.scan-tier{ margin-bottom:16px; }
.scan-tier-h{ font-size:12px; color:var(--muted); margin-bottom:8px; padding-bottom:5px; border-bottom:1px solid var(--line); }
.scan-grid{ display:grid; grid-template-columns:repeat(5,minmax(0,1fr)); gap:8px; }
.scan-cell{ border:1px solid var(--line); border-radius:8px; padding:9px 10px; font-size:12px; cursor:pointer; transition:border-color .15s; }
.scan-cell:hover{ border-color:var(--primary); }
.scan-cell.done{ background:rgba(34,197,94,.08); }
.scan-cell.active{ border-color:var(--primary); box-shadow:0 0 0 1px var(--primary) inset; }
.scan-cell .sc-top{ display:flex; justify-content:space-between; align-items:center; gap:4px; }
.scan-cell .sc-n{ font-weight:500; }
.scan-cell .sc-idx{ color:var(--muted); font-size:10.5px; }
.scan-cell .sc-st{ margin-top:5px; font-size:10.5px; }
.scan-cell.done .sc-st{ color:#16a34a; }
.scan-cell.active .sc-st{ color:var(--primary); }
.scan-cell.pending .sc-st{ color:var(--muted); }
.scan-edit-list{ max-height:420px; overflow-y:auto; border:1px solid var(--line); border-radius:8px; padding:8px; }
.scan-edit-row{ display:flex; align-items:center; gap:8px; padding:6px 4px; border-bottom:1px solid var(--line); }
.scan-edit-row:last-child{ border-bottom:none; }
.scan-edit-row .se-idx{ width:26px; color:var(--muted); font-size:11px; }
.scan-edit-row .se-name{ flex:1; font-size:13px; }
.scan-edit-row .se-tier{ font-size:11px; color:var(--muted); width:62px; }
.scan-edit-row button{ padding:3px 8px; font-size:12px; cursor:pointer; }
.scan-edit-add{ display:flex; gap:8px; margin-top:12px; flex-wrap:wrap; }
.scan-edit-add .input{ flex:1; min-width:140px; }
.scan-edit-add .select{ width:auto; }
@media(max-width:900px){ .scan-kpis{ grid-template-columns:repeat(2,1fr); } .scan-grid{ grid-template-columns:repeat(2,1fr); } }

/* 自动发文页 */
.wp-kpis{ display:grid; grid-template-columns:repeat(4,minmax(0,1fr)); gap:12px; margin-bottom:14px; }
.wp-kpis .kp{ background:var(--muted); border-radius:8px; padding:14px 16px; text-align:center; }
.wp-kpis .kp-n{ display:block; font-size:22px; font-weight:600; line-height:1.1; color:#fff; }
.wp-kpis .kp-l{ display:block; font-size:11.5px; color:rgba(255,255,255,.82); margin-top:6px; }
.wp-grid{ display:grid; grid-template-columns:1fr 1.15fr; gap:14px; margin-bottom:14px; }
.wp-card{ min-width:0; }
.wp-body{ padding:14px 18px 18px; }
.wp-tip{ margin-bottom:12px; line-height:1.55; }
.wp-row{ display:flex; align-items:center; justify-content:space-between; gap:14px; padding:11px 0; border-bottom:1px solid var(--line); }
.wp-row:first-child{ padding-top:2px; }
.wp-row:last-child{ border-bottom:none; }
.wp-field-label{ font-size:13px; font-weight:500; }
.wp-field-desc{ font-size:11px; color:var(--muted); margin-top:3px; line-height:1.45; }
.wp-slots{ display:flex; gap:6px; flex:none; }
.wp-row-static .wp-field-desc{ max-width:260px; }
.wp-topic-list{ max-height:340px; overflow-y:auto; border:1px solid var(--line); border-radius:8px; padding:8px 10px; }
.wp-topic{ border-bottom:1px solid var(--line); padding:9px 2px; }
.wp-topic:last-child{ border-bottom:none; }
.wp-topic-line{ display:flex; align-items:center; gap:7px; }
.wp-topic-idx{ width:22px; color:var(--muted); font-size:11px; flex:none; }
.wp-topic-name{ flex:1; min-width:0; }
.wp-topic-del{ color:var(--danger); background:none; border:none; cursor:pointer; font-size:12px; padding:2px 6px; flex:none; }
.wp-topic-kws{ display:flex; flex-wrap:wrap; gap:5px; margin:7px 0 0 29px; }
.wp-kw{ display:inline-flex; align-items:center; gap:4px; background:#eff6ff; color:#1d4ed8; border-radius:12px; padding:3px 8px; font-size:11px; }
.wp-kw button{ background:none; border:none; color:#1d4ed8; cursor:pointer; font-size:13px; line-height:1; padding:0 0 0 2px; }
.wp-kw-add{ background:none; border:1px dashed var(--line); color:var(--muted); border-radius:12px; padding:3px 9px; font-size:11px; cursor:pointer; }
.wp-topic-actions{ display:flex; gap:10px; margin-top:12px; }
.wp-head-actions{ display:flex; gap:8px; }
.wp-log-wrap{ overflow-x:auto; }
@media(max-width:900px){ .wp-grid{ grid-template-columns:1fr; } .wp-kpis{ grid-template-columns:repeat(2,1fr); } }
.rule-sub{ font-size:11.5px; line-height:1.55; margin:2px 0 10px; }
.rule-toggle{ display:flex; align-items:center; gap:8px; font-size:13px; font-weight:500; margin-bottom:8px; }
.rule-toggle input{ width:16px; height:16px; }
.af-win-body{ display:flex; flex-direction:column; }
.af-windows{ display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); align-content:start; gap:8px; margin-bottom:10px; padding-right:4px; flex:1; min-height:0; overflow-y:auto; }
.af-win-actions{ display:flex; gap:8px; flex-wrap:wrap; }
.af-win{ display:flex; align-items:center; gap:5px; }
.af-win input[type=time]{ width:88px; min-width:0; padding:5px 4px; border:1px solid var(--line); border-radius:6px; font-size:12px; }
.af-win .af-win-sep{ color:var(--muted); flex:none; font-size:11.5px; }
.af-win .af-win-del{ margin-left:auto; flex:none; padding:4px 6px; font-size:11px; color:var(--danger); background:#fef2f2; border:1px solid #fecaca; border-radius:5px; cursor:pointer; }
/* 已执行时段着色 */
.af-win{ position:relative; border-radius:6px; }
.af-win.af-win-done{ background:#ecfdf5; box-shadow:inset 3px 0 0 var(--green); }
.af-win-done input[type=time]{ border-color:#a7f3d0; background:#f0fdf4; }
.af-win-check{ position:absolute; top:-5px; right:6px; width:14px; height:14px; border-radius:50%;
  background:var(--green); color:#fff; font-size:10px; line-height:14px; text-align:center; font-weight:700; z-index:2; pointer-events:none; }
.af-run-progress{ display:flex; align-items:center; justify-content:space-between; gap:10px; font-size:12px; color:var(--muted); margin-bottom:8px; }
.af-run-progress b{ font-weight:700; }
.af-methods{ display:grid; grid-template-columns:1fr 1fr; gap:8px; }
.af-method{ display:flex; align-items:flex-start; gap:8px; padding:8px 10px; border:1px solid var(--line); border-radius:7px; font-size:12px; line-height:1.45; cursor:pointer; }
.af-method:hover{ border-color:#c7d7fb; background:#f9fbff; }
.af-method input{ margin-top:2px; }
.af-method .af-mdesc{ display:block; color:var(--muted); font-size:11px; margin-top:2px; }
/* 关键词库：紧凑标签云（固定高度滚动，支持上千词） */
.af-kw-toolbar{ display:flex; gap:8px; margin-bottom:10px; flex-wrap:wrap; }
.af-kw-toolbar input{ flex:1; min-width:160px; padding:7px 10px; border:1px solid var(--line); border-radius:6px; font-size:12.5px; }
.af-kw-toolbar .af-kw-new{ flex:1.2; }
.af-keywords{ display:flex; flex-wrap:wrap; align-content:flex-start; gap:6px; max-height:210px; overflow-y:auto; padding:10px; border:1px solid var(--line); border-radius:7px; background:#fafbfc; }
.af-kw-chip{ display:inline-flex; align-items:center; gap:3px; max-width:100%; padding:4px 7px; background:#fff; border:1px solid #e2e8f0; border-radius:5px; font-size:11.5px; line-height:1.35; color:var(--text); }
.af-kw-chip:hover{ border-color:#c7d7fb; background:#f9fbff; }
.af-kw-txt{ overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.af-kw-x{ flex:none; width:16px; height:16px; padding:0; border:none; background:transparent; color:#9ca3af; font-size:14px; line-height:1; cursor:pointer; border-radius:3px; }
.af-kw-x:hover{ color:var(--danger); background:#fee2e2; }
.af-kw-more{ padding:4px 10px; font-size:11.5px; color:var(--primary); background:#eff6ff; border:1px solid #dbeafe; border-radius:5px; cursor:pointer; }
@media(max-width:900px){ .rule-grid{ grid-template-columns:1fr; } .rule-grid > .rule-card:nth-child(1), .rule-grid > .rule-card:nth-child(2){ height:auto; } .rule-span2{ grid-column:1; } .af-methods{ grid-template-columns:1fr; } .af-win-body{ display:block; } .af-windows{ display:flex; flex-direction:column; flex:none; max-height:220px; } }

/* ---------- 批量分配 ---------- */
.assign-hint{ background:#eff6ff; color:#1d4ed8; padding:11px 16px; border-radius:8px; font-size:12px; line-height:1.6; margin-bottom:16px; }
.assign-result{ margin-top:18px; border:1px solid var(--line); border-radius:8px; padding:14px 16px; background:#f9fafb; font-size:13px; min-height:48px; line-height:1.7; }
.assign-result .cnt{ font-size:18px; font-weight:600; color:var(--primary); }
.assign-result .prev{ color:var(--muted); font-size:12px; margin-top:6px; }
.assign-result .warn{ color:#b45309; }

/* ---------- 图表 ---------- */
.stats-grid{ display:grid; grid-template-columns:repeat(2,1fr); gap:18px; }
.barchart{ padding:16px 20px; }
.bar-row{ display:flex; align-items:center; gap:10px; margin-bottom:10px; }
.bar-label{ width:90px; font-size:12px; color:var(--muted); text-align:right; flex-shrink:0; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.bar-track{ flex:1; background:#f3f4f6; border-radius:4px; height:18px; overflow:hidden; }
.bar-fill{ height:100%; background:var(--primary); border-radius:4px; min-width:2px; transition:width .3s; }
.bar-val{ width:42px; font-size:12px; font-weight:600; text-align:right; }
.bar-val .bar-pct{ color:var(--muted); font-weight:400; font-size:11px; margin-left:2px; }

/* ---------- 表单/弹窗 ---------- */
.form-grid{ display:grid; grid-template-columns:1fr 1fr; gap:14px; }
.form-group{ display:flex; flex-direction:column; }
.form-group.full{ grid-column:1/-1; }
.form-group label{ font-size:12px; color:var(--muted); margin-bottom:5px; }
.form-group input,.form-group select,.form-group textarea{ width:100%; }
.modal{ position:fixed; inset:0; background:rgba(0,0,0,.45); display:flex; align-items:center; justify-content:center; z-index:50; padding:20px; }
.modal-box{ background:#fff; border-radius:12px; width:520px; max-width:100%; max-height:90vh; overflow:auto; box-shadow:0 20px 50px rgba(0,0,0,.2); }
.modal-box.large{ width:760px; }
.modal-box.small{ width:400px; }
.modal-head{ display:flex; align-items:center; justify-content:space-between; padding:18px 22px; border-bottom:1px solid var(--line); }
.modal-head h3{ font-size:16px; }
.close{ background:none; border:none; font-size:24px; color:var(--muted); cursor:pointer; line-height:1; }
.modal-body{ padding:22px; }
.modal-body > label{ display:block; font-size:12px; color:var(--muted); margin:12px 0 6px; }
.modal-body > input[type=text],.modal-body > input[type=email],.modal-body textarea,#importText{ width:100%; }
.modal-body textarea,#importText{ resize:vertical; }
.modal-foot{ display:flex; justify-content:flex-end; gap:10px; padding:16px 22px; border-top:1px solid var(--line); }
.inline-form{ display:flex; gap:10px; padding:0 20px 16px; }
.inline-form input{ flex:1; }
.master-list{ padding:0 20px; }
.master-item{ display:flex; justify-content:space-between; align-items:center; padding:8px 0; border-bottom:1px solid #f3f4f6; font-size:13px; }
.settings-panel{ max-width:560px; padding-bottom:24px; }
.settings-panel > label,.settings-panel > input{ display:block; margin-left:20px; margin-right:20px; }
.settings-panel > label{ font-size:12px; color:var(--muted); margin-top:14px; margin-bottom:6px; }
.settings-panel > .panel-head + label{ margin-top:20px; }
.settings-panel > .btn{ margin:16px 20px 0; }
.divider{ height:1px; background:var(--line); margin:24px 20px; }
.data-manage{ padding:0 20px; }
.data-manage h3{ font-size:15px; margin-bottom:8px; }
.data-manage p{ margin-bottom:12px; }
.data-manage input{ display:block; margin-bottom:10px; }

.toast{ position:fixed; bottom:28px; left:50%; transform:translateX(-50%); background:#111827; color:#fff;
  padding:12px 24px; border-radius:8px; z-index:100; font-size:13px; box-shadow:0 10px 30px rgba(0,0,0,.2); }
.toast.success{ background:var(--green); }
.toast.error{ background:var(--danger); }

@media(max-width:900px){
  .sidebar{ width:64px; } .brand{ padding:14px 10px; justify-content:center; } .brand-logo{ width:40px; }
  .brand-name,.brand-sub,.nav-item span:not(.ico),.user-meta,.logout-btn{ display:none; }
  .nav-item{ justify-content:center; } .main{ margin-left:64px; width:calc(100% - 64px); }
  .stats-grid{ grid-template-columns:1fr; } .form-grid{ grid-template-columns:1fr; }
}
