/* ==========================================================================
   燕云十六声 · 账号号商台账系统 —— 侧边栏 + 卡片式后台界面
   全离线：只用系统本地字体，不引用任何外部资源。
   ========================================================================== */

:root {
  --bg:           #f4f6f9;
  --card:         #ffffff;
  --bg-soft:      #fafbfc;
  --bg-sunken:    #f2f4f7;

  --ink:          #1d2126;
  --ink-2:        #5a6470;
  --ink-3:        #98a1ac;

  --line:         #e9ecf1;
  --line-strong:  #dfe3e9;

  --brand:        #2f6fd0;
  --brand-soft:   #eef4fe;

  --pos:          #0a7d4b;
  --neg:          #c0392b;
  --warn:         #9a6b00;

  --r:      10px;
  --r-sm:   7px;
  --shadow-lg: 0 18px 50px rgba(20, 30, 48, .18);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei",
               "微软雅黑", "PingFang SC", "Hiragino Sans GB", "Noto Sans CJK SC",
               Roboto, Helvetica, Arial, sans-serif;
  font-size: 13px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { margin: 0; font-weight: 600; }

* { scrollbar-width: thin; scrollbar-color: #d5dae1 transparent; }
*::-webkit-scrollbar { width: 9px; height: 9px; }
*::-webkit-scrollbar-thumb { background: #d5dae1; border-radius: 6px; border: 2px solid transparent; background-clip: content-box; }
*::-webkit-scrollbar-thumb:hover { background: #b6bdc7; background-clip: content-box; }
*::-webkit-scrollbar-track { background: transparent; }

/* ============================ 布局 ============================ */
.app { display: flex; min-height: 100vh; }

.sidebar {
  width: 210px;
  flex: 0 0 210px;
  background: var(--card);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}
.content { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; }

/* ---------------------------- 侧栏品牌 ---------------------------- */
.side-brand { display: flex; align-items: center; gap: 10px; padding: 18px 18px 14px; }
.logo {
  width: 32px; height: 32px; flex: 0 0 32px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 8px;
  background: linear-gradient(135deg, #3b7dde, #2f6fd0);
  color: #fff;
  font-size: 15px;
  font-weight: 700;
}
.side-brand-text { display: flex; flex-direction: column; line-height: 1.3; min-width: 0; }
.side-brand-text b { font-size: 13px; }
.side-brand-text small { font-size: 11px; color: var(--ink-3); }

/* ---------------------------- 侧栏菜单 ---------------------------- */
.side-nav { display: flex; flex-direction: column; gap: 2px; padding: 6px 10px; flex: 1 1 auto; overflow-y: auto; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 12px;
  border: none;
  background: none;
  font-family: inherit;
  font-size: 13px;
  color: var(--ink-2);
  border-radius: var(--r-sm);
  cursor: pointer;
  text-align: left;
  white-space: nowrap;
  transition: background .12s ease, color .12s ease;
}
.nav-item svg {
  width: 16px; height: 16px; flex: 0 0 16px;
  fill: none; stroke: currentColor;
  stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round;
}
.nav-item:hover { background: var(--bg-sunken); color: var(--ink); }
.nav-item.active { background: var(--brand-soft); color: var(--brand); font-weight: 600; }

.side-foot { border-top: 1px solid var(--line); padding: 12px 16px 16px; }
.side-foot-title { font-size: 11px; color: var(--ink-3); margin-bottom: 3px; }
.data-state { font-size: 11.5px; color: var(--ink-2); line-height: 1.85; }
.data-state b { color: var(--ink); font-variant-numeric: tabular-nums; }

/* ---------------------------- 顶栏 ---------------------------- */
.topbar {
  height: 54px;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 24px;
  background: var(--card);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 30;
}
.crumb { font-size: 15px; font-weight: 600; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 14px; }
.topbar-note { font-size: 12px; color: var(--ink-3); }

/* ---------------------------- 撤销 ---------------------------- */
.undo-wrap { position: relative; display: inline-flex; align-items: center; gap: 2px; }
#btnUndo { max-width: 340px; }
#btnUndo .undo-label {
  display: inline-block;
  max-width: 240px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--ink-3);
  font-size: 12px;
  margin-left: 4px;
}
#btnUndo:not([disabled]) { color: var(--ink); }
.undo-caret { padding: 6px 7px; }
.undo-panel {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  z-index: 60;
  width: 380px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r);
  box-shadow: 0 12px 34px rgba(20, 30, 48, .14);
  overflow: hidden;
}
.undo-panel[hidden] { display: none; }
.undo-head {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  font-size: 12.5px; font-weight: 600;
}
.undo-head .muted { font-weight: 400; }
.undo-list { max-height: 300px; overflow: auto; }
.undo-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 14px;
  border-bottom: 1px solid var(--line);
  font-size: 12.5px;
  cursor: pointer;
}
.undo-item:last-child { border-bottom: none; }
.undo-item:hover { background: var(--bg-soft); }
.undo-item.cur { background: var(--brand-soft); }
.undo-time { color: var(--ink-3); font-variant-numeric: tabular-nums; white-space: nowrap; }
.undo-desc { flex: 1 1 auto; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.undo-item.cur .undo-desc { color: var(--brand); font-weight: 600; }
.undo-foot {
  padding: 9px 14px;
  border-top: 1px solid var(--line);
  font-size: 11.5px;
  color: var(--ink-3);
  background: var(--bg-soft);
}
.undo-empty { padding: 22px 14px; text-align: center; color: var(--ink-3); font-size: 12.5px; }

/* ---------------------------- 主区域 ---------------------------- */
main { padding: 18px 24px 64px; max-width: 1720px; width: 100%; }
.page { display: none; }
.page.active { display: block; }

/* ---------------------------- 工具条 ---------------------------- */
.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 16px;
  margin-bottom: 12px;
}
.section-title { font-size: 13px; font-weight: 600; }
.grow { flex: 1 1 auto; }

/* ---------------------- 搜索命中高亮 ---------------------- */
mark.hl {
  background: #fff2a8;
  color: inherit;
  padding: 0 1px;
  border-radius: 2px;
}
.hit-chip {
  display: inline-block;
  margin-left: 6px;
  font-size: 10.5px;
  line-height: 15px;
  padding: 0 6px;
  border-radius: 4px;
  background: #fff6e0;
  color: #8a5f00;
  border: 1px solid #f0dfb4;
  vertical-align: 1px;
}
.hit-note { font-size: 11px; color: var(--ink-3); margin-top: 3px; }

/* ---------------------- 账号状态分类区间 ---------------------- */
.status-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--card);
}
.status-bar-label { font-size: 11.5px; color: var(--ink-3); margin-right: 4px; white-space: nowrap; }
.status-tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border: 1px solid transparent;
  border-radius: 20px;
  background: none;
  font-family: inherit;
  font-size: 12.5px;
  color: var(--ink-2);
  cursor: pointer;
  white-space: nowrap;
  transition: background .12s ease, color .12s ease, border-color .12s ease;
}
.status-tab:hover { background: var(--bg-sunken); color: var(--ink); }
.status-tab.active { background: var(--brand-soft); border-color: #cfe0f8; color: var(--brand); font-weight: 600; }
.status-tab .n {
  font-size: 11px;
  line-height: 16px;
  padding: 0 7px;
  border-radius: 20px;
  background: var(--bg-sunken);
  color: var(--ink-3);
  font-variant-numeric: tabular-nums;
}
.status-tab.active .n { background: #fff; color: var(--brand); }
/* 「今日新增」：日期维度的开关，不是账号状态 —— 没有状态色点，用「虚线描边」提示
   它是可以和一个账号状态标签叠加使用的（两个标签会同时高亮）。 */
.status-tab-today { border-style: dashed; border-color: var(--line); }
.status-tab-today.active { border-style: solid; }
.status-tab-today .n { font-weight: 600; }
/* 「录入时间」列：只读 + 次要信息，字小一点、颜色淡一点，不抢账号名称的注意力 */
td.muted-cell { color: var(--ink-3); font-size: 12px; white-space: nowrap; }

/* ---------------------- 分红管理：分类条 + 口径说明 ---------------------- */
/* 分类条和订单页的「账号状态」区间是同一套观感（.status-bar / .status-tab 那组），
   但类名独立成 .dvd-*：订单页的回归套件按 #ordStatusBar .status-tab 取元素，
   两边用各自的类名互不干扰。 */
.dvd-cats {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--card);
}
.dvd-cat-label { font-size: 11.5px; color: var(--ink-3); margin-right: 4px; white-space: nowrap; }
.dvd-cat {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border: 1px solid transparent;
  border-radius: 20px;
  background: none;
  font-family: inherit;
  font-size: 12.5px;
  color: var(--ink-2);
  cursor: pointer;
  white-space: nowrap;
  transition: background .12s ease, color .12s ease, border-color .12s ease;
}
.dvd-cat:hover { background: var(--bg-sunken); color: var(--ink); }
.dvd-cat.active { background: var(--brand-soft); border-color: #cfe0f8; color: var(--brand); font-weight: 600; }
.dvd-cat .n {
  font-size: 11px;
  line-height: 16px;
  padding: 0 7px;
  border-radius: 20px;
  background: var(--bg-sunken);
  color: var(--ink-3);
  font-variant-numeric: tabular-nums;
}
.dvd-cat.active .n { background: #fff; color: var(--brand); }
/* 当前搜索下一条都没挂到这个人身上：数字压暗但不藏起来（用户要知道「现在没有他的记录」）*/
.dvd-cat.zero { color: var(--ink-3); }
.dvd-cat.zero .n { opacity: .6; }
.dvd-note {
  padding: 9px 16px 0;
  font-size: 11.5px;
  line-height: 1.7;
  color: var(--ink-3);
}
.dvd-note:empty { display: none; }
.dvd-pays { white-space: normal; }
.dvd-pay { margin-right: 6px; }
.dvd-pay b { font-variant-numeric: tabular-nums; }
/* 「本人打款」列：只在选中某个人时出现，加粗一点好和旁边「打款合计」（所有人）区分开 */
#page-dividends .dvd-mine { font-weight: 600; }

/* ---------------------- 拖拽排序 ---------------------- */
#ordTable thead th[data-col] { cursor: grab; }
#ordTable thead th[data-col]:active { cursor: grabbing; }
#ordTable thead th.dragging { opacity: .35; background: var(--brand-soft); }
.status-tab[draggable="true"] { cursor: grab; }
.status-tab[draggable="true"]:active { cursor: grabbing; }
.status-tab.dragging { opacity: .35; background: var(--bg-sunken); }

/* ---------------------- 列宽调整 ---------------------- */
.col-resizer {
  position: absolute;
  top: 0;
  right: -5px;
  width: 11px;
  height: 100%;
  cursor: col-resize;
  z-index: 6;
  user-select: none;
}
.col-resizer::after {
  content: '';
  position: absolute;
  left: 5px;
  top: 4px;
  bottom: 4px;
  width: 1px;
  background: transparent;
  transition: background .12s;
}
.col-resizer:hover::after, .col-resizer.active::after { background: var(--brand); }
.col-resizer.active { background: rgba(45, 110, 220, .10); }
body.col-resizing, body.col-resizing * { cursor: col-resize !important; user-select: none !important; }

/* 有自定义列宽时用固定表格布局，列宽才会被严格尊重 */
#ordTable table.fixed-cols { table-layout: fixed; }
#ordTable table.fixed-cols thead th,
#ordTable table.fixed-cols tbody td {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
#ordTable table.fixed-cols thead th.wrap,
#ordTable table.fixed-cols tbody td.wrap { white-space: normal; }

/* ---------------------- 编辑表头弹窗 ---------------------- */
.hdr-tip {
  font-size: 12px;
  color: var(--ink-3);
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  padding: 8px 10px;
  margin-bottom: 12px;
  line-height: 1.6;
}
.hdr-list { max-height: 320px; overflow: auto; border: 1px solid var(--line); border-radius: var(--r-sm); }
.hdr-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-bottom: 1px solid var(--line);
}
.hdr-row:last-child { border-bottom: none; }
.hdr-row:hover { background: var(--bg-soft); }
.hdr-on { flex: 0 0 auto; display: flex; align-items: center; cursor: pointer; }
.hdr-name {
  flex: 1 1 auto;
  min-width: 0;
  height: 30px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  font-size: 13px;
  font-family: inherit;
  background: var(--card);
}
.hdr-name:focus { outline: none; border-color: var(--brand); }
.hdr-type { flex: 0 0 62px; font-size: 11.5px; color: var(--ink-3); }
.hdr-w {
  flex: 0 0 68px;
  width: 68px;
  height: 30px;
  padding: 0 6px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  font-size: 12.5px;
  font-family: inherit;
  background: var(--card);
  color: var(--ink);
}
.hdr-w:focus { outline: none; border-color: var(--brand); }
.hdr-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 10px 6px;
  font-size: 11px;
  color: var(--ink-3);
}
.hdr-head span:nth-child(1) { flex: 0 0 16px; }
.hdr-head span:nth-child(2) { flex: 1 1 auto; }
.hdr-head span:nth-child(3) { flex: 0 0 62px; }
.hdr-head span:nth-child(4) { flex: 0 0 68px; }
.hdr-head span:nth-child(5) { flex: 0 0 auto; min-width: 66px; }
.hdr-ops { flex: 0 0 auto; display: flex; gap: 3px; }
.hdr-ops .btn { padding: 3px 8px; line-height: 1.1; }
.hdr-add { margin-top: 14px; padding-top: 12px; border-top: 1px dashed var(--line); }
.hdr-add-title { font-size: 12.5px; font-weight: 600; margin-bottom: 8px; }
.hdr-add-row { display: flex; gap: 8px; align-items: center; }
.hdr-add-row .hdr-name { flex: 1 1 40%; }
.hdr-opts {
  flex: 1 1 34%;
  min-width: 0;
  height: 30px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  font-size: 12.5px;
  font-family: inherit;
}
#hdrNewType {
  height: 30px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  font-size: 12.5px;
  font-family: inherit;
  background: var(--card);
  padding: 0 6px;
}

.field { display: flex; flex-direction: column; gap: 3px; }
.field.inline { flex-direction: row; align-items: center; gap: 7px; }
.field.inline.check { gap: 6px; cursor: pointer; }
.field.inline.check input { margin: 0; cursor: pointer; }
.field.inline.check > span { font-size: 12.5px; color: var(--ink-2); }
.field > span { font-size: 11.5px; color: var(--ink-3); white-space: nowrap; }

input[type="text"], input[type="search"], input[type="number"],
input[type="date"], input[type="file"], select, textarea {
  font-family: inherit;
  font-size: 12.5px;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-sm);
  padding: 6px 10px;
  outline: none;
  transition: border-color .12s ease, box-shadow .12s ease;
}
input:hover, select:hover, textarea:hover { border-color: #c9cfd8; }
input:focus, select:focus, textarea:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(47, 111, 208, .12);
}
input[type="search"].search, input.search { min-width: 240px; flex: 1 1 300px; }
textarea { resize: vertical; width: 100%; }
input[type="file"] { padding: 4px 6px; }
select { cursor: pointer; }

/* ---------------------------- 按钮 ---------------------------- */
.btn {
  font-family: inherit;
  font-size: 12.5px;
  line-height: 1.5;
  border: 1px solid var(--line-strong);
  background: #fff;
  color: var(--ink-2);
  border-radius: var(--r-sm);
  padding: 6px 13px;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
  transition: background .12s ease, color .12s ease, border-color .12s ease;
}
.btn:hover { background: var(--bg-soft); color: var(--ink); border-color: #c9cfd8; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 500; }
.btn-primary:hover { background: #2861bb; border-color: #2861bb; color: #fff; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--ink-2); }
.btn-ghost:hover { background: var(--bg-sunken); border-color: transparent; color: var(--ink); }
.btn-danger { color: var(--neg); border-color: var(--line-strong); background: #fff; }
.btn-danger:hover { background: #fdf3f2; border-color: #e8bdb8; color: var(--neg); }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn[disabled] { opacity: .4; cursor: not-allowed; }

/* ============================ 卡片 ============================ */
.panel,
.page-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r);
  margin-bottom: 16px;
  overflow: hidden;
}
.panel-head {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 13px 16px;
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}
.panel-head.mt { border-top: 1px solid var(--line); }
.panel-head h2 { font-size: 13px; font-weight: 600; }
.panel-head .hint { font-size: 11.5px; color: var(--ink-3); }
.panel-body { padding: 14px 16px; }
.panel-body .row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.panel-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }
@media (max-width: 1120px) { .panel-grid { grid-template-columns: 1fr; } }

.note { margin: 0 0 10px; font-size: 12px; color: var(--ink-2); }
.note code, .panel-body code {
  background: var(--bg-sunken);
  border-radius: 4px;
  padding: 1px 5px;
  font-size: 11.5px;
  font-family: ui-monospace, Consolas, "Courier New", monospace;
}
.log {
  margin: 0;
  max-height: 220px;
  overflow: auto;
  background: var(--bg-sunken);
  border-radius: var(--r-sm);
  padding: 11px 13px;
  font-size: 12px;
  color: var(--ink-2);
  white-space: pre-wrap;
  word-break: break-all;
  font-family: ui-monospace, Consolas, "Courier New", monospace;
}

/* 订单 / 流水 / 分红 / 操作日志：筛选 + 表格合成一张卡片 */
#page-orders, #page-flows, #page-dividends, #page-logs {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r);
  overflow: hidden;
}
#page-orders .toolbar, #page-flows .toolbar, #page-dividends .toolbar, #page-logs .toolbar { padding: 14px 16px 0; margin-bottom: 0; }
#page-orders .toolbar + .toolbar { padding-top: 10px; }
#page-orders .table-meta, #page-flows .table-meta, #page-dividends .table-meta, #page-logs .table-meta { padding: 12px 16px 10px; }
#page-orders > .table-wrap, #page-flows > .table-wrap, #page-dividends > .table-wrap, #page-logs > .table-wrap { border: none; border-radius: 0; }
#page-orders .pager, #page-logs .pager { padding: 12px 16px 16px; }

/* 库存页：筛选条单独一张卡，账号卡片铺在灰底上 */
#page-inventory .toolbar {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 12px 16px;
}
#page-inventory .table-meta { padding: 0 2px 12px; }

/* ============================ 指标卡 ============================ */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(178px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}
.stat {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 14px 16px;
  min-width: 0;
}
.stat .k { font-size: 12px; color: var(--ink-3); }
.stat .v {
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -.01em;
  margin-top: 4px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.stat .s { font-size: 11px; color: var(--ink-3); margin-top: 2px; }
.stat.pos .v { color: var(--pos); }
.stat.neg .v { color: var(--neg); }
.stat.warn .v { color: var(--warn); }

/* ============================ 表格 ============================ */
.table-wrap { overflow: auto; max-height: 64vh; background: var(--card); }
table { border-collapse: separate; border-spacing: 0; width: 100%; font-size: 12.5px; }
thead th {
  position: sticky;
  top: 0;
  z-index: 5;
  background: var(--bg-soft);
  color: var(--ink-3);
  font-weight: 500;
  font-size: 11.5px;
  text-align: left;
  padding: 10px 12px;
  white-space: nowrap;
  box-shadow: inset 0 -1px 0 var(--line);
}
thead th.sortable { cursor: pointer; user-select: none; }
thead th.sortable:hover { color: var(--ink); }
tbody td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
  white-space: nowrap;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: #f8fafd; }
tbody tr.hist td { color: var(--ink-2); }

td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td.center, th.center { text-align: center; }
td.wrap { white-space: normal; min-width: 160px; max-width: 340px; word-break: break-word; }
.muted { color: var(--ink-3); }
.pos { color: var(--pos); }
.neg { color: var(--neg); }
.acts { white-space: nowrap; }
.acts .btn { padding: 3px 9px; font-size: 11.5px; }

#page-orders .table-wrap thead th:last-child,
#page-flows .table-wrap thead th:last-child,
#page-dividends .table-wrap thead th:last-child,
#page-orders .table-wrap tbody td:last-child,
#page-flows .table-wrap tbody td:last-child,
#page-dividends .table-wrap tbody td:last-child {
  position: sticky;
  right: 0;
  background: var(--card);
  box-shadow: inset 1px 0 0 var(--line);
}
#page-orders .table-wrap thead th:last-child,
#page-flows .table-wrap thead th:last-child,
#page-dividends .table-wrap thead th:last-child {
  z-index: 6;
  background: var(--bg-soft);
  box-shadow: inset 1px 0 0 var(--line), inset 0 -1px 0 var(--line);
}
#page-orders .table-wrap tbody tr:hover td:last-child,
#page-flows .table-wrap tbody tr:hover td:last-child,
#page-dividends .table-wrap tbody tr:hover td:last-child { background: #f8fafd; }

/* ---------------------- 单元格的就地编辑（Task 2 起默认关闭）----------------------
   INLINE_EDIT_ENABLED = false 时 orderRowHtml() 不再产生 .editable，
   所以下面两条「手型光标 + 悬停高亮」也就没有生效对象了 ——
   保留规则本身（想开回就地编辑时视觉一次到位），同时补一条只读提示：
   只读的数据格点上去就是普通文本，不给任何「可以改」的暗示。 */
#page-orders .table-wrap td.editable { cursor: pointer; }
#page-orders .table-wrap td.editable:hover {
  background: #f1f6ff;
  box-shadow: inset 0 0 0 1px #d3e2fb;
}
#page-orders .table-wrap td.editing {
  background: #fff;
  box-shadow: inset 0 0 0 2px var(--brand);
  padding: 3px 6px;
}
#page-orders .table-wrap td.editing input,
#page-orders .table-wrap td.editing select {
  width: 100%;
  min-width: 86px;
  padding: 4px 7px;
  font-size: 12.5px;
}
#page-orders .table-wrap td.editing input[type="number"] { min-width: 92px; }

