/* ============================================================
   贷款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(37, 99, 235, .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; }
}

/* 移动端 / 平板：底部标签栏已有「＋」新增入口，顶栏的新增隐藏，保证一页只有一个新增按钮
   ⚠️ 必须用 `.topbar__right .topbar__new`（0,2,0）压过后面定义的 `.btn`（0,1,0）—— 只写 `.topbar__new` 会被 .btn 的 display 覆盖 */
@media (max-width: 1023px) {
    .topbar__center { display: none; }
    .topbar__right .topbar__new { display: none; }
}
@media (max-width: 767px) {
    .topbar__role { display: none; }
}

/* v1.14：手机端「客户列表」顶栏改造 —— 整行让给「筛选 + 搜索框 + 搜索」，
   标题和用户名都隐藏，搜索框吃满剩余宽度（用户要求「搜索框根据实际宽度来」）。
   背景：layout.php 只在开了 $topbarSlot 的页面（目前只有客户列表）给 <header> 加 .topbar--tools；
   list.js 在 ≤767px 时只把搜索栏搬进 .topbar__tools，排序工具条留在内容区。
   作用域全部挂在 .topbar--tools 下 —— 其它页面（待办 / 统计 / 回收站 / 详情页）没有这个类，
   手机端顶栏完全不受影响；桌面端与 768–1339px 也不进这个媒体查询，视觉零变化。 */
@media (max-width: 767px) {
    /* 标题与用户名（「抓图（管理员）」）都去掉，顶栏只剩搜索区 */
    .topbar--tools .topbar__left { display: none; }
    .topbar--tools .topbar__user { display: none; }
    /* .topbar 的三列网格（auto minmax(0,1fr) auto）保持不动：
       左块隐藏后右块只剩「新增客户按钮（≤1023px 已隐藏）+ tools 槽」，
       让它整行铺满，避免落在 auto 列里被内容宽度限制 */
    .topbar--tools .topbar__right { grid-column: 1 / -1; }
    /* 槽位与搜索栏都吃满整行 */
    .topbar--tools .topbar__tools { flex: 1 1 100%; width: 100%; min-width: 0; }
    .topbar--tools .topbar__tools .search-bar { margin: 0; gap: 6px; width: 100%; flex: 1 1 auto; }
    /* 顺序仍是「筛选 / 输入框 / 搜索」，与内容区手机端一致 */
    .topbar--tools .topbar__tools .search-bar .filter-toggle { order: 1; flex: 0 0 auto; }
    .topbar--tools .topbar__tools .search-bar .input { order: 2; flex: 1 1 auto; width: auto; min-width: 0; }
    .topbar--tools .topbar__tools .search-bar .btn--primary { order: 3; flex: 0 0 auto; }
    /* 三个控件统一 38px 高（与手机端「搜索」按钮同高），顶栏里不会高矮不齐 */
    .topbar--tools .topbar__tools .search-bar .input,
    .topbar--tools .topbar__tools .search-bar .filter-toggle { min-height: 38px; }
}

.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(37, 99, 235, .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;
}

/* 待办数量红标：与 .tabbar__badge 同色、同数字、同源（都来自 /api/todos/count 的 total），
   属于同一枚提醒在不同位置的重申 —— 首页「待办提醒」卡片标题后 + PC 侧栏「首页」文字后。
   PC 端 .tabbar 在 ≥1024px 直接 display:none，所以侧栏这枚不能省，否则桌面看不到任何红点。
   侧栏这枚刻意不用「图标右上角」：nav-item 是横排，角标会压住「首页」的第一个字。 */
.card__badge, .nav-item__badge {
    display: inline-flex; align-items: center; justify-content: center;
    box-sizing: border-box;
    min-width: 18px; height: 18px; padding: 0 5px;
    border-radius: 9px; background: var(--color-danger); color: #fff;
    font-size: 11px; font-weight: 600; line-height: 1;
    margin-left: 6px; vertical-align: 1px;
}

/* ---------- 通用组件 ---------- */
.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; }
/* 胶囊展开指示三角：纯边框绘制，**零字形依赖**。
   原写法是把 `▾`（U+25BE）当文字塞进 <span> 里 —— 在缺该字形的渲染环境
   （部分 Android webview / headless 截图 / 精简字体包）里会退化成小圆点，
   与「下拉」语义完全不符。这里保留 <span> 元素（有 JS / aria 依赖），
   只把字符去掉、改用 border 三角；颜色用 currentColor，跟着胶囊各状态文字色走。 */
