/* =====================================================================
   FabricERP 网页版 —— 样式（v3.1 换皮：暖白纸面 · 墨色按钮 · 陶土色点缀）
   约定：
   · 只用系统字体，不引外部字体/CDN（工厂网络不一定通外网）
   · 颜色、圆角、间距全部走 :root 变量，组件里不写死色值
   · 深色模式：跟随系统；<html data-theme="light|dark"> 可手动指定（侧栏底部切换）
   · ≥ 761px 按电脑布局；≤ 760px 按手机布局（底部标签栏、卡片列表、全屏表单）
   ===================================================================== */

:root {
  color-scheme: light;

  /* —— 底色：暖白纸面 —— */
  --bg:            #f6f5f0;
  --side:          #efede6;   /* 侧栏 */
  --surface:       #ffffff;
  --surface-2:     #faf9f5;   /* 表头、合计行、次级面板 */
  --surface-3:     #f3f1ea;   /* hover */
  --line:          #e9e6dd;
  --line-strong:   #d8d4c8;

  /* —— 文字 —— */
  --text:          #1f1e1b;
  --text-2:        #5f5c54;
  --text-3:        #949084;

  /* —— 主按钮：墨色 —— */
  --ink:           #262521;
  --ink-hover:     #3a3833;
  --on-ink:        #ffffff;

  /* —— 点缀色：陶土（选中、焦点、当前标签、价格表标记） —— */
  --primary:       #b8532c;
  --primary-hover: #9c4423;
  --primary-soft:  #f8ece5;
  --primary-line:  #eccab9;
  --primary-text:  #8a3c1d;

  /* —— 语义色 —— */
  --danger:        #b42318;   /* 欠款、删除、超发 */
  --danger-soft:   #fcebe9;
  --danger-line:   #f1c3bd;
  --danger-text:   #8c1d13;
  --warn:          #95600a;   /* 待发货、缩率异常 */
  --warn-soft:     #fbf1dd;
  --warn-line:     #ecd3a3;
  --warn-text:     #714806;
  --warn-row:      #fff8e7;   /* 缩率异常整行底色 */
  --warn-chip:     #fdebb9;
  --ok:            #2a7a4b;   /* 已发完、收款 */
  --ok-soft:       #e6f3eb;
  --info:          #2f5fa8;   /* 部分发货 */
  --info-soft:     #e8eef9;
  --muted-soft:    #eeece6;   /* 未加工 */
  --muted:         #59564e;
  --live:          #2f9e5f;   /* 侧栏「已连接」小圆点 */
  --focus-row:     #fdfbf7;

  /* —— 形状 / 间距 —— */
  --r:     10px;
  --r-sm:  7px;
  --r-lg:  14px;
  --gap:   16px;
  --shadow-1: 0 1px 2px rgba(40,36,28,.05);
  --shadow-2: 0 12px 32px rgba(40,36,28,.16), 0 0 0 1px rgba(40,36,28,.06);
  --overlay: rgba(30,28,24,.38);

  /* —— 尺寸 —— */
  --sidebar-w: 224px;
  --row-h:     36px;          /* 表格行高（电脑） */
  --ctl-h:     34px;          /* 输入框/按钮高（电脑） */

  --font: "Microsoft YaHei UI", "Microsoft YaHei", "PingFang SC", "Noto Sans CJK SC",
          -apple-system, "Segoe UI", sans-serif;
  --mono: "Cascadia Mono", Consolas, "SF Mono", monospace;
}

