/* 微信运营台 — 内网仪表台样式(无外部依赖)
   气质: 精密仪表台 × 印刷文档 —— 暖纸白底、炭黑侧栏、铜色点缀、等宽数据 */

:root {
  --bg: #f6f3ec;
  --surface: #fffdf9;
  --ink: #2a2622;
  --ink-soft: #6f675e;
  --ink-faint: #a49b8f;
  --line: #e6e1d7;
  --line-strong: #d5cfc2;
  --accent: #b26a2f;      /* 铜色 */
  --accent-deep: #8a4a1c;
  --accent-soft: #f3e7d8;
  --ok: #2e7d5b;
  --warn: #b45309;
  --bad: #b3402f;
  --sidebar: #221f1b;
  --sidebar-ink: #cbc4b8;
  --sidebar-active: #3a3228;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  /* 图表色阶(同一铜色 hue 的明度阶梯, 等级有序) */
  --chart-a: #63300e;
  --chart-b: #8a4a1c;
  --chart-c: #b26a2f;
  --chart-d: #dcae77;
  --radius: 6px;
  --shadow: 0 1px 3px rgba(42, 38, 34, .07), 0 1px 2px rgba(42, 38, 34, .05);
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "PingFang SC", "Hiragino Sans GB", "Source Han Sans SC",
               "Noto Sans CJK SC", sans-serif;
  font-size: 14px;
  line-height: 1.6;
}

.mono { font-family: var(--mono); }
.muted { color: var(--ink-soft); }

/* ---------- 布局 ---------- */

/* 外壳固定高度 → 整页**永远不出滚动条**; 该滚的东西在各自的局部容器里滚。
   见下面 .main / .main-inner / .main-fill 的三层结构。 */
.layout { display: flex; height: 100vh; overflow: hidden; }

.sidebar {
  width: 216px;
  flex: none;
  background: var(--sidebar);
  color: var(--sidebar-ink);
  display: flex;
  flex-direction: column;
  padding: 20px 12px;
  overflow-y: auto;      /* 窗口矮时侧栏自己滚, 不把整页顶下去 */
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 16px;
  font-weight: 600;
  letter-spacing: .06em;
  padding: 4px 10px 18px;
  color: #f2ede4;
}

.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border: 1px solid var(--accent);
  border-radius: 6px;
  color: #e8b784;
  font-size: 14px;
}

.nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }

.nav-item {
  display: block;
  padding: 9px 12px;
  border-radius: 5px;
  color: var(--sidebar-ink);
  text-decoration: none;
  border-left: 2px solid transparent;
  transition: background .12s, color .12s;
}

.nav-item:hover { background: #2e2a24; color: #f2ede4; }

.nav-item.active {
  background: var(--sidebar-active);
  color: #f2ede4;
  border-left-color: var(--accent);
  font-weight: 600;
}

.sidebar-foot { border-top: 1px solid #3a352d; padding-top: 10px; }
.nav-quit { color: #9d968a; }
.nav-quit:hover { color: #e8c9c2; }

.main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  overflow-y: auto;              /* 默认的局部滚动容器(内容最外层) */
  overscroll-behavior: contain;  /* 滚到底不要把外面的东西带着滚 */
}

.main-inner {
  padding: 28px 36px 56px;
  max-width: 1200px;
}

/* ---------- 表格页: 标题与筛选栏钉住, 只有表格区域滚(main-fill) ----------
   为什么要单独一套: 联系人列表默认一屏放不下 20 行 + 分页条, 若跟着整页滚,
   筛选栏(改关键词/标签的地方)会被滚出视野 —— 每改一次筛选都得先滚回顶部。
   做法是让 main-inner 变成"高度撑满的纵向 flex", 只给表格容器 flex:1 + overflow。 */

.main-fill { overflow: hidden; }

.main-fill > .main-inner {
  flex: 1;
  min-height: 0;                 /* flex 子项默认 min-height:auto, 不置 0 就滚不起来 */
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding-bottom: 16px;          /* 表格页的滚动区就是表格, 底部留白收窄(默认 56px 太浪费) */
}

.main-fill .page-head,
.main-fill .filterbar { flex: none; }

.main-fill #contacts-table {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
}

/* 表头钉在表格滚动区顶部。
   注意用 box-shadow 画分隔线: border-collapse: collapse 下 sticky 的 th 边框会消失。 */
.main-fill #contacts-table .table thead th {
  position: sticky;
  top: 0;
  z-index: 3;
  background: var(--surface);
  box-shadow: inset 0 -1px 0 var(--line-strong);
}

/* 分页条钉在底部: 翻页不用先滚到底 */
.main-fill #contacts-table .pager {
  position: sticky;
  bottom: 0;
  z-index: 3;
  background: var(--bg);
  border-top: 1px solid var(--line);
  padding-bottom: 8px;
}

/* ---------- 页头 ---------- */

.page-head {
  display: flex;
  align-items: baseline;
  gap: 16px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.page-head h1 {
  margin: 0;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: .02em;
}

.page-head h1::after {
  content: "";
  display: block;
  width: 42px;
  height: 3px;
  margin-top: 8px;
  background: var(--accent);
  border-radius: 2px;
}

.remark { color: var(--ink-soft); font-size: 16px; font-weight: 400; }
.back { display: inline-block; margin-bottom: 14px; color: var(--accent-deep); text-decoration: none; }
.back:hover { text-decoration: underline; }
.poll-badge {
  font-size: 12px;
  color: var(--accent-deep);
  background: var(--accent-soft);
  border: 1px solid #e5cdb0;
  padding: 3px 10px;
  border-radius: 20px;
}

/* ---------- 面板 / 网格 ---------- */

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 20px;
  margin-bottom: 20px;
}