.status-select__caret,
.status-pill__caret,
.gender-pill__caret {
    display: inline-block;
    width: 0;
    height: 0;
    margin-left: 4px;
    border-left: 4px solid transparent;
    border-right: 4px solid transparent;
    border-top: 5px solid currentColor;
    vertical-align: middle;
    opacity: .85;
    pointer-events: none;
}
@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); }
/* 性别胶囊的展开三角：几何样式统一在上方 .status-select__caret 的分组规则里定义，
   这里不再重复写 font-size（用文字字号画三角的做法已废弃）。 */
/* 表单里性别胶囊稍大一些，贴合输入区触控尺寸 */
.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); }
}

.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; }
/* 筛选面板里成对排布时，某一项需要「独占左半、右侧留空」：
   用这个空占位撑住右半边（纯布局元素，不含任何表单控件、不参与提交） */
.field-row__spacer { 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__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）时间按钮占一行，动作组整块折到下一行、两端对齐（补录靠左、更新标签+提交靠右）。
   v1.10b：日期框已移回「动作组之外」的独立一行（用户反馈放进动作组反而不规整）。 */
.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; }

/* ---------- 列表工具栏 ---------- */
.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); }
/* v1.10b：「来源渠道 / 会员等级 / 客户类型 / 状态」跟在客户姓名后面、同一行内自动换行，
   不再各占独立列（用户要求「放在名字这一行」） */
.cell-badges { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 4px; margin-left: 8px; vertical-align: middle; }
.cell-date { white-space: nowrap; color: var(--text-2); font-size: 13px; }

/* 搜索结果里「只在跟进内容中命中关键字」的标记（列表 + 手机卡片共用） */
.tag-hit {
    display: inline-flex; align-items: center; flex: 0 0 auto;
    margin-left: 6px; padding: 1px 6px; border-radius: 4px;
    font-size: 11px; line-height: 1.6; white-space: nowrap;
    color: var(--color-info); background: rgba(37, 99, 235, .10);
    border: 1px solid rgba(37, 99, 235, .22);
}

/* 搜索命中跟进内容时，把命中的那句原文摊出来（列表第 1 列与手机卡片共用） */
.hit-snippet {
    margin-top: 3px; max-width: 220px;
    font-size: 12px; line-height: 1.5; color: var(--text-3);
    word-break: break-word;
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
    overflow: hidden;
}
.hit-snippet mark {
    background: rgba(250, 204, 21, .45); color: inherit;
    padding: 0 1px; border-radius: 2px;
}
/* 桌面表格列数多，第 1 列限宽 220px 才不会把「下次跟进 / 操作」挤到换行；
   手机端卡片是通栏的，放开到 100% */
@media (max-width: 767px) {
    .hit-snippet { max-width: 100%; }
}

/* 搜索结果里带出的「回收站客户」（已删除）—— 灰色虚线标 + 标题转灰，
   与现役客户一眼区分；这类行的操作是「恢复」而不是「记跟进」 */
.tag-recycle {
    display: inline-flex; align-items: center; flex: 0 0 auto;
    margin-left: 6px; padding: 1px 6px; border-radius: 4px;
    font-size: 11px; line-height: 1.6; white-space: nowrap;
    color: var(--text-2); background: var(--bg-sunken);
    border: 1px dashed var(--border);
}
.is-recycled .cell-title,
.is-recycled .customer-card__name { color: var(--text-3); }

/* 客户列表列数多（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); min-width: 0; }
/* 主数字：金额（¥340,600 这类长数字）。clamp 让 375px 下自动降档，避免 2×2 栅格里横向溢出；
   tabular-nums 让千分位数字等宽、不跳动。 */
.stat-card__num { font-size: clamp(18px, 5vw, 26px); font-weight: 700; color: var(--color-primary); font-variant-numeric: tabular-nums; letter-spacing: -.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stat-card__label { color: var(--text-2); font-size: 13px; }
/* 副标题：笔数（如「1 笔期次」） */
.stat-card__sub { color: var(--text-3); font-size: 12px; font-variant-numeric: tabular-nums; }
.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; }

/* ---------- 贷款经营（报表页 T5-B：放款 / 收款 / 续期 / 当前逾期） ----------
   四行紧凑数字行：左「指标 + 口径提示」、右「笔数 + 金额」。
   375px 下不横向溢出：每行 flex + space-between，右组允许收缩、金额不折行。 */