/* —— 深色：跟随系统（除非手动选了浅色），或手动选了深色 —— */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #1b1a18; --side: #161513; --surface: #232220; --surface-2: #282725; --surface-3: #302e2b;
    --line: #34322e; --line-strong: #46433d;
    --text: #ece9e2; --text-2: #b4afa5; --text-3: #848076;
    --ink: #ece9e2; --ink-hover: #ffffff; --on-ink: #1b1a18;
    --primary: #e08560; --primary-hover: #eb9a79; --primary-soft: #3a2a22; --primary-line: #6a412f; --primary-text: #f0b294;
    --danger: #f07a6c; --danger-soft: #3b2220; --danger-line: #6b332d; --danger-text: #f6aaa0;
    --warn: #e2ad52; --warn-soft: #362c1b; --warn-line: #66522c; --warn-text: #ecc47f; --warn-row: #2d271b; --warn-chip: #4a3a17;
    --ok: #6cc795; --ok-soft: #1f3327; --info: #85aef0; --info-soft: #1f2a3d;
    --muted-soft: #302e2b; --muted: #b4afa5; --live: #5fd08f; --focus-row: #282725;
    --shadow-1: 0 1px 2px rgba(0,0,0,.3);
    --shadow-2: 0 14px 36px rgba(0,0,0,.5), 0 0 0 1px rgba(255,255,255,.06);
    --overlay: rgba(0,0,0,.55);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #1b1a18; --side: #161513; --surface: #232220; --surface-2: #282725; --surface-3: #302e2b;
  --line: #34322e; --line-strong: #46433d;
  --text: #ece9e2; --text-2: #b4afa5; --text-3: #848076;
  --ink: #ece9e2; --ink-hover: #ffffff; --on-ink: #1b1a18;
  --primary: #e08560; --primary-hover: #eb9a79; --primary-soft: #3a2a22; --primary-line: #6a412f; --primary-text: #f0b294;
  --danger: #f07a6c; --danger-soft: #3b2220; --danger-line: #6b332d; --danger-text: #f6aaa0;
  --warn: #e2ad52; --warn-soft: #362c1b; --warn-line: #66522c; --warn-text: #ecc47f; --warn-row: #2d271b; --warn-chip: #4a3a17;
  --ok: #6cc795; --ok-soft: #1f3327; --info: #85aef0; --info-soft: #1f2a3d;
  --muted-soft: #302e2b; --muted: #b4afa5; --live: #5fd08f; --focus-row: #282725;
  --shadow-1: 0 1px 2px rgba(0,0,0,.3);
  --shadow-2: 0 14px 36px rgba(0,0,0,.5), 0 0 0 1px rgba(255,255,255,.06);
  --overlay: rgba(0,0,0,.55);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font: 14px/1.5 var(--font);
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
::selection { background: var(--primary-soft); color: var(--text); }
a { color: var(--primary-text); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
button, input, select, textarea { font: inherit; color: inherit; }
.num { font-variant-numeric: tabular-nums; }
.t2 { color: var(--text-2); } .t3 { color: var(--text-3); }
.red { color: var(--danger); } .green { color: var(--ok); }
.b { font-weight: 600; }
.nowrap { white-space: nowrap; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
svg.i { width: 16px; height: 16px; flex: none; stroke: currentColor; fill: none;
        stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; vertical-align: -3px; }

/* 细滚动条 */
* { scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 10px; border: 3px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-track { background: transparent; }

/* =====================================================================
   外框：左侧栏 + 主区
   ===================================================================== */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--sidebar-w); flex: none; background: var(--side); color: var(--text-2);
  border-right: 1px solid var(--line);
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 18px 18px 16px; color: var(--text); }
.brand .mark { width: 30px; height: 30px; border-radius: 8px; flex: none; display: grid; place-items: center;
               background: var(--primary); color: #fff; }
.brand .mark svg { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 1.6; }
.brand b { display: block; font-size: 14px; letter-spacing: .4px; line-height: 1.3; }
.brand span { display: block; font-size: 11.5px; color: var(--text-3); }
.nav { padding: 4px 10px; display: flex; flex-direction: column; gap: 2px; overflow-y: auto; min-height: 0; }
.nav a {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: var(--r-sm);
  color: var(--text-2); font-size: 14px;
}
.nav a:hover { background: var(--surface-3); color: var(--text); text-decoration: none; }
.nav a.on { background: var(--surface); color: var(--text); font-weight: 600; box-shadow: var(--shadow-1), 0 0 0 1px var(--line); }
.nav a.on svg.i { color: var(--primary); }
.nav .sep { height: 1px; background: var(--line); margin: 8px 6px; }
.nav .cust-mini { position: relative; padding: 5px 10px 5px 36px; font-size: 13px; color: var(--text-3); border-radius: var(--r-sm); }
.nav .cust-mini::before { content: ""; position: absolute; left: 18px; top: 0; bottom: 0; width: 1px; background: var(--line-strong); }
.nav .cust-mini:hover { color: var(--text); background: var(--surface-3); }
.nav .cust-mini.on { color: var(--text); font-weight: 600; background: transparent; box-shadow: none; }
.nav .cust-mini.on::before { width: 2px; left: 17.5px; background: var(--primary); }
.side-foot { margin-top: auto; padding: 12px 16px 14px; font-size: 12px; color: var(--text-3);
             border-top: 1px solid var(--line); }
.side-foot .dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%;
                  background: var(--live); margin-right: 7px; vertical-align: 1px;
                  box-shadow: 0 0 0 3px color-mix(in srgb, var(--live) 22%, transparent); }
.side-foot .dot.warn { background: #d99a2b; box-shadow: 0 0 0 3px rgba(217,154,43,.22); }
.side-foot .addr { font-family: var(--mono); color: var(--text-2); margin-top: 4px; }
.side-foot .rev { margin-top: 4px; }
.side-foot .rev .red { color: var(--danger); font-weight: 600; }
.theme-sw { display: inline-flex; margin-top: 10px; padding: 2px; border-radius: 8px; background: var(--surface-3); gap: 2px; }
.theme-sw button { border: 0; background: none; height: 24px; padding: 0 9px; border-radius: 6px; font-size: 12px;
                   color: var(--text-3); cursor: pointer; display: inline-flex; align-items: center; gap: 4px; }
.theme-sw button svg.i { width: 13px; height: 13px; vertical-align: 0; }
.theme-sw button:hover { color: var(--text); }
.theme-sw button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow-1); }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; gap: 12px; padding: 14px 28px 0; min-height: 48px;
}
.crumbs { font-size: 13px; color: var(--text-3); }
.crumbs a { color: var(--text-2); }
.page { padding: 10px 28px 44px; }
.page-head { display: flex; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.page-head h1 { font-size: 24px; margin: 0; letter-spacing: .5px; font-weight: 700; }
.page-head .sub { color: var(--text-3); font-size: 13px; margin-top: 3px; }
.page-head .actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }

