:root {
  --c-primary: #2563eb;
  --c-primary-dark: #1d4ed8;
  --c-primary-light: #eff6ff;
  --c-text: #1f2937;
  --c-text-muted: #6b7280;
  --c-border: #e5e7eb;
  --c-bg: #f5f7fa;
  --c-card: #ffffff;
  --c-success: #16a34a;
  --c-warning: #d97706;
  --c-danger: #dc2626;
  --radius: 8px;
  --radius-sm: 6px;
  --radius-lg: 12px;
  --shadow: 0 1px 3px rgba(16, 24, 40, 0.08), 0 1px 2px rgba(16, 24, 40, 0.04);
  --shadow-lg: 0 12px 32px rgba(16, 24, 40, 0.16);
  /* 布局尺度 */
  --topbar-h: 56px;
  --sidebar-w: 232px;
  --sidebar-w-collapsed: 64px;
  /* 间距尺度 */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--c-bg);
  color: var(--c-text);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
  line-height: 1.6;
}

a { color: var(--c-primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- 布局：侧边栏 + 顶部条 ---------- */
.app-shell { display: flex; min-height: 100vh; }
.app-sidebar {
  flex: 0 0 var(--sidebar-w);
  width: var(--sidebar-w);
  background: var(--c-card);
  border-right: 1px solid var(--c-border);
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
  transition: width .18s ease, flex-basis .18s ease;
  z-index: 30;
}
.side-brand {
  display: flex; align-items: center; gap: 10px;
  height: var(--topbar-h); padding: 0 18px;
  border-bottom: 1px solid var(--c-border);
  font-weight: 700; font-size: 15px; color: var(--c-text);
  white-space: nowrap; overflow: hidden;
}
.side-brand .logo {
  flex: 0 0 auto; width: 28px; height: 28px; border-radius: 7px;
  background: var(--c-primary); color: #fff;
  display: flex; align-items: center; justify-content: center; font-weight: 700;
}
.side-brand .side-logo {
  flex: 0 0 auto; width: 28px; height: 28px;
  object-fit: contain; display: block;
}
.side-nav { flex: 1 1 auto; overflow-y: auto; padding: 10px; }
.side-link, .side-group-title {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border-radius: 8px;
  color: var(--c-text-muted); font-weight: 500; font-size: 14px;
  white-space: nowrap; cursor: pointer; text-decoration: none;
  transition: background .12s ease, color .12s ease;
}
a.side-link:hover, .side-group-title:hover { background: var(--c-bg); color: var(--c-text); text-decoration: none; }
a.side-link.active { background: var(--c-primary-light); color: var(--c-primary); font-weight: 600; box-shadow: inset 3px 0 0 var(--c-primary); }
.side-link .nav-icon, .side-group-title .nav-icon { flex: 0 0 auto; }
.side-section { margin-bottom: 2px; }
.side-section-title {
  padding: 14px 12px 6px; margin-top: 2px;
  font-size: 11px; font-weight: 700; letter-spacing: .1em;
  text-transform: uppercase; color: var(--c-text-muted); opacity: .7;
  white-space: nowrap; overflow: hidden;
}
.side-group { margin-bottom: 2px; }
.side-group-title { cursor: default; }
.side-sub { padding: 2px 0 2px 30px; }
.side-sub .side-link { padding: 7px 12px; font-size: 13px; }
.side-collapse {
  flex: 0 0 auto; align-self: flex-end; margin: 8px 12px 12px;
  width: 28px; height: 28px; border: 1px solid var(--c-border); border-radius: 6px;
  background: var(--c-card); color: var(--c-text-muted); cursor: pointer; font-size: 14px;
  transition: transform .18s ease;
}
.side-collapse:hover { color: var(--c-primary); border-color: var(--c-primary); }

.app-main { flex: 1 1 auto; display: flex; flex-direction: column; min-width: 0; }
.app-topbar {
  height: var(--topbar-h); flex: 0 0 var(--topbar-h);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 20px; background: var(--c-card);
  border-bottom: 1px solid var(--c-border); position: sticky; top: 0; z-index: 20;
  box-shadow: 0 1px 0 rgba(16, 24, 40, .04);
}
.app-topbar .topbar-left { display: flex; align-items: center; }
.side-toggle {
  border: 1px solid var(--c-border); background: var(--c-card); color: var(--c-text-muted);
  width: 34px; height: 34px; border-radius: 7px; cursor: pointer; font-size: 16px; line-height: 1;
}
.side-toggle:hover { color: var(--c-primary); border-color: var(--c-primary); }
.app-topbar .right { display: flex; align-items: center; gap: 14px; color: var(--c-text-muted); }

/* 右上角积分徽章：奖章图标 + 数字，与用户名并排。
   采用业内常见的「图标 + 数值」胶囊造型，主色描边 + 浅色底，不抢用户名焦点。
   拉取成功后才加 .is-ready 显形，避免数字还没回来时闪一下空壳。 */
.points-badge {
  display: none;
  align-items: center; gap: 6px;
  height: 28px; padding: 0 10px;
  border-radius: 999px;
  border: 1px solid rgba(37, 99, 235, .25);
  background: rgba(37, 99, 235, .08);
  color: var(--c-primary);
  font-size: 13px; font-weight: 600; line-height: 1;
  cursor: default;
}
.points-badge.is-ready { display: inline-flex; }
.points-badge svg { flex: none; }
.points-badge #points-value { font-variant-numeric: tabular-nums; }
.points-badge:hover { background: rgba(37, 99, 235, .14); }

/* 折叠态：侧栏收窄为图标 */
body.sidebar-collapsed .app-sidebar { flex-basis: var(--sidebar-w-collapsed); width: var(--sidebar-w-collapsed); }
body.sidebar-collapsed .side-brand { padding: 0; justify-content: center; }
body.sidebar-collapsed .side-brand-text,
body.sidebar-collapsed .side-link span,
body.sidebar-collapsed .side-group-title span,
body.sidebar-collapsed .side-section-title,
body.sidebar-collapsed .side-sub { display: none; }
body.sidebar-collapsed .side-nav { padding: 10px 8px; }
body.sidebar-collapsed .side-collapse { transform: rotate(180deg); }

/* 窄屏：侧栏改为抽屉，默认隐藏，由顶栏汉堡切换（collapsed 态即打开抽屉） */
@media (max-width: 720px) {
  .app-sidebar {
    position: fixed; left: 0; top: 0; z-index: 40; box-shadow: var(--shadow-lg);
    transform: translateX(-100%); transition: transform .2s ease;
  }
  body.sidebar-collapsed .app-sidebar { transform: translateX(0); }
  body.sidebar-collapsed .side-brand { padding: 0 18px; justify-content: flex-start; }
  body.sidebar-collapsed .side-brand-text,
  body.sidebar-collapsed .side-link span,
  body.sidebar-collapsed .side-group-title span,
  body.sidebar-collapsed .side-sub { display: revert; }
}

/* ---------- 元数据字典 ---------- */
.scope-badge { display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 12px; border: 1px solid; }
.scope-badge.scope-system { background: #eff6ff; color: #1d4ed8; border-color: #bfdbfe; }
.scope-badge.scope-user { background: #f0fdf4; color: #15803d; border-color: #bbf7d0; }
/* 二级分类标记：挂在父级下的字典项（当前仅客户来源的「陌生开拓-x」） */
.scope-badge.scope-sub { background: #fef3c7; color: #92400e; border-color: #fde68a; margin-left: 6px; }
.inline-form { display: flex; gap: 8px; align-items: center; margin-bottom: 14px; }
.inline-form input { flex: 1; max-width: 320px; }

/* ---------- 字典树形展示（客户来源「陌生开拓」的二级分类） ---------- */
.tree-toggle {
  display: inline-flex; align-items: center; justify-content: center;
  width: 20px; height: 20px; margin-right: 6px; padding: 0;
  border: 1px solid var(--c-border); border-radius: 4px;
  background: #fff; color: var(--c-text-muted); font-size: 11px; line-height: 1; cursor: pointer;
}
.tree-toggle:hover { color: var(--c-primary); border-color: var(--c-primary); }
.tree-count { margin-left: 6px; font-size: 12px; color: var(--c-text-muted); }
/* 二级分类行：名称列缩进，配合 └ 标记体现从属关系 */
table.data td.tree-child { padding-left: 30px; }
.tree-mark { display: inline-block; width: 14px; margin-right: 4px; color: #cbd5e1; }

/* ---------- 列表彩色标签（客户分类 / 客户来源 / 家庭情况） ---------- */
.tag-chip {
  display: inline-block; max-width: 100%; padding: 2px 8px;
  border: 1px solid; border-radius: 10px; font-size: 12px; line-height: 1.6;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.navbar .right { display: flex; align-items: center; gap: 14px; color: var(--c-text-muted); }

/* ---------- 消息提醒铃铛 ---------- */
.bell-wrap { position: relative; display: inline-flex; }
.bell-btn {
  position: relative; display: inline-flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; padding: 0; border: 1px solid var(--c-border);
  border-radius: 50%; background: var(--c-card); color: var(--c-text-muted); cursor: pointer;
  transition: color .12s ease, border-color .12s ease, background .12s ease;
}
.bell-btn:hover { color: var(--c-primary); border-color: var(--c-primary); background: var(--c-primary-light); }
.bell-btn.open { color: var(--c-primary); border-color: var(--c-primary); background: var(--c-primary-light); }
.bell-dot {
  position: absolute; top: -4px; right: -4px; min-width: 16px; height: 16px; padding: 0 4px;
  box-sizing: border-box; border-radius: 9px; background: var(--c-danger); color: #fff;
  font-size: 11px; line-height: 16px; text-align: center; border: 2px solid var(--c-card);
}
/* 显隐用 .open 类控制：不能依赖 hidden 属性——作者样式的 display 会覆盖 UA 的 [hidden]{display:none} */
.bell-panel {
  display: none;
  position: absolute; top: 44px; right: 0; width: 320px; max-height: 60vh; overflow: hidden;
  background: var(--c-card); border: 1px solid var(--c-border); border-radius: var(--radius);
  box-shadow: var(--shadow); z-index: 1000; flex-direction: column;
}
.bell-panel.open { display: flex; }
.bell-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 14px; border-bottom: 1px solid var(--c-border); font-weight: 600; font-size: 14px;
}
.bell-mark { border: none; background: none; color: var(--c-primary); cursor: pointer; font-size: 12px; padding: 0; }
.bell-mark:hover { text-decoration: underline; }
.bell-list { list-style: none; margin: 0; padding: 0; overflow-y: auto; }
.bell-item {
  display: flex; gap: 10px; padding: 10px 14px; border-bottom: 1px solid var(--c-border);
  border-left: 3px solid var(--c-border); cursor: pointer;
}
.bell-item:hover { background: var(--c-bg); }
.bell-item.lvl-high { border-left-color: var(--c-danger); }
.bell-item.lvl-medium { border-left-color: #f59e0b; }
.bell-item.lvl-low { border-left-color: var(--c-primary); }
.bell-item.read { opacity: .55; }
.bell-body { min-width: 0; }
.bell-title { font-size: 13px; font-weight: 600; color: var(--c-text); }
.bell-tag { font-size: 11px; font-weight: 500; color: var(--c-text-muted); margin-left: 6px; }
.bell-msg { font-size: 12px; color: var(--c-text-muted); margin-top: 2px; line-height: 1.4; }
.bell-empty { padding: 22px 14px; text-align: center; color: var(--c-text-muted); font-size: 13px; }
/* 铃铛面板头部操作区：全部已读 + 历史消息入口 */
.bell-head-actions { display: flex; align-items: center; gap: 10px; }
.bell-history-link { color: var(--c-primary); font-size: 12px; text-decoration: none; }
.bell-history-link:hover { text-decoration: underline; }

/* 历史消息：已读提醒归档列表 */
.card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.card-head .card-title { margin: 0; }
.hint-inline { font-weight: 400; font-size: 12px; color: var(--c-text-muted); margin-left: 6px; }
.hint-inline.is-err { color: var(--c-danger); }
.hist-list { list-style: none; margin: 0; padding: 0; }
.hist-item {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 12px;
  padding: 12px 14px; border-bottom: 1px solid var(--c-border); border-left: 3px solid var(--c-border);
}
.hist-item:last-child { border-bottom: none; }
.hist-item.lvl-high { border-left-color: var(--c-danger); }
.hist-item.lvl-medium { border-left-color: #f59e0b; }
.hist-item.lvl-low { border-left-color: var(--c-primary); }
.hist-body { min-width: 0; }
.hist-title { font-size: 14px; font-weight: 600; color: var(--c-text); }
.hist-tag { font-size: 11px; font-weight: 500; color: var(--c-text-muted); margin-left: 6px; }
.hist-msg { font-size: 13px; color: var(--c-text-muted); margin-top: 4px; line-height: 1.5; }
.hist-meta { font-size: 12px; color: var(--c-text-muted); margin-top: 6px; }

.container { max-width: 1280px; margin: 0 auto; padding: 24px; }
.page-title { margin: 0 0 4px; font-size: 21px; font-weight: 700; letter-spacing: -0.01em; color: var(--c-text); }
.page-sub { margin: 0 0 20px; color: var(--c-text-muted); font-size: 13px; }

/* 通用页头模板：标题居左、操作区居右（各菜单页统一复用此类，替代原先逐页复制的内联 flex 样式）。
   改这一处即可全站同步，避免页面间视觉与交互漂移。 */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 20px;
}
.page-header .page-title { margin-bottom: 4px; }
.page-header .page-sub { margin-bottom: 0; }
.page-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
@media (max-width: 640px) {
  .page-header { flex-direction: column; align-items: stretch; }
  .page-actions { flex-wrap: wrap; }
}

/* 悬浮锁定：页头 + 查询工具栏滚动时常驻可见（公共能力）。
   页面不写这段样式——由 window.App.mountStickyHeader() 给 .page-header / .toolbar 加上
   .sticky-header / .sticky-toolbar 即可启用，避免逐页复制一份（产品类型维护页的
   .pt-sticky / .pt-toolbar 是页内前身实现，后续统一迁移到本类）。

   层级取值（每一条都是硬约束，改动前先核对）：
     - 必须 < 20：顶栏 .app-topbar 是 z-index 20 的层叠上下文，铃铛下拉 .bell-panel
       虽然自身 z-index 1000，仍被困在该上下文里、向下覆盖到页头区域；页头若 ≥ 20
       就会把铃铛面板压在下面。故取 15 / 12。
     - 必须 < 50 / 60 / 90：弹窗遮罩 .modal-mask(50)、便签浮层 .note-pop(60)、
       portal 下拉 .search-select-panel.is-portal(90) 都要盖在工具栏之上，15 / 12 均满足。
     - 必须 > 0：正数 z-index 才能压住普通内容与 table.data th（sticky、z-index auto）。

   未吸顶时保持透明、融入页面背景；仅 .is-stuck 才上白底与阴影——否则不滚动时
   页面顶部会无端多出一块白条。 */
.sticky-header {
  position: sticky;
  top: var(--topbar-h, 56px);
  z-index: 15;
  padding-top: 6px;
  padding-bottom: 6px;
  margin-bottom: 16px;
}
.sticky-header.is-stuck {
  background: var(--c-card);
  box-shadow: 0 6px 10px -8px rgba(16, 23, 42, .25);
}
.sticky-toolbar {
  position: sticky;
  /* 顶栏高 + 页头实测高：页头高度由 mountStickyHeader() 实测后写入 --sticky-ph-h，
     窄屏页头换行变高时随之变化，故不能写死 */
  top: calc(var(--topbar-h, 56px) + var(--sticky-ph-h, 58px));
  z-index: 12;
  /* 下方留白改为内边距：内边距在白底盒子内，表格行不会从「工具栏与表格之间的空隙」穿过 */
  margin-bottom: 0;
  padding-bottom: 12px;
}
.sticky-toolbar.is-stuck {
  background: var(--c-card);
  border-bottom: 1px solid var(--c-border);
  box-shadow: 0 6px 10px -8px rgba(16, 23, 42, .18);
}

/* ---------- 知识检索（AnythingLLM API 集成，对话框） ---------- */
/* 整页纵向 flex：聊天卡片占满内容区剩余高度（减去顶栏与容器内边距），
   对话框成为主内容区的主体，避免下方大片留白；无需脚本计算高度 */
.kb-page {
  display: flex; flex-direction: column; gap: var(--space-4);
  flex: 1 1 auto;
  min-height: calc(100vh - var(--topbar-h) - 48px);
}
.kb-head { flex: 0 0 auto; }
.kb-head .page-sub { margin: 0; }

.kb-chat-card {
  flex: 1 1 auto; display: flex; flex-direction: column;
  padding: 0; overflow: hidden; min-height: 360px;
}
/* 知识库选择并入卡片头部，减少纵向占用、统一间距 */
.kb-chat-head {
  flex: 0 0 auto; display: flex; align-items: center; gap: var(--space-3);
  padding: 12px 16px; border-bottom: 1px solid var(--c-border); background: #fafbfc;
}
.kb-chat-head-label { font-size: 13px; color: var(--c-text-muted); white-space: nowrap; }
.kb-select {
  height: 32px; min-width: 180px; max-width: 100%; flex: 0 1 auto; padding: 0 10px;
  border: 1px solid var(--c-border); border-radius: var(--radius-sm);
  background: var(--c-card); color: var(--c-text); font-size: 13px; font-family: inherit;
}
.kb-select:focus {
  outline: none; border-color: var(--c-primary); box-shadow: 0 0 0 3px rgba(37, 99, 235, .12);
}

/* 消息区与输入栏：消息区自适应撑满并可滚动，输入栏固定高度随内容增长 */
.kb-chat { flex: 1 1 auto; display: flex; flex-direction: column; min-height: 0; }

/* 未选择知识库：居中提示 */
.kb-pick {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; padding: 48px 16px; text-align: center; color: var(--c-text-muted);
}
.kb-ph-icon { font-size: 32px; line-height: 1; }
.kb-ph-title { margin: 10px 0 0; font-size: 15px; font-weight: 600; color: var(--c-text); }
.kb-ph-sub { margin: 0; font-size: 13px; }

/* 消息列表：可滚动，气泡纵向排布；min-height:0 保证可收缩而不撑破卡片 */
.kb-messages {
  flex: 1 1 auto; min-height: 0; overflow-y: auto; padding: 20px;
  display: flex; flex-direction: column; gap: 14px; background: var(--c-card);
}
/* 纵向排列：气泡、引用来源、时间行依次向下堆叠。
   原来是横向 flex，后来追加到 .kb-msg 上的来源区会挤在气泡右侧，与时间行一起被压扁。 */
.kb-msg { display: flex; flex-direction: column; }
.kb-msg.user { align-items: flex-end; }
.kb-msg.bot { align-items: flex-start; }
.kb-bubble {
  /* 气泡占比放宽到 88%：对话框加宽后长回答不再被挤压，也不会与来源区相互遮挡 */
  max-width: 88%; padding: 10px 14px; border-radius: 12px; font-size: 14px; line-height: 1.7;
  white-space: pre-wrap; word-break: break-word;
}
.kb-msg.user .kb-bubble { background: var(--c-primary); color: #fff; border-bottom-right-radius: 3px; }
.kb-msg.bot .kb-bubble { background: #f1f5f9; color: var(--c-text); border-bottom-left-radius: 3px; }

/* 提问 / 回答时间：弱化，不与正文抢视觉；无时间时不占位 */
.kb-time { margin-top: 4px; font-size: 11px; color: #9aa3b2; }
.kb-time:empty { display: none; }

/* 引用来源：文档名为链接，一键打开原文 */
.kb-sources { margin-top: 8px; padding-top: 8px; border-top: 1px dashed var(--c-border); }
.kb-sources-title { font-size: 12px; font-weight: 600; color: var(--c-text-muted); margin-bottom: 4px; }
.kb-source {
  display: flex; align-items: baseline; gap: 6px; flex-wrap: wrap;
  font-size: 12px; color: var(--c-text-muted); line-height: 1.6;
}
.kb-source-link {
  display: inline-flex; align-items: baseline; gap: 4px; max-width: 100%;
  color: var(--c-primary); font-weight: 600; text-decoration: none; word-break: break-all;
}
.kb-source-link:hover { text-decoration: underline; }
.kb-source-icon { font-size: 11px; }

/* 输入栏 */
.kb-inputbar {
  flex: 0 0 auto; display: flex; gap: 10px; align-items: flex-end;
  padding: 12px 14px; border-top: 1px solid var(--c-border); background: #fafbfc;
}
.kb-inputbar textarea {
  flex: 1; resize: none; min-height: 38px; max-height: 160px; padding: 9px 12px;
  border: 1px solid var(--c-border); border-radius: 8px; background: #fff; color: var(--c-text);
  font-size: 14px; font-family: inherit; line-height: 1.5;
}
.kb-inputbar textarea:focus {
  outline: none; border-color: var(--c-primary); box-shadow: 0 0 0 3px rgba(37, 99, 235, .12);
}
.kb-inputbar .btn { height: 38px; }
/* 清空历史：与「发送」同排、同高、同一套 .btn 样式，仅文案较长需禁换行 */
.kb-inputbar #kb-clear { white-space: nowrap; }

/* 知识库管理（/kb-admin.html）：上传结果回执与说明列表 */
.kb-upload-result {
  margin-top: 16px; padding: 12px 14px; border-radius: 8px;
  border: 1px solid var(--c-border); font-size: 13px; line-height: 1.7;
}
.kb-upload-result-title { font-weight: 600; margin-bottom: 4px; }
.kb-upload-result ul { margin: 0; padding-left: 18px; }
.kb-upload-result.is-ok { background: #f0fdf4; border-color: #bbf7d0; color: #166534; }
.kb-upload-result.is-err { background: #fef2f2; border-color: #fecaca; color: #991b1b; }
.kb-upload-notes { margin: 0; padding-left: 18px; font-size: 13px; line-height: 1.9; color: var(--c-text-muted); }
.kb-upload-strong { color: var(--c-text); font-weight: 600; }

/* 窄屏：压缩留白、放大气泡占比，保证小屏下同样不重叠、不溢出 */
@media (max-width: 720px) {
  .kb-chat-card { min-height: 300px; }
  .kb-chat-head { flex-wrap: wrap; }
  .kb-messages { padding: 14px; gap: 10px; }
  .kb-bubble { max-width: 92%; }
  .kb-inputbar { padding: 10px; }
}

/* 打字中动画 */
.kb-typing { display: inline-flex; gap: 4px; align-items: center; }
.kb-typing span {
  width: 6px; height: 6px; border-radius: 50%; background: var(--c-text-muted);
  opacity: .4; animation: kb-blink 1.2s infinite;
}
.kb-typing span:nth-child(2) { animation-delay: .2s; }
.kb-typing span:nth-child(3) { animation-delay: .4s; }
/* 等待超过 15s 时附在打字动画后的说明文案（覆盖圆点样式） */
.kb-typing .kb-slow-hint {
  width: auto; height: auto; margin-left: 8px; border-radius: 0;
  background: none; opacity: 1; animation: none;
  font-size: 12px; color: var(--c-text-muted);
}
@keyframes kb-blink { 0%, 80%, 100% { opacity: .3; } 40% { opacity: 1; } }

/* ---------- 知识检索：右侧常驻悬浮入口 + 抽屉对话框 ---------- */
/* 侧边栏已不再提供「知识检索」菜单，改由页面右下角常驻的机器人按钮打开抽屉 */
.kb-fab {
  position: fixed; right: 24px; bottom: 28px; z-index: 40;
  display: flex; align-items: center; justify-content: center;
  width: 52px; height: 52px; padding: 0; border: none; border-radius: 50%;
  background: var(--c-primary); color: #fff; cursor: pointer;
  box-shadow: 0 8px 24px rgba(37, 99, 235, .35);
  transition: transform .16s ease, box-shadow .16s ease, background .16s ease, opacity .16s ease;
}
.kb-fab:hover { transform: translateY(-2px); box-shadow: 0 12px 28px rgba(37, 99, 235, .42); }
.kb-fab.active { background: var(--c-primary-dark); }
.kb-fab svg { width: 26px; height: 26px; }
/* 聊天抽屉展开时隐藏机器人按钮，收起后恢复（收起入口由抽屉内「收起」按钮承担）。
   用 opacity + pointer-events 而非 display:none，保留淡出过渡且不影响按钮已拖动的位置 */
.kb-fab--hidden { opacity: 0; pointer-events: none; }

/* 抽屉：宽度显著加大（默认 680px），消除原先窄对话框内的内容挤压与遮挡；
   top 从顶栏下沿开始，避免遮挡顶栏的铃铛与退出按钮 */
.kb-drawer {
  position: fixed; top: var(--topbar-h); right: 0; bottom: 0; z-index: 45;
  display: none; flex-direction: column;
  width: min(680px, 96vw);
  background: var(--c-card); border-left: 1px solid var(--c-border);
  box-shadow: -8px 0 28px rgba(16, 24, 40, .16);
}
.kb-drawer.open { display: flex; }
.kb-drawer-body {
  flex: 1 1 auto; display: flex; flex-direction: column; min-height: 0;
  padding: 14px 16px 16px;
}
.kb-load-fail { padding: 24px; color: var(--c-danger); font-size: 13px; }

/* 面板骨架：头部固定、聊天区撑满剩余高度并可滚动（min-height:0 保证可收缩而非撑破抽屉） */
.kb-panel { display: flex; flex-direction: column; flex: 1 1 auto; min-height: 0; gap: var(--space-3); }
.kb-panel-head {
  flex: 0 0 auto; display: flex; align-items: center; gap: var(--space-3); flex-wrap: wrap;
}
.kb-panel-title { font-size: 15px; font-weight: 700; color: var(--c-text); }
.kb-panel-close {
  margin-left: auto; width: 28px; height: 28px; padding: 0;
  border: 1px solid var(--c-border); border-radius: var(--radius-sm);
  background: var(--c-card); color: var(--c-text-muted); cursor: pointer;
  font-size: 16px; line-height: 1;
}
.kb-panel-close:hover { color: var(--c-primary); border-color: var(--c-primary); }

@media (max-width: 720px) {
  .kb-fab { right: 16px; bottom: 18px; width: 46px; height: 46px; }
  .kb-drawer { width: 100vw; }
}

/* 拖动定位：由 common.js 写入 left/top 并持久化到 localStorage。
   touch-action:none 让触摸拖动不会被页面滚动/缩放抢走；
   .kb-fab--free 解除默认 right/bottom 锚定（放在媒体查询之后，确保覆盖其中的 right/bottom）。 */
.kb-fab { touch-action: none; -webkit-user-select: none; user-select: none; }
.kb-fab.kb-fab--free { right: auto; bottom: auto; }
.kb-fab--dragging { transition: none; cursor: grabbing; }
.kb-fab--dragging:hover { transform: none; box-shadow: 0 12px 28px rgba(37, 99, 235, .42); }

/* ---------- 卡片 ---------- */
.card {
  background: var(--c-card);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 18px;
  transition: box-shadow .18s ease, transform .18s ease;
}
/* 纵向堆叠的卡片之间补 16px 间距（页面主容器的直接相邻卡片） */
.card + .card { margin-top: 16px; }
.card-title { margin: 0 0 14px; font-size: 15px; font-weight: 600; }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
/* 网格内卡片一律取消上外边距：间距已由 .grid 的 gap 提供。
   否则 .card + .card 会给同排第 2 张起的卡片加 16px 上外边距——
   网格行高按最高项的外框计算，带外边距的卡片高度 = 行高 - 16px，
   于是「每个分区的第一张卡片都比同分区其他卡片高 16px」（必须放在 .card + .card 之后才能覆盖）。 */
.grid > .card { margin-top: 0; }
/* 中等宽度先降为 2 列，避免 4 个 KPI 在 960–1180px 区间被挤成窄条 */
@media (max-width: 1180px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 960px) {
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
}

/* ---------- KPI ---------- */
.kpi { display: flex; flex-direction: column; gap: 2px; }
.kpi .label { color: var(--c-text-muted); font-size: 13px; }
.kpi .value { font-size: 26px; font-weight: 650; letter-spacing: -0.5px; }
.kpi .hint { font-size: 12px; color: var(--c-text-muted); }

/* ---------- 表格 ---------- */
/* 侧边栏展开时表格随主内容区自适应收缩：固定布局 + 单元格省略号，
   保证整表不超出可视宽度、不出现左右滚动（极窄屏再由 .table-wrap 兜底滚动） */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; table-layout: fixed; }
table.data th, table.data td {
  padding: 8px 10px;
  text-align: left;
  border-bottom: 1px solid var(--c-border);
  font-size: 13px;
  /* 次要信息超出即省略号，避免长文本把列撑宽 */
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
table.data th {
  background: #fafbfc;
  color: var(--c-text-muted);
  font-weight: 600;
  font-size: 13px;
  position: sticky;
  top: 0;
  /* 表头允许换行：长表头（如「最近一次生效日」）在窄列宽下完整展示而非被省略号截断；
     数据单元格 td 仍保持 nowrap + 省略号（配合 title 悬浮看全文），二者互不影响 */
  white-space: normal;
  vertical-align: middle;
}
table.data tbody tr:hover { background: #f9fafb; }
table.data td.ellipsis { max-width: 220px; overflow: hidden; text-overflow: ellipsis; }

/* ---------- 自适应列宽表 ----------
   两类用法，目标一致：信息在页面内完整可见，不出现左右滑动。

   ① .tbl-fixed（保单列表 / 保单回收站）
      固定布局 + 逐列定宽：定长字段（日期 / 保单号 / 时间）给死 px，长文本列（姓名 / 险种）
      不给宽度、共享剩余空间并自动换行。表格总宽恒等于容器宽度，**不会因为内容变长而撑宽**，
      所以正常宽度下不可能出现横向滚动；只有屏幕窄到小于 min-width 时才由 .table-wrap 兜底滚动。

   ② .tbl-fit（登录用户管理等列多但内容短的列表）
      自动布局 + 全列允许换行（break-word 只在必要时断词），由浏览器把列压进容器。 */
table.data.tbl-fixed { table-layout: fixed; width: 100%; }
table.data.tbl-fixed th, table.data.tbl-fixed td {
  padding-left: 7px; padding-right: 7px;
  white-space: normal; word-break: break-word;
  overflow: hidden; text-overflow: ellipsis;
}
/* 表头不折行会被省略号截断（「保单受理日期」「最近一次生效日」正是这样丢字）：
   允许折行 + 收紧行高，定宽列里折成两行也要把完整文字显示出来 */
table.data.tbl-fixed th { line-height: 1.35; }
/* 定长字段不折行：日期 / 保单号 / 时间 / 剩余天数被拆成两行会严重影响阅读 */
table.data.tbl-fixed th.nowrap, table.data.tbl-fixed td.nowrap,
table.data.tbl-fixed th.col-time, table.data.tbl-fixed td.col-time,
table.data.tbl-fixed th.col-remain, table.data.tbl-fixed td.col-remain { white-space: nowrap; }
/* 列宽：只给「内容长度可预期」的列定宽，其余（姓名 / 险种）自动分配剩余宽度。
   宽度按 13px 字体的实测字宽反推：日期 "2027-02-28" ≈ 70px、12 位保单号 ≈ 86px、
   三个图标按钮 ≈ 96px，再各留 14px 内边距与少量余量，保证不出现省略号。

   勾选列 100px / 操作列 120px 为 2026-11-23 浏览器实测值（量 clientWidth 与 scrollWidth）：
   - 勾选列内容 = 复选框 13 + 间距 8 +「全选本单」49 + 内边距 14 ≈ 95px。
     上一版写 92px，溢出 3px 后被 text-overflow 削成「…」（表现为「按钮消失了」）；
   - 操作列内容 = 3 枚 28px 图标 + 2×6 间距 + 内边距 14 = 110px，原 126px 富余 16px，
     收窄到 120px 仍不裁切；省下的宽度还给姓名 / 险种列，避免「修勾选列、挤文本列」。 */
table.data.tbl-fixed th.col-check, table.data.tbl-fixed td.col-check { width: 100px; }
table.data.tbl-fixed th.col-status, table.data.tbl-fixed td.col-status { width: 72px; text-align: center; }
table.data.tbl-fixed th.col-act, table.data.tbl-fixed td.col-act { width: 120px; }
table.data.tbl-fixed th[data-col="seq_no"], table.data.tbl-fixed td[data-col="seq_no"] { width: 52px; }
table.data.tbl-fixed th[data-col="sign_date"], table.data.tbl-fixed td[data-col="sign_date"] { width: 96px; }
table.data.tbl-fixed th[data-col="policy_no"], table.data.tbl-fixed td[data-col="policy_no"] { width: 108px; }
table.data.tbl-fixed th[data-col="last_effective_date"], table.data.tbl-fixed td[data-col="last_effective_date"] { width: 96px; }
table.data.tbl-fixed th[data-col="expire_date"], table.data.tbl-fixed td[data-col="expire_date"] { width: 94px; }
/* 回收站固定列 */
table.data.tbl-fixed th[data-col="trash_no"], table.data.tbl-fixed td[data-col="trash_no"] { width: 104px; }
table.data.tbl-fixed th[data-col="trash_type"], table.data.tbl-fixed td[data-col="trash_type"] { width: 64px; }
table.data.tbl-fixed th[data-col="trash_deleted_at"], table.data.tbl-fixed td[data-col="trash_deleted_at"] { width: 132px; }
table.data.tbl-fixed th[data-col="trash_by"], table.data.tbl-fixed td[data-col="trash_by"] { width: 88px; }
table.data.tbl-fixed th[data-col="trash_remain"], table.data.tbl-fixed td[data-col="trash_remain"] { width: 128px; }

table.data.tbl-fit { table-layout: auto; width: 100%; }
table.data.tbl-fit th, table.data.tbl-fit td { padding-left: 7px; padding-right: 7px; white-space: normal; word-break: break-word; }
table.data.tbl-fit th.nowrap, table.data.tbl-fit td.nowrap { white-space: nowrap; }
table.data.tbl-fit th.col-status, table.data.tbl-fit td.col-status { width: 76px; text-align: center; }
table.data.tbl-fit th.col-act, table.data.tbl-fit td.col-act { width: 118px; }

/* 联系电话：固定列宽 + 不换行，保证 11 位号码（含脱敏星号）整列完整展示、不被截断 */
table.data th.cell-phone, table.data td.cell-phone { width: 132px; white-space: nowrap; }
/* 保单列表里可点击的客户姓名（投保人 / 被保险人）：点开是客户信息弹窗，不是页面跳转 */
table.data a.cust-link { color: var(--c-primary); text-decoration: none; border-bottom: 1px dashed transparent; }
table.data a.cust-link:hover { border-bottom-color: var(--c-primary); }

/* ---------- 按钮 ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 34px; padding: 0 14px;
  border: 1px solid var(--c-border);
  border-radius: 6px;
  background: var(--c-card);
  color: var(--c-text);
  font-size: 13px;
  cursor: pointer;
  transition: all .15s;
}
.btn:hover { background: #f3f4f6; }
.btn-primary { background: var(--c-primary); border-color: var(--c-primary); color: #fff; }
.btn-primary:hover { background: var(--c-primary-dark); }
.btn-danger { color: var(--c-danger); border-color: #fecaca; }
.btn-danger:hover { background: #fef2f2; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-sm { height: 28px; padding: 0 10px; font-size: 12px; }

/* ---------- 操作列图标按钮 ---------- */
/* 固定 28×28 的正方形图标按钮：三枚并排也只占约 96px，操作列不再撑宽表格，
   任何分辨率下均完整可见，不会出现横向滚动或按钮被截断。 */
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 28px; height: 28px; padding: 0;
  border: 1px solid var(--c-border); border-radius: var(--radius-sm);
  background: var(--c-card); color: var(--c-text-muted); cursor: pointer;
  transition: color .15s, background .15s, border-color .15s;
}
.icon-btn:hover { color: var(--c-primary); border-color: var(--c-primary); background: var(--c-primary-light); }
/* 删除：警示色，hover 时反白强化危险语义 */
.icon-btn-danger { color: var(--c-danger); border-color: #fecaca; }
.icon-btn-danger:hover { color: #fff; background: var(--c-danger); border-color: var(--c-danger); }
/* 便签：该客户已填写便签时按钮保持主色，无需悬浮即可看出哪些客户有备注 */
.icon-btn-has-note { color: var(--c-primary); border-color: #bfdbfe; background: var(--c-primary-light); }
.icon-btn-has-note:hover { border-color: var(--c-primary); }
/* 冻结：琥珀色，与列表「已冻结」徽章 .st-frozen 同色系，形成「状态→操作」的视觉呼应。
   刻意区别于 .icon-btn-danger 的红色——冻结是可恢复的停用，删除才是不可恢复的终态。 */
.icon-btn-warn { color: #b45309; border-color: #fde68a; }
.icon-btn-warn:hover { color: #fff; background: #d97706; border-color: #d97706; }

/* ---------- 操作反馈提示（替代原生 alert） ----------
   顶部居中浮现、自动淡出。z-index 高于 openConfirm 的 200，
   保证「确认弹窗关闭后紧接着提示结果」时提示一定在最上层可见。 */
.app-toast {
  position: fixed; top: 24px; left: 50%; z-index: 300;
  max-width: min(560px, calc(100vw - 32px));
  padding: 10px 18px; border-radius: 8px;
  background: #0f172a; color: #fff;
  font-size: 13px; line-height: 1.6;
  box-shadow: 0 10px 30px rgba(15, 23, 42, .3);
  /* 初始态：略微上移且透明；挂上 .show 后落位淡入 */
  opacity: 0; transform: translate(-50%, -12px);
  transition: opacity .22s ease, transform .22s ease;
  cursor: pointer;
}
.app-toast.show { opacity: 1; transform: translate(-50%, 0); }
.app-toast-error { background: #b91c1c; }

/* ---------- 客户便签：行悬浮浮层（真实便签质感）+ 弹窗编辑 ---------- */
/* 浮层用 position:fixed + getBoundingClientRect 视口坐标定位，页面滚动不影响；
   始终落在触发行的上方或下方（不覆盖行内列与操作按钮），并夹紧在视口内。 */
.note-pop {
  position: fixed; z-index: 60; display: none;
  width: 300px; max-width: calc(100vw - 24px);
  /* 顶部留出图钉的位置，正文不被图钉钉住 */
  padding: 18px 16px 12px;
  /* 便签纸：暖黄底 + 顶部微高光，叠一层极淡横格线做纸张质感 */
  background-color: #fdf3c0;
  background-image:
    linear-gradient(180deg, rgba(255, 255, 255, .5), rgba(255, 255, 255, 0) 46px),
    repeating-linear-gradient(180deg, rgba(146, 120, 52, 0) 0 27px, rgba(146, 120, 52, .075) 27px 28px);
  border: 1px solid #f0dfa4;
  /* 四角圆角刻意不一致，配合轻微倾斜褪掉「系统弹窗」的规整感 */
  border-radius: 3px 12px 5px 11px;
  transform: rotate(-1.4deg);
  box-shadow: 0 10px 22px rgba(97, 74, 21, .2), 0 2px 4px rgba(97, 74, 21, .12);
  /* 手写感：优先中文楷体，未安装时退回系统手写体 */
  font-family: "Kaiti SC", "STKaiti", "Hanzipen SC", KaiTi, "楷体", "Segoe Print", cursive;
  font-size: 14px; line-height: 1.7; color: #4a3c17;
}
.note-pop.show { display: block; }
/* 图钉：钉在便签顶部正中。钉头（::before）+ 钉针（::after）两层，
   跟着便签一起微微倾斜，避免看起来像规整的系统弹窗。 */
.note-pop::before {
  content: ''; position: absolute; top: -8px; left: 50%;
  width: 18px; height: 18px; margin-left: -9px;
  border-radius: 50%;
  background: radial-gradient(circle at 34% 30%, #fca5a5 0%, #ef4444 45%, #b91c1c 100%);
  box-shadow: 0 2px 5px rgba(120, 20, 20, .38), inset 0 -2px 3px rgba(0, 0, 0, .18);
}
.note-pop::after {
  content: ''; position: absolute; top: 8px; left: 50%;
  width: 2px; height: 7px; margin-left: -1px;
  border-radius: 0 0 1px 1px;
  background: linear-gradient(180deg, #991b1b, #b91c1c);
}
/* 时间行：该条便签自己的日期时间，与正文一起构成完整的一条记录 */
.note-pop-time {
  margin-bottom: 4px; padding-bottom: 4px;
  border-bottom: 1px dashed rgba(146, 120, 52, .35);
  font-size: 12px; color: #8a6d24;
}
.note-pop-time:empty, .note-pop-time.hidden { display: none; }
/* 长文本：正文区限高约 6 行后内部滚动（浮层可接收指针，鼠标移入即可滚动） */
.note-pop-body {
  max-height: 176px; overflow-y: auto;
  white-space: pre-wrap; word-break: break-word;
}

/* ---------- 便签弹窗：左「新增便签」/ 右「便签历史」时间轴 ---------- */
/* 两栏等宽，中间用一条分隔线划开；窄屏退化为上下堆叠 */
.note-modal { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 20px; }
.note-col { min-width: 0; }
.note-col-history { border-left: 1px solid var(--c-border); padding-left: 20px; }
/* 小标题沿用客户表单分组标题的样式，保证弹窗内外的视觉语言一致 */
.note-col-title {
  margin: 0 0 12px; padding-left: 8px;
  border-left: 3px solid var(--c-primary);
  font-size: 14px; font-weight: 600;
}
/* 待录入的一行：日期时间 + 正文 + 移除（输入框样式与列表表单完全同一套） */
.note-row {
  display: grid; grid-template-columns: 168px minmax(0, 1fr) 28px;
  gap: 8px; align-items: start; margin-bottom: 10px;
}
.note-row-time, .note-row-text {
  width: 100%; padding: 6px 10px;
  border: 1px solid var(--c-border); border-radius: 6px;
  background: #fff; color: var(--c-text);
  font: inherit; font-size: 13px;
}
.note-row-time { height: 34px; }
.note-row-text { resize: vertical; line-height: 1.6; }
.note-row-time:focus, .note-row-text:focus {
  outline: none;
  border-color: var(--c-primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, .12);
}
/* 编辑态（便签历史里点「编辑」后复用同一输入行）：操作区有「取消 / 保存」两枚按钮，
   历史列比新增列窄，故改为单列堆叠 —— 时间在上一行、正文在下一行、按钮右对齐 */
.note-row.is-edit { grid-template-columns: minmax(0, 1fr); }
.note-row.is-edit .note-row-time { width: 100%; }
.note-row-ops { display: flex; align-items: center; justify-content: flex-end; gap: 6px; }
.note-row-del { font-size: 16px; line-height: 1; }
.note-add-row { font-size: 13px; }
.note-msg { margin: 8px 0 0; font-size: 12px; }
.note-msg:empty { display: none; }
.note-msg.is-ok { color: #166534; }
.note-msg.is-err { color: var(--c-danger); }

/* 时间轴：竖线串起节点，整体按时间倒序，最新一条在最上方 */
.note-timeline { max-height: 340px; overflow-y: auto; }
.note-tl-item { position: relative; padding: 0 0 16px 18px; }
/* 竖线画在节点左侧并延伸到下一个节点；最后一个节点不再向下延伸 */
.note-tl-item::before {
  content: ''; position: absolute; left: 4px; top: 6px; bottom: -4px;
  border-left: 1px solid var(--c-border);
}
.note-tl-item:last-child::before { display: none; }
.note-tl-dot {
  position: absolute; left: 0; top: 5px;
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--c-primary); box-shadow: 0 0 0 3px rgba(37, 99, 235, .15);
}
/* 时间行：时间靠左，编辑 / 删除入口常驻在右侧（与列表操作列同一套 .icon-btn） */
.note-tl-head { display: flex; align-items: center; gap: 8px; }
.note-tl-time { font-size: 12px; color: var(--c-text-muted); }
.note-tl-ops { margin-left: auto; display: flex; gap: 6px; }
.note-tl-ops .icon-btn { width: 24px; height: 24px; }
.note-tl-text {
  margin-top: 2px; font-size: 13px; line-height: 1.7;
  white-space: pre-wrap; word-break: break-word;
}
/* 超长正文：默认收起到 4 行，底部渐隐暗示还有内容，点「展开」看全文 */
.note-tl-text.is-clamped {
  max-height: 6.8em; overflow: hidden;
  -webkit-mask-image: linear-gradient(180deg, #000 60%, transparent);
          mask-image: linear-gradient(180deg, #000 60%, transparent);
}
.note-tl-more {
  margin-top: 2px; padding: 0; border: none; background: none;
  color: var(--c-primary); font-size: 12px; cursor: pointer;
}
.note-tl-more:hover { text-decoration: underline; }
/* 删除二次确认气泡：就地挂在该条下方，不另开弹窗（免得把便签弹窗顶掉） */
.note-confirm {
  margin-top: 8px; padding: 8px 10px;
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  border: 1px solid #fecaca; border-radius: var(--radius-sm);
  background: #fef2f2; color: var(--c-danger); font-size: 12px;
}
.note-confirm .btn-danger { border-color: var(--c-danger); background: var(--c-danger); color: #fff; }
.note-confirm .btn-danger:hover { background: #b91c1c; border-color: #b91c1c; color: #fff; }
.note-tl-empty { margin: 0; font-size: 13px; color: var(--c-text-muted); }
@media (max-width: 720px) {
  .note-modal { grid-template-columns: 1fr; }
  .note-col-history { border-left: none; padding-left: 0; }
}

/* ---------- 批量操作按钮：续保=主操作实心蓝 / 中止=琥珀描边浅底 / 终止=实心红 ---------- */
.btn-renew {
  background: var(--c-primary); border-color: var(--c-primary); color: #fff; font-weight: 600;
  box-shadow: 0 1px 2px rgba(37, 99, 235, .22);
}
.btn-renew:hover:not(:disabled) {
  background: var(--c-primary-dark); border-color: var(--c-primary-dark);
  box-shadow: 0 2px 6px rgba(37, 99, 235, .28);
}
.btn-suspend {
  background: #fffbeb; border-color: #fcd34d; color: #92400e; font-weight: 600;
}
.btn-suspend:hover:not(:disabled) { background: #fef3c7; border-color: #f59e0b; color: #78350f; }
.btn-terminate {
  background: var(--c-danger); border-color: var(--c-danger); color: #fff; font-weight: 600;
  box-shadow: 0 1px 2px rgba(220, 38, 38, .22);
}
.btn-terminate:hover:not(:disabled) {
  background: #b91c1c; border-color: #b91c1c;
  box-shadow: 0 2px 6px rgba(220, 38, 38, .28);
}
/* 禁用态统一压暗并取消 hover 抬升 */
.btn:disabled,
.btn:disabled:hover { opacity: .5; cursor: not-allowed; box-shadow: none; }

/* ---------- 表单 ---------- */
.field { margin-bottom: 14px; }
.field label { display: block; margin-bottom: 5px; font-size: 13px; color: var(--c-text-muted); }
.field label .req { color: var(--c-danger); margin-left: 2px; }
.field input, .field select, .field textarea {
  width: 100%;
  height: 34px;
  padding: 0 10px;
  border: 1px solid var(--c-border);
  border-radius: 6px;
  background: #fff;
  color: var(--c-text);
  font-size: 13px;
  font-family: inherit;
}
.field textarea { height: auto; padding: 8px 10px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none;
  border-color: var(--c-primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, .12);
}
/* 系统生成的字段（序号、年龄）只读：灰底 + 禁用光标，明确不可手工填写 */
.field input[readonly] { background: #f1f5f9; color: var(--c-text-muted); cursor: not-allowed; }
.field .err { display: none; margin-top: 4px; font-size: 12px; color: var(--c-danger); }
.field.invalid input, .field.invalid select, .field.invalid textarea { border-color: var(--c-danger); }
.field.invalid .err { display: block; }
/* 提示而非报错：身份证号解析不出年龄时用琥珀色中性文案，不标红、不阻断保存 */
.field .err.is-hint { display: block; color: #92400e; }
/* 日期控件右侧的「长期」复选框：与输入框同行，不额外占一行高度 */
.chk-inline {
  display: inline-flex; align-items: center; gap: 4px;
  margin-left: 8px; font-size: 12px; color: var(--c-text-muted);
  cursor: pointer; user-select: none;
}
.chk-inline input { width: 14px; height: 14px; margin: 0; cursor: pointer; }
.field input:disabled { background: #f1f5f9; color: var(--c-text-muted); cursor: not-allowed; }
/* 客户来源的二级分类下拉：选中一级「陌生开拓」后动态出现，与一级上下相邻 */
.field .src-sub { margin-top: 6px; }
/* 固定取值字段的单选框组（如性别：男 / 女）：与输入框等高，避免表单网格错位 */
.radio-row { display: flex; align-items: center; gap: 18px; min-height: 34px; }
.radio-inline {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 13px; color: var(--c-text); cursor: pointer; user-select: none;
}
.radio-inline input { width: 14px; height: 14px; margin: 0; cursor: pointer; }
/* 多值字段（如「健康告知 / 体检异常」）的复选框组：允许折行，与单选框组同高 */
.check-row { display: flex; flex-wrap: wrap; gap: 10px 18px; align-items: center; min-height: 34px; }
.check-row .chk-inline { margin-left: 0; }
/* 保单附险行的「随主险」只读镜像字段：灰底不可编辑，明确不可单独修改 */
.addon-inherit { margin-top: 6px; font-size: 12px; color: var(--c-text-muted); }
.addon-inherit-field { grid-column: 1 / -1; }

.toolbar {
  display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; margin-bottom: 16px;
}
.toolbar .field { margin-bottom: 0; min-width: 150px; }
.toolbar .grow { flex: 1; min-width: 220px; }
/* 区间筛选（签单日期 / 年龄段）：起止两个输入同行，中间以「至」分隔 */
.toolbar .range-field { min-width: 268px; }
.range-inputs { display: flex; align-items: center; gap: 6px; }
.range-inputs input { flex: 1 1 0; min-width: 0; }
.range-sep { flex: 0 0 auto; font-size: 13px; color: var(--c-text-muted); }
.range-inputs select {
  flex: 0 0 116px; height: 34px; padding: 0 8px;
  border: 1px solid var(--c-border); border-radius: 6px;
  background: #fff; color: var(--c-text); font-size: 13px; font-family: inherit;
}
/* 年龄段：预设下拉 + 最小 / 最大输入需要更宽的横向空间 */
.toolbar .age-field { min-width: 340px; }
.age-field input[type="number"] { flex: 1 1 0; min-width: 64px; }

/* ---------- 分页 ---------- */
.pagination {
  display: flex; align-items: center; justify-content: space-between;
  margin-top: 16px; color: var(--c-text-muted); font-size: 13px;
}
.pagination .pages { display: flex; gap: 6px; }
.pagination button {
  min-width: 32px; height: 32px; padding: 0 8px;
  border: 1px solid var(--c-border); border-radius: 6px;
  background: #fff; color: var(--c-text); cursor: pointer; font-size: 13px;
}
.pagination button.active { background: var(--c-primary); border-color: var(--c-primary); color: #fff; }
.pagination button:disabled { opacity: .5; cursor: not-allowed; }

/* ---------- 弹窗 ---------- */
.modal-mask {
  position: fixed; inset: 0;
  background: rgba(17, 24, 39, .45);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 40px 16px;
  overflow-y: auto;
  z-index: 50;
}
.modal {
  width: 100%; max-width: 880px;
  background: var(--c-card);
  border-radius: 10px;
  box-shadow: var(--shadow-lg);
}
/* 宽弹窗：列数多、含定宽列的表格（如保单回收站）用它，避免列被压成竖条 */
.modal.modal-wide { max-width: 1200px; }
.modal header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; border-bottom: 1px solid var(--c-border);
}
.modal header h3 { margin: 0; font-size: 16px; }
.modal .body { padding: 20px; max-height: 62vh; overflow-y: auto; }
.modal footer {
  display: flex; justify-content: flex-end; gap: 10px;
  padding: 14px 20px; border-top: 1px solid var(--c-border);
}
.close-btn {
  border: none; background: none; font-size: 20px; line-height: 1;
  color: var(--c-text-muted); cursor: pointer;
}
.form-section { margin-bottom: 8px; }
.form-section h4 {
  margin: 18px 0 12px; padding-left: 8px;
  border-left: 3px solid var(--c-primary);
  font-size: 14px; font-weight: 600;
}
.form-section:first-child h4 { margin-top: 0; }
.form-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0 16px; }
@media (max-width: 720px) { .form-grid { grid-template-columns: 1fr; } }

/* ---------- 详情 ---------- */
.detail-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px 16px; }
@media (max-width: 720px) { .detail-grid { grid-template-columns: 1fr; } }
.detail-item { min-width: 0; }
.detail-item .k { font-size: 12px; color: var(--c-text-muted); }
.detail-item .v { font-size: 13px; word-break: break-all; }

/* ---------- 登录页 ---------- */
.login-page {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #eef2ff 0%, #f8fafc 100%);
}
.login-box {
  width: 100%; max-width: 380px;
  background: var(--c-card);
  border: 1px solid var(--c-border);
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  padding: 32px;
}
.login-box h1 { margin: 0 0 6px; font-size: 20px; }
.login-box .sub { margin: 0 0 24px; color: var(--c-text-muted); font-size: 13px; }
/* 品牌区：logo 置于平台名左侧。与下方副标题、表单同为左对齐，保持原有版式节奏 */
.login-brand {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 8px;
}
.login-brand h1 { margin: 0; font-size: 20px; line-height: 1.3; }
.login-brand-logo {
  flex: 0 0 auto; display: block; width: 36px; height: 36px;
  object-fit: contain;
}
.login-box .btn-primary { width: 100%; height: 38px; margin-top: 8px; }
/* 登录 / 注册面板切换入口 */
.login-box .switch-line { margin: 14px 0 0; text-align: center; font-size: 13px; color: var(--c-text-muted); }
.login-box .switch-line a { color: var(--c-primary); text-decoration: none; }
.login-box .switch-line a:hover { text-decoration: underline; }
.login-box .hint { margin: 4px 0 0; font-size: 12px; line-height: 1.6; color: var(--c-text-muted); }
.login-tip { margin-top: 16px; font-size: 12px; color: var(--c-text-muted); text-align: center; }

/* ---------- 提示 ---------- */
.alert {
  padding: 10px 12px; border-radius: 6px; font-size: 13px; margin-bottom: 14px;
}
.alert-error { background: #fef2f2; color: var(--c-danger); border: 1px solid #fecaca; }
.alert-success { background: #f0fdf4; color: var(--c-success); border: 1px solid #bbf7d0; }
.empty { padding: 48px 0; text-align: center; color: var(--c-text-muted); }
/* 列表中的密码脱敏展示 */
.masked {
  letter-spacing: 2px;
  color: var(--c-text-muted);
  user-select: none;
}
.tag {
  display: inline-block; padding: 1px 8px; border-radius: 10px;
  background: var(--c-primary-light); color: var(--c-primary); font-size: 12px;
}
/* 积分规则：启用 / 停用 / 内置 三态标签 */
.tag-on { background: #f0fdf4; color: var(--c-success); }
.tag-off { background: #f3f4f6; color: var(--c-text-muted); }
.tag-builtin { background: #fffbeb; color: var(--c-warning); }
/* 数值列：右对齐 + 等宽数字，避免积分列宽度跳动 */
table.data td.num, table.data th.num { text-align: right; font-variant-numeric: tabular-nums; }
/* 分页信息区的错误态（列表加载失败时标红，3 秒后自动恢复） */
.pagination .is-error { color: var(--c-danger); font-weight: 600; }
.loading { padding: 40px; text-align: center; color: var(--c-text-muted); }
.hidden { display: none !important; }

/* ---------- 保单列表：主附险层级 ---------- */
/* 主 / 附险行用明显不同的底色区分：主险白底，附险蓝灰底并缩进 */
table.data tbody tr.main-row { background: #ffffff; }
table.data tbody tr.main-row:hover { background: #f9fafb; }
table.data tbody tr.child-row { background: #eef2f7; }
table.data tbody tr.child-row:hover { background: #e2e9f4; }
table.data tr.child-row td { color: var(--c-text-muted); font-size: 13px; }
table.data tr.child-row td.col-seq { padding-left: 34px; }
table.data th.col-seq, table.data td.col-seq { width: 56px; white-space: nowrap; }

/* 客户 / 潜客列表列宽（.tbl-people）：等比自适应方案。
   历史问题：全部列给定固定像素（合计约 1084~1114px），而 1280/1366 分辨率下表格可用宽度只有
   约 960~1048px（视口 - 侧栏 232 - 容器内边距 48 - 卡片内边距 38），于是整表溢出、
   必须左右拖动才能看到「操作」列。
   现方案：文本列改用百分比随主内容区缩放（长文本仍省略号 + title 悬浮看全文），
   勾选列 / 操作列给定固定像素（图标按钮不可压扁，压扁会裁掉按钮）。
   百分比合计 72.5% + 固定像素列（36 + 150/184）恒小于 100%，因此表格永远等于容器宽度——
   1920 不空旷（百分比随之变大），1280 不溢出。极窄屏（<1200）由下方媒体查询进一步压缩。 */
table.data.tbl-people th, table.data.tbl-people td { padding-left: 8px; padding-right: 8px; }
/* 勾选列只容纳一个复选框；不用保单列表的 .col-check（那里要放「全选本单」按钮，需 118px） */
table.data.tbl-people th.col-check, table.data.tbl-people td.col-check {
  width: 36px; padding-left: 0; padding-right: 0; text-align: center;
}
table.data.tbl-people th.col-name, table.data.tbl-people td.col-name { width: 13%; }
table.data.tbl-people th.cell-phone, table.data.tbl-people td.cell-phone { width: 11%; }
table.data.tbl-people th.col-gender, table.data.tbl-people td.col-gender { width: 4.5%; text-align: center; }
table.data.tbl-people th.col-age, table.data.tbl-people td.col-age { width: 4.5%; text-align: center; }
table.data.tbl-people th.col-cat, table.data.tbl-people td.col-cat { width: 10%; }
table.data.tbl-people th.col-src, table.data.tbl-people td.col-src { width: 10%; }
table.data.tbl-people th.col-family, table.data.tbl-people td.col-family { width: 10.5%; }
table.data.tbl-people th.col-date, table.data.tbl-people td.col-date { width: 9%; }
/* 操作列：4 枚 28px 图标按钮（4×28 + 3×6 间距 + 左右 8px 内边距 = 150px）/ 潜客 5 枚（184px），
   固定不随容器收缩——图标按钮被压扁会被 td 的 ellipsis 整枚裁掉（历史上「删除按钮不见了」） */
table.data.tbl-people th.col-act, table.data.tbl-people td.col-act { width: 150px; }
table.data.tbl-people th.col-act-leads, table.data.tbl-people td.col-act-leads { width: 184px; min-width: 0; }

/* 笔记本 / 小窗（1280 及以下）：百分比再收一档，操作列占比升高时仍不溢出 */
@media (max-width: 1200px) {
  table.data.tbl-people th.col-name, table.data.tbl-people td.col-name { width: 12%; }
  table.data.tbl-people th.cell-phone, table.data.tbl-people td.cell-phone { width: 10.5%; }
  table.data.tbl-people th.col-gender, table.data.tbl-people td.col-gender { width: 4%; }
  table.data.tbl-people th.col-age, table.data.tbl-people td.col-age { width: 4%; }
  table.data.tbl-people th.col-cat, table.data.tbl-people td.col-cat { width: 9%; }
  table.data.tbl-people th.col-src, table.data.tbl-people td.col-src { width: 9%; }
  table.data.tbl-people th.col-family, table.data.tbl-people td.col-family { width: 9.5%; }
  table.data.tbl-people th.col-date, table.data.tbl-people td.col-date { width: 8%; }
}

/* 中止 / 终止状态行：底色覆盖主附险底色，优先级高于 hover */
table.data tbody tr.row-suspended,
table.data tbody tr.row-suspended:hover { background: #fff7ed; }
table.data tbody tr.row-terminated,
table.data tbody tr.row-terminated:hover { background: #fef2f2; }
/* 终止记录加删除线；复选框列、状态徽标列与操作列不加，保证仍可点击与辨识 */
table.data tbody tr.row-terminated td:not(.col-check):not(.col-status):not(.col-act) {
  text-decoration: line-through;
  color: var(--c-text-muted);
}
/* 数据字典：已停用的字典项（enabled = false）。
   停用项仍出现在字典维护页（否则管理员找不到、也无法重新启用），但不会下发到业务下拉，
   故整行灰化 + 名称加删除线，与「启用中」的行明确区分（仿 row-terminated 的既有写法）。 */
table.data tbody tr.row-disabled,
table.data tbody tr.row-disabled:hover { background: #f8fafc; }
/* 排序列不加删除线：停用的字典项仍要能看到并修改它的排序权重 */
table.data tbody tr.row-disabled td:not(.col-enabled):not(.col-sort):not(.col-act) {
  color: var(--c-text-muted);
  text-decoration: line-through;
}
/* 排序权重输入：窄数字框，与 60px 序号列的视觉重量一致 */
table.data th.col-sort, table.data td.col-sort { width: 96px; text-align: center; }
table.data td.col-sort input.sort-input {
  width: 62px; height: 28px; padding: 0 6px; text-align: center;
  border: 1px solid var(--c-border); border-radius: 4px; font-size: 13px;
}
table.data th.col-enabled, table.data td.col-enabled { width: 110px; text-align: center; }

/* 158px = 4 枚 28px 图标按钮 + 3 个 6px 间距 + 单元格左右各 10px 内边距（客户列表含便签按钮） */
table.data th.col-act, table.data td.col-act { width: 158px; white-space: nowrap; text-align: right; }
/* 潜客列表操作列：比客户列表多「转为正式客户」一枚按钮，列宽相应加宽以容纳 5 枚图标按钮
   （28×5 + 4×6 间距 = 164px 内容 + 20px 内边距 ≈ 184px；min-width 兜底，按钮不折行、不截断） */
table.data th.col-act-leads, table.data td.col-act-leads { width: 188px; min-width: 160px; white-space: nowrap; text-align: right; }
table.data td.col-act .icon-btn + .icon-btn { margin-left: 6px; }
/* 操作列按钮组：交给 flex 排布。
   inline-flex 按钮写在多行模板里时，标签之间的换行会被渲染成约 3.7px 的空白，
   4 枚按钮累计多占约 11px，实测把最后一枚「删除」挤出 138px 的内容框而被裁切（"删除按钮不见了"）。
   包裹层用 gap 定间距，不再依赖标签间空白，因此增删按钮也不会重现该问题。
   注意：不能给 td 直接设 display:flex —— 实测会让单元格脱离表格布局、整列错位。 */
.act-btns { display: flex; align-items: center; justify-content: flex-end; gap: 6px; }
/* 图标按钮不参与收缩：列宽不足或小屏时若任由 flex 压缩，28px 的按钮会被压扁变形，
   最后一枚还会被 td 的 text-overflow: ellipsis 整枚裁掉（历史上「删除按钮不见了」正是这个原因）。
   固定不收缩后，宽度缺口交由 .table-wrap 的横向滚动兜底，保证按钮始终完整、可点。 */
.act-btns > .icon-btn { flex: 0 0 auto; }
/* 间距已由 gap 承担，取消上面那条「相邻按钮 6px 外边距」，避免 6 + 6 叠加 */
table.data td.col-act .act-btns > .icon-btn + .icon-btn { margin-left: 0; }
.expand-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 20px; height: 20px; margin-right: 6px; padding: 0;
  border: 1px solid var(--c-border); border-radius: 4px;
  background: var(--c-card); color: var(--c-text-muted);
  font-size: 10px; line-height: 1; vertical-align: middle; cursor: pointer;
  transition: transform 0.12s ease;
}
.expand-btn:hover { border-color: var(--c-primary); color: var(--c-primary); }
.expand-btn.open { transform: rotate(90deg); }
/* 无附险的主险：隐藏箭头但保留占位，保证序号列对齐 */
.expand-btn.leaf { visibility: hidden; cursor: default; }
.tag-addon { background: #f3f4f6; color: var(--c-text-muted); }
.field input[type="file"] { padding: 6px; }
.err-list { max-height: 260px; overflow: auto; margin: 0; padding: 0; list-style: none; font-size: 13px; }
.err-list li { padding: 6px 8px; border-bottom: 1px solid var(--c-border); }
.err-list li:last-child { border-bottom: none; }

/* ---------- 保单列表：批量选择与状态 ---------- */
/* 批量操作条纵向滚动时吸附在顶栏之下（顶栏 56px、z-index 20），
   勾选框与「续保 / 中止 / 终止」不会随列表滚出可视区 */
.batch-bar {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  padding: 10px 12px; margin-bottom: 12px;
  border: 1px solid var(--c-border); border-radius: var(--radius); background: #fafbfc;
  position: sticky; top: var(--topbar-h); z-index: 12;
  box-shadow: 0 2px 8px rgba(16, 24, 40, .06);
}
.batch-bar .sel-all {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 13px; font-weight: 600; color: var(--c-text); cursor: pointer; user-select: none;
}
.batch-bar .sel-info { font-size: 12px; color: var(--c-text-muted); }
.batch-bar .batch-msg { font-size: 12px; font-weight: 600; }
.batch-bar .batch-msg.ok { color: var(--c-success); }
.batch-bar .batch-msg.err { color: var(--c-danger); }
.batch-bar .batch-actions { display: flex; gap: 8px; margin-left: auto; }

/* ---------- 保单回收站（逻辑删除） ---------- */
/* 页面顶部的规则常驻提示：删除后 15 天内可恢复、逾期永久删除 */
.trash-notice {
  display: flex; align-items: flex-start; gap: 8px;
  margin: 0 0 16px; padding: 10px 14px;
  border: 1px solid #fdba74; border-radius: var(--radius);
  background: #fff7ed; color: #9a3412; font-size: 13px; line-height: 1.7;
}
.trash-notice strong { color: #7c2d12; }
.trash-notice-icon { flex: 0 0 auto; font-size: 14px; line-height: 1.7; }
/* 回收站入口上的数量徽标 */
.trash-badge {
  display: inline-block; min-width: 18px; margin-left: 6px; padding: 0 5px;
  border-radius: 9px; background: var(--c-danger); color: #fff;
  font-size: 11px; font-weight: 600; line-height: 18px; text-align: center;
}
/* 剩余可恢复天数：颜色随风险递增（充足 / 临近 / 已逾期） */
.remain-days { font-weight: 600; white-space: nowrap; }
.remain-days.safe { color: var(--c-success); }
.remain-days.warn { color: #b45309; }
.remain-days.danger { color: var(--c-danger); }
/* 回收站表格：剩余天数与操作列给出固定宽度，避免长文案把列撑开 */
table.data th.col-remain, table.data td.col-remain { width: 132px; white-space: normal; }
table.data th.col-time, table.data td.col-time { width: 132px; white-space: nowrap; }
.tag-main { background: #eff6ff; color: #1d4ed8; }
/* 回收站弹窗内的结果反馈（紧随分页下方，非弹窗，4 秒自动消失） */
.trash-msg { min-height: 18px; margin-top: 8px; font-size: 13px; font-weight: 600; }
.trash-msg.ok { color: var(--c-success); }
.trash-msg.err { color: var(--c-danger); }

/* 表头排序：可点击列带排序指示，激活列高亮 */
table.data th.sortable { cursor: pointer; user-select: none; white-space: normal; }
table.data th.sortable:hover { background: #f1f5f9; color: var(--c-text); }
table.data th.sortable.sorted { color: var(--c-primary); background: var(--c-primary-light); }
table.data th .sort-ind { margin-left: 4px; font-size: 10px; color: #cbd5e1; }
table.data th.sortable:hover .sort-ind { color: #94a3b8; }
table.data th.sortable.sorted .sort-ind { color: var(--c-primary); }

/* 勾选列（含「全选本单」按钮）与状态列给定宽度，其余列均分剩余空间 */
table.data th.col-check, table.data td.col-check { width: 118px; white-space: nowrap; }
table.data th.col-status, table.data td.col-status { width: 72px; white-space: nowrap; text-align: center; }
.sel-group {
  margin-left: 8px; padding: 0; border: none; background: none;
  font: inherit; font-size: 12px; color: var(--c-primary); cursor: pointer;
}
.sel-group:hover { text-decoration: underline; }

.status-badge {
  display: inline-block; padding: 2px 8px; border-radius: 10px;
  font-size: 12px; font-weight: 600; line-height: 1.5;
}
.status-badge.st-normal { background: #f3f4f6; color: var(--c-text-muted); }
.status-badge.st-suspended { background: #ffedd5; color: #9a3412; }
.status-badge.st-terminated { background: #fee2e2; color: #991b1b; }
/* 账号冻结：琥珀色（与保单「终止」的红色明确区分——冻结是可逆的停用，不是终止） */
.status-badge.st-frozen { background: #fef3c7; color: #92400e; }
/* 冻结行整行淡琥珀底，列表里一眼可辨 */
table.data tbody tr.row-frozen { background: #fffbeb; }
table.data tbody tr.row-frozen:hover { background: #fef3c7; }
/* 冻结 / 解冻二次确认弹窗：说明文案与原因字数计数器 */
.freeze-tip { margin: 8px 0 0; font-size: 13px; line-height: 1.7; color: var(--c-text-muted); }
.freeze-counter { margin-top: 4px; font-size: 12px; color: var(--c-text-muted); text-align: right; }
.err-list .row-no { display: inline-block; min-width: 62px; color: var(--c-text-muted); }
.err-list .who { color: var(--c-text-muted); }
.err-list .msg { color: var(--c-danger); }
/* 已入库但有提示的行：与「未入库」用颜色区分开，避免被当成失败 */
.err-list.is-warn .msg { color: var(--c-warning); }

/* ---------- 导入弹窗：模板下载与结果分区 ---------- */
.import-tpl { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.import-tpl .btn { text-decoration: none; }
.import-tpl .hint { font-size: 12px; color: var(--c-text-muted); line-height: 1.5; }
.result-sec-title { margin: 10px 0 6px; font-size: 13px; color: var(--c-text-muted); }
/* 导入结果顶部的主操作（下载错误明细）：错误行多时结果正文很长，
   按钮放正文末尾会被挤到滚动区外，故置于汇总条下方、明细之前 */
.result-action {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  margin: 10px 0 2px; padding: 10px 12px;
  border: 1px solid var(--c-primary); border-radius: 8px;
  background: var(--c-primary-light);
}
.result-action .result-action-hint { font-size: 12px; color: var(--c-text-muted); line-height: 1.5; }

/* ---------- Excel 上传区：点击选择 + 拖拽 ---------- */
.drop-zone {
  border: 1px dashed var(--c-border); border-radius: 8px;
  background: var(--c-bg); padding: 18px 14px;
  text-align: center; cursor: pointer;
  transition: border-color .15s ease, background .15s ease, box-shadow .15s ease;
}
.drop-zone:hover { border-color: var(--c-primary); }
/* 忙碌态（如上传中）：置灰不可交互，点击/拖拽/键盘均由 JS 拦截 */
.drop-zone.is-disabled { opacity: .55; cursor: not-allowed; }
.drop-zone.is-disabled:hover { border-color: var(--c-border); }
/* 拖拽悬停高亮：实线描边 + 浅色底，与「未选中」形成明确区分 */
.drop-zone.is-over {
  border-style: solid; border-color: var(--c-primary);
  background: var(--c-primary-light);
  box-shadow: inset 0 0 0 1px var(--c-primary);
}
.drop-zone .drop-inner { display: flex; flex-direction: column; align-items: center; gap: 5px; }
.drop-zone .drop-icon { font-size: 18px; line-height: 1; color: var(--c-primary); }
.drop-zone .drop-main { font-size: 13px; color: var(--c-text); }
.drop-zone .drop-main b { color: var(--c-primary); font-weight: 600; }
.drop-zone .drop-hint { font-size: 12px; color: var(--c-text-muted); }
/* 已选文件时收起引导语，只留文件名与「重新选择」入口 */
.drop-zone.has-file .drop-inner { display: none; }
/* 文件输入框由拖拽区代触发，故隐藏；[hidden] 需显式声明，否则被上面的 display 规则覆盖 */
.drop-zone input[type="file"] { display: none; }
.drop-zone .drop-picked {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 6px 8px;
}
.drop-zone .drop-picked[hidden] { display: none; }
.drop-zone .drop-file-name {
  max-width: 100%; font-size: 13px; font-weight: 600; color: var(--c-text);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.drop-zone .drop-file-size { font-size: 12px; color: var(--c-text-muted); }
.drop-zone .drop-clear {
  border: none; background: transparent; color: var(--c-text-muted);
  font-size: 16px; line-height: 1; padding: 0 2px; cursor: pointer;
}
.drop-zone .drop-clear:hover { color: var(--c-danger); }
.drop-zone .drop-file-again { flex: 0 0 100%; font-size: 12px; color: var(--c-text-muted); }
.drop-msg { margin-top: 6px; font-size: 12px; line-height: 1.5; color: var(--c-text-muted); }
.drop-msg.is-err { color: var(--c-danger); }

/* ---------- 商品图片上传：缩略图 + 拖拽区（上排）/ 移除与提示（下排） ---------- */
.prod-upload { display: flex; align-items: flex-start; gap: 12px; flex-wrap: wrap; }
.prod-upload-main { flex: 1 1 260px; min-width: 220px; }
/* 表单行内的拖拽区比导入弹窗更紧凑，引导文案左对齐 */
.prod-upload .drop-zone { padding: 10px 12px; text-align: left; }
.prod-upload .drop-zone .drop-inner { align-items: flex-start; text-align: left; }
.prod-upload-actions { flex: 0 0 100%; display: flex; align-items: center; gap: 4px; margin-top: 2px; }
.prod-thumb { border: 1px solid var(--c-border); border-radius: 6px; object-fit: cover; background: #fff; display: block; }
.prod-thumb-empty {
  display: flex; align-items: center; justify-content: center;
  width: 48px; height: 48px; border: 1px dashed var(--c-border); border-radius: 6px;
  font-size: 12px; color: var(--c-text-muted); background: var(--c-bg);
}

/* ---------- 图表 ---------- */
.chart-legend { display: flex; flex-wrap: wrap; gap: 8px 16px; margin-top: 12px; font-size: 12px; }
.chart-legend span { display: inline-flex; align-items: center; gap: 6px; color: var(--c-text-muted); }
.chart-legend i { width: 10px; height: 10px; border-radius: 2px; display: inline-block; }
svg.chart { display: block; width: 100%; height: auto; overflow: visible; }
svg.chart text { fill: var(--c-text-muted); font-size: 11px; }

/* ---------- 可搜索下拉（保险公司 / 险种：输入即筛选，↑↓ 键盘选择） ---------- */
.search-select { position: relative; }
.search-select-input { width: 100%; }
.search-select-panel {
  position: absolute; z-index: 20; top: calc(100% + 4px); left: 0; right: 0;
  max-height: 232px; overflow-y: auto;
  background: var(--c-card); border: 1px solid var(--c-border);
  border-radius: var(--radius-sm); box-shadow: var(--shadow-lg);
}
/* hidden 属性需显式声明：上面的 position/背景等不覆盖 display，但防御性写死 */
.search-select-panel[hidden] { display: none; }
.search-select-item { padding: 7px 10px; font-size: 13px; line-height: 1.4; cursor: pointer; }
.search-select-item:hover, .search-select-item.active { background: var(--c-primary-light); color: var(--c-primary-dark); }
.search-select-empty { padding: 8px 10px; font-size: 12px; color: var(--c-text-muted); }
/* 潜客补全项：姓名 + 「电话 · 性别」辅助信息，便于同名区分 */
.search-select-item .lead-name { font-weight: 600; }
.search-select-item .lead-meta { margin-left: 8px; font-size: 12px; color: var(--c-text-muted); }
.search-select-item:hover .lead-meta,
.search-select-item.active .lead-meta { color: inherit; opacity: 0.75; }
/* 转介绍人候选：姓名 + 「客户/潜客 · 电话」辅助信息，便于同名区分 */
.search-select-item .search-select-hint { margin-left: 8px; font-size: 12px; color: var(--c-text-muted); }
.search-select-item:hover .search-select-hint,
.search-select-item.active .search-select-hint { color: inherit; opacity: 0.75; }

/* ---------- 主附险表单：附险行 ---------- */
.addon-rows { display: flex; flex-direction: column; gap: 10px; }
.addon-row {
  border: 1px dashed var(--c-border); border-radius: var(--radius-sm);
  background: #fafbfc; padding: 10px 12px 2px;
}
.addon-row-head { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.addon-row-title { font-size: 13px; font-weight: 600; }
.addon-row-del { margin-left: auto; }
/* 附险五个字段：3 列排布（3 + 2），与主险信息区同栅格，窄列险种名不折行 */
.addon-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0 12px; }
.addon-hint { font-weight: 400; font-size: 12px; color: var(--c-text-muted); }
.addon-add-btn { margin-top: 4px; }

/* ---------- 附险数据弱化展示：列表单元格 / 详情概要卡片 ---------- */
table.data td .cell-addon { color: var(--c-text-muted); }
.addon-row .detail-grid { gap: 10px 14px; }

/* ---------- 客户紧急联系人：1~5 行「姓名 + 标签」（插在「联系电话」之后）----------
   整块独占表单栅格的一整行，行内三段式排布（姓名 / 标签 / 删除） */
.ec-block { grid-column: 1 / -1; }
.ec-row { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr) auto; gap: 8px; align-items: center; }
.ec-row.invalid input,
.ec-row.invalid select { border-color: var(--c-danger); }

/* ==========================================================
   RBAC：岗位权限配置（左侧级别列表 + 右侧 菜单/按钮/数据范围 三 Tab）
   ========================================================== */
.perm-layout { display: flex; gap: 16px; align-items: flex-start; }
/* 左侧：岗位级别列表（固定宽度，窄屏自动堆叠） */
.perm-side {
  flex: 0 0 260px; width: 260px; background: var(--c-card);
  border: 1px solid var(--c-border); border-radius: var(--radius);
  box-shadow: var(--shadow); overflow: hidden;
}
.perm-side-title {
  padding: 12px 14px; font-size: 13px; font-weight: 600;
  border-bottom: 1px solid var(--c-border); background: #fafbfc;
  display: flex; align-items: center; justify-content: space-between;
}
.perm-level-list { padding: 6px; }
.perm-level-item {
  display: flex; align-items: center; gap: 8px; padding: 9px 10px;
  border-radius: var(--radius-sm); cursor: pointer; font-size: 13px;
  border: 1px solid transparent;
}
.perm-level-item:hover { background: #f3f4f6; }
.perm-level-item.active { background: var(--c-primary-light); border-color: #bfdbfe; color: var(--c-primary-dark); font-weight: 600; }
.perm-level-code {
  flex: 0 0 auto; min-width: 38px; padding: 1px 6px; border-radius: 4px;
  background: #eef2ff; color: #4338ca; font-size: 12px; font-weight: 700; text-align: center;
}
.perm-level-item.active .perm-level-code { background: var(--c-primary); color: #fff; }
.perm-level-name { flex: 1 1 auto; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.perm-level-scope { flex: 0 0 auto; font-size: 11px; color: var(--c-text-muted); }
.perm-level-item.active .perm-level-scope { color: var(--c-primary-dark); }
/* 新增级别表单：输入框与按钮复用 .perm-search / .perm-mini-btn，这里只补纵向排布与分隔线 */
.perm-level-form {
  display: flex; flex-direction: column; gap: 6px; padding: 6px;
  border-top: 1px solid var(--c-border);
}
.perm-level-form .perm-search { flex: 1 1 auto; min-width: 0; }
/* 级别行内删除：默认隐形，hover / 选中行才显形，避免左侧列表被一排 × 占满 */
.perm-level-del {
  flex: 0 0 auto; margin-left: 6px; padding: 0 6px; font-size: 12px; line-height: 20px;
  border: 1px solid transparent; border-radius: var(--radius-sm);
  background: transparent; color: var(--c-text-muted); cursor: pointer;
}
.perm-level-item:hover .perm-level-del,
.perm-level-item.active .perm-level-del { border-color: var(--c-border); }
.perm-level-del:hover { color: var(--c-danger); border-color: #fecaca; background: #fef2f2; }

/* 右侧：配置面板 */
.perm-main {
  flex: 1 1 auto; min-width: 0; background: var(--c-card);
  border: 1px solid var(--c-border); border-radius: var(--radius);
  box-shadow: var(--shadow); overflow: hidden;
}
.perm-head { padding: 14px 16px; border-bottom: 1px solid var(--c-border); }
.perm-head h2 { margin: 0; font-size: 15px; }
.perm-head .perm-head-sub { margin-top: 2px; font-size: 12px; color: var(--c-text-muted); }
/* Tab 栏 */
.perm-tabs { display: flex; gap: 2px; padding: 0 16px; border-bottom: 1px solid var(--c-border); background: #fafbfc; }
.perm-tab {
  padding: 10px 14px; font-size: 13px; color: var(--c-text-muted); background: none;
  border: none; border-bottom: 2px solid transparent; cursor: pointer; font-family: inherit;
}
.perm-tab:hover { color: var(--c-primary); }
.perm-tab.active { color: var(--c-primary-dark); font-weight: 600; border-bottom-color: var(--c-primary); }
.perm-pane { padding: 16px; }
.perm-pane[hidden] { display: none; }
.perm-mini-btn {
  padding: 2px 8px; font-size: 12px; border: 1px solid var(--c-border);
  background: #fff; border-radius: 4px; cursor: pointer; color: var(--c-text-muted); font-family: inherit;
}
.perm-mini-btn:hover { color: var(--c-primary); border-color: var(--c-primary); }

/* 权限树工具条：搜索 + 展开折叠 + 全选清空 */
.perm-toolbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.perm-search {
  flex: 1 1 220px; min-width: 180px; padding: 6px 10px; font-size: 13px; font-family: inherit;
  border: 1px solid var(--c-border); border-radius: var(--radius-sm); background: #fff; color: var(--c-text);
}
.perm-search:focus { outline: none; border-color: var(--c-primary); }
.perm-toolbar-hint { margin: 0 0 10px; font-size: 12px; color: var(--c-text-muted); line-height: 1.6; }

/* 权限树：菜单（父）→ 子菜单 / 操作按钮（子） */
.perm-tree {
  max-height: 52vh; overflow-y: auto;
  border: 1px solid var(--c-border); border-radius: var(--radius-sm); padding: 6px; background: #fff;
}
.perm-node {
  display: flex; align-items: center; gap: 6px; padding: 5px 8px;
  border-radius: var(--radius-sm); font-size: 13px;
}
.perm-node:hover { background: #f3f4f6; }
.perm-node-toggle {
  flex: 0 0 auto; width: 16px; height: 16px; line-height: 1; font-size: 11px;
  border: none; background: none; cursor: pointer; color: var(--c-text-muted); font-family: inherit;
}
.perm-node-toggle.is-leaf { cursor: default; }
.perm-node input[type="checkbox"] { flex: 0 0 auto; margin: 0; cursor: pointer; }
.perm-node input[type="checkbox"]:disabled { cursor: not-allowed; }
.perm-badge {
  flex: 0 0 auto; padding: 1px 6px; border-radius: 4px; font-size: 11px; font-weight: 700;
}
.badge-menu { background: #eef2ff; color: #4338ca; }
.badge-button { background: #ecfdf5; color: #047857; }
/* 子菜单：与「菜单 / 按钮」同为可勾选项，用浅青色区分层级；
   未登记权限项的降级子菜单（不可勾选）由 .perm-node.is-locked 置灰区分 */
.badge-submenu { background: #ecfeff; color: #0e7490; }
.perm-node-name { flex: 0 0 auto; }
.perm-node-id {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 11px; color: var(--c-text-muted);
}
.perm-node-url { font-size: 11px; color: #9ca3af; }
.perm-node-count { margin-left: auto; font-size: 11px; color: var(--c-text-muted); }
.perm-item {
  display: flex; align-items: flex-start; gap: 8px; padding: 8px 10px;
  border: 1px solid var(--c-border); border-radius: var(--radius-sm); cursor: pointer; background: #fff;
}
.perm-item:hover { border-color: #bfdbfe; background: #fafbff; }
.perm-item input[type="checkbox"], .perm-item input[type="radio"] { margin: 3px 0 0; flex: 0 0 auto; cursor: pointer; }
.perm-item-body { min-width: 0; }
.perm-item-name { font-size: 13px; }
.perm-item-desc { font-size: 11px; color: var(--c-text-muted); line-height: 1.4; }
/* 数据范围：整行单选卡片 */
.perm-scope-list { display: flex; flex-direction: column; gap: 10px; max-width: 640px; }
.perm-scope-item { align-items: flex-start; }
.perm-scope-item .perm-item-name { font-weight: 600; }
/* 底部操作条 */
.perm-actions {
  display: flex; align-items: center; gap: 10px; padding: 12px 16px;
  border-top: 1px solid var(--c-border); background: #fafbfc;
}
.perm-actions .perm-hint { flex: 1 1 auto; font-size: 12px; color: var(--c-text-muted); }
/* 空态 / 加载 */
.perm-empty { padding: 40px 16px; text-align: center; color: var(--c-text-muted); font-size: 13px; }

@media (max-width: 900px) {
  .perm-layout { flex-direction: column; }
  .perm-side { flex: 1 1 auto; width: 100%; }
}

/* ==========================================================
   组织架构树（用户与权限页）：按 parent_id 层级缩进展示
   ========================================================== */
.org-tree { padding: 4px 0; }
.org-node {
  display: flex; align-items: center; gap: 8px; padding: 6px 8px;
  border-radius: var(--radius-sm); font-size: 13px;
}
.org-node:hover { background: #f3f4f6; }
.org-node.is-root { font-weight: 600; }
.org-node-name { flex: 0 0 auto; }
.org-node-meta { font-size: 11px; color: var(--c-text-muted); }
.org-node-badge {
  padding: 1px 6px; border-radius: 4px; font-size: 11px; font-weight: 700;
  background: #eef2ff; color: #4338ca;
}
.org-empty { padding: 24px; text-align: center; color: var(--c-text-muted); font-size: 13px; }
.org-cycles { margin-top: 8px; padding: 8px 10px; font-size: 12px; color: var(--c-danger); background: #fef2f2; border-radius: var(--radius-sm); }

/* ==========================================================
   可搜索下拉面板：portal 态（保单表单「保险公司 / 险种 / 投保人」搜索）
   ----------------------------------------------------------
   面板打开时以 position:fixed 挂到 document.body，按输入框的视口坐标定位
   （见 policies.js 的 createDropdownController）。
   原因：表单位于 `.modal .body`（max-height:62vh; overflow-y:auto）滚动容器内部，
   position:absolute 的面板会被容器边界裁掉，表现为「下拉打不开 / 只露出一半」。
   层级 90：高于弹窗遮罩（.modal-mask 为 50），低于二次确认弹窗（200），不会盖住确认框。
   ========================================================== */
.search-select-panel.is-portal { position: fixed; right: auto; z-index: 90; }