.panel h2 {
  margin: 0 0 14px;
  font-size: 15px;
  font-weight: 700;
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
}

.panel h2.mt, h2.mt { margin-top: 22px; }

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  align-items: start;
}

@media (max-width: 960px) { .grid-2 { grid-template-columns: 1fr; } }

/* ---------- 表格 ---------- */

.panel-table { padding: 6px 0 10px; overflow-x: auto; }

.table { width: 100%; border-collapse: collapse; }

.table th {
  text-align: left;
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-soft);
  letter-spacing: .05em;
  padding: 10px 16px;
  border-bottom: 1px solid var(--line-strong);
  white-space: nowrap;
}

.table td {
  padding: 10px 16px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

.table tbody tr:last-child td { border-bottom: none; }

.row-link { cursor: pointer; transition: background .1s; }
.row-link:hover { background: #faf6ec; }

.td-name { font-weight: 600; white-space: nowrap; }
.td-remark { color: var(--ink-soft); max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.td-tags { max-width: 200px; }

.conf-high { color: var(--ok); font-weight: 700; }

/* ---------- 标签 / 徽章 ---------- */

.tag {
  display: inline-block;
  font-size: 12px;
  padding: 1px 8px;
  margin: 0 4px 2px 0;
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  color: var(--ink-soft);
  background: var(--bg);
}

.badge {
  display: inline-block;
  font-size: 11px;
  padding: 1px 8px;
  border-radius: 4px;
  background: var(--accent-soft);
  color: var(--accent-deep);
  border: 1px solid #e5cdb0;
  letter-spacing: .03em;
}

.badge-warn { background: #f7e8d4; color: var(--warn); border-color: #e8c9a0; }

.meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 4px; }

/* ---------- 表单 ---------- */

.form { display: flex; flex-direction: column; gap: 10px; }

.form label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
  color: var(--ink-soft);
}

.form input, .form select, .form textarea,
.tag-edit input, .upload-row input, .upload-row select,
.searchbox input, .search-row input, .search-row select,
.reject-row input {
  font: inherit;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 5px;
  padding: 7px 10px;
  outline: none;
}

.form input:focus, .form select:focus, .form textarea:focus,
.tag-edit input:focus, .upload-row input:focus, .upload-row select:focus,
.searchbox input:focus, .search-row input:focus, .search-row select:focus,
.reject-row input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(178, 106, 47, .15);
}

.hint { font-size: 12px; color: var(--ink-faint); margin: 2px 0 0; }

/* ---------- 按钮 ---------- */

button, .btn {
  font: inherit;
  font-weight: 600;
  color: #fff;
  background: var(--accent);
  border: 1px solid var(--accent-deep);
  border-radius: 5px;
  padding: 7px 16px;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
  transition: background .12s;
}

button:hover, .btn:hover { background: var(--accent-deep); }

.btn-ghost {
  background: transparent;
  color: var(--accent-deep);
  border-color: var(--line-strong);
}

.btn-ghost:hover { background: var(--accent-soft); }

.btn-danger {
  background: transparent;
  color: var(--bad);
  border-color: #e3b4ab;
}

.btn-danger:hover { background: #f9e9e6; }

.btn-xs { font-size: 12px; padding: 2px 10px; font-weight: 500; }

.tag-edit, .upload-row, .search-row, .reject-row, .task-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

/* ---------- 空态 ---------- */

.empty {
  text-align: center;
  color: var(--ink-faint);
  padding: 34px 16px;
  font-size: 13px;
  letter-spacing: .02em;
}

/* ---------- 分页 ---------- */

.pager {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 16px 4px;
  font-size: 12px;
  flex-wrap: wrap;
  gap: 8px;
}

.pager-links { display: flex; gap: 6px; align-items: center; }

.pager a {
  color: var(--accent-deep);
  text-decoration: none;
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  padding: 2px 10px;
  cursor: pointer;
}

.pager a:hover { background: var(--accent-soft); }

.page-cur {
  background: var(--accent);
  color: #fff;
  border-radius: 4px;
  padding: 2px 10px;
}

/* ---------- 搜索 / 筛选 ---------- */

.filterbar {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}

/* 筛选栏控件统一外观(与 .form 控件一致) */
.filterbar input, .filterbar select, .page-jump input {
  font: inherit;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 5px;
  padding: 7px 10px;
  outline: none;
}

.filterbar input:focus, .filterbar select:focus, .page-jump input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(178, 106, 47, .15);
}

.filterbar select { min-width: 118px; }

.searchbox { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.searchbox input { width: 240px; }
.searchbox input::placeholder { color: var(--ink-faint); }

/* 标签组合框: 触发按钮 + 可搜索浮层 */
.tag-combo { position: relative; display: inline-block; }

.tag-combo-btn {
  font: inherit;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 5px;
  padding: 7px 10px;
  min-width: 170px;
  max-width: 240px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  text-align: left;
}
.tag-combo-btn:hover { border-color: var(--accent); }
.tag-combo-btn .tag-combo-label {
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.tag-combo-btn .caret { color: var(--ink-faint); font-size: 11px; flex: none; }

.tag-combo-panel {
  /* 浮层: 悬浮在内容之上, 不占文档流、不撑开页面 */
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  z-index: 40;
  width: 430px;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  box-shadow: 0 8px 28px rgba(42, 38, 34, .18);
  padding: 8px;
}

.tag-combo-body { position: relative; }

/* 左侧字母索引: 绝对定位悬浮在标签列表之上, 不随列表滚动(固定) */
.tag-letter-rail {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  z-index: 2;
  width: 24px;
  margin: 0;
  padding: 2px 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  background: var(--surface);
  border-right: 1px solid var(--line);
  border-radius: 4px;
  box-shadow: 2px 0 8px rgba(42, 38, 34, .07);
  overflow-y: auto;
  scrollbar-width: none;
}
.tag-letter-rail::-webkit-scrollbar { width: 0; height: 0; }
.tag-letter {
  font-size: 11px;
  line-height: 1.4;
  text-align: center;
  color: var(--ink-faint);
  border-radius: 3px;
  cursor: pointer;
  flex: none;
  outline: none;
  user-select: none;
}
.tag-letter:hover, .tag-letter:focus-visible {
  background: var(--accent-soft);
  color: var(--accent-deep);
}
.tag-letter.active {
  background: var(--accent);
  color: #fff;
  font-weight: 700;
}
.tag-letter[hidden] { display: none; }

.tag-combo-panel input {
  width: 100%;
  margin-bottom: 6px;
  font: inherit;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 5px;
  padding: 6px 9px;
  outline: none;
}
.tag-combo-panel input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(178, 106, 47, .15);
}

.tag-combo-list {
  list-style: none;
  margin: 0;
  /* 左侧留出悬浮字母索引的宽度 */
  padding: 0 0 0 28px;
  /* 高度同时受窗口限制: 外壳改成固定高度后, 浮层超出窗口的部分会被裁掉,
     所以这里按 vh 收一道(浮层总高 ≈ 列表 + 搜索框 + 提示 + 逻辑行, 约 150px 余量)。 */
  max-height: min(460px, calc(100vh - 330px));
  overflow-y: auto;
}

/* 拼音首字母分组标题 */
.tag-combo-group {
  padding: 7px 9px 3px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .06em;
  color: var(--accent-deep);
  background: var(--accent-soft);
  border-radius: 3px;
  margin-top: 4px;
}
.tag-combo-group[hidden] { display: none; }

.tag-combo-item {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 6px 9px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 13px;
  color: var(--ink);
}
/* 关键: .tag-combo-item 显式 display:flex 会盖过 [hidden] 的 UA 样式,
   hidden 属性必须显式提升优先级, 否则过滤时元素标记了 hidden 却仍然可见 */
.tag-combo-item[hidden] { display: none; }
.tag-combo-item:hover, .tag-combo-item.active {
  background: var(--accent-soft);
  color: var(--accent-deep);
}
.tag-combo-item[aria-selected="true"] { font-weight: 700; color: var(--accent-deep); }
.tag-combo-item .tag-count {
  color: var(--ink-faint);
  font-size: 12px;
  font-family: var(--mono);
  flex: none;
}

.tag-combo-empty { padding: 8px 9px; color: var(--ink-faint); font-size: 13px; }

/* 添加时间区间 */
.date-range { display: inline-flex; align-items: center; gap: 6px; }
.date-range input { padding: 6px 8px; }

/* 页码跳转 */
.page-jump { display: inline-flex; align-items: center; gap: 6px; margin-left: 6px; }
.page-jump input { width: 66px; padding: 3px 8px; text-align: center; }

/* 表头排序 */
.sort-h { color: var(--ink-soft); text-decoration: none; white-space: nowrap; cursor: pointer; }
.sort-h:hover { color: var(--accent-deep); }
.sort-h.on { color: var(--accent-deep); font-weight: 700; }
.sort-ind { margin-left: 3px; font-size: 11px; opacity: .65; }
.sort-h.on .sort-ind { opacity: 1; }

.search-row input { flex: 1; min-width: 240px; }

.htmx-indicator { opacity: 0; transition: opacity .15s; }
.htmx-request .htmx-indicator, .htmx-request.htmx-indicator { opacity: 1; }

/* ---------- 详情页 ---------- */

.conf {
  font-size: 12px;
  color: var(--ok);
  border: 1px solid #bcd8c8;
  background: #eef6f1;
  padding: 1px 8px;
  border-radius: 4px;
}

/* ---------- 审批 ---------- */

.task-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px 16px;
  margin-bottom: 14px;
}

.task-head {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  font-size: 12px;
  margin-bottom: 8px;
}

.task-contact { font-weight: 600; }

.draft-label { font-size: 12px; color: var(--ink-soft); display: block; margin-bottom: 4px; }

.draft {
  width: 100%;
  font: inherit;
  font-size: 13px;
  background: #fbf8f1;
  border: 1px solid var(--line-strong);
  border-radius: 5px;
  padding: 8px 10px;
  min-height: 60px;
  resize: vertical;
  outline: none;
}

.draft:focus { border-color: var(--accent); }

.task-actions { margin-top: 10px; justify-content: space-between; }

.reject-row input { width: 220px; }

/* ---------- 看板 ---------- */

.stat-cards {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 14px;
  margin-bottom: 20px;
}

@media (max-width: 960px) { .stat-cards { grid-template-columns: repeat(3, 1fr); } }

.stat {
  background: var(--surface);
  border: 1px solid var(--line);
  border-top: 3px solid var(--line-strong);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px 16px 12px;
}

.stat-value { font-size: 26px; font-weight: 700; line-height: 1.2; }
.stat-hot { color: var(--bad); }
.stat-label { font-size: 12px; color: var(--ink-soft); margin-top: 2px; }

.chart { width: 100%; height: auto; display: block; }

.chart-label { font-size: 12px; fill: var(--ink-soft); }

.chart-value { font-size: 12px; font-weight: 600; fill: var(--ink); }

.chart-tick { font-size: 10px; fill: var(--ink-faint); }

.grid-line { stroke: var(--line); stroke-width: 1; }

.bar-A { fill: var(--chart-a); }
.bar-B { fill: var(--chart-b); }
.bar-C { fill: var(--chart-c); }
.bar-D { fill: var(--chart-d); }
.bar-grow { fill: var(--chart-c); }

.bar:hover { fill-opacity: .72; }

/* ---------- 搜索结果 ---------- */

.result-list { list-style: none; margin: 14px 0 0; padding: 0; }

.result-item {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px 14px;
  margin-bottom: 10px;
  background: var(--surface);
}

.result-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 4px; }
.sim { color: var(--ok); font-size: 12px; }
.preview { margin: 0; font-size: 13px; color: var(--ink-soft); }