/* 状态圆点 */
.tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--ink-2);
  background: none;
  border: none;
  padding: 0;
  white-space: nowrap;
}
.tag::before {
  content: "";
  width: 6px; height: 6px; flex: 0 0 6px;
  border-radius: 50%;
  background: var(--dot, #ced2d8);
}
.tag.未标注 { --dot: #ced2d8; }
.tag.进行中 { --dot: #5ca85c; }
.tag.已上架 { --dot: #d9a521; }
.tag.已完结 { --dot: #d9534f; }
.tag.亏损   { --dot: #5b7fc7; }
.tag.封存   { --dot: #a8adb5; }
.tag.重点   { --dot: #d4689b; }
.tag.hist   { --dot: #c9a227; }
.tag.income  { --dot: #0a7d4b; }
.tag.expense { --dot: #c0392b; }

.swatch {
  display: inline-block;
  width: 10px; height: 10px;
  border-radius: 50%;
  border: 1px solid rgba(0, 0, 0, .12);
  vertical-align: -1px;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 18px;
  padding: 11px 16px;
  border-bottom: 1px solid var(--line);
  font-size: 12px;
  color: var(--ink-2);
}
.legend-title { font-weight: 600; color: var(--ink); }
.legend-item { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }

.loading, .empty { padding: 34px 16px; text-align: center; color: var(--ink-3); font-size: 12.5px; }

.table-meta {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  font-size: 12px;
  color: var(--ink-3);
}
.table-meta b { color: var(--ink); font-weight: 600; font-variant-numeric: tabular-nums; }
/* 订单表底：合计项 + 右边的「⚙ 自定义合计」按钮（口径仍是筛选全量，见 updateOrdersMeta）*/
.table-meta-text { flex: 1 1 auto; min-width: 0; }
.meta-gear { margin-left: auto; flex: 0 0 auto; font-size: 14px; }
/* 看板：指标卡矩阵下面一行放「⚙ 自定义指标」*/
.stat-gear-line { display: flex; justify-content: flex-end; margin: -6px 0 14px; }
.stat-gear { opacity: .75; font-size: 12px; padding: 3px 8px; }
.stat-gear:hover { opacity: 1; }

.pager {
  display: flex;
  align-items: center;
  gap: 3px;
  flex-wrap: wrap;
  padding: 14px 0 0;
  font-size: 12.5px;
  color: var(--ink-3);
}
.pager button {
  font-family: inherit;
  font-size: 12.5px;
  min-width: 30px;
  padding: 4px 9px;
  border: 1px solid transparent;
  background: none;
  color: var(--ink-2);
  border-radius: var(--r-sm);
  cursor: pointer;
  transition: background .12s ease, color .12s ease;
}
.pager button:hover { background: var(--bg-sunken); color: var(--ink); }
.pager button.cur { background: var(--brand); color: #fff; font-weight: 600; }
.pager button[disabled] { opacity: .35; cursor: not-allowed; }

/* ============================ 库存卡片 ============================ */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(212px, 1fr));
  gap: 14px;
}
.inv-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: border-color .12s ease, box-shadow .12s ease;
}
.inv-card:hover { border-color: #cfd6e0; box-shadow: 0 4px 14px rgba(20, 30, 48, .07); }
.inv-card { cursor: pointer; }
.inv-cover {
  position: relative;
  aspect-ratio: 16 / 10;
  background: var(--bg-sunken);
  overflow: hidden;
}
.inv-cover img { width: 100%; height: 100%; object-fit: cover; display: block; cursor: zoom-in; }
.inv-cover-empty {
  width: 100%; height: 100%;
  display: flex; align-items: center; justify-content: center;
  color: #b7bec8; font-size: 11.5px;
  background: #f7f9fb;
}
.inv-count {
  position: absolute; right: 7px; bottom: 7px;
  background: rgba(20, 26, 34, .62);
  color: #fff;
  font-size: 10.5px;
  padding: 1px 7px;
  border-radius: 20px;
}
.inv-body { padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 5px; flex: 1 1 auto; }
.inv-title { font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.inv-title .muted { font-weight: 400; font-size: 11px; margin-left: 5px; }
.inv-meta {
  font-size: 11.5px; color: var(--ink-3);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.inv-foot { display: flex; align-items: center; gap: 8px; margin-top: auto; padding-top: 3px; }
.inv-profit { font-size: 12.5px; font-variant-numeric: tabular-nums; }
.inv-actions { display: flex; gap: 6px; padding: 0 12px 12px; }
.inv-actions .btn { flex: 1 1 0; justify-content: center; }

/* 库存卡片里的「可见列清单」：字段与顺序跟订单表同一份（orderedCols）。
   两栏自适应：格子最小 96px，卡片宽到一定程度自动并成两栏；
   金额列 / 长值列由 JS 标成 .full 独占一行，数字右对齐、绝不挤压。 */
.inv-fields {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(96px, 1fr));
  gap: 1px 8px;
  margin-top: 1px;
  padding-top: 6px;
  border-top: 1px dashed var(--line);
}
.inv-f { display: flex; align-items: baseline; gap: 5px; min-width: 0; line-height: 1.45; }
.inv-f.full { grid-column: 1 / -1; }
.inv-f-k {
  flex: 0 0 auto; color: var(--ink-3); font-size: 10px; white-space: nowrap;
  /* 用户改的列名可能很长：最多占这一格的 100% − 30px（给值留 ≥25px），超出用省略号 */
  max-width: calc(100% - 30px); overflow: hidden; text-overflow: ellipsis;
}
.inv-f-v {
  flex: 1 1 auto; min-width: 0;
  font-size: 11px; color: var(--ink-2);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.inv-f-v.num { text-align: right; font-variant-numeric: tabular-nums; }
.inv-f-v .tag { font-size: 11px; }
.inv-f-v .swatch { vertical-align: 0; }
/* 盼之编号那一格的值是链接：按链接样式显示（和卡片普通文字一眼区分），点了直达 pzds.com */
.inv-f-v a.inv-pz-link { color: var(--brand); text-decoration: underline; text-underline-offset: 2px; }
.inv-f-v a.inv-pz-link:hover { color: #1d4ed8; }

/* ---------- 宝钱库存：卡片上突出「宝钱数量」+ 合计提示带 ---------- */
.bao-badge {
  display: flex; align-items: baseline; gap: 6px;
  margin: 5px 0 1px; padding: 5px 8px;
  border-radius: var(--r-sm);
  background: #eef7ec;                 /* 绿（进行中）的浅色底，和 .tag.进行中 同一套语义 */
  border: 1px solid #d6e8d1;
  min-width: 0;
}
.bao-badge-k { flex: 0 0 auto; font-size: 10px; color: #4a7a45; white-space: nowrap; }
.bao-badge-v {
  flex: 1 1 auto; min-width: 0;
  font-size: 13px; font-weight: 600; color: #2f5f2b;
  font-variant-numeric: tabular-nums;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.bao-badge-warn {
  flex: 0 0 auto; font-size: 10px; color: #a8621c;
  border: 1px solid #edd3b0; background: #fdf4e8;
  border-radius: 999px; padding: 0 6px; white-space: nowrap;
}
.bao-note {
  margin: 0 0 10px; padding: 9px 12px;
  border: 1px solid #edd3b0; background: #fdf4e8; border-radius: var(--r-sm);
  font-size: 12px; color: #7a4a12; line-height: 1.6;
}
.bao-warn { color: #a8621c; }

/* ============================ 图片管理 ============================ */
.img-manager { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-start; }
.thumbs { display: flex; flex-wrap: wrap; gap: 10px; }
.thumb {
  position: relative;
  width: 92px; height: 68px;
  border-radius: var(--r-sm);
  overflow: hidden;
  border: 1px solid var(--line-strong);
  background: var(--bg-sunken);
}
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; cursor: zoom-in; }
.thumb-del {
  position: absolute; top: 3px; right: 3px;
  width: 19px; height: 19px; line-height: 1;
  border: none; border-radius: 50%;
  background: rgba(20, 26, 34, .66);
  color: #fff; font-size: 13px;
  cursor: pointer; padding: 0;
  display: flex; align-items: center; justify-content: center;
}
.thumb-del:hover { background: var(--neg); }
/* 新订单里还没上传的暂存图：虚线框 + 「待上传」角标，和已经上传的图一眼区分开 */
.thumb.staged { border-style: dashed; border-color: var(--brand); }
.staged-tag {
  position: absolute; left: 0; bottom: 0;
  padding: 0 5px;
  font-size: 10px; line-height: 15px;
  background: var(--brand); color: #fff;
  border-top-right-radius: var(--r-sm);
  pointer-events: none;
}
.upload-btn {
  width: 92px; height: 68px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--r-sm);
  background: var(--bg-soft);
  color: var(--ink-3);
  font-size: 11.5px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  cursor: pointer;
  transition: border-color .12s ease, color .12s ease, background .12s ease;
}
.upload-btn:hover { border-color: var(--brand); color: var(--brand); background: var(--brand-soft); }
.upload-btn.busy { pointer-events: none; opacity: .6; }
.upload-btn .up-sub { font-size: 9px; line-height: 1.15; opacity: .85; }
.upload-btn .plus { font-size: 17px; line-height: 1; }
.img-tip { font-size: 11px; color: var(--ink-3); margin-top: 8px; width: 100%; }
/* 「粘贴目标」那一块：剪贴板粘贴（Ctrl+V / ⌘V）会落到这里。
   只有蓝色的实线描边，不动布局（outline 不占位），所以区块高度 / 位置一个字都不变。 */
.img-manager.paste-target {
  outline: 2px solid var(--brand);
  outline-offset: 1px;
  border-radius: var(--r-sm);
}
.img-paste-tip { margin-top: 4px; }
.img-paste-tip::before { content: '\1F4CB  '; }
/* 图片分类区块组：四块依次堆叠，每块自带标题 / 计数 / 缩略图 / 添加瓷砖；
   空区块也只占一个瓷砖的高度，不会留出一大块空白。 */
.img-sections { display: flex; flex-direction: column; }
.img-sections .img-manager { min-height: 68px; }

/* ============================ 图片查看器 ============================ */
.viewer {
  position: fixed; inset: 0; z-index: 300;
  background: rgba(12, 16, 22, .82);
  display: flex; align-items: center; justify-content: center;
  padding: 40px;
}
.viewer[hidden] { display: none; }
.viewer img { max-width: 100%; max-height: 100%; border-radius: 8px; box-shadow: 0 20px 60px rgba(0,0,0,.5); }
.viewer-close {
  position: absolute; top: 18px; right: 22px;
  width: 34px; height: 34px;
  border: none; border-radius: 50%;
  background: rgba(255,255,255,.16); color: #fff;
  font-size: 20px; line-height: 1; cursor: pointer;
}
.viewer-close:hover { background: rgba(255,255,255,.3); }

/* ============================ 操作日志 ============================ */
.nowrap { white-space: nowrap; }
.who {
  display: inline-block;
  font-size: 11.5px;
  line-height: 17px;
  padding: 0 7px;
  border-radius: 4px;
  background: #eef6ee;
  color: #2f6b3a;
  white-space: nowrap;
}
.who.muted { background: var(--bg-sunken); color: var(--ink-3); }

.op {
  display: inline-block;
  font-size: 11px;
  line-height: 17px;
  padding: 0 7px;
  border-radius: 4px;
  background: var(--bg-sunken);
  color: var(--ink-2);
  white-space: nowrap;
}
.op-create { background: #e8f5ee; color: #0a7d4b; }
.op-update { background: #eaf1fd; color: #2f6fd0; }
.op-delete { background: #fdecea; color: #c0392b; }
.op-image_add, .op-image_del { background: #f3eefc; color: #6b46c1; }
.op-import { background: #fff5e5; color: #9a6b00; }

.chg {
  display: inline-block;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 1px 7px;
  margin: 2px 4px 2px 0;
  font-size: 12px;
  white-space: nowrap;
}
.chg b { font-weight: 600; color: var(--ink-2); margin-right: 4px; }
.chg s { color: var(--ink-3); text-decoration: line-through; }
.chg .arrow { color: var(--ink-3); margin: 0 4px; }
.chg i { font-style: normal; color: var(--brand); font-weight: 600; }

.rec-log {
  max-height: 300px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--bg-soft);
}
.rec-log-table { width: 100%; font-size: 12px; }
.rec-log-table td { padding: 7px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.rec-log-table tr:last-child td { border-bottom: none; }

/* ---------------------- 操作日志：点击回滚 ---------------------- */
/* 能回滚的行：可点击 + 悬停高亮；不能回滚的行：看起来是死的（无手型、无悬停） */
#page-logs .log-row.rb-ok { cursor: pointer; }
#page-logs .log-row.rb-ok:hover td { background: #eef4ff; }
#page-logs .log-row.rb-no { cursor: default; }
#page-logs .log-row.rb-no:hover td { background: transparent; }

.rb-badge {
  display: inline-block;
  font-size: 11px;
  line-height: 17px;
  padding: 0 7px;
  border-radius: 4px;
  background: #e8f5ee;
  color: #0a7d4b;
  font-weight: 500;
  white-space: nowrap;
}
.rb-badge.off { background: var(--bg-sunken); color: var(--ink-3); font-weight: 400; }

.rb-warn {
  background: #fdf3f2;
  border: 1px solid #f3d6d2;
  border-radius: var(--r-sm);
  padding: 10px 12px;
  margin-bottom: 12px;
  font-size: 13px;
  line-height: 1.8;
  color: #8f2d22;
}
.rb-warn b { color: #a8291f; }
.rb-fields {
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  overflow: hidden;
  margin-bottom: 12px;
}
.rb-row { display: flex; border-bottom: 1px solid var(--line); font-size: 12.5px; }
.rb-row:last-child { border-bottom: none; }
.rb-k { flex: 0 0 88px; padding: 8px 10px; background: var(--bg-soft); color: var(--ink-3); }
.rb-v { flex: 1 1 auto; padding: 8px 10px; min-width: 0; overflow-wrap: anywhere; }
.rb-note { font-size: 12.5px; line-height: 1.75; color: var(--ink-3); margin-bottom: 12px; }
.rb-ack {
  display: flex;
  align-items: flex-start;
  gap: 7px;
  font-size: 12.5px;
  line-height: 1.7;
  color: var(--ink-2);
  cursor: pointer;
  user-select: none;
}
.rb-ack input { margin: 3px 0 0; flex: 0 0 auto; }
.rb-actions { margin-top: 12px; display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------------------- CSV 导入结果 ---------------------- */
.io-result { font-size: 12.5px; line-height: 1.7; }
.csv-sum { margin-bottom: 8px; font-size: 13px; }
.csv-nums { display: flex; flex-wrap: wrap; gap: 6px 18px; margin-bottom: 10px; }
.csv-nums span { font-size: 12.5px; color: var(--ink-2); }
.csv-cols { font-size: 12px; color: var(--ink-3); line-height: 1.9; margin-bottom: 8px; word-break: break-all; }
.csv-err {
  background: #fdf3f2;
  border: 1px solid #f3d6d2;
  border-radius: var(--r-sm);
  padding: 9px 12px;
  margin-bottom: 10px;
  font-size: 12.5px;
}
.csv-err ul { margin: 6px 0 0; padding-left: 20px; }
.csv-err li { line-height: 1.75; }
.csv-changed { margin-bottom: 10px; }
.csv-changed .chg { background: #eaf1fd; border-color: #d5e2f7; }
.csv-warn {
  background: #fff8e6;
  border: 1px solid #f0dfb0;
  border-radius: var(--r-sm);
  padding: 10px 13px;
  margin-bottom: 10px;
  font-size: 12.5px;
  line-height: 1.85;
  color: #6b4e00;
}
.csv-warn b { color: #8a5f00; }
.csv-preview { width: 100%; font-size: 12.5px; }
.csv-preview th, .csv-preview td { padding: 6px 10px; border-bottom: 1px solid var(--line); text-align: left; }
.csv-preview th { background: var(--bg-soft); color: var(--ink-3); font-weight: 500; }

/* ---------------------- 计算公式编辑器 ---------------------- */
.fx-tip {
  font-size: 12px;
  color: var(--ink-3);
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  padding: 8px 11px;
  margin-bottom: 12px;
  line-height: 1.7;
}
.fx-cols { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.fx-col {
  position: relative;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink-2);
  border-radius: var(--r-sm);
  padding: 5px 12px;
  font-size: 12.5px;
  font-family: inherit;
  cursor: pointer;
}
.fx-col:hover { background: var(--bg-soft); }
.fx-col.active { background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 600; }
.fx-dot {
  position: absolute;
  top: -3px; right: -3px;
  width: 7px; height: 7px;
  border-radius: 50%;
  background: #f0a020;
  border: 1px solid #fff;
}
.fx-row { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.fx-eq {
  flex: 0 0 auto;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
  min-width: 62px;
  text-align: right;
}
.fx-input {
  flex: 1 1 auto;
  min-width: 0;
  height: 36px;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  font-family: Consolas, Menlo, monospace;
  font-size: 13.5px;
  background: var(--card);
  color: var(--ink);
}
.fx-input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(45,110,220,.10); }
.fx-default { font-size: 11.5px; color: var(--ink-3); margin: 0 0 12px 70px; }
.fx-default code { background: var(--bg-sunken); padding: 1px 5px; border-radius: 3px; font-size: 11.5px; }
.fx-modified { color: #b8860b; margin-left: 6px; }
.fx-pal {
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--bg-soft);
  padding: 9px 11px;
  margin-bottom: 14px;
}
.fx-pal-row { display: flex; align-items: center; flex-wrap: wrap; gap: 5px; padding: 3px 0; }
.fx-pal-label {
  flex: 0 0 62px;
  font-size: 11.5px;
  color: var(--ink-3);
}
.fx-k {
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink-2);
  border-radius: 5px;
  min-width: 30px;
  height: 27px;
  padding: 0 8px;
  font-size: 12.5px;
  font-family: inherit;
  cursor: pointer;
  line-height: 1;
}
.fx-k:hover { background: var(--brand-soft); border-color: var(--brand); color: var(--brand); }
.fx-k.fx-var { background: #eef6ee; border-color: #d6e8d6; color: #2f6b3a; }
.fx-k.fx-res { background: #eaf1fd; border-color: #d5e2f7; color: #2f6fd0; }
.fx-k.fx-fn { background: #f5f0fb; border-color: #e3d8f2; color: #6b46c1; font-family: Consolas, monospace; }
.fx-preview-head {
  font-size: 12.5px;
  font-weight: 600;
  margin-bottom: 8px;
}
.fx-preview-head b { color: var(--brand); }
.fx-preview-head span { font-weight: 400; }
.fx-preview { border: 1px solid var(--line); border-radius: var(--r-sm); overflow: auto; max-height: 220px; }
.fx-table { width: 100%; font-size: 12.5px; }
.fx-table th, .fx-table td {
  padding: 6px 10px;
  border-bottom: 1px solid var(--line);
  text-align: right;
  white-space: nowrap;
}
.fx-table th { background: var(--bg-soft); color: var(--ink-3); font-weight: 500; position: sticky; top: 0; }
.fx-table th:nth-child(1), .fx-table th:nth-child(2),
.fx-table td.fx-id, .fx-table tr td:nth-child(2) { text-align: left; }
.fx-table td.fx-chg { background: #fff8e6; font-weight: 600; color: #8a5f00; }
.fx-note { font-size: 11.5px; color: var(--ink-3); padding: 6px 10px; }
.fx-err {
  background: #fdf3f2;
  border: 1px solid #f3d6d2;
  border-radius: var(--r-sm);
  padding: 10px 12px;
  font-size: 12.5px;
  color: #a03028;
  line-height: 1.7;
}

/* ---------------------- 批量选择 ---------------------- */
#ordTable thead th.pick,
#ordTable tbody td.pick {
  width: 36px;
  min-width: 36px;
  max-width: 36px;
  padding: 0 0 0 12px;
  text-align: left;
}
#ordTable tbody td.pick input,
#ordTable thead th.pick input {
  width: 15px;
  height: 15px;
  cursor: pointer;
  accent-color: var(--brand);
  vertical-align: middle;
}
#ordTable tbody tr.picked td { background: #eef4fe; }
#ordTable tbody tr.picked:hover td { background: #e6eefc; }
.sel-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin: 0 16px 10px;
  padding: 9px 13px;
  background: var(--brand-soft);
  border: 1px solid #cddffa;
  border-radius: var(--r-sm);
  font-size: 12.5px;
}
.sel-bar[hidden] { display: none; }
.sel-bar b { color: var(--brand); }
.sel-bar .grow { flex: 1 1 auto; }

/* ---------------------- 批量修改弹窗 ---------------------- */
.bt-tip {
  font-size: 12px;
  color: var(--ink-3);
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  padding: 8px 11px;
  margin-bottom: 12px;
  line-height: 1.7;
}
.bt-grid { display: grid; grid-template-columns: 72px 1fr; gap: 8px 10px; align-items: center; margin-bottom: 12px; }
.bt-grid label { font-size: 12.5px; color: var(--ink-2); text-align: right; }
.bt-grid select, .bt-grid input {
  height: 34px;
  padding: 0 9px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  font-size: 13px;
  font-family: inherit;
  background: var(--card);
  color: var(--ink);
  width: 100%;
}
.bt-grid select:focus, .bt-grid input:focus { outline: none; border-color: var(--brand); }
.bt-two { display: flex; gap: 8px; }
.bt-preview { border: 1px solid var(--line); border-radius: var(--r-sm); overflow: auto; max-height: 210px; }
.bt-table { width: 100%; font-size: 12.5px; }
.bt-table th, .bt-table td { padding: 6px 10px; border-bottom: 1px solid var(--line); text-align: left; }
.bt-table th { background: var(--bg-soft); color: var(--ink-3); font-weight: 500; position: sticky; top: 0; }
.bt-table td.bt-new { color: var(--brand); font-weight: 600; }
.bt-head { font-size: 12.5px; font-weight: 600; margin: 4px 0 8px; }
.bt-head b { color: var(--brand); }
.bt-err {
  background: #fdf3f2;
  border: 1px solid #f3d6d2;
  border-radius: var(--r-sm);
  padding: 10px 12px;
  font-size: 12.5px;
  color: #a03028;
  line-height: 1.7;
}

/* ============================ 登录 / 初始化 ============================ */
.login-mask {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(160deg, #eef3fb 0%, #e3ebf7 100%);
}
.login-mask[hidden] { display: none; }
.login-box {
  width: 384px;
  max-width: calc(100vw - 32px);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 26px 26px 22px;
  box-shadow: 0 18px 50px rgba(20, 30, 48, .13);
}
.login-brand { display: flex; align-items: center; gap: 10px; margin-bottom: 20px; }
.login-brand b { display: block; font-size: 15px; }
.login-brand small { color: var(--ink-3); font-size: 11.5px; }
.login-field { margin-bottom: 12px; }
.login-field label { display: block; font-size: 12.5px; color: var(--ink-2); margin-bottom: 5px; }
.login-field input {
  width: 100%;
  height: 38px;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  font-size: 14px;
  font-family: inherit;
  background: var(--card);
  color: var(--ink);
}
.login-field input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(45, 110, 220, .10); }
.login-err { color: var(--neg); font-size: 12.5px; min-height: 18px; margin: 2px 0 10px; line-height: 1.5; }
.login-hint { font-size: 12px; color: var(--ink-3); line-height: 1.7; background: var(--bg-soft); border: 1px solid var(--line); border-radius: var(--r-sm); padding: 9px 11px; margin-bottom: 14px; }
.login-box .btn-block { width: 100%; height: 40px; }

/* ============================ 顶栏账号 ============================ */
.user-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: 4px;
  padding-left: 12px;
  border-left: 1px solid var(--line);
}
.user-chip[hidden] { display: none; }
.user-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--brand);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12.5px;
  font-weight: 600;
  flex: 0 0 auto;
}
.user-meta { display: flex; flex-direction: column; line-height: 1.3; }
.user-meta b { font-size: 12.5px; }
.user-meta small { font-size: 10.5px; color: var(--ink-3); }

/* ============================ 账号管理 ============================ */
.lan-addr {
  font-family: Consolas, Menlo, monospace;
  font-size: 13px;
  background: var(--bg-sunken);
  padding: 6px 11px;
  border-radius: var(--r-sm);
  color: var(--ink);
  word-break: break-all;
}
.u-badge { display: inline-block; font-size: 11px; line-height: 18px; padding: 0 8px; border-radius: 4px; margin-right: 4px; }
.u-admin { background: #eaf1fd; color: #2f6fd0; }
.u-member { background: var(--bg-sunken); color: var(--ink-2); }
.u-off { background: #fdecea; color: #c0392b; }
.perm-sec { font-size: 12.5px; font-weight: 600; margin: 16px 0 8px; }
.perm-sec:first-child { margin-top: 0; }
.perm-sec .muted { font-weight: 400; }
.perm-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 4px 14px; }
.perm-item { display: flex; align-items: flex-start; gap: 7px; font-size: 12.5px; padding: 5px 0; cursor: pointer; line-height: 1.5; }
.perm-item input { margin-top: 2px; accent-color: var(--brand); flex: 0 0 auto; }
.perm-item small { display: block; color: var(--ink-3); font-size: 11px; }
.perm-all { font-size: 12px; color: var(--ink-3); margin-bottom: 10px; }

.setup-banner {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  margin: 0 0 14px;
  padding: 11px 15px;
  background: #fff8e6;
  border: 1px solid #f0dfb0;
  border-radius: var(--r);
  font-size: 13px;
  color: #6b4e00;
}
.setup-banner[hidden] { display: none; }
.setup-banner b { color: #8a5f00; }

/* ============================ 弹窗 ============================ */
.modal-mask {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(16, 20, 26, .38);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 48px 16px;
  overflow: auto;
}
.modal-mask[hidden] { display: none; }
.modal {
  background: var(--card);
  border-radius: 12px;
  width: min(920px, 100%);
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 96px);
}
.modal-head {
  display: flex;
  align-items: center;
  padding: 15px 20px;
  border-bottom: 1px solid var(--line);
}
.modal-head h3 { font-size: 14px; font-weight: 600; }
.modal-close {
  margin-left: auto;
  border: none;
  background: none;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  color: var(--ink-3);
  border-radius: var(--r-sm);
  padding: 2px 7px;
  transition: color .12s ease, background .12s ease;
}
.modal-close:hover { color: var(--ink); background: var(--bg-sunken); }
.modal-body { padding: 20px; overflow: auto; }
.modal-foot {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 20px;
  border-top: 1px solid var(--line);
}
.modal-msg { font-size: 12px; color: var(--neg); }

.form-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px 18px; }
.form-grid .full { grid-column: 1 / -1; }
.form-grid .half { grid-column: span 3; }
@media (max-width: 820px) {
  .form-grid { grid-template-columns: 1fr 1fr; }
  .form-grid .half { grid-column: 1 / -1; }
}
.form-item { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.form-item > label { font-size: 11.5px; color: var(--ink-3); }
.form-item .tip { font-size: 11px; color: var(--ink-3); }
.form-item input, .form-item select, .form-item textarea { width: 100%; }
.form-sep {
  grid-column: 1 / -1;
  margin-top: 8px;
  padding-bottom: 7px;
  border-bottom: 1px solid var(--line);
  font-size: 12px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
}
.calc-box {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  gap: 8px 22px;
  background: var(--bg-sunken);
  border-radius: var(--r-sm);
  padding: 11px 14px;
  font-size: 12.5px;
  color: var(--ink-2);
}
.calc-box span b { color: var(--ink); font-variant-numeric: tabular-nums; }
/* ---------- 分红分配（编辑订单表单里的可增删区块） ---------- */
.form-block {
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--bg-soft);
  padding: 10px 12px 11px;
}
.form-block .block-head { font-size: 11.5px; color: var(--ink-3); margin-bottom: 8px; }
.form-block .block-head .muted { font-weight: 400; }
.split-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 108px 104px 30px;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}
.split-row .split-person select,
.split-row .split-person input,
.split-row .split-rate input { width: 100%; }
.split-row .split-rate { position: relative; }
.split-row .split-rate input { padding-right: 22px; }
.split-row .split-rate .pct {
  position: absolute; right: 7px; top: 50%; transform: translateY(-50%);
  font-size: 11.5px; color: var(--ink-3); pointer-events: none;
}
.split-row .split-amt { font-size: 12px; font-variant-numeric: tabular-nums; text-align: right; }
.split-row .split-del { text-align: center; }
.split-row .split-del .btn { padding: 2px 7px; line-height: 1.2; }
.split-hint { font-size: 11px; color: var(--warn); margin-top: 2px; }
.split-empty { font-size: 12px; padding: 4px 0 6px; }
.split-actions { margin-top: 2px; }
.split-foot {
  margin-top: 9px; padding-top: 8px; border-top: 1px dashed var(--line-strong);
  font-size: 12.5px; color: var(--ink-2);
}
.split-foot b { font-variant-numeric: tabular-nums; }
.split-foot.over, .split-foot.over b { color: var(--neg); }
.split-cell { font-variant-numeric: tabular-nums; }
.payout-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px 16px; }

/* ============================ 提示条 ============================ */
.toast-wrap {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 400;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.toast {
  background: #1c2128;
  color: #fff;
  border-radius: var(--r-sm);
  padding: 10px 15px;
  font-size: 12.5px;
  box-shadow: 0 10px 28px rgba(16, 24, 40, .24);
  max-width: 460px;
}
.toast.ok   { background: #0e6b45; }
.toast.err  { background: #a8291f; }
.toast.warn { background: #8a5a00; }

/* ============================ 窄屏 ============================ */
@media (max-width: 900px) {
  .app { flex-direction: column; }
  .sidebar { width: 100%; flex: none; height: auto; position: static; border-right: none; border-bottom: 1px solid var(--line); }
  .side-brand { padding: 14px 16px 10px; }
  .side-nav { flex-direction: row; overflow-x: auto; padding: 4px 10px 10px; }
  .nav-item { width: auto; }
  .side-foot { display: none; }
  .topbar { padding: 0 16px; }
  .topbar-note { display: none; }
  main { padding: 14px 16px 56px; }
}

/* ============================================================================
   紧凑一体化布局 —— 追加在最后，覆盖上面的宽松间距。
   目标：整页填满窗口、表格自己内部滚动，不再出现下半屏一大片空白。
   ============================================================================ */

/* ---- 1. 整页撑满，页面内部滚动，而不是页面被拉长 ---- */
.app { height: 100vh; min-height: 0; overflow: hidden; }
.content { height: 100vh; min-height: 0; overflow: hidden; }
main {
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  padding: 10px 14px 12px;
  max-width: none;
}
.page.active { display: flex; flex-direction: column; flex: 1 1 auto; min-height: 0; }

/* ---- 2. 顶栏 / 侧栏收紧 ---- */
.topbar { height: 46px; padding: 0 14px; gap: 12px; }
.side-brand { padding: 13px 14px 10px; }
.side-nav { padding: 4px 8px; gap: 1px; }
.nav-item { padding: 8px 10px; }
.side-foot { padding: 9px 14px 12px; }

/* ---- 3. 列表页：工具栏 + 表头 + 表格 + 分页合成一张卡，表格吃掉剩余高度 ---- */
#page-orders .table-wrap, #page-logs .table-wrap,
#page-flows .table-wrap, #page-dividends .table-wrap {
  max-height: none;
  flex: 1 1 auto;
  min-height: 140px;
}
#page-orders, #page-logs, #page-flows, #page-dividends { min-height: 0; }
#page-orders .toolbar, #page-logs .toolbar,
#page-flows .toolbar, #page-dividends .toolbar { padding: 10px 12px 0; }
#page-orders .toolbar, #page-logs .toolbar { gap: 7px 12px; }
#page-orders .table-meta, #page-logs .table-meta,
#page-flows .table-meta, #page-dividends .table-meta { padding: 9px 12px 7px; }
#page-orders .pager, #page-logs .pager { padding: 8px 12px 10px; }

/* ---- 4. 表格行紧凑 ---- */
thead th { padding: 7px 10px; }
tbody td { padding: 7px 10px; }

/* ---- 5. 面板 / 卡片间距收紧 ---- */
.panel-grid { gap: 10px; }
.panel-body { padding: 11px 13px; }
.panel-head { padding: 10px 13px; }
.sel-bar { margin: 0 12px 8px; padding: 7px 11px; }
.row { gap: 8px; }

/* ---- 6. 看板 / 库存 / 导入导出：卡片更密、不留大尾巴 ---- */
#page-dash, #page-inventory, #page-io, #page-users {
  overflow-y: auto;
  overflow-x: hidden;
  padding-right: 2px;
}
#page-dash .panel, #page-inventory .panel,
#page-io .panel, #page-users .panel { margin-bottom: 10px; }
#page-dash .panel:last-child, #page-inventory .panel:last-child,
#page-io .panel:last-child, #page-users .panel:last-child { margin-bottom: 0; }

/* 看板卡片矩阵也收紧一点 */
.stat-grid, .kpi-grid { gap: 10px; }

/* ---- 数据概况 齿轮按钮 ---- */
.side-foot-title { display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.side-foot-gear {
  border: none;
  background: transparent;
  color: var(--ink-3);
  font-size: 13px;
  line-height: 1;
  padding: 2px 5px;
  border-radius: 4px;
  cursor: pointer;
  opacity: .5;
}
.side-foot-gear:hover { opacity: 1; background: var(--bg-sunken); color: var(--brand); }

/* ---- 编辑表头：类型下拉 + 选项输入 ---- */
.hdr-type-sel {
  flex: 0 0 88px;
  height: 30px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  font-size: 12.5px;
  font-family: inherit;
  background: var(--card);
  color: var(--ink);
  padding: 0 4px;
}
.hdr-type-sel:focus { outline: none; border-color: var(--brand); }
.hdr-opts { flex: 1 1 160px; min-width: 100px; font-size: 12px; }
.hdr-head { display: flex; align-items: center; gap: 8px; padding: 0 10px 6px; font-size: 11px; color: var(--ink-3); }
.hdr-head span:nth-child(1) { flex: 0 0 16px; }
.hdr-head span:nth-child(2) { flex: 1 1 auto; }
.hdr-head span:nth-child(3) { flex: 0 0 88px; }
.hdr-head span:nth-child(4) { flex: 1 1 160px; min-width: 100px; }
.hdr-head span:nth-child(5) { flex: 0 0 68px; }
.hdr-head span:nth-child(6) { flex: 0 0 auto; min-width: 66px; }

/* ---- 订单号可点击（进编辑页） ---- */
.id-link { cursor: pointer; border-bottom: 1px dashed var(--line); }
.id-link:hover { color: var(--brand); border-bottom-color: var(--brand); }

/* ---- 弹窗标题上的字段设置按钮 ---- */
.modal-title-btn {
  margin-left: 12px;
  font-size: 12px;
  font-weight: 400;
  padding: 4px 10px;
  vertical-align: 2px;
}

/* ---- 计算公式：标签行里的齿轮 ---- */
.fx-col-cfg { color: var(--ink-3); padding: 6px 10px; opacity: .6; }
.fx-col-cfg:hover { opacity: 1; color: var(--brand); }

/* ---- 编辑表头：入公式开关 ---- */
.hdr-fx {
  flex: 0 0 74px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  font-size: 11.5px;
  color: var(--ink-2);
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
}
.hdr-fx input { margin: 0; }
.hdr-fx-ro { color: var(--ink-3); opacity: .75; cursor: help; font-size: 11px; }
.hdr-head span:nth-child(1) { flex: 0 0 16px; }
.hdr-head span:nth-child(2) { flex: 1 1 auto; }
.hdr-head span:nth-child(3) { flex: 0 0 88px; }
.hdr-head span:nth-child(4) { flex: 1 1 160px; min-width: 100px; }
.hdr-head span:nth-child(5) { flex: 0 0 74px; text-align: center; }
.hdr-head span:nth-child(6) { flex: 0 0 68px; }
.hdr-head span:nth-child(7) { flex: 0 0 auto; min-width: 66px; }

/* ==========================================================================
   用户自定义「计算列」：表头只读类型、订单表单只读显示、
   「计算公式显示哪些列」弹窗里的新增/编辑/删除
   ========================================================================== */

/* ---- 编辑表头：计算列的类型是只读的「计算」 ---- */
.hdr-type-ro {
  flex: 0 0 88px;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 30px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--r-sm);
  background: var(--bg-sunken);
  font-size: 12px;
  color: var(--ink-3);
}

/* ---- 编辑订单：计算列只显示不让填 ---- */
.form-static {
  display: flex;
  align-items: center;
  min-height: 34px;
  padding: 0 11px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--r-sm);
  background: var(--bg-sunken);
  color: var(--ink-2);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  cursor: default;
}

/* ---- 「计算公式显示哪些列」弹窗：自定义计算列区块 ---- */
.fxcc { margin-top: 14px; padding-top: 12px; border-top: 1px dashed var(--line); }
.fxcc-title { font-size: 12.5px; font-weight: 600; margin-bottom: 8px; }
.fxcc-title .muted { font-weight: 400; margin-left: 6px; font-size: 11.5px; }
.fxcc-empty {
  font-size: 12px;
  color: var(--ink-3);
  padding: 10px 12px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--r-sm);
  background: var(--bg-soft);
}
.fxcc-list { display: flex; flex-direction: column; gap: 6px; }
.fxcc-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--card);
}
.fxcc-row.editing { border-color: var(--brand); background: var(--brand-soft); }
.fxcc-name {
  flex: 0 0 auto;
  min-width: 74px;
  font-size: 12.5px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.fxcc-formula {
  flex: 1 1 auto;
  min-width: 0;
  font-family: Consolas, Menlo, monospace;
  font-size: 12px;
  color: var(--ink-2);
  background: var(--bg-sunken);
  border-radius: 4px;
  padding: 2px 7px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.fxcc-ref {
  flex: 0 0 auto;
  font-size: 11px;
  color: var(--warn);
  background: #fff8e6;
  border: 1px solid #f0e0b8;
  border-radius: 4px;
  padding: 1px 6px;
}
.fxcc-ops { flex: 0 0 auto; display: flex; gap: 5px; }
.fxcc-ops .btn { padding: 3px 9px; line-height: 1.2; }
.fxcc-in-name { flex: 0 0 150px; font-size: 12.5px; }
.fxcc-in-formula {
  flex: 1 1 auto;
  min-width: 0;
  font-family: Consolas, Menlo, monospace;
  font-size: 12.5px;
}
.fxcc-add { margin-top: 12px; padding-top: 10px; border-top: 1px dashed var(--line); }
.fxcc-add-title { font-size: 12.5px; font-weight: 600; margin-bottom: 8px; }
.fxcc-add-row { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }
.fxcc .fx-pal-row { padding: 2px 0; }
.fxcc .fx-pal-label { flex: 0 0 62px; }

/* ============================================================================
   修复：.page.active 变成 flex 列之后，卡片会被压缩、内容被裁掉
   （导入导出、看板、账号管理等页在窗口较矮时按钮/输入框整个消失）
   ============================================================================ */
.page.active > * { flex-shrink: 0; }                 /* 卡片不许被压扁 */
.page.active > .table-wrap { flex: 1 1 auto; min-height: 140px; }  /* 只有表格吃剩余高度 */
#page-io > .panel, #page-dash > .panel, #page-inventory > .panel,
#page-users > .panel, #page-logs > .panel { flex: 0 0 auto; }

/* ============================================================================
   「选项设置」弹窗（预设清单 / 默认公式 / 默认顺序基线）
   全部走 .opt-* 前缀；不改动上面任何已有规则，避免影响其它页面。
   ============================================================================ */
.opt-tip {
  font-size: 12.5px;
  line-height: 1.75;
  color: var(--ink-2);
  background: var(--bg-sunken);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  padding: 9px 11px;
  margin-bottom: 12px;
}
.opt-sec { margin-bottom: 14px; padding-bottom: 6px; border-bottom: 1px dashed var(--line); }
.opt-sec:last-child { border-bottom: none; margin-bottom: 0; }
.opt-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}
.opt-head > b { font-size: 13px; }
.opt-head > .muted { font-size: 11.5px; }
.opt-row { display: flex; gap: 6px; align-items: center; margin-bottom: 5px; }
.opt-inp {
  flex: 1 1 auto;
  min-width: 0;
  font-size: 12.5px;
  padding: 4px 7px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #fff;
  color: var(--ink-1);
}
.opt-inp:focus { outline: none; border-color: var(--brand); }
.opt-row .btn { flex: 0 0 auto; padding: 3px 8px; line-height: 1.2; }
.opt-empty {
  font-size: 12px;
  color: var(--ink-3);
  background: var(--bg-sunken);
  border: 1px dashed var(--line);
  border-radius: 4px;
  padding: 6px 9px;
  margin-bottom: 5px;
}
.opt-add { display: flex; gap: 8px; align-items: center; margin-top: 7px; flex-wrap: wrap; }
.opt-defrow { gap: 8px; }
.opt-deflabel { flex: 0 0 76px; font-size: 12.5px; font-weight: 600; }
.opt-def { font-family: Consolas, Menlo, monospace; }

/* ---- 自定义数字列的「算式输入」 ---- */
.calc-wrap { display: flex; align-items: center; gap: 8px; margin-top: 5px; }
.calc-input {
  flex: 1 1 auto;
  min-width: 0;
  height: 30px;
  padding: 0 9px;
  border: 1px dashed var(--line);
  border-radius: var(--r-sm);
  background: var(--bg-sunken);
  font-family: ui-monospace, Consolas, monospace;
  font-size: 12.5px;
  color: var(--ink);
}
.calc-input:focus { outline: none; border-style: solid; border-color: var(--brand); background: var(--card); }
.calc-out { flex: 0 0 auto; font-size: 12px; color: var(--brand); font-variant-numeric: tabular-nums; white-space: nowrap; }
.calc-out.bad { color: var(--danger, #c0392b); }

/* ---- 编辑订单里的「目前成本」实时显示 ---- */
.cost-live {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 4px 0 2px;
  padding: 10px 14px;
  background: #eef4ff;
  border: 1px solid #cfe0ff;
  border-radius: var(--r-sm);
  font-size: 13.5px;
  color: var(--ink-2);
}
.cost-live .cl-title { font-weight: 600; color: var(--ink); }
.cost-live .cl-eq { font-variant-numeric: tabular-nums; color: var(--ink-3); }
.cost-live .cl-val { font-size: 17px; color: var(--brand); font-variant-numeric: tabular-nums; margin-left: auto; }

/* ---- 修：目前成本框在 grid 里被压扁成一条线 ---- */
.cost-live {
  grid-column: 1 / -1 !important;
  display: flex !important;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 10px;
  min-height: 44px;
  height: auto !important;
  max-height: none !important;
  box-sizing: border-box;
  overflow: visible;
}
.cost-live .cl-val { margin-left: auto; }
/* 弹窗打开时别自动滚到中间 */
.modal-body { scroll-behavior: auto; }

/* 目前成本框固定在弹窗顶部，滚动也能看见 */
.cost-live {
  position: sticky;
  top: 0;
  z-index: 5;
  background: #eef4ff;
  box-shadow: 0 2px 6px rgba(0,0,0,.06);
}

/* ---- 按用户要求隐藏这两个工具栏按钮 ---- */
#ordFormula, #ordSortReset { display: none !important; }

/* ---- 隐藏所有「恢复默认」类按钮（用户要求） ---- */
#invReset { display: none !important; }

/* ---- 按用户要求：隐藏编辑表头里的「入公式」一列 ---- */
.hdr-fx { display: none !important; }
.hdr-head span:nth-child(5) { display: none !important; }

/* ============================================================================
   优化：列一多，「操作」列会被挤出屏幕，编辑/删除点不到。
   把最后一列（操作）固定在表格右侧，横向滚动时永远可见。
   ============================================================================ */
#ordTable th:last-child,
#ordTable td:last-child {
  position: sticky;
  right: 0;
  background: var(--card);
  z-index: 2;
  box-shadow: -6px 0 8px -6px rgba(0, 0, 0, .18);
}
#ordTable thead th:last-child { z-index: 3; }
#ordTable tbody tr:hover td:last-child { background: var(--bg-sunken); }

/* 操作列里的按钮给大一点，好点 */
#ordTable td:last-child .btn,
#ordTable td:last-child button {
  padding: 5px 9px;
  font-size: 12.5px;
  min-width: 44px;
}
/* 日志/编辑/删除 之间留点间距，别挤在一起 */
#ordTable td:last-child { white-space: nowrap; }
#ordTable td:last-child > * { margin-left: 4px; }
#ordTable td:last-child > *:first-child { margin-left: 0; }

/* ============================================================================
   编辑表头 → 右侧滑出面板（dense）
   ---------------------------------------------------------------------------
   这一段只服务「编辑表头」这一个弹窗，靠 #modalMask.ledger-panel 收窄作用域，
   所以别的弹窗（编辑订单 / 批量修改 / 计算公式 / 选项设置）仍然是原来居中的样子。
   间距刻度：行内边距 9px 12px / 分隔线 1px / 组标题 11px / 控件高 28px。
   ============================================================================ */
#modalMask.ledger-panel {
  align-items: stretch;
  justify-content: flex-end;
  padding: 0;
  overflow: hidden;
  animation: ledger-mask-in .18s ease both;
}
#modalMask.ledger-panel .modal {
  justify-content: flex-start;
  width: clamp(340px, 26vw, 420px);
  max-width: 100%;
  height: 100vh;
  max-height: 100vh;
  border-radius: 0;
  border-left: 1px solid var(--line);
  box-shadow: -18px 0 40px -12px rgba(16, 20, 26, .32);
  animation: ledger-panel-in .18s cubic-bezier(.22, .61, .36, 1) both;
}
@keyframes ledger-mask-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes ledger-panel-in { from { transform: translateX(100%); } to { transform: translateX(0); } }

/* ---- 头部：标题 + 灰色提示 + × ---- */
#modalMask.ledger-panel .modal-head { padding: 11px 14px; gap: 8px; }
#modalMask.ledger-panel .modal-head h3 { font-size: 14px; font-weight: 600; }
#modalMask.ledger-panel .modal-close { font-size: 18px; padding: 1px 6px; }

/* ---- 主体 / 页脚 ---- */
#modalMask.ledger-panel .modal-body { padding: 10px 14px 12px; flex: 1 1 auto; overflow: auto; }
#modalMask.ledger-panel .modal-foot { padding: 10px 14px; gap: 8px; }
#modalMask.ledger-panel .modal-foot .btn { min-width: 64px; padding: 7px 14px; font-size: 13px; }

/* ---- 淡色提示框 ---- */
#modalMask.ledger-panel .hdr-tip {
  margin-bottom: 10px;
  padding: 8px 10px;
  border-radius: 6px;
  background: #f5f8fd;
  border: 1px solid #e4ecf8;
  color: var(--ink-2);
  font-size: 12px;
  line-height: 1.5;
}
#modalMask.ledger-panel .hdr-tip-main { color: var(--ink-2); }
#modalMask.ledger-panel .hdr-tip-sub { margin-top: 5px; color: var(--ink-3); font-size: 11.5px; }
#modalMask.ledger-panel .hdr-tip-sub b { color: var(--ink-2); }

/* ---- 分组标题（「置顶（固定在左侧）」/「其他」）---- */
#modalMask.ledger-panel .hdr-group {
  margin: 10px 0 3px;
  padding: 0 4px;
  font-size: 11px;
  letter-spacing: .04em;
  color: var(--ink-3);
}
#modalMask.ledger-panel .hdr-list + .hdr-group { margin-top: 14px; }
/* 两段列表：外面 #hdrList 一个框，每段自己一个框 */
#modalMask.ledger-panel #hdrList > .hdr-group { margin: 10px 0 4px; }
#modalMask.ledger-panel #hdrList > .hdr-group:first-child { margin-top: 0; }
#modalMask.ledger-panel .hdr-list-box {
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--card);
  overflow: hidden;
}
#modalMask.ledger-panel .hdr-list-box:empty::after {
  content: '（没有列，把下面的行拖进来）';
  display: block;
  padding: 9px 12px;
  color: var(--ink-3);
  font-size: 11.5px;
}
#modalMask.ledger-panel .hdr-list-box[data-pinned="1"] { background: #fbfcfe; }
#modalMask.ledger-panel .hdr-list-box[data-pinned="1"] .hdr-row { background: #f8fafd; }
#modalMask.ledger-panel .hdr-list-box[data-pinned="1"] .hdr-row:hover { background: var(--bg-soft); }

/* ---- 列表容器：去掉大外框，只用细线 ---- */
#modalMask.ledger-panel .hdr-list {
  max-height: none;
  overflow: visible;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--card);
}
#modalMask.ledger-panel #hdrList { border: none; border-radius: 0; background: none; }
#modalMask.ledger-panel .hdr-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0;
  padding: 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
  transition: background .1s ease;
}
#modalMask.ledger-panel .hdr-row:last-child { border-bottom: none; }
#modalMask.ledger-panel .hdr-row:hover { background: var(--bg-soft); }
#modalMask.ledger-panel .hdr-row:has(input[data-hdr="show"]:checked) { background: #f8fafd; }
#modalMask.ledger-panel .hdr-row.dragging { opacity: .45; background: var(--brand-soft); }

/* ---- 第一行：☰ 手柄 / 勾选 / 列名 / 类型 / 列宽 / 图标按钮 ---- */
#modalMask.ledger-panel .hdr-line {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1 1 100%;
  width: 100%;
  min-width: 0;
  padding: 5px 12px;
}
#modalMask.ledger-panel .hdr-grip {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  margin-left: 6px;
  font-size: 12px;
  line-height: 1;
  color: #a9b1bd;
  cursor: grab;
  user-select: none;
  border-radius: 5px;
  padding: 0;
}
#modalMask.ledger-panel .hdr-grip:hover { color: var(--ink-2); background: var(--bg-sunken); }
#modalMask.ledger-panel .hdr-grip:active { cursor: grabbing; }
#modalMask.ledger-panel .hdr-on { flex: 0 0 auto; display: flex; align-items: center; }
#modalMask.ledger-panel .hdr-on input { width: 14px; height: 14px; margin: 0; cursor: pointer; }
#modalMask.ledger-panel .hdr-name {
  flex: 1 1 auto;
  min-width: 0;
  height: 26px;
  padding: 0 6px;
  border: 1px solid transparent;
  border-radius: 5px;
  background: transparent;
  font-size: 12.5px;
  color: var(--ink);
}
#modalMask.ledger-panel .hdr-name:hover { background: var(--bg-sunken); }
#modalMask.ledger-panel .hdr-name:focus {
  outline: none;
  border-color: var(--brand);
  background: var(--card);
}
#modalMask.ledger-panel .hdr-name[readonly] { color: var(--ink-2); cursor: default; }
#modalMask.ledger-panel .hdr-type-sel,
#modalMask.ledger-panel .hdr-type { flex: 0 0 70px; }
#modalMask.ledger-panel .hdr-type-sel {
  width: 70px;
  height: 26px;
  padding: 0 3px;
  border: 1px solid var(--line);
  border-radius: 5px;
  font-size: 11.5px;
  background: var(--card);
  color: var(--ink);
}
#modalMask.ledger-panel .hdr-type-ro {
  height: 28px;
  border-style: dashed;
  border-radius: 5px;
  font-size: 11.5px;
}
#modalMask.ledger-panel .hdr-w-wrap { flex: 0 0 44px; display: flex; align-items: center; }
#modalMask.ledger-panel .hdr-w {
  width: 44px;
  flex: 0 0 44px;
  height: 26px;
  padding: 0 3px;
  border: 1px solid transparent;
  border-radius: 5px;
  background: transparent;
  font-size: 12px;
  text-align: right;
  color: var(--ink-2);
}
#modalMask.ledger-panel .hdr-w:hover { background: var(--bg-sunken); }
#modalMask.ledger-panel .hdr-w:focus { outline: none; border-color: var(--brand); background: var(--card); }
#modalMask.ledger-panel .hdr-w::placeholder { color: #b6bdc8; font-size: 11px; }
#modalMask.ledger-panel .hdr-w::-webkit-outer-spin-button,
#modalMask.ledger-panel .hdr-w::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
#modalMask.ledger-panel .hdr-btns { flex: 0 0 auto; display: flex; align-items: center; gap: 12px; margin-left: 4px; }
#modalMask.ledger-panel .hdr-glyph {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  padding: 0;
  border: none;
  border-radius: 5px;
  background: none;
  color: #a9b1bd;
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
}
#modalMask.ledger-panel .hdr-glyph:hover { background: var(--bg-sunken); color: var(--ink); }
/* 置顶按钮：没置顶＝空心图钉（灰），置顶后＝实心图钉（蓝底），一眼能分清 */
#modalMask.ledger-panel .hdr-glyph-pin { font-size: 12px; }
#modalMask.ledger-panel .hdr-glyph-pin:hover { background: #eef4ff; color: var(--brand); }
#modalMask.ledger-panel .hdr-glyph-pin.on { background: #e8f0ff; box-shadow: inset 0 0 0 1px #cfe0ff; }
#modalMask.ledger-panel .hdr-glyph-del { font-size: 16px; }
#modalMask.ledger-panel .hdr-glyph-del:hover { background: #fdecec; color: var(--neg); }

