/* 订单跟踪与出入库系统 · 移动端优先（浅色） */
:root {
  --bg: #f4f6fa; --card: #fff; --text: #1c2330; --muted: #7a8399; --line: #e6eaf2;
  --primary: #1e6bff; --primary-dark: #1554d1; --green: #0ea66b; --orange: #f0883a;
  --red: #e5484d; --radius: 14px;
}
* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
body { font-family: -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif; background: var(--bg); color: var(--text); font-size: 15px; }
.hidden { display: none !important; }
.view { min-height: 100vh; }

/* 登录 */
#view-login { display: flex; align-items: center; justify-content: center; padding: 20px; }
.login-card { background: var(--card); width: 100%; max-width: 380px; border-radius: 20px; padding: 36px 26px; box-shadow: 0 8px 40px rgba(20,40,90,.10); text-align: center; }
.login-logo { font-size: 50px; }
.login-card h1 { font-size: 22px; margin: 8px 0 2px; }
.login-card .sub { color: var(--muted); font-size: 13px; margin-bottom: 22px; }
.tip { font-size: 12px; color: var(--muted); margin-top: 14px; line-height: 1.5; }
.err { color: var(--red); font-size: 13px; margin-top: 10px; }

/* 通用 */
.field { margin-bottom: 12px; text-align: left; flex: 1; min-width: 0; }
.field label { display: block; font-size: 12.5px; color: var(--muted); margin-bottom: 5px; }
.hint { font-weight: 400; font-size: 12px; color: var(--muted); }
input, select { width: 100%; padding: 11px 12px; border: 1.5px solid var(--line); border-radius: 10px; font-size: 15px; background: #fbfcfe; color: var(--text); }
input:focus, select:focus { outline: none; border-color: var(--primary); }
.row2 { display: flex; gap: 8px; }
.btn { border: none; border-radius: 10px; padding: 10px 16px; font-size: 15px; cursor: pointer; font-weight: 600; background: #e8edf6; color: var(--text); }
.btn.primary { background: var(--primary); color: #fff; }
.btn.primary:active { background: var(--primary-dark); }
.btn.danger { background: #fdeaea; color: var(--red); }
.btn.ghost { background: transparent; border: 1.5px solid var(--line); }
.btn.big { width: 100%; padding: 13px; font-size: 16px; }
.btn.small { padding: 6px 12px; font-size: 13px; }
.btn:disabled { opacity: .55; }

/* 顶栏 */
.topbar { position: sticky; top: 0; z-index: 20; background: var(--primary); color: #fff; padding: 14px 16px; display: flex; align-items: center; gap: 10px; }
.topbar h2 { font-size: 18px; flex: 1; }
.whoami { font-size: 12.5px; background: rgba(255,255,255,.18); padding: 4px 10px; border-radius: 20px; white-space: nowrap; }
.back-btn { background: none; border: none; color: #fff; font-size: 30px; line-height: 1; padding: 0 4px 4px 0; cursor: pointer; }
#content { padding: 14px 14px 84px; max-width: 760px; margin: 0 auto; }

/* 底部导航 */
.tabbar { position: fixed; bottom: 0; left: 0; right: 0; z-index: 30; display: flex; background: #fff; border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
.tab { flex: 1; border: none; background: none; padding: 7px 0 9px; font-size: 11px; color: var(--muted); display: flex; flex-direction: column; gap: 2px; align-items: center; cursor: pointer; }
.tab .ico { font-size: 21px; filter: grayscale(1) opacity(.55); }
.tab.active { color: var(--primary); font-weight: 700; }
.tab.active .ico { filter: none; }

/* 卡片 */
.card { background: var(--card); border-radius: var(--radius); padding: 16px; margin-bottom: 12px; box-shadow: 0 1px 3px rgba(20,40,90,.05); }
.card h3 { font-size: 15.5px; }
.card h4 { font-size: 13.5px; margin: 16px 0 8px; color: var(--muted); }
.card-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 12px; gap: 8px; }

/* 概览 */
.hero { background: linear-gradient(135deg, #1e6bff, #4a8cff); border-radius: var(--radius); padding: 18px; color: #fff; display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; box-shadow: 0 6px 18px rgba(30,107,255,.22); }
.hero-label { font-size: 12.5px; opacity: .85; }
.hero-num { display: flex; align-items: baseline; gap: 4px; margin: 2px 0; }
.hero-num b { font-size: 34px; font-weight: 800; letter-spacing: -.5px; }
.hero-num span { font-size: 13px; opacity: .9; }
.hero-sub { font-size: 12px; opacity: .9; }
.hero-side { text-align: right; display: flex; flex-direction: column; gap: 10px; }
.hero-side div { background: rgba(255,255,255,.15); border-radius: 10px; padding: 7px 12px; min-width: 96px; }
.hero-side span { display: block; font-size: 11.5px; opacity: .85; }
.hero-side b { font-size: 17px; }

.step-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.step-chip { background: #f3f6fb; border-radius: 10px; padding: 8px 12px; font-size: 13px; color: var(--text); border: 1px solid #e8eef7; cursor: pointer; }
.step-chip b { color: var(--orange); font-size: 15px; margin-left: 4px; }
.step-chip.zero b { color: var(--muted); }
.aging-row { display: flex; gap: 10px; }
.aging-item { flex: 1; background: #f7f9fc; border-radius: 10px; padding: 10px 14px; }
.aging-item b { font-size: 22px; color: var(--red); }
.aging-item span { display: block; font-size: 12px; color: var(--muted); margin-top: 2px; }
.aging-item.warn b { color: var(--orange); }

.timeline { display: flex; flex-direction: column; gap: 10px; }
.tl-item { display: flex; gap: 10px; font-size: 13.5px; align-items: flex-start; }
.tl-dot { width: 22px; height: 22px; border-radius: 50%; flex-shrink: 0; display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 700; color: #fff; }
.tl-dot.in { background: var(--green); }
.tl-dot.out { background: var(--primary); }
.tl-main { flex: 1; min-width: 0; }
.tl-main .t1 { font-weight: 600; }
.tl-main .t1 span { font-family: monospace; }
.tl-main .t2 { font-size: 12px; color: var(--muted); margin-top: 1px; }

/* 列表 */
.list { display: flex; flex-direction: column; gap: 8px; }
.list.slim { gap: 0; }
.list.slim > * { border-bottom: 1px solid var(--line); }
.list.slim > *:last-child { border-bottom: none; }
.more-wrap { text-align: center; margin-top: 12px; }

/* 合同卡 */
.c-row { background: var(--card); border-radius: var(--radius); padding: 12px 14px; cursor: pointer; box-shadow: 0 1px 3px rgba(20,40,90,.05); }
.c-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.c-no { font-family: monospace; font-weight: 700; font-size: 15px; word-break: break-all; }
.c-mid { display: flex; gap: 12px; font-size: 12.5px; color: var(--muted); margin-top: 6px; flex-wrap: wrap; }
.c-bot { display: flex; align-items: center; gap: 8px; margin-top: 9px; }
.mini-progress { flex: 1; height: 6px; background: #edf1f8; border-radius: 3px; overflow: hidden; }
.mini-progress i { display: block; height: 100%; background: var(--primary); border-radius: 3px; }
.c-stock { font-weight: 800; font-size: 15px; white-space: nowrap; }
.c-stock i { font-style: normal; font-size: 11.5px; color: var(--muted); font-weight: 400; }
.badge { font-size: 11.5px; padding: 2px 8px; border-radius: 6px; background: #eef2fb; color: var(--primary-dark); white-space: nowrap; }
.badge.done { background: #e9f6ef; color: var(--green); }
.badge.part { background: #fdf1e4; color: var(--orange); }
.badge.zero { background: #f2f4f8; color: var(--muted); }

/* 详情 */
.detail-head { margin-bottom: 12px; }
.dh-top { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.dh-top h2 { font-size: 20px; font-family: monospace; word-break: break-all; }
.type-chips { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.type-chip { font-size: 12px; background: #fff; border: 1px solid var(--line); border-radius: 20px; padding: 3px 10px; }
.type-chip b { color: var(--primary); }
.dt-note { font-size: 12.5px; color: var(--muted); margin-top: 8px; line-height: 1.5; }
.kpi-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 12px; }
.kpi { background: #fff; border-radius: 12px; padding: 10px 8px; text-align: center; box-shadow: 0 1px 3px rgba(20,40,90,.05); }
.kpi b { display: block; font-size: 19px; font-weight: 800; }
.kpi span { font-size: 11px; color: var(--muted); }
.kpi.highlight { background: var(--primary); }
.kpi.highlight b, .kpi.highlight span { color: #fff; }
.progress-wrap { background: #fff; border-radius: 12px; padding: 12px 14px; margin-bottom: 12px; box-shadow: 0 1px 3px rgba(20,40,90,.05); }
.progress-label { display: flex; justify-content: space-between; font-size: 12.5px; color: var(--muted); margin-bottom: 7px; }
.progress { height: 9px; background: #edf1f8; border-radius: 5px; overflow: hidden; }
.progress-bar { height: 100%; background: linear-gradient(90deg, #1e6bff, #4a8cff); border-radius: 5px; transition: width .4s; }
.action-row { display: flex; gap: 8px; margin-bottom: 12px; }
.action-row .btn { flex: 1; }

/* 批次 */
.batch { background: var(--card); border-radius: 12px; padding: 11px 13px; box-shadow: 0 1px 3px rgba(20,40,90,.05); cursor: pointer; }
.batch.finished { opacity: .62; }
.b-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.b-sup { font-weight: 700; font-size: 14.5px; }
.b-sub { font-size: 11.5px; color: var(--muted); font-family: monospace; margin-top: 2px; }
.b-mid { display: flex; gap: 12px; font-size: 12.5px; color: var(--muted); margin-top: 6px; flex-wrap: wrap; }
.b-mid b { color: var(--text); font-weight: 600; }
.b-steps { display: flex; gap: 3px; margin-top: 8px; }
.b-step { flex: 1; text-align: center; font-size: 9.5px; color: #a6adbd; }
.b-step .bar { height: 4px; border-radius: 2px; background: #e8ecf4; margin-bottom: 3px; }
.b-step.done .bar { background: var(--green); }
.b-step.doing .bar { background: var(--orange); }
.b-step.done { color: var(--green); }
.b-step.doing { color: var(--orange); }
.state-chip { font-size: 11px; padding: 2px 7px; border-radius: 5px; white-space: nowrap; }
.state-chip.in { background: #e9f6ef; color: var(--green); }
.state-chip.part { background: #fdf1e4; color: var(--orange); }
.state-chip.none { background: #f2f4f8; color: var(--muted); }

/* 发货记录 */
.ship { background: var(--card); border-radius: 12px; padding: 11px 13px; box-shadow: 0 1px 3px rgba(20,40,90,.05); }
.ship.revoked { opacity: .5; }
.s-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.s-no { font-family: monospace; font-weight: 700; font-size: 13.5px; }
.s-qty { font-weight: 800; color: var(--primary); }
.s-meta { font-size: 12px; color: var(--muted); margin-top: 4px; }
.s-lines { margin-top: 8px; border-top: 1px dashed var(--line); padding-top: 6px; display: flex; flex-direction: column; gap: 3px; }
.s-line { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); }
.s-line b { color: var(--text); font-family: monospace; font-weight: 600; }

/* 记录页 */
.seg { display: flex; background: #eef1f7; border-radius: 11px; padding: 4px; margin-bottom: 12px; }
.seg-btn { flex: 1; border: none; background: none; padding: 9px; border-radius: 8px; font-size: 14.5px; color: var(--muted); font-weight: 600; cursor: pointer; }
.seg-btn.active { background: #fff; color: var(--text); box-shadow: 0 1px 4px rgba(0,0,0,.10); }
.search-row { display: flex; gap: 8px; margin-bottom: 10px; }
.filter-row { display: flex; gap: 6px; align-items: center; margin-bottom: 10px; flex-wrap: wrap; }
.filter-row input { width: auto; flex: 1; min-width: 0; padding: 8px; font-size: 13.5px; }
.dash { color: var(--muted); }
.rec { background: var(--card); border-radius: 12px; padding: 11px 13px; box-shadow: 0 1px 3px rgba(20,40,90,.05); }
.rec-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.rec-no { font-family: monospace; font-size: 12.5px; font-weight: 700; }
.rec-c { font-weight: 700; font-size: 14.5px; font-family: monospace; }
.rec-meta { display: flex; gap: 10px; font-size: 12px; color: var(--muted); margin-top: 5px; flex-wrap: wrap; }
.rec-qty { font-weight: 800; white-space: nowrap; }
.rec-qty.in { color: var(--green); }
.rec-qty.out { color: var(--primary); }

.hint-block { background: #eef2fb; color: var(--primary-dark); border-radius: 10px; padding: 9px 12px; font-size: 12.5px; margin-bottom: 10px; }

/* 我的 */
.user-card { display: flex; align-items: center; gap: 14px; }
.avatar { width: 52px; height: 52px; border-radius: 50%; background: var(--primary); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 22px; font-weight: 700; }
.role-badge { font-size: 12px; background: #eef2fb; color: var(--primary-dark); padding: 2px 9px; border-radius: 6px; }
.menu { background: var(--card); border-radius: var(--radius); margin-bottom: 14px; overflow: hidden; box-shadow: 0 1px 3px rgba(20,40,90,.04); }
.menu-item { display: flex; justify-content: space-between; align-items: center; padding: 14px 16px; border-bottom: 1px solid var(--line); cursor: pointer; font-size: 15px; }
.menu-item:last-child { border-bottom: none; }
.menu-item .arr { color: var(--muted); }
.foot { text-align: center; color: var(--muted); font-size: 12px; padding: 10px 0 20px; }
.foot a { color: inherit; text-decoration: none; border-bottom: 1px dotted currentColor; }
.user-line { display: flex; justify-content: space-between; align-items: center; padding: 9px 2px; border-bottom: 1px solid var(--line); font-size: 14px; }
.user-line:last-child { border-bottom: none; }
.sys-info { font-size: 13px; color: var(--muted); line-height: 1.9; word-break: break-all; }

/* 弹层 */
.modal { position: fixed; inset: 0; z-index: 50; background: rgba(15,25,50,.45); display: flex; align-items: flex-end; justify-content: center; }
.modal-box { background: #fff; width: 100%; max-width: 520px; max-height: 88vh; border-radius: 18px 18px 0 0; padding: 16px; overflow-y: auto; }
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.modal-head b { font-size: 16px; }
.ship-contract-line { display: flex; justify-content: space-between; align-items: center; background: #f7f9fc; border-radius: 10px; padding: 10px 14px; margin-bottom: 8px; font-size: 13px; color: var(--muted); }
.ship-contract-line b { font-family: monospace; font-size: 15px; color: var(--text); }
.ship-stock { font-size: 12.5px; color: var(--muted); margin-bottom: 12px; padding-left: 2px; }
.ship-stock b { color: var(--primary); font-size: 14px; }
.alloc-head { display: flex; justify-content: space-between; align-items: center; font-size: 13.5px; margin: 14px 0 8px; gap: 8px; }
.mini-toggle { display: flex; align-items: center; gap: 5px; font-size: 12px; color: var(--muted); font-weight: 400; }
.mini-toggle input { width: 16px; height: 16px; }
.alloc-list { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.alloc-row { display: flex; align-items: center; gap: 8px; background: #f7f9fc; border-radius: 9px; padding: 8px 10px; font-size: 12.5px; }
.alloc-row .ai { flex: 1; min-width: 0; }
.alloc-row .ai b { font-size: 13px; }
.alloc-row .ai span { display: block; color: var(--muted); font-size: 11.5px; }
.alloc-row input { width: 84px; padding: 7px 8px; font-size: 13px; text-align: right; }
.alloc-row.disabled { opacity: .45; }

/* 工序弹层 */
.step-list { display: flex; flex-direction: column; gap: 8px; }
.step-item { display: flex; justify-content: space-between; align-items: center; padding: 10px 12px; background: #f7f9fc; border-radius: 10px; }
.step-item span { font-size: 14px; }
.step-toggle { display: flex; gap: 5px; }
.step-toggle button { width: 42px; padding: 7px 0; border-radius: 8px; border: 1.5px solid var(--line); background: #fff; font-size: 14px; cursor: pointer; }
.step-toggle button.on { background: var(--green); border-color: var(--green); color: #fff; font-weight: 700; }
.step-toggle button.on.doing { background: var(--orange); border-color: var(--orange); }
.step-legend { font-size: 12px; color: var(--muted); margin: 10px 0 4px; }

/* Toast */
.toast { position: fixed; bottom: 100px; left: 50%; transform: translateX(-50%); background: rgba(25,32,48,.93); color: #fff; padding: 11px 20px; border-radius: 24px; font-size: 14px; z-index: 99; max-width: 86vw; text-align: center; line-height: 1.5; }

@media (max-width: 380px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ---------------- PWA 安装提示条 ---------------- */
.install-bar {
  position: fixed; left: 14px; right: 14px; bottom: calc(70px + env(safe-area-inset-bottom));
  display: flex; align-items: center; gap: 10px;
  background: #fff; border: 1px solid var(--line); border-radius: 16px;
  box-shadow: 0 8px 28px rgba(20, 40, 90, 0.18);
  padding: 12px 14px; z-index: 90;
  animation: ib-in 0.35s ease;
}
@keyframes ib-in { from { transform: translateY(24px); opacity: 0; } to { transform: none; opacity: 1; } }
.install-bar .ib-ico { font-size: 26px; }
.install-bar .ib-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.install-bar .ib-text b { font-size: 15px; color: var(--text); }
.install-bar .ib-text span { font-size: 12px; color: var(--muted); }
.install-bar .btn.small { padding: 7px 16px; flex-shrink: 0; }

/* ---------------- PWA 安装卡片 / 帮助 / 微信提示 ---------------- */
.install-card .install-desc { font-size: 13px; color: var(--muted); line-height: 1.65; margin: 8px 0 12px; }
.install-card .btn { width: 100%; }
.btn.done { background: #E8F5EC !important; color: #1E8E4E !important; box-shadow: none !important; }

.help-body { padding: 2px 2px 0; max-height: 62vh; overflow-y: auto; }
.help-block { margin-bottom: 14px; }
.help-block h4 { font-size: 14.5px; margin: 0 0 8px; color: var(--text); }
.help-block ol { margin: 0; padding-left: 20px; }
.help-block li { font-size: 13.5px; color: #43506B; line-height: 1.95; }
.help-note { background: #F1F6FF; border: 1px solid #D8E6FF; color: #2A4B8D; font-size: 12.5px; line-height: 1.75; padding: 10px 12px; border-radius: 10px; margin: 4px 0 8px; }
.help-note.warn { background: #FFF6E8; border-color: #FFDFB0; color: #9A5B00; }

.wx-tip { position: fixed; inset: 0; background: rgba(10, 16, 28, .84); z-index: 130; padding: 14px; }
.wx-arrow { position: absolute; top: 6px; right: 16px; font-size: 48px; line-height: 1; color: #fff; animation: wx-bob 1.2s ease-in-out infinite; }
@keyframes wx-bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-9px); } }
.wx-box { margin-top: 70px; background: #fff; border-radius: 18px; padding: 22px 18px 18px; text-align: center; box-shadow: 0 12px 40px rgba(0, 0, 0, .3); }
.wx-box b { font-size: 17px; color: var(--text); }
.wx-box p { font-size: 13.5px; color: var(--muted); line-height: 1.8; margin: 8px 0 16px; }
.wx-box .btn { width: 100%; }
.help-dl { display: block; width: 100%; text-align: center; margin: 10px 0 6px; text-decoration: none; box-sizing: border-box; }
.apk-link { display: block; text-align: center; margin-top: 10px; text-decoration: none; } .apk-link.btn { width: 100%; }
.pf-badge { display: inline-block; background: #FFF3E6; color: #B25E00; font-size: 11px; padding: 2px 8px; border-radius: 10px; margin-right: 4px; }

/* 入库弹窗内工序快选 */
.in-steps { display: flex; flex-wrap: wrap; gap: 6px; }
.in-steps button { background: #f3f6fb; border: 1px solid #e2e9f4; border-radius: 10px; padding: 7px 10px; font-size: 13px; color: var(--text); cursor: pointer; }
.in-steps button i { font-style: normal; margin-left: 2px; color: #a6adbd; }
.in-steps button.doing { background: #FFF6E8; border-color: #FFDFB0; }
.in-steps button.doing i { color: var(--orange); }
.in-steps button.done { background: #E8F5EC; border-color: #BFE5CC; }
.in-steps button.done i { color: var(--green); font-weight: bold; }