.biz-list { list-style: none; margin: 8px 0 0; padding: 0; }
.biz-list__row {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 10px;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
    font-size: 13.5px;
}
.biz-list__row:last-child { border-bottom: 0; }
.biz-list__label { color: var(--text); font-weight: 600; min-width: 0; }
.biz-list__hint {
    display: block;
    margin-top: 2px;
    font-size: 11.5px;
    font-weight: 400;
    color: var(--text-3);
}
.biz-list__val {
    display: flex;
    align-items: baseline;
    gap: 10px;
    flex: 0 0 auto;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}
.biz-list__n { color: var(--text-3); font-weight: 600; font-size: 12.5px; }
.biz-list__amt { color: var(--color-primary); font-weight: 700; }
@media (max-width: 374px) {
    /* 极窄屏：金额可以换行到笔数下面，绝不允许出现横向滚动 */
    .biz-list__val { flex-wrap: wrap; justify-content: flex-end; row-gap: 2px; }
}
/* 贷款经营行下方的口径说明（报表页不加载 loan.css，所以不能复用 .hintline） */
.biz-note { margin: 8px 0 0; font-size: 12px; line-height: 1.6; color: var(--text-3); }

/* ---------- 待办 / 时间线 ---------- */
.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);
}

/* ---------- 详情 ---------- */
/* 详情页头部一行三段：左「客户姓名 + 状态 + 高优先」、中「电话 / 地址 / 城市 / 下次跟进」、
   右「编辑 / 删除」。align-items: flex-start —— 「编辑 / 删除」始终与首行「客户姓名」齐平
   （原来居中对齐，资料一折行按钮就掉到两行文字中间，看着像缩进了一格）。 */
.detail-head__top { display: flex; align-items: flex-start; gap: 8px 10px; margin-bottom: 0; flex-wrap: wrap; }
.detail-head__back { flex: 0 0 auto; }
/* 姓名单独成一个 flex 项（0 1 auto：放得下不抢空间、放不下可压缩内部换行） */
.detail-head__name { font-size: 16px; display: inline-flex; align-items: center; gap: 6px; flex-wrap: wrap; flex: 0 1 auto; min-width: 0; }
/* 资料块：flex-basis 取 0（而不是 auto）：否则该块按“最大内容宽”参与换行判定，
   会把右上角的「编辑 / 删除」挤到第二行去 */
.detail-head__info { flex: 1 1 0; min-width: 0; display: flex; align-items: center; flex-wrap: wrap; gap: 4px 8px; }
.detail-head__item { display: inline-flex; align-items: center; gap: 4px; color: var(--text-2); font-size: 12px; white-space: nowrap; }
/* 资料区按「行」分组（.dh-line）：桌面端 display:contents —— 子项直接进入 .detail-head__info 的
   流式排布，表现与分组前完全一致；手机端（见下方 @media）每行才真正独立成行 */
.dh-line { display: contents; }

/* ---------- 详情页姓名行（v1.9）----------
   结构：客户名称（点击即复制）+ 来源渠道 / 会员等级 / 客户类型 / 状态。
   后四项都是「自绘胶囊 + 透明原生 <select> 覆盖」，点一下弹系统选择器、选中立即生效。 */
/* 名称就是复制按钮：去掉按钮外观，只留文字 + 悬停虚线下划线提示可点 */
.name-copy {
    font: inherit; color: inherit; background: none; border: 0; padding: 0;
    cursor: pointer; text-align: left; white-space: normal; word-break: break-word;
    border-bottom: 1px dashed transparent;
}
@media (hover: hover) {
    .name-copy:hover { border-bottom-color: var(--border-strong); }
}
.name-copy:active { opacity: .6; }
.name-copy:focus-visible { outline: 2px solid var(--color-primary); outline-offset: 2px; border-radius: 3px; }

/* 属性区：桌面端与名称同一行，放不下自动换行 */
.detail-head__attrs { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; flex: 1 1 auto; min-width: 0; }
.attr-face {
    display: inline-flex; align-items: center;
    padding: 2px 9px; border-radius: 999px; font-size: 12px; white-space: nowrap;
    background: var(--bg-elev); color: var(--text); border: 1px solid var(--border-strong);
}
/* 未设置时：虚线边框 + 灰字，作为可点的占位 */
.attr-face.is-empty { color: var(--text-3); border-style: dashed; background: transparent; }
/* 姓名行里的「状态」胶囊要和另外三个属性胶囊同尺寸（用户 2026-10-18 反馈状态偏小）：
   .status-tag 原本无边框、字号也小一号，视觉上比「客户类型」矮一截。
   用透明边框补齐高度差，字号 / 内边距与 .attr-face 完全对齐（仅限姓名行，不影响列表 / 回收站的状态标签）。 */