/* ---- 第二行：下拉选项的「选项」，缩进对齐列名 ---- */
#modalMask.ledger-panel .hdr-sub {
  display: flex;
  align-items: center;
  flex: 1 1 100%;
  width: 100%;
  min-width: 0;
  margin: 0 12px 7px 38px;
  padding: 0 8px;
  height: 26px;
  border-radius: 6px;
  background: var(--bg-soft);
  border: 1px solid var(--line);
}
#modalMask.ledger-panel .hdr-opts {
  flex: 1 1 auto;
  min-width: 0;
  height: 24px;
  padding: 0;
  border: none;
  border-radius: 0;
  background: transparent;
  font-size: 12px;
  color: var(--ink);
}
#modalMask.ledger-panel .hdr-opts:hover,
#modalMask.ledger-panel .hdr-opts:focus { background: transparent; border: none; }
#modalMask.ledger-panel .hdr-opts::placeholder { color: var(--ink-3); }

/* ---- 工具栏：已删除列的说明 ---- */
#modalMask.ledger-panel .hdr-list + .fx-note { margin: 6px 2px 0; font-size: 11.5px; }

/* ---- 底部「新增一列」 ---- */
#modalMask.ledger-panel .hdr-add {
  margin-top: 10px;
  padding-top: 9px;
  border-top: 1px dashed var(--line);
}
#modalMask.ledger-panel .hdr-add-title {
  margin-bottom: 6px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .04em;
  color: var(--ink-3);
}
#modalMask.ledger-panel .hdr-add-row { display: flex; align-items: center; gap: 6px; }
#modalMask.ledger-panel .hdr-add-row .hdr-name {
  flex: 1 1 auto;
  min-width: 0;
  height: 28px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--card);
}
#modalMask.ledger-panel .hdr-add-row #hdrNewType {
  flex: 0 0 auto;
  width: 70px;
  height: 28px;
  padding: 0 2px;
  border: 1px solid var(--line);
  border-radius: 5px;
  font-size: 11.5px;
  font-family: inherit;
  background: var(--card);
  color: var(--ink);
}
#modalMask.ledger-panel .hdr-add-row .hdr-opts {
  flex: 1 1 auto;
  min-width: 0;
  height: 28px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--card);
}
#modalMask.ledger-panel .hdr-add-row .btn { flex: 0 0 auto; height: 28px; padding: 0 7px; font-size: 12px; }


