:root {
  --bg: #f4f6f8;
  --card: #ffffff;
  --ink: #16191d;
  --ink-2: #4a5361;
  --ink-3: #7b8794;
  --line: #e3e8ef;
  --line-2: #eef2f6;
  --brand: #1f4e79;
  --brand-soft: #e8f0f7;
  --red: #c8443c;
  --red-soft: #fdecea;
  --amber: #b26a00;
  --amber-soft: #fdf3e2;
  --teal: #1c7c66;
  --teal-soft: #e6f4f0;
  --violet: #6b4fa8;
  --violet-soft: #f0ecf9;
  --slate: #5b6673;
  --slate-soft: #eef1f4;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 4px 12px rgba(16, 24, 40, .05);
  --mono: "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 14px/1.55 -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB",
        "Microsoft YaHei", "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--brand); text-decoration: none; }

.num { font-variant-numeric: tabular-nums; font-feature-settings: "tnum"; }
.mono { font-family: var(--mono); font-size: .92em; }

/* ---------------- 顶栏 ---------------- */
.topbar {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; gap: 16px;
  height: 56px; padding: 0 20px;
  background: var(--card);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: baseline; gap: 8px; font-weight: 700; letter-spacing: .2px; }
.brand small { font-weight: 400; color: var(--ink-3); font-size: 12px; }
.topbar .spacer { flex: 1; }
.who { display: flex; align-items: center; gap: 10px; color: var(--ink-2); font-size: 13px; }
.avatar {
  width: 30px; height: 30px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--brand-soft); color: var(--brand);
  font-weight: 700; font-size: 12px;
}
.role-tag {
  padding: 1px 7px; border-radius: 99px; font-size: 11px;
  background: var(--brand-soft); color: var(--brand);
}
.btn-ghost {
  border: 1px solid var(--line); background: #fff; color: var(--ink-2);
  padding: 5px 12px; border-radius: 7px;
}
.btn-ghost:hover { border-color: var(--ink-3); color: var(--ink); }
.btn-sm { padding: 3px 10px; font-size: 12px; font-weight: 500; border-radius: 6px; }
.section-title .hint b { color: var(--brand); font-weight: 600; }
.btn-primary {
  border: 1px solid var(--brand); background: var(--brand); color: #fff;
  padding: 7px 16px; border-radius: 7px; font-weight: 600;
}
.btn-primary:hover { filter: brightness(1.08); }
.btn-primary:disabled { opacity: .55; cursor: not-allowed; }

/* ---------------- 容器 ---------------- */
.wrap { max-width: 1360px; margin: 0 auto; padding: 20px; }
.section-title {
  display: flex; align-items: center; gap: 10px;
  margin: 22px 0 12px; font-size: 14px; font-weight: 700; color: var(--ink);
}
.section-title .hint { font-weight: 400; font-size: 12px; color: var(--ink-3); }
.section-title .line { flex: 1; height: 1px; background: var(--line); }

/* ---------------- KPI ---------------- */
.kpis { display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; }
@media (max-width: 1100px) { .kpis { grid-template-columns: repeat(2, 1fr); } }
.kpi {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 16px; box-shadow: var(--shadow); position: relative; overflow: hidden;
}
.kpi .k { font-size: 12px; color: var(--ink-3); display: flex; align-items: center; gap: 6px; }
.kpi .v { font-size: 24px; font-weight: 700; margin-top: 6px; letter-spacing: -.4px; }
.kpi .s { font-size: 12px; color: var(--ink-3); margin-top: 4px; }
.kpi.red .v { color: var(--red); }
.kpi.teal .v { color: var(--teal); }
.kpi.amber .v { color: var(--amber); }
.kpi::after {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px;
  background: var(--line);
}
.kpi.red::after { background: var(--red); }
.kpi.teal::after { background: var(--teal); }
.kpi.amber::after { background: var(--amber); }
.kpi.brand::after { background: var(--brand); }

