:root {
  --bg: #f5f6f4;
  --panel: #ffffff;
  --ink: #16211b;
  --ink2: #5c6a62;
  --ink3: #8b978f;
  --line: #e2e6e0;
  --green: #0f5132;
  --green2: #1a7f4f;
  --green-soft: #e9f2ec;
  --gold: #a9853f;
  --gold-soft: #f7f0e2;
  --red: #c0392b;
  --red-soft: #fbeceb;
  --blue: #2c5f8a;
  --blue-soft: #eaf1f7;
  --shadow: 0 1px 2px rgba(20, 40, 28, .05), 0 8px 24px rgba(20, 40, 28, .06);
  --r: 10px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }

html, body { height: 100%; }

body {
  font-family: -apple-system, "PingFang SC", "Helvetica Neue", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

.num { font-variant-numeric: tabular-nums; font-feature-settings: "tnum"; }

/* ---------------- 布局 ---------------- */
.app { display: grid; grid-template-columns: 78px 1fr; height: 100vh; overflow: hidden; }

.rail {
  background: var(--green);
  display: flex; flex-direction: column; align-items: center;
  padding: 18px 0; gap: 6px;
}
.rail .logo {
  width: 38px; height: 38px; border-radius: 11px; background: rgba(255,255,255,.14);
  display: grid; place-items: center; color: #fff; font-weight: 700; font-size: 15px;
  margin-bottom: 14px; letter-spacing: -.5px;
}
.rail button {
  width: 62px; padding: 9px 0 7px; border: 0; background: transparent; color: rgba(255,255,255,.62);
  border-radius: 9px; cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 4px;
  font-size: 11px; font-family: inherit; transition: .15s;
}
.rail button svg { width: 19px; height: 19px; stroke: currentColor; fill: none; stroke-width: 1.7; }
.rail button:hover { color: #fff; background: rgba(255,255,255,.08); }
.rail button.on { color: #fff; background: rgba(255,255,255,.16); }

.main { display: flex; flex-direction: column; overflow: hidden; }

.topbar {
  height: 58px; flex: 0 0 58px; background: var(--panel);
  border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 14px; padding: 0 22px;
}
.topbar h1 { font-size: 15px; font-weight: 600; letter-spacing: .2px; }
.topbar .spacer { flex: 1; }

.searchbox {
  position: relative; width: 320px;
}
.searchbox input {
  width: 100%; height: 34px; padding: 0 12px 0 32px;
  border: 1px solid var(--line); border-radius: 8px; background: #fafbfa;
  font-size: 13px; font-family: inherit; color: var(--ink); outline: none;
  transition: .15s;
}
.searchbox input:focus { border-color: var(--green2); background: #fff; box-shadow: 0 0 0 3px rgba(26,127,79,.1); }
.searchbox svg { position: absolute; left: 10px; top: 9px; width: 15px; height: 15px; stroke: var(--ink3); fill: none; stroke-width: 2; }

.btn {
  height: 34px; padding: 0 14px; border-radius: 8px; border: 1px solid var(--line);
  background: #fff; color: var(--ink); font-size: 13px; font-family: inherit; cursor: pointer;
  display: inline-flex; align-items: center; gap: 6px; transition: .15s; white-space: nowrap;
}
.btn:hover { border-color: #c9d2cb; background: #fafbfa; }
.btn.primary { background: var(--green); border-color: var(--green); color: #fff; }
.btn.intake-alert { border-color: #e7c98a; background: #fff8ec; color: #8a5a10; font-weight: 650; }
.btn.intake-alert.has { background: #b45309; border-color: #b45309; color: #fff; }
.btn.intake-alert.late { background: #9f2d22; border-color: #9f2d22; color: #fff; }
.intake-row.late { background: #fff6f5; }
.intake-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.intake-table th, .intake-table td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.intake-table th { font-size: 12px; color: var(--ink3); font-weight: 600; }
.intake-table .why { width: 140px; height: 30px; border: 1px solid var(--line); border-radius: 6px; padding: 0 8px; font: inherit; }
.btn.primary:hover { background: #0c4229; }
.btn.ai { background: linear-gradient(135deg, #16332a, #0f5132); border-color: transparent; color: #fff; }
.btn.ai:hover { filter: brightness(1.12); }
.btn.ghost { border-color: transparent; color: var(--ink2); }
.btn.ghost:hover { background: #eef1ee; color: var(--ink); }
.btn.sm { height: 28px; padding: 0 10px; font-size: 12px; border-radius: 7px; }
.btn svg { width: 15px; height: 15px; stroke: currentColor; fill: none; stroke-width: 1.9; }

/* 备份镜像状态点 / 路径显示 */
.dot { display: inline-block; width: 6px; height: 6px; border-radius: 50%; margin-right: 5px; vertical-align: 1px; background: var(--ink3); }
.dot.ok { background: var(--green2); }
.dot.warn { background: var(--gold); }
.mir-row { display: flex; gap: 6px; align-items: center; margin-top: 5px; }
.mir-input { flex: 1 1 auto; min-width: 0; font-size: 11.5px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.mir-path { margin-top: 3px; font-size: 10.5px; color: var(--ink3); word-break: break-all; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; line-height: 1.45; }

/* 列表行尾的快捷核销 / 充值 */
/* 列表里「核销 / 充值」两个小按钮（紧跟在手机列后，属冻结区） */
td.op-cell { white-space: nowrap; }
td.op-cell .btn + .btn { margin-left: 5px; }
td.op-cell .btn { padding: 0 8px; }

/* 快捷核销 / 充值小窗 */
.modal-box.op-box { width: 580px; }
.op-bal { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.op-bal-cell { background: var(--bg); border: 1px solid var(--line); border-radius: 9px; padding: 8px 10px; }
.op-bal-cell span { display: block; font-size: 11px; color: var(--ink3); margin-bottom: 1px; }
.op-bal-cell b { font-size: 15px; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.op-bal-cell.zero b { color: var(--ink3); font-weight: 500; }
/* 弹窗 body 里没有 .form 包裹，三列栅格要单独给 */
#opBody .row { display: grid; gap: 10px; margin-bottom: 10px; }
#opBody .row.c3 { grid-template-columns: 1fr 1fr 1fr; }
#opBody .field { min-width: 0; }
/* 弹窗只有 580px 宽，五个类型块排一行要缩字号，否则状态文字被省略号吃掉 */
#opBody .btile { padding: 8px; }
#opBody .btile .bt-name { font-size: 12px; }
#opBody .btile .bt-val { font-size: 10.5px; }
/* 四本账 2×2 排，点击目标更大，字也不会挤一行 */
/* 双类是为了压过后面的 .chip-row{display:flex}，单类会被覆盖 */
.chip-row.op-items { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.chip-row.op-items .chip { text-align: center; padding: 8px 10px; border-radius: 9px; }
.chip em { font-style: normal; opacity: .6; margin-left: 5px; font-size: 11px; }
.chip.on em { opacity: .82; }

/* 权益转出小窗 */
#tfBody .row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 10px; }
#tfBody .field { min-width: 0; }
.tf-rows { display: flex; flex-direction: column; gap: 7px; }
.tf-row { display: grid; grid-template-columns: 1fr 96px 32px; gap: 10px; align-items: center; }
.tf-label { font-size: 12.5px; color: var(--ink2); }
.tf-label em { font-style: normal; font-size: 11px; color: var(--ink3); margin-left: 6px; }
.tf-qty { width: 100%; height: 32px; padding: 0 9px; border: 1px solid var(--line); border-radius: 7px; font-size: 13px; font-family: inherit; outline: none; text-align: right; font-variant-numeric: tabular-nums; }
.tf-qty:focus { border-color: var(--green2); box-shadow: 0 0 0 3px var(--green-soft); }
.tf-unit { font-size: 12px; color: var(--ink3); text-align: left; }

.view { flex: 1; overflow-y: auto; padding: 20px 22px 40px; }
.view[hidden] { display: none; }

/* 客户列表：卡片撑满视口剩余高度，表格区内部滚动，不再用写死的 100vh-345px */
.view-fill { display: flex; flex-direction: column; overflow-y: auto; padding-bottom: 20px; }
.view-fill > .card { flex: 1 1 auto; min-height: 420px; display: flex; flex-direction: column; }
.view-fill .card-head, .view-fill .filterbar, .view-fill .list-foot { flex: 0 0 auto; }
.tbl-wrap { flex: 1; min-height: 0; overflow: auto; }

/* ---------------- 统计卡 ---------------- */
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; margin-bottom: 18px; }
.stat {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--r);
  padding: 13px 15px;
}
.stat .k { font-size: 11.5px; color: var(--ink3); margin-bottom: 6px; letter-spacing: .3px; }
.stat .v { font-size: 21px; font-weight: 600; letter-spacing: -.3px; }
.stat .v small { font-size: 11px; font-weight: 400; color: var(--ink3); margin-left: 3px; }

/* ---------------- 表格 ---------------- */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; }
.card-head {
  height: 44px; display: flex; align-items: center; gap: 10px; padding: 0 15px;
  border-bottom: 1px solid var(--line); font-size: 13px; font-weight: 600;
}
.card-head .spacer { flex: 1; }
.card-head .hint { font-weight: 400; color: var(--ink3); font-size: 12px; }

/* 列表底部翻页条 */
.list-foot {
  height: 42px; display: flex; align-items: center; gap: 8px;
  padding: 0 15px; border-top: 1px solid var(--line);
  font-weight: 400;
}
.list-foot .spacer { flex: 1; }
.list-foot .hint { color: var(--ink3); font-size: 12px; font-weight: 400; }
.list-foot [hidden] { display: none !important; }

table { width: 100%; min-width: 1440px; border-collapse: separate; border-spacing: 0; }
thead th {
  text-align: left; font-size: 11.5px; font-weight: 500; color: var(--ink3);
  padding: 9px 14px; background: #fafbfa; border-bottom: 1px solid var(--line);
  white-space: nowrap; letter-spacing: .2px;
  position: sticky; top: 0; z-index: 3;
}
th .th-sub {
  display: block; font-size: 10px; font-weight: 400; color: var(--ink3);
  opacity: .75; letter-spacing: 0;
}
tbody td { padding: 9px 14px; border-bottom: 1px solid #f0f2ef; font-size: 13px; background: #fff; }
tbody tr { cursor: pointer; transition: background .1s; }
tbody tr:hover td { background: #f8faf8; }
tbody tr:last-child td { border-bottom: 0; }
td.r, th.r { text-align: right; }

/* 会员号 / 姓名 / 手机 / 操作 四列冻结在左侧（偏移由 JS 实测列宽写入 --w1 / --w12 / --w123） */
.sticky-1, .sticky-2, .sticky-3, .sticky-4 {
  position: sticky; z-index: 2;
  background: #fff;
}
th.sticky-1, th.sticky-2, th.sticky-3, th.sticky-4 { background: #fafbfa; z-index: 4; }
.sticky-1 { left: 0; }
.sticky-2 { left: var(--w1, 104px); }
.sticky-3 { left: var(--w12, 224px); }
/* 操作列是冻结区最后一列，分隔阴影跟着它走 */
.sticky-4 { left: var(--w123, 348px); box-shadow: 6px 0 8px -6px rgba(16, 28, 21, .18); }
tbody tr:hover .sticky-1,
tbody tr:hover .sticky-2,
tbody tr:hover .sticky-3,
tbody tr:hover .sticky-4 { background: #f8faf8; }

/* 姓名过长不换行，省略号截断，title 里看全名 */
.sticky-2 b {
  display: inline-block; max-width: 108px; overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap; vertical-align: bottom;
}

/* 数值两行：剩余为主，下附已核销 / 共 */
.num-main { display: block; font-variant-numeric: tabular-nums; line-height: 18px; height: 18px; }
.qty-sub {
  font-size: 10.5px; color: var(--ink3); white-space: nowrap;
  font-variant-numeric: tabular-nums; line-height: 14px; height: 14px;
}
.muted { color: var(--ink3); }
.warn-txt { color: var(--amber, #b7791f); }
.bhint .warn-txt { display: block; margin-top: 5px; }
.bhint .warn-txt[hidden] { display: none; }
.tag {
  display: inline-block; padding: 1px 7px; border-radius: 5px; font-size: 11px;
  background: var(--green-soft); color: var(--green); white-space: nowrap;
}
.tag.gray { background: #f0f2ef; color: var(--ink2); }
.tag.gold { background: var(--gold-soft); color: var(--gold); }
.tag.red { background: var(--red-soft); color: var(--red); }
.tag.blue { background: var(--blue-soft); color: var(--blue); }
.tag.warn { background: var(--gold-soft); color: var(--gold); }
.tag.exp { background: var(--red-soft); color: var(--red); }
.mini-tag.warn { background: var(--gold-soft); color: var(--gold); }
.mini-tag.exp { background: var(--red-soft); color: var(--red); }

/* 时效卡（客户权益类型 4、5）展示块 */
.tc-block { background: var(--blue-soft); border: 1px solid #d6e2f1; border-radius: 10px; padding: 10px 12px; margin-bottom: 12px; }
.tc-block .tc-t { font-size: 12.5px; font-weight: 600; color: var(--blue); margin-bottom: 4px; }
.tc-block .tc-row { font-size: 12px; color: var(--ink2); }
.tc-block .tc-row b { font-size: 13px; }
.tc-block .tc-row b.tc-warn { color: var(--gold); }
.tc-block .tc-row b.tc-exp { color: var(--red); }
.op-tc { display: flex; align-items: center; gap: 8px; }
.op-tc .muted { font-size: 11.5px; }

/* ---------------- 权益类型选择（核销 / 充值 共用） ---------------- */
.bstep {
  display: flex; align-items: center; gap: 8px;
  font-size: 12px; font-weight: 600; color: var(--ink2);
  margin: 2px 0 9px;
}
.bstep::after { content: ''; flex: 1; height: 1px; background: var(--line); }
.btiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 7px; margin-bottom: 16px; }
.btile {
  display: flex; flex-direction: column; align-items: flex-start; gap: 3px;
  padding: 9px 10px; border: 1px solid var(--line); border-radius: 9px;
  background: #fff; cursor: pointer; font-family: inherit; text-align: left;
  transition: .14s; min-width: 0;
}
.btile:hover { border-color: #bfd4c6; }
.btile.on { border-color: var(--green); background: var(--green-soft); box-shadow: 0 0 0 2px var(--green-soft); }
.btile.dis { opacity: .55; }
.btile.dis:hover { border-color: var(--line); }
.btile .bt-name { font-size: 12.5px; font-weight: 600; color: var(--ink); white-space: nowrap; }
.btile .bt-val { font-size: 11px; color: var(--ink3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.btile.on .bt-val { color: var(--green); }

/* 充值页 ① 步只有一条下拉，给个独立包裹控制间距 */
.bfield-single { margin-bottom: 16px; }
.bfield-single select { width: 100%; }

.bhint { font-size: 11.5px; color: var(--ink3); line-height: 1.6; margin-top: 9px; }
.bhint b { color: var(--ink); }

/* 面板里的字段不走 .form 的灰底盒，但栅格规则得补上，否则三列会竖着堆 */
.bfields .row { display: grid; gap: 10px; margin-bottom: 10px; }
.bfields .row.c2 { grid-template-columns: 1fr 1fr; }
.bfields .row.c3 { grid-template-columns: 1fr 1fr 1fr; }
.bfields .row.c4 { grid-template-columns: repeat(4, 1fr); }
.bfields .field { min-width: 0; margin-bottom: 10px; }
.bfields .row .field { margin-bottom: 0; }
.bfields .actions { display: flex; justify-content: flex-end; margin-top: 2px; }

/* 没这项权益时的拦截面 */
.bblock {
  font-size: 12.5px; color: var(--ink2); line-height: 1.7;
  background: var(--gold-soft, #fdf6e6); border: 1px solid #f2e3bd;
  border-radius: 9px; padding: 10px 12px;
}
.bblock b { color: var(--gold); }

/* 核销权益页底部：转出 / 合并 */
.board-tools { padding: 0 15px 15px; }
.board-tools .sec-title { margin-top: 0; }
.board-tools .sec-title .hint { font-weight: 400; font-size: 11.5px; margin-left: 4px; }
.tool-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.tool-row .btn:disabled { opacity: .45; cursor: not-allowed; }

/* 生命周期状态徽章 + 自动标记标签（姓名列下方） */
.stage-row { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; margin-top: 2px; min-height: 15px; }
.stage-badge {
  display: inline-block; padding: 0 7px; border-radius: 999px; font-size: 10.5px;
  font-weight: 600; white-space: nowrap; line-height: 16px;
}
.stage-new    { background: var(--blue-soft); color: var(--blue); }
.stage-active { background: var(--green-soft); color: var(--green); }
.stage-sleep  { background: var(--gold-soft); color: var(--gold); }
.stage-lost   { background: #ecefec; color: var(--ink3); }
.mini-tag {
  display: inline-block; padding: 0 6px; border-radius: 5px; font-size: 10px;
  background: #f0f2ef; color: var(--ink2); white-space: nowrap; line-height: 16px;
}
.mini-tag.more { background: transparent; color: var(--ink3); }

/* 详情抽屉里的状态 + 标记块 */
.stage-block { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin: 2px 0 12px; }
.stage-block .stage-badge { font-size: 11.5px; padding: 1px 9px; line-height: 19px; }
.stage-block .mini-tag { font-size: 11px; padding: 1px 8px; line-height: 18px; }

.zero { color: #c4ccc6; }
.empty { padding: 48px; text-align: center; color: var(--ink3); font-size: 13px; }

/* ---------------- 抽屉 ---------------- */
.mask {
  position: fixed; inset: 0; background: rgba(16,28,21,.32); z-index: 40;
  opacity: 0; pointer-events: none; transition: opacity .2s;
}
.mask.on { opacity: 1; pointer-events: auto; }

.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: 560px; max-width: 94vw;
  background: var(--panel); z-index: 41; box-shadow: -12px 0 40px rgba(16,28,21,.14);
  transform: translateX(100%); transition: transform .24s cubic-bezier(.32,.72,0,1);
  display: flex; flex-direction: column;
}
.drawer.on { transform: translateX(0); }

.dw-head { padding: 18px 22px 14px; border-bottom: 1px solid var(--line); }
.dw-head .row1 { display: flex; align-items: flex-start; gap: 10px; }
.dw-head h2 { font-size: 19px; font-weight: 600; letter-spacing: -.2px; }
.dw-head .meta { font-size: 12px; color: var(--ink3); margin-top: 5px; line-height: 1.6; }
.dw-close {
  margin-left: auto; width: 30px; height: 30px; border: 0; background: #f2f4f2; border-radius: 8px;
  cursor: pointer; color: var(--ink2); display: grid; place-items: center; flex: 0 0 auto;
}
.dw-close:hover { background: #e8ebe8; color: var(--ink); }
.dw-close svg { width: 15px; height: 15px; stroke: currentColor; stroke-width: 2; fill: none; }

.dw-body { flex: 1; overflow-y: auto; padding: 16px 22px 32px; }

.bal-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 9px; margin-bottom: 16px; }
.bal {
  background: #f8faf8; border: 1px solid var(--line); border-radius: 9px; padding: 11px 12px;
}
.bal .k { font-size: 11px; color: var(--ink3); margin-bottom: 4px;
  display: flex; align-items: baseline; justify-content: space-between; gap: 6px; }
.bal .k em { font-style: normal; font-size: 10px; color: var(--ink3); opacity: .85; letter-spacing: .2px; }
.bal .v { font-size: 18px; font-weight: 600; letter-spacing: -.3px; }
.bal .v small { font-size: 10.5px; color: var(--ink3); font-weight: 400; margin-left: 2px; }
.bal.hot { background: var(--green-soft); border-color: #cfe3d7; }
.bal.hot .v { color: var(--green); }
.bal-sub {
  margin-top: 5px; padding-top: 5px; border-top: 1px dashed var(--line);
  font-size: 10.5px; color: var(--ink3); white-space: nowrap; letter-spacing: -.1px;
}
/* 抽屉较窄，四张卡排两行更易读 */
#drawer .bal-grid { grid-template-columns: repeat(2, 1fr); }

.op-row { display: flex; gap: 8px; margin-bottom: 18px; flex-wrap: wrap; }

.sec-title {
  font-size: 12px; font-weight: 600; color: var(--ink2); margin: 0 0 10px;
  display: flex; align-items: center; gap: 8px;
}
.sec-title::after { content: ''; flex: 1; height: 1px; background: var(--line); }
.sec-title .hint { font-weight: 400; font-size: 11px; color: var(--ink3); order: 1; }
.sec-title::after { order: 2; }

/* 内联表单 */
.form { background: #f8faf8; border: 1px solid var(--line); border-radius: 9px; padding: 14px; margin-bottom: 16px; }
.form .row { display: grid; gap: 10px; margin-bottom: 10px; }
.form .row.c2 { grid-template-columns: 1fr 1fr; }
.form .row.c3 { grid-template-columns: 1fr 1fr 1fr; }
.form .row.c4 { grid-template-columns: repeat(4, 1fr); }
.field label { display: block; font-size: 11.5px; color: var(--ink2); margin-bottom: 5px; }
.field input, .field select, .field textarea {
  width: 100%; height: 34px; padding: 0 10px; border: 1px solid #d9e0da; border-radius: 7px;
  background: #fff; font-size: 13px; font-family: inherit; color: var(--ink); outline: none;
}
.field textarea { height: 64px; padding: 8px 10px; resize: vertical; line-height: 1.5; }
.field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--green2); box-shadow: 0 0 0 3px rgba(26,127,79,.1);
}
.form .actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 2px; }

.chip-row { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  padding: 5px 11px; border: 1px solid var(--line); border-radius: 20px; background: #fff;
  font-size: 12px; cursor: pointer; font-family: inherit; color: var(--ink2); transition: .12s;
}
.chip:hover { border-color: #c3cdc6; color: var(--ink); }
.chip.on { background: var(--green); border-color: var(--green); color: #fff; }

/* 时间线 */
.tl { position: relative; padding-left: 16px; }
.tl::before { content: ''; position: absolute; left: 4px; top: 6px; bottom: 6px; width: 1px; background: var(--line); }
.tl-item { position: relative; padding: 0 0 15px 0; }
.tl-item::before {
  content: ''; position: absolute; left: -16px; top: 5px; width: 7px; height: 7px;
  border-radius: 50%; background: #cfd8d1; border: 2px solid #fff;
}
.tl-item.plus::before { background: var(--green2); }
.tl-item.minus::before { background: #d8a13c; }
.tl-top { display: flex; align-items: baseline; gap: 8px; }
.tl-top .t { font-size: 12.5px; font-weight: 500; }
.tl-top .d { font-size: 11px; color: var(--ink3); margin-left: auto; }
.tl-sub { font-size: 11.5px; color: var(--ink3); margin-top: 2px; line-height: 1.5; }
.tl-qty { font-size: 12.5px; font-weight: 600; }
.tl-qty.plus { color: var(--green2); }
.tl-qty.minus { color: #b8832a; }

/* ---------------- 模态 ---------------- */
/* 打开顺序的层级在 app.js 里按弹窗栈写到元素上，后开的盖住先开的。这里的 60 只是没打开时的底。 */
.modal {
  position: fixed; inset: 0; z-index: 60; display: none; align-items: center; justify-content: center;
  background: rgba(16,28,21,.38); padding: 24px;
}
.modal.on { display: flex; }
.modal-box {
  background: var(--panel); border-radius: 14px; width: 880px; max-width: 100%;
  max-height: 90vh; display: flex; flex-direction: column; overflow: hidden;
  box-shadow: 0 24px 70px rgba(16,28,21,.24);
  /* 只动位置不动透明度：动画被节流/暂停时元素依然可见，不会整块消失 */
  animation: pop .18s cubic-bezier(.32,.72,0,1);
}
@keyframes pop { from { transform: scale(.98) translateY(6px); } }
.modal-box.narrow { width: 520px; }
.modal-head {
  padding: 16px 20px; border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 10px;
}
.modal-head h3 { font-size: 15px; font-weight: 600; }
.modal-head .sub { font-size: 11.5px; color: var(--ink3); margin-left: 4px; }
.modal-body { flex: 1; overflow-y: auto; padding: 18px 20px; }
.modal-foot {
  padding: 13px 20px; border-top: 1px solid var(--line); background: #fafbfa;
  display: flex; align-items: center; gap: 9px;
}
.modal-foot .spacer { flex: 1; }

.ai-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.ai-grid textarea {
  width: 100%; height: 240px; padding: 12px; border: 1px solid #d9e0da; border-radius: 9px;
  font-size: 13px; font-family: inherit; line-height: 1.7; resize: none; outline: none; background: #fff;
}
.ai-grid textarea:focus { border-color: var(--green2); box-shadow: 0 0 0 3px rgba(26,127,79,.1); }
.ai-examples { margin-top: 10px; }
.ai-examples .t { font-size: 11.5px; color: var(--ink3); margin-bottom: 6px; }
.ex {
  display: block; width: 100%; text-align: left; padding: 7px 10px; margin-bottom: 5px;
  border: 1px dashed #d9e0da; border-radius: 7px; background: #fbfcfb; font-size: 12px;
  color: var(--ink2); cursor: pointer; font-family: inherit; line-height: 1.5;
}
.ex:hover { border-color: var(--green2); color: var(--ink); background: #fff; }

.result-panel {
  background: #f8faf8; border: 1px solid var(--line); border-radius: 9px; padding: 14px;
  min-height: 240px;
}
.result-panel .ph { color: var(--ink3); font-size: 12.5px; text-align: center; padding-top: 90px; line-height: 1.8; }

.conf-bar { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.conf-track { flex: 1; height: 5px; background: #e6ebe7; border-radius: 3px; overflow: hidden; }
.conf-fill { height: 100%; border-radius: 3px; transition: width .4s; }
.conf-num { font-size: 12px; font-weight: 600; }

.kv { display: grid; grid-template-columns: 62px 1fr; gap: 7px 10px; font-size: 12.5px; margin-bottom: 12px; }
.kv .k { color: var(--ink3); }
.kv .v { color: var(--ink); font-weight: 500; }
.kv .v em { font-style: normal; color: var(--ink3); font-weight: 400; font-size: 11.5px; }

.warns { margin-top: 10px; }
.warn {
  display: flex; gap: 6px; font-size: 11.5px; color: #96690f; background: #fdf6e6;
  border: 1px solid #f2e3bd; border-radius: 7px; padding: 7px 9px; margin-bottom: 5px; line-height: 1.5;
}

.match-box { margin-top: 10px; }
.match {
  display: flex; align-items: center; gap: 9px; padding: 8px 10px; border: 1px solid var(--line);
  border-radius: 8px; background: #fff; margin-bottom: 5px; cursor: pointer; transition: .12s;
}
.match:hover { border-color: var(--green2); }
.match.on { border-color: var(--green2); background: var(--green-soft); }
.match > div:first-child { min-width: 0; flex: 1; }
.match .nm { font-weight: 600; font-size: 12.5px; }
.match .mt { font-size: 11.5px; color: var(--ink3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.match .go { margin-left: auto; font-size: 11px; color: var(--green); white-space: nowrap; flex: 0 0 auto; }

/* 今日面板 */
.board-grid {
  display: grid; grid-template-columns: 1fr 350px; gap: 14px;
  align-items: stretch; min-height: calc(100vh - 132px);
}
.mini-stat { display: flex; gap: 18px; padding: 13px 15px; border-bottom: 1px solid var(--line); }
.mini-stat div { }
.mini-stat .k { font-size: 11px; color: var(--ink3); }
.mini-stat .v { font-size: 17px; font-weight: 600; margin-top: 2px; }

.tabs { display: flex; gap: 4px; background: #eff2ef; padding: 3px; border-radius: 8px; }
.tabs button {
  border: 0; background: transparent; padding: 6px 13px; border-radius: 6px; font-size: 12.5px;
  font-family: inherit; color: var(--ink2); cursor: pointer;
}
.tabs button.on { background: #fff; color: var(--ink); box-shadow: 0 1px 2px rgba(0,0,0,.07); font-weight: 500; }
.tabs button i { font-style: normal; font-size: 10.5px; color: var(--ink3); margin-left: 4px; font-variant-numeric: tabular-nums; }
.tabs button.on i { color: var(--green); }

/* ---------------- 客户列表筛选条 ---------------- */
.filterbar {
  display: flex; align-items: center; gap: 7px; flex-wrap: wrap;
  padding: 9px 15px; border-bottom: 1px solid var(--line); background: #fcfdfc;
  font-weight: 400;
}
.filterbar .spacer { flex: 1; }
.filterbar [hidden] { display: none !important; }
.filterbar .sortsel { height: 27px; }
.sortlab { font-size: 12px; color: var(--ink3); font-weight: 400; }
.dirbtn { min-width: 70px; justify-content: center; }

/* 表头点一下就能排：当前列高亮 + 箭头，未选中的只在悬停时给个提示 */
th.sortable { cursor: pointer; user-select: none; }
th.sortable:hover { background: #f2f6f3; color: var(--ink2); }
th.sortable .ind { margin-left: 3px; font-size: 9px; opacity: .9; }
th.sortable:not(.on):hover .ind::after { content: '⇅'; opacity: .45; }
th.sortable.on { color: var(--green); }

/* toast */
.toast-wrap { position: fixed; top: 18px; left: 50%; transform: translateX(-50%); z-index: 90; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast {
  padding: 9px 16px; border-radius: 9px; font-size: 13px; color: #fff; background: #1d2b23;
  box-shadow: 0 8px 24px rgba(16,28,21,.2); animation: tin .18s;
}
.toast.err { background: var(--red); }
.toast.ok { background: var(--green); }
@keyframes tin { from { transform: translateY(-8px); } }

/* ---------------- 侧栏底部：设置 / 登录 ---------------- */
.rail-foot {
  margin-top: auto; width: 100%;
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding-top: 12px;
  border-top: 1px solid rgba(255,255,255,.14);
}
.rail-tool {
  width: 62px; padding: 8px 0 6px; border: 0; background: transparent;
  color: rgba(255,255,255,.6); border-radius: 9px; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  font-size: 10.5px; font-family: inherit; transition: .15s;
}
.rail-tool svg { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 1.6; }
.rail-tool:hover { color: #fff; background: rgba(255,255,255,.1); }
.rail-tool.who { padding-top: 5px; }
.rail-tool .avi {
  width: 27px; height: 27px; border-radius: 50%; display: grid; place-items: center;
  background: rgba(255,255,255,.18); color: #fff; font-size: 11.5px; font-weight: 600;
  letter-spacing: 0;
}
.rail-tool.who.on .avi { background: #fff; color: var(--green); }
.rail-tool .who-name {
  font-size: 10px; max-width: 60px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* 抽屉里的操作按钮：走 3 列网格，别用 flex 硬挤（多一个按钮就换行错位）。
   必须写成 .op-row.op-btns：后面还有一条 .op-row{grid-template-columns:1fr 88px 82px 26px}
   是给设置页操作员行用的，同权重会把它盖掉。 */
.op-row.op-btns { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-bottom: 18px; }
.op-row.op-btns .btn { width: 100%; justify-content: center; border: 1px solid #9aafa2; background: #fff; color: var(--ink); }
.op-row.op-btns .btn:hover { border-color: #5f7d6c; background: #f7faf8; }
.batch-price { margin-left: auto; color: var(--ink2); white-space: nowrap; }
.btn.danger { color: var(--red); border-color: #e7c4c0; background: #fff; }
.btn.danger:hover { background: var(--red-soft); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.rev-hit { appearance: none; border: 1px solid transparent; background: transparent; text-align: left; cursor: pointer; border-radius: 8px; padding: 4px 6px; font: inherit; color: inherit; }
.rev-hit:hover { border-color: #9aafa2; background: #f4faf6; }
.rev-line { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--line, #e6ece8); font-size: 13px; }
.rev-line b { white-space: nowrap; }
.fin-totals { display: flex; gap: 18px; margin: 8px 0 4px; }
.fin-totals div { min-width: 120px; }
.fin-totals .k { color: var(--ink3); font-size: 12px; }
.fin-totals .v { font-size: 20px; font-weight: 650; }
.price-row { padding: 10px 0; border-bottom: 1px solid var(--line, #e6ece8); }
.price-row .nm { font-size: 13px; margin-bottom: 6px; }

/* 禁用态要看得出来，不然「确认合并」灰着也像个能点的按钮 */
.btn:disabled { opacity: .42; cursor: not-allowed; }

/* ---------------- 介绍人 / 备注 ---------------- */
.ref-link { color: var(--green); text-decoration: none; border-bottom: 1px dashed rgba(0,0,0,.14); cursor: pointer; }
.ref-link:hover { border-bottom-color: var(--green); }

/* 介绍人选择器：输入即搜，选中后高亮，× 清除 */
.ref-wrap { position: relative; }
.ref-wrap input { width: 100%; padding-right: 30px; }
.ref-wrap input.picked { font-weight: 600; color: var(--green); background: var(--green-soft); border-color: #cfe3d7; }
.ref-x {
  position: absolute; right: 7px; top: 50%; transform: translateY(-50%);
  width: 18px; height: 18px; padding: 0; border: 0; border-radius: 50%;
  background: #e6eae6; color: var(--ink2); font-size: 13px; line-height: 18px;
  cursor: pointer; font-family: inherit;
}
.ref-x:hover { background: #d8dfd8; }
.ref-x[hidden] { display: none; }
.ref-res {
  position: absolute; z-index: 60; left: 0; right: 0; top: calc(100% + 5px);
  max-height: 168px; overflow: auto; padding: 6px;
  background: #fff; border: 1px solid var(--line); border-radius: 10px;
  box-shadow: 0 12px 28px rgba(0,0,0,.13);
}
.ref-res[hidden] { display: none; }
.ref-res .match { margin-bottom: 4px; }
.ref-res .match:last-child { margin-bottom: 0; }
.lab-hint { font-weight: 400; color: var(--ink3); font-size: 11px; margin-left: 5px; }

/* 抽屉里的「他介绍进来的人」 */
.ref-block { margin: 0 0 16px; padding: 10px 12px; background: var(--green-soft); border-radius: 9px; }
.ref-block-t { font-size: 11.5px; color: var(--ink2); margin-bottom: 8px; }
.ref-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.ref-chip {
  display: inline-flex; align-items: baseline; gap: 5px; padding: 4px 9px;
  border: 1px solid #cfe3d7; border-radius: 20px; background: #fff;
  font-size: 12px; font-family: inherit; color: var(--ink); cursor: pointer;
}
.ref-chip:hover { border-color: var(--green2); }
.ref-chip em { font-style: normal; font-size: 10.5px; color: var(--ink3); }

/* 列表里的备注列：点一下就地编辑 */
.note-cell { width: 186px; max-width: 186px; cursor: text; overflow: hidden; }
.note-txt, .note-empty { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; }
.note-txt { color: var(--ink2); }
.note-cell:hover .note-txt { color: var(--ink); }
.note-empty { color: #b9c1b9; font-size: 11.5px; }
.note-cell:hover .note-empty { color: var(--green); }
.note-in {
  width: 100%; height: 26px; padding: 0 8px; font-size: 12px; font-family: inherit;
  border: 1px solid var(--green2); border-radius: 6px; outline: none; background: #fff; color: var(--ink);
}

/* ---------------- 重复客户 / 合并 ---------------- */
.dup-group { border: 1px solid var(--line); border-radius: 10px; margin-bottom: 9px; overflow: hidden; }
.dup-head {
  display: flex; align-items: center; gap: 9px; padding: 8px 12px;
  background: #fafbfa; border-bottom: 1px solid #f0f2ef; font-size: 12px;
}
.dup-head .spacer { flex: 1; }
.dup-head .hint { color: var(--ink3); font-weight: 400; }
.dup-tag {
  font-size: 10.5px; padding: 2px 7px; border-radius: 5px; font-weight: 500; white-space: nowrap;
}
.dup-tag.high { background: var(--red-soft); color: var(--red); }
.dup-tag.mid { background: #fdf3e0; color: var(--gold); }
.dup-tag.low { background: #eef2ef; color: var(--ink2); }
.dup-items { display: flex; flex-wrap: wrap; gap: 0; }
.dup-item { flex: 1; min-width: 220px; padding: 9px 12px; border-right: 1px solid #f5f7f4; }
.dup-item:last-child { border-right: 0; }
.dup-item b { font-size: 13px; }
.dup-item .mi { font-size: 11.5px; color: var(--ink3); margin-top: 3px; }

.cmp { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-bottom: 12px; }
.cmp-col { min-width: 0; }
.cmp-role { font-size: 11.5px; color: var(--ink3); margin-bottom: 6px; }
.cmp-card { border: 1px solid var(--line); border-radius: 10px; padding: 11px 13px; background: #fff; }
.cmp-col:first-child .cmp-card { border-color: #cfe3d7; background: var(--green-soft); }
.cmp-name { font-size: 14px; font-weight: 600; display: flex; align-items: center; gap: 6px; margin-bottom: 9px; }
.cmp-name .num { font-size: 11.5px; font-weight: 400; }
.cmp-swap {
  margin-left: auto; border: 0; background: #fff; border-radius: 6px; padding: 2px 8px;
  font-size: 11px; color: var(--ink2); cursor: pointer; font-family: inherit;
}
.cmp-swap:hover { color: var(--green); }
.cmp-grid { display: grid; grid-template-columns: 74px 1fr; row-gap: 5px; font-size: 12.5px; }
.cmp-grid span { color: var(--ink3); font-size: 11.5px; }
.cmp-grid b { font-weight: 600; font-variant-numeric: tabular-nums; }
.cmp-empty {
  width: 100%; height: 128px; border: 1px dashed #cfd8d2; border-radius: 10px; background: #fbfcfb;
  color: var(--ink3); font-family: inherit; font-size: 12.5px; cursor: pointer;
}
.cmp-empty:hover { border-color: var(--green2); color: var(--green); }
.cmp-result { border-top: 1px dashed var(--line); padding-top: 11px; margin-bottom: 10px; }
.cmp-after { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 12.5px; margin-top: 6px; }
.cmp-after span { color: var(--ink3); font-size: 11.5px; }
.cmp-after b { color: var(--ink); font-weight: 600; margin-left: 4px; font-variant-numeric: tabular-nums; }
.cmp-tip {
  font-size: 11.5px; color: var(--ink3); line-height: 1.8;
  background: #fafbfa; border: 1px solid #f0f2ef; border-radius: 8px; padding: 9px 12px;
}
#cmpSearchWrap { margin-bottom: 11px; }
#cmpSearchWrap [hidden] { display: none !important; }

/* ---------------- 数据看板 ---------------- */
.dash-head {
  display: flex; align-items: center; gap: 10px; margin-bottom: 12px;
}
.dash-head .spacer { flex: 1; }
.dash-head .hint { font-size: 11.5px; color: var(--ink3); }
.period-label {
  font-size: 12.5px; color: var(--ink2); font-weight: 500;
  font-variant-numeric: tabular-nums;
}
/* 本期发生：和上面的存量 KPI 区分开，用浅绿底 */
.period-strip {
  display: flex; align-items: stretch; flex-wrap: wrap;
  background: var(--green-soft); border: 1px solid #cfe3d7; border-radius: var(--r);
  margin-bottom: 13px; overflow: hidden;
}
.period-strip .pi { padding: 9px 16px; border-right: 1px solid rgba(30,90,60,.10); }
.period-strip .pi:last-child { border-right: 0; }
.period-strip .pi .k { font-size: 11px; color: #4a6b57; }
.period-strip .pi .v {
  font-size: 15px; font-weight: 600; color: var(--green);
  font-variant-numeric: tabular-nums; line-height: 1.3;
}
.period-strip .pi .v small { font-size: 10.5px; font-weight: 400; color: #4a6b57; margin-left: 2px; }
.period-strip .pi .v.zero { color: #93a89b; }
.rev-wrap { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 13px; }
.rev-card { border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; background: #fff; }
.rev-card h3 { margin: 0 0 4px; font-size: 13px; font-weight: 650; }
.rev-card .sub { font-size: 11.5px; color: var(--ink3); margin-bottom: 8px; }
.rev-nums { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.rev-nums .k { font-size: 11.5px; color: var(--ink3); }
.rev-nums .v { font-size: 18px; font-weight: 650; letter-spacing: -.3px; margin-top: 3px; }
.batch-line { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; padding: 6px 0; border-top: 1px solid var(--line); font-size: 12.5px; }
.batch-line input { width: 88px; height: 28px; }
.dash-kpi { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 11px; margin-bottom: 13px; }
.kpi {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--r);
  padding: 12px 14px; min-width: 0;
}
.kpi .k { font-size: 11.5px; color: var(--ink3); margin-bottom: 7px; letter-spacing: .2px; white-space: nowrap; }
.kpi .v { font-size: 20px; font-weight: 600; letter-spacing: -.4px; line-height: 1.15; }
.kpi .v small { font-size: 11px; font-weight: 400; color: var(--ink3); margin-left: 3px; letter-spacing: 0; }
.kpi .s { font-size: 11px; color: var(--ink3); margin-top: 5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi.accent { background: var(--green-soft); border-color: #cfe3d7; }
.kpi.accent .v { color: var(--green); }
.kpi.warn .v { color: var(--gold); }
/* 可点的卡片（本期新增客户）：悬停给一点反馈，不然没人知道能点 */
.kpi.jump { cursor: pointer; transition: .12s; }
.kpi.jump:hover { border-color: var(--green2); box-shadow: 0 2px 8px rgba(0,0,0,.05); }

/* 风险条 */
.risk-strip {
  display: flex; align-items: center; gap: 0; flex-wrap: wrap;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--r);
  margin-bottom: 13px; overflow: hidden;
}
.risk-item { padding: 10px 16px; display: flex; align-items: baseline; gap: 7px; border-right: 1px solid #f0f2ef; }
.risk-item:last-child { border-right: 0; }
.risk-item .k { font-size: 11.5px; color: var(--ink3); }
.risk-item .v { font-size: 14px; font-weight: 600; font-variant-numeric: tabular-nums; }
.risk-item .v.r { color: var(--red); }
.risk-item .v.g { color: var(--gold); }
.risk-item .u { font-size: 11px; color: var(--ink3); font-weight: 400; }

/* grid 轨道用 minmax(0,1fr)：1fr 的最小值是 min-content，
   宽表格会把轨道撑破、右侧被裁掉 */
.dash-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 13px; margin-bottom: 13px; }
.dash-grid > .card { min-width: 0; }

/* 分层条形 */
.tier-box { padding: 13px 15px 15px; }
.tier-row { display: grid; grid-template-columns: 100px 1fr 112px; align-items: center; gap: 10px; padding: 5px 0; }
.tier-row .lab { font-size: 12px; color: var(--ink2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tier-row .track { height: 16px; background: #f2f4f1; border-radius: 4px; overflow: hidden; }
.tier-row .fill { height: 100%; background: var(--green2); border-radius: 4px; min-width: 2px; }
.tier-row .fill.mute { background: #c3ccc6; }
.tier-row .fill.gold { background: var(--gold); }
.tier-row .val { font-size: 12px; color: var(--ink); text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tier-row .val em { font-style: normal; color: var(--ink3); font-size: 11px; }

/* 看板里的小表 */
.mini-table { width: 100%; min-width: 0; border-collapse: collapse; table-layout: fixed; }
.mini-table th {
  text-align: left; font-size: 11px; font-weight: 500; color: var(--ink3);
  padding: 7px 14px; background: #fafbfa; border-bottom: 1px solid var(--line); white-space: nowrap;
}
.mini-table td {
  padding: 8px 14px; border-bottom: 1px solid #f3f5f2; font-size: 12.5px; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis;
}
.mini-table tbody tr { cursor: pointer; }
.mini-table tbody tr:hover { background: #f8faf8; }
.mini-table tbody tr:last-child td { border-bottom: 0; }
.mini-table .nm { font-weight: 600; }
.mini-table .muted2 { color: var(--ink3); font-size: 11.5px; }
.mini-table td.r, .mini-table th.r { text-align: right; font-variant-numeric: tabular-nums; }

/* 教练上课：四个周期并列，窄屏横向滚动 */
.sess-scroll { overflow-x: auto; }
.sess-table { min-width: 720px; }
.sess-table tbody tr, .sess-table tfoot tr { cursor: default; }
.sess-table tbody tr:hover { background: transparent; }
.sess-table th.grp { text-align: center; border-left: 1px solid var(--line); line-height: 1.35; }
.sess-table th.grp .sub { display: block; font-weight: 400; color: var(--ink3); font-size: 10px; }
.sess-table td.num, .sess-table th.num { text-align: right; font-variant-numeric: tabular-nums; }
.sess-table td.num { border-left: 1px solid #f3f5f2; }
.sess-table td.num.z { color: var(--ink3); }
.sess-table tfoot td { font-weight: 600; background: #fafbfa; border-bottom: 0; }
.sess-note { padding: 0 15px 12px; }

/* 导入客户 */
.imp-tools { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 12px; }
.imp-file {
  position: relative; overflow: hidden; display: inline-flex; align-items: center;
  height: 28px; padding: 0 10px; border: 1px solid var(--line); border-radius: 7px;
  background: #fff; font-size: 12.5px; color: var(--ink2); cursor: pointer;
}
.imp-file:hover { border-color: var(--green2); color: var(--ink); }
.imp-file input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
#importModal textarea {
  width: 100%; height: 72px; margin-top: 6px; padding: 8px 10px;
  border: 1px solid var(--line); border-radius: 8px; resize: vertical;
  font-family: inherit; font-size: 12.5px; line-height: 1.5; outline: none; background: #fff;
}
#importModal textarea:focus { border-color: var(--green2); }
#importModal .imp-table { margin-top: 12px; }
#importModal .imp-table tbody tr { cursor: default; }
#importModal .imp-table td.reason { white-space: normal; overflow: visible; text-overflow: clip; color: var(--ink2); }
#importModal .imp-sum { margin-top: 12px; font-size: 12.5px; color: var(--ink2); }
#importModal .imp-sum b { color: var(--ink); font-weight: 600; }

/* 排序选择 */
.sortsel {
  height: 27px; border: 1px solid var(--line); border-radius: 7px; background: #fff;
  font-family: inherit; font-size: 12px; color: var(--ink2); padding: 0 7px; cursor: pointer; outline: none;
}
.sortsel:hover { border-color: var(--green2); }

/* 设置面板 */
.set-sec { padding: 14px 0; border-bottom: 1px solid #f0f2ef; }
.set-sec:first-child { padding-top: 0; }
.set-sec:last-child { border-bottom: 0; padding-bottom: 0; }
.set-sec h4 { font-size: 12.5px; font-weight: 600; margin-bottom: 10px; display: flex; align-items: center; gap: 8px; }
.op-row { display: grid; grid-template-columns: 1fr 88px 82px 26px; gap: 7px; margin-bottom: 7px; align-items: center; }
.op-row input {
  height: 31px; padding: 0 9px; border: 1px solid var(--line); border-radius: 7px;
  font-size: 12.5px; font-family: inherit; outline: none; min-width: 0; width: 100%;
}
.op-row input:focus { border-color: var(--green2); }
.op-row .del {
  border: 0; background: transparent; color: var(--ink3); cursor: pointer; font-size: 15px;
  line-height: 1; padding: 0; border-radius: 5px; height: 31px;
  display: flex; align-items: center; justify-content: center;
}
.op-row .del:hover { color: var(--red); background: var(--red-soft); }

/* 教练行：姓名（下面挂累计核销）+ PIN + 在职/停用 + 删除 */
.coach-row { grid-template-columns: minmax(0, 1fr) 92px 54px 24px; }
.coach-cell { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.coach-cell .coach-name { width: 100%; }
.coach-row .coach-stat { font-size: 10.5px; color: var(--ink3); white-space: nowrap; }
.coach-row .coach-stat b { color: var(--ink2); font-weight: 600; }
.coach-row .coach-pin { font-size: 11.5px; letter-spacing: 1px; }
.coach-row .coach-pin::placeholder { letter-spacing: 0; font-size: 10.5px; }
.coach-toggle {
  height: 31px; border: 1px solid var(--line); border-radius: 7px; font-size: 12px;
  cursor: pointer; background: #fff; color: var(--ink2); font-family: inherit; padding: 0 8px;
}
.coach-toggle.on { background: var(--green-soft, #e8f4ee); border-color: #cfe3d7; color: var(--green2); }

/* ---------------- 预定管理 ---------------- */
.book-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 292px;
  gap: 14px;
  align-items: start;
}
.book-side { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.book-side-body { max-height: 420px; overflow: auto; }
.book-side-foot { padding: 0 14px 12px; }
#view-book.view { padding: 8px 12px 16px; }
#view-book .card { overflow: visible; }
#view-book .card-head { height: auto; min-height: 0; flex-wrap: wrap; padding: 4px 10px; gap: 6px; }
#view-book .filterbar {
  position: sticky; top: 0; z-index: 6; background: #fff;
  border-bottom: 1px solid var(--line);
}
#view-book .tbl-wrap { overflow: visible; }
#view-book thead th { top: 46px; background: #fafbfa; }
#bookCheckDate { font-weight: 700; color: var(--ink); }
#view-book table.bk-table { min-width: 1280px; }
#view-book td.op-cell { white-space: nowrap; }
#view-book .btn.danger { color: var(--red); }
#view-book .btn.danger:hover { background: var(--red-soft); border-color: #f0d0cc; }
.book-date-lab {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; color: var(--ink2); font-weight: 500;
}
.book-date {
  height: 28px; border: 1px solid var(--line); border-radius: 7px;
  padding: 0 8px; font-family: inherit; font-size: 12.5px; color: var(--ink); background: #fff;
}
.ben-tags { display: inline-flex; flex-wrap: wrap; gap: 4px; align-items: center; vertical-align: middle; }
.ben-col, td.ben-cell { min-width: 220px; }
#view-customers table { min-width: 1680px; }
.bk-note {
  display: inline-block; max-width: 180px; overflow: hidden; text-overflow: ellipsis;
  white-space: nowrap; vertical-align: bottom; font-size: 12px;
}
.bk-sub { font-size: 11px; color: var(--ink3); margin-top: 2px; }
.ab-legend { display: flex; align-items: center; gap: 4px; font-size: 11px; color: var(--ink2); padding: 2px 10px 0; }
.ab-legend i { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
.ab-legend i.lesson { background: #f8f1e3; border: 1px solid #e4d2a6; margin-right: 2px; }
.ab-legend i.bay { background: #e7f2fb; border: 1px solid #c9dff3; margin: 0 2px 0 10px; }
.ab-legend i.course { background: #e5f6ee; border: 1px solid #b7e0c8; margin: 0 2px 0 10px; }
.ab-legend .hint { margin-left: 8px; }
.tv-link-once { display: flex; align-items: center; gap: 8px; padding: 6px 10px 0; }
.tv-link-once[hidden] { display: none !important; }
.tv-link-once input {
  flex: 1; min-width: 0; height: 28px; padding: 0 8px;
  border: 1px solid var(--line); border-radius: 7px; background: #fff; color: var(--ink);
  font: inherit; font-size: 12px;
}
/* 顶栏 58 + 页边 8。整段营业时间平分这块高度；矮于 24px 才在格子内部滚动。列表在下面。 */
#view-book .book-screen {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 68px);
  min-height: 320px;
  min-width: 0;
}
#view-book .book-screen .card-head,
#view-book .ab-legend { flex: 0 0 auto; }
.ab-board {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1 1 auto;
  min-height: 0;
  padding: 4px 8px 6px;
  overflow: hidden;
}
.ab-board .ab-cols,
.ab-board .brow {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr);
  gap: 4px;
  align-items: stretch;
  min-height: 0;
  min-width: 0;
}
.ab-board .ab-cols { flex: 0 0 auto; height: 22px; }
.ab-board .ab-gutter { display: block; }
.ab-board .ab-bay {
  min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  text-align: center; font-size: 11px; line-height: 22px; color: var(--ink3);
}
.ab-board .ab-bay.vip { color: #8a6a32; }
.ab-board .ab-rows {
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  grid-template-rows: repeat(var(--slots, 1), minmax(24px, 1fr));
  gap: 2px;
  overflow: auto;
}
.ab-board .bt {
  display: flex; align-items: center; justify-content: flex-end;
  font-size: 11px; font-variant-numeric: tabular-nums; color: var(--ink3); padding-right: 2px;
}
.ab-board .bcells {
  display: grid;
  grid-template-columns: repeat(var(--bays, 1), minmax(0, 1fr));
  gap: 3px;
  min-width: 0;
  min-height: 0;
}
.ab-board .bcell {
  min-width: 0; min-height: 0; height: 100%;
  display: flex; align-items: center; gap: 4px;
  border-radius: 4px; padding: 0 4px;
  text-align: left; font-size: 12px; line-height: 1.2;
  background: #f4f7f3; color: var(--green2); border: 1px solid #e6ece5; font-family: inherit;
  overflow: hidden;
}
.ab-board .bcell.span { grid-column: 1 / -1; justify-content: center; }
.ab-board .bcell .nm { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bf-mark {
  flex: none; font-style: normal; font-size: 10px; font-weight: 700; line-height: 1.2;
  padding: 0 4px; border-radius: 4px; background: #fff; color: #8a5a12; border: 1px solid #d7b56a;
}
#bookTable .bf-mark { margin-left: 6px; vertical-align: 1px; }
.ab-board .bcell .coach,
.ab-board .bcell .cnt { flex: 0 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ab-board .bcell .coach { font-size: 11px; font-weight: 700; }
.ab-board .bcell .cnt { font-size: 11px; font-weight: 700; }
.ab-board .bcell.used { cursor: pointer; }
.ab-board .bcell.lesson { background: #f8f1e3; color: #7a5a1e; border-color: #e4d2a6; }
.ab-board .bcell.bay { background: #e7f2fb; color: #1d4e89; border-color: #c9dff3; }
.ab-board .bcell.vip { box-shadow: inset 0 0 0 1px #e3d3ae; }
.ab-board .bcell.off { background: #fbf2f1; color: #b98a85; border-color: #f2dfdd; }
.ab-board .bcell.course-note {
  height: auto; min-height: 18px; margin-bottom: 2px;
  background: #e5f6ee; color: #146b45; border-color: #b7e0c8;
  font-size: 11px; font-weight: 700; justify-content: flex-start;
}
.ab-board .brow.has-note { min-height: 46px; }
.bay-row { flex-wrap: wrap; }
.bay-meta { display: flex; align-items: center; gap: 8px; flex: 1 0 100%; padding-left: 36px; }
.bay-meta .bay-rule { width: 118px; height: 30px; }
.bay-meta .max-lab { display: flex; align-items: center; gap: 4px; font-size: 12px; color: var(--ink2); }
.bay-meta .bay-max { width: 54px; height: 30px; }
#partyModal .party-box { width: 560px; }
.party-rule { font-size: 12.5px; color: var(--ink2); background: #f6f8f5; border-radius: 8px; padding: 8px 10px; margin-bottom: 10px; }
.party-row { display: flex; align-items: center; gap: 8px; padding: 8px 0; border-bottom: 1px solid #f0f3ef; }
.party-row .who { flex: 1; min-width: 0; }
.party-row .who b { font-size: 13.5px; }
.party-row .who em { font-style: normal; font-size: 11px; color: var(--ink3); margin-left: 6px; }
.party-row .sub { font-size: 11.5px; color: var(--ink3); margin-top: 2px; }
.party-add { margin-top: 12px; display: flex; flex-direction: column; gap: 8px; }
.party-add .rowline { display: flex; gap: 8px; }
.party-add input { flex: 1; height: 34px; }
.party-hits .match { cursor: pointer; }
.bk-line {
  display: flex; align-items: baseline; gap: 8px;
  padding: 8px 14px; border-bottom: 1px solid #f3f5f2; font-size: 12.5px;
}
.bk-line.on { background: var(--green-soft); }
.bk-line .dt { font-variant-numeric: tabular-nums; color: var(--ink2); flex: 0 0 52px; }
.bk-line .nm { font-weight: 600; }
.bk-line em { font-style: normal; color: var(--ink3); font-size: 11.5px; margin-left: auto; text-align: right; }
.bk-slot-hint { font-size: 11.5px; color: var(--ink3); margin: 2px 0 6px; }
#bookModal .modal-box { width: 640px; }
#bookModal .row { display: grid; gap: 10px; margin-top: 12px; }
#bookModal .row.c2 { grid-template-columns: 1fr 1fr; }
#bookModal .chip:disabled { opacity: .42; cursor: not-allowed; }
#bfModal .modal-box { width: 720px; }
.bf-list { max-height: min(52vh, 480px); overflow: auto; border: 1px solid var(--line); border-radius: 10px; background: #fff; }
.bf-day { position: sticky; top: 0; z-index: 1; padding: 6px 12px; background: #f6f8f5; color: var(--ink2); font-size: 12px; font-weight: 650; border-bottom: 1px solid var(--line); }
.bf-row { display: block; width: 100%; text-align: left; padding: 10px 12px; border: 0; border-bottom: 1px solid #f0f3ef; background: #fff; cursor: pointer; font-family: inherit; }
.bf-row:hover { background: #f7faf7; }
.bf-row .when { font-size: 13.5px; font-weight: 650; color: var(--ink); }
.bf-row .meta { font-size: 12px; color: var(--ink3); margin-top: 3px; }
#bfFormPane .bf-picked { padding: 10px 12px; border-radius: 10px; background: var(--green-soft); margin-bottom: 12px; }
#bfFormPane .bf-picked b { font-size: 14px; }
#bfFormPane .bf-picked span { display: block; font-size: 12px; color: var(--ink2); margin-top: 3px; }
#bfModal .row { display: grid; gap: 10px; margin-top: 12px; }
#bfModal .row.c2 { grid-template-columns: 1fr 1fr; }
#bfCustPick, #bfCustSel { margin-top: 8px; }
#bfCustSel .bk-picked {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border: 1px solid #cfe3d7; border-radius: 9px; background: var(--green-soft);
}
#bfCustSel .bk-picked .nm { font-weight: 600; font-size: 13px; }
#bfCustSel .bk-picked .mt { font-size: 11.5px; color: var(--ink2); margin-top: 2px; }
#bkCustPick, #bkCustSel { margin-top: 8px; }
#bkCustSel .bk-picked {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border: 1px solid #cfe3d7; border-radius: 9px; background: var(--green-soft);
}
#bkCustSel .bk-picked .nm { font-weight: 600; font-size: 13px; }
#bkCustSel .bk-picked .mt { font-size: 11.5px; color: var(--ink2); margin-top: 2px; }


@media (max-width: 1280px) {
  .dash-kpi { grid-template-columns: repeat(3, 1fr); }
  .rev-wrap { grid-template-columns: 1fr; }
}
@media (max-width: 1100px) {
  .stats { grid-template-columns: repeat(3, 1fr); }
  .board-grid { grid-template-columns: 1fr; }
  .book-layout { grid-template-columns: 1fr; }
  .ai-grid { grid-template-columns: 1fr; }
  .dash-grid { grid-template-columns: 1fr; }
}

/* ================= 自定义下拉（ui-select.js） ================= */
/* 原生 select 留在 DOM 里当数据源：透明覆盖、不吃鼠标，保证 .value 与 change 照旧可用 */
.usel { position: relative; width: 100%; }
.usel > select {
  position: absolute; left: 0; top: 0; width: 100%; height: 100%;
  opacity: 0; pointer-events: none; margin: 0;
}
.usel-btn {
  width: 100%; height: 34px; padding: 0 28px 0 10px;
  border: 1px solid #d9e0da; border-radius: 7px; background: #fff;
  font-family: inherit; font-size: 13px; color: var(--ink);
  display: flex; align-items: center; text-align: left;
  cursor: pointer; outline: none; position: relative; min-width: 0;
}
.usel-btn:hover { border-color: #c6d2c9; }
.usel-btn:focus-visible { border-color: var(--green2); box-shadow: 0 0 0 3px rgba(26,127,79,.1); }
.usel.is-open > .usel-btn { border-color: var(--green2); box-shadow: 0 0 0 3px rgba(26,127,79,.1); }
.usel.is-disabled > .usel-btn { background: #f4f6f4; color: var(--ink3); cursor: not-allowed; }
.usel-txt { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.usel-txt.is-ph { color: var(--ink3); }
.usel-caret {
  position: absolute; right: 10px; top: 50%; margin-top: -2px;
  width: 0; height: 0; border-left: 4px solid transparent; border-right: 4px solid transparent;
  border-top: 5px solid #8a9a90; transition: transform .15s;
}
.usel.is-open .usel-caret { transform: rotate(180deg); margin-top: -3px; }

/* 筛选条里的小号下拉 */
.usel-sm { width: auto; }
.usel-sm .usel-btn { height: 27px; font-size: 12px; padding: 0 24px 0 8px; border-radius: 7px; color: var(--ink2); }
.usel-sm .usel-caret { right: 9px; border-top-color: #9aa79f; }

/* 浮层：挂 body + fixed，避免被表格/弹窗的 overflow 裁掉 */
.usel-pop {
  position: fixed; z-index: 200; background: #fff;
  border: 1px solid #dfe6e0; border-radius: 10px;
  box-shadow: 0 14px 38px rgba(16,28,21,.18), 0 2px 6px rgba(16,28,21,.06);
  padding: 5px; overflow-y: auto; max-height: 320px;
  animation: uselIn .12s cubic-bezier(.32,.72,0,1);
}
/* 只动位置不动透明度：动画被节流/暂停时浮层依然可见，不会停在透明帧 */
@keyframes uselIn { from { transform: translateY(-4px); } to { transform: none; } }
.usel-pop.up { animation-name: uselUp; }
@keyframes uselUp { from { transform: translateY(4px); } to { transform: none; } }
.usel-opt {
  display: flex; align-items: center; gap: 5px;
  padding: 7px 9px; border-radius: 7px; font-size: 13px; color: var(--ink);
  cursor: pointer; line-height: 1.4;
}
.usel-opt.hl { background: #f1f6f2; }
.usel-opt.on { color: var(--green); font-weight: 600; }
.usel-opt.dis { color: var(--ink3); cursor: not-allowed; }
.usel-opt.ph { color: var(--ink3); }
.usel-tick { flex: 0 0 11px; font-size: 11px; color: var(--green); opacity: 0; }
.usel-opt.on .usel-tick { opacity: 1; }
.usel-otext { flex: 1; min-width: 0; }
.usel-grp { padding: 8px 9px 4px; font-size: 11px; color: var(--ink3); font-weight: 600; letter-spacing: .3px; }
.usel-grp:first-child { padding-top: 4px; }

/* ================= 权益变更（原「改余额」）表单 ================= */
.adj-t { font-size: 12px; font-weight: 600; color: var(--ink2); display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px; }
.adj-sep { height: 1px; background: var(--line); margin: 16px 0 14px; }
/* 只读输入（结束日期自动算出来的，不给手改） */
.field input[readonly] {
  background: #f2f5f2; color: var(--ink2); cursor: default;
  border-style: dashed;
}
.field input[readonly]:focus { box-shadow: none; border-color: #d9e0da; }

/* ---------------- 设置页：预约区块 ---------------- */
/* 设置弹窗里 .row 原本没有栅格（只有 .form / #opBody 里有），这里补上两列，
   否则 6 个输入框会一路竖着排下去 */
#setModal .row { display: grid; gap: 9px; margin-bottom: 0; }
#setModal .row.c2 { grid-template-columns: 1fr 1fr; }
#setModal .row .field { min-width: 0; margin-bottom: 0; }
#setModal .chip-row { display: flex; flex-wrap: wrap; gap: 6px; }
#setModal .chip-row .chip { height: 28px; padding: 0 10px; font-size: 12px; }
#setModal a { color: var(--green2); }

/* ---------------- 设置页：临时停业 ---------------- */
.stop-list { display: flex; flex-direction: column; gap: 6px; margin-top: 9px; }
.stop-row { display: flex; align-items: center; gap: 9px; background: #faf7f2; border: 1px solid #efe6d8; border-radius: 9px; padding: 7px 10px; font-size: 12.5px; color: var(--ink2); }
.stop-row b { color: var(--ink); font-size: 12.5px; }
.stop-row em { font-style: normal; color: var(--ink3); }
.stop-row .del { margin-left: auto; width: 22px; height: 22px; border-radius: 6px; color: var(--ink3); font-size: 14px; line-height: 1; }
.stop-row .del:hover { background: var(--red-soft, #fbeceb); color: #c0392b; }
a.btn { display: inline-flex; align-items: center; justify-content: center; text-decoration: none; }

#setModal .modal-box { width: min(680px, calc(100vw - 32px)); }
.bay-row { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.bay-row .no { width: 28px; flex: none; color: var(--ink3); font-size: 12px; font-variant-numeric: tabular-nums; }
.bay-row .bay-name { flex: 1; width: auto; }
.bay-row .vip-lab { flex: none; display: flex; align-items: center; gap: 4px; font-size: 12px; color: var(--ink2); }
#setModal .bay-vip { width: auto; height: auto; }
.bay-row .del { flex: none; color: var(--red); font-size: 12px; background: var(--red-soft); border-radius: 7px; padding: 4px 8px; }
.hr-block { background: #f7f8f6; border: 1px solid var(--line); border-radius: 9px; padding: 8px 10px; margin-bottom: 8px; }
.hr-h { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 13px; font-weight: 600; margin-bottom: 6px; }
.hr-row { display: flex; align-items: center; gap: 6px; margin-bottom: 6px; }
#setModal .hr-row select, #setModal .hr-row input { width: auto; }
#setModal .hr-row select { width: 84px; }
#setModal .hr-row input[type="time"] { width: 118px; }
.hr-row .del { margin-left: auto; width: 22px; height: 22px; border-radius: 6px; color: var(--ink3); }
.hr-row .del:hover { background: var(--red-soft); color: var(--red); }

/* ---------------- 权限管理 ---------------- */
.perm-wrap { padding: 4px 16px 12px; overflow-x: auto; }
.perm-table { width: 100%; min-width: 0; table-layout: fixed; border-collapse: collapse; font-size: 13px; }
.perm-table th { text-align: left; font-size: 12px; color: var(--ink3); font-weight: 600; padding: 8px 10px; border-bottom: 1px solid var(--line); }
.perm-table th.ck, .perm-table td.ck { text-align: center; width: 72px; }
.perm-table td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.perm-table .desc { color: var(--ink3); font-size: 12px; margin-top: 2px; line-height: 1.45; }
.perm-table input { width: 16px; height: 16px; accent-color: var(--green); }
.perm-na { color: var(--ink3); }
.staff-form { display: flex; flex-wrap: wrap; gap: 8px; padding: 12px 16px 4px; align-items: center; }
.staff-form input, .staff-form select { height: 34px; border: 1px solid var(--line); border-radius: 8px; padding: 0 10px; font: inherit; font-size: 13px; }
.staff-form input { width: 140px; }
.staff-table { width: 100%; min-width: 0; border-collapse: collapse; font-size: 13px; }
.staff-table th { text-align: left; font-size: 12px; color: var(--ink3); font-weight: 600; padding: 8px 12px; border-bottom: 1px solid var(--line); }
.staff-table td { padding: 8px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.staff-table select, .staff-table input { height: 32px; border: 1px solid var(--line); border-radius: 7px; padding: 0 8px; font: inherit; font-size: 13px; }
.staff-off { opacity: .55; }
#permNote { padding: 0 16px 14px; }
