/* 左右分栏工作台：左客户、右流水，像加强版 Excel。主色深绿只用在主按钮、选中态和「未付」 */
:root {
  color-scheme: light;
  --bg: #F3F5F2;
  --surface: #FDFEFD;
  --sunk: #EDF1ED;
  --ink: #16211B;
  --ink2: #435249;
  --ink3: #66746B;
  --line: #E1E7E2;
  --line2: #C9D3CC;
  --pri: #1E6B47;
  --pri-h: #185A3B;
  --pri-weak: #E6F1EA;
  --warn: #8A5309;
  --warn-line: #E0A43A;
  --warn-bg: #FCF0DA;
  --danger: #A8372B;
  --r1: 8px;
  --r2: 12px;
  --s1: 0 1px 2px rgba(22, 33, 27, .06);
  --s2: 0 8px 24px rgba(22, 33, 27, .12);
  --f13: 13px; --f16: 16px; --f20: 20px; --f25: 25px; --f31: 31px;
  --top: 0px;     /* 11-16 起没有顶栏，导航在左边 */
  --rail: 184px;  /* 左侧导航宽 */
  --tab: 0px;     /* 手机底部标签栏高，电脑上是 0 */
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Segoe UI", sans-serif;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font-size: var(--f16); line-height: 1.6; }
h1, h2, h3 { margin: 0; line-height: 1.2; font-weight: 600; }
button, input, textarea, select { font: inherit; color: inherit; }
input, textarea, select { font-size: 16px; }
.num { font-variant-numeric: tabular-nums; }
:focus-visible { outline: 2px solid var(--pri); outline-offset: 2px; }
[hidden] { display: none !important; }
.muted { color: var(--ink3); font-size: var(--f13); margin: 0; }

/* ---------- 系统外壳：左侧导航 ---------- */
/* 图标：lucide 线条图标，用 mask 着色，跟着文字颜色走 */
.ic { display: inline-block; width: 18px; height: 18px; flex: none; background: currentColor; -webkit-mask: var(--i) center / contain no-repeat; mask: var(--i) center / contain no-repeat; }
.ic-printer { --i: url(icons/printer.svg); }
.ic-chart { --i: url(icons/chart-column.svg); }
.ic-wallet { --i: url(icons/wallet.svg); }
.ic-users { --i: url(icons/users.svg); }
.ic-user { --i: url(icons/user-round.svg); }
.ic-bank { --i: url(icons/landmark.svg); }
.ic-key { --i: url(icons/key-round.svg); }
.ic-out { --i: url(icons/log-out.svg); }
.av { display: inline-grid; place-items: center; width: 32px; height: 32px; flex: none; border-radius: 50%; background: var(--pri-weak); color: var(--pri); font-size: var(--f13); font-weight: 600; }

.rail { position: fixed; left: 0; top: 0; bottom: 0; width: var(--rail); z-index: 30; display: flex; flex-direction: column; padding: 16px 12px; background: var(--surface); border-right: 1px solid var(--line); }
.rail-brand { display: flex; align-items: center; gap: 12px; padding: 4px 4px 24px; color: var(--ink); text-decoration: none; }
.rail-brand img { width: 36px; height: 36px; border-radius: 10px; box-shadow: 0 0 0 1px var(--line); }
.rail-brand span { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.rail-brand b { font-size: var(--f16); font-weight: 600; letter-spacing: .02em; }
.rail-brand small { font-size: var(--f13); color: var(--ink3); }
.rail-m { display: flex; flex-direction: column; gap: 4px; }
.rail-m a { display: flex; align-items: center; gap: 12px; height: 40px; padding: 0 12px; border-radius: var(--r1); color: var(--ink2); text-decoration: none; font-size: 15px; transition: background-color .15s ease-out, color .15s ease-out; }
.rail-m a .ic { opacity: .85; }
.rail-m a:hover { background: var(--sunk); color: var(--ink); }
.rail-m a[aria-current="page"] { background: var(--pri-weak); color: var(--pri); font-weight: 600; }
.rail-m a[aria-current="page"] .ic { opacity: 1; }
.rail-m .m-only { display: none; }
.rail-f { margin-top: auto; padding-top: 12px; border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: 2px; }
.rail-u { display: flex; align-items: center; gap: 12px; padding: 4px 4px 12px; min-width: 0; }
.rail-un { display: flex; flex-direction: column; line-height: 1.3; min-width: 0; }
.rail-un b { font-size: 15px; font-weight: 600; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rail-un small { font-size: var(--f13); color: var(--ink3); }
.rail-a { display: flex; align-items: center; gap: 12px; height: 36px; padding: 0 12px; border: 0; border-radius: var(--r1); background: none; color: var(--ink2); font-size: 14px; cursor: pointer; text-align: left; transition: background-color .15s ease-out; }
.rail-a .ic { width: 16px; height: 16px; }
.rail-a:hover { background: var(--sunk); color: var(--ink); }
.rail-a[hidden] { display: none; }
html.authed .shell { margin-left: var(--rail); }
.dd { position: fixed; top: 0; left: var(--rail); width: calc(100% - var(--rail)); height: calc(100dvh - var(--tab)); border: 0; background: var(--bg); display: block; }

/* 中等宽度（笔记本 1280~1439）：导航收成「图标在上、小字在下」，客户栏收窄、表格列收紧，流水表不用横拖 */
@media (min-width: 861px) and (max-width: 1439px) {
  :root { --rail: 88px; }
  .rail { padding: 16px 8px; }
  .rail-brand { justify-content: center; padding: 4px 0 20px; }
  .rail-brand span { display: none; }
  .rail-m a { flex-direction: column; justify-content: center; gap: 4px; height: 60px; padding: 0 4px; font-size: var(--f13); }
  .rail-m a .ic { width: 20px; height: 20px; }
  .rail-f { align-items: center; }
  .rail-u { padding: 4px 0 8px; justify-content: center; }
  .rail-un { display: none; }
  .rail-a { justify-content: center; width: 40px; padding: 0; }
  .rail-a span { display: none; }
  html.authed .shell { grid-template-columns: 208px minmax(0, 1fr); }
}
@media (min-width: 1440px) { :root { --rail: 200px; } }
/* 1599 以下（含 1440 笔记本）流水表列收紧，备注列留得出位置 */
@media (min-width: 861px) and (max-width: 1599px) {
  .tbl table.ledger { min-width: 880px; }
  .tbl col:nth-child(1) { width: 80px !important; }
  .tbl col:nth-child(2) { width: 132px !important; }
  .tbl col:nth-child(3) { width: 60px !important; }
  .tbl col:nth-child(4) { width: 56px !important; }
  .tbl col:nth-child(5), .tbl col:nth-child(7) { width: 76px !important; }
  .tbl col:nth-child(6) { width: 48px !important; }
  .tbl col:nth-child(8) { width: 72px !important; }
  .tbl col:nth-child(9) { width: 140px !important; }
  .tbl col:nth-child(10) { width: 80px !important; }
}

/* 整页（账号、我的）：不要客户栏 */
body.r-page .shell { grid-template-columns: minmax(0, 1fr); }
body.r-page .side { display: none; }
.pg { max-width: 760px; padding: 24px; }
.pg h1 { font-size: var(--f25); }
.pg > .muted { margin: 8px 0 24px; font-size: 15px; line-height: 1.6; max-width: 38em; }
.pg-h { display: flex; align-items: center; gap: 16px; }
.pg-h .btn { margin-left: auto; }
.pg-list { display: flex; flex-direction: column; gap: 12px; max-width: 360px; }
.av.lg { width: 48px; height: 48px; font-size: var(--f20); }
.me-card { display: flex; align-items: center; gap: 16px; margin: 24px 0 16px; padding: 16px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r2); max-width: 480px; }
.me-card b { display: block; font-size: var(--f16); font-weight: 600; }
.me-card small { font-size: var(--f13); color: var(--ink3); }
.mlist { max-width: 480px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r2); overflow: hidden; }
.mrow { display: flex; align-items: center; gap: 12px; width: 100%; height: 52px; padding: 0 16px; border: 0; background: none; color: var(--ink); font-size: var(--f16); text-decoration: none; text-align: left; cursor: pointer; }
.mrow + .mrow { border-top: 1px solid var(--line); }
.mrow .ic { color: var(--ink2); }
.mrow span { flex: 1; }
.mrow .chev { font-style: normal; color: var(--ink3); font-size: var(--f20); line-height: 1; }
.mrow:hover { background: var(--sunk); }
.mout { max-width: 480px; margin-top: 24px; height: 44px; }
.btn.danger { color: var(--danger); }
.ulist { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r2); overflow: hidden; }
.urow { display: grid; grid-template-columns: minmax(0, 1fr) auto 64px auto; align-items: center; gap: 16px; padding: 12px 16px; }
.urow + .urow { border-top: 1px solid var(--line); }
.urow.off { color: var(--ink3); }
.urow .un { display: flex; align-items: center; gap: 12px; min-width: 0; }
.urow .un b { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.urow .un span, .urow .st { font-size: var(--f13); color: var(--ink3); white-space: nowrap; }
.tag { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: var(--f13); background: var(--sunk); color: var(--ink2); white-space: nowrap; }
.tag.adm { background: var(--pri-weak); color: var(--pri); }

/* 顶栏（11-16 起不用了，留着样式给结算单页的返回链接等） */
.top { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 16px; height: var(--top); padding: 0 16px; background: var(--surface); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 8px; color: var(--ink); text-decoration: none; font-weight: 600; white-space: nowrap; }
.top-r { margin-left: auto; display: flex; gap: 4px; }
.top-r .link { white-space: nowrap; }

/* 按钮 */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 36px; padding: 0 14px; border-radius: var(--r1); border: 1px solid var(--line2); background: var(--surface); cursor: pointer; white-space: nowrap; font-size: 15px; text-decoration: none; color: var(--ink); transition: background-color .15s ease-out, border-color .15s ease-out; }
.btn:hover { background: var(--sunk); }
.btn.pri { background: var(--pri); border-color: var(--pri); color: #FBFDFB; font-weight: 600; }
.btn.pri:hover { background: var(--pri-h); }
.btn:disabled { opacity: .55; cursor: default; }
.btn.wide { width: 100%; }
.btn.lg { height: 40px; font-size: var(--f16); }
.link { background: none; border: 0; padding: 6px 8px; color: var(--ink2); cursor: pointer; border-radius: var(--r1); font-size: 15px; }
.link:hover { color: var(--ink); background: var(--sunk); }
.link.danger { color: var(--danger); }

/* 表单 */
.stack > * + * { margin-top: 16px; }
.fld { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.fld > span { font-size: var(--f13); color: var(--ink2); }
.fld small { color: var(--ink3); font-size: var(--f13); }
.fld input, .fld textarea, .fld select { width: 100%; min-width: 0; height: 40px; padding: 0 12px; border: 1px solid var(--line2); border-radius: var(--r1); background: #FFFEFC; }
.fld textarea { height: auto; padding: 8px 12px; resize: vertical; line-height: 1.5; }
.fld input:focus, .fld textarea:focus, .side-h input:focus, .lf input:focus { border-color: var(--pri); outline: none; box-shadow: 0 0 0 3px var(--pri-weak); }
.fld input[aria-invalid="true"] { border-color: var(--danger); }
.err { color: var(--danger); font-size: var(--f13); margin: 0; }
.err:empty { display: none; }
.hint { margin: -8px 0 0; font-size: var(--f13); color: var(--ink3); }
.hint:empty { display: none; }
.hint.warn { color: var(--warn); }
.grid { display: grid; gap: 12px; }
.g2 { grid-template-columns: minmax(0, 168px) minmax(0, 1fr); }
.g2b { grid-template-columns: minmax(0, 1fr) minmax(0, 120px); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.sec-t { font-size: var(--f13); color: var(--ink3); font-weight: 600; margin: 24px 0 -4px; padding-top: 16px; border-top: 1px solid var(--line); }
.dlg-b > .sec-t:first-child { margin-top: 0; padding-top: 0; border-top: 0; }
.dlg-b > * + * { margin-top: 16px; }
.flagfld input { background: var(--warn-bg); border-color: #EBCF9C; }

/* 登录 */
.login { max-width: 360px; margin: 12vh auto 0; padding: 0 16px; text-align: center; }
.login-m { border-radius: 24px; box-shadow: 0 0 0 1px var(--line), var(--s1); }
.login h1 + .login-s { margin: -24px 0 32px; font-size: var(--f13); color: var(--ink3); letter-spacing: .08em; }
.login h1 { font-size: var(--f25); margin: 8px 0 32px; }
.login form { text-align: left; background: var(--surface); padding: 24px; border-radius: var(--r2); box-shadow: var(--s1); border: 1px solid var(--line); }
.login .btn { height: 40px; font-size: var(--f16); }

/* ---------- 分栏 ---------- */
.shell { display: grid; grid-template-columns: 240px minmax(0, 1fr); height: calc(100dvh - var(--top)); }
.shell.solo { display: block; height: auto; }
.side { display: flex; flex-direction: column; min-height: 0; background: var(--surface); border-right: 1px solid var(--line); }
.side-h { padding: 16px 16px 8px; }
.side-h input { width: 100%; height: 36px; padding: 0 12px; border: 1px solid var(--line2); border-radius: var(--r1); background: var(--bg); }
.side-sum { margin: 12px 0 0; font-size: var(--f13); color: var(--ink3); }
.side-sum b { color: var(--ink); font-weight: 600; }
.clist { flex: 1; overflow-y: auto; padding: 4px 8px 8px; }
.citem { display: block; position: relative; padding: 10px 12px 10px 16px; border-radius: var(--r1); color: inherit; text-decoration: none; }
.citem + .citem { margin-top: 2px; }
.citem:hover { background: var(--sunk); }
.citem[aria-current="page"] { background: var(--pri-weak); }
.citem[aria-current="page"]::before { content: ""; position: absolute; left: 4px; top: 10px; bottom: 10px; width: 3px; border-radius: 2px; background: var(--pri); }
.citem .c1 { display: flex; align-items: baseline; gap: 8px; }
.citem .nm { flex: 1; min-width: 0; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.citem .du { font-weight: 600; color: var(--pri); white-space: nowrap; }
.citem .du.zero { color: var(--ink3); font-weight: 400; }
.citem .c2 { display: flex; flex-wrap: wrap; column-gap: 8px; font-size: var(--f13); color: var(--ink3); margin-top: 2px; }
.citem .c2 > span { white-space: nowrap; }
.citem .c2 .fl { color: var(--warn); }
.clist .none { padding: 24px 12px; font-size: var(--f13); color: var(--ink3); text-align: center; }
.side-f { padding: 12px 16px 16px; border-top: 1px solid var(--line); }

/* 右栏：流水 */
#view { min-width: 0; min-height: 0; overflow: auto; }
#view.v-ledger { display: flex; flex-direction: column; overflow: hidden; }
.lh { display: flex; align-items: center; gap: 16px; padding: 16px 24px 12px; flex-wrap: wrap; }
.lh-t { display: flex; align-items: baseline; gap: 12px; min-width: 0; flex-wrap: wrap; }
.lh h1 { font-size: var(--f25); letter-spacing: -.01em; }
.lh .meta { font-size: var(--f13); color: var(--ink3); }
.lh .acts { margin-left: auto; display: flex; gap: 8px; }
.lf { display: flex; align-items: center; gap: 12px; padding: 0 24px 12px; flex-wrap: wrap; font-size: var(--f13); color: var(--ink2); }
.lf .rng { display: inline-flex; align-items: center; gap: 6px; }
.dwrap { position: relative; display: flex; min-width: 0; }
.dwrap input { flex: 1; min-width: 0; }
.dwrap.empty input:not(:focus) { color: transparent; }
.dwrap.empty input:not(:focus)::-webkit-datetime-edit,
.dwrap.empty input:not(:focus)::-webkit-datetime-edit-fields-wrapper,
.dwrap.empty input:not(:focus)::-webkit-datetime-edit-text,
.dwrap.empty input:not(:focus)::-webkit-datetime-edit-year-field,
.dwrap.empty input:not(:focus)::-webkit-datetime-edit-month-field,
.dwrap.empty input:not(:focus)::-webkit-datetime-edit-day-field { color: transparent; }
.dwrap.empty:not(:focus-within)::after { content: attr(data-ph); position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--ink3); pointer-events: none; font-size: 15px; white-space: nowrap; }
.lf .dwrap.empty:not(:focus-within)::after { left: 9px; font-size: var(--f13); }
.lf .dbox { height: 32px; padding: 0 8px; border: 1px solid var(--line2); border-radius: var(--r1); background: var(--surface); font-size: 16px; width: 140px; }
.lf .clr { font-size: var(--f13); padding: 4px 6px; }
.seg { display: inline-flex; background: var(--sunk); border-radius: var(--r1); padding: 3px; gap: 2px; }
.seg button { border: 0; background: none; height: 28px; padding: 0 12px; border-radius: 6px; cursor: pointer; color: var(--ink2); font-size: var(--f13); white-space: nowrap; }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: var(--s1); font-weight: 600; }
.ftog { display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--line2); background: var(--surface); cursor: pointer; font-size: var(--f13); color: var(--ink2); white-space: nowrap; }
.ftog::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--warn-line); }
.ftog[aria-pressed="true"] { background: var(--warn-bg); border-color: #EBCF9C; color: var(--warn); font-weight: 600; }

.tbl { flex: 1; min-height: 0; overflow: auto; margin: 0 24px; background: var(--surface); border: 1px solid var(--line); border-bottom: 0; border-radius: var(--r2) var(--r2) 0 0; }
table.ledger { border-collapse: separate; border-spacing: 0; width: 100%; min-width: 960px; font-size: 14px; table-layout: fixed; }
.ledger th { position: sticky; top: 0; z-index: 1; background: var(--sunk); color: var(--ink2); font-weight: 600; font-size: var(--f13); text-align: left; padding: 8px; border-bottom: 1px solid var(--line2); white-space: nowrap; }
.ledger td { padding: 8px; border-bottom: 1px solid var(--line); vertical-align: top; overflow-wrap: anywhere; line-height: 1.5; }
.ledger tbody tr { cursor: pointer; }
.ledger tbody tr:hover td { background: #F5F9F6; }
.ledger tbody tr:focus-visible { outline-offset: -2px; }
.ledger tr.fl td:first-child { box-shadow: inset 3px 0 0 var(--warn-line); }
.ledger .n { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.ledger .d { white-space: nowrap; color: var(--ink2); font-variant-numeric: tabular-nums; }
.ledger .neg { color: var(--danger); }
.ledger .pd { color: var(--pri); }
.ledger .ok { color: var(--ink3); }
.ledger .wb, .ledger .note { font-size: var(--f13); color: var(--ink2); }
.ledger .note { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ledger .pr { font-weight: 500; }
.ledger .sp { color: var(--ink3); font-size: var(--f13); margin-top: 2px; }
.ledger .u { color: var(--ink3); font-size: var(--f13); }

.tot { display: flex; align-items: center; gap: 32px; margin: 0 24px 16px; padding: 12px 20px; background: var(--surface); border: 1px solid var(--line); border-top: 1px solid var(--line2); border-radius: 0 0 var(--r2) var(--r2); box-shadow: 0 -4px 12px rgba(22, 33, 27, .04); flex-wrap: wrap; }
.tot .k { display: flex; align-items: baseline; gap: 8px; font-size: var(--f13); color: var(--ink2); }
.tot .k b { font-size: var(--f20); color: var(--ink); font-weight: 600; font-variant-numeric: tabular-nums; }
.tot .k.due b { color: var(--pri); font-size: var(--f25); }
.tot .r { margin-left: auto; font-size: var(--f13); color: var(--ink3); text-align: right; }
.tot .r b { color: var(--ink2); font-weight: 600; }
.tot .m-add { display: none; }

/* 手机卡片 */
.rows { display: none; }
.row { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r2); padding: 12px 16px; cursor: pointer; position: relative; }
.row.fl { box-shadow: inset 3px 0 0 var(--warn-line); }
.row + .row { margin-top: 8px; }
.row .l1 { display: flex; gap: 8px; align-items: baseline; }
.row .l1 .d { color: var(--ink3); font-size: var(--f13); font-variant-numeric: tabular-nums; }
.row .l1 .p { font-weight: 600; flex: 1; min-width: 0; overflow-wrap: anywhere; }
.row .l1 .a { font-weight: 600; white-space: nowrap; font-variant-numeric: tabular-nums; }
.row .l1 .a.ok { color: var(--ink3); font-weight: 400; font-size: var(--f13); }
.row .l1 .a.neg { color: var(--danger); }
.row .l2, .row .l3 { font-size: var(--f13); color: var(--ink2); margin-top: 4px; overflow-wrap: anywhere; }
.row .l3 { color: var(--ink3); }
.row .l4 { font-size: var(--f13); color: var(--warn); margin-top: 6px; }
.mon { font-size: var(--f13); color: var(--ink3); font-weight: 600; margin: 20px 4px 8px; }
.mon:first-child { margin-top: 4px; }

/* 空 / 加载 / 出错 */
.state { text-align: center; padding: 64px 16px; color: var(--ink2); }
.state h3 { font-size: var(--f20); color: var(--ink); margin-bottom: 8px; }
.state p { margin: 0 0 16px; }
.state.loading { color: var(--ink3); }
.tbl .state { padding: 48px 16px; }

/* 弹窗 */
.dlg { border: 0; padding: 0; border-radius: var(--r2); box-shadow: var(--s2); width: min(640px, calc(100vw - 32px)); max-height: calc(100dvh - 48px); background: var(--surface); color: var(--ink); }
.dlg.sm { width: min(440px, calc(100vw - 32px)); }
.dlg::backdrop { background: rgba(22, 33, 27, .36); }
.dlg form { display: flex; flex-direction: column; max-height: calc(100dvh - 48px); }
.dlg-h { display: flex; align-items: center; padding: 16px 20px 8px 24px; }
.dlg-h h2 { font-size: var(--f20); }
.x { margin-left: auto; width: 40px; height: 40px; border: 0; background: none; font-size: 24px; line-height: 1; color: var(--ink3); cursor: pointer; border-radius: var(--r1); }
.x:hover { background: var(--sunk); color: var(--ink); }
.dlg-b { padding: 8px 24px 16px; overflow-y: auto; }
.dlg-f { display: flex; align-items: center; gap: 8px; padding: 12px 24px 16px; border-top: 1px solid var(--line); }
.dlg-f .sp { flex: 1; }
.dlg-f .btn { height: 40px; font-size: var(--f16); }
.hist summary { cursor: pointer; font-size: var(--f13); color: var(--ink2); }
.hist ol { list-style: none; padding: 0; margin: 8px 0 0; font-size: var(--f13); color: var(--ink2); }
.hist li { padding: 8px 0; border-top: 1px solid var(--line); }
.hist li b { color: var(--ink); font-weight: 600; }

.toast { position: fixed; left: 50%; bottom: max(24px, env(safe-area-inset-bottom)); transform: translate(-50%, 8px); background: var(--ink); color: #F4F6F3; padding: 8px 16px; border-radius: var(--r1); font-size: var(--f13); opacity: 0; pointer-events: none; transition: opacity .2s ease-out, transform .2s ease-out; z-index: 50; }
.toast.on { opacity: 1; transform: translate(-50%, 0); }

/* ---------- 结算单（照原 Excel 版式） ---------- */
.pv { padding: 16px 24px 32px; }
.back { display: inline-flex; color: var(--ink2); text-decoration: none; font-size: var(--f13); padding: 4px 0; margin-bottom: 8px; }
.back:hover { color: var(--ink); }
.pbar { display: flex; align-items: flex-end; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.pbar .fld input { width: 152px; height: 36px; font-size: 16px; }
.pbar .sp { flex: 1; }
.toggle { display: inline-flex; align-items: center; gap: 8px; height: 36px; font-size: var(--f13); color: var(--ink2); cursor: pointer; white-space: nowrap; }
.toggle input { width: 16px; height: 16px; accent-color: var(--pri); }
.paper-wrap { overflow-x: auto; background: var(--sunk); border-radius: var(--r2); padding: 16px; }
.paper { background: #fff; color: #111; width: 1120px; margin: 0 auto; padding: 16px; font-size: 13px; line-height: 1.4; box-shadow: var(--s1); }
.paper .hd { display: grid; grid-template-columns: 120px 1fr; align-items: center; gap: 12px; }
.paper .hd img { width: 110px; height: auto; }
.paper .t1 { font-size: 30px; font-weight: 400; letter-spacing: .02em; }
.paper .t1 em { font-style: normal; color: #D0021B; }
.paper .t2 { display: flex; gap: 48px; margin-top: 8px; font-size: 14px; }
.paper .t2 b { color: #D0021B; font-weight: 400; }
.paper .band { display: grid; grid-template-columns: 1.4fr 1fr 1.4fr; margin-top: 12px; border: 1px solid #111; }
.paper .band > div { padding: 10px 16px; font-size: 18px; display: flex; gap: 12px; align-items: baseline; justify-content: center; }
.paper .band .b1 { background: #00B050; }
.paper .band .b2 { background: #F4B0B0; }
.paper .band .b3 { background: #000; color: #fff; font-weight: 600; }
.paper .bank { background: #FDF3DC; border: 1px solid #111; border-top: 0; padding: 4px 16px; font-size: 13px; letter-spacing: .04em; }
.paper .prev { margin: 8px 0 0; color: #D0021B; font-size: 13px; }
.paper table { width: 100%; border-collapse: collapse; margin-top: 12px; table-layout: fixed; }
.paper th, .paper td { border: 1px solid #333; padding: 3px 4px; font-size: 12px; overflow-wrap: anywhere; vertical-align: top; }
.paper th { background: #F2F2F2; font-weight: 600; }
.paper td.n { text-align: right; white-space: nowrap; }
.paper .foot { margin-top: 8px; font-size: 12px; color: #555; text-align: right; }

/* ---------- 手机：左栏当首页，客户页是卡片流 ---------- */
@media (max-width: 860px) {
  :root { --tab: calc(56px + env(safe-area-inset-bottom)); }
  .rail { top: auto; right: 0; width: auto; height: var(--tab); flex-direction: row; padding: 0 0 env(safe-area-inset-bottom); border-right: 0; border-top: 1px solid var(--line); background: var(--surface); }
  .rail-brand, .rail-f { display: none; }
  .rail-m { flex-direction: row; width: 100%; gap: 0; }
  .rail-m a { flex: 1; flex-direction: column; justify-content: center; gap: 4px; height: 56px; padding: 0 4px; border-radius: 0; font-size: var(--f13); }
  .rail-m a .ic { width: 22px; height: 22px; }
  .rail-m a:hover { background: none; }
  .rail-m a[aria-current="page"] { background: none; }
  .rail-m a[data-r="users"] { display: none; }
  .rail-m .m-only { display: flex; }
  html.authed .shell { margin-left: 0; padding-bottom: var(--tab); }
  .dd { left: 0; width: 100%; }
  .toast { bottom: calc(var(--tab) + 16px); }
  .pg { padding: 24px 16px; }
  .urow { grid-template-columns: minmax(0, 1fr) auto auto; }
  .urow .st { display: none; }
  .shell { display: block; height: auto; }
  .side { border-right: 0; background: none; }
  .brand .b2 { display: none; }
  .side-h { padding: 16px; }
  .side-h input { height: 40px; background: var(--surface); }
  .clist { flex: none; padding: 0 16px; overflow: visible; }
  .citem { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r2); padding: 14px 16px; }
  .citem + .citem { margin-top: 8px; }
  .citem[aria-current="page"] { background: var(--surface); }
  .citem[aria-current="page"]::before { display: none; }
  .side-f { border-top: 0; padding: 16px; }
  body.r-home #view { display: none; }
  body:not(.r-home) .side { display: none; }
  #view, #view.v-ledger { display: block; overflow: visible; }
  .lh { padding: 12px 16px 8px; }
  .lh .acts { margin-left: 0; width: 100%; }
  .lh .acts .btn { flex: 1; height: 40px; }
  .lh .acts .btn.pri { display: none; }
  .lf { padding: 0 16px 12px; gap: 8px; }
  .lf .seg { width: 100%; }
  .lf .seg button { flex: 1; }
  .lf .rng { flex: 1; min-width: 0; }
  .lf .dwrap { flex: 1; }
  .lf .dbox { width: 0; height: 36px; }
  .tbl { margin: 0; border: 0; background: none; border-radius: 0; overflow: visible; padding: 0 16px 112px; }
  .tot { bottom: var(--tab) !important; }
  .tbl table { display: none; }
  .rows { display: block; }
  .tot { position: fixed; left: 0; right: 0; bottom: 0; z-index: 15; margin: 0; border-radius: var(--r2) var(--r2) 0 0; gap: 12px; padding: 10px 16px max(10px, env(safe-area-inset-bottom)); box-shadow: 0 -4px 16px rgba(22, 33, 27, .08); flex-wrap: nowrap; }
  .tot .k:not(.due), .tot .r { display: none; }
  .tot .k.due { flex: 1; flex-direction: column; gap: 0; }
  .tot .k.due b { font-size: var(--f20); }
  .tot .m-add { display: inline-flex; height: 44px; padding: 0 24px; }
  .mstat { display: flex; gap: 16px; padding: 0 16px 12px; font-size: var(--f13); color: var(--ink2); }
  .mstat b { color: var(--ink); font-weight: 600; font-variant-numeric: tabular-nums; }
  .g2, .g2b { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .dlg { width: 100vw; max-width: 100vw; max-height: 100dvh; height: 100dvh; border-radius: 0; margin: 0; }
  .dlg.sm { width: 100vw; }
  .dlg form { max-height: 100dvh; height: 100%; }
  .dlg-b { flex: 1; }
  .dlg-f { padding-bottom: max(16px, env(safe-area-inset-bottom)); }
  .brand span { font-size: 15px; }
  .top-r .link { padding: 6px; font-size: var(--f13); }
  .pv { padding: 12px 16px 32px; }
  .pbar { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 12px; }
  .pbar .fld input { width: 100%; height: 40px; }
  .pbar .sp { display: none; }
  .pbar .toggle { align-self: end; min-height: 40px; height: auto; }
  .pbar .btn { width: 100%; height: 40px; }
  .paper-wrap { padding: 8px; overflow: hidden; }
}
@media (min-width: 861px) { .mstat { display: none; } }

@media print {
  @page { size: A4 landscape; margin: 8mm; }
  body { background: #fff; }
  .no-print, .top, .side, .pbar, .back, .toast, .rail, .dd { display: none !important; }
  html.authed .shell { margin-left: 0; }
  .shell { display: block; height: auto; }
  #view { overflow: visible; }
  .pv { padding: 0; }
  .paper-wrap { padding: 0; background: none; overflow: visible; }
  .paper { width: auto; box-shadow: none; padding: 0; zoom: 1 !important; }
  .paper .band > div, .paper .bank, .paper th { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .paper tr { break-inside: avoid; }
}

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

/* 补单价时的「这个客户最近的单价」点选 */
.pchips { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: -4px 0 4px; font-size: var(--f13); color: var(--ink3); }
.pchips[hidden] { display: none; }
.pchips .chip { border: 1px solid var(--line); background: var(--surface); color: var(--ink); border-radius: 999px; padding: 4px 10px; font-size: var(--f13); cursor: pointer; min-width: 0; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pchips .chip:hover { background: var(--sunk); }
.pchips .chip small { color: var(--ink3); margin-left: 2px; }
a.link { text-decoration: none; display: inline-flex; align-items: center; }