/* ---------- 图片 ---------- */

.img-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 14px;
}

.img-card {
  margin: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}

.img-card img {
  width: 100%;
  height: 140px;
  object-fit: cover;
  display: block;
  background: var(--bg);
}

.img-card figcaption {
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
  align-items: flex-start;
}

.img-caption {
  color: var(--ink-soft);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.upload-row { margin-bottom: 14px; }
.upload-row input[type="file"] { padding: 5px; }

/* ---------- 错误页 ---------- */

.error-page { text-align: center; padding: 80px 20px; }

.error-code {
  font-size: 72px;
  font-weight: 700;
  color: var(--line-strong);
  letter-spacing: .04em;
}

.error-page h1 { margin: 4px 0 8px; font-size: 20px; }
.error-detail { color: var(--ink-soft); max-width: 480px; margin: 0 auto 12px; }

/* ---------- Toast ---------- */

#toast-root {
  position: fixed;
  top: 18px;
  right: 18px;
  z-index: 99;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  background: var(--sidebar);
  color: #f2ede4;
  border-left: 3px solid var(--ok);
  border-radius: 5px;
  padding: 9px 16px;
  font-size: 13px;
  box-shadow: var(--shadow);
  max-width: 340px;
  transition: opacity .3s, transform .3s;
}

