/* kzhcrm 后台基础样式 */
:root {
  --bg: #f4f6fa;
  --card: #fff;
  --border: #e3e8f0;
  --primary: #2f6bff;
  --text: #1f2733;
  --muted: #7a8699;
  --danger: #e5484d;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg); color: var(--text); font-size: 14px;
}
a { color: var(--primary); text-decoration: none; }

/* 布局 */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: 200px; background: #1b2230; color: #cdd5e1;
  padding: 18px 0; flex-shrink: 0;
}
.sidebar .logo { padding: 0 20px 16px; font-weight: 700; color: #fff; font-size: 16px; border-bottom: 1px solid #2a3345; }
.sidebar nav a {
  display: block; padding: 9px 20px 9px 36px; color: #cdd5e1; cursor: pointer;
  font-size: 13px;
}
.sidebar nav a:hover, .sidebar nav a.active { background: #2a3345; color: #fff; border-left: 3px solid var(--primary); }
/* 菜单二级分组：标题（图标+箭头）与可折叠项 */
.sidebar .nav-group-title {
  display: flex; align-items: center; justify-content: space-between;
  padding: 11px 20px; color: #7b869b; font-size: 12px; cursor: pointer;
  letter-spacing: 1px;
}
.sidebar .nav-group-title:hover { color: #cdd5e1; }
.sidebar .nav-group-title .arrow {
  font-size: 10px; transition: transform .15s ease; color: inherit;
}
.sidebar .nav-group.collapsed .nav-group-title .arrow { transform: rotate(-90deg); }
.sidebar .nav-group.collapsed .nav-group-body { display: none; }
/* 系统设置内的功能按钮（非页面跳转） */
.sidebar .nav-action {
  display: block; padding: 9px 20px 9px 36px; color: #7b869b;
  cursor: pointer; font-size: 13px;
}
.sidebar .nav-action:hover { background: #2a3345; color: #fff; }
.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.topbar {
  height: 52px; background: var(--card); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; padding: 0 20px;
}
.content { padding: 20px; flex: 1; }

/* 顶部铃铛通知 */
.topbar-right { display: flex; align-items: center; gap: 16px; }
.bell-wrap { position: relative; }
.bell { font-size: 18px; cursor: pointer; line-height: 1; }
.bell-badge {
  position: absolute; top: -6px; right: -10px; background: var(--danger); color: #fff;
  font-size: 11px; line-height: 1; padding: 3px 5px; border-radius: 10px; min-width: 16px; text-align: center;
}
.bell-drop {
  position: absolute; right: 0; top: 30px; width: 320px; background: var(--card);
  border: 1px solid var(--border); border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,.12); z-index: 100;
}
.bell-header { display: flex; justify-content: space-between; align-items: center; padding: 10px 14px; border-bottom: 1px solid var(--border); font-weight: 600; }
.bell-readall { font-size: 12px; color: var(--primary); cursor: pointer; font-weight: 400; }
.bell-list { max-height: 320px; overflow: auto; }
.bell-item { padding: 10px 14px; border-bottom: 1px solid var(--border); cursor: pointer; }
.bell-item:hover { background: var(--bg); }
.bell-item.unread { background: #eef3ff; }
.bi-title { font-weight: 600; font-size: 13px; }
.bi-content { color: var(--muted); font-size: 12px; margin-top: 2px; }
.bi-time { color: #b0b9c8; font-size: 11px; margin-top: 2px; }

/* 组织架构/部门树 */
.dept-hint { color: var(--muted); font-size: 12px; margin-bottom: 12px; }
.dept-tree { list-style: none; padding-left: 22px; }
.dept-tree > .dept-tree { border-left: 1px dashed var(--border); margin-left: 8px; }
.dept-node {
  display: flex; align-items: center; gap: 12px; padding: 8px 10px; margin: 4px 0;
  border: 1px solid var(--border); border-radius: 6px; background: var(--bg);
}
.dept-name { font-weight: 600; }
.dept-leader { color: var(--muted); font-size: 12px; }
.dept-ops { margin-left: auto; display: flex; gap: 6px; }
.btn.danger { color: var(--danger); border-color: #f3c1c2; }

/* 字段配置 */
.cf-tabs { display: flex; gap: 8px; margin-bottom: 14px; }
.cf-tab { padding: 6px 16px; border: 1px solid var(--border); border-radius: 20px; cursor: pointer; font-size: 13px; color: var(--muted); }
.cf-tab.on { background: var(--primary); color: #fff; border-color: var(--primary); font-weight: 600; }

/* 商机看板列内“+ 新建” */
.kanban-add { cursor: pointer; font-size: 12px; font-weight: 400; margin-left: 8px; color: var(--primary); }
.kanban-ops { margin-top: 8px; display: flex; gap: 6px; }

/* 详情键值展示 */
.kv { display: flex; gap: 12px; padding: 6px 0; font-size: 13px; border-bottom: 1px dashed var(--border); }
.kv span { width: 120px; color: var(--muted); flex-shrink: 0; }
.kv b { font-weight: 500; word-break: break-all; }

/* 审批流程节点展示 */
.step-badge { display: inline-block; padding: 1px 8px; border-radius: 10px; font-size: 12px; margin-right: 4px; }
.step-badge.s-approved { background: #e7f6ee; color: #13965f; }
.step-badge.s-rejected { background: #fdecea; color: var(--danger); }
.step-badge.s-pending { background: #eef3fb; color: var(--primary); }
.tpl-step { display: inline-block; background: #f4f6fa; border: 1px solid var(--border); border-radius: 12px; padding: 2px 10px; margin: 0 6px 6px 0; font-size: 12px; }
.tpl-step-row { align-items: center; }

/* 卡片与面板 */
.card { background: var(--card); border: 1px solid var(--border); border-radius: 8px; padding: 18px; margin-bottom: 16px; }
.card h2 { margin-bottom: 14px; font-size: 15px; }
.card h3 { margin-bottom: 14px; font-size: 15px; }

/* 仪表板 */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.stat-card { background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: 14px; }
.stat-card .label { color: var(--muted); font-size: 12px; margin-bottom: 6px; }
.stat-card .value { font-size: 20px; font-weight: 700; }
.stat-card .unit { color: var(--muted); font-size: 12px; margin-top: 4px; }
/* 客户细分标签与聚合徽章 */
.tags { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0; }
.chip { display: inline-block; padding: 2px 10px; border-radius: 12px; background: var(--primary); color: #fff; font-size: 12px; }
.green { color: #13965f; }
.red { color: var(--danger); }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 900px) { .two-col { grid-template-columns: 1fr; } }
.card-total { margin-bottom: 12px; color: var(--muted); }
.card-total b { font-size: 16px; }
.bar-row { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.bar-label { width: 120px; flex-shrink: 0; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar { flex: 1; height: 16px; background: var(--border); border-radius: 4px; overflow: hidden; display: flex; }
.bar-fill { height: 100%; background: var(--primary); transition: width .3s; }
.bar-fill.green { background: var(--primary); }
.bar.double .bar-fill:nth-child(2) { background: var(--border); }
.bar-val { width: 120px; flex-shrink: 0; font-size: 12px; color: var(--muted); text-align: right; }

/* 表格 */
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); }
th { background: #fafbfd; font-weight: 600; white-space: nowrap; }
td { color: #3a4555; }

/* 按钮 */
.btn {
  display: inline-block; padding: 7px 14px; border-radius: 6px; border: 1px solid var(--border);
  background: var(--card); color: var(--text); cursor: pointer; font-size: 13px;
}
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.danger { background: #fff; border-color: #f3c0c1; color: var(--danger); }
.btn.sm { padding: 4px 10px; font-size: 12px; }

/* 表单 */
.field { margin-bottom: 12px; }
.field label { display: block; margin-bottom: 6px; color: var(--muted); font-size: 13px; }
input[type=text], input[type=password], input[type=number], select, textarea {
  width: 100%; padding: 8px 10px; border: 1px solid var(--border); border-radius: 6px; font-size: 14px;
}
textarea { min-height: 70px; resize: vertical; }
.form-row { display: flex; gap: 12px; }

/* 工具栏与分页 */
.toolbar { display: flex; gap: 10px; align-items: center; margin-bottom: 14px; flex-wrap: wrap; }
.toolbar input, .toolbar select { width: auto; }
.pagination { display: flex; gap: 6px; justify-content: flex-end; margin-top: 12px; align-items: center; }
.pagination .btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* 看板 Kanban */
.kanban { display: flex; gap: 14px; overflow-x: auto; padding-bottom: 10px; }
.kanban-col {
  flex: 0 0 250px; background: #eef1f7; border-radius: 8px; padding: 10px;
}
.kanban-col h4 { font-size: 13px; margin-bottom: 10px; color: #3a4555; }
.kanban-card { background: #fff; border-radius: 6px; padding: 10px; margin-bottom: 8px; box-shadow: 0 1px 2px rgba(0,0,0,.06); cursor: pointer; }
.kanban-card .amount { color: var(--primary); font-weight: 600; }

/* 时间线 */
.timeline { border-left: 2px solid var(--border); margin-left: 8px; padding-left: 18px; }
.timeline-item { padding: 8px 0; position: relative; }
.timeline-item::before { content: ""; position: absolute; left: -24px; top: 14px; width: 8px; height: 8px; border-radius: 50%; background: var(--primary); }
.timeline-item .content { font-size: 13px; }
.timeline-item .time { font-size: 12px; color: var(--muted); }

/* 顶部用户 */
.user-drop { cursor: pointer; }

/* 弹窗 */
.mask { position: fixed; inset: 0; background: rgba(0,0,0,.4); display: none; align-items: center; justify-content: center; z-index: 100; }
.mask.show { display: flex; }
.dialog { background: #fff; border-radius: 10px; width: 480px; max-width: 92vw; padding: 20px; max-height: 88vh; overflow: auto; }
.dialog h3 { margin-bottom: 16px; }
.dialog .actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 16px; }
.toast { position: fixed; top: 20px; left: 50%; transform: translateX(-50%); background: #333; color: #fff; padding: 9px 18px; border-radius: 6px; z-index: 200; opacity: 0; transition: opacity .2s; }
.toast.show { opacity: 1; }

/* 顶栏左侧（汉堡 + 标题）与移动端遮罩 */
.topbar-left { display: flex; align-items: center; gap: 10px; }
.menu-toggle { display: none; font-size: 20px; cursor: pointer; line-height: 1; user-select: none; }
.sidebar-backdrop { display: none; }

/* ===== 移动端适配（≤768px：侧栏变抽屉、表格横向滚动、弹窗贴底全宽、触控目标加大） ===== */
@media (max-width: 768px) {
  .menu-toggle { display: inline-block; }
  .sidebar {
    position: fixed; top: 0; bottom: 0; left: 0; z-index: 90; width: 240px;
    transform: translateX(-100%); transition: transform .25s ease; margin: 0;
  }
  .sidebar.open { transform: translateX(0); box-shadow: 4px 0 20px rgba(0,0,0,.25); }
  .sidebar-backdrop {
    display: block; position: fixed; inset: 0; z-index: 80;
    background: rgba(0,0,0,.35); visibility: hidden; opacity: 0; transition: opacity .2s;
  }
  .sidebar-backdrop.show { visibility: visible; opacity: 1; }
  /* 抽屉内菜单项加大触控面积 */
  .sidebar nav a, .sidebar .nav-action { padding: 13px 20px 13px 36px; font-size: 14px; }
  .sidebar .nav-group-title { padding: 14px 20px; }
  .content { padding: 12px; overflow: hidden; }
  .topbar { padding: 0 12px; height: 50px; }
  /* 表格改横向滚动，避免挤破布局 */
  table { display: block; overflow-x: auto; white-space: nowrap; -webkit-overflow-scrolling: touch; }
  th, td { padding: 9px 10px; }
  /* 顶部铃铛下拉改全宽浮层，避免溢出 */
  .bell-drop { position: fixed; left: 10px; right: 10px; top: 50px; width: auto; }
  .kv span { width: 84px; }
  .bar-label { width: 76px; font-size: 12px; }
  .bar-val { width: 76px; }
  /* 弹窗贴底全宽（底部抽屉式），避免小屏居中弹窗被键盘遮挡 */
  .mask { align-items: flex-end; }
  .dialog {
    width: 100%; max-width: 100vw; border-radius: 14px 14px 0 0;
    max-height: 90vh; margin: 0; padding: 16px 16px calc(16px + env(safe-area-inset-bottom));
  }
  /* 指标卡固定两列，避免单行过挤 */
  .stats { grid-template-columns: repeat(2, 1fr); }
  .stat-card .value { font-size: 18px; }
  /* 工具栏在窄屏换行堆叠，输入框占满整行 */
  .toolbar input, .toolbar select { flex: 1 1 100%; }
  .toolbar .btn { flex: 0 0 auto; }
  /* 表单一行双列改纵向堆叠 */
  .form-row { flex-direction: column; gap: 0; }
  /* 触控按钮加大 */
  .btn { padding: 9px 14px; font-size: 14px; }
  .btn.sm { padding: 7px 12px; font-size: 13px; min-height: 32px; }
  /* 分页居中，间距加大 */
  .pagination { justify-content: center; gap: 10px; }
  /* 详情键值换行友好 */
  .kv { flex-wrap: wrap; }
  /* 看板列宽适配小屏 */
  .kanban-col { flex: 0 0 78vw; }
}
/* 客户查重防撞单提醒 */
.dup-warn { color: #c0392b; margin-bottom: 10px; line-height: 1.6; font-size: 13px; }

/* AI线索评分·意向徽章 */
.tier { display:inline-block; padding:2px 8px; border-radius:10px; font-size:12px; font-weight:600; color:#fff; }
.tier-a { background:#e74c3c; }
.tier-b { background:#f39c12; }
.tier-c { background:#95a5a6; }

/* ===== 视觉体验优化（聚合增强，不改变功能结构） ===== */

/* 卡片轻阴影，增强层级 */
.card { box-shadow: 0 1px 2px rgba(16,24,40,.05); }
.card h2, .card h3 { font-weight: 600; }

/* 仪表板指标卡：主色强调条 + 更清晰层次 */
.stat-card { position: relative; background: #fff; border-left: 3px solid var(--primary); box-shadow: 0 1px 2px rgba(16,24,40,.05); }
.stat-card .value { color: var(--primary); font-size: 22px; }

/* 销售漏斗轨道/填充对比度增强 */
.bar { background: #e8ecf3; }
.bar-fill { background: linear-gradient(90deg, var(--primary), #4b8bff); border-radius: 4px; }

/* 表格表头与行距，提升阅读性 */
th { padding: 11px 12px; background: #f7f9fc; font-weight: 600; }
td { padding: 11px 12px; }

/* 按钮交互反馈与主次层级 */
.btn { box-shadow: 0 1px 2px rgba(0,0,0,.04); transition: border-color .15s, background .15s, box-shadow .15s; }
.btn:hover { border-color: #c7d2e3; }
.btn.primary { font-weight: 600; }
.btn.primary:hover { background: #2557e0; border-color: #2557e0; box-shadow: 0 2px 8px rgba(47,107,255,.28); }
.btn.sm { padding: 5px 11px; min-height: 26px; } /* 略增尺寸，避免操作列误触 */

/* 营销/客服等工具条 Tab 选中态更醒目 */
.toolbar .btn { border-radius: 6px; }
.toolbar .btn.primary { box-shadow: 0 2px 6px rgba(47,107,255,.24); }

/* 侧边栏子菜单：选中态前占位色条，避免 hover 跳动；分组标题与菜单项层次更清晰 */
.sidebar nav a { border-left: 3px solid transparent; transition: background .15s, padding-left .15s; }
.sidebar .nav-group-title { font-weight: 600; }

/* 字段配置 / 看板「+ 新建」过渡反馈 */
.cf-tab, .kanban-add { transition: background .15s, color .15s; }
.kanban-add:hover { text-decoration: underline; }

/* 登录页视觉增强 */
.login-card { box-shadow: 0 12px 40px rgba(16,24,40,.10); padding: 34px 28px; }
.login-card .field input { padding: 11px 12px; font-size: 15px; }
.login-card #btn-login { margin-top: 6px; border-radius: 8px; letter-spacing: 2px; }

/* ===== 高分屏放大（4K 等大屏按视口宽度等比缩放，缓解字体过小费眼） =====
   通过 html zoom 整体放大，弹窗/遮罩/固定浮层一并生效；
   缩放阈值按宽度自小到大书写，后到规则覆盖先到，4K 命中最内侧档位。 */
@media (min-width: 1920px) and (max-width: 2559px) { html { zoom: 1.12; } }
@media (min-width: 2560px) and (max-width: 3839px) { html { zoom: 1.35; } }
@media (min-width: 3840px) and (max-width: 5119px) { html { zoom: 1.6; } }
@media (min-width: 5120px) { html { zoom: 1.9; } }
