:root {
  --bg: #f5f6f8;
  --card: #ffffff;
  --border: #e5e7eb;
  --text: #1f2329;
  --text-dim: #6b7280;
  --primary: #1a6dff;
  --primary-hover: #0d5ae0;
  --ok: #16a34a;
  --warn: #d97706;
  --err: #dc2626;
  --radius: 10px;
}

* { box-sizing: border-box; }

/* ⚠️ 必须让 hidden 属性压过作者样式里的 display。
   .modal 用了 display:grid，作者样式优先级高于浏览器默认的 [hidden]{display:none}，
   结果「进入 / 取消」设了 hidden=true 弹窗依然显示（线上真实故障）。 */
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.6 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
        "Microsoft YaHei", sans-serif;
}

/* ---------- 顶栏 ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 24px; background: #fff; border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 10;
}
.brand { display: flex; align-items: center; gap: 12px; }
.logo {
  width: 38px; height: 38px; border-radius: 9px; background: var(--primary);
  color: #fff; display: grid; place-items: center; font-size: 19px; font-weight: 700;
}
.topbar h1 { margin: 0; font-size: 17px; font-weight: 600; }
.sub { margin: 0; font-size: 12px; color: var(--text-dim); }

.status { display: flex; align-items: center; gap: 7px; font-size: 13px; color: var(--text-dim); }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--text-dim); }
.dot.ok { background: var(--ok); }
.dot.warn { background: var(--warn); }
.dot.err { background: var(--err); }

/* ---------- 布局 ---------- */
.wrap { max-width: 1180px; margin: 0 auto; padding: 20px 24px 60px; }
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 900px) { .grid { grid-template-columns: 1fr; } }

.card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px 20px; margin-bottom: 16px;
}
.card-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 14px; gap: 10px;
}
.card-head h2 { margin: 0; font-size: 15px; font-weight: 600; }

/* ---------- 表单 ---------- */
.field { display: block; margin-bottom: 13px; }
.field > span { display: block; font-size: 12.5px; color: var(--text-dim); margin-bottom: 5px; }
input[type=text], input[type=search], input[type=password], textarea, select {
  width: 100%; padding: 9px 11px; border: 1px solid var(--border);
  border-radius: 7px; font: inherit; font-size: 14px; color: var(--text);
  background: #fff; outline: none;
}
input:focus, textarea:focus, select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(26,109,255,.12);
}
textarea { resize: vertical; min-height: 80px; line-height: 1.65; }
select { width: auto; min-width: 120px; }

