/* ============================================================
   保险CRM · app.css
   组件与页面级样式
   ============================================================ */

/* ---------- 基础：hidden 属性优先 ----------
   必须放在组件规则之前并用 !important：
   组件自身的 display（如 .modal{display:flex}）会覆盖浏览器默认的 [hidden]{display:none}，
   导致带 hidden 属性的弹窗/输入框仍然显示。 */
[hidden] { display: none !important; }

/* ---------- 布局 ---------- */
.app { display: flex; min-height: 100vh; min-height: 100dvh; }

.sidebar {
    display: none;
    width: var(--sidebar-w);
    flex: 0 0 var(--sidebar-w);
    background: var(--bg-elev);
    border-right: 1px solid var(--border);
    padding: calc(12px + var(--safe-t)) 10px 12px;
    position: sticky;
    top: 0;
    height: 100vh;
    height: 100dvh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.sidebar__brand { display: flex; align-items: center; gap: 8px; padding: 6px 8px 14px; }
.brand__logo { width: 30px; height: 30px; }
.brand__text { font-weight: 700; color: var(--color-primary); }

.sidebar__nav { display: flex; flex-direction: column; gap: 2px; }
.nav-group { font-size: 12px; color: var(--text-3); padding: 12px 10px 4px; }
.nav-item {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 12px; border-radius: var(--radius-sm);
    color: var(--text-2); min-height: 44px;
}
.nav-item:hover { background: var(--bg-hover); text-decoration: none; }
.nav-item.is-active { background: rgba(255, 106, 0, .12); color: var(--color-primary); font-weight: 600; }
.nav-item__icon { width: 20px; text-align: center; }
.sidebar__foot { margin-top: auto; padding-top: 12px; border-top: 1px solid var(--border); }

.main { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; }

.topbar {
    height: calc(var(--topbar-h) + var(--safe-t));
    padding: var(--safe-t) 12px 0;
    /* 三区布局：左 = 当前栏目名 / 中 = 新增客户 / 右 = 列表工具（排序等）+ 用户名（管理员）+ 退出 */
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    gap: 10px;
    background: var(--bg-elev);
    border-bottom: 1px solid var(--border);
    position: sticky; top: 0; z-index: 20;
}
.topbar__left { display: flex; align-items: center; gap: 8px; min-width: 0; }
.topbar__logo { width: 26px; height: 26px; }
.topbar__title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar__center { display: flex; justify-content: center; min-width: 0; }
.topbar__right { display: flex; align-items: center; gap: 6px; justify-content: flex-end; min-width: 0; }
.topbar__user { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* 顶栏右上角工具体：桌面端由 list.js 把列表页的「搜索框 + 排序工具条」依次搬到这里（用户名之前） */
.topbar__tools { display: flex; align-items: center; min-width: 0; overflow-x: auto; scrollbar-width: none; }
.topbar__tools::-webkit-scrollbar { height: 0; }
.topbar__tools .toolbar-row { margin: 0; flex-wrap: nowrap; gap: 4px; }
.topbar__tools .inline-field { font-size: 13px; white-space: nowrap; }
.topbar__tools .inline-field .input { min-width: 84px; }
.topbar__tools .list-count { margin-left: 2px; }
.topbar__right .btn { white-space: nowrap; }
/* 顶栏里的紧凑搜索框：约 8 个汉字宽（内容宽 ≈124px），不再是通长输入框；
   整组再向左让出约 3 个汉字（42px），与右侧排序工具条拉开距离，避免挤在一起 */
.topbar__tools .search-bar { margin: 0 42px 0 0; flex: 0 0 auto; gap: 4px; }
.topbar__tools .search-bar .input {
    flex: 0 0 auto; width: 146px; min-height: 34px; padding: 6px 10px; font-size: 14px;
}
.topbar__tools .search-bar .btn { flex: 0 0 auto; min-height: 34px; padding: 6px 12px; font-size: 14px; }

/* 列表页顶部搜索框 + 排序工具条：桌面端（≥1340px）由 list.js 搬到顶栏右上角。
   搬运完成前先隐藏，避免加载瞬间在内容区闪一下；未启用 JS 时仍留在内容区可用。 */
@media (min-width: 1340px) {
    html.js .list-toolbar > .search-bar,
    html.js .toolbar-line > .toolbar-row { display: none; }
}

/* 移动端 / 平板：底部标签栏已有「＋」新增入口，顶栏中间的新增隐藏，保证一页只有一个新增按钮 */
@media (max-width: 1023px) {
    .topbar__center { display: none; }
}
@media (max-width: 767px) {
    .topbar__role { display: none; }
}

.content {
    flex: 1 1 auto;
    padding: 10px 14px calc(14px + var(--tabbar-h) + var(--safe-b));
    max-width: 1280px;
    width: 100%;
    margin: 0 auto;
}

/* ---------- 底部标签栏（移动/平板） ---------- */
.tabbar {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
    height: calc(var(--tabbar-h) + var(--safe-b));
    padding-bottom: var(--safe-b);
    display: flex; align-items: stretch;
    background: var(--bg-elev);
    border-top: 1px solid var(--border);
}
.tabbar__item {
    flex: 1 1 0; display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 2px; color: var(--text-3); font-size: 11px; position: relative; min-height: 44px;
}
.tabbar__item:hover { text-decoration: none; }
.tabbar__item.is-active { color: var(--color-primary); }
.tabbar__icon { font-size: 20px; line-height: 1; }
.tabbar__item--add { flex: 0 0 68px; }
.tabbar__plus {
    width: 48px; height: 48px; border-radius: 50%;
    background: var(--color-primary); color: #fff;
    display: flex; align-items: center; justify-content: center; font-size: 26px;
    box-shadow: 0 6px 16px rgba(255, 106, 0, .4);
    margin-top: -14px;
}
.tabbar__badge {
    position: absolute; top: 4px; right: 50%; transform: translateX(20px);
    background: var(--color-danger); color: #fff; font-size: 10px;
    min-width: 16px; height: 16px; border-radius: 8px; padding: 0 4px;
    display: flex; align-items: center; justify-content: center;
}

/* ---------- 通用组件 ---------- */
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.page-title { font-size: 20px; }
.page-sub { color: var(--text-3); font-size: 13px; margin: 2px 0 0; }

.card {
    background: var(--bg-elev);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 14px;
    margin-bottom: 14px;
}
.card__head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.card__title { font-size: 16px; }
.card__more { font-size: 13px; }

.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    min-height: 44px; padding: 10px 16px;
    border-radius: var(--radius-sm); border: 1px solid var(--border-strong);
    background: var(--bg-elev); color: var(--text); cursor: pointer;
    font-weight: 500; white-space: nowrap; text-align: center;
}
.btn:hover { background: var(--bg-hover); text-decoration: none; }
.btn--primary { background: var(--color-primary); border-color: var(--color-primary); color: #fff; }
.btn--primary:hover { background: var(--color-primary-dark); border-color: var(--color-primary-dark); }
.btn--danger { background: var(--color-danger); border-color: var(--color-danger); color: #fff; }
.btn--ghost { background: transparent; }
.btn--sm { min-height: 34px; padding: 6px 12px; font-size: 14px; }
.btn--block { width: 100%; }
/* 次级（软色）按钮：主色淡一档 —— 「保存并记一条跟进」「记跟进」用。
   底色/边框/文字色来自 base.css 令牌（深色模式自动反转）；放在 .btn 系列最后，
   保证同权重下覆盖 .btn 的默认底色与 :hover 灰底。 */
.btn--soft {
    background: var(--btn-soft-bg);
    border-color: var(--btn-soft-border);
    color: var(--btn-soft-fg);
    font-weight: 600;
}
.btn--soft:hover { background: var(--btn-soft-bg-hover); border-color: var(--btn-soft-border); }

.inline-form { display: inline-flex; align-items: center; gap: 6px; margin: 0; }

.alert { padding: 10px 12px; border-radius: var(--radius-sm); margin-bottom: 12px; font-size: 14px; }
.alert--error { background: rgba(220, 38, 38, .1); color: var(--color-danger); }
.alert--warn { background: rgba(245, 158, 11, .12); color: #9A5B00; }

.pill {
    display: inline-block; padding: 2px 8px; border-radius: 999px;
    background: var(--bg-sunken); color: var(--text-2); font-size: 12px;
}
.badge { display: inline-block; background: var(--color-primary); color: #fff; border-radius: 999px; padding: 0 7px; font-size: 12px; }

/* 状态胶囊：浅底深字。颜色由 data-stage 映射到 --st-bg / --st-fg（唯一来源 base.css 的 :root 令牌，
   再由 app/helpers/status.php 的 STAGES 对齐）。视图层只输出 data-stage、不内联颜色；
   深色模式由 base.css 的 dark 令牌自动切「深底浅字」。 */
.status-tag {
    display: inline-block; padding: 2px 9px; border-radius: 999px;
    background: var(--st-bg, #9CA3AF); color: var(--st-fg, #FFFFFF);
    font-size: 12px; white-space: nowrap;
}
.status-tag--muted { background: #9CA3AF; color: #FFFFFF; }
.status-tag--ok { background: var(--color-ok); color: #FFFFFF; }
.status-tag--error { background: var(--color-danger); color: #FFFFFF; }

.status-tag[data-stage="pending_follow"]          { --st-bg: var(--st-pending_follow-bg);          --st-fg: var(--st-pending_follow-fg); }
.status-tag[data-stage="following"]               { --st-bg: var(--st-following-bg);               --st-fg: var(--st-following-fg); }
.status-tag[data-stage="interested"]              { --st-bg: var(--st-interested-bg);              --st-fg: var(--st-interested-fg); }
.status-tag[data-stage="event_invite"]            { --st-bg: var(--st-event_invite-bg);            --st-fg: var(--st-event_invite-fg); }
.status-tag[data-stage="committed"]               { --st-bg: var(--st-committed-bg);               --st-fg: var(--st-committed-fg); }
.status-tag[data-stage="closing"]                 { --st-bg: var(--st-closing-bg);                 --st-fg: var(--st-closing-fg); }
.status-tag[data-stage="signed"]                  { --st-bg: var(--st-signed-bg);                  --st-fg: var(--st-signed-fg); }
.status-tag[data-stage="pending_policy_delivery"] { --st-bg: var(--st-pending_policy_delivery-bg); --st-fg: var(--st-pending_policy_delivery-fg); }
.status-tag[data-stage="development_done"]        { --st-bg: var(--st-development_done-bg);        --st-fg: var(--st-development_done-fg); }
.status-tag[data-stage="renewal_reminder"]        { --st-bg: var(--st-renewal_reminder-bg);        --st-fg: var(--st-renewal_reminder-fg); }
.status-tag[data-stage="claiming"]                { --st-bg: var(--st-claiming-bg);                --st-fg: var(--st-claiming-fg); }
.status-tag[data-stage="redevelopment"]           { --st-bg: var(--st-redevelopment-bg);           --st-fg: var(--st-redevelopment-fg); }
.status-tag[data-stage="no_interest"]             { --st-bg: var(--st-no_interest-bg);             --st-fg: var(--st-no_interest-fg); }

/* 头部状态胶囊（客户姓名旁）：点一下弹系统原生选择器、选中即生效。
   外观仍是 .status-tag（底色随状态变），底层是一个**透明覆盖的原生 <select>** ——
   不做自造轮子，iOS 滚轮 / Android 列表照旧；也避开某些微 webview 把
   appearance:none 后的原生下拉画成空白的老问题。 */
.status-select { position: relative; display: inline-flex; align-items: center; vertical-align: middle; }
.status-select__input {
    position: absolute; inset: 0; z-index: 2;
    width: 100%; height: 100%; min-height: 0;   /* ⚠️ base.css 给 input/select 全局设了 min-height:44px，
                                                   不清零的话透明 select 会比胶囊高 21px、多出来的区域
                                                   会叠到下方元素上造成误点（实测踩到） */
    margin: 0; padding: 0; border: none; border-radius: 999px;
    opacity: 0; cursor: pointer;
    font-size: 16px;                            /* ≥16px 避免 iOS 聚焦时页面放大 */
}
.status-select__input:focus { box-shadow: none; }
.status-select:focus-within .status-select__face { box-shadow: 0 0 0 3px rgba(100, 116, 139, .28); }
.status-select__face { pointer-events: none; }
.status-select__caret { margin-left: 4px; font-size: 9px; opacity: .85; }
@media (hover: hover) {
    .status-select:hover .status-select__face { filter: brightness(1.09); }
}

/* 性别胶囊：与状态胶囊同款「自绘面 + 透明原生 <select> 覆盖」——
   铁律：文字绝不能交给原生 select 渲染（部分 webview 会把 appearance:none 后的 select 画成空白）。
   表单里是可点选的原生 select 覆盖；详情页里没有 select，退化为纯展示胶囊。 */
.gender-pill { position: relative; display: inline-flex; align-items: center; vertical-align: middle; }
.gender-pill__face {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 2px 10px; border-radius: 999px;
    background: var(--g-bg, var(--g-none-bg)); color: var(--g-fg, var(--g-none-fg));
    font-size: 12px; white-space: nowrap; pointer-events: none;
}
.gender-pill__face[data-gender="male"]   { --g-bg: var(--g-male-bg);   --g-fg: var(--g-male-fg); }
.gender-pill__face[data-gender="female"] { --g-bg: var(--g-female-bg); --g-fg: var(--g-female-fg); }
.gender-pill__face[data-gender=""],
.gender-pill__face:not([data-gender])    { --g-bg: var(--g-none-bg);   --g-fg: var(--g-none-fg); }
.gender-pill__caret { font-size: 9px; opacity: .8; pointer-events: none; }
/* 表单里性别胶囊稍大一些，贴合输入区触控尺寸 */
.fitem .gender-pill__face { min-height: 40px; padding: 8px 14px; font-size: 14px; }
.gender-pill__select {
    position: absolute; inset: 0; z-index: 2;
    width: 100%; height: 100%; min-height: 0;   /* 清掉 base.css 的 44px 全局 min-height，避免透明层外溢误点 */
    margin: 0; padding: 0; border: none; border-radius: 999px;
    opacity: 0; cursor: pointer;
    font-size: 16px;                            /* ≥16px 避免 iOS 聚焦时页面放大 */
}
.gender-pill__select:focus { box-shadow: none; }
.gender-pill:focus-within .gender-pill__face { box-shadow: 0 0 0 3px rgba(100, 116, 139, .28); }
@media (hover: hover) {
    .gender-pill:hover .gender-pill__face { filter: brightness(1.09); }
}

.prio { font-size: 11px; padding: 1px 6px; border-radius: 4px; }
.prio--high { background: rgba(220, 38, 38, .12); color: var(--color-danger); }

.empty-text { color: var(--text-3); text-align: center; padding: 18px 8px; }

/* ---------- 表单 ---------- */
.form-card { max-width: 720px; }
.field { display: block; margin-bottom: 12px; }
.field__label { display: block; font-size: 13px; color: var(--text-2); margin-bottom: 5px; }
.field__hint { display: block; font-size: 12px; color: var(--text-3); margin-top: 4px; }
.field--inline { display: inline-flex; flex-direction: column; margin: 0; }
.field-row { display: flex; gap: 10px; }
.field-row > .field { flex: 1 1 0; min-width: 0; }
.required { color: var(--color-danger); }

/* ---------- 客户登记表单：三列「标签在左 / 控件在右」网格 ----------
   原来每个字段「标签一行 + 控件一行」竖着垒 21 行；现在一行放 3 个字段，
   纵向占高约 1/3。窄屏依次折成 2 列 / 1 列，标签列固定 90px 保证各列对齐。 */
.form-card--wide { max-width: 1180px; }
.fgrid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px 20px; }
.fitem {
    display: grid; grid-template-columns: 90px minmax(0, 1fr);
    align-items: center; gap: 8px; min-width: 0;
}
.fitem > *:not(.fitem__label) { min-width: 0; }
.fitem__label { font-size: 13px; color: var(--text-2); white-space: nowrap; }
.fitem .input { min-height: 40px; padding: 8px 10px; }
.fitem .field__pw .input { padding-right: 52px; }
/* 跨列单元格：手机不跨（单列时跨列会产生隐式列）、两列时通长、三列时占两格 */
.fitem--span2, .fitem--span3 { grid-column: auto; }
@media (min-width: 768px) {
    .fgrid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .fitem--span2, .fitem--span3 { grid-column: 1 / -1; }
    /* 保存按钮靠右（贴表单右下角），与网格右缘对齐 */
    .form-card--wide .form-actions { justify-content: flex-end; }
}
@media (min-width: 1280px) {
    .fgrid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .fitem--span2 { grid-column: span 2; }
    .fitem--span3 { grid-column: 1 / -1; }
}
/* 表单里的紧凑胶囊（目前状况多选） */
.pill-select--sm { gap: 6px; }
.pill-select--sm .pill-option span { padding: 4px 10px; font-size: 13px; min-height: 30px; line-height: 20px; }
.form-card--wide > .check { min-height: 36px; margin-bottom: 10px; font-size: 14px; }
.input--sm { min-height: 34px; padding: 6px 10px; font-size: 14px; }
/* 生日：月 / 日 双下拉并排，窄屏也不折行溢出（表单里由 form.js 让「日」随「月」联动） */
.birth-select { display: flex; gap: 8px; min-width: 0; }
.birth-select .input { flex: 1 1 0; min-width: 0; width: auto; }
/* 来源渠道：下拉 + 渠道备注上下堆叠，避免备注框把同一行挤破 */
.fitem__stack { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.fitem__stack .input { width: 100%; }
.textarea { line-height: 1.5; }
/* 跟进内容输入框：通长（下方一行已让给「下次跟进时间 + 补录/更新标签/提交」，
   右侧不再有竖排按钮列，文本框自然铺满整行）；高 6 行（行高 24px → 内容高 144px）；
   仍保留右下角可手动向下拉伸 */
.textarea--follow { width: 100%; max-width: 100%; height: 166px; min-height: 166px; }
.check { display: flex; align-items: center; gap: 8px; min-height: 44px; }
.check input { width: 20px; height: 20px; min-height: auto; }

/* 跟进表单：「更新标签」胶囊按钮（位于「下次跟进时间」行末尾、与「补录」「提交」同排靠右）。
   本质仍是原生 <select>，但让它整块透明覆盖在自绘胶囊之上 ——
   ① 文字与颜色由 .status-pill__face 自绘，任何内核（含微信 webview）都能显示，
      不会出现「原生 select 被 appearance:none 抹掉后看不到文字」的情况；
   ② 点一下仍唤起 iOS/Android 原生选择器，零依赖、零 JS 轮子。 */
.status-pill {
    position: relative; display: inline-flex; align-items: center; gap: 4px;
    padding: 5px 10px; min-height: 34px; border-radius: 999px;
    background: var(--color-pink); border: 1px solid var(--color-pink);
    color: #fff; font-size: 13px; cursor: pointer; white-space: nowrap;
}
.status-pill__face { pointer-events: none; }
.status-pill__caret { font-size: 11px; line-height: 1; opacity: .9; pointer-events: none; }
.status-pill__select {
    position: absolute; inset: 0; z-index: 2;
    width: 100%; height: 100%; min-height: 0;
    padding: 0; margin: 0; border: 0; border-radius: 0;
    opacity: 0; cursor: pointer;
    font-size: 16px; /* 保持 ≥16px，避免 iOS 聚焦时页面放大 */
}
.status-pill__select:focus { box-shadow: none; }
.status-pill:focus-within { box-shadow: 0 0 0 3px rgba(219, 39, 119, .22); }
.status-pill.is-set { background: var(--color-pink-dark); border-color: var(--color-pink-dark); }

/* 跟进表单底部：文本框通长，下方一行 = 「下次跟进时间」的 5 个时间按钮 + 补录 / 更新标签 / 提交，
   后三个靠右收尾（`margin-left: auto` 把整组推到行尾）；
   窄屏（<768px）时间按钮占一行，这三个动作整块折到下一行、两端对齐（补录靠左、更新标签+提交靠右） */
.follow-editor { display: block; }
.follow-foot > .field__label { display: block; margin-bottom: 6px; }
.follow-form .quick-row { align-items: center; margin-bottom: 6px; }
.follow-actions { flex: 0 0 auto; display: flex; align-items: center; gap: 10px; margin-left: auto; }
.follow-actions .check { min-height: 34px; font-size: 13px; }
@media (max-width: 767px) {
    /* 5 个时间按钮（明天/3天后/1周后/自定义/无计划）：窄屏把 chip 与间距收 2px，
       保证 360px 宽的机型也能 5 个同排一行，不至折行 */
    .follow-form .quick-row { gap: 6px; }
    .follow-form .quick-row .chip--sm { padding: 5px 8px; }
    .follow-actions { margin-left: 0; width: 100%; }
    .follow-actions .check { margin-right: auto; }
    .follow-actions .btn { padding: 9px 22px; }
}
.field__pw { position: relative; }
.pw-toggle {
    position: absolute; right: 4px; top: 50%; transform: translateY(-50%);
    background: none; border: none; min-height: 36px; padding: 6px 8px; color: var(--text-2); cursor: pointer;
}
.form-actions { display: flex; gap: 10px; margin-top: 16px; }
.form-actions--sticky {
    position: sticky; bottom: calc(8px + var(--safe-b));
    background: var(--bg-elev); padding: 10px 0; border-top: 1px solid var(--border); z-index: 5;
}
/* 手机端（<768px）：保存区整组贴右下角，「保存」放在最右（右下角）。
   「保存并记一条跟进」只是用 order 挪到左边 —— 不动 DOM 顺序，
   输入框里按回车时的隐式提交仍命中 DOM 第一个 submit（即「保存」），行为不变。 */
@media (max-width: 767px) {
    .form-actions--sticky { justify-content: flex-end; }
    .form-actions--sticky .btn--soft { order: -1; }
}
.pill-select { display: flex; flex-wrap: wrap; gap: 8px; }
.pill-option { position: relative; }
.pill-option input { position: absolute; opacity: 0; pointer-events: none; }
.pill-option span {
    display: inline-block; padding: 8px 14px; border-radius: 999px;
    border: 1px solid var(--border-strong); background: var(--bg-elev); font-size: 14px; min-height: 40px; line-height: 22px;
}
.pill-option input:checked + span { background: var(--color-primary); border-color: var(--color-primary); color: #fff; }
.dup-hint { background: rgba(245, 158, 11, .12); border-radius: var(--radius-sm); padding: 10px; margin-bottom: 12px; font-size: 14px; }

/* 条件展开区（无意向原因 / 再联系日期）：仅当状态为「无意向」时显示；两块信息均为选填。 */
.reveal-box {
    margin-top: 10px; padding: 12px;
    background: var(--bg-sunken);
    border: 1px dashed var(--border-strong);
    border-radius: var(--radius-sm);
}
.reveal-box .field__hint { margin: 0; }

/* ---------- 列表工具栏 ---------- */
.list-toolbar { margin-bottom: 12px; }
.list-count { margin-left: auto; color: var(--text-3); font-size: 13px; white-space: nowrap; }
.search-bar { display: flex; gap: 8px; margin-bottom: 10px; }
.search-bar .input { flex: 1 1 auto; }
.tag-scroll { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 8px; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; }
.tag-chip {
    flex: 0 0 auto; display: inline-flex; align-items: center; gap: 5px;
    padding: 7px 14px; border-radius: 999px; background: var(--bg-elev);
    border: 1px solid var(--border); color: var(--text-2); font-size: 14px; white-space: nowrap; min-height: 38px;
}
.tag-chip.is-active { background: var(--color-primary); border-color: var(--color-primary); color: #fff; }
.tag-chip__badge { background: rgba(0, 0, 0, .12); border-radius: 999px; padding: 0 6px; font-size: 12px; }
.tag-chip.is-active .tag-chip__badge { background: rgba(255, 255, 255, .3); }
.toolbar-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 10px; }
.inline-field { display: inline-flex; align-items: center; gap: 4px; font-size: 14px; color: var(--text-2); }
.inline-field .input { width: auto; min-width: 96px; }
/* 快捷筛选 + 排序工具条：小屏上下堆叠，桌面并排成一行（排序跟在标签行右侧） */
.toolbar-line { display: block; }
.filters { display: grid; gap: 8px; padding: 12px; background: var(--bg-sunken); border-radius: var(--radius-sm); margin-bottom: 10px; }
.filter-bar { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; }

/* ---------- 表格 ---------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th, .table td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table th { color: var(--text-2); font-weight: 600; background: var(--bg-sunken); white-space: nowrap; }
.table tbody tr:hover { background: var(--bg-hover); }
.table__actions { display: flex; gap: 6px; flex-wrap: wrap; }
.cell-title { font-weight: 600; color: var(--text); }
.cell-date { white-space: nowrap; color: var(--text-2); font-size: 13px; }
/* 客户列表列数多（10 列），单元格内边距收窄 2px、日期列字号 13px，
   尽量把「小笔记本（≈1080px）下出现横向滚动」的概率压低（不改动其它页面的表格） */
.customer-table .table th, .customer-table .table td { padding: 10px 10px; }
/* 表头可排序（下次跟进 / 创建日期）：整格是链接，点击切换升序 / 降序。
   箭头用绝对定位塞进右内边距里、不参与列宽计算 —— 客户列表有 10 列，
   箭头若占宽度会在 ≈1080px 窗口额外撑出横向滚动。（故此处不能用 flex） */
.table th.th-sort { padding: 0; position: relative; }
.th-sort__link { display: block; padding: 10px 12px; color: inherit; font-weight: 600; white-space: nowrap; }
.th-sort__link:hover { color: var(--color-primary); }
.th-sort__arrow { position: absolute; top: 50%; right: 3px; transform: translateY(-50%); font-size: 10px; line-height: 1; color: var(--text-3); }
.th-sort.is-active .th-sort__link,
.th-sort.is-active .th-sort__arrow { color: var(--color-primary); }
/* 客户列表表头内边距与该表单元格保持一致（该表内边距已收窄为 10px） */
.customer-table .table th.th-sort .th-sort__link { padding: 10px 10px; }
.log-detail { max-width: 320px; word-break: break-all; color: var(--text-2); }

.customer-table { display: none; }

/* ---------- 移动卡片 ---------- */
.customer-cards { display: grid; gap: 10px; }
/* 手机端整张卡片可点（进详情页，由 list.js 的事件委托实现）：手型光标 + 按下反馈 */
.customer-card { background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px; box-shadow: var(--shadow); cursor: pointer; }
.customer-card:active { background: var(--bg-hover); }
.customer-card__top { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.customer-card__name { font-weight: 600; color: var(--text); flex: 1 1 auto; }
.customer-card__meta { display: flex; flex-wrap: wrap; gap: 8px; color: var(--text-3); font-size: 13px; margin: 8px 0; }
.customer-card__times { display: flex; flex-wrap: wrap; gap: 12px; font-size: 13px; color: var(--text-2); margin-bottom: 10px; }
.customer-card__actions { display: flex; gap: 8px; }
.customer-card__actions .btn { flex: 1 1 0; }

/* ---------- 分页 ---------- */
.pager { display: flex; align-items: center; justify-content: center; gap: 12px; margin: 14px 0; }
.pager__link { padding: 8px 14px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--bg-elev); }
.pager__info { color: var(--text-3); font-size: 14px; }
.load-more-wrap { margin: 10px 0; }

/* ---------- 统计卡 ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 14px; }
.stat-card { background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; display: flex; flex-direction: column; gap: 4px; box-shadow: var(--shadow); }
.stat-card__num { font-size: 26px; font-weight: 700; color: var(--color-primary); }
.stat-card__label { color: var(--text-2); font-size: 13px; }
.stat-card--danger .stat-card__num { color: var(--color-danger); }
.two-col { display: grid; gap: 14px; }

.mini-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.mini-stat { background: var(--bg-sunken); border-radius: var(--radius-sm); padding: 10px; text-align: center; }
.mini-stat__n { display: block; font-size: 18px; font-weight: 700; }
.mini-stat__l { font-size: 12px; color: var(--text-3); }

/* ---------- 条形图 / 漏斗（纯 CSS） ---------- */
.bars { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.bars__item { display: grid; grid-template-columns: 88px 1fr 40px; align-items: center; gap: 8px; font-size: 13px; }
.bars__label { color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bars__track { background: var(--bg-sunken); border-radius: 999px; height: 14px; overflow: hidden; }
.bars__fill { display: block; height: 100%; border-radius: 999px; }
.bars__n { text-align: right; color: var(--text-2); }

.funnel { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.funnel__row { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.funnel__label { width: 72px; color: var(--text-2); }
.funnel__bar { display: inline-block; min-width: 28px; color: #fff; border-radius: 4px; padding: 4px 8px; text-align: right; }

/* ---------- 待办 / 时间线 ---------- */
.todo-mini, .todo-list { list-style: none; margin: 0; padding: 0; }
.todo-mini li { padding: 8px 0; border-bottom: 1px solid var(--border); }
.todo-mini li:last-child { border-bottom: none; }
.todo-mini a { display: flex; justify-content: space-between; gap: 10px; color: var(--text); }
.todo-mini__time { color: var(--text-3); font-size: 13px; }
.todo-mini__time.is-overdue { color: var(--color-danger); }
.todo-list__item { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.todo-list__item:last-child { border-bottom: none; }
.todo-list__main { flex: 1 1 auto; min-width: 0; color: var(--text); }
.todo-list__name { display: block; font-weight: 600; }
.todo-list__meta { display: block; font-size: 12px; color: var(--text-3); }

.timeline-filter, .method-row, .quick-row { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
.chip {
    padding: 7px 14px; border-radius: 999px; border: 1px solid var(--border-strong);
    background: var(--bg-elev); color: var(--text-2); cursor: pointer; min-height: 38px; font-size: 14px;
}
.chip.is-active { background: var(--color-primary); border-color: var(--color-primary); color: #fff; }
.chip--sm { padding: 5px 10px; font-size: 13px; min-height: 34px; }

/* 下次跟进时间：日期时间框紧贴按钮行、收窄为小尺寸，
   避免整行通长导致日历图标离按钮太远，鼠标要跑很远才能点到 */
.quick-row { margin-bottom: 6px; }
.input--dt { display: block; width: 100%; max-width: 220px; margin-bottom: 2px; }

.timeline { position: relative; padding-left: 18px; }
.tl-item { position: relative; padding: 0 0 14px 12px; border-left: 2px solid var(--border); }
.tl-item:last-child { border-left-color: transparent; padding-bottom: 0; }
.tl-item__dot { position: absolute; left: -7px; top: 4px; width: 12px; height: 12px; border-radius: 50%; background: var(--color-primary); }
.tl-item--system .tl-item__dot { background: var(--text-3); }
.tl-item__head { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; font-size: 12px; color: var(--text-3); }
.tl-item__method { font-weight: 600; color: var(--color-primary); }
.tl-item__user { color: var(--text-2); }
.tl-item__content { margin-top: 4px; white-space: pre-wrap; word-break: break-word; }
.tl-item__content--muted { color: var(--text-3); font-size: 13px; }
.tl-item__next { margin-top: 4px; font-size: 13px; color: var(--color-info); }
/* 蓝色「下次跟进」日期：点一下即把这条待办标记完成（只标记，不删记录、不改时间） */
.tl-item__next.is-action {
    display: flex; align-items: center; flex-wrap: wrap; gap: 2px 8px;
    min-height: 30px; padding: 2px 10px; margin-left: -10px;
    border: 1px dashed var(--color-info); border-radius: 8px;
    cursor: pointer; -webkit-tap-highlight-color: transparent;
}
.tl-item__next.is-action::after { content: '点击标记完成'; font-size: 11px; opacity: .8; white-space: nowrap; }
.tl-item__next.is-action:hover  { background: rgba(37, 99, 235, .08); }
.tl-item__next.is-action:active { background: rgba(37, 99, 235, .16); }
.tl-item__next.is-action:focus-visible { outline: 2px solid var(--color-info); outline-offset: 2px; }
.tl-item__next.is-done { color: var(--text-3); }
.tl-item__done {
    display: inline-flex; align-items: center; margin-left: 6px;
    padding: 1px 8px; border-radius: 999px; font-size: 11px; line-height: 1.7;
    color: var(--color-ok); background: rgba(22, 163, 74, .10);
    border: 1px solid rgba(22, 163, 74, .30);
}

/* ---------- 详情 ---------- */
/* 详情页头部压成一行：返回在左，客户姓名 / 电话 / 资料 / 跟进时间 / 状态胶囊依次排在其右侧，
   右上角是「编辑 / 删除」。宽度不够时按需换行，不会溢出或互相压住 */
.detail-head__top { display: flex; align-items: center; gap: 8px 10px; margin-bottom: 0; flex-wrap: wrap; }
.detail-head__back { flex: 0 0 auto; }
/* flex-basis 取 0（而不是 auto）：否则该块按“最大内容宽”参与换行判定，
   会把右上角的「编辑 / 删除」挤到第二行去 */
.detail-head__main { flex: 1 1 0; min-width: 0; display: flex; align-items: center; flex-wrap: wrap; gap: 4px 8px; }
.detail-head__name { font-size: 16px; display: inline-flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.detail-head__item { display: inline-flex; align-items: center; gap: 4px; color: var(--text-2); font-size: 12px; white-space: nowrap; }
/* 「负责人」永远贴在这一行（信息区）的最右面：DOM 里它排最后 + 自动左外边距吃掉剩余空隙 */
.detail-head__item--owner { margin-left: auto; }
.detail-head__actions { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; margin-left: auto; flex: 0 0 auto; }
/* 桌面端（≥1024px）：头部内的小按钮再压一号 + 收紧间距，把整块信息尽量收进同一行；
   窄屏（手机 / 平板）保持 34px 触控尺寸，放不下时自然换行 */
@media (min-width: 1024px) {
    .detail-head .btn--sm { min-height: 28px; padding: 3px 9px; font-size: 12px; }
    .detail-head__main { gap: 4px; }
}
/* 手机端（<768px）：头部改成纵向两段式 ——
   第 1 行「返回 + 编辑/删除」，第 2 段「姓名+状态」与全部资料通长换行。
   必须这么改的原因：窄屏下 .detail-head__main 的 flex:1 1 0 会被「返回」和右侧按钮区
   夹成十几像素的窄列（实测仅 12px），列里 white-space:nowrap 的资料项则全部溢出，
   与按钮区叠在一起（实测 6 处重叠）。桌面端（≥768px）完全不受影响。 */
@media (max-width: 767px) {
    .detail-head__back { order: 1; }
    .detail-head__actions { order: 2; margin-left: auto; }
    .detail-head__main {
        order: 3;
        flex: 0 0 100%; max-width: 100%;
        align-items: flex-start; gap: 6px 10px;
        margin-top: 6px; padding-top: 10px;
        border-top: 1px dashed var(--border);
    }
    /* 窄屏重排：第 1 行「客户姓名 + 状态」左、负责人靠右；
       第 2 行起依次是「电话 + 复制 + 客户类型」、备用/微信/城市、下次跟进。
       用 order 而非改 DOM 结构 —— 桌面端（≥768px）完全不受影响。 */
    /* 零高度的整行占位元素：把「名称 + 负责人」这一行与后面强行隔开（桌面端不生成）。
       有了它，名称就能安全地用 flex-basis:0（宽度不够时压缩自己而不是把负责人挤到下一行）。 */
    .detail-head__main::before { content: ''; order: 2; flex: 0 0 100%; height: 0; }
    .detail-head__main > * { order: 3; }
    .detail-head__name { order: 0; flex: 1 1 0; min-width: 0; font-size: 18px; }
    .detail-head__item--owner { order: 1; flex: 0 0 auto; }
    .detail-head__item--phone { order: 3; font-size: 15px; }
    .detail-head__item--phone .link { font-weight: 600; }
    .detail-head__item { font-size: 13px; }
    .detail-head__actions .btn--sm { min-height: 34px; padding: 7px 12px; font-size: 13px; }
}
.detail-dl { display: grid; grid-template-columns: 120px 1fr; gap: 8px 12px; margin: 0; font-size: 14px; }
.detail-dl dt { color: var(--text-3); }
.detail-dl dd { margin: 0; word-break: break-word; }

.tabs { display: flex; gap: 6px; overflow-x: auto; margin-bottom: 12px; -webkit-overflow-scrolling: touch; }
.tab { flex: 0 0 auto; padding: 9px 16px; border-radius: 999px; border: 1px solid var(--border); background: var(--bg-elev); color: var(--text-2); min-height: 40px; }
.tab.is-active { background: var(--color-primary); border-color: var(--color-primary); color: #fff; }
.tab-panel { display: none; }
.tab-panel.is-active { display: block; }

/* ---------- 文件 ---------- */
.file-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; margin: 10px 0; }
.file-item { position: relative; border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 8px; background: var(--bg-elev); }
.file-item__link { display: block; color: var(--text); text-align: center; }
.file-item__thumb { width: 100%; height: 96px; object-fit: cover; border-radius: 6px; margin-bottom: 6px; }
.file-item__icon { display: block; font-size: 34px; margin-bottom: 6px; }
.file-item__name { font-size: 13px; display: block; word-break: break-all; }
.file-item__meta { display: block; font-size: 12px; color: var(--text-3); margin-top: 4px; }
.file-item__del { position: absolute; top: 6px; right: 6px; background: rgba(220, 38, 38, .9); color: #fff; border: none; border-radius: 4px; font-size: 12px; padding: 4px 8px; cursor: pointer; }
.upload-box { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 10px 0; }
.upload-box input[type="file"] { width: 100%; min-height: 56px; padding: 6px; }
/* 「选取文件」按钮（原生 file 控件的按钮部分）加大一号：56px 控件 / 46px 按钮 / 16px 字号。
   Chromium·新 Safari 用 ::file-selector-button，旧 Safari 用 ::-webkit-file-upload-button，
   两个都写；全站所有 file 控件（客户表单、详情页文件、导入 CSV）一并生效。 */
input[type="file"] { min-height: 56px; padding: 6px; }
input[type="file"]::file-selector-button,
input[type="file"]::-webkit-file-upload-button {
    min-height: 46px; padding: 10px 22px; margin: 0 12px 0 0;
    font-family: inherit; font-size: 16px; font-weight: 500;
    border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
    background: var(--bg-sunken); color: var(--text); cursor: pointer;
}
input[type="file"]::file-selector-button:hover,
input[type="file"]::-webkit-file-upload-button:hover { background: var(--bg-hover); }
.upload-progress { flex: 1 1 100%; height: 6px; background: var(--bg-sunken); border-radius: 999px; overflow: hidden; }
.upload-progress span { display: block; height: 100%; width: 0; background: var(--color-primary); transition: width .2s; }

/* ---------- 保单卡片（客户表单 1:N） ---------- */
/* 每张保单 = 3 列 × 2 行（保险公司/投保人/被保险人 + 受益人/险种/年缴保费），
   右上角一个小号删除按钮（✕）。允许删到 0 张。 */
.policy-card { position: relative; border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 12px; margin-bottom: 10px; background: var(--bg-elev); }
.policy-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px 20px; }
.policy-del {
    position: absolute; top: 6px; right: 6px; z-index: 3;
    width: 26px; height: 26px; line-height: 1; padding: 0;
    display: inline-flex; align-items: center; justify-content: center;
    border: 1px solid var(--border-strong); border-radius: 50%;
    background: var(--bg-elev); color: var(--text-3); font-size: 13px; cursor: pointer;
}
.policy-del:hover { background: rgba(220, 38, 38, .1); color: var(--color-danger); border-color: var(--color-danger); }
.policy-add-wrap { margin-bottom: 4px; }
@media (min-width: 768px) {
    .policy-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (min-width: 1024px) {
    .policy-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

/* ---------- 弹窗 ---------- */
.modal { position: fixed; inset: 0; z-index: 60; display: flex; align-items: flex-end; justify-content: center; }
.modal__mask { position: absolute; inset: 0; background: rgba(0, 0, 0, .45); }
.modal__card {
    position: relative; background: var(--bg-elev); width: 100%; max-width: 480px;
    border-radius: var(--radius) var(--radius) 0 0; padding: 16px 16px calc(16px + var(--safe-b));
    box-shadow: var(--shadow-lg); max-height: 88vh; max-height: 88dvh; overflow-y: auto; -webkit-overflow-scrolling: touch;
}
.modal__title { margin-bottom: 8px; }
.modal__text { color: var(--text-2); margin: 0 0 12px; }
.modal__actions { display: flex; gap: 10px; margin-top: 14px; }
.modal__actions .btn { flex: 1 1 0; }

/* ---------- Toast ---------- */
.toast {
    position: fixed; left: 50%; bottom: calc(80px + var(--safe-b)); transform: translate(-50%, 20px);
    background: rgba(31, 35, 41, .94); color: #fff; padding: 10px 18px; border-radius: 999px;
    font-size: 14px; max-width: 84vw; text-align: center; opacity: 0; pointer-events: none;
    transition: opacity .2s, transform .2s; z-index: 80;
}
.toast.is-show { opacity: 1; transform: translate(-50%, 0); }
.toast--error { background: rgba(220, 38, 38, .95); }
.toast--success { background: rgba(22, 163, 74, .95); }

/* ---------- 登录页 ---------- */
.auth-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; min-height: 100dvh; padding: 20px; background: var(--bg); }
.auth-card { width: 100%; max-width: 380px; background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-lg); padding: 24px 20px calc(24px + var(--safe-b)); }
.auth-brand { text-align: center; margin-bottom: 18px; }
.auth-brand__logo { width: 56px; height: 56px; margin: 0 auto 8px; }
.auth-brand__title { font-size: 18px; }
.auth-form { display: block; }
.auth-form .btn { margin-top: 6px; }
.auth-tip { text-align: center; color: var(--text-3); font-size: 13px; margin-top: 14px; }

/* ---------- 回收站 ---------- */
.recycle-list { display: grid; gap: 10px; }
.recycle-item { display: flex; align-items: center; justify-content: space-between; gap: 10px; background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px; flex-wrap: wrap; }
.recycle-item__title { display: flex; gap: 8px; align-items: center; font-weight: 600; }
.recycle-item__meta { display: flex; flex-wrap: wrap; gap: 10px; font-size: 13px; color: var(--text-3); margin-top: 6px; }
.recycle-item__actions { display: flex; gap: 8px; }

/* ---------- 字典 / 导入 ---------- */
.dict-list { list-style: none; margin: 0 0 10px; padding: 0; }
.dict-list__item { display: flex; gap: 8px; align-items: center; padding: 6px 0; }
.dict-list__item.is-off { opacity: .5; }
.dict-rename { display: flex; gap: 6px; flex: 1 1 auto; }
.dict-add { display: flex; gap: 8px; }
.import-summary { display: flex; gap: 16px; flex-wrap: wrap; margin-bottom: 10px; font-size: 14px; }

/* ---------- 断点 ---------- */
@media (min-width: 768px) {
    .content { padding: 12px 18px calc(18px + var(--tabbar-h) + var(--safe-b)); }
    .stat-grid { grid-template-columns: repeat(4, 1fr); }
    .two-col { grid-template-columns: 1fr 1fr; }
    .customer-cards { display: none; }
    .customer-table { display: block; }
    .load-more-wrap { display: none; }
    .modal { align-items: center; }
    .modal__card { border-radius: var(--radius); }
    .detail-dl { grid-template-columns: 140px 1fr; }
}

@media (min-width: 1024px) {
    .sidebar { display: block; }
    .tabbar { display: none; }
    .content { padding: 12px 28px 40px; }
    .form-actions--sticky { position: static; }
    /* 标签行与排序工具条：≥1340px 时搜索框/工具条被搬到顶栏，这里只剩标签行（占满整行）；
       1024–1339px 时两者并排——标签在左、工具条靠右，宽度不够时整组换到下一行 */
    .toolbar-line { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 12px; }
    /* flex:0 1 auto —— 换行判定用标签的自然宽度，放不下才换行；本身仍可收缩避免溢出 */
    .toolbar-line .tag-scroll {
        flex: 0 1 auto; min-width: 0; max-width: 100%;
        flex-wrap: wrap; column-gap: 6px; row-gap: 8px; overflow: visible; padding-bottom: 0;
    }
    .toolbar-line .tag-chip { padding: 6px 10px; font-size: 13px; min-height: 34px; }
    .toolbar-line .toolbar-row { flex: 0 0 auto; margin-left: auto; flex-wrap: nowrap; margin-bottom: 0; gap: 5px; }
    .toolbar-line .inline-field { font-size: 13px; }
    .toolbar-line .inline-field .input { min-width: 78px; }
    .toolbar-line .list-count { margin-left: 6px; }
}