/* =====================================================================
   基础控件
   ===================================================================== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: var(--ctl-h); padding: 0 14px; border-radius: var(--r-sm);
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--text);
  cursor: pointer; white-space: nowrap; font-size: 14px;
  transition: background .12s, border-color .12s, color .12s;
}
.btn:hover { background: var(--surface-3); text-decoration: none; }
.btn:active { transform: translateY(.5px); }
.btn:focus-visible, .inp:focus-visible { outline: 2px solid var(--primary-line); outline-offset: 1px; }
.btn.primary { background: var(--ink); border-color: var(--ink); color: var(--on-ink); font-weight: 600; }
.btn.primary:hover { background: var(--ink-hover); border-color: var(--ink-hover); }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; font-weight: 600; }
.btn.ghost { border-color: transparent; background: transparent; color: var(--text-2); }
.btn.ghost:hover { background: var(--surface-3); color: var(--text); }
.btn.sm { height: 28px; padding: 0 10px; font-size: 13px; }
.btn.icon { width: var(--ctl-h); padding: 0; }
.btn.sm.icon { width: 28px; }
.btn[disabled] { opacity: .4; pointer-events: none; }

.inp {
  height: var(--ctl-h); padding: 0 10px; border: 1px solid var(--line-strong);
  border-radius: var(--r-sm); background: var(--surface); min-width: 0; width: 100%;
  transition: border-color .12s, box-shadow .12s;
}
.inp::placeholder { color: var(--text-3); }
.inp:focus { border-color: var(--primary); outline: none; box-shadow: 0 0 0 3px var(--primary-soft); }
.inp.num { text-align: right; }
.inp.err { border-color: var(--danger); box-shadow: 0 0 0 3px var(--danger-soft); }
.inp[disabled], .inp[readonly] { background: var(--surface-2); color: var(--text-2); }
select.inp { padding-right: 26px; }
textarea.inp { height: auto; padding: 8px 10px; font-family: var(--mono); }

.search { position: relative; }
.search .inp { padding-left: 32px; width: 220px; }
.search svg { position: absolute; left: 10px; top: 9px; color: var(--text-3); pointer-events: none; }
.topbar .search .inp { background: var(--surface); border-color: var(--line); border-radius: 999px; padding-left: 34px; }
.topbar .search svg { left: 12px; }

.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field > label { font-size: 12px; color: var(--text-2); font-weight: 500; }
.field > label i { color: var(--danger); font-style: normal; }
.field .hint { font-size: 12px; color: var(--text-3); }
.field .hint.ok { color: var(--ok); }
.field .hint.bad { color: var(--danger); }

.check { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; font-size: 13px;
         color: var(--text-2); user-select: none; }
.check input { width: 15px; height: 15px; accent-color: var(--primary); margin: 0; }
input[type="checkbox"], input[type="radio"] { accent-color: var(--primary); }

.seg { display: inline-flex; padding: 2px; gap: 2px; border-radius: 9px; background: var(--surface-3);
       border: 1px solid var(--line); }
.seg button { border: 0; background: none; height: 28px; padding: 0 12px; cursor: pointer; border-radius: 7px;
              font-size: 13px; color: var(--text-2); }
.seg button:hover { color: var(--text); }
.seg button.on { background: var(--surface); color: var(--text); font-weight: 600; box-shadow: var(--shadow-1), 0 0 0 1px var(--line); }

.toolbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.toolbar .grow { flex: 1; }
.daterange { display: inline-flex; align-items: center; gap: 4px; color: var(--text-3); }
.daterange .inp { width: 132px; }

/* —— 状态标签 —— */
.chip { display: inline-flex; align-items: center; gap: 4px; height: 22px; padding: 0 8px;
        border-radius: 6px; font-size: 12px; white-space: nowrap; font-weight: 500; }
.chip::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .85; }
.chip.price::before, .chip.s-warn::before, .chip.s-closed::before { display: none; }
.chip.s-raw     { background: var(--muted-soft); color: var(--muted); }      /* 未加工 */
.chip.s-wait    { background: var(--warn-soft);  color: var(--warn); }       /* 待发货 */
.chip.s-part    { background: var(--info-soft);  color: var(--info); }       /* 部分发货 */
.chip.s-done    { background: var(--ok-soft);    color: var(--ok); }         /* 已发完 */
.chip.s-closed  { background: transparent; color: var(--text-3); box-shadow: inset 0 0 0 1px var(--line-strong); } /* 已结清 */
.chip.s-warn    { background: var(--warn-chip); color: var(--warn-text); }  /* 缩率异常 */
.chip.price     { background: var(--primary-soft); color: var(--primary-text); height: 18px; font-size: 11px; padding: 0 6px; border-radius: 5px; }
.chip svg.i { width: 13px; height: 13px; vertical-align: 0; }