/* ============================================================================
   强制把「操作」列钉在表格右侧（后面的样式把它覆盖了，这里用 !important 兜底）
   ============================================================================ */
#ordTable thead th:last-child,
#ordTable tbody td:last-child,
#page-orders .table-wrap th:last-child,
#page-orders .table-wrap td:last-child {
  position: sticky !important;
  right: 0 !important;
  z-index: 6 !important;
  background: var(--card) !important;
  box-shadow: -8px 0 10px -8px rgba(0, 0, 0, .25) !important;
  white-space: nowrap !important;
}
#ordTable thead th:last-child { z-index: 8 !important; }
#ordTable tbody tr:hover td:last-child { background: var(--bg-sunken) !important; }
/* 按钮别再被压扁 */
#ordTable td:last-child .btn,
#ordTable td:last-child button {
  padding: 5px 10px !important;
  font-size: 12.5px !important;
  min-width: 46px !important;
}

/* ============================================================================
   操作列：固定宽度 + 钉在右侧，日志/编辑/删除 三个按钮必须完整显示
   ============================================================================ */
#ordTable colgroup col[data-k="__acts"] { width: 196px !important; }
#ordTable thead th:last-child,
#ordTable tbody td:last-child,
#page-orders .table-wrap th:last-child,
#page-orders .table-wrap td:last-child {
  position: sticky !important;
  right: 0 !important;
  width: 196px !important;
  min-width: 196px !important;
  max-width: 196px !important;
  box-sizing: border-box !important;
  white-space: nowrap !important;
  z-index: 6 !important;
  background: var(--card) !important;
  box-shadow: -8px 0 10px -8px rgba(0, 0, 0, .25) !important;
  overflow: visible !important;
}
#ordTable thead th:last-child { z-index: 8 !important; }
#ordTable tbody tr:hover td:last-child { background: var(--bg-sunken) !important; }
#ordTable td:last-child .btn,
#ordTable td:last-child button {
  padding: 5px 10px !important;
  font-size: 12.5px !important;
  min-width: 46px !important;
  display: inline-block !important;
}
#ordTable td:last-child > * { margin-left: 5px !important; }
#ordTable td:last-child > *:first-child { margin-left: 0 !important; }

/* ============================================================================
   操作列：收窄成一条紧凑的「功能区」，只占它需要的宽度
   ============================================================================ */
#ordTable colgroup col[data-k="__acts"] { width: 132px !important; }
#ordTable thead th:last-child,
#ordTable tbody td:last-child,
#page-orders .table-wrap th:last-child,
#page-orders .table-wrap td:last-child {
  position: sticky !important;
  right: 0 !important;
  width: 132px !important;
  min-width: 132px !important;
  max-width: 132px !important;
  box-sizing: border-box !important;
  white-space: nowrap !important;
  z-index: 6 !important;
  background: var(--card) !important;
  /* 一条细线分隔，不要大阴影（那会显得「浮起来」） */
  box-shadow: -1px 0 0 var(--line) !important;
  overflow: visible !important;
  padding-left: 8px !important;
  padding-right: 4px !important;
}
#ordTable thead th:last-child { z-index: 8 !important; }
#ordTable tbody tr:hover td:last-child { background: var(--bg-sunken) !important; }
/* 按钮收小，别撑满 */
#ordTable td:last-child .btn,
#ordTable td:last-child button {
  padding: 3px 7px !important;
  font-size: 12px !important;
  min-width: 0 !important;
  display: inline-block !important;
  border-radius: 4px !important;
}
#ordTable td:last-child > * { margin-left: 3px !important; }
#ordTable td:last-child > *:first-child { margin-left: 0 !important; }
/* 纯文字的那种链接按钮（日志/编辑）不需要边框 */
#ordTable td:last-child .btn-ghost,
#ordTable td:last-child button.btn-ghost {
  border: none !important;
  background: transparent !important;
  padding: 3px 4px !important;
}

/* ---- 删除二次确认弹窗 ---- */
.del-confirm { display: flex; gap: 14px; align-items: flex-start; }
.del-icon {
  flex: 0 0 34px; height: 34px; border-radius: 50%;
  background: #fdecea; color: #c0392b;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 18px;
}
.del-main { flex: 1 1 auto; min-width: 0; }
.del-q { font-size: 15px; font-weight: 600; color: var(--ink); margin-bottom: 10px; }
.del-row { display: flex; gap: 10px; font-size: 13.5px; padding: 4px 0; }
.del-row span { flex: 0 0 68px; color: var(--ink-3); }
.del-row b { color: var(--ink); font-weight: 600; word-break: break-all; }
.del-tip { margin-top: 10px; font-size: 12.5px; color: var(--ink-3); line-height: 1.6; }

/* ---- 目前成本蓝框：多行（成本 / 利润 / 分红 / 净利） ---- */
.cost-live { display: block !important; padding: 8px 14px !important; }
.cost-live .cl-line { display: flex; align-items: center; gap: 10px; padding: 2px 0; }
.cost-live .cl-line + .cl-line { border-top: 1px dashed #d8e4fb; }
.cost-live .cl-title { flex: 0 0 66px; font-weight: 600; color: var(--ink); font-size: 13px; }
.cost-live .cl-eq { flex: 1 1 auto; font-variant-numeric: tabular-nums; color: var(--ink-3); font-size: 13px; }
.cost-live .cl-val { margin-left: auto; font-size: 16px; font-variant-numeric: tabular-nums; color: var(--brand); }
.cost-live .cl-val.neg { color: #c0392b; }
.cost-live .cl-val.pos { color: #1a7f37; }
.cost-live .cl-val.dim { color: var(--ink-3); font-size: 13px; font-weight: 400; }

/* ============================================================================
   订单管理 · 分页条（#ordPager）
   版式对齐参考图，一整行：
     共 817 条 | [20条/页 ▾] | ‹ 1 2 3 4 5 6 … 42 › | 前往 [1] 页
   高亮色用本 App 的 --brand（参考图是红色，这里换成品牌色以保持一致）。
   分页条是 .table-wrap 的兄弟节点、在表格下方，不会压到钉在右侧的「操作」列。
   ============================================================================ */
#ordPager.pager {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 10px;
  padding: 9px 12px 10px;
  border-top: 1px solid var(--line);
  font-size: 12.5px;
  color: var(--ink-3);
}
#ordPager[hidden] { display: none; }

/* 「共 N 条」，N = 当前筛选命中的总数（不是全库，也不是本页） */
#ordPager .pager-total { margin-right: 2px; white-space: nowrap; }
#ordPager .pager-total b {
  color: var(--ink);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

/* 每页条数下拉 */
#ordPager .pager-size {
  flex: 0 0 auto;
  height: 28px;
  padding: 0 6px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--card);
  color: var(--ink-2);
  font: inherit;
  font-size: 12.5px;
  cursor: pointer;
}
#ordPager .pager-size:hover { border-color: var(--brand); color: var(--ink); }
#ordPager .pager-size:focus-visible { outline: 2px solid var(--brand-soft); border-color: var(--brand); }

/* 页码区：‹ 1 2 3 … 42 › */
#ordPager .pager-pages {
  display: flex;
  align-items: center;
  gap: 2px;
  margin-left: auto;       /* 把这组推到右边，和「前往」一起靠右 */
}
#ordPager .pg-btn {
  font-family: inherit;
  font-size: 12.5px;
  line-height: 1;
  min-width: 30px;
  height: 28px;
  padding: 0 8px;
  border: 1px solid transparent;
  background: none;
  color: var(--ink-2);
  border-radius: var(--r-sm);
  cursor: pointer;
  font-variant-numeric: tabular-nums;
  transition: background .12s ease, color .12s ease, border-color .12s ease;
}
#ordPager .pg-btn:hover:not([disabled]) { background: var(--bg-sunken); color: var(--ink); }
#ordPager .pg-btn.cur {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
  font-weight: 600;
}
#ordPager .pg-btn.cur:hover { background: var(--brand); color: #fff; }
#ordPager .pg-btn[disabled] { opacity: .35; cursor: not-allowed; }
#ordPager .pg-arrow { font-size: 15px; padding: 0 6px; }
#ordPager .pager-ellipsis {
  min-width: 22px;
  text-align: center;
  color: var(--ink-3);
  user-select: none;
}

/* 前往 [__] 页 */
#ordPager .pager-jump {
  display: flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
}
#ordPager .pager-jump-in {
  width: 46px;
  height: 28px;
  padding: 0 6px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--card);
  color: var(--ink);
  font: inherit;
  font-size: 12.5px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}
#ordPager .pager-jump-in:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 2px var(--brand-soft);
}


/* ============================================================================
   横向滚动条加粗加深（原来太细，拖不住；照 WPS 那种做法）
   ============================================================================ */
