:root {
  --navy: #1a2b4a;
  --navy-2: #243a63;
  --gold: #c9a227;
  --gold-soft: #e7d9a3;
  --bg: #f4f6fa;
  --panel: #ffffff;
  --text: #1f2733;
  --muted: #7c879a;
  --border: #e3e8f0;
  --green: #1f9d6b;
  --red: #d2453f;
  --blue: #2f6db5;
  --shadow: 0 2px 10px rgba(26, 43, 74, 0.08);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
}

#app { display: flex; min-height: 100vh; }

/* 侧边栏 */
.sidebar {
  width: 230px;
  background: linear-gradient(180deg, var(--navy), var(--navy-2));
  color: #fff;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}
.brand { display: flex; align-items: center; gap: 12px; padding: 22px 20px; border-bottom: 1px solid rgba(255,255,255,.08); }
.brand-logo {
  width: 40px; height: 40px; border-radius: 8px;
  background: var(--gold); color: var(--navy);
  font-size: 22px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}
.brand-name { font-size: 17px; font-weight: 700; letter-spacing: 1px; }
/* 侧边栏律所名可能较长：单行省略，悬停 title 显示全称 */
.sidebar .brand-text { flex: 1; min-width: 0; }
.sidebar .brand-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.brand-sub { font-size: 12px; color: var(--gold-soft); margin-top: 2px; }

#nav { flex: 1; padding: 12px 0; }
.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 22px; color: #c5cee0;
  cursor: pointer; font-size: 14px;
  border-left: 3px solid transparent;
  user-select: none;
}
.nav-item:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav-item.active { background: rgba(201,162,39,.16); color: #fff; border-left-color: var(--gold); }
.nav-icon { width: 20px; text-align: center; opacity: .9; }
.sidebar-foot { padding: 14px 16px; font-size: 11px; color: #7e8aa3; border-top: 1px solid rgba(255,255,255,.08); position: relative; }

/* 左下角用户信息 */
.user-chip { display: flex; align-items: center; gap: 10px; cursor: pointer; padding: 8px 6px; border-radius: 8px; }
.user-chip:hover { background: rgba(255,255,255,.06); }
.user-avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--gold); color: var(--navy); display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 15px; flex-shrink: 0; }
.user-meta { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.user-name { color: #fff; font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-sub { color: #9aa7c2; font-size: 11px; }
.foot-note { font-size: 11px; color: #7e8aa3; margin-top: 10px; border-top: 1px solid rgba(255,255,255,.08); padding-top: 10px; }

/* 主区域 */
.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.topbar {
  height: 64px; background: var(--panel);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 28px; position: sticky; top: 0; z-index: 10;
}
.view-title { font-size: 18px; font-weight: 700; }
.topbar-right { display: flex; align-items: center; gap: 16px; }
.search {
  border: 1px solid var(--border); border-radius: 8px;
  padding: 8px 12px; width: 220px; font-size: 13px; outline: none;
}
.search:focus { border-color: var(--gold); }
/* ===== 全域搜索结果面板 ===== */
.search-wrap { position: relative; }
.search-panel {
  position: absolute; top: calc(100% + 8px); right: 0; z-index: 80;
  width: 400px; max-width: 76vw; max-height: 64vh; overflow-y: auto;
  background: var(--panel); border: 1px solid var(--border);
  border-radius: 12px; box-shadow: 0 14px 40px rgba(26, 43, 74, 0.18);
  padding: 6px; backdrop-filter: blur(12px);
}
.search-panel.hidden { display: none; }
.sp-group + .sp-group { margin-top: 4px; border-top: 1px solid var(--border); padding-top: 4px; }
.sp-head {
  display: flex; align-items: center; gap: 6px;
  font-size: 12px; color: var(--muted); padding: 6px 8px 4px;
  position: sticky; top: -6px; background: var(--panel);
}
.sp-count {
  margin-left: auto; font-size: 11px; line-height: 1;
  padding: 3px 8px; border-radius: 999px;
  background: rgba(127, 127, 127, 0.14); color: var(--muted);
}
.sp-item { padding: 7px 8px; border-radius: 8px; cursor: pointer; }
.sp-item:hover, .sp-item.on { background: rgba(127, 127, 127, 0.14); }
.sp-title { font-size: 13px; font-weight: 600; color: var(--text); }
.sp-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.sp-empty { padding: 20px 12px; text-align: center; color: var(--muted); font-size: 13px; }
.sp-tip { display: block; margin-top: 6px; font-size: 11px; opacity: 0.8; }
.user-chip {
  background: var(--navy); color: #fff; padding: 7px 14px;
  border-radius: 20px; font-size: 13px;
}

.content { padding: 26px 28px; }

/* 卡片网格 */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card {
  background: var(--panel); border-radius: 12px; padding: 18px 20px;
  box-shadow: var(--shadow); border-top: 3px solid var(--gold);
}
.stat-card .label { color: var(--muted); font-size: 13px; }
.stat-card .value { font-size: 28px; font-weight: 700; margin-top: 6px; color: var(--navy); }
.stat-card .sub { font-size: 12px; color: var(--muted); margin-top: 4px; }

.panel { background: var(--panel); border-radius: 12px; box-shadow: var(--shadow); padding: 20px; margin-bottom: 22px; }
.panel-title { font-size: 15px; font-weight: 700; margin-bottom: 14px; display: flex; justify-content: space-between; align-items: center; }
.panel-title small { color: var(--muted); font-weight: 400; }

.two-col { display: grid; grid-template-columns: 1.4fr 1fr; gap: 22px; }
@media (max-width: 920px){ .two-col { grid-template-columns: 1fr; } }

/* 工具栏 */
.toolbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; gap: 12px; }
.toolbar .left { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.filter-select { height: 36px; padding: 0 10px; border: 1px solid var(--border); border-radius: 8px; font-size: 13px; background: var(--panel); color: var(--text); cursor: pointer; }
.filter-select:focus { border-color: var(--gold); outline: none; }

/* 按钮 */
.btn { border: none; border-radius: 8px; padding: 9px 16px; font-size: 13px; cursor: pointer; font-weight: 600; white-space: nowrap; }
.btn-primary { background: var(--navy); color: #fff; }
.btn-primary:hover { background: #142037; }
.btn-gold { background: var(--gold); color: var(--navy); }
.btn-gold:hover { background: #b8921f; }
.btn-ghost { background: transparent; color: var(--muted); border: 1px solid var(--border); }
.btn-ghost:hover { background: var(--bg); }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-danger { background: #fbeaea; color: var(--red); }
.btn-danger:hover { background: #f6d6d4; }

/* 表格 */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { text-align: left; color: var(--muted); font-weight: 600; padding: 10px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; }
td { padding: 11px 12px; border-bottom: 1px solid #f0f3f8; vertical-align: middle; }
tbody tr:hover { background: #fafbfe; }

/* 标签 */
.tag { display: inline-block; padding: 3px 10px; border-radius: 12px; font-size: 12px; font-weight: 600; }
.tag-blue { background: #e8f1fb; color: var(--blue); }
.tag-green { background: #e6f6ee; color: var(--green); }
.tag-gold { background: #fbf3da; color: #9c7c10; }
.tag-red { background: #fbeaea; color: var(--red); }
.tag-gray { background: #eef1f5; color: var(--muted); }
.tag-purple { background: #f0e9fb; color: #7a4fd6; }

/* 从财务模块跳转案件后短暂高亮定位 */
.row-flash { animation: rowFlash 2.6s ease-out; }
@keyframes rowFlash {
  0%, 35% { background: #fff6d8; box-shadow: inset 3px 0 0 var(--gold); }
  100% { background: transparent; box-shadow: none; }
}
[data-theme="apple"] .row-flash { animation: rowFlashApple 2.6s ease-out; }
@keyframes rowFlashApple {
  0%, 35% { background: rgba(201, 162, 39, 0.18); box-shadow: inset 3px 0 0 #c9a227; }
  100% { background: transparent; box-shadow: none; }
}

/* 待审批数量角标（标题「流程管理」后） */
.todo-badge {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 20px; height: 20px; padding: 0 6px; margin-left: 6px;
  border-radius: 980px; background: var(--red); color: #fff;
  font-size: 12px; font-weight: 700; line-height: 1; vertical-align: 2px;
}
/* 流程记录卡片切换：待审批 / 已完成 */
.flow-tabs { display: inline-flex; gap: 8px; }
.flow-tab {
  padding: 5px 14px; border-radius: 980px; cursor: pointer;
  background: #eef1f5; color: var(--muted); border: 1px solid transparent;
  font-size: 13px; font-weight: 600; font-family: inherit;
}
.flow-tab b { margin-left: 5px; font-weight: 700; }
.flow-tab:hover { background: #e4e9f0; }
.flow-tab.active { background: #e8f1fb; color: var(--blue); border-color: rgba(0, 102, 204, 0.25); }
[data-theme="apple"] .flow-tab { background: rgba(0, 0, 0, 0.05); backdrop-filter: blur(8px); }
[data-theme="apple"] .flow-tab.active { background: rgba(10, 132, 255, 0.16); color: #0a6cff; border-color: rgba(10, 132, 255, 0.28); }

/* 自动生成的开庭提醒标记 */
.auto-badge { display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 11px; font-weight: 700; background: #fff0e0; color: #c8741a; margin-right: 4px; }
.row-derived { background: #fffaf2; }
.row-derived:hover { background: #fff3e2; }
.task-derived { background: #fffaf2; border-radius: 8px; padding-left: 8px; padding-right: 8px; }
.task-derived:hover { background: #fff3e2; }

/* 线索跟进记录编辑器 */
.fu-add { display: flex; gap: 8px; align-items: flex-start; margin-top: 8px; flex-wrap: wrap; }
.fu-add input[type="date"] { width: 150px; }
.fu-add textarea { flex: 1; min-width: 220px; min-height: 38px; }
.fu-item { display: flex; align-items: flex-start; gap: 8px; padding: 7px 0; border-bottom: 1px dashed #eef1f5; }
.fu-date { flex: 0 0 auto; font-size: 12px; color: var(--blue); font-weight: 600; padding-top: 2px; }
.fu-text { flex: 1; font-size: 13px; color: #333; white-space: pre-wrap; }
.fu-del { flex: 0 0 auto; border: none; background: transparent; color: var(--muted); cursor: pointer; font-size: 13px; padding: 2px 6px; border-radius: 6px; }
.fu-del:hover { background: #fbeaea; color: var(--red); }

/* 线索列表行可点击 */
.row-clickable { cursor: pointer; }
.row-clickable:hover { background: #f5f9ff; }

/* 线索详情页 */
.ld-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px 18px; }
@media (max-width: 900px) { .ld-grid { grid-template-columns: repeat(2, 1fr); } }
.ld-info-k { font-size: 12px; color: var(--muted); margin-bottom: 2px; }
.ld-info-v { font-size: 14px; color: #2b2f36; word-break: break-all; }
.ld-latest { display: flex; align-items: flex-start; gap: 10px; padding: 10px 12px; background: #fff7ea; border: 1px solid #f2e2c4; border-radius: 10px; }
.ld-latest-date { flex: 0 0 auto; font-size: 12px; font-weight: 700; color: #c8741a; padding-top: 2px; }
.ld-latest-text { flex: 1; font-size: 14px; color: #333; white-space: pre-wrap; }

/* 线索漏斗（仪表盘） */
.funnel-wrap { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 0; }
.funnel-step { width: 100%; display: flex; flex-direction: column; align-items: center; padding: 3px 0; border-radius: 8px; }
.funnel-step:hover { background: #f7faff; }
.funnel-bar { height: 36px; border-radius: 6px; display: flex; align-items: center; justify-content: center; color: #fff; font-size: 13px; font-weight: 700; min-width: 96px; box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08); }
.funnel-step:hover .funnel-bar { filter: brightness(1.08); }
.funnel-meta { font-size: 11px; color: var(--muted); margin-top: 2px; }

.prio-高 { color: var(--red); font-weight: 700; }
.prio-中 { color: var(--gold); font-weight: 700; }
.prio-低 { color: var(--muted); }

.row-actions { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }

/* 行内「更多」菜单：低频操作收纳，保持行高紧凑（用 details 实现，无需额外依赖） */
.more-menu { position: relative; }
.more-menu > summary { list-style: none; cursor: pointer; user-select: none; }
.more-menu > summary::-webkit-details-marker { display: none; }
.more-menu > summary::after { content: " ▾"; font-size: 10px; }
.more-menu[open] > summary::after { content: " ▴"; }
.more-list {
  position: absolute; right: 0; top: calc(100% + 4px); z-index: 60;
  min-width: 108px; padding: 6px;
  display: flex; flex-direction: column; gap: 4px;
  background: var(--panel); border: 1px solid var(--border); border-radius: 10px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .14);
}
.more-list .btn { width: 100%; justify-content: center; white-space: nowrap; }
.more-menu.up .more-list { top: auto; bottom: calc(100% + 4px); }
/* 底部行菜单向上弹出，避免被表格滚动区裁切 */
.link { color: var(--blue); cursor: pointer; }
.link:hover { text-decoration: underline; }
.muted { color: var(--muted); }
.empty { text-align: center; color: var(--muted); padding: 40px; }

/* 弹窗 */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(20,32,55,.5);
  display: flex; align-items: center; justify-content: center; z-index: 100;
}
.modal-overlay.hidden { display: none; }
.modal {
  background: #fff; border-radius: 14px; width: 520px; max-width: 94vw;
  max-height: 88vh; display: flex; flex-direction: column; overflow: hidden;
  box-shadow: 0 18px 50px rgba(0,0,0,.25);
}
.modal-head { padding: 18px 22px; border-bottom: 1px solid var(--border); font-size: 16px; font-weight: 700; display: flex; justify-content: space-between; }
.modal-close { background: none; border: none; font-size: 24px; cursor: pointer; color: var(--muted); line-height: 1; }
.modal-body { padding: 20px 22px; overflow-y: auto; }
.modal-foot { padding: 14px 22px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; }

.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.field label .req { color: var(--red); }
.field input, .field select, .field textarea {
  width: 100%; border: 1px solid var(--border); border-radius: 8px;
  padding: 9px 11px; font-size: 13px; font-family: inherit; outline: none; background: #fff;
}
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--gold); }
.field textarea { resize: vertical; min-height: 64px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* 线索转客户弹窗：分段表单 */
.conv-h { font-weight: 700; font-size: 14px; margin: 4px 0 12px; padding-left: 10px; border-left: 3px solid var(--gold); }
.conv-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
.conv-grid .conv-full { grid-column: 1 / -1; }
@media (max-width: 640px) { .conv-grid { grid-template-columns: 1fr; } }

/* toast */
.toast {
  position: fixed; bottom: 28px; left: 50%; transform: translateX(-50%);
  background: var(--navy); color: #fff; padding: 12px 22px; border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0,0,0,.25); z-index: 200; font-size: 13px;
}
.toast.hidden { display: none; }

/* 简易条形图 */
.bar-row { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.bar-name { width: 80px; color: var(--muted); font-size: 13px; }
.bar-track { flex: 1; background: #eef1f5; border-radius: 6px; height: 22px; overflow: hidden; }
.bar-fill { height: 100%; background: linear-gradient(90deg, var(--gold), #e0c45a); }
.bar-val { width: 30px; text-align: right; font-weight: 700; color: var(--navy); }

.task-item { display: flex; justify-content: space-between; align-items: center; padding: 11px 0; border-bottom: 1px solid #f0f3f8; }
.task-item:last-child { border-bottom: none; }
.task-meta { font-size: 12px; color: var(--muted); }

.clickable { cursor: pointer; transition: background .15s; }
.stat-card.clickable:hover { background: #fffdf5; box-shadow: 0 4px 16px rgba(201,162,39,.15); }
.stat-card.clickable:hover .value { color: var(--gold); }
.task-item.clickable:hover { background: #fffdf5; }
.bar-row.clickable:hover { background: #fffdf5; border-radius: 6px; }

/* 登录/注册 */
.auth-overlay {
  position: fixed; inset: 0; z-index: 300;
  background: linear-gradient(135deg, var(--navy), #0e1830);
  display: flex; align-items: center; justify-content: center;
}
.auth-overlay.hidden { display: none; }
.auth-card {
  width: 380px; max-width: 92vw; background: #fff; border-radius: 16px;
  padding: 30px 30px 22px; box-shadow: 0 20px 60px rgba(0,0,0,.35);
}
.auth-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 22px; }
.auth-tabs { display: flex; gap: 18px; border-bottom: 1px solid var(--border); margin-bottom: 20px; }
.auth-tab { padding: 8px 2px; cursor: pointer; color: var(--muted); font-weight: 600; border-bottom: 2px solid transparent; }
.auth-tab.active { color: var(--navy); border-bottom-color: var(--gold); }
.auth-form .field { margin-bottom: 16px; }
.code-row { display: flex; gap: 10px; }
.code-row input { flex: 1; }
.code-row .btn { white-space: nowrap; }
.code-hint { font-size: 12px; color: var(--gold); margin-top: 6px; min-height: 16px; }
.auth-submit { width: 100%; padding: 11px; font-size: 15px; margin-top: 4px; }
.auth-msg { font-size: 13px; margin-top: 12px; min-height: 18px; text-align: center; white-space: pre-line; line-height: 1.6; }
.auth-msg.err { color: var(--red); }
.auth-msg.ok { color: var(--green); }
/* 律所名预检提示（注册时输入律所名后即时反馈是否已被注册） */
.firm-check { display: none; font-size: 12px; margin-top: 6px; line-height: 1.6; }
.firm-check.show { display: block; }
.firm-check.taken { color: var(--red); }
.firm-check.ok { color: var(--green); }
/* 登录页辅助入口：忘记密码 / 验证码登录 / 返回登录 */
.auth-links { display: flex; align-items: center; justify-content: center; gap: 10px; margin: -4px 0 12px; font-size: 13px; }
.auth-links a { color: var(--gold); text-decoration: none; cursor: pointer; }
.auth-links a:hover { text-decoration: underline; }
/* 注册页：用户协议 / 隐私政策 勾选 */
.agree-field { margin: -2px 0 12px; }
.agree-label { display: flex; align-items: flex-start; gap: 8px; font-size: 12px; line-height: 1.6; color: var(--muted); cursor: pointer; }
.agree-label input { margin: 2px 0 0; cursor: pointer; flex: none; }
.agree-label a { color: var(--gold); text-decoration: none; }
.agree-label a:hover { text-decoration: underline; }

/* ---------- 法律文本页（用户协议 / 隐私政策） ---------- */
.legal-wrap { max-width: 760px; margin: 0 auto; padding: 28px 20px 60px; }
.legal-head { display: flex; align-items: center; gap: 14px; padding-bottom: 16px; border-bottom: 1px solid var(--border); }
.legal-brand { width: 40px; height: 40px; border-radius: 10px; background: var(--gold); color: #fff; font-size: 20px; display: flex; align-items: center; justify-content: center; flex: none; }
.legal-title { margin: 0; font-size: 19px; font-weight: 500; color: var(--text); }
.legal-meta { font-size: 12px; color: var(--muted); margin-top: 4px; }
.legal-lead { font-size: 13px; line-height: 1.9; color: var(--muted); background: var(--bg); border-radius: 10px; padding: 14px 16px; margin: 20px 0 24px; }
.legal-h2 { font-size: 15px; font-weight: 500; color: var(--text); margin: 26px 0 10px; }
.legal-key { font-size: 12px; font-weight: 400; color: var(--gold); }
.legal-wrap p { font-size: 13px; line-height: 1.9; color: var(--text); margin: 0 0 10px; }
.legal-foot { margin-top: 32px; padding-top: 18px; border-top: 1px solid var(--border); display: flex; flex-direction: column; gap: 10px; align-items: flex-start; }
.legal-back { font-size: 13px; color: var(--gold); text-decoration: none; }
.legal-back:hover { text-decoration: underline; }

/* 微信登录入口与扫码弹层 */
.wx-block { margin-top: 4px; }
.wx-divider { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 12px; margin: 16px 0 12px; }
.wx-divider::before, .wx-divider::after { content: ""; flex: 1; height: 1px; background: var(--border); }
.wx-btn {
  width: 100%; padding: 11px; font-size: 15px;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  background: #07c160; color: #fff;
}
.wx-btn:hover { background: #06ad56; }
.wx-ico { font-size: 16px; }
.wx-hint { font-size: 11px; color: var(--muted); text-align: center; margin-top: 8px; line-height: 1.6; }
.wx-hint-warn { color: var(--gold); }
/* 未就绪状态：入口仍然可见，但置灰并禁止触发扫码 */
.wx-btn-disabled { background: #b8c0cc; cursor: not-allowed; }
.wx-btn-disabled:hover { background: #b8c0cc; }

.wx-modal {
  position: fixed; inset: 0; z-index: 320;
  background: rgba(10,18,35,.62);
  display: flex; align-items: center; justify-content: center;
}
.wx-modal-card {
  width: 320px; max-width: 92vw; background: #fff; border-radius: 14px;
  padding: 20px 20px 16px; box-shadow: 0 20px 60px rgba(0,0,0,.35);
  text-align: center;
}
.wx-modal-title {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 15px; font-weight: 700; color: var(--navy); margin-bottom: 14px;
}
.wx-x { border: none; background: transparent; cursor: pointer; color: var(--muted); font-size: 16px; line-height: 1; padding: 2px 4px; }
.wx-x:hover { color: var(--navy); }
.wx-qr-box {
  position: relative; width: 220px; height: 220px; margin: 0 auto;
  border: 1px solid var(--border); border-radius: 8px; background: #fff;
  display: flex; align-items: center; justify-content: center; overflow: hidden;
}
.wx-qr-box img { width: 100%; height: 100%; display: block; }
/* 官方授权页内嵌模式：容器放大以容纳官方二维码页 */
.wx-qr-box.wx-qr-embed { width: 300px; height: 400px; }
.wx-qr-box iframe { border: 0; width: 100%; height: 100%; display: block; background: #fff; }
.wx-qr-loading { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 13px; color: var(--muted); background: #fff; }
.wx-modal-tip { font-size: 12px; color: var(--muted); margin-top: 12px; line-height: 1.6; }
.wx-modal-actions { margin-top: 12px; }
.wx-modal-actions .btn { text-decoration: none; display: inline-block; }

.wx-bind-banner { background:#eff6ff; border:1px solid #bfdbfe; color:#1e40af; border-radius:8px; padding:10px 12px; font-size:13px; line-height:1.7; margin-bottom:12px; }
.wx-bind-banner b { color:#1d4ed8; }
.wx-bind-panel { border:1px solid #bfdbfe; background:#f0f7ff; border-radius:10px; padding:16px 14px 12px; margin-top:14px; }
.wx-bind-panel .wx-bind-head { font-size:16px; font-weight:700; color:#1d4ed8; margin-bottom:6px; }
.wx-bind-panel .wx-bind-text { font-size:13px; color:#1e40af; line-height:1.7; margin:0 0 12px; }
.wx-bind-panel .wx-bind-skip { text-align:center; margin-top:10px; font-size:12px; }
.wx-bind-panel .wx-bind-skip a { color:#6b7280; text-decoration:underline; }

.user-chip { cursor: pointer; }

/* 用户下拉菜单 */
.user-menu {
  position: absolute; bottom: calc(100% + 4px); left: 12px; z-index: 50;
  background: #fff; border-radius: 10px; box-shadow: 0 8px 28px rgba(26,43,74,.18);
  overflow: hidden; min-width: 150px; border: 1px solid var(--border);
}
.user-menu.hidden { display: none; }
.user-menu-item { padding: 11px 16px; font-size: 13px; color: var(--text); cursor: pointer; }
.user-menu-item:hover { background: var(--bg); }
.user-menu-item + .user-menu-item { border-top: 1px solid var(--border); }

/* 个人信息弹窗内联元素 */
.pf-sub { border-top: 1px dashed var(--border); margin-top: 16px; padding-top: 14px; }
.pf-hint { font-size: 12px; color: var(--gold); margin-top: 6px; min-height: 16px; }

/* ============================================================
   苹果风主题（data-theme="apple"）· 透明玻璃模式
   设计语言：彩色光晕背景上的「液态玻璃」——高通透毛玻璃面板
   （saturate+blur）、1px 高光描边、顶部内高光、悬浮微抬升；
   圆角更大（20px/胶囊）、苹果蓝 #0A84FF 主强调色、系统字体。
   不影响默认「经典」主题；仅本人可通过「切换界面风格」开启。
   ============================================================ */
[data-theme="apple"] {
  --bg: #eef1f8;
  --panel: rgba(255, 255, 255, 0.55);
  --text: #1d1d1f;
  --muted: #6e6e73;
  --border: rgba(255, 255, 255, 0.7);
  --navy: #16181e;        /* 侧边栏近黑玻璃 */
  --navy-2: #2a2d36;
  --gold: #0a84ff;        /* 主强调色：苹果蓝 */
  --gold-soft: #cfe2ff;
  --shadow: 0 10px 30px rgba(31, 45, 95, 0.12);
  --blue: #0a84ff;
  --green: #34c759;
  --red: #ff3b30;
  --radius: 20px;
}

/* 背景：柔和蓝紫光晕，让玻璃材质能"折射"出层次 */
[data-theme="apple"] body {
  background:
    radial-gradient(1200px 620px at 100% -12%, rgba(120, 170, 255, 0.20), transparent 60%),
    radial-gradient(900px 520px at -8% 112%, rgba(196, 150, 255, 0.18), transparent 55%),
    linear-gradient(160deg, #eef2fb 0%, #eef1f8 52%, #f6f7fb 100%);
}

/* 侧边栏：近黑毛玻璃 + 顶部蓝色微光 */
[data-theme="apple"] .sidebar {
  background: rgba(22, 24, 30, 0.82);
  backdrop-filter: saturate(200%) blur(30px);
  -webkit-backdrop-filter: saturate(200%) blur(30px);
  box-shadow: inset -1px 0 0 rgba(255, 255, 255, 0.06);
}
[data-theme="apple"] .brand {
  background: linear-gradient(180deg, rgba(10, 132, 255, 0.20), transparent);
}

/* 顶栏玻璃 */
[data-theme="apple"] .topbar {
  background: rgba(255, 255, 255, 0.6);
  backdrop-filter: saturate(200%) blur(30px);
  -webkit-backdrop-filter: saturate(200%) blur(30px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.5);
}

/* 玻璃面板 / 卡片：通透 + 高光描边 + 悬浮抬升 */
[data-theme="apple"] .panel,
[data-theme="apple"] .stat-card,
[data-theme="apple"] .org-firm,
[data-theme="apple"] .org-team {
  background: var(--panel);
  backdrop-filter: saturate(220%) blur(32px);
  -webkit-backdrop-filter: saturate(220%) blur(32px);
  border: 1px solid rgba(255, 255, 255, 0.7);
  border-radius: var(--radius);
  box-shadow: 0 10px 30px rgba(31, 45, 95, 0.12), inset 0 1px 0 rgba(255, 255, 255, 0.85);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
[data-theme="apple"] .stat-card { border-top: none; padding: 22px 24px; }
[data-theme="apple"] .stat-card .label { color: var(--muted); }
[data-theme="apple"] .stat-card .value {
  letter-spacing: -0.5px; font-weight: 800;
  background: linear-gradient(180deg, #2a92ff, #0a6cff);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}

/* 可点击卡片：悬浮微抬升 + 更强阴影 */
[data-theme="apple"] .stat-card.clickable:hover,
[data-theme="apple"] .org-firm:hover {
  transform: translateY(-3px);
  box-shadow: 0 20px 46px rgba(31, 45, 95, 0.18), inset 0 1px 0 rgba(255, 255, 255, 0.9);
}
[data-theme="apple"] .stat-card.clickable:hover .value {
  background: linear-gradient(180deg, #1f8bff, #0a5fe0);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}

/* 胶囊按钮 + 玻璃质感渐变 */
[data-theme="apple"] .btn {
  border-radius: 980px; padding: 10px 20px; font-weight: 500;
  border: 1px solid transparent; transition: transform 0.12s ease, box-shadow 0.2s ease, background 0.2s ease;
}
[data-theme="apple"] .btn-sm { padding: 6px 14px; }
[data-theme="apple"] .btn-primary {
  background: linear-gradient(180deg, #2a92ff, #0a84ff); color: #fff;
  box-shadow: 0 4px 14px rgba(10, 132, 255, 0.35);
}
[data-theme="apple"] .btn-primary:hover {
  background: linear-gradient(180deg, #1f8bff, #007aff);
  box-shadow: 0 6px 18px rgba(10, 132, 255, 0.45); transform: translateY(-1px);
}
[data-theme="apple"] .btn-gold {
  background: linear-gradient(180deg, #2a92ff, #0a84ff); color: #fff;
  box-shadow: 0 4px 14px rgba(10, 132, 255, 0.35);
}
[data-theme="apple"] .btn-gold:hover {
  background: linear-gradient(180deg, #1f8bff, #007aff);
  box-shadow: 0 6px 18px rgba(10, 132, 255, 0.45); transform: translateY(-1px);
}
[data-theme="apple"] .btn-ghost {
  border-radius: 980px; border: 1px solid rgba(255, 255, 255, 0.7);
  background: rgba(255, 255, 255, 0.5); color: var(--text);
}
[data-theme="apple"] .btn-ghost:hover { background: rgba(10, 132, 255, 0.08); }
[data-theme="apple"] .btn-danger { background: rgba(255, 59, 48, 0.12); color: var(--red); }
[data-theme="apple"] .btn-danger:hover { background: rgba(255, 59, 48, 0.2); }

/* 输入框 / 选择框：圆润玻璃 */
[data-theme="apple"] .search,
[data-theme="apple"] .filter-select,
[data-theme="apple"] .field input,
[data-theme="apple"] .field select,
[data-theme="apple"] .field textarea {
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid rgba(255, 255, 255, 0.65);
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.05);
}
[data-theme="apple"] .field input:focus,
[data-theme="apple"] .field select:focus,
[data-theme="apple"] .field textarea:focus,
[data-theme="apple"] .search:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 4px rgba(10, 132, 255, 0.18);
}

/* 侧边导航：玻璃胶囊高亮 */
[data-theme="apple"] .nav-item {
  border-radius: 12px;
  margin: 3px 12px;
  padding: 11px 16px;
  color: #d6dbe6;
  transition: background 0.15s ease, transform 0.12s ease;
}
[data-theme="apple"] .nav-item:hover { background: rgba(255, 255, 255, 0.08); color: #fff; }
[data-theme="apple"] .nav-item.active {
  background: linear-gradient(90deg, rgba(10, 132, 255, 0.34), rgba(10, 132, 255, 0.14));
  color: #fff;
  border-left-color: transparent;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.25);
}

/* 弹窗：深玻璃 + 大圆角 */
[data-theme="apple"] .modal-overlay { background: rgba(20, 24, 40, 0.35); backdrop-filter: blur(8px); }
[data-theme="apple"] .modal,
[data-theme="apple"] .auth-card {
  background: rgba(255, 255, 255, 0.62);
  backdrop-filter: saturate(220%) blur(40px);
  -webkit-backdrop-filter: saturate(220%) blur(40px);
  border: 1px solid rgba(255, 255, 255, 0.7);
  border-radius: 24px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.32), inset 0 1px 0 rgba(255, 255, 255, 0.9);
}
[data-theme="apple"] .modal-head { border-bottom: 1px solid rgba(255, 255, 255, 0.5); }
[data-theme="apple"] .modal-foot { border-top: 1px solid rgba(255, 255, 255, 0.5); }

/* 用户下拉菜单 / toast 同材质 */
[data-theme="apple"] .user-menu {
  background: rgba(255, 255, 255, 0.7);
  backdrop-filter: saturate(200%) blur(30px);
  -webkit-backdrop-filter: saturate(200%) blur(30px);
  border: 1px solid rgba(255, 255, 255, 0.7);
  border-radius: var(--radius);
  box-shadow: 0 16px 50px rgba(0, 0, 0, 0.22), inset 0 1px 0 rgba(255, 255, 255, 0.85);
}
[data-theme="apple"] .user-menu-item:hover { background: rgba(10, 132, 255, 0.1); border-radius: 10px; }
[data-theme="apple"] .toast {
  background: rgba(22, 24, 30, 0.78);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border-radius: 14px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

/* 全域搜索面板：它悬浮在密集表格之上，毛玻璃必须比 --panel(0.55) 更实，
   否则底下的表格行和操作按钮直接透出来，结果文字糊成一片 */
[data-theme="apple"] .search-panel {
  background: rgba(255, 255, 255, 0.93);
  backdrop-filter: saturate(200%) blur(28px);
  -webkit-backdrop-filter: saturate(200%) blur(28px);
  border: 1px solid rgba(255, 255, 255, 0.8);
  box-shadow: 0 24px 60px rgba(31, 45, 95, 0.22), inset 0 1px 0 rgba(255, 255, 255, 0.9);
}
/* 吸顶分组头同步做实：结果列表滚动时，行内容不能从分组头透出来 */
[data-theme="apple"] .sp-head {
  background: rgba(255, 255, 255, 0.93);
  backdrop-filter: saturate(200%) blur(20px);
  -webkit-backdrop-filter: saturate(200%) blur(20px);
}
/* 悬停高亮用苹果蓝，和主题强调色一致（经典主题的灰悬停在玻璃上也偏脏） */
[data-theme="apple"] .sp-item:hover,
[data-theme="apple"] .sp-item.on { background: rgba(10, 132, 255, 0.1); }
[data-theme="apple"] .sp-count { background: rgba(10, 132, 255, 0.12); color: #0a6cff; }

/* 表格 / 可点击行：玻璃悬浮高光 */
[data-theme="apple"] th { color: var(--muted); border-bottom: 1px solid rgba(255, 255, 255, 0.6); }
[data-theme="apple"] tbody tr { transition: background 0.15s ease, box-shadow 0.15s ease; }
[data-theme="apple"] tbody tr:hover {
  background: rgba(255, 255, 255, 0.62);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.5);
}
[data-theme="apple"] .row-clickable { transition: background 0.15s ease, box-shadow 0.15s ease; }
[data-theme="apple"] .row-clickable:hover {
  background: rgba(10, 132, 255, 0.08);
  box-shadow: inset 0 0 0 1px rgba(10, 132, 255, 0.2);
}

/* 任务项 / 条形图等可点击条目：玻璃高光 */
[data-theme="apple"] .task-item { transition: background 0.15s ease, box-shadow 0.15s ease, border-radius 0.15s ease; }
[data-theme="apple"] .task-item.clickable:hover,
[data-theme="apple"] .bar-row.clickable:hover {
  background: rgba(10, 132, 255, 0.08);
  border-radius: 12px;
  box-shadow: inset 0 0 0 1px rgba(10, 132, 255, 0.16);
}

/* 标签：圆润玻璃胶囊 */
[data-theme="apple"] .tag { border-radius: 980px; padding: 4px 12px; backdrop-filter: blur(8px); }
[data-theme="apple"] .tag-gold { background: rgba(10, 132, 255, 0.16); color: #0a6cff; }
[data-theme="apple"] .tag-blue { background: rgba(10, 132, 255, 0.16); color: #0a6cff; }
[data-theme="apple"] .tag-green { background: rgba(52, 199, 89, 0.18); color: #1f9d4b; }
[data-theme="apple"] .tag-red { background: rgba(255, 59, 48, 0.16); color: #e02020; }
[data-theme="apple"] .tag-gray { background: rgba(0, 0, 0, 0.06); color: var(--muted); }
[data-theme="apple"] .tag-purple { background: rgba(122, 79, 214, 0.16); color: #7a4fd6; }

/* 漏斗条 / 条形图：柔和渐变（保留行内分段配色） */
[data-theme="apple"] .funnel-bar { border-radius: 12px; box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15); }
[data-theme="apple"] .bar-fill { background: linear-gradient(90deg, #0a84ff, #5ac8fa); border-radius: 6px; box-shadow: 0 1px 4px rgba(10, 132, 255, 0.3); }

/* 强调色同步到品牌 logo（玻璃蓝渐变） */
[data-theme="apple"] .brand-logo,
[data-theme="apple"] .auth-brand .brand-logo {
  background: linear-gradient(180deg, #2a92ff, #0a84ff); color: #fff;
  box-shadow: 0 4px 10px rgba(10, 132, 255, 0.4);
}

/* 切换风格弹窗在当前主题下的高亮也用苹果蓝 */
[data-theme="apple"] .theme-opt.active { background: rgba(10, 132, 255, 0.1); }
[data-theme="apple"] .theme-dot.on { box-shadow: 0 0 0 3px rgba(10, 132, 255, 0.2); }

/* ===== 组织架构 ===== */
.org-firm { border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px; margin-bottom: 16px; background: #fff; }
.org-firm-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 10px; }
.org-firm-name { font-size: 16px; font-weight: 700; color: var(--navy); }
.org-teams { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px; }
.org-team { border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; background: var(--bg); }
/* 客服组织二级架构：子组在父组卡片内缩进展示 */
.org-subteams { margin-top: 10px; padding-top: 8px; border-top: 1px dashed var(--border); }
.org-subteam { margin: 8px 0 0 14px; border-left: 2px solid var(--gold, #c9a227); border-top-left-radius: 0; background: var(--bg-soft, rgba(0,0,0,0.02)); }
.org-team-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.org-team-name { font-weight: 700; color: var(--navy-2); }
.org-members { display: flex; flex-direction: column; gap: 6px; margin-bottom: 10px; }
.org-member { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: 13px; padding: 4px 0; }
.org-assign { display: flex; gap: 6px; flex-wrap: wrap; border-top: 1px dashed var(--border); padding-top: 10px; }
.org-inline { display: inline-flex; gap: 6px; align-items: center; }

/* ===== 切换界面风格弹窗 ===== */
.theme-opt {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 16px; border: 1px solid var(--border); border-radius: 12px;
  cursor: pointer; margin-bottom: 10px; background: var(--panel);
  transition: border-color .15s, background .15s;
}
.theme-opt:hover { border-color: var(--gold); }
.theme-opt.active { border-color: var(--gold); background: rgba(201, 162, 39, 0.06); }
[data-theme="apple"] .theme-opt.active { background: rgba(0, 113, 227, 0.08); }
.theme-opt-info { display: flex; flex-direction: column; }
.theme-opt-name { font-size: 14px; font-weight: 600; color: var(--text); }
.theme-opt-desc { font-size: 12px; color: var(--muted); margin-top: 2px; }
.theme-dot { width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--border); flex: 0 0 auto; }
.theme-dot.on { border-color: var(--gold); background: var(--gold); box-shadow: 0 0 0 3px rgba(201, 162, 39, 0.18); }
[data-theme="apple"] .theme-dot.on { box-shadow: 0 0 0 3px rgba(0, 113, 227, 0.18); }


/* ====================== 筛选列（个人级勾选 + 拖拽排序） ====================== */
.col-picker { position: relative; display: inline-block; margin-left: 8px; vertical-align: middle; }
.cp-badge {
  display: inline-block; min-width: 16px; height: 16px; line-height: 16px; padding: 0 4px;
  margin-left: 5px; border-radius: 8px; background: var(--gold); color: #fff;
  font-size: 11px; text-align: center; vertical-align: 1px;
}
[data-theme="apple"] .cp-badge { background: var(--gold); }
.cp-pop {
  position: absolute; top: calc(100% + 6px); left: 0; z-index: 60; min-width: 232px;
  background: var(--panel, #fff); border: 1px solid var(--border); border-radius: 10px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.16); padding: 0; overflow: hidden;
}
[data-theme="apple"] .cp-pop { backdrop-filter: blur(20px) saturate(180%); background: rgba(255, 255, 255, 0.86); }
.cp-head { padding: 9px 12px; font-size: 12px; color: var(--muted); border-bottom: 1px solid var(--border); }
.cp-list { list-style: none; margin: 0; padding: 4px 0; max-height: 320px; overflow-y: auto; }
.cp-row {
  display: flex; align-items: center; gap: 6px; padding: 6px 12px;
  font-size: 13px; cursor: grab; user-select: none; border-left: 2px solid transparent;
}
.cp-row:hover { background: var(--hover, rgba(0, 0, 0, 0.04)); }
[data-theme="apple"] .cp-row:hover { background: rgba(0, 0, 0, 0.04); }
.cp-row.cp-dragging { opacity: 0.4; cursor: grabbing; }
.cp-row.cp-over { border-left-color: var(--gold); background: var(--gold-soft, rgba(201, 162, 39, 0.1)); }
.cp-row.cp-off { color: var(--muted); }
.cp-row.cp-off .cp-label span { text-decoration: line-through; }
.cp-grip { color: var(--muted); font-size: 11px; letter-spacing: -2px; cursor: grab; flex: 0 0 auto; }
.cp-label { display: flex; align-items: center; gap: 7px; cursor: pointer; flex: 1 1 auto; min-width: 0; }
.cp-label input { cursor: pointer; }
.cp-label span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cp-foot { display: flex; gap: 6px; padding: 8px 12px; border-top: 1px solid var(--border); }

/* ====================== 批量操作条 ====================== */
.bulk-bar {
  display: flex; align-items: center; gap: 8px; padding: 5px 12px; margin-right: 4px;
  background: var(--gold-soft, rgba(201, 162, 39, 0.12));
  border: 1px solid rgba(201, 162, 39, 0.4); border-radius: 8px;
}
[data-theme="apple"] .bulk-bar { background: rgba(0, 113, 227, 0.09); border-color: rgba(0, 113, 227, 0.3); }
.bulk-n { font-size: 13px; color: var(--text); white-space: nowrap; }
.bulk-n b { color: var(--gold); font-size: 14px; }
[data-theme="apple"] .bulk-n b { color: var(--gold); }
table input[type="checkbox"] { cursor: pointer; width: 15px; height: 15px; accent-color: var(--gold); }

/* ====================== 数据筛选面板 ====================== */
.fl-pop { min-width: 320px; max-width: 420px; }
.fl-body { max-height: 420px; overflow-y: auto; padding: 4px 0; }
.fl-row {
  display: flex; align-items: flex-start; gap: 8px; padding: 7px 12px;
  border-bottom: 1px solid var(--border);
}
.fl-row:last-child { border-bottom: none; }
.fl-name { flex: 0 0 76px; font-size: 13px; color: var(--muted); padding-top: 5px; word-break: break-all; }
.fl-in {
  flex: 1 1 auto; min-width: 0; padding: 4px 8px; font-size: 13px;
  border: 1px solid var(--border); border-radius: 6px; background: var(--bg, #fff); color: var(--text);
}
.fl-in:focus { outline: none; border-color: var(--gold); }
[data-theme="apple"] .fl-in:focus { border-color: var(--gold); }
.fl-opts {
  flex: 1 1 auto; min-width: 0; display: flex; flex-wrap: wrap; gap: 4px 10px;
  max-height: 110px; overflow-y: auto;
}
.fl-chk { display: inline-flex; align-items: center; gap: 4px; font-size: 13px; cursor: pointer; }
.fl-chk input { cursor: pointer; width: 14px; height: 14px; accent-color: var(--gold); }
/* 人员筛选输入框：可自由输入，右侧留出下拉箭头位置提示「有建议可补全」 */
.fl-in[list] { cursor: text; }
.fl-in[list]::-webkit-calendar-picker-indicator { opacity: 0.45; cursor: pointer; }
.fl-hint { flex: 1 1 auto; font-size: 12px; color: var(--muted); line-height: 1.5; }

/* ====================== 分页器 ====================== */
.pager {
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap;
  gap: 8px; padding: 10px 14px; margin-top: 10px;
  background: var(--panel, #fff); border: 1px solid var(--border); border-radius: 10px;
  font-size: 13px;
}
.pager-right { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.pager .btn[disabled] { opacity: 0.45; cursor: not-allowed; }
.pager-num { padding: 0 6px; color: var(--text); white-space: nowrap; }
.pager .filter-select { padding: 4px 6px; font-size: 13px; }


/* ============================================================
   手机端自适应（≤900px 折叠侧栏 / ≤640px 抽屉导航）
   桌面端样式全部保持原样，以下规则只在窄屏生效
   ============================================================ */

/* 顶栏左侧容器：桌面端不改变原有 flex 布局 */
.topbar-left { display: flex; align-items: center; gap: 10px; min-width: 0; }
.topbar-left .view-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* 汉堡按钮：桌面端隐藏 */
.menu-btn {
  display: none;
  width: 40px; height: 40px;
  border: 1px solid var(--border); border-radius: 8px;
  background: var(--panel);
  flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  cursor: pointer; flex-shrink: 0; padding: 0;
}
.menu-btn span {
  display: block; width: 18px; height: 2px;
  background: var(--text); border-radius: 2px;
}

/* 抽屉遮罩：默认隐藏 */
.drawer-mask {
  display: none; position: fixed; inset: 0;
  background: rgba(10, 18, 34, .5); z-index: 90;
  -webkit-backdrop-filter: blur(2px); backdrop-filter: blur(2px);
}
.drawer-mask.hidden { display: none !important; }

/* ---------- 平板：侧栏收起为窄条 ---------- */
@media (max-width: 900px) {
  .sidebar { width: 190px; }
  .content { padding: 18px 16px; }
  .topbar { padding: 0 16px; }
  .search { width: 160px; }
  .stat-grid { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
}

/* ---------- 手机：抽屉式导航 ---------- */
@media (max-width: 640px) {
  /* 侧栏改为离屏抽屉，从左滑入 */
  .sidebar {
    position: fixed; left: 0; top: 0; bottom: 0;
    width: 264px; height: 100%; height: 100dvh;
    transform: translateX(-100%);
    transition: transform .26s cubic-bezier(.4, 0, .2, 1);
    z-index: 100; box-shadow: none;
    overflow-y: auto; -webkit-overflow-scrolling: touch;
  }
  /* 打开状态：由 body.drawer-open 控制 */
  body.drawer-open .sidebar { transform: translateX(0); box-shadow: 8px 0 32px rgba(10, 18, 34, .28); }
  body.drawer-open .drawer-mask { display: block; }
  body.drawer-open { overflow: hidden; }

  .menu-btn { display: flex; }
  .drawer-mask { display: none; }

  /* 顶栏：压缩高度与内边距，标题可省略 */
  .topbar { height: 54px; padding: 0 12px; gap: 8px; }
  .topbar-left { flex: 1; min-width: 0; }
  .topbar-right { flex-shrink: 0; }
  .view-title { font-size: 16px; }

  /* 搜索框缩窄为图标尺寸，聚焦时展开 */
  .search { width: 96px; padding: 7px 10px; font-size: 12px; transition: width .2s ease; }
  .search:focus { width: 150px; }
  .search-panel { width: calc(100vw - 24px); max-width: none; right: -12px; }

  /* 内容区内边距收紧，列表横向滚动 */
  .content { padding: 14px 12px; }

  /* 卡片 */
  .panel { padding: 14px 12px; border-radius: 10px; margin-bottom: 14px; }
  .panel-title { font-size: 14px; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 16px; }
  .stat-card { padding: 14px; }
  .stat-card .value { font-size: 22px; }
  .stat-card .label { font-size: 12px; }
  .two-col { gap: 14px; }

  /* 工具栏换行，按钮占满更好按 */
  .toolbar { flex-wrap: wrap; gap: 8px; }
  .toolbar .left { gap: 6px; }
  .toolbar .btn-sm { padding: 7px 11px; font-size: 12px; }

  /* 表格：横向滚动 + 首列吸附，滑起来不晕 */
  .table-wrap {
    overflow-x: auto; -webkit-overflow-scrolling: touch;
    margin: 0 -12px; padding: 0 12px;
  }
  table { font-size: 12px; }
  th, td { padding: 9px 8px; white-space: nowrap; }
  th { position: sticky; top: 0; z-index: 5; background: var(--panel); }
  /* 第一列（勾选/联系人）固定，横向滚动时留个锚点 */
  th:first-child, td:first-child {
    position: sticky; left: 0; z-index: 6; background: var(--panel);
    box-shadow: 1px 0 0 var(--border);
  }
  th:first-child { z-index: 7; }
  /* 行内操作按钮竖排，避免横向拉爆 */
  .row-actions { flex-direction: column; align-items: stretch; gap: 4px; }
  .row-actions .btn-sm { width: 100%; text-align: center; }

  /* 弹窗：接近全屏，从底部滑入 */
  .modal-overlay { padding: 0; align-items: flex-end; }
  .modal {
    width: 100%; max-width: none;
    max-height: 92vh; max-height: 92dvh;
    border-radius: 16px 16px 0 0;
    animation: sheetUp .26s cubic-bezier(.4, 0, .2, 1);
  }
  .modal-head { padding: 14px 16px; font-size: 15px; }
  .modal-body { padding: 16px; }
  .modal-foot { padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); }
  .modal-foot .btn { flex: 1; padding: 11px 12px; font-size: 14px; }
  @keyframes sheetUp { from { transform: translateY(100%); } to { transform: translateY(0); } }

  /* 表单：输入框更大，避免 iOS 聚焦自动放大 */
  .field input, .field select, .field textarea { font-size: 16px; padding: 11px 12px; }
  .field label { font-size: 13px; }

  /* 批量操作条：横向滚动不换行 */
  .bulk-bar {
    display: flex; align-items: center; gap: 8px;
    overflow-x: auto; -webkit-overflow-scrolling: touch;
    padding: 8px 0; flex-wrap: nowrap;
  }
  .bulk-bar .btn-sm { flex-shrink: 0; }
  .bulk-n { flex-shrink: 0; font-size: 12px; }

  /* 分页控件 */
  .pager { flex-wrap: wrap; gap: 8px; }
  .pager .btn-sm { padding: 8px 12px; }

  /* 详情页信息网格：单列 */
  .ld-grid { grid-template-columns: 1fr !important; gap: 8px; }
  .ld-info-k { font-size: 12px; }
  .ld-info-v { font-size: 13px; }

  /* 登录卡片 */
  .auth-overlay {
    padding: 20px 16px calc(20px + env(safe-area-inset-bottom));
    align-items: flex-start; overflow-y: auto; -webkit-overflow-scrolling: touch;
  }
  .auth-card {
    width: calc(100vw - 32px); max-width: none;
    margin: 0 auto; padding: 22px 18px; flex-shrink: 0;
  }
  .auth-submit { padding: 12px; font-size: 15px; }
  .code-row { flex-wrap: nowrap; gap: 8px; }
  .code-row input { flex: 1; min-width: 0; }

  /* 筛选面板 / 列设置下拉：窄屏改为底部抽屉，避免右侧溢出被裁切 */
  .cp-pop {
    position: fixed !important; left: 0 !important; right: 0 !important; bottom: 0 !important;
    top: auto !important;
    width: 100% !important; min-width: 0 !important; max-width: none !important;
    max-height: 82vh; max-height: 82dvh; overflow-y: auto;
    border-radius: 16px 16px 0 0; z-index: 110;
    animation: sheetUp .26s cubic-bezier(.4, 0, .2, 1);
  }
  /* 弹层内的多行筛选列表在小屏上放宽，避免输入框挤成一团 */
  .fl-pop { min-width: 0 !important; max-width: none !important; }
  .fl-row { flex-wrap: wrap; }
  .fl-in { flex: 1; min-width: 96px; }
  .cp-list { max-height: 56vh; overflow-y: auto; }

  /* 安装提示条 */
  .install-tip {
    position: fixed; left: 12px; right: 12px; bottom: calc(12px + env(safe-area-inset-bottom));
    z-index: 120;
  }
  .install-tip-body {
    background: var(--navy); color: #fff;
    border-radius: 12px; padding: 14px 16px;
    box-shadow: 0 12px 32px rgba(10, 18, 34, .3);
    display: flex; flex-direction: column; gap: 8px;
  }
  .install-tip-title { font-size: 14px; font-weight: 700; }
  .install-tip-text { font-size: 12px; color: #c5cee0; line-height: 1.5; }
  .install-tip-body .btn-ghost { color: var(--gold-soft); border-color: rgba(255,255,255,.25); align-self: flex-start; }
  .install-tip.hidden { display: none !important; }
}

/* ---------- 小屏手机 ---------- */
@media (max-width: 380px) {
  .topbar { padding: 0 8px; }
  .content { padding: 12px 8px; }
  .search { width: 76px; }
  .search:focus { width: 120px; }
  .stat-grid { gap: 8px; }
  .view-title { font-size: 15px; max-width: 130px; }
}

/* 横屏手机：压低顶栏，避免内容被挤没 */
@media (max-height: 480px) and (orientation: landscape) {
  .topbar { height: 48px; }
  .content { padding: 10px; }
  .modal { max-height: 96vh; max-height: 96dvh; }
}

/* 暗色主题下的抽屉遮罩与固定列背景，避免透出底色 */
[data-theme="apple"] th,
[data-theme="apple"] td:first-child { background: var(--panel); }

/* 触屏设备：点击高亮改为柔和，去掉 300ms 延迟副作用 */
@media (hover: none) {
  .nav-item, .btn, .sp-item, .row-actions .btn { -webkit-tap-highlight-color: rgba(201, 162, 39, .18); }
  .nav-item:active { background: rgba(255,255,255,.12); }
}
