/* ==========================================================================
   销客 CRM · 设计系统
   ========================================================================== */
:root {
  --brand: #4f46e5;
  --brand-600: #4338ca;
  --brand-50: #eef2ff;
  --brand-100: #e0e7ff;
  --success: #10b981;
  --success-50: #ecfdf5;
  --warning: #f59e0b;
  --warning-50: #fffbeb;
  --danger: #ef4444;
  --danger-50: #fef2f2;
  --info: #0ea5e9;
  --info-50: #f0f9ff;
  --purple: #8b5cf6;
  --cyan: #06b6d4;

  --bg: #f6f7fb;
  --card: #ffffff;
  --surface: #ffffff;
  --surface-2: #fafbfd;
  --border: #e6e8f0;
  --border-soft: #f0f2f7;
  --border-strong: #d3d7e3;
  --text: #1a1f36;
  --text-2: #5a6178;
  --text-3: #8b91a6;
  --text-4: #b3b8c8;
  /* 半透明顶栏 / 输入底色等零散色，集中在这里，好换肤 */
  --topbar-bg: rgba(255, 255, 255, .86);
  --fill: #f3f4f8;
  --fill-2: #f1f3f8;
  --hover-soft: #fafbfd;

  --radius: 14px;
  --radius-sm: 9px;
  --radius-xs: 6px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 1px 3px rgba(16, 24, 40, .06);
  --shadow-md: 0 4px 12px rgba(16, 24, 40, .07), 0 2px 4px rgba(16, 24, 40, .04);
  --shadow-lg: 0 12px 32px rgba(16, 24, 40, .12), 0 4px 8px rgba(16, 24, 40, .05);
  --sidebar-w: 232px;
  --topbar-h: 64px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 13.5px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font-family: inherit; font-size: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }
h1, h2, h3, h4, p { margin: 0; }
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #d6dae6; border-radius: 6px; border: 2px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background: #bcc2d3; background-clip: content-box; }