.table-wrap::-webkit-scrollbar,
#ordTable::-webkit-scrollbar,
.inv-grid::-webkit-scrollbar {
  height: 15px;
  width: 15px;
}
.table-wrap::-webkit-scrollbar-track,
#ordTable::-webkit-scrollbar-track,
.inv-grid::-webkit-scrollbar-track {
  background: #eef0f2;
  border-top: 1px solid var(--line);
  border-radius: 0;
}
.table-wrap::-webkit-scrollbar-thumb,
#ordTable::-webkit-scrollbar-thumb,
.inv-grid::-webkit-scrollbar-thumb {
  background: #b4bcc6;
  border-radius: 8px;
  border: 3px solid #eef0f2;
  min-width: 60px;
}
.table-wrap::-webkit-scrollbar-thumb:hover,
#ordTable::-webkit-scrollbar-thumb:hover,
.inv-grid::-webkit-scrollbar-thumb:hover { background: #8d97a3; }
.table-wrap::-webkit-scrollbar-thumb:active,
#ordTable::-webkit-scrollbar-thumb:active,
.inv-grid::-webkit-scrollbar-thumb:active { background: #6b7683; }
.table-wrap::-webkit-scrollbar-corner,
#ordTable::-webkit-scrollbar-corner { background: #eef0f2; }
/* 滚动条始终占位，避免出现/消失时表格跳动 */
.table-wrap { scrollbar-gutter: stable; }

/* ============================================================================
   手机号次数管理
   表头 / 单元格 / 分页条 / 提示带全部复用订单页与宝钱库存那一套（.table-wrap、
   .table-meta、.pager、.bao-note），这里只补这一页特有的东西：分类胶囊、
   「每一次出现」的日期胶囊、以及「绑定次数」的条形可视化。
   ============================================================================ */
.ph-table thead th.sortable { cursor: pointer; user-select: none; }
.ph-table thead th.sortable::after { content: '⇅'; margin-left: 4px; font-size: 10px; color: #c3cad3; }
.ph-table thead th.sortable:hover::after { color: var(--ink-3); }
.ph-table tbody td { vertical-align: top; }
.ph-phone {
  font-weight: 600; font-variant-numeric: tabular-nums; letter-spacing: .2px;
  position: sticky; left: 0; background: var(--card); z-index: 1;
}
.ph-table tbody tr:hover .ph-phone { background: #f8fafd; }
.ph-cat {
  display: inline-block; font-size: 11px; line-height: 1.75;
  padding: 0 8px; border-radius: 999px; white-space: nowrap;
  border: 1px solid var(--line-strong); background: var(--bg-soft); color: var(--ink-2);
}
.ph-cat[data-cat="号商"]   { border-color: #cfe0f7; background: var(--brand-soft); color: #2f6fd0; }
.ph-cat[data-cat="客户"]   { border-color: #d6e8d1; background: #eef7ec; color: #2f5f2b; }
.ph-cat[data-cat="千游卡"] { border-color: #edd3b0; background: #fdf4e8; color: #a8621c; }
.ph-cat[data-cat="其他"]   { border-color: #e3d7ef; background: #f6f0fb; color: #7a4fa0; }
.ph-cat[data-cat="无备注"] { border-color: var(--line); background: var(--bg-sunken); color: var(--ink-3); }
.ph-note {
  color: var(--ink-2); max-width: 190px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.ph-first { font-variant-numeric: tabular-nums; white-space: nowrap; }
.ph-occ { max-width: 430px; min-width: 230px; }
.ph-chip {
  display: inline-flex; align-items: center; gap: 3px;
  margin: 1px 3px 1px 0;
  font-size: 11px; line-height: 1.75; padding: 0 7px;
  border-radius: 999px; border: 1px solid var(--line-strong);
  background: var(--bg-sunken); color: var(--ink-2);
  font-variant-numeric: tabular-nums; white-space: nowrap;
}
.ph-chip b { font-weight: 600; color: var(--brand); margin-left: 1px; }
.ph-chip.unknown { border-color: #edd3b0; background: #fdf4e8; color: #a8621c; }
.ph-bar { display: flex; align-items: center; gap: 7px; min-width: 132px; }
.ph-bar-track {
  flex: 1 1 auto; height: 8px; border-radius: 999px;
  background: var(--bg-sunken); overflow: hidden;
}
.ph-bar-fill {
  display: block; height: 100%; border-radius: 999px;
  background: linear-gradient(90deg, #7fb0ee, var(--brand));
}
.ph-bar-num {
  flex: 0 0 auto; min-width: 38px; text-align: right;
  font-size: 10.5px; color: var(--ink-3); font-variant-numeric: tabular-nums;
}

/* ---- 手机号页「网易安全中心」按钮：蓝色实心，显眼 ---- */
#page-phones .phone-netease,
a.phone-netease {
  background: var(--brand) !important;
  border-color: var(--brand) !important;
  color: #fff !important;
  font-weight: 600;
  text-decoration: none;
  padding: 6px 14px;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
}
#page-phones .phone-netease:hover,
a.phone-netease:hover {
  background: #1d4ed8 !important;
  border-color: #1d4ed8 !important;
  color: #fff !important;
}

/* ================= 备忘录（#page-memo） ================= */
/* 便签卡片：复用全局的 --card / --line / --brand 令牌，跟别的页一个脸色 */
.memo-new { display: flex; flex-direction: column; gap: 8px; padding: 12px 14px; }
.memo-new-head { font-size: 12.5px; font-weight: 600; color: var(--ink-2); }
.memo-new textarea {
  width: 100%; min-height: 66px; resize: vertical;
  border: 1px solid var(--line-strong); border-radius: var(--r-sm);
  background: var(--card); color: var(--ink);
  font: inherit; font-size: 13px; line-height: 1.7; padding: 8px 10px;
}
.memo-new textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.memo-new-foot { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.memo-new-foot input { width: 130px; }
.memo-hint { font-size: 11.5px; color: var(--ink-3); }
.memo-list { display: flex; flex-direction: column; gap: 10px; margin-top: 10px; }
.memo-card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--r);
  padding: 10px 12px; box-shadow: 0 1px 2px rgba(20, 30, 48, .04);
}
.memo-card.pinned { border-color: #f0d9a8; background: linear-gradient(180deg, #fffdf6, var(--card) 60%); }
.memo-card-head { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-bottom: 6px; }
.memo-badge {
  display: inline-flex; align-items: center; gap: 3px; white-space: nowrap;
  font-size: 11px; line-height: 1.8; padding: 0 8px; border-radius: 999px;
  border: 1px solid var(--line-strong); background: var(--bg-sunken); color: var(--ink-2);
}
.memo-badge-pin { border-color: #f0d9a8; background: #fdf6e6; color: #a8621c; }
.memo-badge-tag { border-color: #cfe0f7; background: var(--brand-soft); color: #2f6fd0; }
.memo-body { white-space: pre-wrap; word-break: break-word; font-size: 13px; line-height: 1.75; color: var(--ink); }
.memo-edit {
  width: 100%; min-height: 70px; resize: vertical;
  border: 1px solid var(--brand); border-radius: var(--r-sm);
  background: var(--card); color: var(--ink);
  font: inherit; font-size: 13px; line-height: 1.75; padding: 8px 10px;
}
.memo-edit:focus { outline: none; box-shadow: 0 0 0 3px var(--brand-soft); }
.memo-edit-hint { font-size: 11.5px; color: var(--ink-3); margin-top: 4px; }
.memo-times { margin-top: 7px; font-size: 11.5px; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.memo-empty { padding: 26px 16px; text-align: center; line-height: 1.9; }
.memo-empty-icon { font-size: 26px; line-height: 1.4; }
.memo-empty-hint { margin-top: 8px; font-size: 12px; color: var(--ink-3); }
/* 备忘录图片：新建框里的图片条 + 卡片上的图片条。
   缩略图 / 待上传角标 / 「＋ 添加图片」瓷砖 / 点图放大全部复用订单那套
   （.thumb / .thumb-del / .staged-tag / .upload-btn / #viewer），这里只排一下版式。 */
.memo-new-imgs { display: flex; align-items: flex-start; gap: 10px; flex-wrap: wrap; }
.memo-new-imgs .muted { font-size: 11.5px; color: var(--ink-3); line-height: 68px; }
.memo-imgs { display: flex; align-items: flex-start; gap: 10px; flex-wrap: wrap; margin-top: 8px; }
.memo-imgs .thumb { width: 104px; height: 78px; }
.memo-imgs .upload-btn { width: 104px; height: 78px; }
/* 权限弹窗里「服务端还没支持的页面」：置灰 + 虚线框，说明为什么点不动 */
.perm-item.perm-pending { opacity: .62; cursor: not-allowed; border-style: dashed; }

/* ============================================================================
   修：卡片页（宝钱库存 / 账号库存）往下划不动
   上一次把 overflow 加在 .card-grid 上，结果把卡片内容裁掉了 ——
   这次改成只让【页面本身】滚动，卡片区一律不裁剪。
   ============================================================================ */
#page-baocun,
#page-inventory {
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
}
#page-baocun .card-grid,
#page-inventory .card-grid {
  flex: 0 0 auto;      /* 不再拉伸、不裁剪，让内容自然撑开，由外层页面滚动 */
  min-height: 0;
  overflow: visible;
}
#page-baocun::-webkit-scrollbar,
#page-inventory::-webkit-scrollbar { width: 10px; }
#page-baocun::-webkit-scrollbar-thumb,
#page-inventory::-webkit-scrollbar-thumb { background: #b4bcc6; border-radius: 6px; }

/* 被锁定的下拉（原表颜色）：灰底 + 禁止光标，一眼看出不能改 */
#modalBody select[disabled] {
  background: var(--bg-sunken, #f3f4f6) !important;
  color: var(--ink-3, #6b7280) !important;
  cursor: not-allowed !important;
  border-color: var(--line) !important;
}

/* ================= 账号囤货资源管理（源表「白玉京   八音时装」） ================= */
/* 一条记录 = 源表一个非空数据行；H 列起的尾随列数量不定，所以表格宽度是动态的，
   统一靠 .table-wrap 横向滚动，操作列不粘（这一页没有订单页那种固定 132px 操作列的要求）。 */
.stk-note {
  margin: 0 0 12px; padding: 10px 14px; border-radius: var(--r-sm);
  background: var(--brand-soft); border: 1px solid rgba(47, 111, 208, .22);
  color: var(--ink-2); font-size: 12.5px; line-height: 1.8;
}
.stk-note b { color: var(--ink); }
.stk-note code {
  padding: 1px 5px; border-radius: 4px; background: rgba(47, 111, 208, .1);
  color: var(--ink); font-size: 12px;
}
.stk-check { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }
.stk-check input { margin: 0; }
/* 控件多、窗口窄的时候工具条会换行：右边两个按钮始终作为一个整体换下去，不会被拆开 */
.stk-actions { display: inline-flex; align-items: center; gap: 8px; flex: 0 0 auto; }
#page-stock .toolbar { row-gap: 8px; }
#page-stock .search { max-width: 250px; }
.stk-table { min-width: 1240px; }
.stk-table th, .stk-table td { white-space: nowrap; }
.stk-table th.stk-x, .stk-table td.stk-x { min-width: 108px; color: var(--ink-2); }
.stk-acct { font-weight: 600; }
/* 源表续行（该行账号格是空的，已挂到上面的账号行） */
.stk-cont { display: inline-block; color: var(--ink-3); font-weight: 400; cursor: help; }
.stk-raw { color: var(--ink-3); font-size: 11.5px; margin-top: 2px; font-weight: 400; }
/* 「一格多个数字 / 不是纯数字」这类不参与合计的标记 */
.stk-flag {
  display: inline-block; margin-left: 6px; padding: 0 6px; border-radius: 999px;
  font-size: 11px; line-height: 1.7;
  background: rgba(154, 107, 0, .1); border: 1px solid rgba(154, 107, 0, .3); color: var(--warn);
  cursor: help;
}
.stk-kind {
  display: inline-block; padding: 0 7px; border-radius: 999px; font-size: 11px; line-height: 1.75;
  background: rgba(90, 100, 112, .12); color: var(--ink-2);
}
.stk-kind-sub {
  display: inline-block; padding: 0 7px; border-radius: 999px; font-size: 11px; line-height: 1.75;
  background: rgba(154, 107, 0, .14); border: 1px solid rgba(154, 107, 0, .42); color: var(--warn); font-weight: 600;
}
/* 源表小计行整行黄底：一眼能看出它和数据行不是一类 */
.stk-table tr.stk-subrow td { background: rgba(154, 107, 0, .07); }
.stk-num-sub { color: var(--warn); }
.stk-sum { display: flex; flex-wrap: wrap; gap: 8px 26px; margin-top: 4px; }
.stk-sum span { color: var(--ink-2); }
.stk-sum b { color: var(--ink); font-size: 15px; margin: 0 4px; }
.stk-sum small { color: var(--ink-3); font-size: 11.5px; }
.stk-sum-note { margin-top: 3px; font-size: 11.5px; color: var(--ink-3); }
/* 编辑弹窗里的「原表附加列」网格 */
.stk-extra-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px 12px; }
.stk-extra-item { display: flex; flex-direction: column; gap: 3px; font-size: 12px; color: var(--ink-2); }
.stk-extra-item input {
  border: 1px solid var(--line-strong); border-radius: var(--r-sm); background: var(--card); color: var(--ink);
  font: inherit; font-size: 12.5px; padding: 5px 8px;
}
.stk-extra-item input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }

/* ================= 账号囤货资源管理（囤货台账 + 出售登记） ================= */
/* 这一版是整页重做：下面这些 .stk-* 是新页面用的。
   上面旧的 .stk-table / .stk-acct 等仍被复用（表格骨架 / 账号列加粗）。 */
.stk-tabs {
  display: flex; align-items: center; gap: 6px;
  border-bottom: 1px solid var(--line); margin-bottom: 10px; flex-wrap: wrap;
}
.stk-tab {
  appearance: none; border: 0; background: transparent; cursor: pointer;
  padding: 8px 16px; font-size: 14px; font-weight: 600; color: var(--ink-2);
  border-bottom: 2px solid transparent; margin-bottom: -1px; border-radius: 6px 6px 0 0;
}
.stk-tab:hover { color: var(--ink); background: var(--brand-soft); }
.stk-tab.active { color: var(--brand); border-bottom-color: var(--brand); background: transparent; }
.stk-rule { font-size: 11.5px; color: var(--ink-3); max-width: 62%; line-height: 1.5; text-align: right; }
/* hidden 属性必须能压住 .stk-pane 的 display:flex，否则两个分页签会同时显示 */
.stk-pane[hidden] { display: none !important; }
.stk-table-grouped { min-width: 1220px; }
.stk-table-sales { min-width: 1040px; }
.stk-table th, .stk-table td { vertical-align: top; }

/* 账号分组：一行账号小计 + 下面跟着它每一条物品 */
.stk-table tr.stk-grouprow td { background: rgba(47, 111, 208, .07); font-weight: 600; border-top: 2px solid var(--line); }
.stk-table tr.stk-lotrow td { background: transparent; }
.stk-table tr.stk-lotrow:hover td { background: rgba(0, 0, 0, .025); }
.stk-branch { color: var(--ink-3); font-weight: 400; margin-right: 2px; }
.stk-count { margin-left: 8px; font-size: 11.5px; font-weight: 400; color: var(--ink-3); }
.stk-invtag {
  display: inline-block; margin: 0 4px 3px 0; padding: 1px 8px; border-radius: 9px;
  background: var(--brand-soft); color: var(--brand); font-size: 11.5px; font-weight: 600;
}
.stk-more { align-self: center; font-size: 12px; color: var(--ink-3); margin-left: 4px; }
.stk-imgs { display: flex; gap: 4px; flex-wrap: wrap; align-items: center; }
.stk-imgs img {
  width: 40px; height: 40px; object-fit: cover; border-radius: 5px;
  border: 1px solid var(--line); cursor: zoom-in; background: #fff;
}
.stk-code { display: block; font-size: 11px; color: var(--ink-3); font-weight: 400; font-family: ui-monospace, Consolas, monospace; }
.stk-item { font-weight: 600; }
.stk-num-neg { color: var(--neg); font-weight: 700; }
.stk-num-zero { color: var(--warn); font-weight: 600; }
.stk-flag-manual {
  background: rgba(154, 107, 0, .16); color: var(--warn);
  border: 1px solid rgba(154, 107, 0, .28);
}
.stk-form-tip {
  margin-top: 10px; padding: 8px 10px; border-radius: 6px;
  background: var(--brand-soft); color: var(--ink-2); font-size: 12px; line-height: 1.65;
}

/* 统计面板 */
.stk-stats { margin-top: 18px; }
.stk-stat-head {
  font-size: 15px; font-weight: 700; color: var(--ink);
  border-left: 3px solid var(--brand); padding-left: 8px; margin-bottom: 10px;
}
.stk-stat-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 10px; }
.stk-card {
  border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px;
  background: var(--card); display: flex; flex-direction: column; gap: 3px;
}
.stk-card-main { border-color: var(--brand); background: var(--brand-soft); }
.stk-card-t { font-size: 12px; color: var(--ink-2); }
.stk-card-v { font-size: 20px; font-weight: 700; color: var(--ink); }
.stk-card-s { font-size: 11.5px; color: var(--ink-3); line-height: 1.5; }
.stk-stat-sec { margin: 16px 0 6px; font-size: 13.5px; font-weight: 700; color: var(--ink); }
.stk-stat-wrap { max-height: 340px; }
.stk-stat-table { min-width: 900px; }
.stk-stat-table td, .stk-stat-table th { white-space: nowrap; }
.stk-stat-note {
  margin-top: 10px; padding: 8px 10px; border-radius: 6px;
  background: var(--card); border: 1px dashed var(--line);
  color: var(--ink-3); font-size: 11.5px; line-height: 1.7;
}

/* ============================================================================
   小号账号管理 / 小号库存（本轮新增）
   ----------------------------------------------------------------------------
   小号表沿用订单表那一整套表格样式（列宽拖拽 / 固定列 / 右侧钉住的「操作」列 /
   就地编辑 / 蓝色实时框）。这里把上面所有针对 #ordTable / #page-orders 的规则
   原样复制一份给 #smallOrdTable / #page-smallOrders —— 一份样式两处生效，
   而选择器彼此独立，所以以后改哪一边都不会串到另一边。
   ============================================================================ */
#smallOrdTable thead th[data-col] { cursor: grab; }
#smallOrdTable thead th[data-col]:active { cursor: grabbing; }
#smallOrdTable thead th.dragging { opacity: .35; background: var(--brand-soft); }
#smallOrdTable table.fixed-cols { table-layout: fixed; }
#smallOrdTable table.fixed-cols thead th,
#smallOrdTable table.fixed-cols tbody td {
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
#smallOrdTable table.fixed-cols thead th.wrap,
#smallOrdTable table.fixed-cols tbody td.wrap { white-space: normal; }
#smallOrdTable thead th:last-child,
#smallOrdTable tbody td:last-child,
#page-smallOrders .table-wrap th:last-child,
#page-smallOrders .table-wrap td:last-child {
  position: sticky !important;
  right: 0 !important;
  width: 132px !important;
  min-width: 132px !important;
  max-width: 132px !important;
  box-sizing: border-box !important;
  white-space: nowrap !important;
  z-index: 6 !important;
  background: var(--card) !important;
  box-shadow: -1px 0 0 var(--line) !important;
  overflow: visible !important;
  padding-left: 8px !important;
  padding-right: 4px !important;
}
#smallOrdTable thead th:last-child { z-index: 8 !important; }
#smallOrdTable tbody tr:hover td:last-child { background: var(--bg-sunken) !important; }
#smallOrdTable td:last-child .btn,
#smallOrdTable td:last-child button {
  padding: 3px 7px !important;
  font-size: 12px !important;
  min-width: 0 !important;
  display: inline-block !important;
  border-radius: 4px !important;
}
#smallOrdTable td:last-child > * { margin-left: 3px !important; }
#smallOrdTable td:last-child > *:first-child { margin-left: 0 !important; }
#smallOrdTable td:last-child .btn-ghost,
#smallOrdTable td:last-child button.btn-ghost {
  border: none !important;
  background: transparent !important;
  padding: 3px 4px !important;
}
#smallOrdTable colgroup col[data-k="__acts"] { width: 132px !important; }
#smallOrdTable::-webkit-scrollbar { width: 10px; height: 10px; }
#smallOrdTable::-webkit-scrollbar-thumb { background: #c9ced6; border-radius: 6px; }
#smallOrdTable::-webkit-scrollbar-track { background: #eef0f2; }

/* 「分红比例」列：由利润推导的只读列，给一个淡淡的底，让人一眼看出它不是手填的 */
.small-rate-cell {
  display: inline-flex; align-items: center; gap: 4px;
  font-variant-numeric: tabular-nums; font-weight: 600; color: #1d4ed8;
}
.small-rate-cell .small-rate-tag {
  font-size: 10px; font-weight: 400; color: #6b7280;
  border: 1px solid #dbe1ea; background: #f5f7fa; border-radius: 999px; padding: 0 5px;
}
/* 空表提示：新账本一条都没有时也要像个正常页面 */
.small-empty { padding: 30px 16px; text-align: center; line-height: 2; color: var(--ink-3); }
.small-empty b { color: var(--ink); }
.small-empty .btn { margin-top: 10px; }
.small-empty-hint { font-size: 12px; color: var(--ink-3); margin-top: 6px; }
.small-bands {
  margin: 0 0 10px; padding: 9px 12px;
  border: 1px solid #d8e4fb; background: #f4f8ff; border-radius: var(--r-sm);
  font-size: 12px; color: #24467a; line-height: 1.7;
}
.small-bands b { color: #1d4ed8; }
/* ============================================================================
   补：小号库存的卡片区也要能滚动（和账号库存/宝钱库存同样的坑）
   ——— 滚动放在【页面】上，卡片区不裁剪。
   ============================================================================ */
#page-smallInventory {
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
}
#page-smallInventory .card-grid {
  flex: 0 0 auto;
  min-height: 0;
  overflow: visible;
}
#page-smallInventory::-webkit-scrollbar { width: 10px; }
#page-smallInventory::-webkit-scrollbar-thumb { background: #b4bcc6; border-radius: 6px; }

/* ============================================================================
   全局修复：所有页面都能纵向滚动
   —— 原来只有 .table-wrap / 卡片页各自处理，遗漏的页面（囤货、小号库存…）内容一多就划不动。
   统一让 .page.active 自己滚，卡片区一律不裁剪；有自己滚动容器的页面（表格）不受影响。
   ============================================================================ */
.page.active {
  overflow-y: auto;
  overflow-x: hidden;
  min-height: 0;
}
.page.active::-webkit-scrollbar { width: 10px; }
.page.active::-webkit-scrollbar-thumb { background: #b4bcc6; border-radius: 6px; }
.page.active::-webkit-scrollbar-track { background: transparent; }
/* 卡片区不参与拉伸/裁剪，让内容自然撑开，由页面滚动 */
/* ============================ 看板：小号账本分区 ============================ */
/* 只作用于 #dashSmallPanel：#page-dash 的滚动 / flex 规则一个字没动，
   .card-grid 也没有碰（这里用的是 .stat-grid，与主账指标卡同一套）。 */
#dashSmallPanel .stat-grid { margin-bottom: 2px; }
#dashSmallPanel .dash-book-head { display: flex; align-items: baseline; gap: 10px; margin: 14px 0 6px; }
#dashSmallPanel .dash-book-head .ttl { font-size: 13px; font-weight: 600; }
#dashSmallPanel .dash-book-head .tip { font-size: 11px; color: var(--ink-3); }
#dashSmallPanel .table-wrap { max-height: none; }
#dashSmallPanel table th.tot, #dashSmallPanel table td.tot { font-weight: 600; }
#dashSmallPanel .dash-cmp-note { font-size: 11px; color: var(--ink-3); line-height: 1.8; padding: 8px 2px 0; }
#dashSmallPanel .dash-cmp-note b { color: var(--ink-2); font-weight: 600; }

.page.active .card-grid {
  flex: 0 0 auto;
  min-height: 0;
  overflow: visible;
}

/* ============================================================================
   这 4 个页面上面有 `#page-orders…{overflow:hidden}`（ID 优先级高于 .page.active），
   所以它们不参与整页滚动 —— 平时靠 .table-wrap 内部滚动。这里补一层保险：
   内容真超出时页面也能滚，不会卡住。
   ============================================================================ */
#page-orders,
#page-flows,
#page-dividends,
#page-logs {
  overflow-y: auto;
  overflow-x: hidden;
}
#page-orders::-webkit-scrollbar,
#page-flows::-webkit-scrollbar,
#page-dividends::-webkit-scrollbar,
#page-logs::-webkit-scrollbar { width: 10px; }
#page-orders::-webkit-scrollbar-thumb,
#page-flows::-webkit-scrollbar-thumb,
#page-dividends::-webkit-scrollbar-thumb,
#page-logs::-webkit-scrollbar-thumb { background: #b4bcc6; border-radius: 6px; }

/* ============================================================================
   小号账号管理的表格没有铺满宽度（右边空一块）。
   和其它表一样：表格宽度 100%，列按内容分配；内容超宽时才横向滚动。
   ============================================================================ */
#smallOrdTable table,
#ordTable table {
  width: 100%;
  min-width: 100%;
  border-collapse: separate;
  border-spacing: 0;
}
#page-smallOrders .table-wrap,
#page-smallOrders #smallOrdTable {
  width: 100%;
}

/* ============================================================================
   小号账号管理：表格下方留白过大。
   只让【表格区】撑满剩余高度（分页条固定在下面），卡片页一律不碰。
   注意加 .active，否则未激活的页面也会显示。
   ============================================================================ */
#page-smallOrders.active {
  display: flex;
  flex-direction: column;
  min-height: 0;
}
#page-smallOrders.active .table-wrap,
#page-smallOrders.active #smallOrdTable {
  flex: 1 1 auto;
  min-height: 200px;
}

/* 「恢复默认表头」按钮栏（编辑表头面板底部） */
.hdr-reset-bar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  margin-top: 14px; padding-top: 12px; border-top: 1px dashed var(--line);
}
.hdr-reset-bar .hdr-reset-tip { font-size: 12px; color: var(--ink-3); line-height: 1.6; }

/* ============================================================================
   订单 / 小号表格：整行按账号状态填充淡色背景（用户 2026-10-17 要求，对齐 WPS）
   只用极淡的底、不动文字色，保证可读性；hover / 选中 / 斑马纹仍然优先。
   ============================================================================ */
#ordTable tbody tr.st-红 > td, #smallOrdTable tbody tr.st-红 > td { background-color: #fdeceb !important; }
#ordTable tbody tr.st-绿 > td, #smallOrdTable tbody tr.st-绿 > td { background-color: #eaf7ee !important; }
#ordTable tbody tr.st-黄 > td, #smallOrdTable tbody tr.st-黄 > td { background-color: #fdf6e3 !important; }
#ordTable tbody tr.st-蓝 > td, #smallOrdTable tbody tr.st-蓝 > td { background-color: #eaf1fc !important; }
#ordTable tbody tr.st-灰 > td, #smallOrdTable tbody tr.st-灰 > td { background-color: #f2f3f5 !important; }
#ordTable tbody tr.st-粉 > td, #smallOrdTable tbody tr.st-粉 > td { background-color: #fdeef7 !important; }
/* 选中行 / 悬停行盖过状态底色 */
#ordTable tbody tr.picked > td { background: #e8f0fe !important; }
#ordTable tbody tr:hover > td, #smallOrdTable tbody tr:hover > td { filter: brightness(0.97); }


/* 整列被选中时的高亮（Ctrl+点击表头 / 右键表头 都会高亮） */
#ordTable tbody td.col-picked, #smallOrdTable tbody td.col-picked {
  outline: 2px solid #2f6df6 !important;
  outline-offset: -2px;
  background-image: linear-gradient(rgba(47,109,246,.12), rgba(47,109,246,.12)) !important;
}
#ordTable thead th.col-picked, #smallOrdTable thead th.col-picked {
  outline: 2px solid #2f6df6 !important;
  outline-offset: -2px;
}

