/**
 * 蓝培CRM 统一设计系统 v4「墨韵 · 纸感」(2026-10-18)
 * v4：暖纸灰底 + 朱砂/墨红双色 + 衬线大数字 + 尺度跳跃 + 卡片悬浮反馈
 * 兼容：全部类名与 v3 一致（30 页依赖）；layui 覆盖层同步 v4 色值
 */

:root {
    /* 品牌色：墨红 + 朱砂 */
    --brand:        #8b0000;
    --brand-dark:   #6f0000;
    --brand-2:      #c02c38;
    --brand-light:  #faecec;
    --brand-grad:   linear-gradient(135deg, #c02c38 0%, #8b0000 58%, #730000 100%);

    /* 语义色 */
    --blue:   #2f6fed;
    --green:  #1a9e6e;
    --orange: #e8932c;
    --red:    #e0483d;

    /* 中性色（暖纸调） */
    --ink:    #26231f;
    --ink-2:  #57534c;
    --ink-3:  #948e83;
    --line:   #eae6e0;
    --bg:     #f7f6f4;
    --bg-2:   #f1efec;
    --white:  #ffffff;

    /* 圆角 / 阴影 */
    --r-sm: 8px;
    --r:    14px;
    --r-lg: 18px;
    --shadow-sm: 0 1px 2px rgba(60,50,40,.05);
    --shadow:    0 1px 2px rgba(60,50,40,.04), 0 2px 12px rgba(60,50,40,.05);
    --shadow-md: 0 8px 28px rgba(60,50,40,.11);
    --shadow-lg: 0 20px 56px rgba(45,35,30,.18);

    /* 动效节奏 */
    --dur: .18s;
    --ease: cubic-bezier(.4, 0, .2, 1);

    /* 侧栏：墨色分层 */
    --side-bg:       #22262d;
    --side-bg-deep:  #1a1d22;
    --side-text:     #babfc8;
    --side-text-dim: #8a93a2;

    --side-w: 220px;
    --head-h: 60px;

    /* 衬线展示字体（仅数字/大标题点缀） */
    --serif: Georgia, "Times New Roman", "Noto Serif SC", "Songti SC", "SimSun", serif;
}

/* ========== 基础 ========== */
* { -webkit-font-smoothing: antialiased; }
html, body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
                 "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
    color: var(--ink);
    font-size: 14px;
}
::selection { background: rgba(139,0,0,.14); }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: #d4cec5; border-radius: 8px; }
::-webkit-scrollbar-thumb:hover { background: #bfb7aa; }
::-webkit-scrollbar-track { background: transparent; }

/* ========== 登录页（v4 纸感 + 朱砂光晕） ========== */
.hx-login-wrap {
    position: fixed; inset: 0;
    background: linear-gradient(150deg, #221012 0%, #38100f 42%, #6f0000 100%);
    display: flex; align-items: center; justify-content: center;
    padding: 24px; box-sizing: border-box;
}
.hx-login-wrap::before {
    content: ''; position: absolute; inset: 0;
    background:
      radial-gradient(circle at 16% 20%, rgba(255,190,160,.10), transparent 42%),
      radial-gradient(circle at 84% 80%, rgba(255,120,110,.13), transparent 45%);
}
.hx-login-wrap::after { /* 纸感细网格，中央渐隐 */
    content: ''; position: absolute; inset: 0; pointer-events: none;
    background-image:
      linear-gradient(rgba(255,255,255,.03) 1px, transparent 1px),
      linear-gradient(90deg, rgba(255,255,255,.03) 1px, transparent 1px);
    background-size: 40px 40px;
    -webkit-mask-image: radial-gradient(ellipse at center, #000 28%, transparent 74%);
    mask-image: radial-gradient(ellipse at center, #000 28%, transparent 74%);
}

/* 分栏容器 */
.hx-login-panel {
    position: relative; z-index: 1;
    width: 880px; max-width: 100%;
    display: flex; border-radius: 20px; overflow: hidden;
    box-shadow: var(--shadow-lg);
}

/* 左侧品牌区 */
.hx-login-brand {
    flex: 1 1 46%; min-width: 0;
    background:
      radial-gradient(circle at 82% -8%, rgba(255,150,130,.30), transparent 48%),
      linear-gradient(160deg, #a01218 0%, #730000 100%);
    color: #fff; padding: 52px 44px;
    display: flex; flex-direction: column;
}
.hx-brand-mark {
    width: 48px; height: 48px; border-radius: 13px;
    background: rgba(255,255,255,.14);
    border: 1px solid rgba(255,255,255,.26);
    display: flex; align-items: center; justify-content: center;
    font-family: var(--serif); font-size: 23px; font-weight: 800;
    backdrop-filter: blur(4px); margin-bottom: 18px;
}
.hx-login-brand-title { font-size: 27px; font-weight: 800; letter-spacing: 5px; }
.hx-login-brand-sub { font-size: 13px; color: rgba(255,255,255,.72); margin-top: 9px; letter-spacing: 1.5px; }
.hx-login-points { list-style: none; margin: 42px 0 0; padding: 0; }
.hx-login-points li {
    display: flex; align-items: center; gap: 10px;
    font-size: 14px; color: rgba(255,255,255,.9); padding: 9px 0;
}
.hx-login-points li i {
    width: 6px; height: 6px; border-radius: 50%; flex: 0 0 6px;
    background: #ffb3a8; box-shadow: 0 0 10px rgba(255,179,168,.85);
}
.hx-login-brand .hx-brand-foot {
    margin-top: auto; font-size: 12px; color: rgba(255,255,255,.5); letter-spacing: .5px;
}

/* 右侧表单卡 */
.hx-login-box {
    flex: 1 1 54%; min-width: 0;
    background: var(--white);
    padding: 52px 46px 40px; text-align: center;
    display: flex; flex-direction: column; justify-content: center;
}
.hx-login-box .hx-logo { font-size: 24px; font-weight: 800; color: var(--brand); margin-bottom: 8px; letter-spacing: 3px; display: none; }
.hx-login-box .hx-subtitle { font-size: 13px; color: var(--ink-3); margin-bottom: 30px; letter-spacing: 1px; display: none; }
.hx-login-box .layui-form-item { margin-bottom: 18px; }
.hx-login-box .layui-input {
    height: 46px; border-radius: var(--r-sm); font-size: 14px; padding: 0 15px;
    border: 1px solid var(--line); transition: all var(--dur) var(--ease);
}
.hx-login-box .layui-input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(139,0,0,.1); }
.hx-login-box .layui-btn {
    width: 100%; height: 46px; border-radius: var(--r-sm); font-size: 16px;
    background: var(--brand-grad); border: none; letter-spacing: 4px;
    box-shadow: 0 8px 20px rgba(139,0,0,.3);
    transition: all var(--dur) var(--ease);
}
.hx-login-box .layui-btn:hover { filter: brightness(1.08); transform: translateY(-1px); box-shadow: 0 10px 24px rgba(139,0,0,.36); }
.hx-login-box .layui-btn:active { transform: translateY(0); }
.hx-login-tips { margin-top: 22px; font-size: 12px; color: var(--ink-3); letter-spacing: .5px; }

@media (max-width: 860px) {
    .hx-login-brand { display: none; }
    .hx-login-panel { width: 420px; border-radius: var(--r-lg); }
    .hx-login-box { padding: 40px 32px 32px; }
    .hx-login-box .hx-logo, .hx-login-box .hx-subtitle { display: block; }
}

/* ========== 主框架 ========== */
.hx-layout { position: fixed; inset: 0; }

.hx-header {
    height: var(--head-h); background: rgba(255,255,255,.92);
    backdrop-filter: blur(8px);
    border-bottom: 1px solid var(--line);
    display: flex; align-items: center; padding: 0 22px;
    position: fixed; top: 0; left: 0; right: 0; z-index: 1000;
}
.hx-header .hx-logo-sm {
    font-size: 19px; font-weight: 800; color: var(--brand);
    margin-right: 16px; white-space: nowrap; letter-spacing: 1px;
    display: flex; align-items: center; gap: 9px;
}
.hx-header .hx-logo-sm::before {
    content: ''; width: 22px; height: 22px; border-radius: 7px;
    background: var(--brand-grad); flex: 0 0 22px;
    box-shadow: inset 0 0 0 1.5px rgba(255,255,255,.28), 0 3px 8px rgba(139,0,0,.3);
}
/* 当前页标题（框架顶栏） */
.hx-header .hx-crumb {
    padding-left: 16px; border-left: 1px solid var(--line);
    font-size: 13px; color: var(--ink-3); letter-spacing: .5px;
}
.hx-header .hx-crumb b { color: var(--ink); font-weight: 600; font-size: 14px; }
.hx-header .hx-header-right { margin-left: auto; display: flex; align-items: center; gap: 18px; }
.hx-header .hx-user-name { color: var(--ink-2); font-size: 14px; display: none; align-items: center; }
.hx-header .hx-user-name i { margin-right: 5px; color: var(--ink-3); }
.hx-header .hx-logout { color: var(--ink-3); cursor: pointer; font-size: 14px; display: none; align-items: center; transition: color var(--dur) var(--ease); }
.hx-header .hx-logout:hover { color: var(--brand); }

/* 侧边导航：墨色分组式 */
.hx-side {
    position: fixed; top: var(--head-h); left: 0; bottom: 0;
    width: var(--side-w);
    background: linear-gradient(180deg, var(--side-bg) 0%, var(--side-bg-deep) 100%);
    border-right: 1px solid rgba(255,255,255,.04);
    overflow-y: auto; z-index: 999; transition: width .3s;
    display: flex; flex-direction: column;
}
.hx-side .layui-nav { background: none; flex: 1 1 auto; }
/* 分组小标题 */
.hx-side .hx-nav-label {
    padding: 18px 28px 7px; font-size: 10.5px; color: #676e7c;
    letter-spacing: 2.5px; user-select: none; text-transform: uppercase;
}
.hx-side .layui-nav .layui-nav-item > a {
    color: var(--side-text); padding: 0 20px; height: 44px; line-height: 44px; font-size: 14px;
    margin: 1px 8px; border-radius: 9px; transition: all var(--dur) var(--ease);
}
.hx-side .layui-nav .layui-nav-item > a:hover { color: #fff; background: rgba(255,255,255,.07); }
.hx-side .layui-nav .layui-nav-item > a i { margin-right: 9px; font-size: 16px; }
.hx-side .layui-nav-tree .layui-nav-bar { display: none; }
.hx-side .layui-nav .layui-nav-child { background: transparent; padding: 0 0 2px; }
.hx-side .layui-nav .layui-nav-child a {
    padding-left: 46px; color: var(--side-text-dim); height: 40px; line-height: 40px; font-size: 13.5px;
    margin: 1px 8px; border-radius: 9px; transition: all var(--dur) var(--ease);
}
.hx-side .layui-nav .layui-nav-child a:hover { color: #fff; background: rgba(255,255,255,.05); }
/* 选中态：品牌红胶囊 + 白字；展开的分组标题仅提亮 */
.hx-side .layui-nav-tree .layui-this > a,
.hx-side .layui-nav-tree .layui-nav-child dd.layui-this a {
    color: #fff !important; background: var(--brand) !important;
}
.hx-side .layui-nav-tree .layui-this > a { box-shadow: 0 4px 14px rgba(139,0,0,.4); }
.hx-side .layui-nav-tree .layui-nav-itemed > a {
    color: #fff !important; background: rgba(255,255,255,.06) !important;
}
.hx-side .layui-nav-tree .layui-nav-child dd.layui-this a::before {
    content: ''; display: inline-block; width: 6px; height: 6px; border-radius: 50%;
    background: #ff9d92; margin-right: 8px; vertical-align: middle;
}

/* 侧栏底部用户卡 */
.hx-side-footer {
    flex: 0 0 auto; margin: 10px; padding: 12px;
    background: rgba(255,255,255,.05); border: 1px solid rgba(255,255,255,.08);
    border-radius: var(--r);
}
.hx-avatar {
    width: 36px; height: 36px; border-radius: 50%; flex: 0 0 36px;
    background: var(--brand-grad); color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-size: 15px; font-weight: 700;
    box-shadow: inset 0 0 0 1.5px rgba(255,255,255,.25);
}
.hx-side-footer .hx-side-user { min-width: 0; flex: 1; }
.hx-side-footer .hx-side-name {
    font-size: 13.5px; color: #fff; font-weight: 600; cursor: pointer;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    transition: color var(--dur) var(--ease);
}
.hx-side-footer .hx-side-name:hover { color: #ff9d92; }
.hx-side-footer .hx-side-role { font-size: 11px; color: var(--side-text-dim); margin-top: 2px; }
.hx-side-footer .hx-side-logout {
    color: var(--side-text-dim); cursor: pointer; font-size: 15px; padding: 6px; border-radius: 8px;
    transition: all var(--dur) var(--ease);
}
.hx-side-footer .hx-side-logout:hover { color: #fff; background: rgba(255,255,255,.08); }

.hx-body {
    position: fixed; top: var(--head-h); left: var(--side-w); right: 0; bottom: 0;
    overflow: hidden; transition: left .3s;
}
.hx-body iframe { width: 100%; height: 100%; border: none; background: var(--bg); }

/* ========== 内容页 ========== */
.hx-page {
    padding: 18px 20px; background: var(--bg); min-height: 100%; box-sizing: border-box;
    animation: hxPageIn .4s var(--ease) both;
}
@keyframes hxPageIn {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: none; }
}
.hx-page-title {
    font-size: 22px; font-weight: 800; color: var(--ink);
    margin-bottom: 16px; display: flex; align-items: center;
    letter-spacing: .5px;
}
.hx-page-title::before {
    content: ''; display: inline-block; width: 4px; height: 20px;
    background: var(--brand-grad); border-radius: 3px; margin-right: 12px;
}
.hx-page-title span { font-size: 13px; color: var(--ink-3); font-weight: normal; margin-left: 12px; letter-spacing: 0; }

/* ========== 卡片 ========== */
.hx-card {
    background: var(--white); border-radius: var(--r); padding: 16px;
    margin-bottom: 12px; border: 1px solid var(--line); box-shadow: var(--shadow-sm);
    transition: transform var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.hx-card:hover { box-shadow: var(--shadow); }
.hx-card-title {
    font-size: 15px; font-weight: 700; color: var(--ink);
    margin: -2px 0 12px; padding-bottom: 10px;
    border-bottom: 1px solid var(--line);
    display: flex; align-items: center;
}
.hx-card-title::before {
    content: ''; width: 3px; height: 15px; background: var(--brand-grad);
    border-radius: 2px; margin-right: 9px;
}

/* ========== 统计卡片（v4：衬线大数字） ========== */
.hx-stat-cards { display: flex; gap: 14px; flex-wrap: wrap; margin-bottom: 14px; }
.hx-stat-card {
    flex: 1; min-width: 150px; background: var(--white);
    border-radius: var(--r); padding: 18px 16px 16px;
    border: 1px solid var(--line); box-shadow: var(--shadow-sm);
    position: relative; overflow: hidden;
    transition: transform var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.hx-stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.hx-stat-card .hx-stat-value {
    font-family: var(--serif);
    font-size: 34px; font-weight: 700; color: var(--ink);
    line-height: 1; margin-bottom: 8px; font-variant-numeric: tabular-nums;
    letter-spacing: -.5px;
}
.hx-stat-card .hx-stat-label { font-size: 13px; color: var(--ink-3); letter-spacing: .3px; }
.hx-stat-card .hx-stat-icon { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); font-size: 30px; color: #f0ede8; }
.hx-stat-card::after {
    content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 4px;
    background: var(--brand-grad);
}
.hx-stat-card:nth-child(2)::after { background: linear-gradient(180deg, #4d82f4, var(--blue)); }
.hx-stat-card:nth-child(3)::after { background: linear-gradient(180deg, #2cb987, var(--green)); }
.hx-stat-card:nth-child(4)::after { background: linear-gradient(180deg, #f2a94e, var(--orange)); }

/* ========== 工具栏 ========== */
.hx-toolbar {
    background: var(--white); border-radius: var(--r);
    padding: 11px 14px; margin-bottom: 12px;
    border: 1px solid var(--line); box-shadow: var(--shadow-sm);
    display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
}
.hx-toolbar .layui-input { height: 34px; border-radius: var(--r-sm); border-color: var(--line); }
.hx-toolbar .layui-input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(139,0,0,.08); }

/* ========== 表单控件（layui） ========== */
.layui-input, .layui-textarea, .layui-select {
    border-color: var(--line) !important; border-radius: var(--r-sm) !important;
    transition: all .18s;
}
.layui-input:hover, .layui-textarea:hover { border-color: #cfc7ba !important; }
.layui-input:focus, .layui-textarea:focus { border-color: var(--brand) !important; box-shadow: 0 0 0 3px rgba(139,0,0,.09) !important; outline: none; }
.layui-form-select dl dd.layui-this { background-color: var(--brand); }

/* ========== 按钮（layui） ========== */
.layui-btn { border-radius: var(--r-sm); font-weight: 500; transition: all .18s; }
.layui-btn:not(.layui-btn-primary):not(.layui-btn-normal):not(.layui-btn-warm):not(.layui-btn-danger) {
    background: var(--brand);
}
.layui-btn:not(.layui-btn-primary):not(.layui-btn-normal):not(.layui-btn-warm):not(.layui-btn-danger):hover {
    background: var(--brand-dark); filter: none;
}
.layui-btn-primary { border-color: var(--line); color: var(--ink-2); background: var(--white); }
.layui-btn-primary:hover { border-color: var(--brand); color: var(--brand); background: var(--brand-light); }
.layui-btn-normal { background: var(--blue); }
.layui-btn-normal:hover { background: #2560d4; }
.layui-btn-warm { background: var(--orange); }
.layui-btn-warm:hover { background: #d6841f; }
.layui-btn-danger { background: var(--red); }
.layui-btn-danger:hover { background: #cf3a30; }

/* ========== 表格（layui table 组件） ========== */
.hx-page .layui-table-view { border-radius: var(--r); overflow: hidden; border: 1px solid var(--line); box-shadow: var(--shadow-sm); }
.layui-table-view .layui-table-header { border-bottom: 1px solid var(--line); }
.layui-table-view .layui-table th {
    background: var(--bg-2) !important; color: var(--ink-2);
    font-weight: 600; font-size: 13px;
}
.layui-table[lay-even] tr:nth-child(even) { background: #faf9f6; }
.layui-table-view .layui-table td, .layui-table-view .layui-table th { border-color: var(--line); }
.layui-table-view .layui-table-body tr { transition: background .15s; }
.layui-table-view .layui-table-body tr:hover,
.layui-table-hover { background: var(--brand-light) !important; }
.layui-table-page { border-top: 1px solid var(--line); }
.layui-laypage .layui-laypage-curr .layui-laypage-em { background: var(--brand); }
.layui-laypage a:hover { color: var(--brand); }
.layui-table-tool { background: var(--white); border-color: var(--line); }

/* 原生 table（部分页面用 layui-table 直接拼） */
.hx-page > .layui-table,
.hx-card .layui-table { border-radius: var(--r); overflow: hidden; border: 1px solid var(--line); }
.hx-page .layui-table th { background: var(--bg-2); color: var(--ink-2); font-weight: 600; }
.hx-page .layui-table td, .hx-page .layui-table th { border-color: var(--line); padding: 5px 10px; }

/* ========== 弹窗 / layer ========== */
.layui-layer { border-radius: var(--r) !important; box-shadow: var(--shadow-md) !important; overflow: hidden; }
.layui-layer .layui-layer-title {
    background: var(--white) !important; color: var(--ink) !important;
    border-bottom: 1px solid var(--line) !important; font-weight: 600; height: 48px !important; line-height: 48px !important;
}
.layui-layer-btn .layui-layer-btn0 { background: var(--brand) !important; border-color: var(--brand) !important; }
.layui-layer-btn .layui-layer-btn0:hover { background: var(--brand-dark) !important; }
.layui-layer-ico { background-position: -23px -161px; } /* 关闭 */
.layui-layer-tab .layui-layer-title span.layui-this { background: var(--brand); }

/* ========== 标签 ========== */
.hx-tag { display: inline-block; padding: 2px 10px; border-radius: 5px; font-size: 12px; color: #fff; }
.layui-badge, .layui-badge-dot, .layui-badge-rim { border-radius: 4px; }

/* ========== 按钮组 ========== */
.hx-btn-group { display: flex; gap: 4px; flex-wrap: wrap; }
.hx-btn-group .layui-btn-xs { height: 26px; line-height: 26px; padding: 0 9px; font-size: 12px; }

/* ========== 详情 ========== */
.hx-detail-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(215px,1fr)); gap: 8px 16px; }
.hx-detail-item { display: flex; align-items: baseline; font-size: 14px; }
.hx-detail-item .hx-label { color: var(--ink-3); min-width: 68px; flex-shrink: 0; }
.hx-detail-item .hx-value { color: var(--ink); font-weight: 500; }

/* ========== 跟进记录 ========== */
.hx-follow-item {
    border-left: 3px solid var(--brand); padding: 10px 14px; margin-bottom: 10px;
    background: var(--bg-2); border-radius: 0 var(--r-sm) var(--r-sm) 0;
}
.hx-follow-item .hx-follow-meta { font-size: 12px; color: var(--ink-3); margin-bottom: 6px; }
.hx-follow-item .hx-follow-content { font-size: 14px; color: var(--ink); line-height: 1.6; }

/* ========== 录音 ========== */
.hx-audio-wrap { display: flex; align-items: center; gap: 8px; }
.hx-audio-wrap audio { height: 32px; }

/* ========== 图表柱 ========== */
.hx-chart-bar { display: flex; align-items: flex-end; gap: 6px; height: 200px; padding: 6px 0; }
.hx-chart-bar .hx-bar {
    flex: 1; background: linear-gradient(180deg, #c02c38, #8b0000);
    border-radius: 5px 5px 0 0; min-height: 4px; position: relative;
    transition: all .3s; cursor: pointer;
}
.hx-chart-bar .hx-bar:hover { filter: brightness(1.12); }
.hx-chart-bar .hx-bar-label { position: absolute; bottom: -22px; left: 50%; transform: translateX(-50%); font-size: 11px; color: var(--ink-3); white-space: nowrap; }
.hx-chart-bar .hx-bar-value { position: absolute; top: -20px; left: 50%; transform: translateX(-50%); font-size: 11px; color: var(--ink-2); font-weight: 600; }

/* ========== 响应式 ========== */
/* 断点说明：所有内容页统一渲染在 dashboard.html 的 iframe 内，侧栏固定 220px，
   920px 窗口下内容区仅约 690px。因此"紧凑/窄屏"断点必须按内容区宽度设定，
   不能沿用手机断点（768px）去约束桌面端——否则统计卡片、工具栏会被误判为手机而竖排，
   页面被无谓拉长。 */

/* 侧栏折叠：只作用于外层框架 dashboard.html（内容页内不存在 .hx-side/.hx-body） */
@media (max-width: 768px) {
    .hx-side { width: 0; overflow: hidden; }
    .hx-body { left: 0; }
    /* 侧栏折叠后，用户操作回退到顶栏 */
    .hx-side-footer { display: none; }
    .hx-header .hx-user-name, .hx-header .hx-logout { display: inline-flex; }
}

/* 紧凑内容区（≈690px@920px窗口起）：收紧间距、工具栏保持横排可换行、统计卡片两列起排 */
@media (max-width: 920px) {
    .hx-page { padding: 12px; }
    .hx-page-title { font-size: 18px; margin-bottom: 12px; }
    .hx-page-title::before { height: 16px; }
    .hx-card { padding: 12px; margin-bottom: 8px; }
    .hx-card-title { margin-bottom: 8px; padding-bottom: 6px; }

    /* 工具栏：保持横排，仅允许子项收缩换行，避免撑破容器（不要竖排堆叠） */
    .hx-toolbar { padding: 8px 10px; gap: 8px; }
    .hx-toolbar > * { max-width: 100%; }
    .hx-toolbar .layui-input, .hx-toolbar .layui-input-inline, .hx-toolbar select { min-width: 0; max-width: 100%; }

    /* 统计卡片：紧凑宽度下每行 2~3 个，而不是一列到底 */
    .hx-stat-cards { gap: 10px; margin-bottom: 10px; }
    .hx-stat-card { min-width: 140px; padding: 12px; }
    .hx-stat-card .hx-stat-value { font-size: 26px; margin-bottom: 5px; }
    .hx-stat-card .hx-stat-icon { font-size: 26px; right: 10px; }

    /* 原生宽表：宿主容器横向滚动，宽表不再被挤压换行；窄表仍铺满整行。
       整块置于 @supports 内：若浏览器不支持 :has()，则滚动容器与表格规则一起失效，
       退化为现状（表格自行换行），不会出现"表格溢出容器"的回归。 */
    @supports selector(:has(*)) {
        .hx-card:has(> table),
        .hx-page > .layui-form:has(> table) { overflow-x: auto; }
        .hx-card > table.layui-table,
        .hx-page > .layui-form > table.layui-table { width: auto; min-width: 100%; border-radius: var(--r-sm); }
        .hx-card > table.layui-table th, .hx-card > table.layui-table td,
        .hx-page > .layui-form > table.layui-table th,
        .hx-page > .layui-form > table.layui-table td { white-space: nowrap; }
    }

    /* 详情网格与图表：压缩最小列宽与高度，减少纵向长度 */
    .hx-detail-grid { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 8px 12px; }
    .hx-detail-item .hx-label { min-width: 64px; }
    .hx-chart-bar { height: 160px; }
}

/* 通用表格横向滚动容器：供各页面按需包裹宽表。
   宿主容器自身横向滚动 → 窄表铺满整行、宽表在容器内滚动而不挤破页面。 */
.hx-table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; max-width: 100%; }
.hx-table-wrap > table { min-width: 100%; }
.hx-table-wrap > table.layui-table { width: auto; min-width: 100%; border-radius: var(--r-sm); }
.hx-table-wrap > table.layui-table th,
.hx-table-wrap > table.layui-table td { white-space: nowrap; }

/* 手机宽度：真正的小屏才单列堆叠 */
@media (max-width: 520px) {
    .hx-stat-cards { flex-direction: column; }
    .hx-stat-card { min-width: 0; }
    .hx-toolbar { flex-direction: column; align-items: stretch; }
    .hx-toolbar .layui-input, .hx-toolbar .layui-input-inline, .hx-toolbar select, .hx-toolbar .layui-btn { width: 100%; }
    .hx-detail-grid { grid-template-columns: 1fr; }
}

/* ========== 强制覆盖 layui 默认主色（同步 v4 色值） ========== */
/* 侧边导航选中 */
.layui-nav-tree .layui-this > a,
.layui-nav-tree .layui-nav-itemed > a,
.layui-nav-tree .layui-nav-child dd.layui-this a {
    background-color: #8b0000 !important; color: #fff !important;
}
.layui-nav-tree .layui-nav-bar { background-color: #8b0000 !important; }
/* 主按钮：覆盖 layui 蓝绿 */
.layui-btn,
.layui-btn[class*="layui-bg"] { background-color: #8b0000 !important; }
.layui-btn:hover { background-color: #6f0000 !important; }
.layui-btn-primary, .layui-btn-primary:hover { background-color: #fff !important; color: #8b0000 !important; }
.layui-btn-normal { background-color: #2f6fed !important; }
.layui-btn-warm { background-color: #e8932c !important; }
.layui-btn-danger { background-color: #e0483d !important; }
/* 分页 / 表单选中 / 开关 / 单选复选 / 滑块 */
.layui-laypage .layui-laypage-curr .layui-laypage-em { background-color: #8b0000 !important; }
.layui-laypage input:focus, .layui-laypage select:focus { border-color: #8b0000 !important; }
.layui-form-select dl dd.layui-this { background-color: #8b0000 !important; }
.layui-form-radio > i:hover, .layui-form-radioed > i, .layui-form-radioed { color: #8b0000 !important; }
.layui-form-checked[lay-skin="primary"] > i { border-color: #8b0000 !important; background-color: #8b0000 !important; color: #fff !important; }
.layui-form-checked i, .layui-form-checked:hover i { color: #8b0000 !important; }
.layui-form-onswitch { border-color: #8b0000 !important; background-color: #8b0000 !important; }
.layui-slider-input-btn i:hover, .layui-slider-wrap-btn { color: #8b0000 !important; }
/* Tab 选中 */
.layui-tab-brief > .layui-tab-title .layui-this { color: #8b0000 !important; }
.layui-tab-brief > .layui-tab-title .layui-this::after { border-color: #8b0000 !important; }
.layui-tab-title .layui-this::after { border-bottom-color: #8b0000 !important; }
/* 进度条 */
.layui-progress-bar { background-color: #8b0000 !important; }
/* 面包屑链接 */
.layui-breadcrumb a:hover { color: #8b0000 !important; }

/* ========== 动效可达性 & 焦点 ========== */
:focus-visible { outline: 2px solid rgba(139,0,0,.45); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        transition-duration: .01ms !important;
        animation-duration: .01ms !important;
        animation: none !important;
    }
    .hx-page { animation: none; }
}

/* ========== v3b 扩展组件（日志页 / 筛选Chip / 咨询气泡 / 图片网格 / 标签色板） ========== */

/* 筛选 / 分段 Chips */
.hx-chip {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 5px 14px; border-radius: 17px; font-size: 13px;
    color: var(--ink-2); background: var(--white);
    border: 1px solid var(--line); cursor: pointer; user-select: none;
    transition: all var(--dur) var(--ease);
}
.hx-chip:hover { border-color: var(--brand); color: var(--brand); }
.hx-chip.hx-chip-on { background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 600; box-shadow: 0 3px 10px rgba(139,0,0,.25); }

/* 日志列表 */
.hx-log-row {
    display: flex; gap: 12px; align-items: flex-start;
    background: var(--white); border: 1px solid var(--line);
    border-radius: var(--r); padding: 11px 15px; margin-bottom: 9px;
    box-shadow: var(--shadow-sm); transition: box-shadow var(--dur) var(--ease), transform var(--dur) var(--ease);
}
.hx-log-row:hover { box-shadow: var(--shadow); transform: translateY(-1px); }
.hx-log-main { flex: 1; min-width: 0; }
.hx-log-title { font-size: 13.5px; font-weight: 600; color: var(--ink); line-height: 1.5; word-break: break-all; }
.hx-log-diff { font-size: 12px; color: var(--ink-2); line-height: 1.55; margin-top: 3px; word-break: break-all; }
.hx-log-meta { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.hx-log-user { font-size: 12px; color: var(--brand-2); font-weight: 600; }
.hx-log-tag { font-size: 11px; color: var(--ink-2); background: var(--bg-2); padding: 2px 7px; border-radius: 4px; }
.hx-log-time { flex: 0 0 auto; font-size: 11px; color: var(--ink-3); font-variant-numeric: tabular-nums; padding-top: 2px; }

/* 咨询对话气泡（role 格式：抖音会话） */
.consult-bubbles { display: flex; flex-direction: column; gap: 12px; padding: 4px 0; }
.consult-bubble { max-width: 78%; display: flex; flex-direction: column; gap: 2px; }
.consult-bubble .cb-role { font-size: 11px; color: var(--ink-3); }
.consult-bubble .cb-body {
    padding: 9px 13px; border-radius: 12px; font-size: 13px;
    line-height: 1.6; word-break: break-all; box-shadow: var(--shadow-sm);
}
.consult-bubble .cb-body a { color: var(--blue); }
.consult-bubble .cb-time { font-size: 10.5px; color: var(--ink-3); }
.consult-bubble.cb-cust { align-self: flex-end; align-items: flex-end; }
.consult-bubble.cb-cust .cb-role { color: var(--brand-2); font-weight: 600; }
.consult-bubble.cb-cust .cb-body { background: var(--brand-light); border: 1px solid rgba(139,0,0,.12); border-bottom-right-radius: 3px; }
.consult-bubble.cb-agent { align-self: flex-start; align-items: flex-start; }
.consult-bubble.cb-agent .cb-role { color: var(--green); font-weight: 600; }
.consult-bubble.cb-agent .cb-body { background: #edf6f0; border: 1px solid #d9e8de; border-bottom-left-radius: 3px; }
.consult-bubble.cb-ai { align-self: flex-start; align-items: flex-start; }
.consult-bubble.cb-ai .cb-role { color: var(--blue); font-weight: 600; }
.consult-bubble.cb-ai .cb-body { background: #edf3fd; border: 1px solid #d9e5f7; border-bottom-left-radius: 3px; }
.consult-bubble.cb-system { align-self: center; align-items: center; max-width: 92%; }
.consult-bubble.cb-system .cb-body { background: var(--bg-2); border: 1px dashed var(--line); color: var(--ink-3); font-size: 12px; border-radius: 6px; }

/* 跟进图片网格 */
.hx-img-grid { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.hx-img-grid:empty { display: none; }
.hx-img-grid img {
    width: 92px; height: 92px; object-fit: cover; border-radius: 10px;
    border: 1px solid var(--line); cursor: zoom-in;
    transition: transform var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.hx-img-grid img:hover { transform: scale(1.04); box-shadow: var(--shadow-md); }

/* 标签颜色色板 */
.hx-palette { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
.hx-swatch {
    width: 30px; height: 30px; border-radius: 9px; cursor: pointer;
    border: 2px solid transparent; box-shadow: inset 0 0 0 2px rgba(255,255,255,.6);
    transition: transform var(--dur) var(--ease), border-color var(--dur) var(--ease);
}
.hx-swatch:hover { transform: scale(1.12); }
.hx-swatch.hx-swatch-on { border-color: var(--ink); box-shadow: inset 0 0 0 2px #fff, 0 2px 8px rgba(0,0,0,.18); }

/* 侧边栏彻底清除 layui 默认青绿色选中态 */
.hx-side .layui-nav-tree .layui-nav-item.layui-this,
.hx-side .layui-nav-tree .layui-nav-child dd.layui-this { background: transparent !important; }
.hx-side .layui-nav-tree .layui-nav-child dd.layui-this a { background: var(--brand) !important; }
.hx-side .layui-nav-tree .layui-nav-child dd.layui-this::after,
.hx-side .layui-nav-tree .layui-nav-bar { display: none !important; }
