:root {
  --bg: #f4f6fa; --card: #ffffff; --border: #e3e8f0; --border-2: #eef2f8;
  --text: #1f2937; --muted: #6b7280;
  --primary: #2563eb; --primary-dark: #1d4ed8; --primary-soft: #eff6ff;
  --green: #16a34a; --green-soft: #dcfce7;
  --red: #dc2626; --red-soft: #fee2e2;
  --orange: #d97706; --orange-soft: #fef3c7;
  --sidebar: #1e293b; --sidebar-text: #cbd5e1;
  /* 纵向节奏：模块之间 > 模块内卡片之间 > 卡片内元素之间，三档拉开层次 */
  --gap-mod: 28px; --gap-block: 14px; --gap-tight: 10px;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: "Segoe UI", "Microsoft YaHei", sans-serif; background: var(--bg); color: var(--text); font-size: 14px; }
a { color: var(--primary); text-decoration: none; }
.hidden { display: none !important; }
.muted { color: var(--muted); font-size: 12px; }
.mt8 { margin-top: 8px; } .mt16 { margin-top: 16px; } .mt24 { margin-top: 24px; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }

/* ---------- 登录 ---------- */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg, #1e293b, #2563eb); }
.login-card { background: var(--card); border-radius: 12px; padding: 40px 36px; width: 360px; box-shadow: 0 20px 50px rgba(0,0,0,.3); }
.login-logo { font-size: 24px; font-weight: 700; text-align: center; line-height: 1.35; word-break: break-word; }
.login-sub { text-align: center; color: var(--muted); margin: 6px 0 24px; font-size: 12px; letter-spacing: 1px; }
.login-err { color: var(--red); font-size: 13px; margin-top: 12px; min-height: 18px; text-align: center; }