/* ============================================================================
   撤销按钮隐藏（2026-10-22 用户要求）
   · 隐藏「↶ 撤销」那个一键撤销按钮（容易误触）
   · 但保留右边的 ▾ 箭头 + 最近 10 步面板 —— 用户可以自己挑回溯到哪一步
   · 代码全部保留，以后要恢复：删掉 #btnUndo 那一条即可
   ============================================================================ */
#btnUndo { display: none !important; }

/* 「最近一步操作」文字（撤销按钮已隐藏，这行是唯一的可见提示） */
.undo-last {
  font-size: 12.5px;
  color: var(--ink-3);
  max-width: 340px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin-right: 2px;
  cursor: default;
}

/* 由算式框计算得出的数字框（变现金额 / 增加成本）：只读观感 */
input.calc-target-readonly {
  background: #f5f6f8 !important;
  color: var(--ink-2) !important;
  cursor: default !important;
}
input.calc-target-readonly:focus { outline: none !important; box-shadow: none !important; }

/* ============================================================================
   PWA / 手机端（2026-11-10）
   · 刘海屏安全区：viewport-fit=cover 之后，内容不要钻到状态栏 / Home 指示条下面
   · 安装提示 / 离线横幅：Chinese UI，和现有卡片风格一致
   · 手机横屏：侧栏变成「logo + 一行菜单」，把高度让给表格
   ============================================================================ */

/* ---- 1. 手机浏览器地址栏伸缩时，用动态视口高度，避免底部被切 ---- */
@supports (height: 100dvh) {
  .app, .content { height: 100dvh; }
}

/* ---- 2. 安全区 ---- */
@supports (padding: env(safe-area-inset-top)) {
  .app {
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
  }
  .sidebar {
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
  }
  .topbar {
    height: calc(46px + env(safe-area-inset-top));
    padding-top: env(safe-area-inset-top);
  }
  main { padding-bottom: calc(12px + env(safe-area-inset-bottom)); }
  .modal-mask {
    padding-top: calc(48px + env(safe-area-inset-top));
    padding-bottom: calc(48px + env(safe-area-inset-bottom));
  }
  .login-mask {
    padding-top: calc(24px + env(safe-area-inset-top));
    padding-bottom: calc(24px + env(safe-area-inset-bottom));
  }
  .toast-wrap {
    right: calc(20px + env(safe-area-inset-right));
    bottom: calc(20px + env(safe-area-inset-bottom));
  }
}

/* ---- 3. 离线横幅 ---- */
.offline-bar {
  position: fixed;
  top: calc(8px + env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%);
  z-index: 500;
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: calc(100vw - 24px);
  padding: 7px 14px;
  border-radius: 999px;
  background: #8a5a00;
  color: #fff;
  font-size: 12.5px;
  line-height: 1.4;
  white-space: nowrap;
  box-shadow: 0 8px 26px rgba(60, 40, 0, .28);
}
.offline-bar small { font-size: 11px; color: rgba(255, 255, 255, .72); }
.offline-dot {
  width: 7px; height: 7px; flex: 0 0 7px;
  border-radius: 50%;
  background: #ffd166;
  box-shadow: 0 0 0 3px rgba(255, 209, 102, .18);
}
@media (max-width: 560px) {
  .offline-bar small { display: none; }
}

