/* ============================================================
   计件管家 · 小工厂的订单 / 计件工资 / 产量统计
   纯静态样式，零外部依赖；浅色主题
   ============================================================ */
:root {
  --bg: #f4f3f0;
  --card: #ffffff;
  --ink: #1c2733;
  --ink2: #46586b;
  --ink3: #8494a5;
  --line: #e6e3dd;
  --brand: #2358e9;
  --brand-weak: #e9effd;
  --orange: #f26b1d;
  --orange-weak: #fdeee2;
  --teal: #0f9d8c;
  --teal-weak: #e2f5f2;
  --red: #d64541;
  --red-weak: #fdeceb;
  --gold: #c98a12;
  --gold-weak: #faf3df;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow-sm: 0 1px 3px rgba(28, 39, 51, .05);
  --shadow: 0 10px 28px -14px rgba(28, 39, 51, .18);
  --font: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei",
    "Segoe UI", "Noto Sans SC", sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.6;
}
button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, select, textarea { font-family: inherit; font-size: 14px; color: var(--ink); }
small { color: var(--ink3); }
b { font-weight: 700; }
em { font-style: normal; }

/* ---------------- 布局骨架 ---------------- */
.shell { display: flex; min-height: 100vh; }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.view { flex: 1; width: 100%; max-width: 1180px; margin: 0 auto; padding: 22px 26px 90px; }