.toast-error { border-left-color: var(--bad); }
.toast-out { opacity: 0; transform: translateY(-6px); }

/* ---------- 登录页 ---------- */

.login-body {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(640px 320px at 85% -10%, rgba(178, 106, 47, .12), transparent),
    var(--bg);
}

.login-card {
  width: 380px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: 0 6px 24px rgba(42, 38, 34, .1);
  padding: 36px 34px;
}

.login-brand { padding: 0 0 12px; font-size: 20px; color: var(--ink); }
.login-sub { color: var(--ink-soft); font-size: 12px; margin: 0 0 22px; }

.login-form { display: flex; flex-direction: column; gap: 10px; }
.login-form label { font-size: 12px; color: var(--ink-soft); }

.login-form input {
  font: inherit;
  font-family: var(--mono);
  border: 1px solid var(--line-strong);
  border-radius: 5px;
  padding: 9px 12px;
  outline: none;
}

.login-form input:focus { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(178, 106, 47, .15); }
.login-form button { margin-top: 8px; padding: 10px; }

.login-error {
  color: var(--bad);
  font-size: 13px;
  background: #f9e9e6;
  border: 1px solid #e3b4ab;
  border-radius: 5px;
  padding: 7px 12px;
}


/* 画像阅读区(机器抽取摘要 + 证据链, 2026-09-11) */
.reading {
  background: var(--accent-soft);
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  padding: 12px 14px;
  margin: 10px 0 14px;
}
.reading h3 { margin: 0 0 8px; font-size: 14px; color: var(--accent-deep); }
.reading h3 .hint { font-weight: 400; }
.reading dl { display: grid; grid-template-columns: 76px 1fr; gap: 6px 12px; margin: 0; }
.reading dt { font-size: 12px; color: var(--ink-soft); padding-top: 2px; }
.reading dd { margin: 0; font-size: 13px; line-height: 1.55; }
.reading ul.facts { margin: 0; padding-left: 16px; }
.reading ul.facts li { margin: 1px 0; }
.evidence { margin: 0 0 14px; }
.evidence summary {
  cursor: pointer;
  font-size: 13px;
  color: var(--accent-deep);
  padding: 6px 0;
}
.evidence table { width: 100%; border-collapse: collapse; font-size: 12px; }
.evidence th, .evidence td {
  border-top: 1px solid var(--line);
  padding: 5px 8px;
  text-align: left;
  vertical-align: top;
}
.evidence th { color: var(--ink-soft); font-weight: 600; white-space: nowrap; }
.evidence td:nth-child(2) { color: var(--ink); }