.btn {
  padding: 8px 15px; border: 1px solid var(--border); border-radius: 7px;
  background: #fff; color: var(--text); font: inherit; font-size: 13.5px;
  cursor: pointer; transition: .15s;
}
.btn:hover { border-color: #c9ced6; background: #fafbfc; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-hover); }
.btn.primary:disabled { background: #a9c6ff; border-color: #a9c6ff; cursor: not-allowed; }
.btn.ghost { color: var(--text-dim); }
.btn.sm { padding: 6px 11px; font-size: 12.5px; }
.btn.big { width: 100%; padding: 12px; font-size: 15px; font-weight: 500; margin-top: 6px; }

/* ---------- Tabs ---------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 14px; }
.tab {
  padding: 8px 14px; border: none; background: none; cursor: pointer;
  font: inherit; font-size: 13.5px; color: var(--text-dim);
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tab.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 500; }
.tab-body { min-height: 120px; }
.radio { display: flex; align-items: center; gap: 8px; font-size: 14px; cursor: pointer; }
.hint { font-size: 12.5px; color: var(--text-dim); margin-top: 8px; }

/* ---------- 成员选择 ---------- */
.picker {
  max-height: 300px; overflow-y: auto; border: 1px solid var(--border);
  border-radius: 7px; margin-top: 8px;
}
.picker-row {
  display: flex; align-items: center; gap: 9px; padding: 7px 11px;
  border-bottom: 1px solid #f0f1f3; cursor: pointer; font-size: 13.5px;
}
.picker-row:last-child { border-bottom: none; }
.picker-row:hover { background: #f7f9fc; }
.picker-row .nm { font-weight: 500; }
.picker-row .dp { color: var(--text-dim); font-size: 12px; }
.picker-empty { padding: 22px; text-align: center; color: var(--text-dim); font-size: 13px; }

/* ---------- 组织架构树：公司 → 部门 → 人员 ---------- */
.org-tools { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.btn.xs { padding: 3px 9px; font-size: 12px; }
.org-sum { margin-left: auto; font-size: 12px; color: var(--text-dim); white-space: nowrap; }
.org-picker { max-height: 380px; }
.org-node { border-bottom: 1px solid #f0f1f3; }
.org-node:last-child { border-bottom: none; }
.org-group {
  display: flex; align-items: center; gap: 7px; padding: 7px 10px;
  background: #f7f9fc; border-bottom: 1px solid #eef0f3; font-size: 13.5px;
}
.org-group:hover { background: #f0f5ff; }
.org-group[data-lvl="0"] { background: #eaf2ff; }
.org-group[data-lvl="0"] .org-name { font-weight: 600; }
.org-twisty {
  width: 14px; height: 14px; flex: none; border: 0; padding: 0;
  background: none; color: var(--text-dim); cursor: pointer;
}
.org-twisty::before {
  content: ''; display: block; width: 0; height: 0;
  border-left: 5px solid currentColor;
  border-top: 4px solid transparent; border-bottom: 4px solid transparent;
  transition: transform .15s;
}
.org-twisty.open::before { transform: rotate(90deg) translateX(1px); }
.org-twisty.placeholder::before { display: none; }
.org-folder { width: 15px; height: 15px; flex: none; color: #5b9bff; }
.org-name { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.org-count { margin-left: auto; font-size: 11.5px; color: var(--text-dim); white-space: nowrap; }
.org-group input[type=checkbox], .org-person input[type=checkbox] {
  flex: none; accent-color: var(--primary); cursor: pointer;
}
.org-children.collapsed { display: none; }
.org-person .dp { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- 预览 ---------- */
.preview {
  border: 1px solid var(--border); border-radius: 8px;
  padding: 11px 13px; background: #fafbfc; margin: 14px 0 12px;
}
.preview-label { font-size: 11.5px; color: var(--text-dim); display: block; margin-bottom: 6px; }
.preview-body { font-size: 13.5px; white-space: pre-wrap; word-break: break-word; }

/* ---------- 图片选择与预览 ---------- */
input[type=file] { width: 100%; font-size: 13px; padding: 8px 0; }
.img-preview { margin-top: 6px; }
.preview-img {
  display: block; max-width: 100%; max-height: 220px; object-fit: contain;
  border: 1px solid var(--border); border-radius: 8px; background: #fff;
}
.preview-body img {
  display: block; max-width: 100%; max-height: 180px; margin-top: 8px;
  border-radius: 6px; border: 1px solid var(--border);
}

/* ---------- 自检 ---------- */
.setup-body { font-size: 13.5px; }
.setup-row {
  display: flex; align-items: flex-start; gap: 9px;
  padding: 7px 0; border-bottom: 1px solid #f3f4f6;
}
.setup-row:last-child { border-bottom: none; }
.mark { font-weight: 700; width: 16px; flex: none; }
.mark.ok { color: var(--ok); }
.mark.bad { color: var(--err); }
.setup-row .msg { color: var(--text-dim); }
.setup-tip {
  margin-top: 12px; padding: 10px 12px; border-radius: 7px;
  background: #fff7ed; border: 1px solid #fed7aa; font-size: 13px; color: #9a3412;
}
.setup-tip.ok { background: #f0fdf4; border-color: #bbf7d0; color: #166534; }

/* ---------- 记录表 ---------- */
.batch-body { font-size: 13.5px; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 8px 10px; text-align: left; border-bottom: 1px solid #f0f1f3; font-size: 13px; }
th { color: var(--text-dim); font-weight: 500; font-size: 12px; }
.tag {
  display: inline-block; padding: 1px 8px; border-radius: 20px;
  font-size: 11.5px; font-weight: 500;
}
.tag.ok { background: #dcfce7; color: #166534; }
.tag.err { background: #fee2e2; color: #991b1b; }
.empty { padding: 24px; text-align: center; color: var(--text-dim); font-size: 13px; }

/* ---------- 弹窗 / toast ---------- */
.modal {
  position: fixed; inset: 0; background: rgba(0,0,0,.4);
  display: grid; place-items: center; z-index: 100;
}
.modal-card {
  background: #fff; border-radius: 12px; padding: 22px 24px;
  width: min(380px, 92vw);
}
.modal-card h2 { margin: 0 0 14px; font-size: 16px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 9px; margin-top: 14px; }

.toast {
  position: fixed; bottom: 26px; left: 50%; transform: translateX(-50%);
  background: #1f2329; color: #fff; padding: 11px 20px; border-radius: 8px;
  font-size: 13.5px; z-index: 200; max-width: 88vw; box-shadow: 0 6px 22px rgba(0,0,0,.2);
}
.toast.err { background: var(--err); }
.toast.ok { background: var(--ok); }

/* ---------- 阅读回执 / 名单 / 备份 ---------- */
.check-line { display: flex; align-items: flex-start; gap: 8px; margin: 12px 0 4px; font-size: 13.5px; cursor: pointer; }
.check-line input { margin-top: 3px; flex: none; }
.check-line.compact { margin: 0; font-size: 13px; white-space: nowrap; }
.receipt-tip { margin-top: 8px; color: var(--primary); }
.file-btn { position: relative; overflow: hidden; cursor: pointer; display: inline-flex; align-items: center; }
.file-btn input[type=file] { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; }
.backup-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 12px; }
.backup-actions .hint { flex: 1 1 100%; }

.modal-card.wide {
  width: min(860px, 94vw); max-height: 86vh;
  display: flex; flex-direction: column;
}
.report-summary { margin-bottom: 8px; }
.report-stats { display: flex; align-items: center; gap: 12px; font-size: 13px; margin-bottom: 6px; }
.report-tools {
  display: flex; align-items: flex-end; gap: 14px; flex-wrap: wrap;
  padding: 10px 0 12px; border-bottom: 1px solid var(--border);
}
.field.inline { margin: 0; min-width: 180px; }
.field.inline span { display: block; font-size: 12px; color: var(--text-dim); margin-bottom: 4px; }
.field.inline select {
  padding: 6px 10px; border: 1px solid var(--border);
  border-radius: 7px; font-size: 13px; background: #fff;
}
.report-body { overflow: auto; padding-top: 12px; }
.report-company { margin-bottom: 16px; }
.report-company-head {
  display: flex; justify-content: space-between; font-weight: 600; font-size: 13.5px;
  padding: 7px 10px; background: #eef4ff; border-radius: 7px;
}
.report-company-head span { color: var(--text-dim); font-weight: 400; font-size: 12.5px; }
.report-dept { margin: 10px 0 0 12px; }
.report-dept-head { display: flex; justify-content: space-between; font-size: 13px; padding-bottom: 5px; }
.report-dept-head span { color: var(--text-dim); font-size: 12px; }
.report-people { display: flex; flex-wrap: wrap; gap: 6px; }
.person {
  display: inline-flex; align-items: baseline; gap: 5px;
  padding: 3px 9px; border-radius: 6px; font-size: 12.5px; border: 1px solid transparent;
}
.person.ok { background: #f0fdf4; color: #166534; border-color: #bbf7d0; }
.person.no { background: #fef2f2; color: #991b1b; border-color: #fecaca; }
.person small { font-size: 10.5px; opacity: .6; }
/* 互动统计在页面卡片内（不是弹窗），必须自己限高，1839 人不能撑爆页面 */
.interact-body { max-height: 460px; overflow: auto; padding: 12px 4px 4px; }
.interact-summary { margin: 10px 0 0; }