/* ---- 4. 「添加到桌面」提示（只在手机浏览器标签页里出现，一个会话一次） ---- */
.pwa-hint {
  position: fixed;
  left: 50%;
  bottom: calc(14px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 450;
  display: flex;
  align-items: center;
  gap: 11px;
  width: min(440px, calc(100vw - 24px));
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--card);
  box-shadow: 0 16px 40px rgba(20, 30, 48, .20);
  animation: pwa-hint-in .22s ease-out;
}
@keyframes pwa-hint-in {
  from { opacity: 0; transform: translate(-50%, 8px); }
  to   { opacity: 1; transform: translate(-50%, 0); }
}
.pwa-hint-icon {
  width: 40px; height: 40px; flex: 0 0 40px;
  border-radius: 9px;
}
.pwa-hint-text {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.pwa-hint-text b { font-size: 13px; font-weight: 600; color: var(--ink); }
.pwa-hint-text span { font-size: 11.5px; line-height: 1.55; color: var(--ink-2); }
.pwa-hint-actions { display: flex; align-items: center; gap: 3px; flex: 0 0 auto; }
.pwa-hint-actions .btn-sm { padding: 5px 10px; font-size: 12px; white-space: nowrap; }
.pwa-hint-close {
  border: 0;
  background: transparent;
  color: var(--ink-3);
  font-size: 18px;
  line-height: 1;
  padding: 4px 6px;
  border-radius: 6px;
  cursor: pointer;
}
.pwa-hint-close:hover { background: var(--bg-sunken); color: var(--ink); }
@media (max-width: 370px) {
  .pwa-hint { gap: 8px; padding: 10px; }
  .pwa-hint-icon { width: 34px; height: 34px; flex-basis: 34px; }
  .pwa-hint-actions .btn-sm { padding: 5px 8px; }
}

/* ---- 5. 手机横屏：别让顶部的品牌行 + 菜单吃掉半屏高度 ---- */
@media (max-width: 900px) and (orientation: landscape) {
  .sidebar {
    flex-direction: row;
    align-items: center;
    gap: 4px;
  }
  .side-brand { flex: 0 0 auto; padding: 6px 8px 6px 12px; }
  .side-brand .logo { width: 24px; height: 24px; flex-basis: 24px; font-size: 12px; border-radius: 6px; }
  .side-brand-text { display: none; }
  .side-nav {
    flex: 1 1 auto;
    flex-direction: row;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 5px 8px 6px 0;
  }
  .nav-item { padding: 5px 9px; font-size: 12px; }
  .topbar { height: 40px; padding-top: 0; }
  main { padding: 8px 12px 10px; }
}

/* ---- 6. iOS 独立窗口：状态栏是白底黑字，保持顶栏干净 ---- */
@media (display-mode: standalone) {
  body { overscroll-behavior-y: none; }
}

/* ===== MOBILE-RESPONSIVE-BEGIN ===== */
/* ============================================================================
   手机 / 平板适配（2026-11-10）
   目标：14 个页面在 ≤900px（含 844×390 横屏手机）下全部可用；>900px 一个像素不变。
   做法：
     1. 断点用 900px 而不是 820px —— 844×390 的横屏手机 CSS 宽度就是 844，
        用 820 会漏掉它；900 也是原来「窄屏」那条既有的分界，不新增语义。
     2. 侧栏 ≤900px 变成抽屉（☰ 打开 / 遮罩或选中即关），桌面侧栏规则不动。
     3. 订单 / 小号两张 20 列大表在手机上变「一行一张卡」（列名 + 值），
        其它表格保留 .table-wrap 横向滚动兜底。
     4. 所有可点控件 ≥40px；模态框全屏 + 保存条固定。
   本块之前 styles.css 里已有的 @media(max-width:900px) 规则由本块覆盖。
   ============================================================================ */

/* 手机专用元素：桌面端一律不占位 */
.nav-toggle,
.drawer-backdrop,
.drawer-close,
.drawer-pwd,
.mob-only { display: none; }

@media (max-width: 900px) {
  /* ---------- 1. 骨架：整屏不给 body 滚，页面自己滚 ---------- */
  html, body { height: 100%; }
  body { overflow: hidden; }
  .app {
    display: block;
    height: 100vh;
    height: 100dvh;
    min-height: 0;
    overflow: hidden;
  }
  .content {
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
    min-height: 0;
    overflow: hidden;
  }
  main {
    flex: 1 1 auto;
    min-height: 0;
    width: 100%;
    padding: 8px 8px calc(8px + env(safe-area-inset-bottom, 0px));
    overflow: hidden;
  }
  .setup-banner { padding: 10px 12px; gap: 8px; font-size: 12.5px; line-height: 1.65; }

  /* ---------- 2. 抽屉式导航 ---------- */
  .nav-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 44px;
    width: 44px;
    height: 44px;
    padding: 0;
    border: 1px solid var(--line-strong);
    border-radius: var(--r-sm);
    background: var(--card);
    color: var(--ink);
    font-size: 21px;
    line-height: 1;
    cursor: pointer;
  }
  .nav-toggle:active { background: var(--bg-sunken); }
  .drawer-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 210;
    background: rgba(16, 20, 26, .38);
    opacity: 0;
    pointer-events: none;
    transition: opacity .2s ease;
  }
  body.nav-open .drawer-backdrop { opacity: 1; pointer-events: auto; }
  .sidebar {
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    z-index: 220;
    width: min(84vw, 320px);
    height: 100vh;
    height: 100dvh;
    padding-top: env(safe-area-inset-top, 0px);
    border-right: 1px solid var(--line);
    border-bottom: none;
    background: var(--card);
    box-shadow: 8px 0 34px rgba(16, 24, 40, .16);
    transform: translateX(-102%);
    visibility: hidden;
    transition: transform .22s ease, visibility 0s linear .22s;
  }
  body.nav-open .sidebar {
    transform: none;
    visibility: visible;
    transition: transform .22s ease;
  }
  .side-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 10px 10px 14px;
    flex: 0 0 auto;
  }
  .side-brand-text { display: flex; }
  .side-brand-text b { font-size: 14px; }
  .drawer-close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-left: auto;
    width: 40px;
    height: 40px;
    padding: 0;
    border: none;
    border-radius: var(--r-sm);
    background: none;
    color: var(--ink-3);
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
  }
  .drawer-close:active { background: var(--bg-sunken); }
  .side-nav {
    flex: 1 1 auto;
    flex-direction: column;
    overflow-x: hidden;
    overflow-y: auto;
    gap: 2px;
    padding: 4px 8px 10px;
    -webkit-overflow-scrolling: touch;
  }
  .nav-item {
    width: 100%;
    min-height: 42px;
    padding: 8px 12px;
    font-size: 14px;
    white-space: normal;
  }
  .side-foot {
    display: block;
    flex: 0 0 auto;
    padding: 10px 14px calc(12px + env(safe-area-inset-bottom, 0px));
    border-top: 1px solid var(--line);
  }
  .side-foot-gear { min-width: 40px; min-height: 40px; }
  .drawer-pwd { display: inline-flex; margin-top: 8px; }

  /* ---------- 3. 顶栏：☰ + 标题 + 撤销 + 账号 ---------- */
  .topbar {
    height: 52px;
    flex: 0 0 52px;
    flex-wrap: nowrap;
    gap: 4px;
    padding: 0 6px;
    position: relative;
    z-index: 40;
  }
  .crumb {
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 15px;
  }
  .topbar-right { margin-left: 0; flex: 0 0 auto; gap: 2px; }
  .topbar-note, .undo-last { display: none; }
  .undo-caret { min-width: 40px; min-height: 40px; padding: 0 8px; font-size: 18px; color: var(--ink-2); }
  .undo-panel {
    position: fixed;
    left: 8px;
    right: 8px;
    top: calc(52px + env(safe-area-inset-top, 0px));
    width: auto;
    max-height: 64vh;
    overflow: auto;
    z-index: 260;
  }
  .user-chip { border-left: none; padding-left: 0; margin-left: 0; gap: 4px; }
  .user-meta { min-width: 0; }
  .user-meta b { max-width: 88px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .user-meta small { display: none; }
  .user-avatar { width: 30px; height: 30px; }
  #btnPwd { display: none; }          /* 手机上进抽屉里的「改密码」 */
  #btnReload { min-height: 40px; }

  /* ---------- 4. 工具条 / 筛选 / 触控尺寸 ---------- */
  .toolbar { gap: 8px 10px; margin-bottom: 10px; }
  .toolbar .grow { display: none; }
  .toolbar .btn { flex: 0 0 auto; }
  input.search, input[type="search"].search {
    min-width: 0 !important;
    flex: 1 1 200px;
    width: auto;
    max-width: 100%;
  }
  /* 手机上默认收起筛选项：搜索、所有操作按钮、表格都还在；点「筛选」展开 */
  .page.has-filter-toggle:not(.filters-open) .toolbar .field.inline:not(.filter-keep) { display: none !important; }
  .toolbar .filter-toggle {
    flex: 0 0 auto;
    border-color: var(--line-strong);
    background: var(--card);
    color: var(--ink-2);
    min-height: 40px;
  }
  .toolbar .filter-toggle[aria-expanded="true"] {
    border-color: var(--brand);
    color: var(--brand);
    background: var(--brand-soft);
  }
  .field.inline {
    flex: 1 1 auto;
    min-width: 0;
    max-width: 100%;
    gap: 6px;
  }
  .field.inline > span { white-space: normal; line-height: 1.35; }
  .field.inline select,
  .field.inline input { max-width: 100%; min-width: 0; }
  .field.inline.check > span { white-space: normal; }

  .btn { min-height: 40px; padding: 8px 12px; font-size: 13px; }
  .btn-sm { min-height: 40px; padding: 8px 11px; font-size: 12.5px; }
  .mob-only { display: inline-flex; min-width: 44px; justify-content: center; }
  .btn .undo-label { max-width: none; }
  input[type="text"], input[type="search"], input[type="number"],
  input[type="date"], input[type="file"], select, textarea { min-height: 40px; }
  input[type="checkbox"], input[type="radio"] { min-height: 0; }
  .side-foot-gear, .meta-gear { font-size: 16px; }

  /* 状态分类条 / 分红分类条：单行横向滑动，别吃掉半屏高度 */
  .status-bar, .dvd-cats {
    flex-wrap: nowrap;
    overflow-x: auto;
    overflow-y: hidden;
    gap: 6px;
    padding: 6px 10px;
    -webkit-overflow-scrolling: touch;
  }
  .status-bar::-webkit-scrollbar, .dvd-cats::-webkit-scrollbar { display: none; }
  .status-tab, .dvd-cat { flex: 0 0 auto; min-height: 40px; padding: 8px 12px; font-size: 13px; }
  .status-bar-label, .dvd-cat-label { flex: 0 0 auto; }
  .table-meta { gap: 8px 12px; font-size: 12px; }

  /* ---------- 5. 订单 / 小号表：一行一张卡 ---------- */
  #page-orders .toolbar,
  #page-smallOrders .toolbar,
  #page-logs .toolbar,
  #page-flows .toolbar,
  #page-dividends .toolbar { padding: 10px 10px 0; }
  #page-orders .toolbar + .toolbar,
  #page-smallOrders .toolbar + .toolbar { padding-top: 0; }
  #page-orders .table-meta,
  #page-smallOrders .table-meta,
  #page-logs .table-meta,
  #page-flows .table-meta,
  #page-dividends .table-meta { padding: 8px 10px; }
  #page-orders .pager,
  #page-smallOrders .pager,
  #page-logs .pager { padding: 8px 10px 12px; }
  #page-orders .sel-bar, #page-smallOrders .sel-bar { margin: 0 10px 8px; }

  #page-orders .table-wrap,
  #page-smallOrders .table-wrap,
  #page-smallOrders #smallOrdTable {
    flex: 0 0 auto;
    min-height: 0;
    max-height: none;
    width: 100% !important;
    overflow: visible;
    background: transparent;
    padding: 2px 10px 4px;
  }
  #ordTable table,
  #smallOrdTable table {
    display: block;
    width: 100%;
    min-width: 0;
    border-collapse: separate;
    border-spacing: 0;
  }
  #ordTable colgroup, #smallOrdTable colgroup,
  #ordTable thead, #smallOrdTable thead { display: none; }
  #ordTable tbody, #smallOrdTable tbody { display: block; }
  #ordTable .col-resizer, #smallOrdTable .col-resizer { display: none; }

  #ordTable tbody tr,
  #smallOrdTable tbody tr {
    position: relative;
    display: block;
    margin: 0 0 10px;
    padding: 10px 12px;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 10px;
    box-shadow: 0 1px 3px rgba(20, 30, 48, .05);
  }
  #ordTable tbody tr:last-child,
  #smallOrdTable tbody tr:last-child { margin-bottom: 0; }

  /* 状态底色移到整张卡上（原来是每个 td 各自填色） */
  #ordTable tbody tr.st-红, #smallOrdTable tbody tr.st-红 { background: #fdeceb; }
  #ordTable tbody tr.st-绿, #smallOrdTable tbody tr.st-绿 { background: #eaf7ee; }
  #ordTable tbody tr.st-黄, #smallOrdTable tbody tr.st-黄 { background: #fdf6e3; }
  #ordTable tbody tr.st-蓝, #smallOrdTable tbody tr.st-蓝 { background: #eaf1fc; }
  #ordTable tbody tr.st-灰, #smallOrdTable tbody tr.st-灰 { background: #f2f3f5; }
  #ordTable tbody tr.st-粉, #smallOrdTable tbody tr.st-粉 { background: #fdeef7; }
  #ordTable tbody tr.st-红 > td, #smallOrdTable tbody tr.st-红 > td,
  #ordTable tbody tr.st-绿 > td, #smallOrdTable tbody tr.st-绿 > td,
  #ordTable tbody tr.st-黄 > td, #smallOrdTable tbody tr.st-黄 > td,
  #ordTable tbody tr.st-蓝 > td, #smallOrdTable tbody tr.st-蓝 > td,
  #ordTable tbody tr.st-灰 > td, #smallOrdTable tbody tr.st-灰 > td,
  #ordTable tbody tr.st-粉 > td, #smallOrdTable tbody tr.st-粉 > td,
  #ordTable tbody tr.picked > td, #smallOrdTable tbody tr.picked > td {
    background: transparent !important;
  }
  #ordTable tbody tr.picked, #smallOrdTable tbody tr.picked {
    background: #e8f0fe;
    border-color: #9dbcf5;
  }

  /* 数据格：左侧列名 + 右侧值；值自动换行，长值不再被截断 */
  #ordTable tbody td[data-label],
  #smallOrdTable tbody td[data-label],
  #ordTable table.fixed-cols tbody td,
  #smallOrdTable table.fixed-cols tbody td {
    position: relative;
    display: block;
    width: auto !important;
    min-width: 0 !important;
    max-width: none !important;
    padding: 3px 0 3px 84px !important;
    min-height: 27px;
    border: none !important;
    background: transparent !important;
    box-shadow: none !important;
    white-space: normal !important;
    overflow: visible !important;
    text-overflow: clip !important;
    line-height: 1.55;
    overflow-wrap: anywhere;
  }
  #ordTable tbody td[data-label]::before,
  #smallOrdTable tbody td[data-label]::before {
    content: attr(data-label);
    position: absolute;
    left: 0;
    top: 4px;
    width: 76px;
    color: var(--ink-3);
    font-size: 11.5px;
    font-weight: 400;
    line-height: 1.5;
    white-space: normal;
    overflow-wrap: anywhere;
    text-align: left;
  }
  #ordTable tbody td[data-label] .tag,
  #smallOrdTable tbody td[data-label] .tag { font-size: 12px; }

  /* 订单号那一格当卡片标题：不加列名、加一条虚线 */
  #ordTable tbody td[data-field="id"],
  #smallOrdTable tbody td[data-field="id"] {
    padding: 0 0 6px !important;
    margin-bottom: 2px;
    border-bottom: 1px dashed var(--line) !important;
    font-size: 14px;
    font-weight: 600;
    line-height: 1.5;
  }
  #ordTable tbody td[data-field="id"]::before,
  #smallOrdTable tbody td[data-field="id"]::before { display: none; }
  #ordTable tbody td[data-field="id"] .id-link,
  #smallOrdTable tbody td[data-field="id"] .id-link {
    display: inline-block;
    padding: 2px 0;
    border-bottom-color: var(--line-strong);
  }

  /* 勾选列：卡片右上角，方便单手点 */
  #ordTable tbody td.pick {
    position: absolute;
    top: 8px;
    right: 8px;
    width: auto !important;
    padding: 0 !important;
    border: none !important;
    background: transparent !important;
    z-index: 2;
  }
  #ordTable tbody td.pick input { width: 22px; height: 22px; margin: 0; }
  #ordTable tbody tr { padding-right: 40px; }

  /* 操作列：卡片底部三个等宽大按钮 */
  #ordTable tbody td.acts,
  #smallOrdTable tbody td.acts,
  #page-orders .table-wrap tbody td:last-child,
  #page-smallOrders .table-wrap tbody td:last-child,
  #smallOrdTable tbody td:last-child {
    position: static !important;
    right: auto !important;
    width: auto !important;
    min-width: 0 !important;
    max-width: none !important;
    padding: 8px 0 0 !important;
    margin-top: 6px;
    border: none !important;
    border-top: 1px solid var(--line) !important;
    background: transparent !important;
    box-shadow: none !important;
    z-index: auto !important;
    overflow: visible !important;
    white-space: normal !important;
    display: flex;
    gap: 8px;
  }
  #ordTable tbody td.acts .btn,
  #smallOrdTable tbody td.acts .btn,
  #ordTable td:last-child .btn,
  #smallOrdTable td:last-child .btn,
  #smallOrdTable td:last-child button {
    flex: 1 1 0;
    min-width: 0 !important;
    min-height: 40px !important;
    padding: 8px 10px !important;
    font-size: 13px !important;
    border-radius: var(--r-sm) !important;
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    margin-left: 0 !important;
  }
  #ordTable tbody td.acts .btn-danger,
  #smallOrdTable tbody td.acts .btn-danger { flex: 0 0 auto; }
  /* 日志 / 编辑是 ghost 按钮：手机上给实底 + 边框，手指一眼看得出能点 */
  #ordTable tbody td.acts .btn-ghost,
  #smallOrdTable tbody td.acts .btn-ghost {
    border: 1px solid var(--line-strong) !important;
    background: var(--card) !important;
    color: var(--ink-2) !important;
  }
  #smallOrdTable td:last-child .btn-ghost,
  #smallOrdTable td:last-child button.btn-ghost { border: none !important; }

  /* 其它表格：保留横向滚动兜底，不撑破页面 */
  #page-phones .table-wrap,
  #page-logs .table-wrap,
  #page-flows .table-wrap,
  #page-dividends .table-wrap,
  #page-stock .table-wrap,
  #userTable,
  #ioStats,
  #dashBooksCompare,
  #monthTable,
  #statusTable,
  #channelTable,
  #partnerTable {
    overflow: auto;
    max-width: 100%;
    -webkit-overflow-scrolling: touch;
  }
  #page-logs .table-wrap, #page-flows .table-wrap,
  #page-dividends .table-wrap, #page-phones .table-wrap { max-height: 62vh; }

  /* 分页条：触控尺寸 */
  .pager { gap: 4px; padding: 10px 0 4px; }
  .pager button,
  #ordPager .pg-btn, #smallOrdPager .pg-btn, #logPager .pg-btn,
  #baoPager .pg-btn, #phonePager .pg-btn { min-width: 40px; min-height: 40px; padding: 6px 9px; }
  .pager-size { min-height: 40px; }
  .pager-jump-in { width: 64px; min-height: 40px; }

  /* ---------- 6. 看板 / 库存卡片 / 囤货 ---------- */
  .stat-grid, .kpi-grid { gap: 10px; }
  .stat .v { font-size: 19px; }
  .panel-head { padding: 10px 12px; }
  .panel-body { padding: 12px; }
  .panel-grid { gap: 10px; }
  #page-dash .panel, #page-inventory .panel,
  #page-io .panel, #page-users .panel { margin-bottom: 10px; }

  #page-inventory .toolbar { padding: 10px; }
  #page-inventory .table-meta, #page-baocun .table-meta,
  #page-smallInventory .table-meta { padding: 8px 2px 10px; }
  .card-grid { gap: 10px; }              /* 不碰 display / grid-template */
  .inv-body { padding: 10px; }
  .inv-actions { padding: 0 10px 10px; gap: 8px; }
  .inv-actions .btn { min-height: 40px; font-size: 13px; }
  .inv-cover { aspect-ratio: 16 / 9; }
  /* 没有图的卡别浪费 200px 的首屏：压成一条「暂无图片」条（:has 不支持时保持上面的比例） */
  .inv-cover:has(.inv-cover-empty) { aspect-ratio: auto; height: 64px; }
  .inv-fields { gap: 2px 8px; }

  .stk-tabs { gap: 6px; flex-wrap: wrap; }
  .stk-tab { min-height: 40px; padding: 8px 14px; font-size: 13.5px; }
  .stk-rule { flex: 1 1 100%; max-width: none; text-align: left; font-size: 11px; margin-top: 2px; }
  .stk-actions { gap: 8px; flex-wrap: wrap; }
  .stk-stats { margin-top: 10px; }
  .stk-stat-cards { gap: 8px; }
  .stk-stat-wrap { max-height: 56vh; }
  .stk-note, .small-bands, .bao-note { font-size: 12px; line-height: 1.7; }
  .stk-sum { gap: 6px 18px; }

  #page-io .panel-body { padding: 12px; }
  #page-io .row, #page-users .row { gap: 8px; }
  #page-io input[type="file"] { width: 100%; max-width: 100%; }
  #page-io .log { max-width: 100%; }
  #page-users .panel-body { padding: 12px; }
  .lan-addr { word-break: break-all; }

  /* 备忘录 */
  .memo-new { padding: 10px; }
  .memo-new-foot { gap: 8px; }
  .memo-new-foot input { flex: 1 1 140px; width: auto; min-width: 0; }
  .memo-hint { flex: 1 1 100%; }
  .memo-imgs .thumb, .memo-imgs .upload-btn { width: 92px; height: 68px; }
  .memo-card { padding: 10px; }

  /* ---------- 7. 弹窗 / 表单：全屏 + 固定底部按钮 ---------- */
  .modal-mask {
    position: fixed;
    inset: 0;
    padding: 0;
    align-items: stretch;
    overflow: hidden;
  }
  .modal {
    width: 100%;
    max-width: none;
    height: 100vh;
    height: 100dvh;
    max-height: 100vh;
    max-height: 100dvh;
    border-radius: 0;
    display: flex;
    flex-direction: column;
  }
  .modal-head {
    flex: 0 0 auto;
    min-height: 52px;
    padding: 10px 12px;
    padding-top: calc(10px + env(safe-area-inset-top, 0px));
    position: sticky;
    top: 0;
    z-index: 3;
    background: var(--card);
  }
  .modal-head h3 { font-size: 14px; line-height: 1.4; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .modal-title-btn { min-height: 40px; margin-left: 8px; padding: 8px 10px; vertical-align: middle; }
  .modal-close {
    flex: 0 0 44px;
    width: 44px;
    height: 44px;
    padding: 0;
    margin-left: auto;
    font-size: 24px;
  }
  .modal-body {
    flex: 1 1 auto;
    min-height: 0;
    padding: 12px;
    overflow: auto;
    -webkit-overflow-scrolling: touch;
  }
  .modal-foot {
    flex: 0 0 auto;
    position: sticky;
    bottom: 0;
    z-index: 3;
    gap: 8px;
    padding: 8px 12px calc(8px + env(safe-area-inset-bottom, 0px));
    background: var(--card);
    border-top: 1px solid var(--line);
    flex-wrap: nowrap;
  }
  .modal-foot .grow { display: none; }
  .modal-foot .btn { flex: 1 1 0; min-width: 0; min-height: 44px; justify-content: center; font-size: 14px; }
  .modal-msg { flex: 1 1 100%; font-size: 11.5px; }
  .modal-foot .modal-msg:empty { display: none; }

  .form-grid { grid-template-columns: 1fr !important; gap: 10px; }
  .form-grid .full, .form-grid .half { grid-column: 1 / -1; }
  .form-item input, .form-item select, .form-item textarea { min-height: 40px; }
  .form-item > label { font-size: 12px; }
  .form-static { min-height: 40px; }
  .calc-box { gap: 6px 16px; padding: 10px 12px; font-size: 12px; }
  .form-block { padding: 10px; }
  .payout-grid { grid-template-columns: 1fr; }
  .split-row {
    grid-template-columns: minmax(0, 1fr) 84px 40px;
    grid-template-areas: "person person person" "rate amt del";
    gap: 6px;
    margin-bottom: 8px;
  }
  .split-row .split-person { grid-area: person; }
  .split-row .split-rate { grid-area: rate; }
  .split-row .split-amt { grid-area: amt; align-self: center; font-size: 11.5px; }
  .split-row .split-del { grid-area: del; }
  .split-row .split-del .btn { min-height: 40px; width: 40px; padding: 0; justify-content: center; }
  .stk-extra-grid { grid-template-columns: 1fr; }
  .img-manager { gap: 8px; }
  .thumbs { gap: 8px; }
  .thumb, .upload-btn { width: 92px; height: 68px; }
  .thumb-del { width: 40px; height: 40px; font-size: 17px; }
  .img-tip { font-size: 11px; line-height: 1.6; }
  .memo-edit { min-height: 90px; }

  .hdr-list { max-height: 48vh; }
  .hdr-row { flex-wrap: wrap; gap: 6px; padding: 8px 10px; }
  .hdr-name { flex: 1 1 120px; min-width: 0; }
  .hdr-type { flex: 0 0 auto; }
  .hdr-w { flex: 0 0 64px; width: 64px; }
  .hdr-ops { margin-left: auto; }
  .hdr-ops .btn { min-height: 40px; padding: 4px 8px; }
  .hdr-add-row { flex-wrap: wrap; }
  .hdr-add-row .hdr-name { flex: 1 1 100%; }
  .hdr-opts { flex: 1 1 100%; }
  .fxcc-row { flex-wrap: wrap; gap: 6px; }
  .fxcc-name { flex: 1 1 100%; }
  .fxcc-formula { flex: 1 1 100%; white-space: normal; }
  .fxcc-in-name, .fxcc-in-formula { flex: 1 1 100%; }
  .fxcc-ops { margin-left: auto; }
  .perm-grid { grid-template-columns: 1fr; }
  .rb-k { flex: 0 0 72px; padding: 7px 8px; }
  .rb-v { padding: 7px 8px; }
  .rb-actions .btn { min-height: 44px; }

  /* 登录 / 提示 / 图片查看器 */
  .login-box { padding: 22px 18px; }
  .login-field input { height: 44px; font-size: 16px; }  /* ≥16px 防止 iOS 自动放大 */
  .viewer { padding: 0; }
  .viewer-close { top: calc(10px + env(safe-area-inset-top, 0px)); right: 10px; width: 44px; height: 44px; }
  .toast-wrap {
    left: 10px;
    right: 10px;
    bottom: calc(10px + env(safe-area-inset-bottom, 0px));
    align-items: stretch;
  }
  .toast { max-width: none; width: 100%; font-size: 13px; }
  .pwa-hint { z-index: 90; }             /* 别挡住模态框 / 提示条 */

  /* 输入框 16px：iOS Safari 聚焦时不会自动放大页面 */
  .modal input[type="text"], .modal input[type="number"],
  .modal input[type="date"], .modal select, .modal textarea,
  .memo-new textarea, .memo-edit, .login-field input { font-size: 16px; }
}

/* ---------- 8. 手机横屏：一行工具条横向滑动，避免筛选吃掉整屏 ---------- */
@media (max-width: 900px) and (orientation: landscape) {
  .topbar { height: 46px; flex-basis: 46px; }
  .undo-panel { top: 46px; }
  main { padding: 6px 6px calc(6px + env(safe-area-inset-bottom, 0px)); }
  .sidebar { flex-direction: column; }
  .side-brand { padding: 10px 10px 8px 12px; }
  .side-nav { flex-direction: column; overflow-x: hidden; overflow-y: auto; }
  .nav-item { min-height: 44px; font-size: 14px; }
  .status-bar, .dvd-cats { padding: 4px 8px; }
  .status-tab, .dvd-cat { min-height: 40px; }
  .toolbar {
    flex-wrap: nowrap;
    overflow-x: auto;
    overflow-y: hidden;
    gap: 8px;
    padding-bottom: 2px;
    -webkit-overflow-scrolling: touch;
  }
  .toolbar > * { flex: 0 0 auto; }
  .toolbar .search { flex: 0 0 220px; min-width: 220px; }
  .toolbar .grow { display: none; }
  .field.inline { flex: 0 0 auto; }
  #page-orders .toolbar, #page-smallOrders .toolbar,
  #page-logs .toolbar, #page-flows .toolbar, #page-dividends .toolbar { padding: 8px 8px 0; }
  #page-orders .toolbar + .toolbar,
  #page-smallOrders .toolbar + .toolbar { padding-top: 6px; }
  .modal-head { min-height: 46px; padding: 6px 12px; }
  .modal-body { padding: 10px 12px; }
  .modal-foot { padding: 6px 12px calc(6px + env(safe-area-inset-bottom, 0px)); }
  .modal-foot .btn { min-height: 40px; }
  .form-grid { gap: 8px 12px; }
  #page-dash .stat .v { font-size: 18px; }
  .stat { padding: 10px 12px; }
}

/* ---------- 10. 平板 / 横屏（600–900px）：卡片两列，别把值甩到屏幕最右 ---------- */
@media (min-width: 600px) and (max-width: 900px) {
  #ordTable tbody tr,
  #smallOrdTable tbody tr {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    column-gap: 20px;
    align-items: start;
  }
  #ordTable tbody td[data-field="id"],
  #smallOrdTable tbody td[data-field="id"],
  #ordTable tbody td.acts,
  #smallOrdTable tbody td.acts { grid-column: 1 / -1; }
  #ordTable tbody td[data-label],
  #smallOrdTable tbody td[data-label] { padding-right: 0 !important; }
}