.detail-head__attrs .status-tag {
    padding: 2px 9px; font-size: 12px;
    border: 1px solid transparent;
    display: inline-flex; align-items: center;
}

/* 顶栏右侧动作区（详情页的「编辑 / 删除」）：排在用户名之后、「退出」之前；
   只有详情页会渲染，列表页不出现。 */
.topbar__actions { display: flex; align-items: center; gap: 6px; flex: 0 0 auto; }
.topbar__actions .btn { white-space: nowrap; }
.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__info { gap: 4px; }
}
/* 手机端（<768px）：头部改成纵向两段式 ——
   第 1 行「客户姓名 + 编辑 / 删除」（v1.4 起按钮不再独占一行：原来按钮在上一行、
   姓名被挤到下一行，白占一整行高度），其下资料区固定 3 行（v1.5）：
   第 2 行「性别 · 电话 · 拨打 · 复制 · 客户类型（贴右，整行不换行）」、
   第 3 行「居住地址（放不下可换行）」、第 4 行「最近跟进 / 下次跟进（只到年月日）」。
   .detail-head__info 用 flex-basis:100% 强制换行，保证「姓名一定与按钮同行」这件事
   不依赖两者宽度，短名字（2 个字）也不会把性别胶囊挤上第一行。
   桌面端（≥768px）完全不受影响。城市与备用电话已按需求从头部去掉。 */
@media (max-width: 767px) {
    /* 第 1 行「客户姓名 + 编辑 / 删除」必须永远同一行。姓名用 flex-basis:0（而不是 auto）：
       否则它按「最大内容宽」参与换行判定，窄屏（≤375px）下 姓名宽 + 按钮宽 会判定放不下，
       整块按钮被丢到第 2 行（白占一行高度）。改成 0 后换行判定只看按钮宽，
       姓名吃掉剩余空间（内部再折行也不会横向溢出）。
       注意不能给容器加 flex-wrap:nowrap —— 那样 flex-basis:100% 的资料块就挤不回第二行了。 */
    .detail-head__top { align-items: center; }
    /* 第 1 行只剩姓名（点击即复制），独占整行 */
    .detail-head__name { order: 0; flex: 1 1 100%; min-width: 0; font-size: 18px; }
    /* 第 2 行：来源渠道 / 会员等级 / 客户类型 / 状态 —— 整段占一行，内部自动折行 */
    .detail-head__attrs { order: 1; flex: 1 1 100%; max-width: 100%; gap: 4px; }
    /* 三个属性胶囊 + 状态胶囊要能挤进 393px 一行（实测 4 个胶囊总宽 ≈349px > 335px 会折行，
       故左右内边距收到 8px、间距收到 4px → ≈327px） */
    .attr-face { font-size: 13px; padding: 3px 8px; min-height: 30px; }
    /* 状态胶囊在手机端同样对齐属性胶囊（原来 12px 无边框，比「客户类型」矮 10px） */
    .detail-head__attrs .status-tag { font-size: 13px; padding: 3px 8px; min-height: 30px; }
    .detail-head__info {
        order: 2;
        flex: 1 1 100%; max-width: 100%;
        flex-direction: column; align-items: stretch; gap: 8px;
        margin-top: 6px; padding-top: 10px;
        border-top: 1px dashed var(--border);
    }
    .dh-line { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; }
    /* 第 2 行整行不换行；「客户类型」贴最右（与上方「编辑 / 删除」、下方日期右缘对齐） */
    .dh-line--contact { flex-wrap: nowrap; gap: 4px 6px; }
    .dh-line--contact .dh-line__end { margin-left: auto; flex: 0 0 auto; }
    /* 第 3 行地址：允许折行 */
    .dh-line--addr .detail-head__item { white-space: normal; align-items: flex-start; }
    .detail-head__item { font-size: 13px; }
    .detail-head__item--phone { font-size: 15px; flex: 0 1 auto; min-width: 0; }
    .detail-head__item--phone .link { font-weight: 600; display: inline-block; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    /* 「拨打 / 复制」用紧凑尺寸压进第 2 行（编辑 / 删除已移到顶栏） */
    .dh-line--contact .btn--sm { min-height: 32px; padding: 5px 10px; font-size: 13px; }
}
/* 超窄屏（≤380px，如 iPhone SE 一代）：第 1 行的「编辑 / 删除」与第 2 行的「拨打 / 复制 /
   客户类型」各收一号，保证「姓名 + 按钮」同一行、「电话 + 拨打 + 复制 + 客户类型」
   同一行且手机号不被省略号截断、也不产生横向滚动 */
@media (max-width: 380px) {
    .dh-line--contact { gap: 4px; }
    .dh-line--contact .btn--sm { padding: 5px 8px; font-size: 12px; }
    .dh-line--contact .dh-line__end { font-size: 11px; padding: 0 7px; }
    .detail-head__item--phone { font-size: 14px; }
}
.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; }