/* ---------- 关系图谱 ---------- */
.graph-controls { margin-bottom: 10px; }
.graph-controls select { min-width: 112px; }

.graph-legend {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  font-size: 12px; color: var(--ink-soft);
  margin: 0 0 10px;
}
.graph-legend .lg { display: inline-flex; align-items: center; gap: 4px; }
.graph-legend .lg::before {
  content: ''; width: 12px; height: 12px; border-radius: 50%;
  display: inline-block;
}
.graph-legend .lg-tag::before { background: #6b6156; }
.graph-legend .lg-c-min::before { background: #f2e8da; border: 1px solid var(--line-strong); }
.graph-legend .lg-c-max::before { background: #7a4413; margin-left: -6px; }

.graph-canvas {
  width: 100%;
  height: calc(100vh - 175px);
  min-height: 620px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 6px;
}

.graph-note { margin-top: 8px; font-size: 12px; color: var(--ink-faint); line-height: 1.5; }

.graph-detail {
  margin-top: 10px; padding: 10px 12px;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  font-size: 13px;
}
.graph-detail-head { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.graph-detail-head button { margin-left: auto; }
.graph-detail-table { border-collapse: collapse; font-size: 12px; margin-bottom: 6px; }
.graph-detail-table th, .graph-detail-table td {
  border-top: 1px solid var(--line);
  padding: 4px 12px 4px 0;
  text-align: left;
}
.graph-detail-table th { color: var(--ink-soft); font-weight: 600; }

/* ---------- 来源 / 群(2026-09-14) ---------- */
.td-source { max-width: 260px; }
.grp-name {
  display: inline-block; max-width: 190px; overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap; vertical-align: bottom;
  color: var(--ink); font-weight: 500;
}
.grp-n { font-size: 11px; color: var(--ink-faint); margin-left: 4px; }
.grp-more {
  font-size: 11px; color: var(--ink-faint); margin-left: 6px;
  border-bottom: 1px dotted var(--line-strong); cursor: help;
}
.group-list { list-style: none; padding: 0; margin: 0; }
.group-list li {
  padding: 6px 0; border-top: 1px solid var(--line);
  display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap;
}
.group-list li:first-child { border-top: none; }

/* ---------- 群成员变动流水 + 已退群兜底(2026-09-14) ---------- */
.grp-hist { color: var(--ink-faint); font-weight: 400; border-bottom: 1px dotted var(--line-strong); }
.event-list { list-style: none; padding: 0; margin: 0; }
.event-list li {
  padding: 6px 0; border-top: 1px solid var(--line);
  display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap;
}
.event-list li:first-child { border-top: none; }
.ev-badge {
  font-size: 11px; padding: 1px 6px; border-radius: 3px; border: 1px solid var(--line-strong);
  color: var(--ink-soft); background: var(--bg);
}
.ev-leave { color: var(--warn); border-color: #e8c9a0; background: #f7e8d4; }
.ev-join { color: #3f6b4a; border-color: #bcd9c4; background: #e8f3eb; }

/* 画像字段旁的证据徽标 + 证据链行高亮(2026-09-14) */
.ev-chip {
  display: inline-block; min-width: 1.15em; padding: 0 .38em; margin-left: .38em;
  border-radius: 999px; background: #ecdfcb; color: #7a4b1e;
  font-size: .7rem; line-height: 1.5; text-decoration: none; vertical-align: 1px;
}
a.ev-chip:hover { background: #dcc4a2; }
.evidence tbody tr.hl td { background: #fdf3e3; }
.evidence tbody tr.hl td:first-child { box-shadow: inset 3px 0 0 #b8763a; }
/* 出处列不许折行: 聊天出处是 `wxid_xxx#local_id`, 一折行就三四行高, 把"时间"列挤得对不上行。
   (2026-09-14 视觉复核时发现: 加了资料卡出处后, 这一列的拥挤更明显了) */
.evidence td:nth-child(3) { white-space: nowrap; }

/* ---------- 联系人头像(2026-09-14) ----------
   两层: 底层"名字首字 + 按名字推导的色相"兜底, 上层真实头像 <img>(加载失败由 onerror 移除)。
   缺头像的人因此永远有一块可辨识的色块, 不会出现空白或裂图。 */
.avatar {
  position: relative;
  display: inline-flex;
  flex: none;
  width: var(--av-size, 28px);
  height: var(--av-size, 28px);
  border-radius: 50%;
  overflow: hidden;
  background: hsl(var(--av-h, 30) 38% 88%);
  color: hsl(var(--av-h, 30) 45% 30%);
  vertical-align: middle;
}
.avatar-initial {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: calc(var(--av-size, 28px) * .44);
  font-weight: 600;
  line-height: 1;
  user-select: none;
}
.avatar-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: var(--surface);
}
/* 头像与名字同行(td-name 是 nowrap 的, 用 flex 让长名字仍能省略号收尾) */
.td-name { display: flex; align-items: center; gap: 8px; }
.td-name .nm { overflow: hidden; text-overflow: ellipsis; }
/* 详情页头: 头像与标题对齐到中线, 不跟着 baseline 走 */
.page-head .avatar { align-self: center; }

/* 推荐标签(2026-09-15): 已在现有标签集里的用实心, 新增建议用虚线+角标区分 ——
   两者样式一样的话, 人看不出"这个词是不是库里已有的"(用户要求"尽可能用现有标签") */
.rec-tags { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.rec-tag {
  display: inline-block; font-size: 12px; padding: 1px 8px;
  border-radius: 4px; background: var(--accent-soft); color: var(--accent-deep);
  border: 1px solid #e0cdb4;
}
.rec-tag.is-new {
  background: transparent; color: var(--ok); border: 1px dashed #9dc4ae;
}
.rec-tag.is-new::after { content: "新"; font-size: 10px; margin-left: 4px; vertical-align: 1px; }

/* ---------- 标签多选(and / or / not, 2026-09-14) ---------- */
/* 标签筛选: 可手敲表达式的输入框(与组合框按钮同尺寸, 换了内里) */
.tag-combo-field {
  display: inline-flex; align-items: center; gap: 6px;
  min-width: 240px; max-width: 320px;
  padding: 4px 8px 4px 10px;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 5px;
}
.tag-combo-field:focus-within { border-color: var(--accent); }
.tag-combo-input {
  font: inherit; color: var(--ink); background: none; border: none; outline: none;
  flex: 1; min-width: 0; padding: 3px 0;
}
.tag-combo-input::placeholder { color: var(--ink-faint); }
.tag-combo-caret {
  flex: none; cursor: pointer; color: var(--ink-faint); font-size: 11px;
  padding: 0 2px; user-select: none;
}
.tag-combo-caret:hover { color: var(--accent); }
.tag-combo-hint {
  padding: 7px 10px; font-size: 12px; line-height: 1.7; color: var(--ink-soft);
  border-top: 1px solid var(--line); background: #fffdf7;
}
.tag-combo-hint b { color: var(--accent-deep); }
.tag-combo-hint code {
  font-family: var(--mono); font-size: 11.5px;
  background: var(--accent-soft); color: var(--accent-deep);
  padding: 1px 5px; border-radius: 3px;
}
.tag-combo-logicrow {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 10px; border-top: 1px solid var(--line);
  background: var(--bg);
}
.tag-combo-logicrow .muted { font-size: 12px; }
.toggle-btn.on {
  background: var(--accent-soft); color: var(--accent-deep);
  border-color: #e0cdb4; font-weight: 600;
}
.tag-combo-chips {
  display: flex; gap: 4px; flex-wrap: wrap; max-width: 240px;
}
.tag-chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 1px 6px; border-radius: 4px; font-size: 12px;
  background: var(--accent-soft); color: var(--accent-deep);
  border: 1px solid #e0cdb4;
}
.tag-chip .x { cursor: pointer; color: var(--ink-faint); font-size: 11px; }
.tag-chip .x:hover { color: var(--bad); }
.tag-logic {
  display: inline-flex; border: 1px solid var(--line-strong); border-radius: 5px;
  overflow: hidden; background: var(--surface);
}
.tag-logic label {
  padding: 6px 9px; font-size: 12px; cursor: pointer; color: var(--ink-soft);
  border-right: 1px solid var(--line);
}
.tag-logic label:last-child { border-right: none; }
.tag-logic input { position: absolute; opacity: 0; pointer-events: none; }
.tag-logic label:has(input:checked) { background: var(--accent-soft); color: var(--accent-deep); font-weight: 600; }
/* 多选时条目左侧的勾选位: 未选为空框, 选中打勾 */
.tag-combo-item .tick { flex: none; width: 14px; color: var(--accent); font-size: 12px; }
.tag-combo-item .tlabel { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* 群成员开关(默认隐藏群成员时给出"被藏了多少"的提示) */
.hidden-note {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; color: var(--ink-soft);
}
.hidden-note button {
  font: inherit; font-size: 12px; padding: 2px 8px; cursor: pointer;
  border: 1px solid var(--line-strong); border-radius: 4px;
  background: var(--surface); color: var(--accent-deep);
}
.hidden-note button:hover { border-color: var(--accent); }

/* ---------- 消息 / 朋友圈(任务单 M-7) ---------- */

/* 与联系人列表同一套局部滚动: 标题 + 筛选栏钉住, 列表区自己滚 */
.main-fill #messages-table,
.main-fill #moments-list {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
}
.main-fill #messages-table .table thead th {
  position: sticky; top: 0; z-index: 3;
  background: var(--surface);
  box-shadow: inset 0 -1px 0 var(--line-strong);
}
.main-fill #messages-table .pager,
.main-fill #moments-list .pager {
  position: sticky; bottom: 0; z-index: 3;
  border-top: 1px solid var(--line);
  padding-bottom: 8px;
}
.main-fill #messages-table .pager { background: var(--bg); }
.main-fill #moments-list .pager { background: var(--surface); }

/* 关键词命中高亮 */
mark {
  background: #ffe08a;
  color: inherit;
  padding: 0 1px;
  border-radius: 2px;
}

/* 消息行 */
.msg-table .td-time { white-space: nowrap; width: 124px; }
.msg-table .td-chat { min-width: 190px; }
.msg-table .td-dir { white-space: nowrap; width: 76px; color: var(--ink-soft); }
.msg-table .td-content {
  word-break: break-word;
  white-space: normal;
  line-height: 1.65;
}
.chat-label { font-weight: 600; }
.sender { margin-left: 8px; font-size: 12px; color: var(--ink-soft); }
.badge-kind { margin-left: 6px; font-size: 11px; }

/* 朋友圈卡片 */
.moment-list { display: flex; flex-direction: column; }
.moment-card { padding: 15px 4px; border-bottom: 1px solid var(--line); }
.moment-card:last-child { border-bottom: none; }
.moment-head {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  margin-bottom: 6px;
}
.moment-author { font-weight: 700; }
.moment-author a { color: var(--accent-deep); text-decoration: none; }
.moment-author a:hover { text-decoration: underline; }
.moment-loc { font-size: 12px; color: var(--ink-soft); }
.moment-content { white-space: pre-wrap; word-break: break-word; line-height: 1.75; }

/* 联系人详情 → 消息 / 朋友圈深链 */
.rel-links { display: flex; gap: 8px; margin: -6px 0 16px; }

/* 「只看带图」开关(筛选栏里的 label) */
.filterbar label.toggle-btn {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; padding: 6px 10px; cursor: pointer;
  border: 1px solid var(--line-strong); border-radius: 5px;
  background: var(--surface); color: var(--accent-deep);
}
.filterbar label.toggle-btn input { width: auto; margin: 0; padding: 0; }

/* ================= 移动端适配 (≤820px) =================
   桌面 = 固定外壳 + 局部滚动 + 常驻侧栏;
   手机 = 顶栏 + 抽屉侧栏 + 整页滚动 + 表格转卡片。
   断点 820px: iPad 竖屏(768) 也吃这一套, 横屏(1024) 回到桌面布局。 */

.topbar { display: none; }
.nav-scrim { display: none; }

@media (max-width: 820px) {
  /* --- 基础: 页面级滚动, 禁掉桌面那套局部滚动 --- */
  html, body { height: auto; min-height: 100%; }
  body { font-size: 15px; -webkit-text-size-adjust: 100%; }

  .layout { display: block; height: auto; overflow: visible; }

  .main {
    height: auto;
    overflow: visible;
    padding-top: calc(52px + env(safe-area-inset-top));
  }
  .main-inner {
    max-width: none;
    padding: 16px 14px calc(28px + env(safe-area-inset-bottom));
  }
  /* main-fill(表格页的定高外壳)在手机上退化成普通文档流 */
  .main-fill, .main-fill > .main-inner { display: block; overflow: visible; height: auto; }
  .main-fill #contacts-table,
  .main-fill #messages-table,
  .main-fill #moments-list { overflow: visible; }
  .main-fill #contacts-table .pager,
  .main-fill #messages-table .pager,
  .main-fill #moments-list .pager { position: static; }

  /* --- 顶栏 --- */
  .topbar {
    display: flex;
    align-items: center;
    gap: 12px;
    position: fixed;
    top: 0; left: 0; right: 0;
    height: calc(52px + env(safe-area-inset-top));
    padding: env(safe-area-inset-top) 14px 0;
    background: var(--sidebar);
    color: #f2ede4;
    z-index: 40;
  }
  .topbar-title { font-size: 15px; font-weight: 600; letter-spacing: .05em; }
  .nav-toggle {
    display: inline-flex; align-items: center; justify-content: center;
    width: 38px; height: 38px; padding: 0;
    background: transparent; color: #e8b784;
    border: 1px solid #4a4238; border-radius: 7px;
    font-size: 17px; line-height: 1;
  }
  .nav-toggle:active { background: #2e2a24; }

  /* --- 侧栏 → 抽屉 --- */
  .sidebar {
    position: fixed; top: 0; bottom: 0; left: 0;
    width: min(78vw, 280px);
    z-index: 60;
    height: auto;
    padding: calc(16px + env(safe-area-inset-top)) 12px calc(16px + env(safe-area-inset-bottom));
    transform: translateX(-102%);
    transition: transform .22s ease;
    box-shadow: 10px 0 30px rgba(0, 0, 0, .3);
  }
  body.nav-open .sidebar { transform: none; }
  .nav-item { padding: 13px 12px; font-size: 15px; }
  .nav-scrim {
    display: block;
    position: fixed; inset: 0;
    background: rgba(20, 18, 15, .45);
    z-index: 55;
    opacity: 0; pointer-events: none;
    transition: opacity .2s ease;
  }
  body.nav-open .nav-scrim { opacity: 1; pointer-events: auto; }

  /* --- 页头 --- */
  .page-head { margin-bottom: 14px; gap: 8px; }
  .page-head h1 { font-size: 19px; }
  .page-head h1::after { margin-top: 6px; width: 34px; }
  .remark { font-size: 14px; }

  /* --- 筛选栏: 两列网格, 搜索/标签/日期占整行 --- */
  .filterbar {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    padding: 10px;
    margin-bottom: 14px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 10px;
  }
  .filterbar .searchbox,
  .filterbar .tag-combo,
  .filterbar .date-range,
  .filterbar .graph-controls { grid-column: 1 / -1; }
  .filterbar input,
  .filterbar select { width: 100%; min-width: 0; font-size: 16px; /* ≥16px 防 iOS 聚焦自动放大 */ min-height: 40px; }
  .searchbox input { width: 100%; }
  .filterbar select { min-width: 0; }
  .date-range { display: flex; align-items: center; gap: 6px; flex-wrap: nowrap; }
  .date-range input { flex: 1 1 0; min-width: 0; }
  .filterbar button, .filterbar .btn, .filterbar .btn-xs,
  .filterbar label.toggle-btn { min-height: 38px; font-size: 14px; justify-content: center; }

  /* 标签浮层: 手机上贴底弹出, 不再向右溢出屏幕 */
  .tag-combo { display: block; }
  .tag-combo-btn { width: 100%; max-width: none; min-height: 40px; justify-content: space-between; }
  .tag-combo-panel {
    position: fixed;
    left: 8px; right: 8px; top: auto; bottom: calc(8px + env(safe-area-inset-bottom));
    width: auto;
    max-height: 72vh;
    overflow-y: auto;
    z-index: 70;
    box-shadow: 0 -8px 32px rgba(0, 0, 0, .25);
  }
  .tag-combo-list { max-height: 46vh; }
  .tag-combo-hint { display: none; }   /* 小屏省空间: 语法说明长, 桌面再看 */

  /* --- 表格 → 卡片 --- */
  .panel-table { padding: 0; overflow: visible; border: none; background: transparent; }
  .table, .table tbody, .table tr, .table td { display: block; width: 100%; }
  .table thead { display: none; }
  .table tbody tr {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 10px 12px;
    margin-bottom: 10px;
    box-shadow: var(--shadow);
  }
  .table tbody tr:active { background: var(--accent-soft); }
  .table td {
    display: flex;
    gap: 8px;
    align-items: baseline;
    padding: 3px 0;
    border: none;
  }
  .table td[data-label]::before {
    content: attr(data-label);
    flex: 0 0 58px;
    color: var(--ink-faint);
    font-size: 12px;
  }
  /* 名称 = 卡片标题行, 不带标签 */
  .table td.td-name {
    display: flex; align-items: center;
    font-size: 16px; font-weight: 600;
    padding-bottom: 8px; margin-bottom: 6px;
    border-bottom: 1px dashed var(--line);
  }
  .table td.td-name::before { display: none; }
  /* 消息正文 = 卡片主体, 整宽 */
  .table td.td-content { display: block; padding: 8px 10px; margin-top: 6px; background: var(--bg); border-radius: 8px; }
  .table td.td-content::before { display: none; }
  .table td.td-chat { flex-wrap: wrap; }

  /* --- 分页 --- */
  .pager { flex-wrap: wrap; gap: 8px; padding: 10px 2px; }
  .pager-links { flex-wrap: wrap; gap: 6px; }
  .pager a, .page-cur { min-width: 34px; min-height: 34px; display: inline-flex; align-items: center; justify-content: center; }
  .page-jump { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
  .page-jump input { width: 64px; font-size: 16px; }

  /* --- 面板 / 网格 --- */
  .panel { padding: 14px; }
  .grid-2 { grid-template-columns: 1fr; gap: 12px; }
  .stat-cards { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stat { padding: 12px; }
  .img-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .img-caption { font-size: 12px; }
  .rel-links { flex-wrap: wrap; }
  .group-list li, .event-list li { flex-wrap: wrap; }

  /* 表单控件(详情页)统一大一点, 防 iOS 缩放 */
  .form input, .form select, .form textarea, .tag-edit input, .login-form input { font-size: 16px; min-height: 40px; }
  .form button, .tag-edit button, .login-form button { min-height: 42px; }

  /* --- 看板 SVG 图表 --- */
  .chart { width: 100%; height: auto; }

  /* --- 图谱: 手机竖屏给足高度, 工具栏改为网格 --- */
  .graph-controls { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
  .graph-controls > span.muted:first-child, .graph-controls > label { grid-column: 1 / -1; }
  .graph-canvas { height: 68vh; min-height: 420px; }
  .graph-legend { flex-wrap: wrap; gap: 6px; font-size: 12px; }
  .graph-detail { font-size: 13px; }

  /* --- 朋友圈卡片 --- */
  .moment-card { padding: 12px; }
  .moment-head { flex-wrap: wrap; gap: 6px; }

  /* --- 登录页 --- */
  .login-body { padding: 20px; }
  .login-card { width: 100%; max-width: 420px; padding: 26px 20px; }

  /* --- 提示条 --- */
  #toast-root { left: 12px; right: 12px; bottom: calc(12px + env(safe-area-inset-bottom)); }
}

/* 超窄屏(≤380px): 两列也嫌挤, 收成一列 */
@media (max-width: 380px) {
  .filterbar { grid-template-columns: 1fr; }
  .stat-cards { grid-template-columns: 1fr; }
  .img-grid { grid-template-columns: 1fr; }
}

/* 指触设备: 去掉 hover 残留色, 加大可点区 */
@media (hover: none) {
  .row-link:hover td { background: transparent; }
  .nav-item:hover { background: transparent; }
}

/* 联系人详情页「证据链」表格: 手机上同样转卡片(字段/出处/时间作副信息, 原话整宽) */
@media (max-width: 820px) {
  .evidence-table, .evidence-table tbody, .evidence-table tr, .evidence-table td { display: block; width: 100%; }
  .evidence-table thead { display: none; }
  .evidence-table tr {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 8px 10px;
    margin-bottom: 8px;
  }
  .evidence-table td { border: none; padding: 2px 0; display: flex; gap: 8px; align-items: baseline; }
  .evidence-table td[data-label]::before {
    content: attr(data-label);
    flex: 0 0 42px;
    color: var(--ink-faint);
    font-size: 12px;
  }
  .evidence-table td.ev-quote { display: block; margin: 4px 0; color: var(--ink); }
  .evidence-table td.ev-quote::before { display: none; }
  .evidence summary { padding: 10px 0; }
}