/* =====================================================================
   卡片 / 数字看板
   ===================================================================== */
.card { background: var(--surface); border-radius: var(--r); box-shadow: var(--shadow-1), 0 0 0 1px var(--line); }
.card.pad { padding: 18px; }
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 12px; margin-bottom: 18px; }
.kpi { padding: 16px 18px 14px; position: relative; overflow: hidden; }
.kpi .k { font-size: 12.5px; color: var(--text-2); display: flex; align-items: center; gap: 6px; }
.kpi .v { font-size: 26px; font-weight: 700; margin-top: 4px; letter-spacing: .2px; font-variant-numeric: tabular-nums; line-height: 1.25; }
.kpi .v small { font-size: 13px; font-weight: 400; color: var(--text-3); margin-left: 4px; }
.kpi .d { font-size: 12px; color: var(--text-3); margin-top: 4px; }
.kpi.debt .v { color: var(--danger); }
.kpi.debt::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--danger); }

/* 客户页头部的汇总条 */
.facts { display: flex; flex-wrap: wrap; gap: 6px 22px; font-size: 13px; color: var(--text-2); }
.facts b { color: var(--text); font-size: 15px; margin-left: 4px; }
.facts .debt b { color: var(--danger); }

/* =====================================================================
   标签页
   ===================================================================== */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px;
        overflow-x: auto; scrollbar-width: none; }
.tabs a { padding: 9px 12px; color: var(--text-2); border-bottom: 2px solid transparent;
          margin-bottom: -1px; white-space: nowrap; font-size: 14px; }
.tabs a:hover { color: var(--text); text-decoration: none; }
.tabs a.on { color: var(--text); border-bottom-color: var(--primary); font-weight: 600; }
.tabs a .cnt { font-size: 11.5px; color: var(--text-2); margin-left: 6px; font-weight: 500; background: var(--surface-3);
               padding: 1px 6px; border-radius: 10px; }
.tabs a.on .cnt { background: var(--primary-soft); color: var(--primary-text); }

/* =====================================================================
   表格（只读列表）
   ===================================================================== */
.tbl-wrap { background: var(--surface); border-radius: var(--r); box-shadow: var(--shadow-1), 0 0 0 1px var(--line);
            overflow: auto; max-height: calc(100vh - 290px); }
.tbl { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13px; }
.tbl th, .tbl td { padding: 0 12px; height: var(--row-h); border-bottom: 1px solid var(--line);
                   text-align: left; white-space: nowrap; }
.tbl thead th { position: sticky; top: 0; z-index: 2; background: var(--surface-2); color: var(--text-3);
                font-weight: 600; font-size: 12px; height: 36px; cursor: pointer; user-select: none; letter-spacing: .3px; }
.tbl thead th:hover { color: var(--text); }
.tbl thead tr.grp th { height: 24px; font-size: 11px; color: var(--text-3); text-align: center; letter-spacing: 1px;
                       border-bottom: 0; cursor: default; padding-top: 4px; }
.tbl thead tr.grp + tr th { top: 24px; }
.tbl thead th.sorted { color: var(--text); }
.tbl thead th.sorted::after { content: " ▾"; color: var(--primary); }
.tbl .r { text-align: right; } .tbl .c { text-align: center; }
.tbl td.r { font-variant-numeric: tabular-nums; }
.tbl td.wrap { white-space: normal; min-width: 120px; }
.tbl td.muted { color: var(--text-3); }
.tbl tbody tr { cursor: default; }
.tbl tbody tr:last-child td { border-bottom: 0; }
.tbl tbody tr:hover td { background: var(--surface-3); }
.tbl tbody tr.sel td { background: var(--primary-soft); }
.tbl tbody tr.sel td:first-child { box-shadow: inset 3px 0 0 var(--primary); }
.tbl tbody tr.warn td { background: var(--warn-row); }
.tbl tbody tr.dim td { color: var(--text-3); }
.tbl tbody tr.click { cursor: pointer; }
.tbl tfoot td { position: sticky; bottom: 0; background: var(--surface-2); font-weight: 600;
                border-top: 1px solid var(--line-strong); border-bottom: 0; }
.tbl .grp-a { box-shadow: inset 1px 0 0 var(--line); }  /* 分组左竖线 */
.tbl td.lot { font-family: var(--mono); font-weight: 600; letter-spacing: .2px; }
.tbl td.ck, .tbl th.ck { width: 34px; padding: 0 0 0 14px; }
.tbl .row-act { opacity: 0; display: inline-flex; gap: 4px; transition: opacity .1s; }
.tbl tr:hover .row-act, .tbl tr.sel .row-act, .tbl tr:focus-within .row-act { opacity: 1; }
.tbl td.act { text-align: right; width: 1%; padding-right: 10px; }
.tbl td.money-debt { color: var(--danger); font-weight: 600; }