/* ---------------- 状态筛选 ---------------- */
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 14px 0 4px; }
.chip {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 6px 12px; border-radius: 99px;
  border: 1px solid var(--line); background: #fff; color: var(--ink-2);
  font-size: 13px; transition: .12s;
}
.chip:hover { border-color: var(--ink-3); }
.chip.on { background: var(--brand); border-color: var(--brand); color: #fff; }
.chip .n { font-size: 12px; opacity: .75; }
.chip .dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.chip.on .dot { background: #fff; }

/* ---------------- 账龄条 ---------------- */
.aging-bar { display: flex; gap: 2px; height: 34px; margin-top: 8px; }
.aging-seg {
  position: relative; border-radius: 4px; min-width: 2px;
  background: var(--brand-soft); transition: .15s;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; color: var(--brand); overflow: hidden; white-space: nowrap;
}
.aging-seg:hover { filter: brightness(.94); }
.aging-seg.hot { background: var(--red-soft); color: var(--red); }
.aging-legend { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 8px; font-size: 12px; color: var(--ink-3); }

/* ---------------- 卡片 / 表格 ---------------- */
.panel {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); overflow: hidden;
}
.toolbar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 12px 14px; border-bottom: 1px solid var(--line-2);
}
.tabs { display: flex; gap: 4px; background: var(--bg); padding: 3px; border-radius: 8px; }
.tabs button {
  border: 0; background: transparent; padding: 6px 14px; border-radius: 6px;
  font-size: 13px; color: var(--ink-2);
}
.tabs button.on { background: #fff; color: var(--ink); font-weight: 600; box-shadow: 0 1px 2px rgba(0,0,0,.06); }
.search {
  flex: 1; min-width: 180px; max-width: 320px;
  display: flex; align-items: center; gap: 6px;
  border: 1px solid var(--line); border-radius: 8px; padding: 5px 10px; background: #fff;
}
.search input { border: 0; outline: 0; flex: 1; background: transparent; }
select.sel {
  border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; background: #fff;
}

/* 业务员欠款总览：占比条 + 部门分组行 */
.owe-bar { height: 4px; border-radius: 2px; background: var(--line-2); margin-top: 4px; overflow: hidden; }
.owe-bar i { display: block; height: 100%; border-radius: 2px; background: linear-gradient(90deg, var(--red), #ff8a5c); }
tr.dept-row td { background: var(--brand-soft); font-weight: 700; font-size: 12.5px; color: var(--ink-2); letter-spacing: .3px; }
tr.total-row td { background: #fdf0e6; font-weight: 800; border-top: 2px solid var(--ink); }
tr.dept-row, tr.total-row { cursor: default; }

/* 业务员卡片视图 */
.team-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(235px, 1fr)); gap: 12px; }
.p-card { border: 1px solid var(--line-2); border-radius: 12px; padding: 14px 14px 12px; background: #fff;
  cursor: pointer; transition: box-shadow .15s, transform .15s, border-color .15s; }
.p-card:hover { box-shadow: 0 6px 18px rgba(31,59,91,.12); transform: translateY(-2px); border-color: var(--brand); }
.p-card-zero { opacity: .62; }
.pc-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.pc-name { font-weight: 800; font-size: 15px; }
.pc-dept { font-size: 11px; color: var(--ink-3); background: var(--brand-soft); border-radius: 999px; padding: 2px 8px; }
.pc-owe .num { font-size: 21px; font-weight: 800; letter-spacing: -.3px; color: var(--ink); }
.pc-owe .num.hot { color: var(--red); }
.p-card-zero .pc-owe .num { font-size: 15px; color: var(--ink-3); font-weight: 600; }
.pc-meta { display: flex; justify-content: space-between; font-size: 11.5px; color: var(--ink-3); margin-top: 6px; }
.aging-stack { display: flex; height: 8px; border-radius: 4px; overflow: hidden; background: var(--line-2); margin-top: 9px; }
.aging-stack i { display: block; height: 100%; }
.pc-foot { display: flex; justify-content: space-between; font-size: 11.5px; color: var(--ink-2); margin-top: 7px; gap: 8px; }
.pc-foot span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* 下钻返回条：从总览点进某业务员/账龄时顶部显示 */
.back-bar { display: flex; align-items: center; gap: 12px; margin: 0 0 12px; }
.btn-back {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px; border-radius: 8px;
  background: var(--brand); color: #fff; font-size: 13.5px; font-weight: 600;
  text-decoration: none; box-shadow: 0 1px 4px rgba(0,0,0,.12);
  transition: filter .15s;
}
.btn-back:hover { filter: brightness(1.1); }
.back-hint { font-size: 12.5px; color: var(--ink-3); }

table { width: 100%; border-collapse: separate; border-spacing: 0; }
/* 明细区：表头直接钉在窗口顶部（顶栏 56px 之下），页面怎么拉都看得见列名。
   关键：这里不能有任何「可纵向滚动」的祖先容器，否则 sticky 只认那个容器、页面滚动时失效。
   用 overflow-x:clip 只裁横向溢出，不会生成滚动容器。 */
/* 客户明细：标题行 → 工具栏 → 表头 三层依次吸顶，滚动时始终知道"在看什么、怎么筛、哪一列" */
#listTitleBar {
  position: sticky; top: var(--top0, 56px); z-index: 9;
  margin: 0; padding: 14px 0 10px; background: var(--bg);
}
.list-panel .toolbar {
  position: sticky; top: var(--top1, 78px); z-index: 8;
  background: var(--card);
  border-radius: 12px 12px 0 0;
}
.panel.list-panel { overflow: visible; }
#tableWrap {
  overflow-x: clip;
  overflow-y: visible;
}
/* 单据明细表：固定布局，列宽由 colgroup 按数据宽度分配，不随浏览器猜 */
.doc-table { table-layout: fixed; }
.doc-table td .tag { white-space: normal; display: inline-block; line-height: 1.5; }
thead th {
  text-align: left; font-weight: 700; font-size: 12px; color: var(--ink-2);
  padding: 10px 12px; background: #f2f5f9;
  border-bottom: 2px solid #ccd6e2; border-left: 1px solid var(--line-2);
  white-space: nowrap;
  position: sticky; top: 56px; z-index: 7;
  box-shadow: 0 2px 0 rgba(31,59,91,.06);
}
/* 明细区表头要退到「标题行 + 工具栏」下面（偏移量由 app.js 实测写入） */
.list-panel thead th { top: var(--top2, 130px); }
thead th:first-child { border-left: none; }
thead th.r, td.r { text-align: right; }