/* ---------- 布局 ---------- */
#main-view { display: flex; min-height: 100vh; }
.sidebar { width: 214px; background: var(--sidebar); color: var(--sidebar-text); display: flex; flex-direction: column; position: fixed; top: 0; bottom: 0; z-index: 30; }
.brand { padding: 20px 18px; font-size: 17px; font-weight: 700; color: #fff; border-bottom: 1px solid rgba(255,255,255,.08); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#nav { flex: 1; padding: 10px 8px; overflow-y: auto; }
.nav-item { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-radius: 8px; cursor: pointer; margin-bottom: 2px; color: var(--sidebar-text); font-size: 14px; }
.nav-item:hover { background: rgba(255,255,255,.08); }
.nav-item.active { background: var(--primary); color: #fff; }
.nav-group { font-size: 11px; color: #64748b; padding: 12px 14px 4px; letter-spacing: .5px; }
.sidebar-foot { padding: 14px; border-top: 1px solid rgba(255,255,255,.08); font-size: 13px; }
.sidebar-foot #whoami { margin-bottom: 8px; line-height: 1.4; }
.sidebar-foot .foot-btns { display: flex; gap: 6px; }
.sidebar-foot .foot-btns .btn { flex: 1; justify-content: center; padding-left: 0; padding-right: 0; }
.main { flex: 1; margin-left: 214px; padding: 14px 24px 40px; min-width: 0; }

/* ---------- 选项卡 ---------- */
.tabbar-wrap { display: flex; align-items: flex-end; gap: 10px; border-bottom: 1px solid var(--border); margin-bottom: 14px; position: relative; }
.tabbar-wrap .tabbar { flex: 1; min-width: 0; border-bottom: none; margin-bottom: 0; }
.tabbar { display: flex; gap: 6px; align-items: flex-end; overflow-x: auto; overflow-y: hidden; padding: 2px 0 0; margin-bottom: 14px; border-bottom: 1px solid var(--border); min-height: 38px; }
.tabbar::-webkit-scrollbar { height: 4px; }
.tab { display: flex; align-items: center; gap: 6px; padding: 7px 10px 8px 14px; border: 1px solid var(--border); border-bottom: none; border-radius: 9px 9px 0 0; background: #f4f7fb; color: #475569; font-size: 13px; cursor: pointer; white-space: nowrap; max-width: 220px; position: relative; top: 1px; }
.tab:hover { background: #eef3fa; }
.tab.active { background: #fff; color: var(--text); font-weight: 600; border-color: var(--border); box-shadow: 0 -2px 0 var(--primary) inset; }
.tab.dirty .tab-t::after { content: ' •'; color: #d97706; }
.tab-t { overflow: hidden; text-overflow: ellipsis; }
.tab-x { border: none; background: transparent; color: #94a3b8; font-size: 14px; line-height: 1; cursor: pointer; padding: 2px 4px; border-radius: 5px; }
.tab-x:hover { background: #e2e8f0; color: #475569; }
.tab-x.armed { background: var(--red); color: #fff; font-size: 11px; padding: 3px 6px; }
.tab-panes { position: relative; }
.tab-pane { display: none; }
.tab-pane.active { display: block; }
.tab-page { min-width: 0; }

/* 页签栏右侧：批量关闭 */
.tab-tools { display: flex; align-items: center; gap: 5px; padding-bottom: 5px; flex: none; white-space: nowrap; }
.tt-btn { border: 1px solid var(--border); background: #fff; color: #475569; font-size: 12.5px; line-height: 1; padding: 5px 8px; border-radius: 7px; cursor: pointer; display: inline-flex; align-items: center; gap: 3px; }
.tt-btn:hover { background: #f1f5fb; color: var(--text); border-color: #cbd5e1; }
.tt-btn.danger { color: #b91c1c; border-color: #f3c9c9; background: #fef4f4; }
.tt-btn.danger:hover { background: #fde8e8; }
.tt-btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.tt-btn:disabled { opacity: .45; cursor: not-allowed; background: #fff; }
.tt-btn .tt-caret { font-size: 10px; color: #94a3b8; }
.tt-count { font-size: 12.5px; color: var(--muted); }
.tt-count b { color: var(--primary); }
.tab-menu { position: absolute; right: 0; top: calc(100% + 6px); z-index: 70; min-width: 218px; background: #fff; border: 1px solid var(--border); border-radius: 10px; box-shadow: 0 12px 30px rgba(15,23,42,.16); padding: 5px; }
.tm-item { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 8px 10px; border-radius: 7px; font-size: 13px; color: var(--text); cursor: pointer; }
.tm-item:hover { background: #f1f5fb; }
.tm-item.disabled { color: #b9c2d0; cursor: not-allowed; }
.tm-item.disabled:hover { background: transparent; }
.tm-k { font-size: 12px; color: #94a3b8; }
.tm-sep { height: 1px; background: var(--border); margin: 4px 6px; }
.tab.picking { cursor: pointer; }
.tab.picking .tab-t::after { color: #94a3b8; }
.tab.picked { background: var(--primary-soft); border-color: #bfdbfe; color: var(--primary-dark); }
.tab-cb { width: 13px; height: 13px; margin: 0; accent-color: var(--primary); cursor: pointer; flex: none; }

/* ---------- 页头 ---------- */
.page-head { display: flex; align-items: flex-start; justify-content: space-between; flex-wrap: wrap; gap: 12px;
  padding-bottom: 12px; margin-bottom: 20px; border-bottom: 1px solid var(--border); }
.ph-left { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.page-title { font-size: 20px; font-weight: 700; }
.page-sub { color: var(--muted); font-size: 12.5px; }
.back-link { color: var(--muted); font-size: 13px; display: inline-flex; align-items: center; gap: 4px; margin-bottom: 2px; }
.back-link:hover { color: var(--primary); }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.toolbar input, .toolbar select { width: auto; }
.toolbar .sep { width: 1px; height: 22px; background: var(--border); }

/* ---------- 按钮 ---------- */
.btn { padding: 8px 15px; border: none; border-radius: 8px; cursor: pointer; font-size: 14px; background: #e8ecf3; color: var(--text); transition: filter .15s, background .15s; }
.btn:hover { filter: brightness(.97); }
.btn.primary { background: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-dark); filter: none; }
.btn.danger { background: var(--red); color: #fff; }
.btn.ghost { background: #fff; border: 1px solid var(--border); }
.btn.ghost:hover { border-color: #c7d2e0; background: #fafcff; }
.btn.sm { padding: 4px 10px; font-size: 12px; border-radius: 6px; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
/* 条件不满足的「删除」入口：保留按钮，点一下用 toast 说清原因 */
.btn.btn-del-blocked { opacity: .55; cursor: help; }
.btn.armed { background: var(--red) !important; color: #fff !important; border-color: var(--red) !important; }

/* ---------- 卡片 / 网格 ---------- */
.card { background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 18px; margin-bottom: var(--gap-block);
  box-shadow: 0 1px 2px rgba(15,23,42,.035); }
.card h3 { font-size: 15px; margin-bottom: 12px; display: flex; align-items: center; gap: 8px; }
.card > h3 { padding-bottom: 10px; margin-bottom: 14px; border-bottom: 1px solid var(--border-2); }
.card h3 .muted { font-weight: 400; }
.grid { display: grid; gap: var(--gap-block); }
.grid.c2 { grid-template-columns: 1fr 1fr; }
.grid.c3 { grid-template-columns: repeat(3, 1fr); }
.grid.stats { grid-template-columns: repeat(auto-fit, minmax(158px, 1fr)); }
/* 网格里已有 gap，卡片再带 margin-bottom 会把纵向间距撑成横向的两倍 —— 这里统一收掉 */
.grid > .card, .grid > .stat, .grid > .tbl-wrap { margin-bottom: 0; }
.stat { background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 15px 18px;
  box-shadow: 0 1px 2px rgba(15,23,42,.035); }
.stat .label { color: var(--muted); font-size: 12px; }
.stat .value { font-size: 23px; font-weight: 700; margin-top: 6px; }
.stat .value.blue { color: var(--primary); } .stat .value.green { color: var(--green); }
.stat .value.red { color: var(--red); } .stat .value.orange { color: var(--orange); }
.stat .sub { color: var(--muted); font-size: 12px; margin-top: 4px; }

/* ---------- 模块分节 ----------
   页面里「不同内容模块」用 .mod 包一层并给标题：模块之间 26px，
   模块内卡片之间 14px，卡片内元素 10px 左右 —— 三档间距一眼能分出层次。 */
.mod { margin-bottom: var(--gap-mod); }
.mod:last-child { margin-bottom: 0; }
.mod-h { display: flex; align-items: center; gap: 8px; margin: 0 2px var(--gap-tight); }
.mod-h::before { content: ''; flex: none; width: 3px; height: 13px; border-radius: 2px; background: var(--primary); }
.mod-h .mod-t { font-size: 13.5px; font-weight: 700; color: #334155; letter-spacing: .2px; }
.mod-h .mod-s { font-size: 12px; color: var(--muted); }
.mod-h .mod-line { flex: 1 1 auto; height: 1px; background: var(--border); margin-left: 4px; }
.mod-body { display: flex; flex-direction: column; gap: var(--gap-block); }
.mod-body > * { margin-top: 0 !important; margin-bottom: 0 !important; }
.mod-body > .grid { gap: var(--gap-block); }
.mod-body > .grid > .card, .mod-body > .grid > .stat { margin-bottom: 0; }

/* ---------- 表格 ---------- */
/* 网格线：border-collapse 换成 separate + 每格画右/下边框，
   表头 sticky 滚动时边框不会消失，相邻格也不会叠成 2px 双线 */
table.tbl { width: 100%; border-collapse: separate; border-spacing: 0; background: var(--card); }
.tbl th, .tbl td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--border);
  border-right: 1px solid var(--border); white-space: nowrap; }
.tbl th:last-child, .tbl td:last-child { border-right: 0; }
.tbl tbody tr:last-child > td { border-bottom: 0; }
.tbl th { background: #f8fafc; font-size: 12.5px; color: var(--muted); position: sticky; top: 0; z-index: 2; font-weight: 600; }
/* 上下行用极浅的底色区分（画在 td 上，首列 sticky 也能带上背景） */
.tbl tbody tr > td { background: var(--card); }
.tbl tbody tr:nth-child(even) > td { background: #f6f8fb; }
.tbl tbody tr:hover > td { background: #eef5fe; }
.tbl td.wrap { white-space: normal; }
.tbl .actions { display: flex; gap: 6px; flex-wrap: nowrap; white-space: nowrap; }
.tbl .actions .btn { padding: 3px 8px; }
.tbl-wrap { background: var(--card); border: 1px solid var(--border); border-radius: 12px; overflow: auto; max-height: calc(100vh - 300px);
  box-shadow: 0 1px 2px rgba(15,23,42,.035); }
.tag { display: inline-block; padding: 2px 10px; border-radius: 99px; font-size: 12px; line-height: 18px; }
.tag.gray { background: #f1f5f9; color: #475569; }
.tag.blue { background: #dbeafe; color: #1d4ed8; }
.tag.green { background: #dcfce7; color: #15803d; }
.tag.orange { background: #fef3c7; color: #b45309; }
.tag.red { background: #fee2e2; color: #b91c1c; }
.tag.purple { background: #ede9fe; color: #6d28d9; }
/* 操作日志：行内展开的请求参数 */
.lg-detail { margin-top: 4px; }
.lg-detail > summary { cursor: pointer; font-size: 12px; color: var(--muted); list-style: none; }
.lg-detail > summary::-webkit-details-marker { display: none; }
.lg-detail > summary::before { content: '▸ '; }
.lg-detail[open] > summary::before { content: '▾ '; }
.lg-pre { margin: 6px 0 0; padding: 8px 10px; background: #f8fafc; border: 1px solid var(--border);
  border-radius: 8px; font-size: 12px; line-height: 1.5; color: #334155;
  white-space: pre-wrap; word-break: break-all; max-height: 220px; overflow: auto; max-width: 520px; }
.pager { display: flex; align-items: center; gap: 10px; margin-top: 10px; justify-content: flex-end; }
/* 表格 + 分页是同一个模块：表格和分页贴近，模块之间才拉开 */
.list-block > .pager { margin-top: 10px; }
.list-block + .list-block { margin-top: var(--gap-block); }
.pager span { color: var(--muted); font-size: 13px; }
/* 统一分页：信息 / 每页数量 / 页码按钮 / 跳转，窄屏自动换行 */
.pager { flex-wrap: wrap; row-gap: 8px; }
.pager .pager-info { white-space: nowrap; }
.pager .pager-size, .pager .pager-jump { display: inline-flex; align-items: center; gap: 5px; white-space: nowrap; }
.pager .pager-size select { width: auto; height: 30px; padding: 3px 6px; font-size: 13px; }
.pager .pager-nav, .pager .pager-pages { display: inline-flex; align-items: center; gap: 4px; }
.pager .pager-num { min-width: 30px; height: 30px; padding: 0 6px; border: 1px solid var(--border);
  background: #fff; color: var(--text); border-radius: 7px; cursor: pointer; font-size: 13px; }
.pager .pager-num:hover:not(.on) { border-color: var(--primary); color: var(--primary); }
.pager .pager-num.on { background: var(--primary); border-color: var(--primary); color: #fff; font-weight: 600; }
.pager .pager-dots { padding: 0 2px; }
.pager .pager-jump input { width: 56px; height: 30px; padding: 3px 6px; text-align: center; font-size: 13px; }
.empty { text-align: center; color: var(--muted); padding: 36px; }

/* ---------- 表单 ---------- */
.field { margin-bottom: 14px; }
.field label { display: block; margin-bottom: 6px; color: var(--muted); font-size: 13px; }
.field .hint { color: var(--muted); font-size: 12px; margin-top: 5px; }
/* line-height 显式统一：Chromium 下 select 默认内容行高比 input 高约 2px，
   不写死就会出现在同一行的「下拉框比输入框高一截」。明细行另有紧凑规则覆盖回去。 */
input, select, textarea { width: 100%; padding: 9px 12px; border: 1px solid var(--border); border-radius: 8px; font-size: 14px; line-height: 20px; outline: none; background: #fff; color: var(--text); font-family: inherit; }
input[type=date], input[type=datetime-local], input[type=time] { height: 40px; }
/* select 是替换类元素，line-height 压不住它内部那 1px；直接定高才真正等高。
   明细行 / 组合面板 / 账单筛选各有自己的紧凑高度，特异性更高会覆盖这条。 */
select { height: 40px; }
input[type=checkbox], input[type=radio] { line-height: normal; }
input:focus, select:focus, textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,.12); }
input:disabled, select:disabled { background: #f8fafc; color: var(--muted); }
input[type=checkbox], input[type=radio] { width: auto; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.form-grid.c3 { grid-template-columns: repeat(3, 1fr); }
.form-grid.c4 { grid-template-columns: repeat(4, 1fr); }
.form-grid .full { grid-column: 1 / -1; }
.form-grid .span2 { grid-column: span 2; }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; padding-top: 4px; }
.form-section { border-top: 1px solid var(--border); margin-top: 20px; padding-top: 18px; }
.form-section:first-child { border-top: none; margin-top: 0; padding-top: 0; }
.form-section > h3 { font-size: 14px; margin-bottom: 14px; padding-left: 9px; border-left: 3px solid var(--primary);
  border-radius: 2px; line-height: 1.35; }

/* 快速新增伙伴（页面内展开，不弹窗） */
.quick-add { display: flex; gap: 8px; align-items: flex-end; background: var(--primary-soft); border: 1px dashed #bfdbfe; border-radius: 10px; padding: 10px 12px; margin-top: 8px; }
.quick-add .field { margin-bottom: 0; flex: 1; }
.quick-add .field label { font-size: 12px; }

/* 可输入筛选的下拉（客户 / 供应商）：输入框 + 下拉列表，原生 select 只当取值容器 */
.partner-row { display: flex; gap: 8px; align-items: center; }
.partner-row .btn { flex: 0 0 auto; white-space: nowrap; }
.combo { position: relative; flex: 1 1 auto; min-width: 0; }
.combo-input { width: 100%; height: 38px; padding: 0 30px 0 12px; border: 1px solid var(--border);
  border-radius: 8px; font-size: 14px; background: #fff; color: var(--text); }
.combo-input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,.12); }
.combo-arrow { position: absolute; top: 1px; right: 1px; bottom: 1px; width: 26px; border: 0; padding: 0;
  background: transparent; color: var(--muted); cursor: pointer; border-radius: 0 7px 7px 0; font-size: 12px; }
.combo-arrow:hover { color: var(--primary); background: var(--primary-soft); }
.combo-native { position: absolute; left: 0; top: 0; width: 1px; height: 1px; padding: 0; border: 0;
  opacity: 0; pointer-events: none; }
.combo-pop { position: absolute; left: 0; right: 0; top: calc(100% + 4px); z-index: 45; max-height: 264px;
  overflow: auto; background: #fff; border: 1px solid var(--border); border-radius: 10px; padding: 4px;
  box-shadow: 0 14px 34px rgba(15,23,42,.16); }
/* 检索下拉比输入框宽一些，长档案名不折行；「＋新组合」面板与它同名，这里只作用于检索框内 */
.combo > .combo-pop { min-width: 240px; max-width: 340px; }
.combo-item { display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 7px 10px; border-radius: 7px; cursor: pointer; font-size: 13.5px; }
.combo-item:hover, .combo-item.hl { background: var(--primary-soft); }
.combo-item.on { color: var(--primary); font-weight: 600; }
.combo-item .ci-n { min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.combo-item .ci-sub { color: var(--muted); font-size: 12px; font-weight: 400; white-space: nowrap; }
.combo-empty, .combo-more, .combo-foot { padding: 8px 10px; color: var(--muted); font-size: 12px; }
.combo-foot { border-top: 1px dashed var(--border); margin-top: 4px; }

/* ---------- 开单页：商品目录 + 明细 ---------- */
.split { display: grid; grid-template-columns: 228px minmax(0, 1fr); gap: 16px; align-items: start; }
/* 单据信息与「目录 + 明细」是两个模块：卡片底部 14px 之外再留一点，层次才分得开 */
.card + .split { margin-top: 8px; }
.catalog { position: sticky; top: 12px; display: flex; flex-direction: column; max-height: calc(100vh - 90px); margin-bottom: 0; padding: 14px; }
.catalog h3 { margin-bottom: 10px; font-size: 14px; }
.catalog-list { overflow: auto; flex: 1; margin-top: 10px; border-top: 1px solid var(--border-2); }
.cat-item { padding: 8px 4px; border-bottom: 1px solid var(--border-2); cursor: pointer; }
.cat-item:hover { background: var(--primary-soft); }
.cat-item .n { font-weight: 600; font-size: 13px; }
.cat-item .m { color: var(--muted); font-size: 11.5px; margin-top: 2px; display: flex; justify-content: space-between; gap: 8px; }
.cat-target { background: #fff7ed; border: 1px dashed #fdba74; color: #b45309; border-radius: 8px; padding: 7px 10px; font-size: 12.5px; margin-bottom: 8px; display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.lines { margin-bottom: 0; padding: 14px; }
.lines-bar { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; margin-bottom: 10px; }
.lines-bar input { width: 68px; }
/* 批量添加的数字框不要上下箭头，68px 就能完整显示 1000 */
#add-n { -moz-appearance: textfield; }
#add-n::-webkit-outer-spin-button, #add-n::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
/* 明细工具条按钮收一点边距：1280 宽的窗口也能排成一行，不把明细区顶下去 */
.lines-bar .btn.sm { padding: 4px 7px; }
.sticky-bar { position: sticky; bottom: 0; background: rgba(255,255,255,.96); backdrop-filter: blur(4px); border: 1px solid var(--border); border-radius: 12px; padding: 12px 16px; margin-top: 14px; display: flex; justify-content: space-between; align-items: center; gap: 12px; z-index: 6; box-shadow: 0 -6px 18px rgba(15,23,42,.06); }
.sticky-bar .sum { display: flex; gap: 22px; flex-wrap: wrap; font-size: 13px; }
.sticky-bar .sum b { font-size: 15px; }
.sticky-bar .sum .money { color: var(--red); }

/* ---------- 虚拟滚动明细表 ---------- */
/* 虚拟表格：表头固定在明细顶部，只有行内容滚动（行不会被表头切掉半行） */
.vg-body { display: flex; flex-direction: column; overflow: hidden; border: 1px solid var(--border); border-radius: 10px; position: relative; background: #fff; }
.vg-head { position: sticky; top: 0; z-index: 5; flex: 0 0 auto; display: grid; box-sizing: border-box; background: #f8fafc;
  border-bottom: 1px solid var(--border); box-shadow: 0 2px 6px -4px rgba(15,23,42,.28);
  font-size: 12.5px; color: #64748b; font-weight: 600; }
.vg-head > div { padding: 0 8px; height: 40px; display: flex; align-items: center; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vg-head > div.right { justify-content: flex-end; }
.vg-scroll { flex: 1 1 auto; min-height: 0; overflow: auto; position: relative; }
.vg-spacer { position: relative; }
.vg-row { position: absolute; left: 0; right: 0; display: grid; border-bottom: 1px solid #f1f5f9; align-items: center; }
.vg-row:hover { background: #fbfdff; }
.vg-row.is-sel, .vg-row.is-sel:hover { background: #eff6ff; box-shadow: inset 0 0 0 1.5px #3b82f6; }
.vg-row .row-no { cursor: pointer; color: var(--muted); justify-content: flex-start; font-variant-numeric: tabular-nums; }
.vg-row .row-no:hover { color: var(--primary); }
.vg-row .row-no.on { color: var(--primary); font-weight: 700; }
.vg-row > div { padding: 0 8px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; height: 36px; display: flex; align-items: center; }
/* 行内输入框 / 下拉：用负边距把控件自带的内边距抵掉，
   文字正好从 8px 起（和表头同一位置），右边数字也贴到 8px —— 表头与内容一条线 */
.vg-row input, .vg-row select { width: calc(100% + 16px); margin: 0 -8px; padding: 4px 7px;
  border: 1px solid transparent; border-radius: 5px; background: transparent; font-size: 13px;
  line-height: 17px; height: 27px; }
.vg-row input:hover, .vg-row select:hover { border-color: var(--border); }
/* 横向滚动时把操作列钉在右边：删除按钮不用滚才能点到 */
.vg-head-pin { position: absolute; top: 0; right: 0; z-index: 6; display: none;
  background: #f8fafc; border-bottom: 1px solid var(--border); pointer-events: none;
  box-shadow: -8px 0 8px -8px rgba(15,23,42,.3); }
.vg-body.is-x .vg-row > div.op-cell { position: sticky; right: 0; z-index: 3;
  background: #fff; box-shadow: -8px 0 8px -8px rgba(15,23,42,.3); }
.vg-body.is-x .vg-row:hover > div.op-cell { background: #fbfdff; }
.vg-body.is-x .vg-row.is-sel > div.op-cell { background: #eff6ff; }
.vg-body.is-x .vg-row.is-return > div.op-cell { background: #fff7f7; }

/* 明细表尾合计行：与明细共用同一列模板，数量/金额对齐到各自列
   （外面套一层 wrap 负责裁剪，横向滚动时内部跟着平移，列不会错开） */
.vg-foot-wrap { margin-top: 6px; border-radius: 10px; overflow: hidden; }
.vg-foot { display: grid; align-items: center; border: 1px solid var(--border);
  border-top: 2px solid var(--border); border-radius: 10px; background: #f8fafc; font-size: 13px; min-height: 38px; }
.vg-foot > .f-label { padding: 5px 10px; font-weight: 600; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.vg-foot > .f-label .muted { font-weight: 400; font-size: 12px; }
.vg-foot > .f-num { padding: 5px 8px; text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.vg-foot > .f-num.muted { font-weight: 400; color: var(--muted); }
.vg-foot > .f-money { color: var(--red); }
.vg-foot .f-sub { display: block; font-size: 11px; font-weight: 400; color: var(--muted); }
.vg-row input:focus, .vg-row select:focus { border-color: var(--primary); background: #fff; box-shadow: none; }
.vg-row input[type=number] { text-align: right; }
.vg-row .sku-cell { cursor: pointer; border: 1px dashed #cbd5e1; border-radius: 6px; padding: 3px 7px;
  margin: 0 -8px; width: calc(100% + 16px); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vg-row .sku-cell:hover { border-color: var(--primary); background: var(--primary-soft); }
.vg-row.is-return { background: #fff7f7; }
.vg-row.is-return .sku-cell { border-color: #fecaca; }
/* 子项下拉（采购 / 退货）：列窄，字号收到 12px，两个字要完整显示 */
.lt-select { font-size: 12px !important; }
.lt-purchase { color: #1d4ed8; } .lt-return { color: #b91c1c; }
/* 明细行「属性」下拉：可切换同商品的其他型号 */
.vg-row .attr-sel { font-size: 12px !important; border-color: var(--border) !important; background: #fff !important; color: #334155; }
.vg-row .attr-sel:hover { border-color: var(--primary) !important; }
/* 允许空值属性的下拉停在「（空）」时用灰色，和选了值区分开 */
.vg-row .attr-sel.attr-sel-empty { color: var(--muted); }
/* 属性框是「可输入的combobox」：右侧一个小箭头，点输入框即展开全部候选值。
   background 简写在上一条带 !important，所以这里三个子属性也要 !important。 */
.vg-row .attr-sel.attr-combo { padding-right: 17px !important; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%236b7280' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E") !important;
  background-repeat: no-repeat !important; background-position: right 5px center !important; }

/* 属性候选浮层：挂 body 上 fixed 定位（避开虚拟表格 overflow:hidden 裁剪），
   宽度由 JS 设成输入框的宽度，做到「下拉框尺寸跟输入框对齐」。 */
.attr-pop { position: fixed; z-index: 90; display: none; max-height: 264px; overflow: auto;
  background: #fff; border: 1px solid var(--border); border-radius: 8px; padding: 4px;
  box-shadow: 0 14px 34px rgba(15,23,42,.18); }
.attr-pop.on { display: block; }
.attr-pop .ap-item { padding: 6px 9px; border-radius: 6px; font-size: 13px; cursor: pointer;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.attr-pop .ap-item:hover, .attr-pop .ap-item.hl { background: var(--primary-soft); }
.attr-pop .ap-item.on { color: var(--primary); font-weight: 600; }
/* 浮层与输入框等宽，属性列窄时动作项允许折行，别把「＋ 新增值…」截成「＋ 新增...」 */
.attr-pop .ap-item.act { color: var(--primary); margin-top: 3px; padding-top: 7px;
  border-top: 1px dashed var(--border); border-radius: 0 0 6px 6px;
  white-space: normal; font-size: 12px; line-height: 1.35; }
.attr-pop .ap-empty { padding: 8px 9px; color: var(--muted); font-size: 12px; }
.cat-item .n .tag { margin-left: 4px; font-size: 11px; padding: 1px 7px; }

/* ---------- 退货单：可退清单 ---------- */
.pane { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.ret-tabs { display: flex; gap: 6px; margin-bottom: 10px; }
.ret-tabs button { flex: 1; padding: 6px 8px; border: 1px solid var(--border); background: #fff; border-radius: 8px; font-size: 12.5px; color: var(--muted); cursor: pointer; }
.ret-tabs button.on { background: var(--primary-soft); border-color: #bfdbfe; color: var(--primary); font-weight: 600; }
.ret-item { padding: 9px 4px; border-bottom: 1px solid var(--border-2); }
.ret-item .n { font-weight: 600; font-size: 13px; }
.ret-item .m { color: var(--muted); font-size: 11.5px; margin-top: 3px; display: flex; justify-content: space-between; gap: 8px; }
.ret-item .m b { font-size: 12px; }
.ret-item .ret-act { display: flex; gap: 6px; margin-top: 6px; align-items: center; }
.ret-item .ret-act input { width: 62px; padding: 4px 6px; font-size: 12px; }
.ret-item .ret-act button { flex: 1; }
.ret-item .ret-act input:disabled, .ret-item .ret-act button:disabled { opacity: .45; cursor: not-allowed; }
.ret-foot { display: flex; gap: 8px; align-items: center; padding-top: 8px; margin-top: 4px; border-top: 1px solid var(--border-2); font-size: 12px; }

/* ---------- 详情页 ---------- */
.detail-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; }
.detail-no { font-size: 18px; font-weight: 700; letter-spacing: .5px; }
.kv { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px 20px; margin-top: 14px; }
.kv .k { color: var(--muted); font-size: 12px; margin-bottom: 3px; }
.kv .v { font-size: 14px; font-weight: 500; word-break: break-all; }
.detail-totals { display: flex; gap: 26px; flex-wrap: wrap; margin-top: 16px; padding-top: 14px; border-top: 1px dashed var(--border); }
.detail-totals .item .k { color: var(--muted); font-size: 12px; }
.detail-totals .item .v { font-size: 18px; font-weight: 700; margin-top: 2px; }

/* ---------- 权限勾选 ---------- */
.perm-group { border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; margin-bottom: 12px; }
.perm-group > .head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.perm-group .head b { font-size: 13.5px; }
.perm-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.perm-item { display: flex; gap: 8px; align-items: flex-start; padding: 7px 9px; border-radius: 8px; cursor: pointer; border: 1px solid transparent; }
.perm-item:hover { background: #f8fafc; border-color: var(--border); }
.perm-item input { margin-top: 3px; }
.perm-item .name { font-size: 13px; }
.perm-item .desc { color: var(--muted); font-size: 11.5px; margin-top: 1px; }
.role-card { border: 1px solid var(--border); border-radius: 12px; padding: 16px; background: var(--card); display: flex; flex-direction: column; gap: 8px; }
.role-card .role-name { font-weight: 700; font-size: 15px; display: flex; align-items: center; gap: 8px; }
.role-card .perm-tags { display: flex; flex-wrap: wrap; gap: 5px; min-height: 24px; }

/* ---------- 其它 ---------- */
.chart-box { position: relative; height: 268px; }
/* 报表中心「商品价格走势」卡片标题右侧的商品选择器 */
.rp-prod-box { float: right; width: 260px; margin: -4px 0 0 12px; }
.rp-prod-box .combo { font-size: 13px; }
/* 规格选择：同一机型不同品质/带框价差很大，和商品选择并排放 */
.rp-combo-box { float: right; margin: -4px 0 0 12px; }
.rp-combo-box select { font-size: 12.5px; padding: 5px 8px; border: 1px solid var(--border); border-radius: 7px; background: #fff; color: #334155; max-width: 210px; }
.rp-period-box { float: right; margin: -4px 0 0 12px; }
.rp-period-box .seg button { border: 1px solid var(--border); border-radius: 7px; background: #fff; padding: 5px 12px; font-size: 12.5px; color: var(--muted); cursor: pointer; }
.rp-period-box .seg button + button { margin-left: -1px; }
.rp-period-box .seg button:hover { background: #f1f5f9; }
.rp-period-box .seg button.on { background: var(--primary); border-color: var(--primary); color: #fff; font-weight: 600; }
@media (max-width: 720px) {
  .rp-prod-box { float: none; width: 100%; margin: 8px 0 0; }
  .rp-combo-box { float: none; display: inline-block; margin: 8px 0 0; }
  .rp-period-box { float: none; display: inline-block; margin: 8px 0 0; }
}
.toast { position: fixed; top: 20px; left: 50%; transform: translateX(-50%); background: #1e293b; color: #fff; padding: 10px 22px; border-radius: 10px; z-index: 200; font-size: 14px; box-shadow: 0 8px 24px rgba(0,0,0,.25); max-width: 70vw; }
.toast.err { background: var(--red); }
.toast.warn { background: #b45309; }
.tree-item { padding: 7px 8px; border-radius: 6px; cursor: pointer; display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.tree-item:hover { background: #f1f5f9; }
.tree-item.active { background: #dbeafe; color: var(--primary-dark); }
.attr-row { display: flex; gap: 6px; align-items: center; margin-bottom: 6px; flex-wrap: wrap; }
.attr-row input { width: auto; }
/* 「允许空值」勾选：一行里横向排，不占满 */
.attr-empty-sw { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; white-space: nowrap; cursor: pointer; }
.tag-box { display: flex; flex-wrap: wrap; gap: 6px; padding: 10px; background: #f8fafc; border: 1px dashed var(--border); border-radius: 10px; min-height: 42px; }
.tag-box .tag a { color: inherit; text-decoration: none; margin-left: 6px; opacity: .6; font-weight: 700; }
.tag-box .tag a:hover { opacity: 1; }
.pick-list { margin-top: 8px; max-height: 220px; overflow: auto; border: 1px solid var(--border); border-radius: 10px; }
/* 商品库里没有的名字：直接新建并加入本组 */
.create-line { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 8px; padding: 8px 10px;
  border: 1px dashed #93c5fd; border-radius: 10px; background: var(--primary-soft); }
.create-line .muted { font-size: 12px; }
.pick-item { display: flex; align-items: center; gap: 8px; padding: 7px 10px; border-bottom: 1px solid #f1f5f9; cursor: pointer; font-size: 13px; }
.pick-item:hover { background: var(--primary-soft); }
.pick-item input { width: auto; }
.pick-item span:nth-child(2) { flex: 1; }
.pagination-bar { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 9px; overflow: hidden; background: #fff; }
.seg a { padding: 7px 14px; font-size: 13px; color: var(--muted); border-right: 1px solid var(--border); }
.seg a:last-child { border-right: none; }
.seg a.active { background: var(--primary); color: #fff; }
.seg a:hover { background: #f1f5f9; }
.seg a.active:hover { background: var(--primary); }
.source-panel { border: 1px solid var(--border); border-radius: 10px; padding: 12px; margin-top: 8px; background: #f8fafc; }
.source-list { max-height: 200px; overflow: auto; margin-top: 8px; border: 1px solid var(--border); border-radius: 8px; background: #fff; }
.source-item { padding: 8px 10px; border-bottom: 1px solid #f1f5f9; cursor: pointer; font-size: 13px; display: flex; justify-content: space-between; gap: 10px; }
.source-item:hover { background: var(--primary-soft); }

/* ---------- 系统设置 ---------- */
.set-list { display: flex; flex-direction: column; gap: 2px; margin-top: 8px; }
.set-row { display: flex; align-items: center; justify-content: space-between; gap: 20px;
  padding: 14px 4px; border-bottom: 1px solid var(--border-2); }
.set-row:last-child { border-bottom: 0; }
.set-main { flex: 1; min-width: 0; }
.set-label { font-weight: 600; font-size: 14px; margin-bottom: 3px; }
.set-main .muted { font-size: 12.5px; line-height: 1.6; }
.switch { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; user-select: none;
  font-size: 13px; color: var(--muted); white-space: nowrap; }
.switch input { width: 42px; height: 22px; appearance: none; background: #cbd5e1; border-radius: 99px;
  position: relative; cursor: pointer; transition: background .18s; margin: 0; padding: 0; flex: none; }
.switch input::after { content: ''; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px;
  background: #fff; border-radius: 50%; transition: transform .18s; box-shadow: 0 1px 3px rgba(0,0,0,.2); }
.switch input:checked { background: var(--primary); }
.switch input:checked::after { transform: translateX(20px); }

/* ---------- 系统设置 · 数据维护 ---------- */
.mt-scopes { display: flex; flex-direction: column; gap: 10px; margin-top: 12px; }
.mt-scope { border: 1px solid var(--border); border-radius: 10px; padding: 14px 16px; background: #fcfdff; }
.mt-scope-hd { display: flex; align-items: center; gap: 10px; }
.mt-scope-hd b { font-size: 14px; }
.mt-scope-desc { font-size: 12.5px; line-height: 1.65; margin: 6px 0 10px; max-width: 760px; }
.mt-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.mt-chip { display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: 6px;
  background: #f1f5f9; font-size: 12px; color: #475569; }
.mt-chip b { font-weight: 700; color: var(--text); font-variant-numeric: tabular-nums; }
.mt-scope-ft { display: flex; align-items: center; gap: 12px; margin-top: 12px; }
.mt-scope-ft .muted { font-size: 12px; }
.mt-bk { margin-top: 18px; border-top: 1px solid var(--border-2); padding-top: 14px; }
.mt-bk-hd { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.mt-bk-hd .muted { font-size: 12px; }
.mt-bk-hd .btn { margin-left: auto; }
.mt-bk-row { display: flex; align-items: center; gap: 10px; padding: 7px 2px;
  border-bottom: 1px dashed var(--border-2); font-size: 13px; }
.mt-bk-row:last-child { border-bottom: 0; }
.mt-bk-time { font-variant-numeric: tabular-nums; color: #475569; min-width: 152px; }
.mt-bk-act { margin-left: auto; display: flex; gap: 6px; }
.mt-empty { font-size: 12.5px; padding: 6px 2px; }
.mt-tip { font-size: 12px; line-height: 1.7; margin-top: 12px; }
.mt-err { color: var(--red); font-size: 13px; }
.mt-confirm-list { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 8px; font-size: 13px; color: #475569; }
.mt-confirm-list b { color: var(--text); }

@media (max-width: 1180px) {
  .split { grid-template-columns: 1fr; }
  .catalog { position: static; max-height: 320px; }
}
@media (max-width: 900px) {
  .grid.c2, .grid.c3, .form-grid, .form-grid.c3, .form-grid.c4, .perm-grid { grid-template-columns: 1fr; }
  .form-grid .span2 { grid-column: 1 / -1; }
  .main { padding: 16px; }
  .sidebar { width: 60px; }
  .sidebar .brand, .sidebar-foot #whoami, .nav-group { display: none; }
  .sidebar-foot .foot-btns { flex-direction: column; gap: 4px; }
  .sidebar-foot .foot-btns .btn { font-size: 11px; }
  .nav-item { justify-content: center; padding: 12px 0; font-size: 18px; }
  .nav-item span.t { display: none; }
  .main { margin-left: 60px; }
}

/* 拆单页 */
.split-tip { background: #eff6ff; border: 1px solid #bfdbfe; color: #1e40af; border-radius: 10px;
  padding: 10px 14px; font-size: 13px; line-height: 1.6; margin-bottom: 14px; }

/* 导入页 */
.import-bar { display: flex; gap: 12px; align-items: center; margin: 14px 0; flex-wrap: wrap; }
.import-bar input[type=file] { border: 1px dashed #cbd5e1; border-radius: 10px; padding: 8px 12px; background: #f8fafc; font-size: 13px; }
.import-sum { display: flex; gap: 20px; align-items: center; flex-wrap: wrap; font-size: 13px;
  background: #f8fafc; border: 1px solid var(--border); border-radius: 10px; padding: 10px 14px; margin-bottom: 12px; }
.import-sum b { font-size: 15px; }

/* ---------- 属性独立展示：开关 / chip ---------- */
.attr-switch { display: inline-flex; border: 1px solid var(--border); border-radius: 9px; overflow: hidden; background: #fff; }
.attr-switch .sw-opt { border: 0; background: #fff; padding: 8px 16px; font-size: 13px; color: var(--muted);
  cursor: pointer; border-right: 1px solid var(--border); transition: background .15s, color .15s; }
.attr-switch .sw-opt:last-child { border-right: 0; }
.attr-switch .sw-opt:hover { background: var(--primary-soft); }
.attr-switch .sw-opt.on { background: var(--primary); color: #fff; font-weight: 600; }

.attr-chips { display: flex; flex-wrap: wrap; gap: 4px; }
.attr-chip { display: inline-flex; align-items: center; gap: 4px; font-size: 11.5px; line-height: 1.6;
  padding: 1px 7px; border-radius: 6px; background: #f1f5f9; color: var(--muted); white-space: nowrap; }

/* ---------- 属性组合单独定价（同机型不同品质 / 带框各一个价） ---------- */
.var-price-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px;
  margin-bottom: 8px; flex-wrap: wrap; }
.var-price-bar .muted { font-size: 12px; line-height: 1.6; }
.vp-in { width: 108px; text-align: right; padding: 5px 8px; font-size: 13px; }
.vp-in::placeholder { color: #cbd5e1; }
.attr-chip b { color: var(--text); font-weight: 600; }
.attr-chip.muted { opacity: .6; }

/* 库存组合 */
.combo-chips { display: flex; flex-wrap: wrap; gap: 5px; }
.combo-chip { display: inline-flex; align-items: center; gap: 6px; font-size: 11.5px; line-height: 1.7;
  padding: 2px 8px; border-radius: 7px; background: #f1f5f9; border: 1px solid var(--border-2); white-space: nowrap; }
.combo-chip .cc-name { color: var(--muted); }
.combo-chip b { color: var(--text); font-weight: 700; }
.combo-chip.low { background: var(--orange-soft); border-color: #fde68a; }
.combo-chip.low b { color: var(--orange); }
.combo-chip.neg { background: var(--red-soft); border-color: #fecaca; }
.combo-chip.neg b { color: var(--red); }
.combo-chips.big .combo-chip { font-size: 12.5px; padding: 4px 10px; }

/* 商品组：属性维度（分类做母版，本组可增删） */
.def-bar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.def-add-box { display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 10px 12px; margin-bottom: 10px; border: 1px dashed #bfdbfe; border-radius: 10px; background: #f8fbff; }
.def-list { display: flex; flex-direction: column; gap: 6px; }
.def-item { display: flex; align-items: center; gap: 10px; padding: 7px 10px; font-size: 12.5px;
  border: 1px solid var(--border-2); border-radius: 9px; background: #f8fafc; }
.def-item.own { background: #f5f9ff; border-color: #dbeafe; }
.def-item .def-name { font-weight: 700; min-width: 76px; flex: none; }
.def-item .def-opts { display: flex; flex-wrap: wrap; gap: 4px; flex: 1; min-width: 0; }
.def-item .def-opt { padding: 1px 8px; border-radius: 6px; background: #fff;
  border: 1px solid var(--border); font-size: 11.5px; color: #334155; }
.def-item .tag { flex: none; }
/* 固定尺寸的「×」图标按钮：不允许被 flex 挤压，也不允许往里塞长文案 */
.def-item .def-del { flex: none; width: 24px; height: 24px; padding: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 15px; line-height: 1; white-space: nowrap; overflow: hidden;
  border: 1px solid var(--border); border-radius: 5px;
  background: #fff; color: var(--muted); cursor: pointer; }
.def-item .def-del:hover { border-color: var(--red); color: var(--red); background: var(--red-soft); }
.def-item .def-del:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
/* 组合表里还没保存的空白行 */
.tbl tbody tr.row-new > td { background: #f5f9ff; }
.tbl tbody tr.row-new:hover > td { background: #eaf3ff; }
.tbl select.c-attr.need { border-color: #fca5a5; background: #fff7f7; color: #b91c1c; }
.combo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 8px; }
.combo-cell { border: 1px solid var(--border); border-radius: 9px; padding: 8px 10px; background: #f8fafc; }
.combo-cell .cc-t { font-size: 12.5px; color: var(--text); margin-bottom: 6px; }
.combo-cell .cc-q { width: 100%; height: 30px; text-align: right; }

/* 批量新增商品：组合勾选面板 */
.batch-panel { margin-top: 12px; padding: 14px; border: 1px solid var(--border); border-radius: 12px; background: #fbfdff; }
.batch-head { display: flex; align-items: center; gap: 10px; margin: 12px 0 8px; font-size: 13px; }
.batch-head a { color: var(--primary); }
.combo-grid.pick { max-height: 300px; overflow: auto; }
.combo-grid.pick .pick-cell { display: flex; align-items: center; gap: 8px; cursor: pointer; padding: 7px 10px; }
.combo-grid.pick .pick-cell .cc-t { margin: 0; }
.pick-cell.on { border-color: var(--primary); background: var(--primary-soft); }

/* ---------- 明细行：逐项属性 + 行操作 ---------- */
.vg-row .row-attrs { display: flex; align-items: center; gap: 4px; overflow: hidden; flex-wrap: nowrap; width: 100%; }
.vg-row .row-attrs .attr-chip { flex: none; }
.vg-row .row-attrs .attr-sel { width: auto; max-width: 70px; min-width: 42px; padding: 3px 4px; flex: none; }
.vg-row .row-attrs .attr-switch { flex: none; }
.attr-switch.sm .sw-opt { padding: 3px 8px; font-size: 11.5px; }
.row-ops { display: flex; gap: 2px; align-items: center; }
.row-ops .op { width: 25px; height: 25px; padding: 0; border: 1px solid var(--border); background: #fff;
  border-radius: 5px; color: var(--muted); cursor: pointer; font-size: 13px; line-height: 1;
  display: inline-flex; align-items: center; justify-content: center; }
.row-ops .op:hover:not(:disabled) { border-color: var(--primary); color: var(--primary); background: var(--primary-soft); }
.row-ops .op:disabled { opacity: .3; cursor: not-allowed; }
.row-ops .op.del:hover { border-color: var(--red); color: var(--red); background: var(--red-soft); }

/* 明细行：商品名后的规格、两值属性开关、属性区横向可滚 */
.spec-mini { margin-left: 6px; font-size: 11.5px; color: var(--muted); font-weight: 400; }
.vg-row .row-attrs { overflow-x: auto; overflow-y: hidden; scrollbar-width: thin; }
.vg-row .row-attrs::-webkit-scrollbar { height: 3px; }
.vg-row .row-attrs::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 3px; }
/* 两值开关与同行的输入框等高（27px），不再矮一截 */
.attr-toggle { flex: none; height: 27px; padding: 0 8px; border-radius: 6px; font-size: 11.5px;
  border: 1px solid var(--border); background: #fff; color: #334155; cursor: pointer; white-space: nowrap; }
.attr-toggle.on { border-color: #bfdbfe; background: var(--primary-soft); color: var(--primary); }
.attr-toggle.off { border-color: var(--border); background: #f8fafc; color: var(--muted); }
.attr-toggle:hover { border-color: var(--primary); }

/* ---------- 供应商供货品牌（采购单头部） ---------- */
.brand-hint { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 8px; font-size: 12px; }
.brand-tag { display: inline-block; padding: 1px 9px; border-radius: 99px; font-size: 12px; line-height: 18px;
  background: #eff6ff; color: #1d4ed8; border: 1px solid #bfdbfe; white-space: nowrap; }

/* ---------- 明细「＋ 新组合」面板 ---------- */
.combo-pop { border: 1px solid #bfdbfe; background: var(--primary-soft); border-radius: 12px;
  padding: 10px 12px; margin-bottom: 10px; display: flex; flex-direction: column; gap: 8px; }
.combo-pop.hidden { display: none; }
.cp-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 12.5px; }
.cp-row > label { color: var(--muted); min-width: 34px; }
.cp-row select, .cp-row input { height: 28px; border: 1px solid var(--border); border-radius: 7px;
  background: #fff; padding: 0 8px; font-size: 12.5px; }
.cp-row select { max-width: 240px; }
.cp-attrs { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; flex: 1 1 auto; }
.cp-attr { display: inline-flex; flex: 0 0 auto; align-items: center; gap: 5px; background: #fff;
  border: 1px solid var(--border); border-radius: 9px; padding: 4px 8px; }
.cp-attr b { font-size: 12px; color: var(--text); font-weight: 600; white-space: nowrap; }
.cp-attr select { max-width: 110px; border: 1px solid var(--border-2); }
.cp-attr input[data-new] { width: 72px; }

/* ---------- 仪表盘：销售单状态卡 ---------- */
.status-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin-top: 12px; }
.status-card { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border: 1px solid var(--border);
  border-radius: 10px; background: #f8fafc; text-decoration: none; color: inherit; transition: border-color .15s, background .15s; }
.status-card:hover { border-color: var(--primary); background: var(--primary-soft); }
.status-card b { font-size: 17px; font-weight: 700; }
.status-card .muted { font-size: 12px; }

/* ---------- 明细操作列：四个按钮不能被裁掉 ---------- */
.vg-row > div.op-cell { padding: 0 6px; overflow: visible; justify-content: flex-end; }
.row-ops { flex-wrap: nowrap; }

/* ---------- 确认弹窗（关闭有修改的页签等） ---------- */
.modal-mask { position: fixed; inset: 0; background: rgba(15,23,42,.38); z-index: 999;
  display: flex; align-items: center; justify-content: center; padding: 20px;
  animation: fade-in .12s ease-out; }
.modal-mask.out { animation: fade-out .12s ease-in forwards; }
.modal { width: 100%; max-width: 420px; background: #fff; border-radius: 14px;
  box-shadow: 0 20px 50px rgba(15,23,42,.22); overflow: hidden;
  animation: pop-in .14s cubic-bezier(.2,.8,.3,1); }
.modal-hd { display: flex; align-items: center; gap: 9px; padding: 16px 18px 4px; }
.modal-hd .mi { width: 30px; height: 30px; flex: none; border-radius: 50%; display: inline-flex;
  align-items: center; justify-content: center; font-size: 15px; background: #eff6ff; color: #1d4ed8; }
.modal-hd .mi.warn { background: #fef3c7; color: #b45309; }
.modal-hd .mi.danger { background: var(--red-soft, #fee2e2); color: var(--red, #dc2626); }
.modal-hd b { font-size: 15px; }
.modal-bd { padding: 6px 18px 4px 57px; color: #475569; font-size: 13px; line-height: 1.7; }
.modal-bd .modal-note { margin-top: 6px; font-size: 12px; color: var(--muted); }
.modal-ft { display: flex; justify-content: flex-end; gap: 10px; padding: 14px 18px 16px; }
.modal-ft .btn { min-width: 78px; justify-content: center; }
/* 确认弹窗默认聚焦确定键：给个明显轮廓，提示按回车即可确认 */
.modal-ft .btn:focus { outline: 3px solid rgba(37,99,235,.55); outline-offset: 2px; }
/* 输入弹窗：新增属性值等要填短文本的场景 */
.modal-label { display: block; margin-top: 8px; font-size: 12px; color: var(--muted); }
.modal-input { width: 100%; margin-top: 6px; padding: 8px 10px; border: 1px solid var(--border);
  border-radius: 8px; font-size: 13px; outline: none; background: #fff; }
.modal-input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,.12); }
/* 表单弹窗（修改密码）：字段说明 + 行内错误提示 */
.modal-bd-form { padding: 4px 20px 2px; }
.modal-input.bad { border-color: var(--red); }
.modal-err { min-height: 18px; margin-top: 8px; font-size: 12px; color: var(--red); }
.modal-tip { margin-top: 4px; font-size: 12px; color: var(--muted); }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes fade-out { from { opacity: 1; } to { opacity: 0; } }
@keyframes pop-in { from { opacity: 0; transform: translateY(6px) scale(.98); } to { opacity: 1; transform: none; } }

/* ---------- 账单：维度切换 + 往来单位 ---------- */
.bill-bar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.bill-bar .seg { display: inline-flex; border: 1px solid var(--border); border-radius: 9px; overflow: hidden; background: #fff; }
.bill-bar .seg button { border: none; background: transparent; padding: 6px 12px; font-size: 12.5px;
  color: var(--muted); cursor: pointer; white-space: nowrap; }
.bill-bar .seg button + button { border-left: 1px solid var(--border); }
.bill-bar .seg button.on { background: var(--primary-soft); color: var(--primary); font-weight: 600; }
.bill-bar select#b-partner { min-width: 200px; max-width: 250px; height: 32px; padding: 0 8px;
  line-height: 30px; flex: 0 0 auto; }
.tbl tr.link-row { cursor: pointer; }
.tbl tr.link-row:hover td { background: var(--primary-soft); }
.bill-tip { margin: 0 0 10px; padding: 8px 12px; border-radius: 9px; font-size: 12.5px;
  background: #f8fafc; border: 1px solid var(--border); color: #475569; }

/* 新组合面板：新增属性维度 */
.cp-attr.new-dim { border-style: dashed; border-color: #93c5fd; background: #f8fbff; }
.cp-attr .cp-x { border: none; background: transparent; color: #94a3b8; cursor: pointer;
  font-size: 13px; line-height: 1; padding: 2px 3px; border-radius: 4px; }
.cp-attr .cp-x:hover { background: var(--red-soft, #fee2e2); color: var(--red, #dc2626); }

/* ============================================================
   手机端（<=720px）：顶栏 + 侧栏抽屉 + 单列主区
   放在文件末尾，用来覆盖上面 900px / 1180px 的桌面收缩规则
   （390px 同时命中 900px 和这里的规则，后者后定义所以生效）。
   只改布局与触控尺寸，不动任何业务结构与 class 名。
   ============================================================ */
.mobile-bar { display: none; }
.sidebar-mask { display: none; }

@media (max-width: 720px) {
  body { overflow-x: hidden; }
  body.nav-open { overflow: hidden; }

  /* 顶栏 */
  .mobile-bar { display: flex; align-items: center; gap: 8px; position: fixed;
    top: 0; left: 0; right: 0; height: 52px; z-index: 40; padding: 0 10px;
    background: var(--sidebar); color: #fff; box-shadow: 0 2px 8px rgba(15,23,42,.18); }
  .mb-menu { flex: none; width: 40px; height: 40px; border: 0; border-radius: 9px;
    background: rgba(255,255,255,.1); color: #fff; font-size: 20px; line-height: 1;
    cursor: pointer; display: flex; align-items: center; justify-content: center; }
  .mb-menu:active { background: rgba(255,255,255,.22); }
  .mb-title { min-width: 0; font-size: 15px; font-weight: 700; white-space: nowrap;
    overflow: hidden; text-overflow: ellipsis; }

  /* 侧栏抽屉：恢复被 900px 规则隐藏掉的标题 / 分组 / 菜单文字 */
  .sidebar { left: 0; width: 270px; z-index: 60; transform: translateX(-100%);
    transition: transform .22s ease; box-shadow: 8px 0 28px rgba(15,23,42,.28); }
  .sidebar.open { transform: translateX(0); }
  .sidebar .brand { display: block; font-size: 15px; padding: 16px; }
  .sidebar-foot #whoami { display: block; }
  .nav-group { display: block; }
  .nav-item { justify-content: flex-start; padding: 12px 14px; font-size: 15px; }
  .nav-item span.t { display: inline; }
  .sidebar-foot .foot-btns { flex-direction: row; gap: 6px; }
  .sidebar-foot .foot-btns .btn { font-size: 12px; }
  .sidebar-mask { display: block; position: fixed; inset: 0; z-index: 50;
    background: rgba(15,23,42,.45); opacity: 0; pointer-events: none; transition: opacity .22s ease; }
  .sidebar-mask.on { opacity: 1; pointer-events: auto; }

  /* 主区：不再给侧栏留 60px，顶部让出顶栏高度 */
  .main { margin-left: 0; padding: 62px 12px 32px; }
  .tabbar-wrap { margin-bottom: 10px; }
  .tab { max-width: 150px; padding: 8px 8px 8px 11px; font-size: 12.5px; }
  .tab-tools .tt-btn { font-size: 11.5px; padding: 6px 7px; min-height: 32px; }
  .tab-tools .tt-count { display: none; }
  .tab-menu { right: 0; min-width: 200px; }

  /* 登录 */
  .login-card { width: calc(100vw - 32px); max-width: 360px; padding: 26px 22px; }

  /* 卡片 / 页头 / 工具条 */
  .card { padding: 14px; border-radius: 10px; }
  .page-head { margin-bottom: 14px; padding-bottom: 10px; gap: 10px; }
  .page-title { font-size: 18px; }
  .toolbar { gap: 6px; }
  .toolbar > * { min-width: 0; }
  .toolbar .sep { display: none; }
  .mod { margin-bottom: 20px; }

  /* 触控尺寸；输入框 16px 防 iOS 聚焦时整页自动放大 */
  input, select, textarea { font-size: 16px; }
  .combo-input, .modal-input { font-size: 16px; }
  .btn { min-height: 40px; padding: 9px 14px; }
  .btn.sm { min-height: 34px; padding: 6px 10px; }
  .tab-x { padding: 6px 8px; font-size: 16px; }
  .def-item .def-del { width: 30px; height: 30px; }
  .attr-switch .sw-opt { padding: 9px 14px; }
  .toast { max-width: calc(100vw - 24px); top: 62px; }

  /* 表格保持横向可滑，别把整页撑宽 */
  .tbl-wrap { max-height: 62vh; -webkit-overflow-scrolling: touch; position: relative; }
  .tbl th, .tbl td { padding: 9px 10px; }
  /* 首列钉住：横向滑到「数量 / 操作」列时，还能对上这一行是哪个商品 */
  .tbl th:first-child, .tbl td:first-child { position: sticky; left: 0; z-index: 3; }
  .tbl th:first-child { z-index: 4; }
  .tbl td:first-child { box-shadow: 2px 0 5px -3px rgba(15,23,42,.35); }
  /* 明确提示表格可左右滑，否则右侧的关键列容易被当成「没有」 */
  .tbl-wrap::after {
    content: '表格可左右滑动'; position: sticky; bottom: 0; left: 0;
    display: block; width: 100%; box-sizing: border-box; text-align: center;
    padding: 6px 0; font-size: 11px; color: var(--muted);
    background: rgba(248,250,252,.97); border-top: 1px solid var(--border);
    pointer-events: none;
  }
  .pager { flex-wrap: wrap; justify-content: center; }
  .vg-scroll, .row-attrs, .catalog-list, .combo-pop { -webkit-overflow-scrolling: touch; }

  /* 表单与各类横排工具条 */
  .field { margin-bottom: 12px; }
  .form-actions { justify-content: stretch; }
  .form-actions .btn { flex: 1; }
  .quick-add, .partner-row, .import-bar, .ret-foot, .mt-bk-row, .mt-scope-ft { flex-wrap: wrap; }
  .quick-add .field, .partner-row .combo { min-width: 100%; }
  .quick-add .btn, .partner-row .btn { min-width: 100%; }
  .bill-bar { gap: 8px; }
  .bill-bar select#b-partner { min-width: 0; max-width: 100%; width: 100%; }
  .bill-bar input[type=date] { flex: 1 1 130px; }

  /* 开单页：目录在上、明细在下，目录别占半屏 */
  .split { gap: 12px; }
  .catalog { max-height: 230px; }
  .lines { padding: 12px; }
  .lines-bar input { width: 76px; }
  .sticky-bar { flex-direction: column; align-items: stretch; gap: 8px; padding: 10px 12px; }
  .sticky-bar .sum { gap: 10px 16px; font-size: 12px; }
  .sticky-bar .btn { width: 100%; }

  /* 弹窗：贴边留白 + 底部按钮加大 */
  .modal-mask { padding: 12px; }
  .modal { max-width: 100%; }
  .modal-bd { padding-left: 18px; }
  .modal-ft .btn { flex: 1; min-height: 44px; }

  /* 图表与详情 */
  .chart-box { height: 220px; }
  .detail-totals { gap: 14px; }
  .kv { gap: 10px 14px; }
  .mt-bk-time { min-width: 0; }
  .rp-prod-box, .rp-combo-box, .rp-period-box { max-width: 100%; }
}

@media (max-width: 720px) {
  .lg-pre { max-width: 100%; max-height: 180px; }
}