/* 表下方的合计条（不随表格滚动） */
.sumbar { display: flex; gap: 6px 20px; flex-wrap: wrap; padding: 10px 4px 0; font-size: 13px;
          color: var(--text-2); }
.sumbar b { color: var(--text); }
.sumbar .tip { margin-left: auto; color: var(--text-3); }

/* 批量操作条：勾选后浮出 */
.bulkbar { position: sticky; bottom: 16px; z-index: 5; margin: 14px auto 0; width: max-content;
           display: flex; align-items: center; gap: 10px; padding: 7px 8px 7px 16px;
           background: var(--ink); color: var(--on-ink); border-radius: 12px; box-shadow: var(--shadow-2);
           animation: pop .15s ease-out; }
.bulkbar .btn { height: 30px; }
.bulkbar .btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.bulkbar .btn.primary:hover { background: var(--primary-hover); }
.bulkbar .btn.ghost { color: inherit; opacity: .75; }
.bulkbar .btn.ghost:hover { background: transparent; opacity: 1; }

/* 行尾「…」菜单 */
.rowmenu { box-shadow: var(--shadow-2) !important; animation: pop .12s ease-out; }

/* 空状态 */
.empty { padding: 48px 16px; text-align: center; color: var(--text-3); }
.empty b { display: block; color: var(--text-2); font-size: 15px; margin-bottom: 4px; }

/* =====================================================================
   主从布局（发货单列表 + 右侧明细）
   ===================================================================== */
.split { display: grid; grid-template-columns: minmax(0, 1fr) 420px; gap: 16px; align-items: start; }
.detail { position: sticky; top: 12px; }
.detail .hd { padding: 16px 18px 12px; border-bottom: 1px solid var(--line); }
.detail .hd h3 { margin: 0; font-size: 17px; font-family: var(--mono); letter-spacing: .3px; }
.detail .hd .meta { font-size: 12px; color: var(--text-2); margin-top: 6px; display: flex; gap: 12px; flex-wrap: wrap; }
.detail .bd { padding: 4px 0; max-height: calc(100vh - 360px); overflow: auto; }
.detail .it { padding: 10px 18px; border-bottom: 1px dashed var(--line); display: grid;
              grid-template-columns: 1fr auto; gap: 2px 12px; font-size: 13px; }
.detail .it:last-child { border-bottom: 0; }
.detail .it .l1 { font-weight: 600; }
.detail .it .l1 .lot { font-family: var(--mono); margin-right: 6px; }
.detail .it .l2 { color: var(--text-2); font-size: 12px; }
.detail .it .amt { text-align: right; font-variant-numeric: tabular-nums; }
.detail .ft { padding: 12px 18px; border-top: 1px solid var(--line); background: var(--surface-2);
              display: flex; justify-content: space-between; font-size: 13px; border-radius: 0 0 var(--r) var(--r); }
.detail .ft b { font-size: 15px; }
.detail .ops { display: flex; gap: 6px; padding: 10px 18px 12px; flex-wrap: wrap; border-bottom: 1px solid var(--line); }

/* =====================================================================
   对账公式卡
   ===================================================================== */
.formula { display: grid; grid-template-columns: 1fr auto 1fr auto 1fr auto 1.2fr; align-items: center;
           gap: 0; padding: 18px 20px; margin-bottom: 18px; }
.formula .op { font-size: 20px; color: var(--text-3); padding: 0 14px; font-weight: 300; }
.formula .k { font-size: 12px; color: var(--text-2); }
.formula .v { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; margin-top: 2px; }
.formula .end .v { color: var(--danger); font-size: 26px; }
.formula .end { padding: 10px 16px; background: var(--danger-soft); border-radius: var(--r-sm); }

/* =====================================================================
   弹窗 / 抽屉 / 确认框 / 提示
   ===================================================================== */
.overlay { position: fixed; inset: 0; background: var(--overlay); z-index: 50;
           display: flex; align-items: flex-start; justify-content: center; padding: 4vh 16px;
           animation: fade .12s ease-out; backdrop-filter: blur(2px); }
@keyframes fade { from { opacity: 0; } }
.modal { background: var(--surface); border-radius: var(--r-lg); box-shadow: var(--shadow-2);
         width: 100%; max-width: 520px; max-height: 92vh; display: flex; flex-direction: column;
         animation: pop .16s cubic-bezier(.2,.8,.3,1); }
