:root {
  --bg: #f3f4f6; --card: #fff; --ink: #1c2530; --muted: #6b7684; --line: #e3e6ea;
  --brand: #1f4e79; --brand-ink: #fff; --accent: #c2410c; --ok: #15803d; --warn: #b45309; --bad: #b91c1c;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink);
  font: 15px/1.55 -apple-system, "PingFang SC", "Microsoft YaHei", "Helvetica Neue", sans-serif; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

.top { background: var(--brand); color: var(--brand-ink); display: flex; align-items: center; gap: 10px;
  padding: 0 14px; height: 52px; position: sticky; top: 0; z-index: 30; }
.top .logo { font-weight: 700; font-size: 17px; white-space: nowrap; color: #fff; display: flex; align-items: center; gap: 8px; }
.top .logo .logo-img { height: 34px; width: auto; display: block; }
.top .logo:hover { text-decoration: none; }
.top .sp { flex: 1; }
.top .who { color: #d6e2ee; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 9em; }
.top .out { color: #d6e2ee; white-space: nowrap; font-size: 13px; }
.navbtn { background: none; border: 0; color: #fff; font-size: 22px; line-height: 1; padding: 8px 10px; margin-left: -6px;
  cursor: pointer; border-radius: 6px; }
.navbtn:hover { background: rgba(255,255,255,.12); }

.side { position: fixed; top: 52px; left: 0; bottom: 0; width: 168px; background: #fff; border-right: 1px solid var(--line);
  overflow-y: auto; padding: 8px 0 24px; z-index: 20; transition: transform .2s ease; }
.side a { display: block; padding: 11px 20px; color: var(--ink); font-size: 15px; border-left: 3px solid transparent; }
.side a:hover { background: #f3f6fa; text-decoration: none; }
.side a.sub { padding-left: 36px; font-size: 14px; color: var(--muted); }
.side a.on { background: #e8f0f8; color: var(--brand); border-left-color: var(--brand); font-weight: 600; }
.scrim { display: none; }
body.has-side main { margin-left: 168px; transition: margin .2s ease; }
body.nav-closed .side { transform: translateX(-100%); }
body.nav-closed main { margin-left: 0; }

main { max-width: 1180px; margin: 0 auto; padding: 16px; }
h1 { font-size: 20px; margin: 4px 0 14px; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
h2 { font-size: 16px; margin: 0 0 10px; }
.sub { color: var(--muted); font-size: 13px; font-weight: 400; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px;
  margin-bottom: 14px; }
.grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); margin-bottom: 14px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; }
.stat .k { color: var(--muted); font-size: 13px; }
.stat .v { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat .v small { font-size: 13px; font-weight: 400; color: var(--muted); }
.cols { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }

.flash { background: #fff7e6; border: 1px solid #f5d491; color: #7a4b00; padding: 9px 14px; border-radius: 8px;
  margin-bottom: 12px; }

.tw { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-variant-numeric: tabular-nums; }
th, td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
th { color: var(--muted); font-weight: 500; font-size: 13px; background: #fafbfc; }
td.r, th.r { text-align: right; }
tr:last-child td { border-bottom: 0; }
tfoot td { font-weight: 700; border-top: 2px solid var(--line); }
.empty { color: var(--muted); padding: 18px 0; text-align: center; }

.btn { display: inline-block; background: var(--brand); color: #fff; border: 0; border-radius: 7px;
  padding: 8px 16px; font-size: 14px; cursor: pointer; font-family: inherit; }
.btn:hover { filter: brightness(1.1); text-decoration: none; }
.btn.ghost { background: #fff; color: var(--brand); border: 1px solid var(--brand); }
.btn.sm { padding: 4px 10px; font-size: 13px; }
.btn.danger { background: #fff; color: var(--bad); border: 1px solid var(--bad); }
.linkbtn { background: none; border: 0; color: var(--brand); cursor: pointer; padding: 0; font: inherit; }
.linkbtn.danger { color: var(--bad); }
form.inline { display: inline; }

label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 3px; }
input, select, textarea { width: 100%; padding: 8px 10px; border: 1px solid #cfd5dc; border-radius: 7px;
  font: inherit; background: #fff; color: var(--ink); }
input:focus, select:focus, textarea:focus { outline: 2px solid #9fc0df; border-color: var(--brand); }
.fields { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); margin-bottom: 12px; }
.fields .wide { grid-column: 1 / -1; }
.lines td { padding: 5px 4px; border: 0; }
.lines th { background: none; padding: 4px; }
.lines input, .lines select { min-width: 86px; }
.lines select { min-width: 220px; }
.bar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-top: 12px; }
.bar .sp { flex: 1; }
.total { font-size: 18px; font-weight: 700; }

.tag { display: inline-block; padding: 1px 8px; border-radius: 10px; font-size: 12px; background: #eef2f6; color: #44505c; }
.tag.ok { background: #e3f4e8; color: var(--ok); }
.tag.warn { background: #fdf0d9; color: var(--warn); }
.tag.bad { background: #fde4e4; color: var(--bad); }
.kv { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 6px 18px; }
.kv div span { color: var(--muted); margin-right: 6px; }

.login { max-width: 340px; margin: 12vh auto; }
.login .logo { display: block; width: 120px; height: auto; margin: 0 auto 8px; }
.login h1 { justify-content: center; }
.login .fields { grid-template-columns: 1fr; }

@media (max-width: 640px) {
  main { padding: 10px; }
  .top { padding: 0 10px; gap: 8px; }
  .stat .v { font-size: 19px; }
}
@media print {
  .top, .noprint, .flash { display: none !important; }
  body { background: #fff; }
  main { max-width: none; padding: 0; }
  .card { border: 0; padding: 0; }
}

.est { color: var(--muted); font-size: 13px; line-height: 1.7; }
.est .big { font-size: 20px; color: var(--brand); }
.est .big.ok { color: var(--ok); }
.est .big.bad { color: var(--bad); font-size: 16px; }

.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 3px; }
.cal .wd { text-align: center; font-size: 12px; color: var(--muted); padding: 2px 0; }
.cal .day { min-height: 62px; border: 1px solid var(--line); border-radius: 6px; padding: 3px 4px; background: #fff;
  overflow: hidden; }
.cal .day.past { background: #f6f7f9; color: #a3abb5; }
.cal .day.today { border-color: var(--brand); box-shadow: inset 0 0 0 1px var(--brand); }
.cal .dn { font-size: 12px; font-weight: 600; margin-bottom: 2px; }
.cal .dn span { font-weight: 400; color: var(--brand); margin-left: 3px; font-size: 11px; }
.chip { font-size: 11px; line-height: 1.35; border-radius: 4px; padding: 1px 4px; margin-top: 2px; white-space: nowrap;
  overflow: hidden; }
.cal .chip b { display: block; }
.chip.prod { background: #e3edf8; color: #1f4e79; }
.chip.ship { background: #e3f4e8; color: #15803d; }
@media (max-width: 640px) { .cal .day { min-height: 54px; padding: 2px; } .chip { font-size: 10px; padding: 0 2px; } }

input[type=checkbox], input[type=radio] { width: auto; margin-right: 4px; }
.checks { border: 1px solid var(--line); border-radius: 7px; padding: 8px 12px; margin-bottom: 12px; }
.checks > div { padding: 4px 0; }
.checks > div > b { display: inline-block; min-width: 4.5em; color: var(--muted); font-weight: 500; font-size: 13px; }
.checks label { display: inline-block; margin: 2px 14px 2px 0; color: var(--ink); font-size: 14px; white-space: nowrap; }

@media (max-width: 640px) {
  .fields { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .fields > div { min-width: 0; }
  .lines input { min-width: 0; }
  .lines select { min-width: 0; max-width: 130px; }
  .total { font-size: 16px; }
}

/* 手机：导航是抽屉，默认收起，点 ☰ 滑出 */
@media (max-width: 900px) {
  body.has-side main, body.nav-closed main { margin-left: 0; }
  .side { transform: translateX(-100%); width: 220px; box-shadow: 2px 0 12px rgba(0,0,0,.12); }
  body.nav-open .side { transform: none; }
  body.nav-open .scrim { display: block; position: fixed; inset: 52px 0 0 0; background: rgba(0,0,0,.3); z-index: 15; }
  body.nav-closed .side { transform: translateX(-100%); }
  body.nav-open.nav-closed .side { transform: none; }
}
@media (max-width: 640px) {
  input, select, textarea { font-size: 16px; }          /* iPhone 输入框小于 16px 会自动放大页面 */
  .btn { padding: 10px 16px; font-size: 15px; }
  .btn.sm { padding: 7px 12px; font-size: 14px; }
  h1 { font-size: 18px; }
  th, td { padding: 8px 8px; }
  .lines td { padding: 4px 2px; }
  .bar { gap: 8px; }
  .bar .btn:not(.sm):last-child { flex: 1 1 100%; }      /* 表单底部主按钮占满一行，好点 */
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .stat { padding: 10px 12px; }
  .top .who { display: none; }
}

.scanbox { display: flex; flex-direction: column; gap: 6px; }
.scanbtn { font-size: 17px; padding: 14px 18px; }
.scanmsg { padding: 8px 12px; border-radius: 7px; background: #e3f4e8; color: #14532d; font-size: 14px; }
.scanmsg.bad { background: #fde4e4; color: var(--bad); }
.cam { position: fixed; inset: 0; background: #000; z-index: 50; display: flex; flex-direction: column; }
.cam video { flex: 1; width: 100%; object-fit: cover; }
.cambar { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 14px 16px; color: #fff; background: rgba(0,0,0,.7); }

/* 生产过磅 */
h1.wh { justify-content: space-between; }
h1.wh .rec { margin-left: auto; }
.tabs { display: flex; gap: 0; border: 1px solid var(--brand); border-radius: 9px; overflow: hidden; margin-bottom: 12px; }
.tabs button, .tabs a { flex: 1; padding: 12px 6px; font-size: 16px; background: #fff; color: var(--brand); border: 0;
  border-left: 1px solid var(--brand); cursor: pointer; text-align: center; font-family: inherit; }
.tabs > :first-child { border-left: 0; }
.tabs .on { background: var(--brand); color: #fff; font-weight: 600; }
.tabs a:hover { text-decoration: none; }
.csearch { margin-bottom: 12px; }
.picked { margin: 8px 0 4px; font-size: 15px; }
.hits { display: flex; flex-wrap: wrap; gap: 6px; }
.hit { border: 1px solid var(--line); background: #fff; border-radius: 18px; padding: 7px 14px; font-size: 14px; cursor: pointer; font-family: inherit; }
.hit.on { border-color: var(--brand); background: #e8f0f8; color: var(--brand); font-weight: 600; }
.hit.none { border-style: dashed; color: var(--muted); }
.hit small { color: var(--muted); }
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 60; display: flex; align-items: center; justify-content: center; padding: 16px; }
.modal .box { background: #fff; border-radius: 12px; padding: 18px 20px; width: 100%; max-width: 420px; }
.modal .cfb > div { padding: 3px 0; font-size: 15px; }
.modal.only .btn:not(.ghost) { display: none; }
select option.common { font-weight: 700; }
.lines select[name=t] { min-width: 112px; max-width: none; }
.modal .bar .btn { flex: 1 1 0; }
.modal .bar .sp { display: none; }
.rackbox { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin-top: 12px; }
.rcell { display: flex; flex-direction: column; align-items: center; gap: 4px; border: 1px solid var(--line); border-radius: 9px;
  padding: 10px 8px; margin: 0; color: var(--ink); background: #fff; }
.rcell span { font-size: 16px; font-weight: 600; }
.rcell small { color: var(--muted); }
.rcell input { text-align: center; font-size: 18px; }
.rackbox .rcell:nth-child(1) span { color: #c0392b; }
.rackbox .rcell:nth-child(2) span { color: #1f6fb2; }
.rackbox .rcell:nth-child(3) span { color: #6b7684; }
#rackcheck { margin-top: 8px; font-size: 14px; }
.okmsg { color: var(--ok); }
.errmsg { color: var(--bad); font-weight: 600; }
#rpick { font-size: 16px; padding: 10px; }
.datebox { position: relative; width: 100%; padding: 8px 10px; border: 1px solid #cfd5dc; border-radius: 7px; background: #fff;
  cursor: pointer; min-height: 38px; font-size: inherit; }
.datebox .ph { color: var(--muted); }
.datebox input[type=date] { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; border: 0; padding: 0; cursor: pointer; }
.datebox input[type=date]::-webkit-calendar-picker-indicator { position: absolute; inset: 0; width: auto; height: auto; opacity: 0; cursor: pointer; }
@media (max-width: 640px) { .datebox { font-size: 16px; min-height: 42px; } }
.rackret { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 18px; margin: 10px 0 0; padding: 10px 12px;
  background: #f8fafc; border: 1px solid var(--line); border-radius: 9px; font-size: 15px; }
.rackret b { color: var(--accent); font-size: 18px; }
.rackret label { display: flex; align-items: center; gap: 6px; margin: 0; color: var(--ink); font-size: 15px; }
.rackret input { width: 110px; text-align: center; font-size: 17px; }
.twobtn .btn { flex: 1 1 0; }
td.dt { white-space: nowrap; color: var(--muted); }
