:root {
  --bg: #f4f5f7;
  --card: #ffffff;
  --text: #111827;
  --muted: #6b7280;
  --line: #e5e7eb;
  --soft: #f9fafb;
  --primary: #1f6feb;
  --ok: #15803d;
  --warn: #b45309;
  --danger: #b91c1c;
  --radius: 10px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0; padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Helvetica Neue", "Microsoft YaHei", sans-serif;
  font-size: 14px;
  line-height: 1.55;
}

button, input, select, textarea { font-family: inherit; font-size: 14px; color: inherit; }
button { cursor: pointer; border: none; background: none; }

.topbar {
  position: sticky; top: 0; z-index: 20;
  background: var(--card);
  border-bottom: 1px solid var(--line);
}
.topbar-inner {
  max-width: 1080px; margin: 0 auto;
  display: flex; align-items: center; gap: 12px;
  padding: 10px 14px;
}
.brand { font-size: 15px; font-weight: 600; letter-spacing: .2px; }
.brand small { font-weight: 400; color: var(--muted); margin-left: 6px; font-size: 12px; }
.spacer { flex: 1; }

.tabs {
  display: flex; gap: 4px;
  max-width: 1080px; margin: 0 auto; padding: 0 10px 8px;
}
.tab {
  flex: 1; text-align: center;
  padding: 8px 6px; border-radius: 8px;
  font-size: 13px; color: var(--muted);
  background: var(--soft); border: 1px solid transparent;
}
.tab.on { background: #eaf1fe; color: var(--primary); border-color: #cfe0fc; font-weight: 500; }
.tab .n { font-size: 11px; opacity: .85; margin-left: 3px; }

.wrap { max-width: 1080px; margin: 0 auto; padding: 12px 14px 90px; }

.chips { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }
.chip {
  padding: 5px 11px; border-radius: 999px; font-size: 12px;
  background: var(--card); border: 1px solid var(--line); color: #374151;
}
.chip.on { background: #111827; border-color: #111827; color: #fff; }

.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 12px 14px;
  margin-bottom: 10px;
}
.card.tap:active { background: var(--soft); }

.row { display: flex; align-items: center; gap: 8px; }
.row.top { align-items: flex-start; }
.grow { flex: 1; min-width: 0; }

.oid { font-size: 14px; font-weight: 600; letter-spacing: .3px; }
.cust { font-size: 14px; color: #1f2937; margin-top: 2px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sub { font-size: 12.5px; color: var(--muted); margin-top: 4px; }
.money { font-size: 17px; font-weight: 700; font-variant-numeric: tabular-nums; }

.badge {
  display: inline-block; padding: 2px 8px; border-radius: 6px;
  font-size: 12px; white-space: nowrap;
}
.b1 { background: #f3f4f6; color: #4b5563; }
.b2 { background: #eef2ff; color: #4338ca; }
.b3 { background: #fef3c7; color: #92400e; }
.b4 { background: #e0f2fe; color: #0369a1; }
.b5 { background: #ede9fe; color: #6d28d9; }
.b6 { background: #fef9c3; color: #854d0e; }
.b7 { background: #ffe4e6; color: #be123c; }
.b8 { background: #dcfce7; color: #15803d; }
.b9 { background: #f3f4f6; color: #9ca3af; }
.b10 { background: #f3f4f6; color: #6b7280; }

.al { font-size: 12.5px; padding: 2px 7px; border-radius: 5px; white-space: nowrap; }
.al-danger { background: #fee2e2; color: var(--danger); }
.al-warn { background: #fef3c7; color: var(--warn); }
.al-ok { background: #f0fdf4; color: var(--ok); }

.stats { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 8px; margin-bottom: 12px; }
.stat { background: var(--soft); border-radius: 8px; padding: 9px 11px; }
.stat .k { font-size: 12px; color: var(--muted); }
.stat .v { font-size: 18px; font-weight: 700; margin-top: 2px; font-variant-numeric: tabular-nums; }
.stat .v.sm { font-size: 15px; }

.sec-title {
  font-size: 12.5px; color: var(--muted);
  margin: 16px 0 8px; letter-spacing: .5px;
}

.tl { position: relative; padding-left: 18px; }
.tl::before {
  content: ""; position: absolute; left: 5px; top: 6px; bottom: 6px;
  width: 1px; background: var(--line);
}
.tl-item { position: relative; padding: 0 0 14px; }
.tl-item::before {
  content: ""; position: absolute; left: -17px; top: 5px;
  width: 9px; height: 9px; border-radius: 50%;
  background: #fff; border: 2px solid #d1d5db;
}
.tl-item.done::before { border-color: var(--ok); background: var(--ok); }
.tl-item.doing::before { border-color: var(--warn); background: #fff; }
.tl-t { font-size: 13px; font-weight: 500; }
.tl-d { font-size: 12.5px; color: var(--muted); margin-top: 2px; }

.list-item {
  display: flex; justify-content: space-between; gap: 10px;
  padding: 10px 0; border-bottom: 1px dashed var(--line); font-size: 14px;
}
.list-item:last-child { border-bottom: none; }
.list-item .r { color: #1f2937; font-weight: 500; font-size: 13.5px; text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }

.field { margin-bottom: 12px; }
.field label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 5px; }
.field input, .field select, .field textarea {
  width: 100%; padding: 10px 11px;
  border: 1px solid var(--line); border-radius: 8px;
  background: #fff; outline: none;
}
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--primary); }
.field .hint { font-size: 11px; color: var(--muted); margin-top: 4px; }
.field2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.seg { display: flex; gap: 6px; }
.seg button {
  flex: 1; padding: 9px 0; border-radius: 8px; font-size: 13px;
  background: var(--soft); border: 1px solid var(--line); color: #374151;
}
.seg button.on { background: #eaf1fe; border-color: #cfe0fc; color: var(--primary); font-weight: 500; }

.stepper { display: flex; align-items: center; gap: 8px; }
.stepper button {
  width: 44px; height: 44px; border-radius: 8px;
  background: var(--soft); border: 1px solid var(--line);
  font-size: 20px; color: #374151; line-height: 1;
}
.stepper input {
  flex: 1; text-align: center; font-size: 24px; font-weight: 600;
  padding: 8px 0; border: 1px solid var(--line); border-radius: 8px;
  font-variant-numeric: tabular-nums;
}

.calc {
  background: var(--soft); border-radius: 8px; padding: 10px 12px;
  margin: 10px 0; font-size: 13px;
}
.calc .l { display: flex; justify-content: space-between; gap: 8px; }
.calc .l + .l { margin-top: 4px; font-size: 12px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 10px 16px; border-radius: 8px; font-size: 14px;
  background: var(--soft); border: 1px solid var(--line); color: #374151;
}
.btn-primary { background: #111827; color: #fff; border-color: #111827; font-weight: 500; }
.btn-line { background: #fff; }
.btn-sm { padding: 7px 12px; font-size: 13px; }
.btn-block { width: 100%; }
.btn-row { display: flex; gap: 8px; margin-top: 14px; }
.btn-row .btn { flex: 1; }

.fab {
  position: fixed; right: 16px; bottom: 20px; z-index: 30;
  background: #111827; color: #fff;
  padding: 12px 20px; border-radius: 999px; font-size: 14px; font-weight: 500;
  box-shadow: 0 4px 14px rgba(17,24,39,.18);
}

.mask {
  position: fixed; inset: 0; background: rgba(17,24,39,.35);
  z-index: 40; display: flex; align-items: flex-end; justify-content: center;
}
.sheet {
  width: 100%; max-width: 560px; background: #fff;
  border-radius: 14px 14px 0 0; padding: 14px 16px 18px;
  max-height: 92vh; overflow-y: auto;
}
.sheet-h { display: flex; align-items: center; margin-bottom: 12px; }
.sheet-h .t { font-size: 15px; font-weight: 600; }
.sheet-h .x { margin-left: auto; font-size: 22px; color: var(--muted); line-height: 1; padding: 0 4px; }

.empty { text-align: center; color: var(--muted); font-size: 13px; padding: 40px 0; }

.tblwrap { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow-x: auto; }
table.grid { width: 100%; border-collapse: collapse; font-size: 12px; white-space: nowrap; }
table.grid th {
  text-align: left; font-weight: 500; color: var(--muted);
  padding: 9px 10px; border-bottom: 1px solid var(--line); background: var(--soft);
}
table.grid td { padding: 9px 10px; border-bottom: 1px solid var(--line); font-variant-numeric: tabular-nums; }
table.grid tr:last-child td { border-bottom: none; }
table.grid tr.tap:hover { background: var(--soft); cursor: pointer; }
.num { text-align: right; }
.lock { background: var(--soft); color: var(--muted); }
.danger { color: var(--danger); }
.warnc { color: var(--warn); }
.okc { color: var(--ok); }

.desk { display: none; }
.mob { display: block; }
@media (min-width: 860px) {
  .desk { display: block; }
  .mob { display: none; }
  .stats { grid-template-columns: repeat(4, minmax(0,1fr)); }
  .wrap { padding-bottom: 40px; }
  .fab { right: calc(50% - 520px); }
  .mask { align-items: center; }
  .sheet { border-radius: 14px; max-height: 86vh; }
  .sheet-h .x { display: none; }
}

/* 搜索框 */
.searchbox { position: relative; margin: 0 0 10px; }
.searchbox input {
  width: 100%; padding: 9px 32px 9px 32px;
  border: 1px solid var(--line); border-radius: 9px;
  background: var(--card) url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='15' height='15' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='M20 20l-3.5-3.5'/%3E%3C/svg%3E") no-repeat 10px center;
  font-size: 13px; outline: none;
}
.searchbox input:focus { border-color: #c7d7f5; box-shadow: 0 0 0 3px #eef4ff; }
.searchbox input::-webkit-search-cancel-button { display: none; }
.qclr {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  width: 22px; height: 22px; border-radius: 50%;
  background: #eef0f3; color: var(--muted); font-size: 14px; line-height: 1;
}

/* 顶部操作人 */
.whosel {
  border: 1px solid var(--line); border-radius: 7px;
  background: var(--soft); color: var(--text);
  padding: 4px 6px; font-size: 12px; max-width: 90px;
}

/* 设置菜单 */
.menu { display: flex; flex-direction: column; gap: 8px; padding: 4px 0 8px; }
.mi {
  text-align: left; padding: 12px 14px; border-radius: 9px;
  background: var(--soft); border: 1px solid var(--line); font-size: 14px;
}
.mi.danger { color: var(--danger); }

/* 明细行里的改/删按钮不换行 */
.list-item .r { display: flex; align-items: center; gap: 4px; white-space: nowrap; }

/* 进入系统时的选人页 */
.gate {
  z-index: 60; align-items: center; padding: 18px;
  background: rgba(244, 245, 247, .97);
}
.gate[hidden] { display: none; }
.gate-card {
  width: 100%; max-width: 400px;
  background: #fff; border: 1px solid var(--line);
  border-radius: 16px; padding: 26px 20px 16px;
  box-shadow: 0 12px 34px rgba(17, 24, 39, .10);
}
.gate-brand { font-size: 18px; font-weight: 600; text-align: center; letter-spacing: .5px; }
.gate-sub {
  font-size: 13px; color: var(--muted); text-align: center;
  margin: 8px 0 18px; line-height: 1.6;
}
.role {
  display: flex; align-items: center; gap: 12px; width: 100%;
  padding: 12px 13px; border: 1px solid var(--line);
  border-radius: 11px; background: var(--soft); text-align: left;
}
.role + .role { margin-top: 9px; }
.role:active { background: #eaf1fe; }
.role.on { border-color: #cfe0fc; background: #eaf1fe; }
.rav {
  width: 36px; height: 36px; border-radius: 50%;
  background: #111827; color: #fff; flex: none;
  display: flex; align-items: center; justify-content: center;
  font-size: 15px; font-weight: 500;
}
.role.on .rav { background: var(--primary); }
.role .col { display: flex; flex-direction: column; }
.role .rn { font-size: 15px; font-weight: 600; }
.role .rl { font-size: 12px; color: var(--muted); }
.role .rk { margin-left: auto; font-size: 11px; color: var(--primary); }
.gate-foot {
  margin-top: 16px; font-size: 11px; color: var(--muted);
  text-align: center; line-height: 1.6;
}
.gate-back { margin-top: 6px; font-size: 13px; color: var(--primary); padding: 6px 12px; }

/* 顶栏当前操作人 */
.whochip {
  border: 1px solid var(--line); background: var(--soft);
  border-radius: 7px; padding: 4px 10px; font-size: 12px; color: var(--text);
}
.whochip.none { color: var(--warn); border-color: #fcd34d; background: #fffbeb; }

/* 排产计划（还没到发车日） */
.al-plan { background: #fff7ed; color: #c2410c; border: 1px solid #fed7aa; }
.list-item.pend { opacity: .82; }
.list-item.pend > div:first-child > div:first-child { color: #92400e; }

/* 客户名联想下拉 */
.sg {
  position: absolute; left: 0; right: 0; top: calc(100% + 4px); z-index: 40;
  background: #fff; border: 1px solid var(--line); border-radius: 10px;
  box-shadow: 0 10px 26px rgba(15, 23, 42, .16);
  max-height: 236px; overflow-y: auto;
}
.sg.up { top: auto; bottom: calc(100% + 4px); }
.sg-i {
  display: flex; align-items: center; gap: 8px;
  padding: 11px 12px; font-size: 14px; cursor: pointer;
}
.sg-i + .sg-i { border-top: 1px solid #f1f5f9; }
.sg-i > span { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sg-i em { font-style: normal; font-size: 11px; color: var(--muted); flex: none; }
.sg-i.on, .sg-i:hover, .sg-i:active { background: #f0f9f6; }

/* 排产日历 */
.cal-top { display: flex; align-items: center; gap: 8px; margin: 2px 0 10px; }
.cal-top .mt { font-size: 15px; font-weight: 600; }
.cal-top .sp { flex: 1; }
.cal-nav {
  width: 34px; height: 34px; border-radius: 8px; font-size: 18px; line-height: 1;
  border: 1px solid var(--line); background: var(--card); color: #374151;
}
.cal-today {
  height: 34px; padding: 0 12px; border-radius: 8px; font-size: 12px;
  border: 1px solid var(--line); background: var(--card); color: var(--primary);
}
.cal-week { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; margin-bottom: 5px; }
.cal-week span { text-align: center; font-size: 11px; color: var(--muted); }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal-d {
  min-height: 62px; border-radius: 9px; border: 1px solid transparent;
  background: var(--soft); padding: 5px 2px 4px;
  display: flex; flex-direction: column; align-items: center; gap: 1px;
}
.cal-d.out { background: transparent; }
.cal-d .dnum { font-size: 13px; color: #374151; line-height: 1.1; }
.cal-d .dtag { font-size: 11px; line-height: 1.15; color: var(--muted); }
.cal-d .dkg { font-size: 10.5px; line-height: 1.15; color: var(--muted); }
.cal-d.plan { background: #fff7ed; border-color: #fed7aa; }
.cal-d.plan .dnum { color: #c2410c; font-weight: 600; }
.cal-d.plan .dtag, .cal-d.plan .dkg { color: #c2410c; }
.cal-d.done { background: #f0fdf4; border-color: #bbf7d0; }
.cal-d.done .dtag, .cal-d.done .dkg { color: #15803d; }
.cal-d.today { outline: 2px solid var(--primary); outline-offset: -1px; }
.cal-d[data-day] { cursor: pointer; }
.cal-foot { margin-top: 10px; font-size: 11px; color: var(--muted); text-align: center; line-height: 1.7; }

/* 关键数值行：数量 × 单价 · 账期 */
.kv {
  display: flex; align-items: baseline; gap: 6px; flex-wrap: wrap;
  margin-top: 5px; font-size: 14.5px; color: #111827;
  font-variant-numeric: tabular-nums; line-height: 1.45;
}
.kv b { font-weight: 700; }
.kv .x { color: var(--muted); font-size: 12px; font-weight: 400; }
.ktag {
  font-size: 12px; color: #4b5563; background: #f3f4f6; border: 1px solid var(--line);
  border-radius: 5px; padding: 1px 7px; white-space: nowrap;
}

/* 搜索时的统计口径提示 */
.qnote {
  display: inline-block; margin: -4px 0 8px;
  font-size: 11.5px; color: #1d4ed8; background: #eff6ff;
  border-radius: 6px; padding: 4px 10px;
}

/* 市场单标记 */
.mtag {
  font-size: 11px; padding: 1px 6px; border-radius: 5px;
  background: #eef2ff; color: #4338ca; font-weight: 500;
  margin-left: 4px; vertical-align: 1.5px;
}

/* 市场单品种明细行 */
.itemrow {
  display: grid; grid-template-columns: 1fr 76px 70px 28px;
  gap: 6px; margin-bottom: 8px; align-items: center;
}
.itemrow input {
  width: 100%; padding: 9px 9px; border: 1px solid var(--line);
  border-radius: 8px; background: #fff; outline: none; font-size: 14px;
}
.itemrow input:focus { border-color: var(--primary); }
.itemrow .i-name { min-width: 0; }
.itemrow .i-del {
  width: 28px; height: 36px; border-radius: 8px;
  background: var(--soft); color: var(--muted); font-size: 16px; line-height: 1;
}
.additem { width: 100%; margin-top: 2px; }

/* 客户额度 / 催款 */
.tab .ndot {
  display: inline-block; width: 6px; height: 6px; border-radius: 50%;
  background: var(--danger); margin-left: 4px; vertical-align: 4px;
}
.qalert {
  display: flex; align-items: center; gap: 10px;
  background: #fef2f2; border: 1px solid #fecaca; color: #b91c1c;
  border-radius: 10px; padding: 10px 12px; margin-bottom: 10px;
  font-size: 13px; line-height: 1.5;
}
.qalert[data-gocust] { cursor: pointer; }
.qalert .qa-l { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.qalert .qa-l b { font-size: 13.5px; }
.qalert .qa-l span { font-size: 12px; color: #b45309; }
.qalert .qa-go { flex: none; font-size: 12.5px; color: #b91c1c; }
.qok {
  background: #f0fdf4; border: 1px solid #bbf7d0; color: #15803d;
  border-radius: 10px; padding: 10px 12px; margin-bottom: 10px;
  font-size: 12.5px; line-height: 1.6;
}
.qcard {
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  padding: 12px 13px; margin-bottom: 10px;
}
.qcard.over { border-color: #fecaca; background: #fffbfb; }
.qcard.near { border-color: #fed7aa; }
.qhd { display: flex; align-items: center; gap: 8px; }
.qhd b {
  flex: 1; min-width: 0; font-size: 14.5px; color: #111827;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.qrow { margin-top: 7px; }
.qrow .ql { font-size: 12.5px; color: var(--muted); }
.qrow .ql b { font-size: 18px; font-weight: 700; color: #111827; font-variant-numeric: tabular-nums; margin-left: 2px; }
.qcard.over .qrow .ql b { color: var(--danger); }
.qsub2 { font-size: 12px; color: #4b5563; margin-top: 3px; font-variant-numeric: tabular-nums; }
.qbar { height: 6px; border-radius: 999px; background: #f1f5f9; margin: 9px 0 7px; overflow: hidden; }
.qbar i { display: block; height: 100%; border-radius: 999px; background: var(--ok); }
.qbar i.near { background: #f59e0b; }
.qbar i.over { background: var(--danger); }
.qfoot { font-size: 11.5px; color: var(--muted); }
.qtag {
  flex: none; font-size: 11px; padding: 1px 7px; border-radius: 5px;
  background: #f3f4f6; color: #4b5563;
}
.qtag.near { background: #fff7ed; color: #c2410c; }
.qtag.over { background: #fee2e2; color: var(--danger); }

/* 口令入口 */
.pwc form { display: flex; gap: 8px; margin-top: 4px; }
.pwc input {
  flex: 1; min-width: 0; padding: 12px 14px; font-size: 16px;
  border: 1px solid var(--line); border-radius: 10px; background: #fff;
  outline: none; letter-spacing: 2px;
}
.pwc input:focus { border-color: var(--primary); }
.pwc .btn { flex: none; padding: 0 20px; height: 46px; border-radius: 10px; }
.pw-err {
  min-height: 18px; margin-top: 8px; text-align: center;
  font-size: 12.5px; color: var(--danger);
}
#pwgate { z-index: 70; }