/* 侧栏 */
.side {
  width: 232px; flex-shrink: 0; background: #fbfaf8;
  border-right: 1px solid var(--line);
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
}
.side-brand { display: flex; gap: 11px; align-items: center; padding: 20px 18px 16px; }
.side-brand .logo {
  width: 40px; height: 40px; border-radius: 12px; flex-shrink: 0;
  background: linear-gradient(135deg, #2358e9, #4b7bf5);
  color: #fff; font-weight: 800; font-size: 19px;
  display: flex; align-items: center; justify-content: center;
}
.side-brand b { font-size: 16px; display: block; letter-spacing: -.2px; }
.side-brand small { font-size: 11px; display: block; }
.side nav { padding: 6px 12px; flex: 1; overflow-y: auto; }
.nav-item {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 10px 12px; border-radius: 10px; margin-bottom: 2px;
  color: var(--ink2); font-size: 13.5px; font-weight: 500; text-align: left;
}
.nav-item svg { flex-shrink: 0; }
.nav-item:hover { background: #f1efe9; }
.nav-item.on { background: var(--brand-weak); color: var(--brand); font-weight: 600; }
.nav-group { font-size: 11px; color: var(--ink3); padding: 14px 12px 6px; letter-spacing: 1px; }
.side-foot { padding: 14px 18px; border-top: 1px solid var(--line); font-size: 11px; color: var(--ink3); line-height: 1.8; }
.side-foot b { color: var(--ink2); font-size: 12px; }

/* 顶栏 */
.topbar {
  display: none; position: sticky; top: 0; z-index: 30;
  background: rgba(251, 250, 248, .92); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
  padding: 12px 16px; align-items: center; gap: 10px;
}
.topbar-title { font-size: 16px; font-weight: 700; flex: 1; }
.topbar-date { font-size: 12px; color: var(--ink3); }
.icon-btn {
  width: 36px; height: 36px; border-radius: 10px;
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--ink2); border: 1px solid var(--line); background: #fff;
}
.menu-btn { display: none; }

/* ---------------- 通用组件 ---------------- */
.section { margin-top: 20px; }
.section-head { display: flex; align-items: baseline; gap: 10px; margin-bottom: 12px; }
.section-head h2 { font-size: 16px; letter-spacing: -.2px; }
.section-head .sub { font-size: 12px; color: var(--ink3); }
.section-head .act { margin-left: auto; display: flex; gap: 8px; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.card-head { display: flex; align-items: center; gap: 10px; padding: 15px 18px 0; }
.card-head h3 { font-size: 14.5px; }
.card-head .sub { font-size: 12px; color: var(--ink3); }
.card-head .head-act { margin-left: auto; display: flex; gap: 8px; }
.card-pad { padding: 14px 18px 18px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 16px; border-radius: 10px;
  background: var(--brand); color: #fff; font-size: 13.5px; font-weight: 600;
  transition: .15s;
}
.btn:hover { filter: brightness(1.06); }
.btn:active { transform: scale(.97); }
.b-sm { padding: 6px 12px; font-size: 12.5px; border-radius: 8px; }
.b-ghost { background: #fff; color: var(--ink2); border: 1px solid var(--line); }
.b-ghost:hover { border-color: #cfd8e2; filter: none; }
.b-orange { background: var(--orange); }
.b-teal { background: var(--teal); }
.b-danger { background: var(--red-weak); color: var(--red); border: 1px solid #f5c9c7; }

.chip {
  padding: 6px 13px; border-radius: 999px; font-size: 12.5px;
  background: #fff; border: 1px solid var(--line); color: var(--ink2); font-weight: 500;
}
.chip.on { background: var(--ink); border-color: var(--ink); color: #fff; }

.input, select.input, textarea.input {
  width: 100%; padding: 9px 12px; border-radius: 10px;
  border: 1px solid var(--line); background: #fff; outline: none; transition: .15s;
}
.input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-weak); }
.form-row { margin-bottom: 12px; }
.form-row label { display: block; font-size: 12.5px; color: var(--ink2); font-weight: 600; margin-bottom: 5px; }
.form-row .hint { font-weight: 400; color: var(--ink3); }
.form-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.pill { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 11px; font-weight: 600; background: #f1efe9; color: var(--ink2); }
.p-blue { background: var(--brand-weak); color: var(--brand); }
.p-orange { background: var(--orange-weak); color: var(--orange); }
.p-teal { background: var(--teal-weak); color: var(--teal); }
.p-red { background: var(--red-weak); color: var(--red); }
.p-gold { background: var(--gold-weak); color: var(--gold); }

.bar { height: 6px; border-radius: 4px; background: #edeae4; overflow: hidden; }
.bar i { display: block; height: 100%; border-radius: 4px; background: var(--brand); transition: width .3s; }
.bar-lg { height: 9px; border-radius: 6px; background: #edeae4; overflow: hidden; }
.bar-lg i { display: block; height: 100%; border-radius: 6px; background: var(--brand); }
.bar-orange i { background: var(--orange); }
.bar-teal i { background: var(--teal); }

/* toast / modal */
.toast {
  position: fixed; left: 50%; bottom: 96px; transform: translateX(-50%) translateY(16px);
  background: rgba(28, 39, 51, .92); color: #fff; font-size: 13px;
  padding: 10px 18px; border-radius: 999px; opacity: 0; pointer-events: none;
  transition: .22s; z-index: 90; max-width: 86vw; text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.mask {
  position: fixed; inset: 0; background: rgba(20, 28, 38, .45); z-index: 80;
  display: none; align-items: flex-start; justify-content: center; padding: 8vh 16px 16px;
}
.mask.show { display: flex; }
.modal {
  background: #fff; border-radius: 16px; width: 100%; max-width: 460px;
  box-shadow: var(--shadow); max-height: 82vh; display: flex; flex-direction: column;
}
.modal-head { display: flex; align-items: center; padding: 16px 18px 10px; }
.modal-head h3 { font-size: 15.5px; flex: 1; }
.modal-body { padding: 4px 18px 16px; overflow-y: auto; }
.modal-foot { display: flex; gap: 10px; justify-content: flex-end; padding: 12px 18px 16px; border-top: 1px solid var(--line); }

/* ---------------- 首屏 Hero ---------------- */
.hero {
  display: flex; gap: 20px; align-items: stretch;
  background: linear-gradient(120deg, #1d3f9e 0%, #2358e9 58%, #4b7bf5 100%);
  border-radius: 18px; padding: 26px 28px; color: #fff;
  box-shadow: 0 18px 40px -20px rgba(35, 88, 233, .55);
}
.hero-main { flex: 1.4; min-width: 0; }
.hero-kicker {
  display: inline-flex; align-items: center; gap: 7px;
  font-size: 11.5px; font-weight: 600; letter-spacing: .5px;
  background: rgba(255, 255, 255, .14); padding: 4px 12px; border-radius: 999px;
}
.hero h1 { font-size: 24px; line-height: 1.45; letter-spacing: -.4px; margin: 12px 0 8px; }
.hero h1 em { color: #ffd9a8; }
.hero p { font-size: 13px; opacity: .82; max-width: 460px; }
.hero-side { display: flex; gap: 12px; align-items: stretch; }
.mini {
  background: rgba(255, 255, 255, .1); border: 1px solid rgba(255, 255, 255, .18);
  border-radius: 12px; padding: 12px 16px; min-width: 108px;
  display: flex; flex-direction: column; justify-content: center;
}
.mini .k { font-size: 11px; opacity: .75; }
.mini .v { font-size: 24px; font-weight: 800; letter-spacing: -.5px; margin-top: 2px; }
.mini .v small { font-size: 11px; font-weight: 500; opacity: .7; margin-left: 2px; }
.mini .m { font-size: 10.5px; opacity: .65; margin-top: 2px; }

/* 待办提醒 */
.alert {
  display: flex; gap: 12px; align-items: flex-start;
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 16px; box-shadow: var(--shadow-sm);
}
.alert .al-ico { font-size: 20px; line-height: 1.3; }
.alert .al-body { flex: 1; min-width: 0; }
.alert .al-title { font-size: 13.5px; font-weight: 700; }
.alert .al-title.bad { color: var(--red); }
.alert .al-desc { font-size: 12px; color: var(--ink3); margin-top: 2px; }
.alert .btn { flex-shrink: 0; }
.a-red { border-left: 4px solid var(--red); }
.a-gold { border-left: 4px solid var(--gold); }
.a-teal { border-left: 4px solid var(--teal); }
.alerts { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

/* 统计卡 */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.stat {
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
  padding: 15px 16px 13px; box-shadow: var(--shadow-sm); position: relative; overflow: hidden;
}
.stat .st-ico { position: absolute; right: 12px; top: 12px; color: var(--ink3); opacity: .5; }
.stat .st-label { font-size: 12px; color: var(--ink3); font-weight: 500; }
.stat .st-num { font-size: 26px; font-weight: 800; letter-spacing: -.8px; margin-top: 3px; }
.stat .st-num small { font-size: 12px; font-weight: 600; color: var(--ink3); margin-left: 2px; }
.stat .st-foot { font-size: 11.5px; color: var(--ink3); margin-top: 4px; }
.s-blue .st-num { color: var(--brand); }
.s-orange .st-num { color: var(--orange); }
.s-teal .st-num { color: var(--teal); }
.s-gold .st-num { color: var(--gold); }

/* 周趋势图 */
.trend { display: flex; align-items: flex-end; gap: 10px; height: 132px; padding: 6px 4px 0; }
.t-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; justify-content: flex-end; }
.t-col .t-qty { font-size: 11px; color: var(--ink2); font-weight: 600; }
.t-bar { width: 100%; max-width: 44px; border-radius: 7px 7px 3px 3px; background: linear-gradient(180deg, #4b7bf5, #2358e9); min-height: 4px; }
.t-bar.dim { background: linear-gradient(180deg, #c9d8f8, #b3c7f4); }
.t-col .t-label { font-size: 10.5px; color: var(--ink3); }

/* 工人排行 */
.rank { display: flex; flex-direction: column; gap: 9px; }
.rank-row { display: flex; align-items: center; gap: 11px; }
.avatar {
  width: 34px; height: 34px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 14px; font-weight: 700;
}
.rank-row .rk-main { flex: 1; min-width: 0; }
.rank-row .rk-name { font-size: 13px; font-weight: 600; display: flex; gap: 6px; align-items: baseline; }
.rank-row .rk-name small { font-weight: 400; }
.rank-row .bar { margin-top: 4px; }
.rank-row .rk-num { text-align: right; flex-shrink: 0; }
.rank-row .rk-num b { font-size: 14px; }
.rank-row .rk-num small { display: block; font-size: 10.5px; }

/* ---------------- 记账页 ---------------- */
.date-nav { display: flex; align-items: center; gap: 10px; }
.date-nav .dn-btn { width: 32px; height: 32px; border-radius: 9px; border: 1px solid var(--line); background: #fff; display: flex; align-items: center; justify-content: center; color: var(--ink2); }
.date-nav .dn-date { font-size: 14px; font-weight: 700; min-width: 118px; text-align: center; }
.date-nav .dn-date small { display: block; font-size: 10.5px; font-weight: 400; }

.rec-grid { display: grid; grid-template-columns: 1.05fr 1fr; gap: 14px; align-items: start; }
.worker-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.w-tile {
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 12px 12px; text-align: center; box-shadow: var(--shadow-sm);
  transition: .15s; position: relative;
}
.w-tile:hover { border-color: #c9d6f5; box-shadow: var(--shadow); transform: translateY(-1px); }
.w-tile .avatar { margin: 0 auto 8px; }
.w-tile .w-name { font-size: 13.5px; font-weight: 700; }
.w-tile .w-role { font-size: 11px; color: var(--ink3); }
.w-tile .w-today { margin-top: 8px; padding-top: 8px; border-top: 1px dashed var(--line); font-size: 11.5px; color: var(--ink2); }
.w-tile .w-today b { font-size: 16px; color: var(--brand); }
.w-tile .w-today .amt { color: var(--orange); font-weight: 700; }
.w-tile .w-flag { position: absolute; top: 10px; right: 10px; font-size: 10px; }

.entry-list { display: flex; flex-direction: column; gap: 8px; max-height: 520px; overflow-y: auto; }
.entry {
  display: flex; align-items: center; gap: 10px;
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 10px 12px; box-shadow: var(--shadow-sm);
}
.entry .e-ava { width: 30px; height: 30px; border-radius: 50%; flex-shrink: 0; display: flex; align-items: center; justify-content: center; color: #fff; font-size: 12px; font-weight: 700; }
.entry .e-main { flex: 1; min-width: 0; }
.entry .e-line1 { font-size: 13px; }
.entry .e-line1 b { font-weight: 700; }
.entry .e-line2 { font-size: 11px; color: var(--ink3); }
.entry .e-amt { font-size: 14.5px; font-weight: 800; color: var(--orange); flex-shrink: 0; }
.entry .e-amt small { font-weight: 500; }
.entry .e-del { width: 26px; height: 26px; border-radius: 8px; color: var(--ink3); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.entry .e-del:hover { background: var(--red-weak); color: var(--red); }

/* 计件弹窗里的产品选择 */
.prod-pick { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 12px; }
.pp {
  border: 1.5px solid var(--line); border-radius: 10px; padding: 10px 12px;
  text-align: left; background: #fff; transition: .12s;
}
.pp .pp-name { font-size: 13px; font-weight: 600; }
.pp .pp-price { font-size: 11.5px; color: var(--orange); font-weight: 700; }
.pp.on { border-color: var(--brand); background: var(--brand-weak); }
.qty-row { display: flex; gap: 10px; align-items: center; }
.qty-row .input { flex: 1; font-size: 20px; font-weight: 800; text-align: center; letter-spacing: 1px; }
.qty-step { width: 44px; height: 44px; border-radius: 10px; border: 1px solid var(--line); background: #fff; font-size: 20px; font-weight: 700; color: var(--ink2); flex-shrink: 0; }
.qty-step:active { background: #f1efe9; }
.calc-line { font-size: 12.5px; color: var(--ink2); margin-top: 10px; text-align: center; }
.calc-line b { color: var(--orange); font-size: 17px; }

/* ---------------- 订单页 ---------------- */
.order-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; }
.order {
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px 18px 14px; box-shadow: var(--shadow-sm); position: relative;
  display: flex; flex-direction: column;
}
.order .o-foot { margin-top: auto; }
.order.hot { border-left: 4px solid var(--red); }
.order .o-top { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.order .o-no { font-size: 11px; color: var(--ink3); font-family: ui-monospace, monospace; }
.order .o-cust { font-size: 15px; font-weight: 700; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.order .o-prod { font-size: 12.5px; color: var(--ink2); margin-top: 2px; }
.order .o-meta { display: flex; gap: 14px; margin-top: 10px; font-size: 11.5px; color: var(--ink3); }
.order .o-meta b { color: var(--ink); font-size: 13px; }
.order .o-done { margin-top: 10px; display: flex; align-items: center; gap: 10px; }
.order .o-done .bar { flex: 1; }
.order .o-done .od-txt { font-size: 11.5px; color: var(--ink2); flex-shrink: 0; white-space: nowrap; }
.order .o-foot { display: flex; gap: 8px; margin-top: auto; padding-top: 12px; align-items: center; }
.order .o-due { font-size: 11.5px; margin-left: auto; }
.order .o-due .d-ok { color: var(--teal); font-weight: 600; }
.order .o-due .d-warn { color: var(--gold); font-weight: 600; }
.order .o-due .d-hot { color: var(--red); font-weight: 700; }

/* ---------------- 工资页 ---------------- */
.pay-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; align-items: start; }
.pay-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.pay-table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.pay-table th { text-align: left; font-size: 11px; color: var(--ink3); font-weight: 600; padding: 7px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.pay-table td { padding: 9px 8px; border-bottom: 1px solid #f1efe9; }
.pay-table td.num, .pay-table th.num { text-align: right; }
.pay-table tr.total td { font-weight: 700; border-bottom: none; background: #fbfaf8; }
.pay-preview {
  background: #fbfaf8; border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 14px 16px; font-size: 12.5px; line-height: 2; color: var(--ink2);
  white-space: pre-wrap; word-break: break-all; max-height: 600px; overflow-y: auto;
}

/* ---------------- 工人/设置 ---------------- */
.wk-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.wk-card { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 15px 16px; box-shadow: var(--shadow-sm); position: relative; }
.wk-card .wk-top { display: flex; align-items: center; gap: 10px; }
.wk-card .wk-name { font-size: 14.5px; font-weight: 700; }
.wk-card .wk-role { font-size: 11.5px; color: var(--ink3); }
.wk-card .wk-nums { display: flex; gap: 18px; margin-top: 11px; padding-top: 11px; border-top: 1px dashed var(--line); }
.wk-card .wk-nums .n .v { font-size: 17px; font-weight: 800; }
.wk-card .wk-nums .n .v.o { color: var(--orange); }
.wk-card .wk-nums .n .k { font-size: 10.5px; color: var(--ink3); }
.wk-card .wk-act { position: absolute; top: 12px; right: 12px; display: flex; gap: 4px; }
.wk-card .wk-act button { width: 26px; height: 26px; border-radius: 8px; color: var(--ink3); display: flex; align-items: center; justify-content: center; }
.wk-card .wk-act button:hover { background: #f1efe9; color: var(--ink); }

.prod-row { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid #f1efe9; }
.prod-row:last-child { border-bottom: none; }
.prod-row .pr-name { font-weight: 600; font-size: 13.5px; flex: 1; }
.prod-row .pr-price { font-size: 13px; color: var(--orange); font-weight: 700; }
.prod-row .pr-act { display: flex; gap: 4px; }
.set-block { display: flex; align-items: center; gap: 12px; padding: 13px 0; border-bottom: 1px solid #f1efe9; }
.set-block:last-child { border-bottom: none; }
.set-block .sb-body { flex: 1; min-width: 0; }
.set-block .sb-title { font-size: 13px; font-weight: 600; }
.set-block .sb-desc { font-size: 11.5px; color: var(--ink3); margin-top: 1px; }

.empty { text-align: center; padding: 44px 20px; }
.empty .e-ico { font-size: 34px; }
.empty .e-txt { font-size: 13px; color: var(--ink3); margin-top: 8px; }

/* ---------------- 移动端 tabbar ---------------- */
.tabbar {
  display: none; position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  background: rgba(255, 255, 255, .96); backdrop-filter: blur(10px);
  border-top: 1px solid var(--line);
  padding: 6px 8px calc(8px + env(safe-area-inset-bottom));
}
.tab-item { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 5px 0; color: var(--ink3); font-size: 10.5px; border-radius: 10px; }
.tab-item.on { color: var(--brand); font-weight: 600; }
.tab-item svg { width: 21px; height: 21px; }

.side-mask { display: none; }

@media (max-width: 900px) {
  .side {
    position: fixed; left: 0; top: 0; bottom: 0; z-index: 60;
    transform: translateX(-105%); transition: transform .25s;
    box-shadow: 0 0 60px rgba(0, 0, 0, .18);
  }
  .shell.side-open .side { transform: translateX(0); }
  .shell.side-open .side-mask { display: block; position: fixed; inset: 0; background: rgba(20, 28, 38, .4); z-index: 50; }
  .menu-btn { display: inline-flex; }
  .topbar { display: flex; }
  .view { padding: 16px 14px calc(96px + env(safe-area-inset-bottom)); }
  .tabbar { display: flex; }
  .hero { flex-direction: column; padding: 20px 18px; gap: 14px; }
  .hero h1 { font-size: 20px; }
  .hero-side { width: 100%; }
  .mini { flex: 1; min-width: 0; padding: 10px 12px; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .alerts { grid-template-columns: 1fr; }
  .rec-grid, .pay-grid { grid-template-columns: 1fr; }
  .order-grid { grid-template-columns: 1fr; }
  .worker-grid { grid-template-columns: repeat(2, 1fr); }
  .wk-grid { grid-template-columns: 1fr; }
  .form-2 { grid-template-columns: 1fr; }
  .section { margin-top: 16px; }
  .pay-preview { max-height: none; }
}