/* ---------- 布局 ---------- */
#app { display: flex; height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  flex: 0 0 var(--sidebar-w);
  background: linear-gradient(180deg, #131a2b 0%, #0b1220 100%);
  color: #cbd2e0;
  display: flex;
  flex-direction: column;
  transition: width .18s ease, flex-basis .18s ease;
  z-index: 30;
}
.sidebar-brand {
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 18px;
  border-bottom: 1px solid rgba(255, 255, 255, .06);
  flex: 0 0 var(--topbar-h);
}
.brand-mark {
  width: 30px; height: 30px; flex: 0 0 30px;
  border-radius: 9px;
  background: linear-gradient(135deg, #6366f1, #4f46e5);
  display: grid; place-items: center;
  color: #fff; font-weight: 700; font-size: 15px;
  box-shadow: 0 2px 8px rgba(79, 70, 229, .45);
}
.brand-text { font-size: 15px; font-weight: 600; color: #fff; letter-spacing: .3px; white-space: nowrap; }
.brand-sub { font-size: 10.5px; color: #6b7690; letter-spacing: .5px; margin-top: -3px; white-space: nowrap; }

.sidebar-nav { flex: 1; overflow-y: auto; padding: 12px 10px; }
.nav-group-label {
  font-size: 10.5px; letter-spacing: .8px; color: #5c6785;
  padding: 10px 10px 6px; text-transform: uppercase; font-weight: 600;
}
.nav-item {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 11px; margin-bottom: 2px;
  border-radius: 9px; color: #a9b2c7;
  font-size: 13.5px; font-weight: 500;
  cursor: pointer; user-select: none;
  transition: background .14s, color .14s;
  position: relative;
  white-space: nowrap;
}
.nav-item:hover { background: rgba(255, 255, 255, .06); color: #e6eaf3; text-decoration: none; }
.nav-item.active { background: linear-gradient(90deg, rgba(79, 70, 229, .9), rgba(79, 70, 229, .62)); color: #fff; box-shadow: 0 3px 10px rgba(79, 70, 229, .3); }
.nav-item.active::before {
  content: ''; position: absolute; left: -10px; top: 50%; transform: translateY(-50%);
  width: 3px; height: 18px; border-radius: 0 3px 3px 0; background: var(--surface);
}
.nav-item svg { flex: 0 0 17px; opacity: .9; }
.nav-item .nav-label { flex: 1; overflow: hidden; text-overflow: ellipsis; }
.nav-badge {
  font-size: 10.5px; font-weight: 700; line-height: 1;
  padding: 3px 6px; border-radius: 20px;
  background: var(--danger); color: #fff; min-width: 18px; text-align: center;
}
.nav-badge.warn { background: var(--warning); }
.nav-badge.gray { background: rgba(255, 255, 255, .14); color: #cbd2e0; }

.sidebar-foot {
  padding: 10px 14px; border-top: 1px solid rgba(255, 255, 255, .06);
  font-size: 11px; color: #5c6785; display: flex; align-items: center; justify-content: space-between;
}
.sidebar-foot .dot { display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--success); margin-right: 5px; }

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

.topbar {
  height: var(--topbar-h); flex: 0 0 var(--topbar-h);
  background: var(--topbar-bg);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 16px;
  padding: 0 24px; z-index: 20;
}
.topbar-title { font-size: 15px; font-weight: 650; letter-spacing: .2px; }
.topbar-title small { display: block; font-size: 11.5px; font-weight: 400; color: var(--text-3); margin-top: -2px; }
.topbar-spacer { flex: 1; }

.search-trigger {
  display: flex; align-items: center; gap: 8px;
  width: 260px; height: 34px; padding: 0 12px;
  background: var(--fill); border: 1px solid transparent; border-radius: 9px;
  color: var(--text-3); font-size: 13px; cursor: pointer;
  transition: .15s;
}
.search-trigger:hover { background: #eef0f6; border-color: var(--border-strong); }
.search-trigger kbd {
  margin-left: auto; font-family: inherit; font-size: 10.5px; color: var(--text-3);
  background: var(--surface); border: 1px solid var(--border); border-radius: 4px; padding: 1px 5px;
}

.icon-btn {
  position: relative;
  width: 34px; height: 34px; border-radius: 9px;
  border: 1px solid transparent; background: transparent; color: var(--text-2);
  display: grid; place-items: center; transition: .15s;
}
.icon-btn:hover { background: #f3f4f8; color: var(--text); }
.icon-btn .badge-dot {
  position: absolute; top: 3px; right: 3px; min-width: 15px; height: 15px;
  border-radius: 8px; background: var(--danger); color: #fff;
  font-size: 9.5px; font-weight: 700; line-height: 15px; text-align: center; padding: 0 3px;
  border: 1.5px solid var(--surface);
}

.user-chip {
  display: flex; align-items: center; gap: 9px; padding: 4px 8px 4px 4px;
  border-radius: 24px; cursor: pointer; transition: .15s;
}
.user-chip:hover { background: #f3f4f8; }
.user-chip .u-name { font-size: 12.5px; font-weight: 600; line-height: 1.2; }
.user-chip .u-role { font-size: 10.5px; color: var(--text-3); line-height: 1.2; }

.view {
  flex: 1; overflow-y: auto; overflow-x: hidden;
  padding: 22px 24px 40px;
  position: relative;
}

/* ---------- 通用块 ---------- */
.page-head { display: flex; align-items: flex-start; gap: 16px; margin-bottom: 18px; }
.page-head h1 { font-size: 20px; font-weight: 680; letter-spacing: -.2px; }
.page-head .sub { color: var(--text-3); font-size: 12.5px; margin-top: 3px; }
.page-head .actions { margin-left: auto; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

.card {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.card-pad { padding: 20px; }
.card-head {
  display: flex; align-items: center; gap: 10px;
  padding: 16px 20px; border-bottom: 1px solid var(--border);
}
.card-head h3 { font-size: 14px; font-weight: 650; }
.card-head .sub { font-size: 11.5px; color: var(--text-3); }
.card-head .actions { margin-left: auto; display: flex; gap: 6px; align-items: center; }
.card-body { padding: 20px; }
.card-body.tight { padding: 12px 20px; }

.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.nowrap { flex-wrap: nowrap; }
.spacer { flex: 1; }
.mt-0 { margin-top: 0 } .mt-4 { margin-top: 4px } .mt-8 { margin-top: 8px } .mt-12 { margin-top: 12px }
.mt-16 { margin-top: 16px } .mt-20 { margin-top: 20px } .mt-24 { margin-top: 24px }
.mb-0 { margin-bottom: 0 } .mb-8 { margin-bottom: 8px } .mb-12 { margin-bottom: 12px } .mb-16 { margin-bottom: 16px }
.text-2 { color: var(--text-2) } .text-3 { color: var(--text-3) } .text-sm { font-size: 12px }
.text-xs { font-size: 11px } .text-lg { font-size: 16px } .text-xl { font-size: 19px }
.fw-6 { font-weight: 600 } .fw-7 { font-weight: 700 }
.mono { font-variant-numeric: tabular-nums; }
.center { text-align: center }
.right { text-align: right }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hr { height: 1px; background: var(--border); margin: 16px 0; border: 0; }

/* ---------- 按钮 ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 34px; padding: 0 13px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--text);
  font-size: 13px; font-weight: 550; white-space: nowrap;
  transition: .15s; user-select: none;
}
.btn:hover { background: #f7f8fb; border-color: #c3c9d9; }
.btn:active { transform: translateY(.5px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn svg { flex: 0 0 auto; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; box-shadow: 0 1px 3px rgba(79, 70, 229, .35); }
.btn-primary:hover { background: var(--brand-600); border-color: var(--brand-600); }
.btn-ghost { border-color: transparent; background: transparent; color: var(--text-2); }
.btn-ghost:hover { background: #f3f4f8; color: var(--text); }
.btn-danger { color: var(--danger); border-color: #f6c9c9; background: var(--danger-50); }
.btn-danger:hover { background: #fee2e2; border-color: #f0a8a8; }
.btn-danger-solid { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger-solid:hover { background: #dc2626; }
.btn-sm { height: 28px; padding: 0 9px; font-size: 12px; border-radius: 7px; }
.btn-lg { height: 40px; padding: 0 18px; font-size: 14px; border-radius: 10px; }
.btn-block { width: 100%; }
.btn-icon { width: 34px; padding: 0; }
.btn-icon.btn-sm { width: 28px; }

/* ---------- 表单 ---------- */
.field { display: flex; flex-direction: column; gap: 5px; }
.field > label { font-size: 12px; font-weight: 600; color: var(--text-2); }
.field > label .req { color: var(--danger); margin-left: 2px; }
.field .hint { font-size: 11px; color: var(--text-3); }
.input, .select, .textarea {
  width: 100%; height: 34px; padding: 0 11px;
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: var(--surface); outline: none; transition: .15s;
  font-size: 13px;
}
.textarea { height: auto; min-height: 76px; padding: 9px 11px; resize: vertical; line-height: 1.6; }
.input:focus, .select:focus, .textarea:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(79, 70, 229, .12); }
.input::placeholder, .textarea::placeholder { color: var(--text-4); }
.input:disabled, .select:disabled { background: var(--bg); color: var(--text-3); }
.select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238b91a6' stroke-width='2.5' stroke-linecap='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; padding-right: 28px; }
.input-sm, .select-sm { height: 30px; font-size: 12.5px; }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 16px; }
.form-grid .span-2 { grid-column: span 2; }
.form-grid .span-full { grid-column: 1 / -1; }

.check { display: inline-flex; align-items: center; gap: 7px; cursor: pointer; font-size: 13px; user-select: none; }
.check input { width: 15px; height: 15px; accent-color: var(--brand); cursor: pointer; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  display: inline-flex; align-items: center; gap: 5px;
  height: 28px; padding: 0 11px; border-radius: 20px;
  border: 1px solid var(--border-strong); background: var(--surface);
  font-size: 12.5px; color: var(--text-2); cursor: pointer; transition: .15s;
}
.chip:hover { border-color: var(--brand); color: var(--brand); }
.chip.active { background: var(--brand-50); border-color: var(--brand); color: var(--brand-600); font-weight: 600; }
.chip-close { opacity: .55; margin-left: 1px; }
.chip-close:hover { opacity: 1; }

/* ---------- 徽标 / 标签 ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  height: 21px; padding: 0 8px; border-radius: 6px;
  font-size: 11.5px; font-weight: 600; line-height: 21px; white-space: nowrap;
  background: var(--fill-2); color: var(--text-2);
}
.badge.gray { background: var(--fill-2); color: #5a6178; }
.badge.blue { background: #eef2ff; color: #4338ca; }
.badge.green { background: #ecfdf5; color: #047857; }
.badge.amber { background: #fffbeb; color: #b45309; }
.badge.red { background: #fef2f2; color: #b91c1c; }
.badge.purple { background: #f5f3ff; color: #6d28d9; }
.badge.cyan { background: #ecfeff; color: #0e7490; }
.badge.solid { background: var(--brand); color: #fff; }
.badge.lg { height: 24px; line-height: 24px; font-size: 12px; padding: 0 10px; }

.tag {
  display: inline-flex; align-items: center;
  height: 20px; padding: 0 7px; border-radius: 5px;
  font-size: 11px; background: var(--fill-2); color: #5a6178;
  border: 1px solid #e9ebf2; white-space: nowrap;
}
.tag.primary { background: var(--brand-50); color: var(--brand-600); border-color: var(--brand-100); }
.tag.green { background: var(--success-50); color: #047857; border-color: #d1fae5; }
.tag.amber { background: var(--warning-50); color: #b45309; border-color: #fde68a; }
.tag.red { background: var(--danger-50); color: #b91c1c; border-color: #fecaca; }

.dot-badge { display: inline-block; width: 7px; height: 7px; border-radius: 50%; }

/* ---------- 头像 ---------- */
.avatar {
  display: inline-grid; place-items: center; flex: 0 0 auto;
  border-radius: 50%; color: #fff; font-weight: 650; letter-spacing: .3px;
  background: var(--brand); user-select: none;
}
.avatar.sq { border-radius: 8px; }
.avatar-ring { box-shadow: 0 0 0 2px #fff, 0 0 0 3.5px rgba(79, 70, 229, .18); }
.avatar-stack { display: inline-flex; }
.avatar-stack .avatar { margin-left: -7px; border: 2px solid var(--surface); }
.avatar-stack .avatar:first-child { margin-left: 0; }

/* ---------- 表格 ---------- */
.table-wrap { overflow-x: auto; border-radius: var(--radius); }
table.tbl { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13px; }
.tbl thead th {
  text-align: left; font-size: 11.5px; font-weight: 600; color: var(--text-3);
  padding: 10px 14px; background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  white-space: nowrap; position: sticky; top: 0; z-index: 2;
}
.tbl thead th:first-child { border-top-left-radius: var(--radius); padding-left: 20px; }
.tbl thead th:last-child { border-top-right-radius: var(--radius); padding-right: 20px; }
.tbl tbody td { padding: 11px 14px; border-bottom: 1px solid var(--fill-2); vertical-align: middle; }
.tbl tbody td:first-child { padding-left: 20px; }
.tbl tbody td:last-child { padding-right: 20px; }
.tbl tbody tr { transition: background .12s; }
.tbl tbody tr:hover { background: var(--hover-soft); }
.tbl tbody tr:last-child td { border-bottom: 0; }
.tbl tbody tr.clickable { cursor: pointer; }
.tbl .cell-main { font-weight: 600; color: var(--text); }
.tbl .cell-sub { font-size: 11.5px; color: var(--text-3); }
.tbl .num { font-variant-numeric: tabular-nums; text-align: right; }

/* ---------- KPI ---------- */
.kpi { padding: 18px 20px; position: relative; overflow: hidden; }
.kpi .label { font-size: 12px; color: var(--text-3); font-weight: 500; display: flex; align-items: center; gap: 6px; }
.kpi .value { font-size: 25px; font-weight: 700; letter-spacing: -.5px; margin-top: 7px; font-variant-numeric: tabular-nums; line-height: 1.15; }
.kpi .value small { font-size: 13px; font-weight: 600; color: var(--text-3); margin-left: 2px; }
.kpi .foot { font-size: 11.5px; color: var(--text-3); margin-top: 8px; display: flex; align-items: center; gap: 6px; }
.kpi .kpi-icon {
  position: absolute; right: 16px; top: 16px;
  width: 38px; height: 38px; border-radius: 11px;
  display: grid; place-items: center; opacity: .95;
}
.delta-up { color: var(--success); font-weight: 600; }
.delta-down { color: var(--danger); font-weight: 600; }

/* ---------- 空态 / 加载 ---------- */
.empty { padding: 52px 20px; text-align: center; color: var(--text-3); }
.empty .ico { margin-bottom: 12px; color: var(--text-4); }
.empty h4 { font-size: 14px; color: var(--text-2); margin-bottom: 4px; font-weight: 600; }
.empty p { font-size: 12.5px; max-width: 340px; margin: 0 auto 14px; line-height: 1.7; }

.spinner { display: flex; align-items: center; justify-content: center; gap: 10px; padding: 60px 0; color: var(--text-3); font-size: 13px; }
.spinner::before {
  content: ''; width: 18px; height: 18px; border-radius: 50%;
  border: 2px solid var(--border-strong); border-top-color: var(--brand);
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.skeleton { background: linear-gradient(90deg, var(--fill-2) 25%, #e8ebf3 37%, var(--fill-2) 63%); background-size: 400% 100%; animation: shimmer 1.3s ease infinite; border-radius: 6px; }
@keyframes shimmer { 0% { background-position: 100% 50% } 100% { background-position: 0 50% } }

/* ---------- 模态 / 抽屉 ---------- */
.overlay {
  position: fixed; inset: 0; background: rgba(15, 23, 42, .42);
  z-index: 100; display: flex; align-items: center; justify-content: center;
  padding: 24px; animation: fade .16s ease;
  backdrop-filter: blur(2px);
}
@keyframes fade { from { opacity: 0 } to { opacity: 1 } }
@keyframes slideUp { from { opacity: 0; transform: translateY(12px) scale(.99) } to { opacity: 1; transform: none } }
@keyframes slideInRight { from { transform: translateX(36px); opacity: .6 } to { transform: none; opacity: 1 } }

.modal {
  background: var(--surface); border-radius: 16px; box-shadow: var(--shadow-lg);
  width: 560px; max-width: 100%; max-height: calc(100vh - 60px);
  display: flex; flex-direction: column; animation: slideUp .2s cubic-bezier(.2, .8, .3, 1);
}
.modal-head { display: flex; align-items: flex-start; gap: 12px; padding: 20px 22px 0; }
.modal-head h3 { font-size: 16px; font-weight: 680; }
.modal-head .sub { font-size: 12px; color: var(--text-3); margin-top: 2px; }
.modal-head .close { margin-left: auto; }
.modal-body { padding: 18px 22px; overflow-y: auto; flex: 1; }
.modal-foot { padding: 14px 22px; border-top: 1px solid var(--border); display: flex; gap: 9px; justify-content: flex-end; background: #fcfcfe; border-radius: 0 0 16px 16px; }

.drawer-overlay {
  position: fixed; inset: 0; background: rgba(15, 23, 42, .34);
  z-index: 100; display: flex; justify-content: flex-end;
  animation: fade .16s ease; backdrop-filter: blur(1.5px);
}
.drawer {
  background: var(--surface); width: 720px; max-width: 94vw; height: 100%;
  display: flex; flex-direction: column; box-shadow: var(--shadow-lg);
  animation: slideInRight .22s cubic-bezier(.2, .8, .3, 1);
}
.drawer-head { padding: 20px 24px 14px; border-bottom: 1px solid var(--border); }
.drawer-body { flex: 1; overflow-y: auto; padding: 20px 24px; }
.drawer-foot { padding: 13px 24px; border-top: 1px solid var(--border); display: flex; gap: 9px; justify-content: flex-end; background: #fcfcfe; }

/* ---------- Toast ---------- */
.toast-wrap { position: fixed; top: 20px; left: 50%; transform: translateX(-50%); z-index: 300; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast {
  background: #1f2937; color: #fff; padding: 9px 16px; border-radius: 9px;
  font-size: 13px; box-shadow: var(--shadow-lg);
  display: flex; align-items: center; gap: 8px;
  animation: toastIn .22s cubic-bezier(.2, .8, .3, 1);
  max-width: 460px;
}
@keyframes toastIn { from { opacity: 0; transform: translateY(-10px) } to { opacity: 1; transform: none } }
.toast.success { background: #065f46; }
.toast.error { background: #991b1b; }
.toast.warning { background: #92400e; }
.toast.info { background: #1e3a8a; }

/* ---------- 标签页 ---------- */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin-bottom: 18px; overflow-x: auto; }
.tab {
  padding: 9px 14px; font-size: 13px; font-weight: 550; color: var(--text-3);
  border: 0; border-bottom: 2px solid transparent; background: transparent;
  cursor: pointer; white-space: nowrap; font-family: inherit;
  transition: .14s; margin-bottom: -1px;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--brand); border-bottom-color: var(--brand); }
.tab .count { font-size: 11px; background: var(--fill-2); padding: 1px 6px; border-radius: 10px; margin-left: 5px; color: var(--text-3); }
.tab.active .count { background: var(--brand-50); color: var(--brand); }

.seg { display: inline-flex; background: var(--fill-2); border-radius: 9px; padding: 3px; gap: 2px; }
.seg-item {
  padding: 5px 12px; border-radius: 7px; font-size: 12.5px; font-weight: 550;
  color: var(--text-2); cursor: pointer; transition: .14s; border: 0; background: transparent;
  display: inline-flex; align-items: center; gap: 5px;
}
.seg-item:hover { color: var(--text); }
.seg-item.active { background: var(--surface); color: var(--brand); box-shadow: 0 1px 3px rgba(16, 24, 40, .1); }

/* ---------- 工具栏 ---------- */
.toolbar { display: flex; gap: 9px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.toolbar .search-box { position: relative; width: 240px; }
.toolbar .search-box svg { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--text-3); pointer-events: none; }
.toolbar .search-box .input { padding-left: 31px; }

/* ---------- 看板 ---------- */
.kanban { display: flex; gap: 14px; align-items: flex-start; overflow-x: auto; padding-bottom: 14px; min-height: 420px; }
.kanban-col {
  flex: 0 0 282px; width: 282px;
  background: #f3f4f9; border-radius: 12px; border: 1px solid #eceef6;
  display: flex; flex-direction: column; max-height: calc(100vh - 250px);
  transition: background .15s, border-color .15s;
}
.kanban-col.drag-over { background: var(--brand-50); border-color: #c7d2fe; border-style: dashed; }
.kanban-col-head { padding: 11px 13px; display: flex; align-items: center; gap: 8px; flex: 0 0 auto; }
.kanban-col-head .name { font-size: 12.5px; font-weight: 650; }
.kanban-col-head .cnt { font-size: 11px; color: var(--text-3); background: #e6e9f2; padding: 1px 7px; border-radius: 10px; font-weight: 600; }
.kanban-col-head .amt { margin-left: auto; font-size: 11.5px; color: var(--text-3); font-weight: 600; font-variant-numeric: tabular-nums; }
.kanban-list { flex: 1; overflow-y: auto; padding: 0 9px 10px; display: flex; flex-direction: column; gap: 8px; min-height: 40px; }
.kcard {
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  padding: 11px 12px; cursor: grab; transition: .15s; box-shadow: 0 1px 2px rgba(16, 24, 40, .04);
  position: relative;
}
.kcard:hover { box-shadow: var(--shadow-md); border-color: #d6daf0; transform: translateY(-1px); }
.kcard:active { cursor: grabbing; }
.kcard.dragging { opacity: .45; }
.kcard .kc-title { font-size: 12.5px; font-weight: 650; line-height: 1.45; margin-bottom: 7px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.kcard .kc-amt { font-size: 14px; font-weight: 700; color: var(--brand); font-variant-numeric: tabular-nums; }
.kcard .kc-meta { display: flex; align-items: center; gap: 6px; margin-top: 8px; font-size: 11px; color: var(--text-3); }
.kcard .kc-foot { display: flex; align-items: center; gap: 5px; margin-top: 8px; padding-top: 8px; border-top: 1px dashed #eef0f6; }
.kcard .kc-foot .spacer { flex: 1 }
.kcard .kc-cust { font-size: 11px; color: var(--text-2); margin-bottom: 4px; display: flex; align-items: center; gap: 4px; }

/* ---------- 时间线 ---------- */
.timeline { position: relative; padding-left: 26px; }
.timeline::before { content: ''; position: absolute; left: 8px; top: 6px; bottom: 6px; width: 2px; background: linear-gradient(180deg, var(--border), var(--fill-2)); border-radius: 2px; }
.tl-item { position: relative; padding-bottom: 18px; }
.tl-item:last-child { padding-bottom: 0; }
.tl-dot {
  position: absolute; left: -26px; top: 3px;
  width: 18px; height: 18px; border-radius: 50%;
  background: var(--surface); border: 2px solid var(--border-strong);
  display: grid; place-items: center; color: var(--text-3);
}
.tl-dot.primary { border-color: var(--brand); color: var(--brand); background: var(--brand-50); }
.tl-dot.green { border-color: var(--success); color: var(--success); background: var(--success-50); }
.tl-dot.amber { border-color: var(--warning); color: var(--warning); background: var(--warning-50); }
.tl-dot.red { border-color: var(--danger); color: var(--danger); background: var(--danger-50); }
.tl-dot.purple { border-color: var(--purple); color: var(--purple); background: #f5f3ff; }
.tl-head { display: flex; align-items: center; gap: 8px; margin-bottom: 3px; flex-wrap: wrap; }
.tl-title { font-size: 12.5px; font-weight: 650; }
.tl-time { font-size: 11px; color: var(--text-3); }
.tl-body { font-size: 12.5px; color: var(--text-2); line-height: 1.65; background: var(--surface-2); border-radius: 8px; padding: 8px 11px; margin-top: 5px; border: 1px solid var(--border-soft); }
.tl-body.plain { background: transparent; border: 0; padding: 0; }

/* ---------- 列表行 ---------- */
.list { display: flex; flex-direction: column; }
.list-item {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 20px; border-bottom: 1px solid var(--fill-2);
  transition: background .12s;
}
.list-item:last-child { border-bottom: 0; }
.list-item:hover { background: var(--surface-2); }
.list-item.clickable { cursor: pointer; }
.list-item .li-main { flex: 1; min-width: 0; }
.list-item .li-title { font-size: 13px; font-weight: 600; }
.list-item .li-sub { font-size: 11.5px; color: var(--text-3); margin-top: 1px; }
.list-item .li-right { margin-left: auto; text-align: right; flex: 0 0 auto; }

/* ---------- 进度条 ---------- */
.progress { height: 6px; background: #eef0f6; border-radius: 4px; overflow: hidden; }
.progress > i { display: block; height: 100%; border-radius: 4px; background: var(--brand); transition: width .4s ease; }
.progress.green > i { background: var(--success); }
.progress.amber > i { background: var(--warning); }
.progress.red > i { background: var(--danger); }

/* ---------- 详情页 ---------- */
.detail-grid { display: grid; grid-template-columns: minmax(0, 1.65fr) minmax(300px, 1fr); gap: 16px; align-items: start; }
.info-list { display: grid; grid-template-columns: 92px 1fr; gap: 9px 12px; font-size: 12.5px; }
.info-list dt { color: var(--text-3); }
.info-list dd { margin: 0; color: var(--text); word-break: break-all; }
.stat-strip { display: flex; border: 1px solid var(--border); border-radius: 11px; overflow: hidden; background: #fcfcfe; }
.stat-strip > div { flex: 1; padding: 11px 14px; border-right: 1px solid var(--border); }
.stat-strip > div:last-child { border-right: 0; }
.stat-strip .k { font-size: 10.5px; color: var(--text-3); }
.stat-strip .v { font-size: 16px; font-weight: 700; margin-top: 1px; font-variant-numeric: tabular-nums; }

/* ---------- 图表 ---------- */
.chart { width: 100%; display: block; overflow: visible; }
.chart-legend { display: flex; flex-wrap: wrap; gap: 12px; font-size: 11.5px; color: var(--text-2); margin-top: 10px; }
.chart-legend .lg-item { display: inline-flex; align-items: center; gap: 5px; }
.chart-legend .sw { width: 9px; height: 9px; border-radius: 3px; }

/* ---------- 日历 ---------- */
.cal { border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; background: var(--surface); }
.cal-head-row { display: grid; grid-template-columns: repeat(7, 1fr); background: var(--surface-2); border-bottom: 1px solid var(--border); }
.cal-head-row div { padding: 8px; text-align: center; font-size: 11.5px; font-weight: 600; color: var(--text-3); }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); }
.cal-cell {
  min-height: 124px; border-right: 1px solid var(--fill-2); border-bottom: 1px solid var(--fill-2);
  padding: 6px 7px; position: relative; transition: background .12s;
}
.cal-cell:nth-child(7n) { border-right: 0; }
.cal-cell.other { background: #fcfcfe; }
.cal-cell.today { background: #f5f6ff; }
.cal-cell:hover { background: #fafbff; }
.cal-date { font-size: 11.5px; font-weight: 600; color: var(--text-2); margin-bottom: 4px; display: flex; align-items: center; gap: 4px; }
.cal-cell.today .cal-date { color: var(--brand); }
.cal-cell.today .cal-date::before { content: ''; width: 5px; height: 5px; border-radius: 50%; background: var(--brand); }
.cal-ev {
  font-size: 10.5px; padding: 2px 5px; border-radius: 4px; margin-bottom: 2px;
  background: var(--brand-50); color: var(--brand-600);
  cursor: pointer; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  border-left: 2px solid var(--brand);
}
.cal-ev.done { background: #f4f5f8; color: var(--text-3); text-decoration: line-through; border-left-color: var(--text-4); }
.cal-ev.red { background: var(--danger-50); color: #b91c1c; border-left-color: var(--danger); }
.cal-ev.green { background: var(--success-50); color: #047857; border-left-color: var(--success); }
.cal-more { font-size: 10px; color: var(--text-3); padding-left: 3px; }

/* ---------- 搜索面板 ---------- */
.cmdk { position: fixed; inset: 0; z-index: 200; background: rgba(15, 23, 42, .4); display: flex; justify-content: center; padding-top: 12vh; animation: fade .15s; backdrop-filter: blur(2px); }
.cmdk-box { width: 620px; max-width: 92vw; background: var(--surface); border-radius: 14px; box-shadow: var(--shadow-lg); height: fit-content; max-height: 70vh; display: flex; flex-direction: column; animation: slideUp .18s; overflow: hidden; }
.cmdk-input { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.cmdk-input input { flex: 1; border: 0; outline: 0; font-size: 15px; background: transparent; }
.cmdk-res { overflow-y: auto; padding: 8px; }
.cmdk-group { font-size: 10.5px; color: var(--text-3); font-weight: 700; letter-spacing: .6px; padding: 8px 10px 4px; }
.cmdk-item { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; cursor: pointer; }
.cmdk-item:hover, .cmdk-item.sel { background: #f5f6fb; }
.cmdk-item .ci-main { flex: 1; min-width: 0; }
.cmdk-item .ci-title { font-size: 13px; font-weight: 550; }
.cmdk-item .ci-sub { font-size: 11px; color: var(--text-3); }
.cmdk-foot { padding: 8px 14px; border-top: 1px solid var(--border); font-size: 11px; color: var(--text-3); display: flex; gap: 14px; background: #fcfcfe; }

/* ---------- 提醒面板 ---------- */
.remind-panel { position: fixed; top: 60px; right: 16px; width: 366px; max-height: 76vh; z-index: 90; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow-lg); display: flex; flex-direction: column; animation: slideUp .16s; overflow: hidden; }
.remind-head { padding: 13px 16px; border-bottom: 1px solid var(--border); display: flex; align-items: center; }
.remind-body { overflow-y: auto; }
.remind-section { padding: 10px 16px 6px; }
.remind-section .rh { font-size: 11px; font-weight: 700; color: var(--text-3); letter-spacing: .4px; margin-bottom: 6px; display: flex; align-items: center; gap: 6px; }
.remind-row { display: flex; align-items: flex-start; gap: 9px; padding: 8px 0; border-bottom: 1px dashed var(--fill-2); cursor: pointer; }
.remind-row:last-child { border-bottom: 0; }
.remind-row:hover .rr-title { color: var(--brand); }
.remind-row .rr-title { font-size: 12.5px; font-weight: 550; line-height: 1.45; }
.remind-row .rr-sub { font-size: 11px; color: var(--text-3); margin-top: 1px; }

/* ---------- 杂项 ---------- */
.link-btn { color: var(--brand); font-size: 12.5px; font-weight: 550; cursor: pointer; background: none; border: 0; padding: 0; }
.link-btn:hover { text-decoration: underline; }
.muted-box { background: var(--surface-2); border: 1px solid var(--border-soft); border-radius: 9px; padding: 10px 13px; font-size: 12px; color: var(--text-2); }
.alert { display: flex; gap: 9px; padding: 10px 13px; border-radius: 9px; font-size: 12.5px; line-height: 1.6; align-items: flex-start; }
.alert.warn { background: var(--warning-50); border: 1px solid #fde68a; color: #92400e; }
.alert.info { background: var(--info-50); border: 1px solid #bae6fd; color: #075985; }
.alert.danger { background: var(--danger-50); border: 1px solid #fecaca; color: #991b1b; }
.alert.success { background: var(--success-50); border: 1px solid #a7f3d0; color: #065f46; }
.alert svg { flex: 0 0 auto; margin-top: 1px; }

.pill-group { display: inline-flex; border: 1px solid var(--border-strong); border-radius: 9px; overflow: hidden; }
.pill-group > button { border: 0; background: var(--surface); padding: 6px 12px; font-size: 12.5px; color: var(--text-2); border-right: 1px solid var(--border); display: inline-flex; align-items: center; gap: 5px; }
.pill-group > button:last-child { border-right: 0; }
.pill-group > button:hover { background: #f7f8fb; }
.pill-group > button.active { background: var(--brand); color: #fff; }
.pill-group > button.active svg { color: #fff; }

.bulkbar {
  position: sticky; bottom: 16px; margin: 14px auto 0; width: fit-content;
  background: #1f2937; color: #fff; border-radius: 12px;
  padding: 9px 14px; display: flex; align-items: center; gap: 12px;
  box-shadow: var(--shadow-lg); font-size: 12.5px; z-index: 12;
  animation: slideUp .18s;
}
.bulkbar .btn { background: rgba(255, 255, 255, .1); border-color: rgba(255, 255, 255, .16); color: #fff; height: 28px; font-size: 12px; }
.bulkbar .btn:hover { background: rgba(255, 255, 255, .2); }
.bulkbar .cnt { font-weight: 700; color: #a5b4fc; }

.owner-cell { display: flex; align-items: center; gap: 7px; min-width: 0; }
.owner-cell .name { font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.level-badge { width: 20px; height: 20px; border-radius: 6px; display: inline-grid; place-items: center; font-size: 10.5px; font-weight: 700; flex: 0 0 20px; }
.level-A { background: #fef2f2; color: #b91c1c; border: 1px solid #fecaca; }
.level-B { background: #fffbeb; color: #b45309; border: 1px solid #fde68a; }
.level-C { background: #eff6ff; color: #1d4ed8; border: 1px solid #bfdbfe; }
.level-D { background: #f4f5f8; color: #6b7280; border: 1px solid #e5e7eb; }

.tbl-mini { width: 100%; font-size: 12.5px; border-collapse: collapse; }
.tbl-mini th { text-align: left; font-size: 11px; color: var(--text-3); font-weight: 600; padding: 6px 8px; border-bottom: 1px solid var(--border); }
.tbl-mini td { padding: 8px; border-bottom: 1px solid var(--fill-2); }
.tbl-mini tr:last-child td { border-bottom: 0; }

/* 响应式 */
@media (max-width: 1024px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 1100px) {
  :root { --sidebar-w: 64px; }
  .sidebar .brand-text, .sidebar .brand-sub, .sidebar .nav-label, .sidebar .nav-group-label, .sidebar .nav-badge, .sidebar-foot span:last-child { display: none; }
  .sidebar-brand { justify-content: center; padding: 0; }
  .nav-item { justify-content: center; padding: 11px; }
  .nav-item.active::before { display: none; }
  .sidebar-foot { justify-content: center; }
  .grid-3, .grid-5 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .detail-grid { grid-template-columns: 1fr; }
}
@media (max-width: 820px) {
  .sidebar { display: none; }
  .view { padding: 16px 14px 40px; }
  .topbar { padding: 0 14px; gap: 10px; }
  .search-trigger { width: 38px; padding: 0; justify-content: center; }
  .search-trigger span, .search-trigger kbd { display: none; }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  /* 仪表盘 5 张 KPI 在手机上排 2 列，比一条条竖着堆更好扫 */
  .grid-5 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .form-grid { grid-template-columns: 1fr; }
  .form-grid .span-2 { grid-column: auto; }
  .page-head { flex-wrap: wrap; }
  .page-head .actions { width: 100%; margin-left: 0; }
  .drawer { width: 100%; max-width: 100%; }
  /* 手写表格（设置页/报表页）保持原表格语义，外层横向滚动 */
  .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .table-wrap .tbl { min-width: 560px; }
  .kanban { gap: 10px; }
  .kanban-col { flex-basis: 260px; width: 260px; }
}

/* ============================================================
   page.js 构件兼容层
   page.js 输出 .page-actions/.kpi-grid/.kpi-label… 等别名，
   与上面设计系统的真实类名对齐，避免「helper 无样式」。
   ============================================================ */
.page-head .page-actions { margin-left: auto; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.card-head .card-actions { margin-left: auto; display: flex; gap: 6px; align-items: center; }
.card-body-flush { padding: 0; }
.card-body-flush > .tbl thead th:first-child,
.card-body-flush > .tbl tbody td:first-child { padding-left: 20px; }
.card-body-flush > .tbl thead th:last-child,
.card-body-flush > .tbl tbody td:last-child { padding-right: 20px; }

.kpi-grid { display: grid; gap: 14px; grid-template-columns: repeat(4, minmax(0, 1fr)); margin-bottom: 16px; }
.kpi-grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.kpi-grid.cols-5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.kpi-top { display: flex; align-items: center; gap: 6px; }
.kpi-label { font-size: 12px; color: var(--text-3); font-weight: 500; }
.kpi-value { font-size: 25px; font-weight: 700; letter-spacing: -.5px; margin-top: 7px; font-variant-numeric: tabular-nums; line-height: 1.15; }
.kpi-value small { font-size: 13px; font-weight: 600; color: var(--text-3); margin-left: 2px; }
.kpi-foot { font-size: 11.5px; color: var(--text-3); margin-top: 8px; display: flex; align-items: center; gap: 6px; }
.kpi .kpi-ic {
  position: absolute; right: 16px; top: 16px;
  width: 38px; height: 38px; border-radius: 11px;
  display: grid; place-items: center; opacity: .95;
  background: var(--brand-soft); color: var(--brand);
}
.kpi.tone-green .kpi-ic { background: #e8f7f0; color: var(--success); }
.kpi.tone-amber .kpi-ic { background: #fef5e7; color: var(--warning); }
.kpi.tone-red .kpi-ic { background: #fdecee; color: var(--danger); }
.kpi.tone-blue .kpi-ic { background: #eaf1fe; color: var(--info); }

.toolbar .tb-left { display: flex; gap: 9px; align-items: center; flex-wrap: wrap; }
.toolbar .tb-right { margin-left: auto; display: flex; gap: 8px; align-items: center; }

.segmented { display: inline-flex; background: var(--fill-2); border-radius: 9px; padding: 3px; gap: 2px; }
.segmented .seg {
  padding: 6px 13px; border: 0; background: transparent; border-radius: 7px;
  font-size: 12.5px; font-weight: 500; color: var(--text-2); cursor: pointer;
  font-family: inherit; display: inline-flex; align-items: center; gap: 6px; transition: .15s;
}
.segmented .seg:hover { color: var(--text); }
.segmented .seg.active { background: var(--surface); color: var(--brand); box-shadow: 0 1px 3px rgba(16, 24, 40, .1); font-weight: 600; }
.segmented .seg-n { font-size: 10.5px; padding: 0 5px; border-radius: 20px; background: rgba(15,23,42,.07); color: var(--text-3); min-width: 16px; text-align: center; }
.segmented .seg.active .seg-n { background: var(--brand-soft); color: var(--brand); }
.segmented.sm .seg { padding: 4px 9px; font-size: 12px; }

.text-danger { color: var(--danger) !important; }
.text-warn { color: var(--warning) !important; }
.fw6 { font-weight: 600; }

@media (max-width: 1100px) {
  .kpi-grid, .kpi-grid.cols-5 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi-grid.cols-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 820px) {
  .kpi-grid, .kpi-grid.cols-3, .kpi-grid.cols-5 { grid-template-columns: 1fr; }
  .page-head .page-actions { width: 100%; margin-left: 0; }
  .toolbar .tb-right { margin-left: 0; width: 100%; }
}

/* ============================================================
   别名兼容层（app.js / page.js / forms.js / 部分页面使用的类名
   与上面设计系统的真实类名对齐，避免「有结构无样式」）
   ============================================================ */

/* ---- 侧边栏（app.js 用 sb-*） ---- */
.sb-brand {
  height: var(--topbar-h); flex: 0 0 var(--topbar-h);
  display: flex; align-items: center; gap: 10px;
  padding: 0 18px; border-bottom: 1px solid rgba(255, 255, 255, .06);
}
.sb-brand .logo {
  width: 30px; height: 30px; flex: 0 0 30px; border-radius: 9px;
  background: linear-gradient(135deg, #6366f1, #4f46e5);
  display: grid; place-items: center;
  color: #fff; font-weight: 700; font-size: 15px;
  box-shadow: 0 2px 8px rgba(79, 70, 229, .45);
}
.sb-brand .brand-text { display: flex; flex-direction: column; min-width: 0; }
.sb-brand .brand-text strong { font-size: 14px; font-weight: 650; color: #fff; letter-spacing: .3px; line-height: 1.2; white-space: nowrap; }
.sb-brand .brand-text span { font-size: 10px; color: #6b7690; letter-spacing: .4px; white-space: nowrap; margin-top: 1px; }

.sb-nav { flex: 1; overflow-y: auto; padding: 12px 10px; }
.sb-nav .nav-group {
  font-size: 10.5px; letter-spacing: .8px; color: #5c6785;
  padding: 12px 10px 6px; font-weight: 600;
}
.sb-nav .nav-group:first-child { padding-top: 2px; }
.sb-nav .nav-item .label { flex: 1; overflow: hidden; text-overflow: ellipsis; }
.sb-nav .nav-item .ic { display: flex; flex: 0 0 17px; opacity: .92; }

.sb-foot {
  padding: 10px 12px; border-top: 1px solid rgba(255, 255, 255, .06);
}
.sb-user {
  width: 100%; display: flex; align-items: center; gap: 9px;
  padding: 6px 8px; border: 0; border-radius: 10px;
  background: rgba(255, 255, 255, .05); color: #cbd2e0;
  font-family: inherit; cursor: pointer; transition: background .14s;
  text-align: left;
}
.sb-user:hover { background: rgba(255, 255, 255, .1); }
.sb-user .uinfo { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.sb-user .uinfo strong { font-size: 12.5px; font-weight: 600; color: #fff; line-height: 1.25; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sb-user .uinfo em { font-size: 10.5px; font-style: normal; color: #7b869e; line-height: 1.25; }
.sb-user > svg { opacity: .5; flex: 0 0 14px; }

/* ---- 顶栏搜索按钮（app.js 用 tb-search） ---- */
.tb-search {
  display: flex; align-items: center; gap: 8px;
  width: 300px; height: 34px; padding: 0 12px;
  background: #f3f4f8; border: 1px solid transparent; border-radius: 9px;
  color: var(--text-3); font-size: 13px; cursor: pointer;
  transition: background .15s, border-color .15s;
  flex: 0 1 auto;
}
.tb-search:hover { background: #eef0f6; border-color: var(--border-strong); }
.tb-search span { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: left; }
.tb-search kbd {
  font-family: inherit; font-size: 10.5px; color: var(--text-3);
  background: var(--surface); border: 1px solid var(--border); border-radius: 4px; padding: 1px 5px;
}
.tb-right { margin-left: auto; display: flex; align-items: center; gap: 8px; }
#btn-bell .dot {
  position: absolute; top: 7px; right: 7px; width: 7px; height: 7px;
  border-radius: 50%; background: var(--danger); border: 1.5px solid var(--surface);
}

/* ---- 命令面板（app.js 用 cmdk-body/hint/sec） ---- */
.cmdk-body { overflow-y: auto; padding: 8px; max-height: calc(70vh - 60px); }
.cmdk-hint { padding: 16px 12px; font-size: 12.5px; color: var(--text-3); text-align: center; }
.cmdk-sec {
  font-size: 10.5px; color: var(--text-3); font-weight: 700;
  letter-spacing: .6px; padding: 8px 10px 4px;
}
.cmdk-item .ic { display: flex; flex: 0 0 16px; color: var(--text-3); }
.cmdk-item > div { flex: 1; min-width: 0; }
.cmdk-item .t { font-size: 13px; font-weight: 550; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cmdk-item .d { font-size: 11px; color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cmdk-item > svg { flex: 0 0 14px; color: var(--text-4); }

/* ---- 提醒抽屉（app.js 用 remind-sec/remind-item） ---- */
.remind-sec { padding: 6px 0 10px; }
.remind-sec h4 {
  font-size: 11px; font-weight: 700; color: var(--text-3); letter-spacing: .4px;
  margin: 0 0 4px; display: flex; align-items: center; gap: 6px;
  text-transform: none;
}
.remind-sec h4 .cnt {
  font-size: 10px; font-weight: 700; padding: 1px 6px; border-radius: 20px;
  background: var(--fill-2); color: var(--text-2); min-width: 16px; text-align: center;
}
.remind-item {
  display: flex; align-items: flex-start; gap: 9px;
  padding: 9px 0; border-bottom: 1px dashed var(--fill-2); cursor: pointer;
}
.remind-item:last-child { border-bottom: 0; }
.remind-item:hover .ri-title { color: var(--brand); }
.remind-item .ri-title { font-size: 12.5px; font-weight: 550; line-height: 1.45; }
.remind-item .ri-sub { font-size: 11px; color: var(--text-3); margin-top: 1px; }
.remind-item > svg { flex: 0 0 14px; color: var(--text-4); margin-top: 3px; }
.dot-red, .dot-blue, .dot-amber, .dot-gray {
  width: 7px; height: 7px; border-radius: 50%; flex: 0 0 7px; margin-top: 6px;
}
.dot-red { background: var(--danger); }
.dot-blue { background: var(--info); }
.dot-amber { background: var(--warning); }
.dot-gray { background: var(--text-4); }

/* ---- 用户切换弹窗 ---- */
.user-list { display: flex; flex-direction: column; gap: 2px; }
.user-list .user-row {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px; border-radius: 9px; cursor: pointer;
  transition: background .14s;
}
.user-list .user-row:hover { background: #f5f6fb; }
.user-list .user-row.active { background: var(--brand-50); }
/* 登录设备列表（安全加固）：行本身不可点，只有右侧「退出」按钮可点，
   所以把继承来的 pointer 光标去掉，否则用户会以为整行能点 */
.user-list.sess-list .user-row { cursor: default; }
.user-list .user-row .btn-sm { flex: 0 0 auto; }

/* ---- 表单错误提示（forms.js 用 alert-box） ---- */
.alert-box {
  display: flex; gap: 9px; padding: 10px 13px; border-radius: 9px;
  font-size: 12.5px; line-height: 1.6; align-items: flex-start;
  background: var(--danger-50); border: 1px solid #fecaca; color: #991b1b;
}
/* hidden 属性必须能覆盖 .alert-box 的 display:flex，否则空错误条会一直占位 */
.alert-box[hidden] { display: none; }
.alert-box.amber, .alert-box.warn { background: var(--warning-50); border-color: #fde68a; color: #92400e; }
.alert-box.info { background: var(--info-50); border-color: #bae6fd; color: #075985; }
.alert-box svg { flex: 0 0 auto; margin-top: 1px; }

/* ---- 阶段徽标（page.js 用 stage-badge + --sc 变量） ---- */
.stage-badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 8px; border-radius: 20px; font-size: 11.5px; font-weight: 500;
  background: color-mix(in srgb, var(--sc, #64748b) 12%, #fff);
  color: var(--sc, #475569);
  border: 1px solid color-mix(in srgb, var(--sc, #64748b) 28%, #fff);
  white-space: nowrap;
}
.stage-badge i { width: 6px; height: 6px; border-radius: 50%; background: var(--sc, #64748b); flex: 0 0 6px; }

/* ---- 表格横向滚动容器 ---- */
.tbl-wrap { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* ---- 任务列表（tasks.js 用 task-item/task-detail） ---- */
.task-item { border-bottom: 1px solid var(--border); }
.task-item:last-child { border-bottom: 0; }
.task-item[data-status="done"] { opacity: .78; }
.task-item .list-item { border-bottom: 0; }
.task-detail {
  padding: 2px 20px 14px 56px;
  font-size: 12.5px; color: var(--text-2); line-height: 1.65;
  background: #fbfcfe;
}
.task-detail .kv { display: flex; gap: 8px; margin-top: 5px; }
.task-detail .kv b { color: var(--text-3); font-weight: 600; flex: 0 0 68px; }
.task-detail[hidden] { display: none; }

/* ---- 全局加载态 ---- */
.page-loading {
  display: flex; align-items: center; justify-content: center;
  min-height: 320px; color: var(--text-3); font-size: 13px;
}

/* ---- 快速新建菜单 ---- */
.quick-menu {
  position: fixed; z-index: 120; min-width: 176px; padding: 6px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 11px;
  box-shadow: var(--shadow-lg); animation: slideUp .14s;
}
.quick-menu button {
  width: 100%; display: flex; align-items: center; gap: 9px;
  padding: 8px 11px; border: 0; border-radius: 7px; background: transparent;
  font-family: inherit; font-size: 13px; color: var(--text); cursor: pointer; text-align: left;
}
.quick-menu button:hover { background: #f5f6fb; color: var(--brand); }
.quick-menu button svg { flex: 0 0 16px; color: var(--text-3); }
.quick-menu button:hover svg { color: var(--brand); }

/* ---- 小号按钮 ---- */
.btn-xs { height: 24px; padding: 0 8px; font-size: 11.5px; border-radius: 6px; gap: 4px; }
.btn-xs svg { width: 12px; height: 12px; }

/* ---- 跟进动态筛选行（activities.js 用 f-q） ---- */
.f-q { min-width: 220px; }

/* ---- 侧栏折叠/窄屏适配（补 sb-* 版本） ---- */
@media (max-width: 1100px) {
  .sb-brand { justify-content: center; padding: 0; }
  .sb-brand .brand-text { display: none; }
  .sb-nav .nav-group { display: none; }
  .sb-nav .nav-item { justify-content: center; padding: 11px; }
  .sb-nav .nav-item .label, .sb-nav .nav-badge { display: none; }
  .sb-user { justify-content: center; padding: 6px; }
  .sb-user .uinfo { display: none; }
  .sb-user > svg { display: none; }
}
@media (max-width: 820px) {
  .tb-search { width: 38px; padding: 0; justify-content: center; }
  .tb-search span, .tb-search kbd { display: none; }
}

/* 移动端：菜单按钮唤出侧边抽屉（<820px 时侧栏默认隐藏） */
@media (max-width: 820px) {
  #app.mobile-nav-open .sidebar {
    display: flex; position: fixed; left: 0; top: 0; bottom: 0;
    width: 232px; flex: 0 0 232px; z-index: 60;
    box-shadow: 0 0 40px rgba(0, 0, 0, .35);
  }
  #app.mobile-nav-open .sidebar .brand-text,
  #app.mobile-nav-open .sidebar .nav-group,
  #app.mobile-nav-open .sidebar .nav-item .label { display: block; }
  /* 徽标只有真的有数字时才显示，别把 hidden 的 0 也撑出来 */
  #app.mobile-nav-open .sidebar .nav-badge:not([hidden]) { display: block; }
  #app.mobile-nav-open .sidebar .nav-badge[hidden] { display: none; }
  #app.mobile-nav-open .sidebar .sb-brand { justify-content: flex-start; padding: 0 18px; }
  #app.mobile-nav-open .sidebar .nav-item { justify-content: flex-start; padding: 9px 11px; }
  #app.mobile-nav-open .sidebar .sb-user { justify-content: flex-start; padding: 6px 8px; }
  #app.mobile-nav-open .sidebar .sb-user .uinfo { display: flex; }
}

/* ---------- 工具栏内控件宽度修正（select 默认 width:100% 会逐行占满） ---------- */
.toolbar .tb-left > .select,
.toolbar .tb-left > .select-sm,
.toolbar .tb-left > select { width: auto; min-width: 108px; max-width: 190px; flex: 0 0 auto; }
.toolbar .tb-left > .input,
.toolbar .tb-left > .input-sm { width: auto; }
.toolbar .search-box { flex: 0 0 240px; width: 240px; }
.toolbar .search-box .input { width: 100%; }
.toolbar .check { flex: 0 0 auto; white-space: nowrap; }
.toolbar .tb-right { flex: 0 0 auto; }

/* ============================================================
 * 登录页
 * 左品牌 / 右表单的两栏结构。动效只做三件事：入场（轻微上浮 +
 * 错峰）、背景光晕极慢漂移、出错时抖一下。不做循环闪烁 ——
 * 登录页每天要过很多次，安静比热闹重要。
 * ============================================================ */
#login-root[hidden] { display: none; }
#app[hidden] { display: none; }

.login-screen {
  position: relative;
  min-height: 100vh;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 20px;
  padding: 40px 24px;
  overflow: hidden;
  background: linear-gradient(158deg, #080c17 0%, #0d1424 44%, #0a1020 100%);
  color: #e6eaf5;

  /* 登录页永远是深色底（这是它自己的视觉语言，不跟全局主题走）。
     所以在这里就地重定义一组变量：卡片、输入框、文字全部改深色档，
     否则浅色主题下会出现「深色背景 + 纯白卡片」这种突兀的拼贴感。
     只覆盖变量、不改选择器，原有规则一行都不用动。 */
  --surface: #161c2c;
  --surface-2: #1b2234;
  --border: #2a3450;
  --border-strong: #3a4666;
  --text: #e8ecf7;
  --text-2: #b9c2d6;
  --text-3: #8b95ad;
  --text-4: #6d778f;
  --brand-50: rgba(99, 102, 241, .16);
}

/* ---- 背景层：网格 + 三团缓慢漂移的光 ---- */
.login-bg { position: absolute; inset: 0; pointer-events: none; }

.lg-grid {
  position: absolute; inset: -10%;
  background-image:
    linear-gradient(rgba(148, 163, 208, .055) 1px, transparent 1px),
    linear-gradient(90deg, rgba(148, 163, 208, .055) 1px, transparent 1px);
  background-size: 46px 46px;
  mask-image: radial-gradient(760px 520px at 50% 42%, #000 0%, transparent 78%);
  -webkit-mask-image: radial-gradient(760px 520px at 50% 42%, #000 0%, transparent 78%);
  opacity: .85;
}

.lg-orb {
  position: absolute; border-radius: 50%;
  filter: blur(72px);
  will-change: transform;
}
.lg-orb-a {
  width: 540px; height: 540px;
  left: -140px; top: -160px;
  background: radial-gradient(circle, rgba(99, 102, 241, .5), transparent 68%);
  animation: orbA 26s ease-in-out infinite alternate;
}
.lg-orb-b {
  width: 480px; height: 480px;
  right: -120px; bottom: -180px;
  background: radial-gradient(circle, rgba(14, 165, 233, .38), transparent 68%);
  animation: orbB 32s ease-in-out infinite alternate;
}
.lg-orb-c {
  width: 360px; height: 360px;
  right: 30%; top: 8%;
  background: radial-gradient(circle, rgba(139, 92, 246, .26), transparent 70%);
  animation: orbC 24s ease-in-out infinite alternate;
}
@keyframes orbA { to { transform: translate3d(60px, 46px, 0) scale(1.1); } }
@keyframes orbB { to { transform: translate3d(-52px, -40px, 0) scale(1.08); } }
@keyframes orbC { to { transform: translate3d(-34px, 54px, 0) scale(.94); } }

/* ---- 两栏容器 ---- */
.login-shell {
  position: relative; z-index: 1;
  width: 100%; max-width: 1010px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 396px;
  gap: 56px;
  align-items: center;
}

/* ============ 左栏：品牌 + 价值主张 ============ */
.login-hero {
  min-width: 0;
  animation: fadeUp .52s cubic-bezier(.22, .68, .29, 1) both;
}

.lh-brand, .lp-brand { display: flex; align-items: center; gap: 11px; }
.lh-brand { margin-bottom: 30px; }
.login-logo {
  width: 40px; height: 40px; border-radius: 11px; flex: 0 0 auto;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(145deg, #6366f1, #4338ca);
  color: #fff; font-size: 19px; font-weight: 800;
  box-shadow: 0 8px 20px -6px rgba(79, 70, 229, .65);
}
.lh-brand strong, .lp-brand strong { display: block; font-size: 16px; letter-spacing: .2px; color: #f2f5ff; }
.lh-brand span, .lp-brand span { display: block; font-size: 11.5px; color: #8d97b4; margin-top: 1px; }

.lh-title {
  font-size: 38px; line-height: 1.24; font-weight: 800;
  letter-spacing: -.8px; margin: 0 0 14px;
  background: linear-gradient(122deg, #ffffff 8%, #c9d2f7 52%, #93b4f6 96%);
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent; color: transparent;
}
.lh-sub {
  font-size: 13.5px; line-height: 1.85; color: #98a3c0;
  margin: 0 0 22px; max-width: 420px;
}

/* 走势线：入场时从左往右画出来，画完就静止 */
.lh-spark {
  display: block; width: 100%; max-width: 340px; height: 76px; margin-bottom: 22px;
  /* 折线往右淡出，避免末尾被容器切出一道竖直硬边 */
  mask-image: linear-gradient(90deg, #000 0%, #000 84%, transparent 100%);
  -webkit-mask-image: linear-gradient(90deg, #000 0%, #000 84%, transparent 100%);
}
.lh-line {
  stroke-dasharray: 360;
  stroke-dashoffset: 360;
  animation: drawLine 1.5s cubic-bezier(.4, .1, .2, 1) .32s forwards;
}
.lh-area { opacity: 0; animation: fadeIn .9s ease-out 1.1s forwards; }
.lh-dot { opacity: 0; animation: fadeIn .5s ease-out 1.72s forwards; }
@keyframes drawLine { to { stroke-dashoffset: 0; } }
@keyframes fadeIn { to { opacity: 1; } }

.lh-points { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 14px; }
.lh-points li {
  display: flex; align-items: flex-start; gap: 11px;
  opacity: 0;
  animation: fadeUp .5s cubic-bezier(.22, .68, .29, 1) forwards;
  animation-delay: calc(.44s + var(--i) * .1s);
}
.lh-ico {
  width: 28px; height: 28px; border-radius: 8px; flex: 0 0 auto;
  display: flex; align-items: center; justify-content: center;
  color: #a5b4fc;
  background: rgba(99, 102, 241, .14);
  border: 1px solid rgba(129, 140, 248, .22);
}
.lh-points b { display: block; font-size: 13px; font-weight: 600; color: #dfe5f7; }
.lh-points em { display: block; font-style: normal; font-size: 12px; color: #8590ad; margin-top: 2px; line-height: 1.6; }

.lh-foot {
  margin-top: 30px; padding-top: 16px;
  border-top: 1px solid rgba(148, 163, 208, .12);
  font-size: 11.5px; color: #6f7a96;
  display: flex; align-items: center; gap: 7px;
  opacity: 0; animation: fadeIn .5s ease-out .9s forwards;
}

/* ============ 右栏：登录卡片 ============ */
.login-panel {
  position: relative;
  background: var(--surface);
  border-radius: 20px;
  padding: 34px 32px 26px;
  border: 1px solid var(--border);
  box-shadow:
    0 30px 80px -24px rgba(2, 6, 20, .8),
    0 0 0 1px rgba(255, 255, 255, .06),
    inset 0 1px 0 rgba(255, 255, 255, .07);
  animation: fadeUp .42s cubic-bezier(.22, .68, .29, 1) .16s both;
}
.login-panel::before {
  content: ''; position: absolute; inset: 0 0 auto 0; height: 120px;
  border-radius: 20px 20px 0 0; pointer-events: none;
  background: linear-gradient(180deg, rgba(129, 140, 248, .07), transparent);
}
.login-panel.is-shake { animation: shake .42s cubic-bezier(.36, .07, .19, .97) both; }
@keyframes shake {
  10%, 90% { transform: translateX(-2px); }
  20%, 80% { transform: translateX(3px); }
  30%, 50%, 70% { transform: translateX(-5px); }
  40%, 60% { transform: translateX(5px); }
}
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: none; }
}

/* 移动端才把品牌放进卡片 */
.lp-brand { display: none; margin-bottom: 22px; }

.login-title { font-size: 22px; font-weight: 700; color: var(--text); letter-spacing: -.3px; margin: 0; }
.login-sub { font-size: 12.5px; color: var(--text-3); margin: 7px 0 24px; line-height: 1.65; }

.login-form { display: flex; flex-direction: column; gap: 15px; }
.login-field { display: flex; flex-direction: column; gap: 7px; }
.lf-label { font-size: 12px; font-weight: 600; color: var(--text-2); letter-spacing: .1px; }

.login-input { position: relative; display: flex; align-items: center; }
.li-ico {
  position: absolute; left: 12px;
  display: flex; color: #a6b0c3;
  transition: color .16s;
  pointer-events: none;
}
.login-input input {
  width: 100%; height: 44px;
  padding: 0 40px 0 38px;
  border: 1px solid var(--border); border-radius: 10px;
  font-size: 13.5px; color: var(--text); font-family: inherit;
  background: var(--surface-2);
  transition: border-color .16s, box-shadow .16s, background .16s;
}
.login-input input::placeholder { color: #a9b4c4; }
.login-input input:hover { border-color: var(--border-strong); }
.login-input input:focus {
  outline: none; background: var(--surface);
  border-color: #6366f1;
  box-shadow: 0 0 0 3.5px rgba(99, 102, 241, .15);
}
.login-input:focus-within .li-ico { color: #6366f1; }

.li-eye {
  position: absolute; right: 6px;
  width: 30px; height: 30px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  border: 0; background: transparent; cursor: pointer;
  color: #a6b0c3;
  transition: color .14s, background .14s;
}
.li-eye:hover { color: #6366f1; background: var(--brand-50); }
.li-eye.is-on { color: #6366f1; }

.login-caps {
  font-size: 11.5px; color: #92400e;
  background: #fffbeb; border: 1px solid #fde68a;
  border-radius: 8px; padding: 6px 10px; margin-top: -4px;
}
.login-error {
  font-size: 12px; color: #b91c1c;
  background: #fef2f2; border: 1px solid #fecaca;
  border-radius: 8px; padding: 8px 11px; line-height: 1.5;
  animation: fadeUp .22s ease-out both;
}

/* ---- 提交按钮：三种状态（idle / loading / done） ---- */
.login-btn {
  position: relative;
  height: 45px; margin-top: 5px;
  border: 0; border-radius: 10px; cursor: pointer;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  background: linear-gradient(145deg, #5b52ea, #4338ca);
  color: #fff; font-size: 14px; font-weight: 600; letter-spacing: 2px;
  font-family: inherit;
  box-shadow: 0 12px 24px -10px rgba(79, 70, 229, .8);
  transition: transform .12s, box-shadow .18s, opacity .16s, filter .16s;
}
.login-btn:hover:not(:disabled) {
  transform: translateY(-1px);
  filter: saturate(1.08) brightness(1.04);
  box-shadow: 0 16px 30px -10px rgba(79, 70, 229, .85);
}
.login-btn:active:not(:disabled) { transform: translateY(0) scale(.995); }
.login-btn:disabled { cursor: default; opacity: .78; }
.login-btn:focus-visible { outline: 2px solid #a5b4fc; outline-offset: 2px; }
.login-btn.is-done { background: linear-gradient(145deg, #10b981, #059669); box-shadow: 0 12px 24px -10px rgba(16, 185, 129, .8); }

.lb-spin {
  display: none;
  width: 14px; height: 14px; border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, .42);
  border-top-color: #fff;
  animation: spin .62s linear infinite;
}
.login-btn.is-loading .lb-spin { display: block; }
.login-btn.is-loading .lb-text { letter-spacing: 1px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- 左栏底部信任说明的小绿点（.login-dot 给 .lh-foot 复用） ---- */
.login-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: #22c55e; box-shadow: 0 0 0 3px rgba(34, 197, 94, .16); flex: 0 0 auto;
}
.login-copy {
  position: relative; z-index: 1;
  font-size: 11.5px; color: rgba(163, 175, 202, .42); letter-spacing: .2px;
}

/* ============ 响应式 ============ */
@media (max-width: 920px) {
  .login-shell { grid-template-columns: minmax(0, 420px); justify-content: center; gap: 0; }
  .login-hero { display: none; }
  .lp-brand { display: flex; }
  .lp-brand strong { color: var(--text); }
  .lp-brand span { color: var(--text-3); }
}
@media (max-width: 480px) {
  .login-screen { padding: 26px 16px; }
  .login-panel { padding: 28px 22px 22px; border-radius: 16px; }
  .login-title { font-size: 20px; }
}

/* 尊重系统的「减少动效」设置：关掉漂移与描线，只留静态排版 */
@media (prefers-reduced-motion: reduce) {
  .lg-orb, .lh-line, .lh-area, .lh-dot, .lh-points li, .lh-foot,
  .login-hero, .login-panel, .login-error { animation: none !important; }
  .lh-line { stroke-dashoffset: 0; }
  .lh-area, .lh-dot, .lh-points li, .lh-foot { opacity: 1; }
  .login-panel.is-shake { animation: none !important; }
  .lb-spin { animation-duration: 1.4s; }
}

/* ============================================================
 * 移动端 / 触屏适配（手写补充层）
 * 目标：手机窄屏（375~430px）下所有页面都能正常操作，而不是
 * 只能看不能点。重点解决：侧边抽屉关闭、横向溢出、触控目标偏小、
 * 弹窗在窄屏里被 padding 挤扁、表格列被压成竖条。
 * ============================================================ */

/* ---- 侧边抽屉：遮罩 + 关闭按钮 ---- */
.nav-scrim {
  position: fixed; inset: 0; z-index: 55;
  background: rgba(11, 18, 32, .48);
  backdrop-filter: blur(1px);
  animation: fade .16s ease;
}
.nav-scrim[hidden] { display: none; }

.nav-close {
  display: none; /* 只在抽屉形态出现 */
  margin-left: auto; flex: 0 0 auto;
  width: 32px; height: 32px; border-radius: 8px;
  border: 0; background: rgba(255, 255, 255, .08); color: #cbd2e0;
  place-items: center; cursor: pointer;
}
.nav-close:hover { background: rgba(255, 255, 255, .16); color: #fff; }

/* 打开抽屉时锁住页面滚动，避免背景跟着滑 */
body.nav-locked { overflow: hidden; }

/* 顶栏菜单键：桌面隐藏，窄屏显示 */
#btn-menu { display: none; }

@media (max-width: 820px) {
  #btn-menu { display: grid; }

  #app.mobile-nav-open .sidebar {
    z-index: 60;
    animation: slideInLeft .2s cubic-bezier(.2, .8, .3, 1);
  }
  #app.mobile-nav-open .sidebar .nav-close { display: grid; }
  /* 品牌区给关闭按钮留位置：文字可截断，按钮不被挤走 */
  #app.mobile-nav-open .sidebar .sb-brand { padding: 0 8px 0 16px; gap: 8px; }
  #app.mobile-nav-open .sidebar .sb-brand .brand-text { min-width: 0; flex: 1; overflow: hidden; }
  #app.mobile-nav-open .sidebar .sb-brand .brand-text strong,
  #app.mobile-nav-open .sidebar .sb-brand .brand-text span { overflow: hidden; text-overflow: ellipsis; }
}
@keyframes slideInLeft { from { transform: translateX(-16px); opacity: .6 } to { transform: none; opacity: 1 } }

/* ---- 触控目标：手机上按钮/输入框不小于 40px ---- */
@media (max-width: 820px) {
  .btn { height: 38px; padding: 0 14px; }
  .btn-sm { height: 32px; padding: 0 10px; }
  .btn-xs { height: 30px; padding: 0 9px; }
  .btn-icon { width: 38px; padding: 0; }
  .btn-icon.btn-sm { width: 32px; }
  .icon-btn { width: 38px; height: 38px; }
  .input, .select, .textarea { height: 40px; font-size: 16px; } /* 16px 防 iOS 聚焦自动放大 */
  .input-sm, .select-sm { height: 36px; font-size: 15px; }
  .textarea { min-height: 88px; }
  .check { padding: 6px 0; }
  .check input { width: 18px; height: 18px; }
  .chip { height: 32px; padding: 0 13px; }
  .tab { padding: 11px 13px; }
  .segmented .seg { padding: 8px 12px; }
  .seg-item { padding: 7px 12px; }
  .link-btn { padding: 6px 0; }
  .nav-item { padding: 12px 11px; }
  /* 关掉移动端点击高亮块，改用 :active 轻反馈 */
  * { -webkit-tap-highlight-color: transparent; }
  .btn:active, .card:active, .nav-item:active { opacity: .86; }
}

/* ---- 横向溢出治理：任何页面都不能把 body 撑宽 ---- */
@media (max-width: 820px) {
  html, body { max-width: 100%; overflow-x: hidden; }
  .view { min-width: 0; }
  .card, .card-body { min-width: 0; }
  .tabs { overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
  .tabs::-webkit-scrollbar { display: none; }
  .segmented, .seg { max-width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .toolbar { gap: 8px; }
  .toolbar .tb-left { width: 100%; gap: 8px; }
  .toolbar .tb-right { margin-left: 0; width: 100%; }
  .toolbar .search-box { flex: 1 1 100%; width: 100%; }
  .toolbar .tb-left > .select,
  .toolbar .tb-left > .select-sm,
  .toolbar .tb-left > select { flex: 1 1 calc(50% - 4px); max-width: none; min-width: 0; }
  .page-head .actions .btn { flex: 1 1 auto; }
  .f-q { min-width: 0; width: 100%; }
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  /* 手机上 KPI 字号收一点，两列排才不会挤爆 */
  .kpi, .kpi-grid > .kpi { padding: 14px 14px; }
  .kpi .value, .kpi-value { font-size: 20px; letter-spacing: -.3px; }
  .kpi .kpi-icon, .kpi .kpi-ic { right: 12px; top: 12px; width: 30px; height: 30px; border-radius: 9px; }
  .kpi .foot, .kpi-foot { font-size: 11px; }
  .stat-strip { flex-wrap: wrap; }
  .stat-strip > div { flex: 1 1 50%; border-right: 0; border-bottom: 1px solid var(--border); }
  .stat-strip > div:nth-child(odd) { border-right: 1px solid var(--border); }
  .stat-strip > div:last-child { border-bottom: 0; }
  .detail-grid { gap: 12px; }
  .card-head { padding: 14px 16px; }
  .card-body { padding: 14px 16px; }
  .info-list { grid-template-columns: 82px 1fr; }
  .page-head h1 { font-size: 18px; }
}

/* ---- 弹窗 / 抽屉：手机上贴边全宽，别被 24px padding 挤成一条 ---- */
@media (max-width: 820px) {
  .overlay { padding: 12px; align-items: flex-end; }
  .modal { width: 100%; max-height: calc(100vh - 24px); border-radius: 14px; }
  .modal-head { padding: 16px 16px 0; }
  .modal-body { padding: 14px 16px; }
  .modal-foot { padding: 12px 16px; border-radius: 0 0 14px 14px; flex-wrap: wrap; }
  .modal-foot .btn { flex: 1 1 auto; }
  .modal-foot .spacer { display: none; }
  .drawer-head, .drawer-body, .drawer-foot { padding-left: 16px; padding-right: 16px; }
  .remind-panel { top: auto; bottom: 0; right: 0; left: 0; width: 100%; max-height: 78vh; border-radius: 16px 16px 0 0; }
  .quick-menu { max-width: calc(100vw - 20px); }
  .cmdk { padding-top: 8vh; }
  .cmdk-box { max-width: calc(100vw - 20px); max-height: 76vh; }
  .cmdk-input input { font-size: 16px; }
}

/* ---- 日历：手机上 7 列塞不下，改成工作日/日期小卡 + 横向滚动 ---- */
@media (max-width: 820px) {
  .cal { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .cal-head-row, .cal-grid { min-width: 620px; }
  .cal-cell { min-height: 96px; padding: 5px; }
  .cal-ev { font-size: 10px; padding: 2px 4px; }
}

/* ---- 看板 / 列表：手机上卡片窄一点，多露半张 ---- */
@media (max-width: 480px) {
  .kanban-col { flex-basis: 82vw; width: 82vw; }
  .kpi-grid { grid-template-columns: 1fr; }
  .grid-5 { grid-template-columns: 1fr; }
  .page-head .actions .btn { flex: 1 1 100%; }
  .stat-strip > div { flex: 1 1 100%; border-right: 0 !important; }
}

/* ---------- 客户详情页头部：窄屏纵向堆叠，避免标题被挤成竖排 ---------- */
.cd-head { align-items: flex-start; gap: 14px; }
.cd-head-main { min-width: 0; flex: 1 1 auto; }
.cd-head-main h2 { line-height: 1.35; }
.cd-head-actions { margin-left: auto; gap: 8px; flex: 0 0 auto; flex-wrap: wrap; justify-content: flex-end; }
/* 操作按钮变多以后（加了「打印 / PDF」），nowrap 会让标题列被压成一条竖缝，
   所以这里允许整行换行：按钮凑不齐就整体掉到第二行，标题列保住最小可读宽度。 */
.row.nowrap.cd-head { flex-wrap: wrap; }
.cd-head-main { flex: 1 1 260px; }
@media (max-width: 820px) {
  /* 用 .row.nowrap.cd-head 提高优先级，压过 .row.nowrap 的 nowrap */
  .row.nowrap.cd-head { flex-wrap: wrap; row-gap: 12px; }
  .cd-head-main { flex: 1 1 calc(100% - 68px); min-width: 0; }
  .cd-head-actions { margin-left: 0; width: 100%; flex: 1 1 100%; justify-content: flex-start; }
  .cd-head-actions .btn { flex: 1 1 calc(50% - 4px); justify-content: center; }
}

/* ---------- 通用 grid 里的 KPI 卡：手机上保持两列，别一张占一整行 ---------- */
@media (max-width: 820px) {
  .grid.grid-4:has(> .kpi),
  .grid.grid-3:has(> .kpi) { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid.grid-4 > .kpi, .grid.grid-3 > .kpi { padding: 14px; }
  .grid.grid-4 > .kpi .value, .grid.grid-3 > .kpi .value { font-size: 20px !important; }
}
@media (max-width: 480px) {
  .grid.grid-4:has(> .kpi) { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* ---------- 日历：手机上改成整月铺满 7 列，事件只留圆点/短标题 ---------- */
@media (max-width: 820px) {
  .cal { overflow: hidden; }
  .cal-head-row, .cal-grid { min-width: 0; }
  .cal-head-row div { padding: 6px 0; font-size: 10.5px; }
  .cal-cell { min-height: 72px; padding: 3px 4px; }
  .cal-date { font-size: 10.5px; margin-bottom: 2px; }
  .cal-ev { font-size: 0; padding: 0; height: 5px; border-radius: 3px; border-left: 0; margin-bottom: 3px; background: var(--brand); }
  .cal-ev.red { background: var(--danger); }
  .cal-ev.green { background: var(--success); }
  .cal-ev.done { background: #cfd4e2; }
  .cal-more { font-size: 9.5px; padding-left: 0; line-height: 1.2; }
  /* 当天有事时把日期点成实心，便于扫读 */
  .cal-cell:has(.cal-ev) .cal-date { font-weight: 700; }
}

/* ---------- KPI 栅格：820px 下统一两列（含 cols-3 / cols-5，报表页 6 张卡） ---------- */
@media (max-width: 820px) {
  .kpi-grid.cols-3, .kpi-grid.cols-5 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi .kpi-top, .kpi-top { gap: 6px; }
  .kpi .kpi-label, .kpi-label { font-size: 11.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
}

/* ---------- 跟进动态：手机上日期筛选并排，隐藏「至」分隔符 ---------- */
@media (max-width: 820px) {
  .toolbar > input[type="date"].input,
  .toolbar > input[type="date"].input-sm { width: auto !important; flex: 1 1 calc(50% - 6px); min-width: 0; }
  /* 只隐藏「至」这个分隔符，别把右侧计数一起藏了 */
  .toolbar > .text-sm.text-3:not([data-el]) { display: none; }
  .toolbar > .spacer { display: none; }
  .toolbar > .btn[data-act="reset"] { order: 90; flex: 0 0 auto; width: auto; height: 34px; }
  .toolbar > [data-el="count"] { order: 91; margin-left: auto; text-align: right; white-space: nowrap; }
}

/* ---------- 表格内的行内编辑控件：手机上别被压成「初」一个字 ---------- */
@media (max-width: 820px) {
  .table-wrap .tbl .input,
  .table-wrap .tbl .select,
  .table-wrap .tbl .input-sm,
  .table-wrap .tbl .select-sm { min-width: 84px; width: 100%; }
  .table-wrap .tbl th, .table-wrap .tbl td { white-space: nowrap; }
  .table-wrap .tbl td .muted, .table-wrap .tbl td .text-3 { white-space: nowrap; }
}

/* ---------- 设置-销售阶段表：手机上压缩列宽，尽量一屏放下 ---------- */
@media (max-width: 820px) {
  .table-wrap .tbl { min-width: 0; }
  .table-wrap .tbl th, .table-wrap .tbl td { padding-left: 6px; padding-right: 6px; }
  .table-wrap .tbl .input, .table-wrap .tbl .input-sm { min-width: 76px; padding: 6px 8px; font-size: 13px; }
  .table-wrap .tbl td .btn-icon, .table-wrap .tbl td .icon-btn { width: 26px; height: 26px; }
}

/* ============================================================
   实时协作 / 附件 / 异步导入（第三轮新增）
   ============================================================ */

/* ---------- 顶栏在线人数 ---------- */
.online-chip {
  display: flex; align-items: center; gap: 6px;
  height: 34px; padding: 0 10px 0 4px;
  border-radius: 18px; background: #eef2ff; color: #3730a3;
  font-size: 12px; font-weight: 600; white-space: nowrap;
}
.online-chip[hidden] { display: none; }
.online-chip .av-stack { display: flex; }
.online-chip .av-stack > span { margin-left: -6px; }
.online-chip .av-stack > span:first-child { margin-left: 0; }
.online-chip .av-stack .avatar { border: 2px solid #eef2ff; }
.online-chip .live-dot {
  width: 7px; height: 7px; border-radius: 50%; background: var(--success);
  box-shadow: 0 0 0 3px rgba(16,185,129,.16); margin-left: 2px;
}
@media (max-width: 820px) {
  .online-chip { height: 30px; padding: 0 8px 0 3px; font-size: 11px; }
  .online-chip .live-text { display: none; }
}

/* ---------- 连接状态小圆点（断线时提示） ---------- */
.live-off .live-dot { background: var(--text-3); box-shadow: none; }

/* ---------- 附件列表 ---------- */
.file-ico {
  flex: 0 0 auto; width: 34px; height: 34px; margin-right: 10px;
  display: grid; place-items: center;
  border-radius: 9px; background: #f1f5f9; font-size: 17px; line-height: 1;
}
.list-item .li-sub { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- 拖拽上传区 ---------- */
.dropzone {
  margin-top: 12px; padding: 18px 14px;
  border: 1.5px dashed var(--border); border-radius: 10px;
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  color: var(--text-3); font-size: 12.5px;
  transition: border-color .15s, background .15s, color .15s;
}
.dropzone.over {
  border-color: var(--brand); background: #eef2ff; color: var(--brand);
}
@media (max-width: 820px) {
  .dropzone { padding: 14px 10px; font-size: 12px; }
  .file-ico { width: 30px; height: 30px; font-size: 15px; margin-right: 8px; }
}

/* ---------- 异步导入进度 ---------- */
.import-progress { margin-top: 14px; display: none; }
.import-progress.on { display: block; }
.import-progress .bar {
  height: 8px; border-radius: 5px; background: #e5e7eb; overflow: hidden;
}
.import-progress .bar > i {
  display: block; height: 100%; width: 0;
  background: linear-gradient(90deg, var(--brand), #7c7cf0);
  transition: width .25s ease;
}
.import-progress .meta {
  display: flex; justify-content: space-between;
  font-size: 12px; color: var(--text-3); margin-top: 6px;
}
.import-progress.done .bar > i { background: var(--success); }
.import-progress.failed .bar > i { background: var(--danger); }

/* ---------- 冲突提示 ---------- */
.conflict-line {
  display: flex; align-items: flex-start; gap: 8px;
  padding: 10px 12px; margin-bottom: 12px;
  border-radius: 9px; background: #fff7ed; color: #9a3412;
  border: 1px solid #fed7aa; font-size: 12.5px; line-height: 1.6;
}
.conflict-line strong { font-weight: 700; }

/* ============================================================
 *  表头排序（A1）：可点表头有 hover 与箭头，当前排序列高亮
 *  ui.table() 只有在列定义里给了 sortKey 时才输出这种 th，
 *  所以其他表格（只读表格）不会出现误点的箭头。
 * ============================================================ */
.tbl thead th.th-sort {
  cursor: pointer; user-select: none; white-space: nowrap;
  transition: color .12s, background .12s;
}
.tbl thead th.th-sort:hover { color: var(--brand); background: var(--brand-50, #eef2ff); }
.tbl thead th.th-sort .th-label { display: inline-block; }
.tbl thead th.th-sort .th-arrow {
  display: inline-block; min-width: 10px; margin-left: 3px;
  font-size: 10px; font-weight: 700; color: var(--brand);
  opacity: 0; transition: opacity .12s;
}
.tbl thead th.th-sort:hover .th-arrow { opacity: .45; }
.tbl thead th.th-sort.is-sorted { color: var(--brand); }
.tbl thead th.th-sort.is-sorted .th-arrow { opacity: 1; }

/* ---------- 带操作按钮的提示条（A6 撤销删除） ---------- */
.toast.toast-has-action { pointer-events: auto; gap: 10px; padding-right: 6px; }
.toast .toast-msg { flex: 1; min-width: 0; }
.toast .toast-act {
  flex: 0 0 auto; height: 24px; padding: 0 10px; border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, .38); background: rgba(255, 255, 255, .14);
  color: inherit; font-size: 12px; font-weight: 600; cursor: pointer;
  transition: background .12s, border-color .12s;
}
.toast .toast-act:hover { background: rgba(255, 255, 255, .26); border-color: rgba(255, 255, 255, .6); }
@media (max-width: 820px) {
  .toast-wrap { left: 12px; right: 12px; transform: none; align-items: stretch; }
  .toast { width: 100%; }
}

/* ============================================================
 * 合同回款（B1）
 * ============================================================ */
.pay-bar {
  height: 6px;
  border-radius: 4px;
  background: #eef1f7;
  overflow: hidden;
  margin-top: 5px;
}
.pay-bar > i {
  display: block;
  height: 100%;
  border-radius: 4px;
  transition: width .25s ease;
}
.pay-bar.none > i { background: #e2e6ef; }

/* ============================================================
 * 报表下钻筛选条（B3）
 * ============================================================ */
.dim-bar {
  margin: 2px 0 14px;
}
.dim-bar .dim-inner {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 9px 13px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-2);
}
.dim-bar .dim-label {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-2);
  margin-right: 2px;
}
.dim-bar select { min-width: 116px; }
@media (max-width: 820px) {
  .dim-bar .dim-inner { gap: 6px; }
  .dim-bar select { flex: 1 1 46%; min-width: 0; }
}

/* ============================================================
 * 目标拆解（B2）
 * ============================================================ */
.target-rows { display: flex; flex-direction: column; gap: 2px; }
.target-row {
  display: flex; align-items: center; gap: 12px;
  padding: 9px 2px; border-bottom: 1px solid var(--border);
}
.target-row:last-child { border-bottom: 0; }
.target-row.total { border-top: 1px solid var(--border); margin-top: 2px; padding-top: 11px; }
.target-row .tr-name { flex: 1; min-width: 0; font-size: 13.5px; display: flex; align-items: center; gap: 7px; }
.target-row .tr-name .dot { width: 8px; height: 8px; border-radius: 50%; flex: 0 0 auto; }
.target-row .tr-input { display: flex; align-items: center; gap: 6px; flex: 0 0 190px; }
.target-row .tr-input input { width: 100%; text-align: right; }
.target-row .tr-input .unit { font-size: 12px; color: var(--text-3); }
.compare-box { display: flex; flex-direction: column; gap: 10px; }
.compare-box .cmp-line { display: flex; justify-content: space-between; align-items: baseline; font-size: 13.5px; }
.compare-box .cmp-line .k { color: var(--text-3); }
.compare-box .cmp-line .v { font-weight: 650; font-size: 15px; }
.compare-box .cmp-bar { margin: 2px 0 4px; }
@media (max-width: 820px) {
  .target-row { flex-wrap: wrap; }
  .target-row .tr-input { flex: 1 1 100%; }
}

/* ============================================================
 * 客户合并（B4）
 * ============================================================ */
.merge-box { display: flex; flex-direction: column; gap: 10px; }
.merge-hint { font-size: 13px; color: var(--text-2); }
.merge-list { display: flex; flex-direction: column; gap: 6px; max-height: 320px; overflow: auto; }
.merge-row {
  display: flex; align-items: center; gap: 10px; padding: 9px 12px;
  border: 1px solid var(--border); border-radius: 9px; cursor: pointer;
  transition: border-color .12s, background .12s;
}
.merge-row:hover { border-color: var(--brand); background: var(--brand-50, #eef2ff); }
.merge-row.is-master { border-color: var(--brand); background: var(--brand-50, #eef2ff); }
.merge-row input[type="radio"] { flex: 0 0 auto; margin: 0; }
.merge-row .mr-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.merge-row .mr-name { font-size: 13.5px; font-weight: 600; }
.merge-row .mr-sub { font-size: 11.5px; color: var(--text-3); }
.merge-row .mr-stat { flex: 0 0 auto; font-size: 11.5px; color: var(--text-3); text-align: right; }
.merge-note {
  display: flex; gap: 6px; align-items: flex-start;
  font-size: 12px; color: var(--text-3); line-height: 1.55;
  background: #f8fafc; border-radius: 8px; padding: 9px 11px;
}
@media (max-width: 820px) {
  .merge-row { flex-wrap: wrap; }
  .merge-row .mr-stat { flex: 1 1 100%; text-align: left; }
}

/* ============================================================
 * 自定义字段（B5）
 * ============================================================ */
.cf-group + .cf-group { margin-top: 18px; }
.cf-group-head {
  display: flex; align-items: baseline; gap: 10px;
  padding: 0 2px 8px; border-bottom: 1px solid var(--border); margin-bottom: 2px;
}
.cf-key {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 11.5px; padding: 2px 6px; border-radius: 5px;
  background: #f1f5f9; color: var(--text-2);
}
.cf-req { color: #dc2626; margin-left: 2px; font-weight: 700; }
.cf-empty {
  padding: 22px 2px; text-align: center; font-size: 13px; color: var(--text-3);
}
.cf-empty-lg {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 44px 20px; text-align: center; color: var(--text-3);
}
.cf-empty-lg .t { font-size: 14px; font-weight: 600; color: var(--text-2); }
.cf-empty-lg .d { font-size: 12.5px; max-width: 420px; line-height: 1.6; }
.field.is-off, .form-item.is-off { opacity: .5; }

/* ==================== 日历周/日视图 + 按人看（B6） ==================== */
.cal-bar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.cal-bar .cal-period { font-size: 15px; font-weight: 680; }
.cal-bar [data-owner] { min-width: 120px; }

/* 周视图：7 列，每列是一条当天的时间线 */
.cal-wk-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.cal-wk-col { border-right: 1px solid var(--border); min-height: 220px; padding: 8px 7px 12px; display: flex; flex-direction: column; }
.cal-wk-col:last-child { border-right: 0; }
.cal-wk-col.today { background: #f5f6ff; }
.cal-wk-date { display: flex; align-items: center; gap: 5px; padding-bottom: 7px; margin-bottom: 7px; border-bottom: 1px solid var(--fill-2); }
.cal-wk-date b { font-size: 16px; font-weight: 700; color: var(--text); }
.cal-wk-date span { font-size: 11px; color: var(--text-3); }
.cal-wk-col.today .cal-wk-date b { color: var(--brand); }
.cal-wk-date .cal-add { margin-left: auto; }
.cal-wk-evs { display: flex; flex-direction: column; gap: 4px; }
.cal-wk-empty { color: var(--text-4); font-size: 12px; text-align: center; padding-top: 6px; }

/* 日视图：一行一条任务，信息更全 */
.cal-day { padding: 6px 4px; }
.cal-day-row { display: flex; align-items: center; gap: 10px; padding: 11px 8px; border-bottom: 1px solid var(--fill-2); cursor: pointer; border-radius: 8px; }
.cal-day-row:hover { background: #fafbff; }
.cal-day-row:last-child { border-bottom: 0; }
.cal-day-row.is-done { opacity: .72; }
.cdr-time { width: 52px; flex: 0 0 52px; font-size: 12.5px; color: var(--text-3); }
.cdr-bar { width: 3px; height: 32px; border-radius: 2px; flex: 0 0 3px; }
.cdr-main { flex: 1; min-width: 0; }
.cdr-title { font-weight: 600; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cdr-title.is-done { text-decoration: line-through; color: var(--text-3); }
.cdr-sub { font-size: 12px; color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-top: 2px; }
.cdr-btn { height: 26px; padding: 0 9px; flex: 0 0 auto; }
.cal-day-empty { padding: 40px 0; text-align: center; color: var(--text-3); font-size: 13px; display: flex; align-items: center; justify-content: center; gap: 10px; }

/* 单元格右上角的「+」按钮（三种视图共用） */
.cal-add { position: absolute; top: 4px; right: 6px; width: 18px; height: 18px; border-radius: 5px; display: grid; place-items: center; color: var(--text-4); cursor: pointer; background: transparent; }
.cal-add:hover { color: var(--brand); background: var(--brand-50, #eef2ff); }
.cal-wk-date .cal-add { position: static; }

@media (max-width: 1024px) {
  .cal-wk-grid { grid-template-columns: repeat(7, minmax(96px, 1fr)); overflow-x: auto; }
}
@media (max-width: 820px) {
  .cal-bar { gap: 8px; }
  .cal-bar .cal-period { width: 100%; font-size: 14px; }
  .cal-wk-grid { grid-template-columns: repeat(7, minmax(84px, 1fr)); }
  .cal-wk-col { min-height: 180px; padding: 6px 5px 10px; }
  .cal-wk-date b { font-size: 14px; }
  .cdr-time { width: 44px; flex: 0 0 44px; font-size: 11.5px; }
  .cdr-title { font-size: 13px; }
  .cal-day-row { padding: 9px 5px; gap: 8px; }
}

/* ==================== 跟进话术模板（B7） ==================== */
.tpl-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding: 0 0 12px; margin-bottom: 4px; border-bottom: 1px dashed var(--border); }
.tpl-label { font-size: 12px; font-weight: 600; color: var(--text-3); margin-right: 2px; }
.tpl-chip {
  height: 26px; padding: 0 11px; border-radius: 20px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text-2); font-size: 12px; cursor: pointer; max-width: 220px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; transition: all .12s;
}
.tpl-chip:hover { border-color: var(--brand); color: var(--brand); background: var(--brand-50, #eef2ff); }
.tpl-chip.is-used { border-color: var(--brand); color: var(--brand); background: var(--brand-50, #eef2ff); font-weight: 600; }
@media (max-width: 820px) { .tpl-chip { max-width: 100%; } }

/* ==================== 话术模板管理（B7） ==================== */
.tpl-preview {
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden; max-width: 520px; line-height: 1.55; word-break: break-word;
}
@media (max-width: 820px) { .tpl-preview { max-width: none; } }

/* ==================== 暗色模式（C1） ====================
   只覆盖变量 + 少量硬编码语义色（badge / alert / toast / 日历色条）。
   组件样式全部走变量，所以这里不需要重写任何布局。 */
html[data-theme="dark"] {
  --brand: #6366f1;
  --brand-600: #4f46e5;
  --brand-50: #1e2036;
  --brand-100: #272a45;

  --bg: #0e1220;
  --card: #161b2b;
  --surface: #161b2b;
  --surface-2: #1b2133;
  --border: #262d42;
  --border-soft: #1f2537;
  --border-strong: #333b55;
  --text: #e6e9f2;
  --text-2: #a9b1c6;
  --text-3: #7d869c;
  --text-4: #5c6479;

  --topbar-bg: rgba(22, 27, 43, .86);
  --fill: #1d2334;
  --fill-2: #1f2637;
  --hover-soft: #1c2233;

  --success: #34d399;
  --success-50: #10281f;
  --warning: #fbbf24;
  --warning-50: #2a2113;
  --danger: #f87171;
  --danger-50: #2c1618;
  --info: #38bdf8;
  --info-50: #10222f;

  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 1px 3px rgba(0, 0, 0, .24);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, .36), 0 2px 4px rgba(0, 0, 0, .24);
  --shadow-lg: 0 12px 32px rgba(0, 0, 0, .5), 0 4px 8px rgba(0, 0, 0, .3);
}
html[data-theme="dark"] ::-webkit-scrollbar-thumb { background: #2f3750; background-clip: content-box; border: 2px solid transparent; }
html[data-theme="dark"] ::-webkit-scrollbar-thumb:hover { background: #3d476a; background-clip: content-box; }

/* 语义色徽标：浅色主题是「浅底深字」，暗色主题反过来「深底浅字」 */
html[data-theme="dark"] .badge.gray { background: #232a3d; color: #a9b1c6; }
html[data-theme="dark"] .badge.blue { background: #1d2440; color: #a5b4fc; }
html[data-theme="dark"] .badge.green { background: #10281f; color: #6ee7b7; }
html[data-theme="dark"] .badge.amber { background: #2a2113; color: #fcd34d; }
html[data-theme="dark"] .badge.red { background: #2c1618; color: #fca5a5; }
html[data-theme="dark"] .badge.purple { background: #221c3b; color: #c4b5fd; }
html[data-theme="dark"] .badge.cyan { background: #10242b; color: #67e8f9; }
html[data-theme="dark"] .badge.solid { color: #fff; }
html[data-theme="dark"] .level-A { background: #10281f; color: #6ee7b7; border-color: #1c5a43; }
html[data-theme="dark"] .level-B { background: #2a2113; color: #fcd34d; border-color: #5c4715; }
html[data-theme="dark"] .level-C { background: #10222f; color: #7dd3fc; border-color: #1a4a63; }
html[data-theme="dark"] .level-D { background: #232a3d; color: #a9b1c6; border-color: #333b55; }
html[data-theme="dark"] .alert.warn { background: #2a2113; border-color: #4d3a12; color: #fcd34d; }
html[data-theme="dark"] .alert.info { background: #10222f; border-color: #1a4a63; color: #7dd3fc; }
html[data-theme="dark"] .alert.danger { background: #2c1618; border-color: #5a2a2c; color: #fca5a5; }
html[data-theme="dark"] .alert.success { background: #10281f; border-color: #1c5a43; color: #6ee7b7; }

/* 输入类：暗色下白底会刺眼 */
html[data-theme="dark"] input,
html[data-theme="dark"] textarea,
html[data-theme="dark"] select { background: var(--surface-2); color: var(--text); }
html[data-theme="dark"] .input:disabled,
html[data-theme="dark"] .select:disabled { background: var(--fill-2); color: var(--text-3); }
html[data-theme="dark"] .skeleton { background: linear-gradient(90deg, #1f2637 25%, #262d42 37%, #1f2637 63%); background-size: 400% 100%; }
html[data-theme="dark"] kbd { background: #232a3d; color: #a9b1c6; border-color: #333b55; }
html[data-theme="dark"] .toast { background: #232a3d; color: #e6e9f2; }
html[data-theme="dark"] .overlay { background: rgba(4, 6, 14, .62); }
html[data-theme="dark"] .modal { border: 1px solid var(--border); }
html[data-theme="dark"] .nav-scrim { background: rgba(4, 6, 14, .6); }

/* 日历 / 图表里写死的浅底色条不跟着变量走，单独抬亮一点 */
html[data-theme="dark"] .pay-bar { background: #232a3d; }
html[data-theme="dark"] .bar-track { background: #232a3d; }
html[data-theme="dark"] .tl-body { border-color: var(--border-soft); }
html[data-theme="dark"] .muted-box { border-color: var(--border-soft); }
@media (max-width: 820px) { html[data-theme="dark"] .overlay { background: rgba(4, 6, 14, .7); } }

/* ==================== 跨页批量选择提示（C4） ==================== */
.bulkbar .cnt .offpage { font-style: normal; font-weight: 500; color: var(--warning); margin-left: 4px; }
html[data-theme="dark"] .bulkbar .cnt .offpage { color: #fcd34d; }

/* ==================== 行内快速编辑（C2） ==================== */
.inline-edit {
  border: 0; background: transparent; padding: 0; margin: 0; font: inherit;
  color: inherit; cursor: pointer; border-radius: 6px; display: inline-flex; align-items: center;
  transition: box-shadow .12s, background .12s;
}
.inline-edit:hover { background: var(--brand-50); box-shadow: 0 0 0 3px var(--brand-50); }
.inline-pop {
  position: fixed; z-index: 200; min-width: 136px; max-height: 320px; overflow: auto;
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  box-shadow: var(--shadow-lg); padding: 5px; animation: popIn .1s ease;
}
@keyframes popIn { from { opacity: 0; transform: translateY(-3px); } to { opacity: 1; transform: none; } }
.inline-pop .ip-title { font-size: 11px; font-weight: 600; color: var(--text-3); padding: 5px 8px 4px; }
.inline-pop .ip-item {
  display: flex; align-items: center; gap: 8px; width: 100%; padding: 6px 8px;
  border: 0; background: transparent; border-radius: 7px; font-size: 12.5px; color: var(--text);
  cursor: pointer; text-align: left; white-space: nowrap;
}
.inline-pop .ip-item:hover { background: var(--fill-2); }
.inline-pop .ip-item.is-on { background: var(--brand-50); color: var(--brand); font-weight: 600; }
.inline-pop .ip-desc { font-size: 11px; color: var(--text-3); margin-left: auto; }
html[data-theme="dark"] .inline-edit:hover { background: var(--brand-50); box-shadow: 0 0 0 3px var(--brand-50); }

/* ============================================================
   暗色模式补遗（C1）
   上面第一轮只把「background:#fff」家族抽成了变量，但仍有一批
   浅色底是写死的（hover 灰、kanban 列底、日历今天底等）。深色下
   这些会变成刺眼的亮块 —— 最典型的是顶栏主题按钮 hover 时糊成
   一个白方块把图标盖住。这里按「同一个视觉角色」逐一映射到深色。
   ============================================================ */
html[data-theme="dark"] .icon-btn:hover,
html[data-theme="dark"] .btn-ghost:hover,
html[data-theme="dark"] .user-chip:hover { background: var(--fill); }
html[data-theme="dark"] .btn:hover { background: var(--surface-2); border-color: var(--border-strong); }
html[data-theme="dark"] .btn-danger:hover { background: #3a1a1d; border-color: #5a2a2c; color: #fca5a5; }
html[data-theme="dark"] .search-trigger:hover,
html[data-theme="dark"] .tb-search:hover { background: var(--fill-2); }
html[data-theme="dark"] .tb-search,
html[data-theme="dark"] .search-trigger { background: var(--fill); }
html[data-theme="dark"] .pill-group > button:hover { background: var(--fill-2); }
html[data-theme="dark"] .quick-menu button:hover,
html[data-theme="dark"] .user-list .user-row:hover,
html[data-theme="dark"] .cmdk-item:hover,
html[data-theme="dark"] .cmdk-item.sel { background: var(--fill); }

html[data-theme="dark"] .modal-foot,
html[data-theme="dark"] .drawer-foot,
html[data-theme="dark"] .cmdk-foot,
html[data-theme="dark"] .stat-strip,
html[data-theme="dark"] .task-detail { background: var(--surface-2); }
html[data-theme="dark"] .kanban-col { background: var(--surface-2); border-color: var(--border-soft); }
html[data-theme="dark"] .kanban-col-head .cnt { background: var(--fill-2); color: var(--text-2); }
html[data-theme="dark"] .progress,
html[data-theme="dark"] .import-progress .bar { background: var(--fill-2); }
html[data-theme="dark"] .pay-bar.none > i { background: var(--fill-2); }
html[data-theme="dark"] .file-ico,
html[data-theme="dark"] .cf-key { background: var(--fill-2); color: var(--text-2); }
html[data-theme="dark"] .merge-note { background: var(--surface-2); color: var(--text-3); }
html[data-theme="dark"] .online-chip { background: var(--brand-50); color: #a5b4fc; }
html[data-theme="dark"] .dropzone.over { background: var(--brand-50); border-color: var(--brand); }
html[data-theme="dark"] .conflict-line { background: #2a2113; color: #fcd34d; border-color: #5c4715; }
html[data-theme="dark"] .login-field input { background: var(--surface-2); border-color: var(--border); color: var(--text); }
html[data-theme="dark"] .login-error { background: #2c1618; border-color: #5a2a2c; color: #fca5a5; }
html[data-theme="dark"] .login-caps { background: #2a2113; border-color: #5c4715; color: #fcd34d; }
html[data-theme="dark"] .login-panel { box-shadow: 0 30px 80px -24px rgba(0,0,0,.85), 0 0 0 1px rgba(255,255,255,.06); }
html[data-theme="dark"] .li-ico { color: var(--text-3); }
html[data-theme="dark"] .login-input input::placeholder { color: var(--text-4); }

html[data-theme="dark"] .kpi.tone-green .kpi-ic { background: #10281f; }
html[data-theme="dark"] .kpi.tone-amber .kpi-ic { background: #2a2113; }
html[data-theme="dark"] .kpi.tone-red .kpi-ic { background: #2c1618; }
html[data-theme="dark"] .kpi.tone-blue .kpi-ic { background: #10222f; }
html[data-theme="dark"] .tl-dot.purple { background: #221c3b; }

html[data-theme="dark"] .cal-cell.other,
html[data-theme="dark"] .cal-cell.today,
html[data-theme="dark"] .cal-cell:hover,
html[data-theme="dark"] .cal-wk-col.today,
html[data-theme="dark"] .cal-day-row:hover { background: var(--surface-2); }
html[data-theme="dark"] .cal-cell.today,
html[data-theme="dark"] .cal-wk-col.today { background: var(--brand-50); }
html[data-theme="dark"] .cal-ev.done { background: var(--fill-2); }

/* ============================================================
   表格首列冻结 + 列宽可拖（C3）
   只有列多的表（客户 / 商机）才开 sticky，小表硬冻第一列会显得别扭。
   冻结列的背景必须自己兜住，否则横向滚动时下面单元格的文字会透上来。
   ============================================================ */
.table-wrap.tbl-sticky { overflow: auto; }
.tbl .tbl-th { position: relative; }
.tbl .tbl-stick {
  position: sticky; left: 0; z-index: 3;
  background: var(--surface);
}
.tbl thead th.tbl-stick { background: var(--surface-2); z-index: 4; }
.tbl tbody tr:hover .tbl-stick { background: var(--hover-soft); }
.tbl tbody tr.is-selected .tbl-stick { background: var(--brand-50); }
/* 冻结列右侧的分隔阴影，滚动时才有「边缘」感 */
.tbl .tbl-stick::after {
  content: ''; position: absolute; top: 0; right: 0; bottom: -1px; width: 1px;
  background: var(--border);
}
.tbl thead th.tbl-stick::after { background: var(--border-strong); }

/* 列宽拖拽手柄：平时透明，hover 表头才显形，避免表格看起来毛糙 */
.tbl .col-grip {
  position: absolute; top: 0; right: -3px; bottom: 0; width: 7px;
  cursor: col-resize; z-index: 5; user-select: none;
}
.tbl .col-grip::before {
  content: ''; position: absolute; top: 22%; bottom: 22%; left: 3px; width: 1.5px;
  background: var(--border-strong); opacity: 0; transition: opacity .12s;
}
.tbl thead th:hover .col-grip::before { opacity: .75; }
.tbl .col-grip:hover::before { opacity: 1; background: var(--brand); }
body.col-resizing { cursor: col-resize; user-select: none; }
body.col-resizing .tbl .col-grip::before { opacity: 1; background: var(--brand); }

html[data-theme="dark"] .tbl .tbl-stick { background: var(--surface); }
html[data-theme="dark"] .tbl thead th.tbl-stick { background: var(--surface-2); }
html[data-theme="dark"] .tbl tbody tr:hover .tbl-stick { background: var(--hover-soft); }

/* ============================================================
 * 空库首次进入引导（C5）+ 快捷键说明面板（C6）
 * ============================================================ */

/* ---------- C5 引导 ---------- */
.ob-wrap { display: grid; gap: 12px; }
.ob-lead { font-size: 13px; color: var(--text-2); line-height: 1.75; margin: 0; }
.ob-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.ob-item {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 12px 13px; border: 1px solid var(--border); border-radius: 10px;
  background: var(--surface-2);
}
.ob-idx {
  flex: 0 0 20px; height: 20px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 11.5px; font-weight: 700; color: #fff; background: var(--brand);
}
.ob-ico {
  flex: 0 0 26px; height: 26px; border-radius: 8px;
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--brand); background: var(--brand-50);
}
.ob-main { flex: 1; min-width: 0; }
.ob-title { font-size: 13.5px; font-weight: 650; color: var(--text); }
.ob-desc { font-size: 12.5px; color: var(--text-2); line-height: 1.65; margin-top: 3px; }
.ob-tip { font-size: 12px; color: var(--text-3); line-height: 1.6; margin-top: 4px; }
.ob-go { flex: 0 0 auto; align-self: center; white-space: nowrap; }
@media (max-width: 820px) {
  .ob-item { flex-wrap: wrap; }
  .ob-go { margin-left: 56px; }
}

/* ---------- C6 快捷键 ---------- */
.sc-wrap { display: grid; gap: 18px; }
.sc-group-head {
  font-size: 12px; font-weight: 700; letter-spacing: .04em;
  color: var(--text-3); text-transform: uppercase; margin-bottom: 8px;
}
.sc-rows { display: grid; gap: 2px; }
.sc-row {
  display: flex; align-items: center; gap: 12px;
  padding: 6px 8px; border-radius: 7px;
}
.sc-row:hover { background: var(--surface-2); }
.sc-keys { flex: 0 0 132px; display: flex; align-items: center; gap: 3px; flex-wrap: wrap; }
.sc-key {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 22px; height: 22px; padding: 0 6px;
  border: 1px solid var(--border); border-bottom-width: 2px; border-radius: 5px;
  background: var(--surface); color: var(--text);
  font-size: 11.5px; font-weight: 600; font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}
.sc-plus { font-size: 10px; color: var(--text-3); }
.sc-act {
  font-size: 12px; font-weight: 600; color: var(--brand);
  background: var(--brand-50); padding: 2px 8px; border-radius: 5px; white-space: nowrap;
}
.sc-desc { flex: 1; min-width: 0; font-size: 12.5px; color: var(--text-2); line-height: 1.6; }
.sc-foot {
  display: flex; align-items: flex-start; gap: 6px;
  font-size: 12px; color: var(--text-3); line-height: 1.65;
  padding-top: 10px; border-top: 1px solid var(--border-soft);
}
@media (max-width: 820px) {
  .sc-keys { flex: 0 0 92px; }
}

/* ===========================================================================
   客户档案打印 / 导出 PDF（C7）
   ---------------------------------------------------------------------------
   不引第三方库：屏幕上把 .print-sheet 挂进 body，再由 @media print 决定
   「打印时只显示纸面」。屏幕下 print-host 常驻 display:none，所以日常完全不可见。
   导出 PDF = 浏览器打印对话框里选「另存为 PDF」，中文字体沿用系统字体，不用打包。
   =========================================================================== */

.print-host { display: none; }

/* ---------- 纸面基础样式（打印时才生效，屏幕上不参与布局） ---------- */
.print-sheet {
  color: #1a1d29;
  background: #fff;
  font-size: 12px;
  line-height: 1.6;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Source Han Sans SC", sans-serif;
}

.print-sheet .ps-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  padding-bottom: 12px;
  border-bottom: 2px solid #1a1d29;
}
.print-sheet .ps-head h1 {
  margin: 0 0 6px;
  font-size: 20px;
  font-weight: 700;
  line-height: 1.3;
}
.print-sheet .ps-head-meta { display: flex; flex-wrap: wrap; gap: 6px; }
.print-sheet .ps-chip {
  display: inline-block;
  padding: 1px 7px;
  border: 1px solid #c9cdd8;
  border-radius: 4px;
  font-size: 10.5px;
  color: #4a5061;
  white-space: nowrap;
}
.print-sheet .ps-head-side { text-align: right; flex: 0 0 auto; }
.print-sheet .ps-brand { font-size: 11px; font-weight: 600; color: #4a5061; }
.print-sheet .ps-stamp { font-size: 10px; color: #7b8296; margin-top: 3px; }

/* 关键指标条 */
.print-sheet .ps-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 0;
  margin: 14px 0 4px;
  border: 1px solid #dfe2ea;
  border-radius: 6px;
  overflow: hidden;
}
.print-sheet .ps-stats > div {
  flex: 1 1 0;
  min-width: 108px;
  padding: 8px 12px;
  border-right: 1px solid #dfe2ea;
}
.print-sheet .ps-stats > div:last-child { border-right: 0; }
.print-sheet .ps-stats .k { display: block; font-size: 10px; color: #7b8296; }
.print-sheet .ps-stats .v { display: block; font-size: 14px; font-weight: 700; margin-top: 2px; }

/* 分区 */
.print-sheet .ps-sec { margin-top: 16px; break-inside: auto; }
.print-sheet .ps-sec-title {
  margin: 0 0 6px;
  padding-bottom: 4px;
  font-size: 12.5px;
  font-weight: 700;
  border-bottom: 1px solid #dfe2ea;
}

/* 两列信息表 */
.print-sheet .ps-kv {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}
.print-sheet .ps-kv th,
.print-sheet .ps-kv td {
  padding: 4px 8px;
  border: 1px solid #e6e8ef;
  vertical-align: top;
  text-align: left;
  word-break: break-word;
}
.print-sheet .ps-kv th {
  width: 22%;
  font-weight: 600;
  color: #4a5061;
  background: #f7f8fb;
}

/* 数据表 */
.print-sheet .ps-tbl {
  width: 100%;
  border-collapse: collapse;
  font-size: 11.5px;
}
.print-sheet .ps-tbl th,
.print-sheet .ps-tbl td {
  padding: 4px 7px;
  border: 1px solid #e6e8ef;
  text-align: left;
  vertical-align: top;
  word-break: break-word;
}
.print-sheet .ps-tbl thead th { background: #f7f8fb; font-weight: 600; color: #4a5061; }
.print-sheet .ps-tbl tbody tr:nth-child(even) { background: #fcfcfe; }

/* 跟进记录 */
.print-sheet .ps-acts { margin: 0; padding-left: 18px; }
.print-sheet .ps-acts > li { margin-bottom: 5px; break-inside: avoid; }
.print-sheet .ps-act-when { color: #7b8296; font-size: 10.5px; margin-right: 6px; }
.print-sheet .ps-act-who { font-weight: 600; margin-right: 6px; }
.print-sheet .ps-empty { margin: 2px 0; color: #9aa1b2; font-size: 11px; }
.print-sheet .ps-note { margin: 4px 0 0; color: #9aa1b2; font-size: 10.5px; }

.print-sheet .ps-foot {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-top: 18px;
  padding-top: 8px;
  border-top: 1px solid #dfe2ea;
  font-size: 10px;
  color: #9aa1b2;
}

/* ---------- 打印时的版面切换 ---------- */
@media print {
  /* 纸张边距：@page 比 margin 可靠，浏览器打印对话框会尊重它 */
  @page { size: A4 portrait; margin: 14mm 12mm; }

  html, body { background: #fff !important; margin: 0 !important; padding: 0 !important; }

  /* 藏掉应用外壳：侧栏、顶栏、toast、弹窗、遮罩一律不进纸 */
  body.printing > *:not(.print-host) { display: none !important; }
  body.printing .print-host { display: block !important; }

  /* 打印件不需要阴影/圆角/动效 */
  .print-sheet, .print-sheet * {
    box-shadow: none !important;
    text-shadow: none !important;
    animation: none !important;
    transition: none !important;
  }

  /* 分区尽量不跨页断开标题 */
  .print-sheet .ps-sec-title { break-after: avoid; page-break-after: avoid; }
  .print-sheet .ps-head { break-after: avoid; page-break-after: avoid; }
  .print-sheet .ps-tbl tr, .print-sheet .ps-kv tr { break-inside: avoid; }
}

/* ============================================================
   打印预览弹窗（C7 补充）
   预览里显示的就是最终会打印的 .print-sheet 原样，只是缩小放在纸上，
   所以这里只负责「纸」的外观，纸质版本身的排版仍由上面那节决定。
   ============================================================ */
.print-preview {
  background: #eef0f5;
  padding: 14px;
  border-radius: 8px;
  max-height: 62vh;
  overflow: auto;
}
.print-preview-paper {
  width: 100%;
  max-width: 720px;
  margin: 0 auto;
  background: #fff;
  box-shadow: 0 2px 14px rgba(20, 26, 48, .12);
  border-radius: 3px;
  padding: 22px 24px;
}
/* 预览里的纸质版是给屏幕看的，字号按屏幕缩一点，避免 900px 弹窗里挤成一片 */
.print-preview-paper .print-sheet { font-size: 11px; }
.print-preview-paper .print-sheet .ps-head h1 { font-size: 17px; }
.print-preview-paper .print-sheet .ps-stats .v { font-size: 12.5px; }

html[data-theme="dark"] .print-preview { background: #0b0e18; }
html[data-theme="dark"] .print-preview-paper { box-shadow: 0 2px 16px rgba(0, 0, 0, .5); }

@media(max-width: 820px) {
  .print-preview { padding: 8px; max-height: 56vh; }
  .print-preview-paper { padding: 14px 12px; }
}

/* ============================================================
   智能洞察（D1）
   洞察卡放在客户详情右栏最上面，所以视觉要「先给结论」：
   一句 headline + 若干短句 + 下一步动作，全用列表而不是段落。
   ============================================================ */
.ins-wrap { display: flex; flex-direction: column; gap: 10px; }
.ins-loading { display: flex; align-items: center; gap: 7px; font-size: 12.5px; color: var(--text-3); }
.ins-headline { font-size: 13.5px; font-weight: 600; line-height: 1.6; color: var(--text); }
.ins-tone { font-size: 11.5px; font-weight: 600; margin-left: 6px; }
.ins-points { margin: 0; padding-left: 17px; display: flex; flex-direction: column; gap: 5px; }
.ins-points li { font-size: 12.5px; line-height: 1.62; color: var(--text-2); }
.ins-sec-label {
  font-size: 11.5px; font-weight: 600; color: var(--text-3);
  letter-spacing: .3px; margin-top: 2px;
}
.ins-acts { display: flex; flex-direction: column; gap: 8px; }
.ins-act {
  display: flex; align-items: flex-start; gap: 9px;
  padding: 9px 11px; border: 1px solid var(--border-soft);
  border-radius: 9px; background: var(--surface-2);
}
.ins-act-body { flex: 1; min-width: 0; }
.ins-act-title { font-size: 12.5px; font-weight: 600; line-height: 1.5; color: var(--text); }
.ins-act-reason { font-size: 11.5px; line-height: 1.55; color: var(--text-3); margin-top: 2px; }

/* 丢单风险：一行一个商机，分数放右边对齐，扫一眼就能挑出最该管的那个 */
.ins-risk { display: flex; flex-direction: column; gap: 2px; }
.ins-risk-row {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 8px; border-radius: 7px; min-width: 0;
}
.ins-risk-row:hover { background: var(--hover-soft); }
.ins-risk-dot { width: 7px; height: 7px; border-radius: 50%; flex: 0 0 7px; }
.ins-risk-dot.red { background: var(--danger); }
.ins-risk-dot.amber { background: var(--warning); }
.ins-risk-dot.green { background: var(--success); }
.ins-risk-name {
  font-size: 12.5px; color: var(--text); min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 0 1 auto;
}
.ins-risk-row .text-xs { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ins-risk-score { font-size: 12px; font-weight: 700; font-variant-numeric: tabular-nums; flex: 0 0 auto; }
.ins-risk-score.red { color: var(--danger); }
.ins-risk-score.amber { color: var(--warning); }
.ins-risk-score.green { color: var(--success); }
.ins-foot { font-size: 11px; color: var(--text-3); line-height: 1.55; }

@media(max-width: 820px) {
  .ins-risk-row .text-xs { display: none; }
  .ins-act { flex-wrap: wrap; }
}

/* ---------- 商机详情的丢单风险条（D1） ---------- */
.risk-card {
  border: 1px solid var(--border); border-radius: 11px;
  padding: 12px 14px; background: var(--surface);
}
.risk-head { display: flex; align-items: center; gap: 8px; }
.risk-title { font-size: 13px; font-weight: 600; color: var(--text); }
.risk-score {
  margin-left: auto; font-size: 17px; font-weight: 700;
  font-variant-numeric: tabular-nums; line-height: 1;
}
.risk-score i { font-size: 11px; font-style: normal; font-weight: 600; margin-left: 1px; }
.risk-low .risk-score { color: var(--success); }
.risk-medium .risk-score { color: var(--warning); }
.risk-high .risk-score { color: var(--danger); }
.risk-bar {
  height: 5px; border-radius: 3px; overflow: hidden;
  background: var(--fill-2); margin: 9px 0 10px;
}
.risk-bar > i { display: block; height: 100%; border-radius: 3px; transition: width .3s ease; }
.risk-low .risk-bar > i { background: var(--success); }
.risk-medium .risk-bar > i { background: var(--warning); }
.risk-high .risk-bar > i { background: var(--danger); }
.risk-factors { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.risk-factors li { display: flex; align-items: baseline; gap: 7px; font-size: 12px; line-height: 1.55; }
.risk-delta {
  flex: 0 0 auto; font-size: 10.5px; font-weight: 700;
  color: var(--danger); background: var(--danger-50, #fef2f2);
  border-radius: 4px; padding: 1px 5px; font-variant-numeric: tabular-nums;
}
.risk-flabel { flex: 0 0 auto; font-weight: 600; color: var(--text); }
.risk-fwhy { flex: 1 1 auto; min-width: 0; color: var(--text-3); }

html[data-theme="dark"] .risk-delta { background: rgba(248, 113, 113, .16); }

@media(max-width: 820px) {
  .risk-factors li { flex-wrap: wrap; gap: 4px 6px; }
  .risk-fwhy { flex-basis: 100%; }
}

/* ==========================================================================
   PWA / 扫码 / 语音（D5）
   ========================================================================== */

/* ---------- 离线提示条 ---------- */
/* 固定底部居中，压在内容之上；有操作按钮的页面底部留白已由 .toast-wrap 处理，
   这条只在断网时出现，所以不额外占版面。 */
.offline-bar {
  position: fixed; left: 50%; bottom: 16px; transform: translateX(-50%);
  z-index: 60; display: flex; align-items: center; gap: 8px;
  max-width: min(560px, calc(100vw - 32px));
  padding: 9px 14px; border-radius: 10px;
  background: #3b3f52; color: #fff;
  font-size: 12.5px; line-height: 1.5;
  box-shadow: 0 6px 20px rgba(16, 24, 40, .22);
}
.offline-bar[hidden] { display: none; }
.offline-bar svg { flex: 0 0 auto; opacity: .85; }
.offline-bar span { flex: 1 1 auto; min-width: 0; }
/* 断网时把「在线人数」这类实时标识压暗，避免误导 */
body.is-offline .online-chip { opacity: .45; }

html[data-theme="dark"] .offline-bar { background: #2a3145; box-shadow: 0 6px 22px rgba(0, 0, 0, .55); }

@media(max-width: 820px) {
  .offline-bar { left: 12px; right: 12px; transform: none; max-width: none; bottom: 12px; }
}

/* ---------- 扫码建档 ---------- */
.scan-wrap { display: flex; flex-direction: column; gap: 14px; }
.scan-stage {
  position: relative; border-radius: 10px; overflow: hidden;
  background: #10131f; min-height: 132px;
  display: flex; align-items: center; justify-content: center;
}
.scan-video { display: block; width: 100%; max-height: 280px; object-fit: cover; }
.scan-video[hidden] { display: none; }
.scan-hint {
  padding: 24px 18px; text-align: center; color: #b9c0d4;
  font-size: 12.5px; line-height: 1.65;
}
.scan-manual { display: flex; flex-direction: column; gap: 6px; }
.scan-text { width: 100%; resize: vertical; font-size: 12.5px; line-height: 1.6; font-family: inherit; }
.scan-result:empty { display: none; }
.scan-parsed {
  border: 1px solid var(--border); border-radius: 10px;
  background: var(--surface-2); padding: 12px 14px;
}
.scan-parsed-head {
  display: flex; align-items: center; gap: 8px;
  font-size: 12.5px; font-weight: 600; color: var(--text);
  margin-bottom: 9px;
}
.scan-kv {
  display: grid; grid-template-columns: 76px 1fr;
  gap: 6px 12px; margin: 0; font-size: 12.5px; line-height: 1.55;
}
.scan-kv dt { color: var(--text-3); }
.scan-kv dd { margin: 0; color: var(--text); word-break: break-all; }
.scan-tip { margin: 0; font-size: 11.5px; color: var(--text-3); line-height: 1.6; }

html[data-theme="dark"] .scan-parsed { background: var(--surface-2); }
@media(max-width: 820px) {
  .scan-kv { grid-template-columns: 64px 1fr; }
  .scan-video { max-height: 220px; }
}

/* ---------- 语音记跟进 ---------- */
.voice-wrap { display: flex; flex-direction: column; gap: 12px; }
.voice-lead { margin: 0; font-size: 12.5px; color: var(--text-2); line-height: 1.65; }
.voice-note { margin: 0; font-size: 11.5px; color: var(--text-3); line-height: 1.6; }
/* 麦克风按钮由 attachVoiceInput 插在 textarea 前面（同一个父节点内），
   这里只做外观；位置靠 margin 而不是 absolute，避免盖住输入框。 */
.voice-btn {
  display: inline-flex; align-items: center; gap: 6px;
  align-self: flex-start; margin-bottom: 6px;
  height: 30px; padding: 0 11px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--surface);
  color: var(--text-2); font-size: 12.5px; font-family: inherit;
  cursor: pointer; transition: background .12s, color .12s, border-color .12s;
}
.voice-btn:hover { background: var(--brand-50); border-color: var(--brand-100); color: var(--brand); }
.voice-btn.is-listening {
  background: var(--danger-50); border-color: #fecaca; color: var(--danger);
  animation: voicePulse 1.4s ease-in-out infinite;
}
@keyframes voicePulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, .32); }
  50% { box-shadow: 0 0 0 5px rgba(239, 68, 68, 0); }
}
html[data-theme="dark"] .voice-btn { background: var(--surface-2); }
html[data-theme="dark"] .voice-btn.is-listening { background: rgba(239, 68, 68, .16); border-color: rgba(239, 68, 68, .4); }