@keyframes pop { from { transform: translateY(8px) scale(.99); opacity: .5; } }
.modal.wide { max-width: 1240px; height: 92vh; }
.modal.mid { max-width: 820px; }
.modal .mh { display: flex; align-items: center; gap: 10px; padding: 16px 20px 14px; border-bottom: 1px solid var(--line); }
.modal .mh h2 { font-size: 17px; margin: 0; letter-spacing: .3px; }
.modal .mh .sub { color: var(--text-3); font-size: 13px; }
.modal .mh .x { margin-left: auto; }
.modal .mb { padding: 18px 20px; overflow: auto; flex: 1; }
.modal .mf { display: flex; align-items: center; gap: 8px; padding: 12px 20px; border-top: 1px solid var(--line);
             background: var(--surface-2); border-radius: 0 0 var(--r-lg) var(--r-lg); }
.modal .mf .total { margin-right: auto; font-size: 14px; color: var(--text-2); }
.modal .mf .total b { color: var(--text); font-size: 16px; margin: 0 2px; }
.modal .mf .total .amt b { color: var(--primary-text); font-size: 19px; }
.form-grid { display: grid; grid-template-columns: repeat(var(--cols, 2), minmax(0,1fr)); gap: 14px 14px; }
.form-grid .span2 { grid-column: span 2; }
.form-grid .spanall { grid-column: 1 / -1; }
.note-box { background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-sm);
            padding: 10px 12px; font-size: 13px; color: var(--text-2); }
.note-box.info { background: var(--primary-soft); border-color: var(--primary-line); color: var(--primary-text); }
.note-box.warn { background: var(--warn-soft); border-color: var(--warn-line); color: var(--warn-text); }
.note-box.danger { background: var(--danger-soft); border-color: var(--danger-line); color: var(--danger-text); }
.note-box ul { margin: 6px 0 0; padding-left: 18px; }

.confirm .mb { font-size: 14px; }
.confirm .mb p { margin: 0 0 8px; }

.sync-note { margin-left: 8px; }