/* ---------- 11. 手机「列」菜单（复制整列，右键的触屏替代） ---------- */
.colcopy-tip {
  font-size: 12.5px;
  line-height: 1.7;
  color: var(--ink-2);
  background: var(--bg-sunken);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  padding: 9px 11px;
}
.colcopy-list { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.colcopy-row {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--card);
  font-family: inherit;
  font-size: 13px;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
}
.colcopy-row:active { background: var(--brand-soft); border-color: var(--brand); }
.colcopy-name {
  flex: 1 1 auto;
  min-width: 0;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.colcopy-n { flex: 0 0 auto; color: var(--ink-3); font-size: 11.5px; }
.colcopy-go { flex: 0 0 auto; color: var(--brand); font-weight: 600; font-size: 12.5px; }

/* 低高度（横屏手机 390px 高）：抽屉整体滚动，14 个入口 + 数据概况都够得着 */
@media (max-width: 900px) and (max-height: 520px) {
  .sidebar {
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
  .side-nav {
    flex: 0 0 auto;
    overflow: visible;
  }
  .side-foot { flex: 0 0 auto; }
  .side-brand { padding-top: 8px; padding-bottom: 6px; }
}

@media (max-width: 480px) {
  .topbar { height: 50px; flex-basis: 50px; }
  .crumb { font-size: 14px; }
  .user-meta { display: none; }
  #btnReload {
    font-size: 0;
    width: 40px;
    min-width: 40px;
    padding: 0;
    justify-content: center;
  }
  #btnReload::after { content: '↻'; font-size: 19px; line-height: 1; }
  #btnLogout { min-height: 40px; padding: 8px 9px; font-size: 12.5px; }
  #page-orders .toolbar, #page-smallOrders .toolbar,
  #page-logs .toolbar, #page-flows .toolbar, #page-dividends .toolbar { padding: 8px 8px 0; }
  #page-orders .table-meta, #page-smallOrders .table-meta { padding: 8px; }
  #page-orders .pager, #page-smallOrders .pager { padding: 6px 8px 10px; }
  #page-orders .table-wrap, #page-smallOrders .table-wrap { padding: 2px 8px 4px; }
  .form-grid { gap: 8px; }
  .modal-body { padding: 10px; }
  .modal-head { padding: 8px 10px; padding-top: calc(8px + env(safe-area-inset-top, 0px)); }
  .modal-foot { padding: 8px 10px calc(8px + env(safe-area-inset-bottom, 0px)); }
}
/* ===== MOBILE-RESPONSIVE-END ===== */




/* ============================================================================
   PWA 独立窗口（standalone）安全区补丁
   手机端样式把 .topbar 的高度写死成 52 / 46 / 50px，并用了 padding:0 6px，
   会把前面 @supports 里的 env(safe-area-inset-top) 覆盖掉。
   这里在移动块之后用同样的断点把刘海高度加回去：浏览器标签页里 env=0，
   高度和原来一模一样；只有装到桌面后（iOS 刘海 / Android 状态栏）才多出安全区。
   ============================================================================ */
@media (max-width: 900px) {
  .topbar {
    height: calc(52px + env(safe-area-inset-top, 0px));
    flex-basis: calc(52px + env(safe-area-inset-top, 0px));
    padding-top: env(safe-area-inset-top, 0px);
  }
  .sidebar { padding-left: env(safe-area-inset-left, 0px); }
}
@media (max-width: 900px) and (orientation: landscape) {
  .topbar {
    height: calc(46px + env(safe-area-inset-top, 0px));
    flex-basis: calc(46px + env(safe-area-inset-top, 0px));
    padding-top: env(safe-area-inset-top, 0px);
  }
}
@media (max-width: 480px) {
  .topbar {
    height: calc(50px + env(safe-area-inset-top, 0px));
    flex-basis: calc(50px + env(safe-area-inset-top, 0px));
    padding-top: env(safe-area-inset-top, 0px);
  }
}

/* ============================================================================
   手机卡片 V2（2026-11-14）
   用户反馈「我看着好拥挤呀」：本块只重排 ≤900px 的手机卡片。
   · ≤480px：每张卡一个字段一行（标签左、值右），核心金额 17px；
   · 481–900px：订单卡仍是一行一张，次要字段两列（只在展开后）；
   · 桌面（≥1024px）完全不受影响：所有新增节点在桌面 display:none，
     订单卡的手机结构只在 isPhoneView() 为真时生成。
   不碰 .card-grid 的 display / grid-template，不新增表格列。
   ============================================================================ */
.m2-only { display: none; }

@media (max-width: 900px) {
  /* ---------- 类型 / 触控：手机上的正文和可点控件都放大 ---------- */
  .page.active .btn,
  .page.active button,
  .page.active select,
  .page.active input:not([type="checkbox"]):not([type="radio"]),
  .page.active a.btn,
  .topbar button {
    min-height: 44px !important;
  }
  .page.active .btn,
  .page.active .btn-sm {
    font-size: 13.5px;
  }
  .page.active .toolbar {
    align-items: center;
    gap: 10px;
  }
  .page.active .toolbar .field.inline {
    min-width: 0;
  }
  .page.active .toolbar .field.inline > span {
    color: var(--ink-2);
    font-size: 12.5px;
  }
  /* 工具条里的 ghost 按钮也给可见描边：手机上「看起来像文字」的按钮最容易被漏点。 */
  .page.active .toolbar .btn-ghost:not(.filter-toggle) {
    background: var(--card);
    border-color: var(--line-strong);
  }
  .page.active .toolbar select,
  .page.active .toolbar input {
    min-height: 44px;
    font-size: 14px;
  }
  .page.active .table-meta {
    font-size: 13px;
    line-height: 1.75;
  }
  .side-nav .nav-item { min-height: 44px; }
  .drawer-close, .side-foot-gear { min-width: 44px; min-height: 44px; }
  .page.active .pager button,
  .page.active .pager .pg-btn { min-height: 44px !important; }

  /* ---------- 手机状态色：只用于左边线和状态徽章 ---------- */
  .m2-tone-红, .inv-card[data-m2-tone="红"] { --m2-tone:#d9534f; --m2-tone-bg:#fdeceb; --m2-tone-ink:#a13934; --m2-tone-line:#f2c6c2; }
  .m2-tone-绿, .inv-card[data-m2-tone="绿"] { --m2-tone:#5ca85c; --m2-tone-bg:#eaf7ee; --m2-tone-ink:#256f40; --m2-tone-line:#cce6d5; }
  .m2-tone-黄, .inv-card[data-m2-tone="黄"] { --m2-tone:#d9a521; --m2-tone-bg:#fdf6e3; --m2-tone-ink:#7d5b00; --m2-tone-line:#eeda9f; }
  .m2-tone-蓝, .inv-card[data-m2-tone="蓝"] { --m2-tone:#5b7fc7; --m2-tone-bg:#eaf1fc; --m2-tone-ink:#35558f; --m2-tone-line:#c9d8f3; }
  .m2-tone-灰, .inv-card[data-m2-tone="灰"] { --m2-tone:#a8adb5; --m2-tone-bg:#f2f3f5; --m2-tone-ink:#5a6470; --m2-tone-line:#dfe3e9; }
  .m2-tone-粉, .inv-card[data-m2-tone="粉"] { --m2-tone:#d4689b; --m2-tone-bg:#fdeef7; --m2-tone-ink:#974264; --m2-tone-line:#f2cbdd; }

  .m2-status {
    display: inline-flex;
    flex: 0 0 auto;
    align-items: center;
    gap: 7px;
    min-height: 28px;
    padding: 4px 10px;
    border: 1px solid var(--m2-tone-line, #dfe3e9);
    border-radius: 999px;
    background: var(--m2-tone-bg, #f2f3f5);
    color: var(--m2-tone-ink, #5a6470);
    font-size: 12px;
    font-weight: 600;
    line-height: 1.2;
    white-space: nowrap;
    --dot: var(--m2-tone, #a8adb5);
  }
  .m2-status::before { width: 7px; height: 7px; flex-basis: 7px; }

  /* ---------- 库存卡：标题 / 状态 / 金额 / 次要字段 ---------- */
  .card-grid { gap: 12px; }          /* 只调间距，不碰 display / grid-template */
  .inv-card {
    border-left: 4px solid var(--m2-tone, #ced2d8);
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(20, 30, 48, .05);
  }
  .inv-cover {
    height: 92px;
    aspect-ratio: auto;
    margin: 12px 14px 0;
    border-radius: 8px;
  }
  .inv-cover:has(.inv-cover-empty) { display: none; }
  .inv-cover img { object-fit: cover; }
  .inv-count { right: 8px; bottom: 8px; font-size: 11.5px; }
  .inv-body { gap: 0; padding: 14px 14px 12px; }
  .inv-title, .inv-foot { display: none !important; }
  .inv-actions { gap: 10px; padding: 0 14px 14px; }
  .inv-actions .btn { min-height: 46px !important; font-size: 14px !important; }

  .m2-inv-head { display: flex; align-items: flex-start; gap: 10px; }
  .m2-inv-titlemain { flex: 1 1 auto; min-width: 0; }
  .m2-inv-name {
    color: var(--ink);
    font-size: 16px;
    font-weight: 700;
    line-height: 1.35;
    overflow-wrap: anywhere;
  }
  .m2-inv-id {
    margin-top: 3px;
    color: var(--ink-3);
    font-size: 12.5px;
    font-variant-numeric: tabular-nums;
  }

  .m2-money {
    display: flex;
    flex-direction: column;
    margin-top: 12px;
    border-top: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
  }
  .m2-money-row {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    min-height: 44px;
    padding: 10px 0;
    border-bottom: 1px dashed var(--line);
  }
  .m2-money-row:last-child { border-bottom: 0; }
  .m2-money-k {
    flex: 0 0 auto;
    color: var(--ink-3);
    font-size: 12.5px;
    line-height: 1.5;
  }
  .m2-money-v {
    flex: 1 1 auto;
    min-width: 0;
    color: var(--ink);
    font-size: 17px;
    font-weight: 650;
    line-height: 1.35;
    text-align: right;
    font-variant-numeric: tabular-nums;
    overflow-wrap: anywhere;
  }
  .m2-money-v.pos { color: var(--pos); }
  .m2-money-v.neg { color: var(--neg); }
  .m2-money-v.zero { color: var(--ink-2); }
  .m2-money-v.m2-empty { color: var(--ink-3); font-weight: 500; }

  .m2-inv-primary-field { display: none !important; }
  .inv-fields {
    display: none;
    grid-template-columns: minmax(0, 1fr);
    gap: 0;
    margin-top: 12px;
    padding-top: 0;
    border-top: 1px solid var(--line);
  }
  .inv-card.m2-expanded .inv-fields { display: grid; }
  .inv-f {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    min-height: 44px;
    padding: 10px 0;
    border-bottom: 1px solid var(--line);
    line-height: 1.55;
  }
  .inv-f:last-child { border-bottom: 0; }
  .inv-f-k {
    flex: 0 1 auto;
    max-width: 46%;
    color: var(--ink-3);
    font-size: 12.5px;
    white-space: normal;
    overflow: visible;
    text-overflow: clip;
  }
  .inv-f-v {
    flex: 1 1 auto;
    min-width: 0;
    color: var(--ink);
    font-size: 14px;
    text-align: right;
    white-space: normal;
    overflow: visible;
    text-overflow: clip;
    overflow-wrap: anywhere;
  }
  .inv-f-v.num { text-align: right; font-size: 14px; }
  .inv-f-v .tag { font-size: 12px; }
  .inv-f-v a.inv-pz-link { word-break: break-all; }

  .m2-more-wrap { display: block; margin-top: 10px; }
  .m2-more {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    min-height: 46px !important;
    padding: 10px 12px;
    border: 1px solid var(--line-strong);
    border-radius: 10px;
    background: var(--bg-soft);
    color: var(--ink-2);
    font-family: inherit;
    font-size: 13.5px;
    font-weight: 600;
    line-height: 1.3;
    cursor: pointer;
  }
  .m2-more:active { background: var(--bg-sunken); }
  .m2-more-meta { color: var(--ink-3); font-size: 12px; font-weight: 400; }
  .m2-more-caret { font-size: 15px; line-height: 1; transition: transform .15s ease; }
  .m2-more.m2-open .m2-more-caret { transform: rotate(180deg); }

  .bao-badge { margin: 10px 0 0; padding: 9px 10px; gap: 8px; font-size: 13px; }
  .bao-badge-v { font-size: 17px; font-weight: 650; }

  /* ---------- 订单 / 小号：一条记录一张有层次的卡 ---------- */
  #ordTable tbody tr.m2-order-card,
  #smallOrdTable tbody tr.m2-order-card {
    position: relative;
    display: block !important;
    margin: 0 0 12px;
    padding: 14px 14px 12px;
    border: 1px solid var(--line);
    border-left: 4px solid var(--m2-tone, #ced2d8);
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(20, 30, 48, .05);
    overflow: hidden;
  }
  #ordTable tbody tr.m2-order-card:last-child,
  #smallOrdTable tbody tr.m2-order-card:last-child { margin-bottom: 0; }

  #ordTable tbody tr.m2-order-card > td.m2-order-top,
  #smallOrdTable tbody tr.m2-order-card > td.m2-order-top {
    position: static !important;
    display: block !important;
    width: auto !important;
    min-width: 0 !important;
    max-width: none !important;
    min-height: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    border: 0 !important;
    background: transparent !important;
    box-shadow: none !important;
    white-space: normal !important;
    overflow: visible !important;
    text-align: left;
  }
  .m2-ord-head { display: flex; align-items: flex-start; gap: 10px; padding-right: 8px; }
  /* 勾选框在卡片右上角；状态徽章必须整颗露出来，不能被 checkbox 压掉最后一个字。 */
  #ordTable tbody tr.m2-order-card:has(td.pick) .m2-ord-head { padding-right: 56px; }
  .m2-ord-titlemain { flex: 1 1 auto; min-width: 0; }
  .m2-ord-name {
    color: var(--ink);
    font-size: 16px;
    font-weight: 700;
    line-height: 1.35;
    overflow-wrap: anywhere;
  }
  .m2-ord-imgs {
    display: inline-block;
    margin-left: 7px;
    padding: 1px 6px;
    border-radius: 999px;
    background: var(--bg-sunken);
    color: var(--ink-2);
    font-size: 11.5px;
    font-weight: 500;
    vertical-align: 2px;
  }
  .m2-ord-sub {
    display: flex;
    align-items: center;
    gap: 7px;
    margin-top: 3px;
    color: var(--ink-3);
    font-size: 12.5px;
    line-height: 1.5;
  }
  .m2-ord-id { font-variant-numeric: tabular-nums; }
  .m2-ord-sub .tag { font-size: 11.5px; }

  #ordTable tbody tr.m2-order-card > td.m2-primary,
  #smallOrdTable tbody tr.m2-order-card > td.m2-primary { display: none !important; }
  #ordTable tbody tr.m2-order-card > td.m2-secondary,
  #smallOrdTable tbody tr.m2-order-card > td.m2-secondary { display: none !important; }
  #ordTable tbody tr.m2-order-card.m2-expanded > td.m2-secondary,
  #smallOrdTable tbody tr.m2-order-card.m2-expanded > td.m2-secondary {
    position: relative !important;
    display: block !important;
    width: auto !important;
    min-width: 0 !important;
    max-width: none !important;
    min-height: 44px;
    margin: 0 !important;
    padding: 11px 0 11px 104px !important;
    border: 0 !important;
    border-bottom: 1px solid var(--line) !important;
    background: transparent !important;
    box-shadow: none !important;
    color: var(--ink);
    font-size: 14px;
    line-height: 1.55;
    text-align: right;
    white-space: normal !important;
    overflow: visible !important;
    text-overflow: clip !important;
    overflow-wrap: anywhere;
  }
  #ordTable tbody tr.m2-order-card.m2-expanded > td.m2-secondary::before,
  #smallOrdTable tbody tr.m2-order-card.m2-expanded > td.m2-secondary::before {
    content: attr(data-label);
    position: absolute;
    left: 0;
    top: 12px;
    width: 92px;
    color: var(--ink-3);
    font-size: 12.5px;
    font-weight: 400;
    line-height: 1.5;
    text-align: left;
    white-space: normal;
    overflow-wrap: anywhere;
  }

  #ordTable tbody tr.m2-order-card > td.acts,
  #smallOrdTable tbody tr.m2-order-card > td.acts {
    position: static !important;
    display: flex !important;
    flex-wrap: wrap;
    align-items: stretch;
    gap: 10px;
    margin: 0 !important;
    padding: 12px 0 0 !important;
    border: 0 !important;
    border-top: 1px solid var(--line) !important;
    background: transparent !important;
    box-shadow: none !important;
  }
  #ordTable tbody tr.m2-order-card > td.acts .m2-more,
  #smallOrdTable tbody tr.m2-order-card > td.acts .m2-more {
    flex: 1 1 100%;
    order: -1;
    min-height: 46px !important;
    margin-bottom: 2px;
  }
  #ordTable tbody tr.m2-order-card > td.acts .btn,
  #smallOrdTable tbody tr.m2-order-card > td.acts .btn {
    flex: 1 1 0;
    min-width: 0 !important;
    min-height: 46px !important;
    padding: 10px 12px !important;
    font-size: 14px !important;
  }

  #ordTable tbody tr.m2-order-card > td.pick,
  #smallOrdTable tbody tr.m2-order-card > td.pick {
    top: 12px;
    right: 12px;
  }
  #ordTable tbody tr.m2-order-card > td.pick input { width: 24px; height: 24px; }

  /* 订单卡上的金额与库存卡同一套刻度 */
  #ordTable tbody tr.m2-order-card .m2-money,
  #smallOrdTable tbody tr.m2-order-card .m2-money { margin-top: 14px; }

  /* ---------- 列表容器 / 分页：留出卡片间距 ---------- */
  #page-orders .table-wrap,
  #page-smallOrders .table-wrap,
  #page-smallOrders #smallOrdTable {
    padding: 4px 12px 8px;
  }
  #page-orders .pager, #page-smallOrders .pager { padding: 2px 12px 12px; }
  .table-meta { padding-top: 8px; padding-bottom: 8px; }

  /* ---------- 平板 / 横屏：订单卡次要字段两列 ---------- */
  @media (min-width: 481px) {
    #ordTable tbody tr.m2-order-card,
    #smallOrdTable tbody tr.m2-order-card {
      display: grid !important;
      grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
      column-gap: 22px;
    }
    #ordTable tbody tr.m2-order-card > td.m2-order-top,
    #smallOrdTable tbody tr.m2-order-card > td.m2-order-top,
    #ordTable tbody tr.m2-order-card > td.acts,
    #smallOrdTable tbody tr.m2-order-card > td.acts,
    #ordTable tbody tr.m2-order-card > td.pick,
    #smallOrdTable tbody tr.m2-order-card > td.pick { grid-column: 1 / -1; }
    #ordTable tbody tr.m2-order-card.m2-expanded > td.m2-secondary,
    #smallOrdTable tbody tr.m2-order-card.m2-expanded > td.m2-secondary {
      padding: 10px 0 10px 104px !important;
      min-height: 44px;
      font-size: 14px;
    }
    #ordTable tbody tr.m2-order-card.m2-expanded > td.m2-secondary::before,
    #smallOrdTable tbody tr.m2-order-card.m2-expanded > td.m2-secondary::before {
      width: 92px;
      top: 11px;
      font-size: 12.5px;
    }
    #ordTable tbody tr.m2-order-card .m2-money,
    #smallOrdTable tbody tr.m2-order-card .m2-money {
      display: grid;
      grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
      column-gap: 22px;
    }
    #ordTable tbody tr.m2-order-card .m2-money-row:nth-last-child(1):nth-child(odd),
    #smallOrdTable tbody tr.m2-order-card .m2-money-row:nth-last-child(1):nth-child(odd) {
      grid-column: 1 / -1;
    }
  }
}

/* 横屏手机（844×390）：旧规则把工具条设成 nowrap + 横向滚动，结果搜索框被压成
   ~40px、右边按钮被裁掉。这里改成正常换行（控件仍有 44px 触控高度），
   搜索框保底 220px —— 宁可多一行，也不要一个看不清的搜索框。 */
@media (max-width: 900px) and (orientation: landscape) {
  .page.active .toolbar {
    flex-wrap: wrap !important;
    overflow-x: visible !important;
    overflow-y: visible !important;
    gap: 10px;
  }
  .page.active .toolbar .search {
    flex: 1 1 220px !important;
    width: auto !important;
    min-width: 220px !important;
    max-width: 100% !important;
  }
  .page.active .toolbar .field.inline { flex: 0 1 auto; }
  .page.active .toolbar .btn { flex: 0 0 auto; }
}

@media (max-width: 480px) {
  /* 390px：搜索独占一行；筛选项两两一行；按钮两列，保证每个 ≥44px */
  .page.active .toolbar {
    align-items: stretch;
    gap: 10px;
    padding: 10px;
  }
  .page.active .toolbar .search {
    order: -20;
    flex: 1 1 100% !important;
    width: auto !important;
    min-width: 0 !important;
    max-width: none !important;
  }
  /* 有「筛选」按钮的页面：筛选与搜索同一行；没有筛选的页面：搜索独占一行。
     这里用 calc 明确占满「整行 − 76px 筛选按钮 − 10px 间距」，
     后面的排序/方向才会换行，不会把搜索框挤成一条缝。 */
  .page.active .toolbar:has(.filter-toggle) .search {
    flex: 1 1 calc(100% - 96px) !important;
  }
  .page.active .toolbar .btn.filter-toggle {
    order: -21;
    flex: 0 0 76px;
    padding: 8px 6px;
    justify-content: center;
    min-height: 46px !important;
    font-size: 13.5px;
  }
  .page.active .toolbar .field.inline {
    flex: 1 1 calc(50% - 5px);
    align-items: center;
    justify-content: space-between;
    gap: 8px;
  }
  .page.active .toolbar .field.inline select,
  .page.active .toolbar .field.inline input[type="date"],
  .page.active .toolbar .field.inline input[type="number"] {
    flex: 1 1 auto;
    min-width: 0;
    width: auto;
    max-width: 68%;
  }
  .page.active .toolbar .btn {
    flex: 1 1 calc(50% - 8px);
    justify-content: center;
  }
  .page.active .toolbar .btn:not(.btn-primary) {
    background: var(--card);
    border-color: var(--line-strong);
  }
  .page.active .toolbar .grow { display: none; }
  .page.active .toolbar .field.inline.check {
    flex: 0 0 100%;
    justify-content: flex-start;
    gap: 8px;
  }
  .page.active .toolbar .field.inline.check > span { white-space: nowrap; }

  /* 订单 / 小号：第二排的列操作按内容宽度自然换行（不再被拉成 4 行文字）；
     主按钮「新增」始终排在最前，每个按钮都有可见边框。 */
  #page-orders .toolbar + .toolbar,
  #page-smallOrders .toolbar + .toolbar {
    flex-wrap: wrap;
    gap: 8px;
    padding: 10px;
  }
  #page-orders .toolbar + .toolbar > *,
  #page-smallOrders .toolbar + .toolbar > * { flex: 0 0 auto !important; }
  #page-orders .toolbar + .toolbar .btn:not(.btn-primary),
  #page-smallOrders .toolbar + .toolbar .btn:not(.btn-primary) {
    flex: 0 0 auto !important;
    background: var(--card);
    border-color: var(--line-strong);
  }
  #ordAdd, #smallOrdAdd { order: -10; }
  #page-orders .toolbar + .toolbar .grow,
  #page-smallOrders .toolbar + .toolbar .grow { display: none; }

  /* 390px：库存卡字段严格一行一个（标签左 / 值右），与订单卡一致 */
  .m2-money-row { min-height: 46px; padding: 11px 0; }
  .m2-money-v { font-size: 17.5px; }
  .inv-f { min-height: 46px; padding: 11px 0; }
  .m2-inv-name, .m2-ord-name { font-size: 16px; }
  .m2-status { font-size: 12px; }
  .inv-actions .btn, .m2-more { min-height: 48px !important; }
  #ordTable tbody tr.m2-order-card > td.acts .btn,
  #smallOrdTable tbody tr.m2-order-card > td.acts .btn { min-height: 48px !important; }
  .m2-ord-head { padding-right: 28px; }
  .m2-ord-name { padding-right: 0; }
  .inv-cover { height: 84px; }
}

/* ===== MOBILE-CARD-V2-END ===== */






/* ============================================================================
   手机卡片里的「勾选框」隐藏（2026-11-14 用户反馈：孤零零一个大方框，
   夹在金额区和「展开更多」之间，很容易误触）
   手机上没有批量操作，勾选本来就是桌面专用；要恢复：删掉这一段。
   ============================================================================ */
@media (max-width: 900px) {
  /* 真正的选择器：桌面表格里勾选框在 <td class="pick">，
     手机上 td 变成 block 就单独占一行 —— 直接整格隐藏。 */
  td.pick,
  th.pick,
  .pick,
  td[data-label="勾选"],
  td[data-label="选择"],
  tr[data-mobile-card] td.pick,
  .card td.pick,
  .card .pick {
    display: none !important;
  }
  /* 兜底：卡片里任何残留的勾选框（含它所在的一行） */
  .card > input[type="checkbox"],
  .card label > input[type="checkbox"][data-pick],
  label:has(> input[data-pick]) {
    display: none !important;
  }
  label:has(> input[data-pick]) {
    display: none !important;
  }
}