/* ---------- 弹窗 ---------- */
.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; }

/* ---------- 设置页「其他」入口行（手机端回收站唯一入口） ---------- */
.settings-links { margin-bottom: 12px; }
.link-row {
    display: flex; align-items: center; gap: 10px;
    min-height: 52px; padding: 6px 2px;
    border-top: 1px solid var(--border);
    color: inherit; text-decoration: none;
    -webkit-tap-highlight-color: transparent;
}
.link-row:hover, .link-row:active { background: var(--bg-hover); }
.link-row__icon  { flex: 0 0 auto; font-size: 17px; line-height: 1; }
.link-row__label { flex: 0 0 auto; font-weight: 600; }
.link-row__meta  { margin-left: auto; color: var(--text-3); font-size: 13px; text-align: right; }
.link-row__arrow { flex: 0 0 auto; color: var(--text-3); font-size: 18px; line-height: 1; }

/* ---------- 字典 / 导入 ---------- */
.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; }
}

/* ============================================================
   v1.3 / v1.4 细节：顶栏返回 / 待办整行可点 / 列表筛选入口 / 保单删除
   v1.4（2026-10-17 第四轮）：返回热区放大、手机端搜索框收窄与筛选同行、
   保单多色调 + 按钮靠右、详情页头部对齐与编辑按钮字号（见上方各组件处）
   ============================================================ */

/* 内页顶栏最左的「← 返回列表」：取代原来的 logo 图标 + 栏目名（logo 图标已全局移除）。
   点击热区按触控标准放大到 44px 高、左右各留 14px 内边距（原来只有文字那一点，
   拇指很容易点空）；用负左边距抵消内边距，视觉位置基本不动。 */
.topbar__back {
    display: inline-flex; align-items: center; gap: 4px;
    font-weight: 600; color: var(--text);
    min-height: 44px; padding: 8px 14px; margin-left: -8px;
    border-radius: var(--radius-sm);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.topbar__back:hover, .topbar__back:active { background: var(--bg-sunken); }

/* 待办：整行任意位置都能点进详情 —— 用「拉伸点击热区」把 <a> 覆盖到整个 li
   （含右侧状态胶囊与 li 的内边距），不需要额外 JS，也不改 DOM 结构 */
.todo-list__item { position: relative; }
.todo-list__main::after { content: ''; position: absolute; inset: 0; }
.todo-mini li { position: relative; }
.todo-mini a::after { content: ''; position: absolute; inset: 0; }

/* 列表页：筛选入口挪到搜索框正下方；面板底部的「确定」负责应用筛选 */
.search-bar .filter-toggle { flex: 0 0 auto; }
.filters__actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 2px; }

@media (max-width: 767px) {
    /* 手机端：第一行 = 左「筛选」+ 右侧「搜索框 + 搜索」（搜索框撑满剩余空间，搜索按钮略小一号）。
       用 order 重排、不改 DOM 顺序 —— 桌面端把这一组搬进顶栏时仍是「搜索框 + 搜索 + 筛选」。 */
    .search-bar { flex-wrap: nowrap; align-items: center; gap: 8px; }
    .search-bar .filter-toggle { order: 1; flex: 0 0 auto; margin-left: 0; }
    .search-bar .input { order: 2; flex: 1 1 auto; width: auto; min-width: 0; margin-left: auto; }
    .search-bar .btn--primary { order: 3; flex: 0 0 auto; min-height: 38px; padding: 7px 12px; font-size: 14px; }
    .filters__actions .btn { width: 100%; }
    /* 手机端隐藏「导出 CSV」（桌面端保留） */
    .toolbar-row .export-csv { display: none; }
}