.toast-host { position: fixed; top: 18px; left: 50%; transform: translateX(-50%); z-index: 80;
              display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast { background: var(--ink); color: var(--on-ink); padding: 10px 16px; border-radius: 10px; box-shadow: var(--shadow-2);
         font-size: 14px; display: flex; gap: 8px; align-items: center; animation: pop .15s ease-out; }
.toast.ok svg { color: var(--live); }
.toast.err { background: var(--danger); color: #fff; }

/* =====================================================================
   可编辑明细表（进仓单 / 发货单）
   ===================================================================== */
.egrid { width: 100%; table-layout: fixed; min-width: 1060px; border-collapse: separate; border-spacing: 0; font-size: 13px; }
.egrid th { background: var(--surface-2); color: var(--text-3); font-weight: 600; font-size: 12px;
            text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); white-space: nowrap;
            position: sticky; top: 0; z-index: 2; }
.egrid th.r { text-align: right; }
.egrid td { padding: 3px 3px; border-bottom: 1px solid var(--line); vertical-align: top; }
.egrid td.idx { width: 28px; color: var(--text-3); text-align: center; padding-top: 10px; font-size: 12px; }
.egrid .inp { height: 32px; border-color: var(--line); background: var(--surface); border-radius: 5px; padding: 0 7px; }
.egrid .inp:hover { border-color: var(--line-strong); }
.egrid .inp:focus { border-color: var(--primary); background: var(--surface); }
.egrid td.ro { padding: 9px 7px 0; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.egrid td.ro.r { text-align: right; color: var(--text); font-variant-numeric: tabular-nums; font-weight: 600; }
.egrid td.avail { font-size: 12px; padding-top: 10px; }
.egrid tr:focus-within td { background: var(--focus-row); }
.egrid tr.bad td { background: var(--danger-soft); }
.egrid td.del { width: 34px; padding-top: 5px; }
.egrid tfoot td { background: var(--surface-2); font-weight: 600; padding: 9px 7px; border-bottom: 0; }
.egrid-wrap { border: 1px solid var(--line); border-radius: var(--r); overflow: auto; background: var(--surface); }
.cell-price { position: relative; }
.cell-price .chip { position: absolute; left: 6px; top: -7px; pointer-events: none; }
.ac { position: relative; }
.ac-list { position: absolute; left: 0; top: 34px; z-index: 30; min-width: 380px; max-height: 300px; overflow: auto;
           background: var(--surface); border-radius: var(--r); box-shadow: var(--shadow-2); padding: 4px; }
.ac-list .o { display: grid; grid-template-columns: 70px 1fr auto; gap: 8px; padding: 7px 8px; border-radius: 6px;
              cursor: pointer; font-size: 13px; align-items: center; }
.ac-list .o:hover, .ac-list .o.on { background: var(--primary-soft); }
.ac-list .o .lot { font-family: var(--mono); font-weight: 700; }
.ac-list .o .s { color: var(--text-3); font-size: 12px; }
.grid-actions { display: flex; gap: 8px; margin: 10px 0 4px; flex-wrap: wrap; align-items: center; }
.grid-actions .kbd { margin-left: auto; font-size: 12px; color: var(--text-3); }
kbd { font: 11px var(--mono); padding: 1px 5px; border: 1px solid var(--line-strong); border-bottom-width: 2px;
      border-radius: 4px; background: var(--surface); color: var(--text-2); }

/* 码单编辑器 */
.rolls-ed { display: grid; grid-template-columns: 1fr 200px; gap: 14px; }
.rolls-ed textarea { min-height: 300px; }
.rolls-stat { font-size: 13px; }
.rolls-stat .big { font-size: 22px; font-weight: 700; }

/* =====================================================================
   设置页 / 基础资料
   ===================================================================== */
.settings { display: grid; grid-template-columns: 180px minmax(0, 720px); gap: 24px; }
.settings .snav { display: flex; flex-direction: column; gap: 2px; }
.settings > div { min-width: 0; }
.settings .snav a { white-space: nowrap; padding: 8px 12px; border-radius: var(--r-sm); color: var(--text-2); }
.settings .snav a:hover { background: var(--surface-3); color: var(--text); text-decoration: none; }
.settings .snav a.on { background: var(--surface); color: var(--text); font-weight: 600; box-shadow: var(--shadow-1), 0 0 0 1px var(--line); }
.settings section { padding: 22px; }
.settings h3 { margin: 0 0 4px; font-size: 16px; }
.settings .desc { color: var(--text-3); font-size: 13px; margin-bottom: 16px; }
.radio-card { display: flex; gap: 10px; padding: 12px 14px; border: 1px solid var(--line-strong); border-radius: var(--r);
              cursor: pointer; margin-bottom: 8px; transition: border-color .12s, background .12s; }
.radio-card:hover { border-color: var(--text-3); }
.radio-card.on { border-color: var(--primary); background: var(--primary-soft); }
.radio-card input { accent-color: var(--primary); margin-top: 3px; }
.radio-card b { display: block; }
.radio-card span { font-size: 13px; color: var(--text-2); }
.qr { width: 132px; height: 132px; background: repeating-conic-gradient(#1c2028 0 25%, #fff 0 50%) 0 0/16px 16px;
      border: 8px solid #fff; box-shadow: var(--shadow-1); border-radius: 6px; }
.kv { display: grid; grid-template-columns: 110px 1fr; gap: 8px 12px; font-size: 13px; align-items: center; }
.kv .k { color: var(--text-2); }
.code { font-family: var(--mono); background: var(--surface-2); border: 1px solid var(--line); padding: 2px 8px;
        border-radius: 5px; }

/* =====================================================================
   登录页（局域网 / 手机第一次打开）
   ===================================================================== */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px;
         background: radial-gradient(900px 500px at 15% -10%, var(--primary-soft) 0, transparent 60%), var(--bg); }
.login .card { width: 100%; max-width: 380px; padding: 30px 28px; }
.login h1 { font-size: 21px; margin: 0 0 6px; }
.login p { color: var(--text-2); font-size: 13px; margin: 0 0 18px; }
.login .btn { width: 100%; height: 42px; margin-top: 14px; }
.login .inp { height: 42px; }

/* 启动时「正在打开…」 */
.boot { min-height: 100vh; display: grid; place-items: center; color: var(--text-3); font-size: 14px; }

/* =====================================================================
   设计规范页
   ===================================================================== */
.swatches { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px,1fr)); gap: 10px; }
.sw { border-radius: var(--r); overflow: hidden; box-shadow: var(--shadow-1); background: var(--surface); font-size: 12px; }
.sw div { height: 54px; }
.sw p { margin: 0; padding: 6px 10px; }
.sw code { color: var(--text-3); font-family: var(--mono); }
.spec h2 { font-size: 16px; margin: 26px 0 10px; }
.spec .row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }

/* =====================================================================
   手机布局（≤ 760px）
   ===================================================================== */