/* 表头第二行：列筛选（日期区间 / 单据类型 / 账龄） */
thead tr.filter-row th {
  background: #f8fafc; border-bottom: 1px solid var(--line);
  padding: 5px 6px; font-weight: 400; position: static; top: auto;
}
thead tr.filter-row th.fw { min-width: 128px; }
.fh { font-size: 11px; color: var(--ink-3); font-weight: 400; }
.f-in, .f-sel {
  width: 100%; font-size: 11.5px; padding: 3px 5px; border-radius: 5px;
  border: 1px solid var(--line); background: #fff; color: var(--ink-2);
}
.f-in { margin-bottom: 3px; }
.f-in:last-child { margin-bottom: 0; }
.f-in:focus, .f-sel:focus { outline: none; border-color: var(--brand); color: var(--ink); }
.btn-mini {
  border: 1px solid var(--line); background: #fff; color: var(--brand);
  font-size: 11.5px; padding: 3px 9px; border-radius: 5px;
}
.btn-mini:hover { border-color: var(--brand); }
tbody td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  border-left: 1px solid var(--line-2);
  vertical-align: middle;
}
tbody td:first-child { border-left: none; }
tbody tr:nth-child(even) td { background: #fafbfd; }
tbody tr:hover td { background: #edf4fb; }
tbody tr.clickable { cursor: pointer; }
tbody tr.done td:first-child { box-shadow: inset 3px 0 0 var(--teal); }
/* 账龄矩阵列块：整块用深一档的竖线，和普通列区分开 */
th.blk, td.blk { border-left: 1px solid #d3dce7; }
th.blk { background: #eef2f8; }
th.blk:first-child, td.blk:first-child { border-left: 1px solid #d3dce7; }
.cell-main { font-weight: 600; }
.cell-sub { font-size: 12px; color: var(--ink-3); margin-top: 2px; }

.tag {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 8px; border-radius: 99px; font-size: 12px; white-space: nowrap;
}
.tag.red { background: var(--red-soft); color: var(--red); }
.tag.amber { background: var(--amber-soft); color: var(--amber); }
.tag.teal { background: var(--teal-soft); color: var(--teal); }
.tag.violet { background: var(--violet-soft); color: var(--violet); }
.tag.slate { background: var(--slate-soft); color: var(--slate); }
.tag.outline { background: #fff; color: var(--ink-3); border: 1px solid var(--line); }

.pager { display: flex; align-items: center; gap: 10px; padding: 12px 14px; color: var(--ink-3); font-size: 13px; }
.pager .spacer { flex: 1; }
.pager button { border: 1px solid var(--line); background: #fff; border-radius: 7px; padding: 4px 12px; }
.pager button:disabled { opacity: .45; cursor: not-allowed; }

.empty { padding: 48px 20px; text-align: center; color: var(--ink-3); }
.empty .big { font-size: 28px; margin-bottom: 8px; opacity: .5; }

/* ---------------- 抽屉 ---------------- */
.mask {
  position: fixed; inset: 0; background: rgba(16, 24, 40, .28);
  opacity: 0; pointer-events: none; transition: .18s; z-index: 50;
}
.mask.on { opacity: 1; pointer-events: auto; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(620px, 94vw);
  background: var(--card); border-left: 1px solid var(--line);
  transform: translateX(100%); transition: transform .22s cubic-bezier(.2,.8,.2,1);
  z-index: 60; display: flex; flex-direction: column;
}
.drawer.on { transform: none; }
.drawer-head {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 16px 18px; border-bottom: 1px solid var(--line);
}
.drawer-head h3 { margin: 0; font-size: 16px; }
.drawer-head .sub { font-size: 12px; color: var(--ink-3); margin-top: 3px; }
.drawer-body { flex: 1; overflow-y: auto; padding: 16px 18px 28px; }
.drawer-foot {
  padding: 12px 18px; border-top: 1px solid var(--line); background: #fbfcfd;
  display: flex; align-items: center; gap: 10px;
}
.x-btn { border: 0; background: transparent; font-size: 20px; line-height: 1; color: var(--ink-3); padding: 2px 6px; }
.x-btn:hover { color: var(--ink); }

.facts { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1px; background: var(--line-2); border: 1px solid var(--line-2); border-radius: 8px; overflow: hidden; }
.fact { background: #fff; padding: 10px 12px; }
.fact .k { font-size: 11px; color: var(--ink-3); }
.fact .v { font-size: 14px; font-weight: 600; margin-top: 2px; word-break: break-all; }
.fact.wide { grid-column: span 2; }

.amount-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1px; background: var(--line-2); border: 1px solid var(--line-2); border-radius: 8px; overflow: hidden; margin-top: 10px; }
.amount-row .fact .v { font-size: 16px; }
.amount-row .fact.hi .v { color: var(--red); }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-grid .full { grid-column: span 2; }
label.f { display: block; }
label.f > span { display: block; font-size: 12px; color: var(--ink-2); margin-bottom: 4px; font-weight: 600; }
label.f > span em { color: var(--red); font-style: normal; margin-left: 2px; }
label.f input, label.f select, label.f textarea {
  width: 100%; border: 1px solid var(--line); border-radius: 8px;
  padding: 8px 10px; background: #fff; outline: 0;
}
label.f input:focus, label.f select:focus, label.f textarea:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
label.f textarea { min-height: 76px; resize: vertical; }
.hintline { font-size: 12px; color: var(--ink-3); margin-top: 6px; }
.hintline.warn { color: var(--amber); }

.siblings { margin-top: 6px; border: 1px solid var(--line-2); border-radius: 8px; overflow: hidden; }
.siblings .row { display: flex; gap: 10px; padding: 8px 12px; border-bottom: 1px solid var(--line-2); font-size: 13px; align-items: center; }
.siblings .row:last-child { border-bottom: 0; }
.siblings .row:hover { background: #fafcfe; cursor: pointer; }

.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translate(-50%, 20px);
  background: #16191d; color: #fff; padding: 10px 18px; border-radius: 9px;
  font-size: 13px; opacity: 0; pointer-events: none; transition: .2s; z-index: 90;
  max-width: 80vw;
}
.toast.on { opacity: 1; transform: translate(-50%, 0); }
.toast.err { background: var(--red); }

/* ---------------- 登录 ---------------- */
.login-wrap {
  min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: radial-gradient(1100px 560px at 50% -10%, #e6eef7 0%, var(--bg) 62%);
  padding: 28px 20px;
}
.login-card {
  width: min(392px, 100%); background: var(--card); border: 1px solid var(--line);
  border-radius: 16px; box-shadow: 0 18px 48px rgba(16,24,40,.10), 0 2px 4px rgba(16,24,40,.04);
  padding: 28px 26px 20px;
}
.lg-head { display: flex; align-items: center; gap: 12px; margin-bottom: 22px; }
.lg-logo {
  width: 42px; height: 42px; flex: 0 0 42px; border-radius: 11px;
  background: linear-gradient(140deg, #2a5f92, #1a3f61); color: #fff;
  display: grid; place-items: center; font-size: 13px; font-weight: 800; letter-spacing: .5px;
}
.login-card h1 { margin: 0; font-size: 18px; letter-spacing: -.2px; }
.login-card p.sub { margin: 3px 0 0; color: var(--ink-3); font-size: 12.5px; line-height: 1.45; }

.lg-field { display: block; margin-bottom: 14px; }
.lg-field > span:first-child {
  display: block; font-size: 12px; color: var(--ink-2); margin-bottom: 6px; font-weight: 600;
}
.lg-field input {
  width: 100%; border: 1px solid var(--line); border-radius: 9px;
  padding: 11px 12px; font-size: 14.5px; outline: 0; background: #fff;
  transition: border-color .12s, box-shadow .12s;
}
.lg-field input::placeholder { color: #a9b3bf; font-size: 13.5px; }
.lg-field input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }

.lg-pwd { position: relative; display: block; }
.lg-pwd input { padding-right: 52px; }
.lg-eye {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  border: 0; background: transparent; color: var(--ink-3); font-size: 12px;
  padding: 5px 8px; border-radius: 6px;
}
.lg-eye:hover { color: var(--brand); background: var(--brand-soft); }

.lg-chpwd {
  border: 1px solid var(--line-2); background: #fafcfe; border-radius: 10px;
  padding: 12px 12px 2px; margin-bottom: 14px;
}
.lg-chpwd[hidden] { display: none; }
.lg-tip { font-size: 11.5px; color: var(--ink-3); line-height: 1.55; margin-bottom: 10px; }
.lg-chpwd .lg-field { margin-bottom: 10px; }
.lg-chpwd .lg-field input { padding: 9px 11px; font-size: 14px; }

.btn-primary.lg-btn { width: 100%; padding: 11px; margin-top: 4px; font-size: 14.5px; letter-spacing: 1px; }
.login-err { color: var(--red); font-size: 12.5px; min-height: 18px; margin-top: 7px; }

.lg-links {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  margin-top: 6px; font-size: 12.5px;
}
.lg-links i { color: var(--line); font-style: normal; }
.lg-links a { color: var(--ink-3); }
.lg-links a:hover { color: var(--brand); text-decoration: underline; }

.lg-foot {
  margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--line-2);
  font-size: 11.5px; color: var(--ink-3); text-align: center; line-height: 1.75;
}
.lg-foot b { color: var(--ink-2); font-weight: 700; letter-spacing: .5px; }
.lg-copy { margin-top: 16px; font-size: 11px; color: #9aa5b2; letter-spacing: .3px; }
.login-card form[hidden] { display: none; }

/* ---------------- 财务页 ---------------- */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 1000px) { .grid-2 { grid-template-columns: 1fr; } }
.mini-bar { height: 6px; border-radius: 99px; background: var(--line-2); overflow: hidden; }
.mini-bar > i { display: block; height: 100%; background: var(--teal); border-radius: 99px; }
.loading { padding: 40px; text-align: center; color: var(--ink-3); }

/* ---------------- 账龄分布卡片 ---------------- */
.aging-cards {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 8px;
  margin-top: 12px;
}
@media (max-width: 1100px) { .aging-cards { grid-template-columns: repeat(4, 1fr); } }
@media (max-width: 700px)  { .aging-cards { grid-template-columns: repeat(2, 1fr); } }
.aging-card {
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #fff;
  padding: 9px 10px;
  text-align: left;
  transition: box-shadow .12s, border-color .12s;
}
.aging-card:hover { border-color: var(--ink-3); box-shadow: var(--shadow); }
.aging-card.on { border-color: var(--brand); box-shadow: 0 0 0 2px var(--brand-soft); }
.aging-card .k { font-size: 12px; color: var(--ink-3); }
.aging-card .v { font-size: 17px; font-weight: 700; margin: 2px 0; }
.aging-card .s { font-size: 11px; color: var(--ink-3); }
.aging-card.ok   { border-top: 3px solid var(--teal); }
.aging-card.ok   .v { color: var(--ink); }
.aging-card.warn { border-top: 3px solid var(--amber); }
.aging-card.warn .v { color: var(--amber); }
.aging-card.bad  { border-top: 3px solid var(--red); }
.aging-card.bad  .v { color: var(--red); }
.aging-card.worst { border-top: 3px solid #8f1d16; background: var(--red-soft); }
.aging-card.worst .v { color: #8f1d16; }
.aging-card.zero { opacity: .45; }

/* ---------------- 客户横幅（点开客户后） ---------------- */
.cust-banner {
  background: var(--card);
  border: 1px solid var(--line);
  border-left: 4px solid var(--brand);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px 16px;
  margin-bottom: 14px;
}
.cust-banner .cb-head { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.cust-banner .cb-name { font-size: 17px; font-weight: 700; }
.cust-banner .cb-sub { font-size: 12px; color: var(--ink-3); margin-top: 2px; }
.cust-banner .cb-owes { margin-left: auto; text-align: right; }
.cust-banner .cb-owes .k { font-size: 12px; color: var(--ink-3); }
.cust-banner .cb-owes .v { font-size: 22px; font-weight: 800; }
.cust-banner .cb-owes.bad .v { color: var(--red); }
.cust-banner .cb-owes.ok .v { color: var(--teal); font-size: 18px; }
.cust-banner .cb-aging {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  margin-top: 12px; padding-top: 12px; border-top: 1px dashed var(--line);
}
.cust-banner .cb-aging-t { font-size: 12px; color: var(--ink-3); }
.cb-bucket {
  border: 1px solid var(--line); border-radius: 99px;
  background: #fff; padding: 4px 12px; font-size: 13px;
}
.cb-bucket:hover { border-color: var(--ink-3); }
.cb-bucket b { font-weight: 700; }
.cb-bucket.ok   b { color: var(--ink); }
.cb-bucket.warn b { color: var(--amber); }
.cb-bucket.bad,
.cb-bucket.worst b { color: var(--red); }
.cb-bucket.worst { background: var(--red-soft); border-color: #f0c4c0; }
.cb-bucket.zero { opacity: .4; }

/* ---------------- 总表账龄矩阵 ---------------- */
.matrix-scroll { overflow-x: auto; }
.matrix-scroll table { min-width: 100%; }
.matrix-th {
  font-size: 11px !important; padding: 6px 6px !important; white-space: nowrap;
  color: var(--ink-2); border-left: 1px solid #d3dce7; background: #eef2f8 !important;
}
.matrix-bad  { color: var(--red); font-weight: 600; }
.matrix-warn { color: var(--amber); }
.matrix-zero { color: var(--line); }

/* ---------------- 金蝶核销专区 ---------------- */
.wo-toolbar {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line-2);
  display: flex; gap: 12px; flex-wrap: wrap; align-items: center;
}
.btn-primary {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--brand); color: #fff; text-decoration: none;
  border-radius: 8px; padding: 8px 16px; font-size: 13px; font-weight: 600;
  box-shadow: var(--shadow); transition: filter .12s;
}
.btn-primary:hover { filter: brightness(1.08); }
.wo-agg { margin-left: auto; font-size: 12px; color: var(--ink-3); text-align: right; }
.wo-agg b { color: var(--ink); }
.wo-fin-sel {
  border: 1px solid var(--line); border-radius: 6px; padding: 3px 6px;
  font-size: 12px; background: #fff; color: var(--ink);
}
.wo-fin-sel.v-done { color: var(--teal); font-weight: 600; border-color: var(--teal); }
.wo-fin-sel.v-wait { color: var(--amber); font-weight: 600; }

/* ---------------- 截图附件 ---------------- */
.att-zone {
  display: flex; flex-wrap: wrap; gap: 10px;
}
.att-thumb {
  position: relative; width: 86px; height: 86px;
  border: 1px solid var(--line); border-radius: 8px; overflow: hidden;
  background: var(--line-2); cursor: zoom-in;
}
.att-thumb img {
  width: 100%; height: 100%; object-fit: cover; display: block;
}
.att-thumb:hover { border-color: var(--brand); }
.att-del {
  position: absolute; top: 2px; right: 2px;
  width: 18px; height: 18px; line-height: 16px; padding: 0;
  border: none; border-radius: 50%;
  background: rgba(15, 18, 25, .62); color: #fff;
  font-size: 13px; cursor: pointer; display: none;
}
.att-thumb:hover .att-del { display: block; }
.att-del:hover { background: var(--red); }
.att-add {
  width: 86px; height: 86px;
  border: 1.5px dashed var(--line); border-radius: 8px;
  background: transparent; color: var(--ink-3);
  font-size: 22px; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  transition: border-color .12s, color .12s;
}
.att-add small { font-size: 11px; font-weight: 400; }
.att-add:hover, .att-add:disabled { border-color: var(--brand); color: var(--brand); }
.att-add:disabled { opacity: .5; cursor: wait; }
.att-badge {
  border: 1px solid var(--line); border-radius: 6px;
  background: var(--brand-soft, #eef4fa); color: var(--brand);
  font-size: 12px; padding: 3px 8px; cursor: pointer; white-space: nowrap;
}
.att-badge:hover { border-color: var(--brand); }

/* 灯箱：看凭证大图 */
.lightbox {
  position: fixed; inset: 0; z-index: 300;
  background: rgba(15, 18, 25, .86);
  display: none; flex-direction: column; align-items: center;
  padding: 46px 24px 18px; gap: 10px;
}
.lightbox.on { display: flex; }
.lightbox .lb-x {
  position: absolute; top: 14px; right: 18px;
  width: 34px; height: 34px; border: none; border-radius: 50%;
  background: rgba(255, 255, 255, .14); color: #fff;
  font-size: 22px; line-height: 1; cursor: pointer;
}
.lightbox .lb-x:hover { background: rgba(255, 255, 255, .28); }
.lightbox .lb-body {
  flex: 1; min-height: 0; width: 100%;
  display: flex; flex-direction: column; align-items: center;
  gap: 14px; overflow-y: auto; padding: 4px;
}
.lightbox .lb-body img {
  max-width: min(92vw, 1100px); max-height: 74vh;
  border-radius: 6px; background: #fff;
  box-shadow: 0 24px 60px rgba(0, 0, 0, .45);
}
.lightbox .lb-cap { color: rgba(255, 255, 255, .85); font-size: 13px; }


/* ---------------- 催款跟进 · 风险预警 ---------------- */
tr.risk-row td { background: #fdf1ef; }
tr.risk-row:hover td { background: #fbe7e4; }
.risk-sel {
  width: 100%; max-width: 130px; font-size: 12px; padding: 4px 6px;
  border: 1px solid var(--line); border-radius: 6px; background: #fff;
}
.risk-sel.v-done { color: var(--teal); font-weight: 600; border-color: var(--teal); }
.risk-sel.v-wait { color: var(--amber); font-weight: 600; }
.risk-note {
  width: 100%; max-width: 200px; font-size: 12px; padding: 4px 6px;
  border: 1px dashed var(--line); border-radius: 6px; display: block;
}
.risk-note:focus { outline: none; border-color: var(--brand); border-style: solid; }

/* ---------------- 导入回填 · 结果弹层 ---------------- */
.imp-mask {
  position: fixed; inset: 0; background: rgba(16, 24, 40, .35);
  display: flex; align-items: center; justify-content: center; z-index: 80;
}
.imp-card {
  width: min(560px, 92vw); max-height: 78vh; overflow: auto;
  background: #fff; border-radius: 12px; padding: 20px 22px;
  box-shadow: 0 12px 40px rgba(16, 24, 40, .22);
}
.imp-title { font-size: 15px; font-weight: 700; margin-bottom: 10px; }
.imp-body table { font-size: 12.5px; }
.imp-body th { color: var(--ink-3); font-weight: 600; padding: 6px 8px; border-bottom: 1px solid var(--line); text-align: left; }
.imp-body td { padding: 6px 8px; border-bottom: 1px solid var(--line-2); vertical-align: top; }

/* ---------------- 业务员联想选择（按部门分组） ---------------- */
.owner-pick { position: relative; }
.owner-pick .sel { min-width: 170px; }
.owner-list {
  position: absolute; top: calc(100% + 4px); left: 0; z-index: 60;
  width: 260px; max-height: 340px; overflow: auto;
  background: #fff; border: 1px solid var(--line); border-radius: 8px;
  box-shadow: 0 8px 28px rgba(16, 24, 40, .16);
}
.owner-dept {
  padding: 6px 12px 4px; font-size: 11.5px; font-weight: 700; color: var(--ink-3);
  background: #f6f8fb; border-bottom: 1px solid var(--line-2);
  display: flex; justify-content: space-between; position: sticky; top: 0;
}
.owner-dept span { font-weight: 400; }
.owner-item { padding: 7px 14px; font-size: 13px; cursor: pointer; }
.owner-item:hover { background: #eef4ff; }
.owner-item.on { color: var(--brand); font-weight: 600; }
.owner-none { padding: 12px; color: var(--ink-3); font-size: 12.5px; text-align: center; }

/* ---------------- 修改密码弹层 ---------------- */
.pwd-form label { display: block; font-size: 12.5px; color: var(--ink-2); margin-bottom: 10px; }
.pwd-form input {
  display: block; width: 100%; margin-top: 4px; padding: 8px 10px;
  border: 1px solid var(--line); border-radius: 7px; font-size: 13.5px;
}
.pwd-form input:focus { outline: none; border-color: var(--brand); }

/* ---------------- 登录页 · 旧折叠区（已由 .lg-* 取代，保留兜底） ---------------- */

/* ================================================================
   老板界面 · 部门两级 / 图表 / 分析 / 客户信用
   ================================================================ */

/* --- 部门（一级）→ 人员（二级）布局 --- */
.dept-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr);
  gap: 12px; align-items: start;
}
@media (max-width: 1080px) { .dept-layout { grid-template-columns: 1fr; } }

.dept-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(196px, 1fr));
  gap: 10px; padding: 12px;
}
.dept-card {
  position: relative; overflow: hidden; cursor: pointer;
  border: 1px solid var(--line-2); border-radius: 10px; background: #fff;
  padding: 11px 12px 10px; transition: border-color .14s, box-shadow .14s, transform .14s;
}
.dept-card::before {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--brand);
}
.dept-card:hover { border-color: var(--brand); box-shadow: 0 6px 16px rgba(31,59,91,.1); transform: translateY(-1px); }
.dept-card.on { border-color: var(--brand); background: #f7fafd; }
.dc-top { display: flex; align-items: baseline; gap: 8px; }
.dc-name { font-size: 14px; font-weight: 800; color: var(--ink); }
.dc-ppl { font-size: 11.5px; color: var(--ink-3); margin-left: auto; }
.dc-owe { font-size: 20px; font-weight: 800; letter-spacing: -.4px; margin-top: 5px; color: var(--red); }
.dc-owe.zero { color: var(--ink-3); font-size: 14px; }
.dc-owe small { font-size: 12px; font-weight: 600; color: var(--ink-3); margin-left: 4px; }
.dc-bar { height: 5px; border-radius: 3px; background: var(--line-2); margin-top: 7px; overflow: hidden; }
.dc-bar i { display: block; height: 100%; border-radius: 3px; background: linear-gradient(90deg, #c8443c, #e88b5c); }
.dc-foot { display: flex; justify-content: space-between; font-size: 11px; color: var(--ink-3); margin-top: 6px; gap: 6px; }
.dc-foot b { color: var(--ink-2); font-weight: 600; }
.dc-go { position: absolute; right: 10px; top: 10px; color: var(--line); font-size: 12px; }
.dept-card:hover .dc-go { color: var(--brand); }

/* 下钻返回条（部门内） */
.drill-bar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 10px 12px; border-bottom: 1px solid var(--line-2); background: #f8fafc;
}
.drill-back {
  display: inline-flex; align-items: center; gap: 5px; cursor: pointer;
  border: 1px solid var(--line); background: #fff; color: var(--ink-2);
  border-radius: 7px; padding: 5px 12px; font-size: 12.5px; font-weight: 600;
}
.drill-back:hover { border-color: var(--brand); color: var(--brand); }
.drill-title { font-size: 13.5px; font-weight: 700; }
.drill-sub { font-size: 12px; color: var(--ink-3); }
.drill-sub b { color: var(--ink); }

/* 人员卡片：比原来小一圈 */
.team-cards {
  grid-template-columns: repeat(auto-fill, minmax(168px, 1fr));
  gap: 9px; padding: 12px;
}
.team-cards .p-card { padding: 9px 11px 8px; border-radius: 9px; }
.team-cards .pc-head { margin-bottom: 4px; }
.team-cards .pc-name { font-size: 13.5px; font-weight: 700; }
.team-cards .pc-dept { display: none; }
.team-cards .pc-owe .num { font-size: 16px; font-weight: 800; }
.team-cards .p-card-zero .pc-owe .num { font-size: 13px; }
.team-cards .pc-meta { font-size: 11px; margin-top: 3px; }
.team-cards .aging-stack { height: 5px; margin-top: 6px; }
.team-cards .pc-foot { font-size: 11px; margin-top: 5px; }

/* --- 图表面板 --- */
.chart-panel { padding: 12px 14px 14px; }
.chart-cap {
  font-size: 12px; font-weight: 700; color: var(--ink-2);
  display: flex; align-items: center; gap: 6px; margin-bottom: 8px;
}
.chart-cap span { font-weight: 400; color: var(--ink-3); font-size: 11.5px; }
.donut-wrap { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.donut { flex: 0 0 152px; }
.donut-legend { flex: 1; min-width: 150px; display: flex; flex-direction: column; gap: 5px; }
.dl-row { display: flex; align-items: center; gap: 7px; font-size: 12px; }
.dl-dot { width: 8px; height: 8px; border-radius: 2px; flex: 0 0 8px; }
.dl-name { color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dl-val { margin-left: auto; font-weight: 700; color: var(--ink); font-variant-numeric: tabular-nums; }
.dl-pct { color: var(--ink-3); font-size: 11px; width: 36px; text-align: right; }

.hbars { display: flex; flex-direction: column; gap: 7px; margin-top: 2px; }
.hbar { display: grid; grid-template-columns: 62px 1fr 58px; align-items: center; gap: 8px; cursor: pointer; }
.hbar-name { font-size: 12px; color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hbar-track { height: 12px; background: var(--line-2); border-radius: 3px; overflow: hidden; }
.hbar-track i { display: block; height: 100%; border-radius: 3px; transition: width .3s; }
.hbar-val { font-size: 11.5px; font-weight: 700; text-align: right; color: var(--ink); font-variant-numeric: tabular-nums; }
.hbar:hover .hbar-name { color: var(--brand); font-weight: 600; }

.chart-divider { height: 1px; background: var(--line-2); margin: 14px 0 10px; }

/* --- 洞察条 --- */
.insight {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 10px; padding: 12px 14px; border-bottom: 1px solid var(--line-2); background: #fbfcfe;
}
.insight-item { font-size: 12.5px; color: var(--ink-2); line-height: 1.5; }
.insight-item .t { font-size: 11.5px; color: var(--ink-3); display: block; margin-bottom: 2px; }
.insight-item b { font-weight: 700; color: var(--ink); }
.insight-item b.red { color: var(--red); }
.insight-item b.amber { color: var(--amber); }
.insight-item b.teal { color: var(--teal); }

/* --- 分析表 --- */
.an-table { overflow-x: auto; }
.an-table table { min-width: 900px; font-size: 12.5px; }
.an-table th { white-space: nowrap; }
.an-table td { white-space: nowrap; }
.an-table tbody tr { cursor: pointer; }
.hb-cell { display: flex; align-items: center; gap: 7px; min-width: 116px; }
.hb-track { flex: 1; height: 6px; border-radius: 3px; background: var(--line-2); overflow: hidden; }
.hb-track i { display: block; height: 100%; border-radius: 3px; }
.hb-num { font-weight: 700; font-variant-numeric: tabular-nums; width: 22px; text-align: right; }

/* --- 客户信用 --- */
.grade-chip {
  display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid var(--line); background: #fff; border-radius: 99px;
  padding: 5px 11px; font-size: 12.5px; color: var(--ink-2);
}
.grade-chip b { font-weight: 800; }
.grade-chip.on { color: #fff; border-color: transparent; }
.grade-chip[data-g="A"].on { background: var(--teal); }
.grade-chip[data-g="B"].on { background: #3f7f8f; }
.grade-chip[data-g="C"].on { background: var(--amber); }
.grade-chip[data-g="D"].on { background: #b0503f; }
.grade-chip[data-g="E"].on { background: var(--red); }
.grade-chip .cnt { font-size: 11px; opacity: .72; }

.gtag {
  display: inline-grid; place-items: center; width: 22px; height: 22px;
  border-radius: 6px; font-weight: 800; font-size: 12px; color: #fff;
}
.gtag.A { background: var(--teal); } .gtag.B { background: #3f7f8f; }
.gtag.C { background: var(--amber); } .gtag.D { background: #b0503f; } .gtag.E { background: var(--red); }

.score-bar { display: flex; align-items: center; gap: 6px; }
.score-bar .sb { width: 44px; height: 5px; border-radius: 3px; background: var(--line-2); overflow: hidden; }
.score-bar .sb i { display: block; height: 100%; }
.score-bar b { font-variant-numeric: tabular-nums; font-size: 12.5px; width: 22px; }

.chip-tag {
  display: inline-block; padding: 1px 7px; border-radius: 99px; font-size: 11px;
  background: var(--slate-soft); color: var(--ink-2); white-space: nowrap;
}
.chip-tag.red { background: var(--red-soft); color: var(--red); }
.chip-tag.amber { background: var(--amber-soft); color: var(--amber); }
.chip-tag.teal { background: var(--teal-soft); color: var(--teal); }

.credit-note { padding: 10px 14px; font-size: 12px; color: var(--ink-3); border-top: 1px solid var(--line-2); line-height: 1.6; }
.guide { display: flex; flex-wrap: wrap; gap: 14px; padding: 10px 14px; font-size: 11.5px; color: var(--ink-3); background: #fbfcfe; border-bottom: 1px solid var(--line-2); }
.guide b { color: var(--ink-2); }
.team-cards .pc-meta span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.team-cards .pc-foot { gap: 6px; }