.only-mobile { display: none !important; }
.tabbar, .m-head { display: none; }
.cards { display: flex; flex-direction: column; gap: 8px; }
.mcard { background: var(--surface); border-radius: var(--r); box-shadow: var(--shadow-1), 0 0 0 1px var(--line); padding: 12px 14px; }
.mcard .t { display: flex; align-items: center; gap: 8px; }
.mcard .t .lot { font-family: var(--mono); font-weight: 700; font-size: 15px; }
.mcard .t .chip { margin-left: auto; }
.mcard .s { font-size: 13px; color: var(--text-2); margin-top: 2px; }
.mcard .nums { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; margin-top: 8px; font-size: 12px; color: var(--text-3); }
.mcard .nums b { display: block; color: var(--text); font-size: 15px; font-variant-numeric: tabular-nums; }
.mcard .nums b.red { color: var(--danger); }
.mcard .ops { display: flex; gap: 8px; margin-top: 10px; }
.mcard .ops .btn { flex: 1; height: 36px; }
.mcard.warn { background: var(--warn-row); }
.mcard .rowx { display: flex; justify-content: space-between; padding: 6px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.mcard .rowx:last-child { border-bottom: 0; }
.mcard .rowx span:first-child { color: var(--text-2); }

@media (max-width: 760px) {
  :root { --ctl-h: 40px; --row-h: 44px; }
  body { font-size: 15px; }
  .only-desktop { display: none !important; }
  .only-mobile { display: revert !important; }
  .cards.only-mobile { display: flex !important; }
  .sidebar { display: none; }
  .topbar { display: none; }
  .m-head { display: flex; position: sticky; top: 0; z-index: 20; align-items: center; gap: 8px;
            background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(10px);
            border-bottom: 1px solid var(--line); color: var(--text); padding: 8px 12px; min-height: 52px; }
  .m-head h1 { font-size: 17px; margin: 0; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .m-head .btn.ghost { color: var(--text); }
  .page { padding: 12px 12px 92px; }
  .page-head { display: none; }
  .kpis { grid-template-columns: 1fr 1fr; gap: 8px; }
  .kpi { padding: 12px 14px; }
  .kpi .v { font-size: 20px; }
  .tabs { margin: 0 -12px 12px; padding: 0 8px; }
  .tabs a { padding: 12px 12px; }
  .toolbar .search, .toolbar .search .inp { width: 100%; flex: 1; }
  .toolbar .search { flex: 1 1 160px; }
  .toolbar .grow { display: none; }
  .toolbar .only-desktop { display: none !important; }
  .split { grid-template-columns: 1fr; }
  .formula { grid-template-columns: 1fr 1fr; gap: 10px; padding: 14px; }
  .formula .op { display: none; }
  .formula .end { grid-column: span 2; }
  .tabbar { display: grid; grid-template-columns: repeat(4, 1fr); position: fixed; left: 0; right: 0; bottom: 0;
            z-index: 30; background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: blur(10px);
            border-top: 1px solid var(--line);
            padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); }
  .tabbar a { display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 11px; color: var(--text-3); padding: 4px 0; }
  .tabbar a:hover { text-decoration: none; }
  .tabbar a svg.i { width: 22px; height: 22px; }
  .tabbar a.on { color: var(--primary); }
  .tabbar a.plus span.circ { width: 46px; height: 46px; border-radius: 14px; background: var(--ink); color: var(--on-ink);
                             display: grid; place-items: center; margin-top: -20px; box-shadow: 0 6px 16px rgba(40,36,28,.28); }
  .overlay { padding: 0; align-items: stretch; backdrop-filter: none; }
  .modal, .modal.wide, .modal.mid { max-width: none; max-height: none; height: 100%; border-radius: 0; }
  .modal .mh { padding: 12px 14px; }
  .modal .mb { padding: 12px; background: var(--bg); }
  .modal .mf { border-radius: 0; padding: 10px 12px calc(10px + env(safe-area-inset-bottom)); flex-wrap: wrap; }
  .modal .mf .total { width: 100%; margin-bottom: 4px; }
  .modal .mf .btn { flex: 1; height: 44px; }
  .confirm.modal { height: auto; margin: auto 12px; border-radius: var(--r-lg); }
  .overlay:has(.confirm) { align-items: center; }
  .form-grid { --cols: 1 !important; }
  .form-grid .span2 { grid-column: auto; }
  .settings { grid-template-columns: 1fr; }
  .settings .snav { flex-direction: row; overflow-x: auto; }
  .bulkbar { bottom: 76px; }
  .rolls-ed { grid-template-columns: 1fr; }
  .form-grid.hdr { --cols: 2 !important; }
  .form-grid.hdr .m-span2 { grid-column: span 2; }
  .hide-m { display: none !important; }
  .net-grid { grid-template-columns: 1fr !important; }
  .kv { grid-template-columns: 1fr; gap: 2px; }
  .kv .k { margin-top: 8px; }
  .search .inp { width: 100%; }
}

/* 手机上的发货明细卡片（替代可编辑表格） */
.icard { background: var(--surface); border-radius: var(--r); box-shadow: var(--shadow-1), 0 0 0 1px var(--line); padding: 12px; margin-bottom: 10px; }
.icard .ih { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.icard .ih .n { width: 22px; height: 22px; border-radius: 6px; background: var(--primary-soft); color: var(--primary-text);
                display: grid; place-items: center; font-size: 12px; font-weight: 700; }
.icard .ih .x { margin-left: auto; }
.icard .g { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.icard .g .full { grid-column: span 2; }
.icard .amt { display: flex; justify-content: space-between; margin-top: 10px; padding-top: 8px; border-top: 1px dashed var(--line);
              font-size: 14px; }
.icard .amt b { font-size: 17px; color: var(--primary-text); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* 打印时隐藏框架（真正的送货单/对账单打印仍走后端生成的 A4 页面） */
@media print { .sidebar, .topbar, .tabbar, .m-head, .toolbar, .bulkbar { display: none !important; } }
