* { margin: 0; padding: 0; box-sizing: border-box; }
:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --bg: #f3f5f9;
  --panel: #ffffff;
  --border: #e3e8f0;
  --text: #1f2937;
  --text-2: #6b7280;
  --red: #dc2626;
  --green: #16a34a;
  --orange: #ea580c;
}
body {
  font-family: "Microsoft YaHei", "PingFang SC", "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
}
#app { display: flex; min-height: 100vh; }

/* ---------- 侧边导航 ---------- */
aside {
  width: 200px;
  background: #16213a;
  color: #cbd5e1;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}
aside .logo {
  padding: 20px 18px;
  font-size: 17px;
  font-weight: 700;
  color: #fff;
  border-bottom: 1px solid rgba(255,255,255,.08);
}
aside .logo span { color: #60a5fa; }
.nav-item {
  padding: 13px 18px;
  cursor: pointer;
  font-size: 14px;
  border-left: 3px solid transparent;
  transition: background .15s;
  user-select: none;
}
.nav-item:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav-item.active {
  background: rgba(37,99,235,.25);
  color: #fff;
  border-left-color: var(--primary);
}
aside .foot {
  margin-top: auto;
  padding: 14px 18px;
  font-size: 12px;
  color: #64748b;
}

/* ---------- 主区域 ---------- */
main { flex: 1; padding: 22px 26px; min-width: 0; }
.page { display: none; }
.page.active { display: block; }
.page-title {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 4px;
}
.page-desc { color: var(--text-2); font-size: 13px; margin-bottom: 18px; }

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 18px 20px;
  margin-bottom: 18px;
}
.panel h3 {
  font-size: 15px;
  margin-bottom: 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}

/* ---------- 表单 ---------- */
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 12px 16px;
}
.form-item label {
  display: block;
  font-size: 12px;
  color: var(--text-2);
  margin-bottom: 5px;
}
.form-item label .req { color: var(--red); }
input, select, textarea {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
  font-family: inherit;
  background: #fff;
  color: var(--text);
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(37,99,235,.12);
}
input[readonly] { background: #f8fafc; color: var(--text-2); }

.btn {
  display: inline-block;
  padding: 8px 18px;
  border: none;
  border-radius: 6px;
  font-size: 14px;
  cursor: pointer;
  background: var(--primary);
  color: #fff;
  transition: background .15s;
}
.btn:hover { background: var(--primary-dark); }
.btn.secondary { background: #eef2f7; color: var(--text); border: 1px solid var(--border); }
.btn.secondary:hover { background: #e2e8f0; }
.btn.danger { background: #fff; color: var(--red); border: 1px solid #fecaca; }
.btn.danger:hover { background: #fef2f2; }
.btn.small { padding: 4px 10px; font-size: 12px; }
.btn-bar { margin-top: 16px; display: flex; gap: 10px; flex-wrap: wrap; }

/* ---------- 表格 ---------- */
table.grid {
  width: 100%;
  border-collapse: collapse;
  margin-top: 8px;
}
table.grid th, table.grid td {
  border: 1px solid var(--border);
  padding: 8px 10px;
  text-align: left;
  font-size: 13px;
}
table.grid th { background: #f8fafc; font-weight: 600; color: #374151; }
table.grid td input, table.grid td select { padding: 5px 8px; font-size: 13px; }
table.grid tr:hover td { background: #fafbfd; }
.num { text-align: right !important; font-variant-numeric: tabular-nums; }
.money { color: var(--orange); font-weight: 600; }
.tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 12px;
  background: #eff6ff;
  color: var(--primary);
}
.tag.g { background: #f0fdf4; color: var(--green); }
.tag.o { background: #fff7ed; color: var(--orange); }
.empty { color: var(--text-2); text-align: center; padding: 22px 0; font-size: 13px; }

/* ---------- 工作台卡片 ---------- */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 14px; margin-bottom: 18px; }
.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px 18px;
}
.card .k { font-size: 12px; color: var(--text-2); margin-bottom: 8px; }
.card .v { font-size: 26px; font-weight: 700; }
.card .v.blue { color: var(--primary); }
.card .v.green { color: var(--green); }
.card .v.orange { color: var(--orange); }

/* ---------- 路线规划 ---------- */
.route-inputs {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 12px;
  align-items: end;
}
#map-box { position: relative; }
#map {
  width: 100%;
  height: 430px;
  border-radius: 8px;
  border: 1px solid var(--border);
  overflow: hidden;
}
#map-fallback { display: none; }
.route-result {
  margin-top: 14px;
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px 16px;
  display: none;
}
.route-result .line { margin: 4px 0; }
.route-result .big { font-size: 16px; font-weight: 700; color: var(--primary); }
.route-result ol { margin: 8px 0 0 20px; color: var(--text-2); font-size: 13px; }
.route-result ol li { margin: 2px 0; }

/* ---------- 物流单路线结果 ---------- */
.wb-route {
  margin-top: 12px;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: 8px;
  padding: 12px 16px;
  display: none;
  font-size: 13px;
}

/* ---------- 客户扫码模式（手机端全屏只显示物流状态） ---------- */
/* 首屏渲染前（JS 执行前）就隐藏系统界面，消除"先闪一下系统再跳转" */
html.cust aside { display: none !important; }
html.cust .page { display: none !important; }
html.cust #page-track { display: block !important; }
html.cust .nav-item { display: none !important; }
html.cust main { padding: 14px 12px; width: 100%; }
html.cust #track-search, html.cust #track-scan, html.cust .page-desc { display: none !important; }
html.cust .cust-tip {
  display: block !important;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  color: #1d4ed8;
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 13px;
  margin-bottom: 14px;
}
body.cust aside { display: none !important; }       /* 去掉左侧导航栏 */
body.cust main { padding: 14px 12px; width: 100%; }
body.cust .page-desc { display: none; }             /* 隐藏给员工看的说明文字 */
body.cust #track-search { display: none; }          /* 查询框默认收起，可点"查询其他单号"展开 */
body.cust #track-scan { display: none; }            /* 客户不需要摄像头扫码入口 */
body.cust .page-title { font-size: 18px; margin-bottom: 10px; }
body.cust .panel { padding: 14px; border-radius: 10px; }
body.cust .steps .dot { width: 24px; height: 24px; font-size: 12px; }
body.cust .steps .lbl { font-size: 11px; }
body.cust .track-head { flex-direction: column; align-items: stretch; gap: 14px; }
body.cust .timeline .t-text { font-size: 14px; }
body.cust .timeline li { padding-left: 20px; }
.cust-tip { display: none; }
body.cust .cust-tip {
  display: block;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  color: #1d4ed8;
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 13px;
  margin-bottom: 14px;
}
body.cust .cust-tip a { color: #1d4ed8; text-decoration: underline; cursor: pointer; }

/* ---------- 提示 ---------- */
#toast {
  position: fixed;
  top: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: #111827;
  color: #fff;
  padding: 10px 22px;
  border-radius: 8px;
  font-size: 14px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s;
  z-index: 9999;
  max-width: 70%;
}
#toast.show { opacity: .95; }
#toast.err { background: var(--red); }

/* ---------- 物流跟踪 ---------- */
.track-bar { display: flex; gap: 10px; }
.track-bar input { flex: 1; font-size: 16px; padding: 12px 14px; letter-spacing: 1px; }
.steps { display: flex; align-items: flex-start; margin: 20px 0 8px; }
.steps .st { flex: 1; text-align: center; position: relative; }
.steps .dot {
  width: 28px; height: 28px; border-radius: 50%;
  background: #e5e7eb; color: #9ca3af;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 13px; position: relative; z-index: 1;
}
.steps .st.done .dot { background: var(--green); color: #fff; }
.steps .st.cur .dot { background: var(--primary); color: #fff; box-shadow: 0 0 0 4px rgba(37,99,235,.18); }
.steps .st::before { content: ''; position: absolute; top: 14px; left: -50%; width: 100%; height: 2px; background: #e5e7eb; }
.steps .st:first-child::before { display: none; }
.steps .st.done::before { background: var(--green); }
.steps .lbl { margin-top: 7px; font-size: 12px; color: var(--text-2); }
.steps .st.cur .lbl { color: var(--primary); font-weight: 600; }
.steps .st.done .lbl { color: var(--green); }

.timeline { list-style: none; margin-top: 8px; }
.timeline li { position: relative; padding: 0 0 18px 24px; border-left: 2px solid #e5e7eb; margin-left: 10px; }
.timeline li:last-child { border-left-color: transparent; padding-bottom: 2px; }
.timeline .t-dot {
  position: absolute; left: -8px; top: 3px; width: 12px; height: 12px; border-radius: 50%;
  background: var(--green); border: 2px solid #fff; box-shadow: 0 0 0 2px var(--green);
}
.timeline li.pending .t-dot { background: #d1d5db; box-shadow: 0 0 0 2px #d1d5db; }
.timeline .t-time { font-size: 12px; color: var(--text-2); margin-bottom: 2px; }
.timeline .t-text { font-size: 14px; }
.timeline li.pending .t-text { color: #9ca3af; }
.timeline .t-loc { font-size: 12px; color: var(--text-2); margin-left: 6px; }

.track-head { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 12px; align-items: center; }
.track-head .bc svg { display: block; }

/* ---------- 打印单据 ---------- */
#print-root { display: none; }
.doc { width: 720px; margin: 0 auto; font-size: 13px; color: #000; }
.doc h2 { text-align: center; font-size: 22px; letter-spacing: 8px; margin-bottom: 6px; }
.doc .doc-no { text-align: right; margin-bottom: 6px; }
.doc table { width: 100%; border-collapse: collapse; }
.doc table th, .doc table td { border: 1px solid #000; padding: 6px 8px; }
.doc table th { background: #f0f0f0; }
.doc .info td { border: 1px solid #000; }
.doc .sign { display: flex; margin-top: 14px; }
.doc .sign div { flex: 1; }
.doc .total-row td { font-weight: 700; }
.barcode { display: flex; align-items: flex-end; height: 46px; margin: 8px 0; }
.barcode i { display: block; background: #000; margin-right: 1px; }
.doc .wb-heads { display: flex; gap: 0; }
.doc .wb-heads > div { flex: 1; border: 1px solid #000; padding: 8px; min-height: 90px; }
.doc .wb-heads .t { font-weight: 700; margin-bottom: 6px; border-bottom: 1px dashed #999; padding-bottom: 4px; }

@media print {
  #app, #toast, #login-mask { display: none !important; }
  #print-root { display: block !important; }
}

/* ---------- 登录页 ---------- */
#login-mask { display: none; }
html.needlogin #login-mask {
  display: flex !important;
  position: fixed;
  inset: 0;
  z-index: 900;
  align-items: center;
  justify-content: center;
  background: #eef2f7;
  padding: 20px;
}
html.needlogin #app { display: none !important; }
html.needlogin #print-root { display: none !important; }

.login-card {
  width: 100%;
  max-width: 380px;
  background: #fff;
  border: 1px solid #e3e8f0;
  border-radius: 14px;
  padding: 30px 28px 24px;
  box-shadow: 0 6px 24px rgba(15, 23, 42, .06);
}
.login-brand { font-size: 21px; font-weight: 500; color: #1f2937; letter-spacing: 1px; text-align: center; }
.login-brand span { color: #2563eb; }
.login-sub { text-align: center; color: #6b7280; font-size: 13px; margin: 8px 0 20px; }
.login-err {
  display: none;
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #b91c1c;
  border-radius: 8px;
  padding: 9px 12px;
  font-size: 13px;
  margin-bottom: 14px;
  line-height: 1.5;
}
.login-field { margin-bottom: 14px; }
.login-field label { display: block; font-size: 13px; color: #4b5563; margin-bottom: 6px; }
.login-field input {
  width: 100%;
  box-sizing: border-box;
  padding: 10px 12px;
  border: 1px solid #d5dbe6;
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  color: #1f2937;
  background: #fff;
  outline: none;
}
.login-field input:focus { border-color: #2563eb; box-shadow: 0 0 0 3px rgba(37, 99, 235, .12); }
.login-btn {
  width: 100%;
  padding: 11px 0;
  font-size: 15px;
  margin-top: 6px;
}
.login-btn[disabled] { opacity: .65; cursor: default; }
.login-tip { text-align: center; color: #9ca3af; font-size: 12px; margin-top: 14px; }

/* 侧边栏底部：当前登录者与退出 */
aside .foot .me-line { font-size: 12px; color: #cbd5e1; margin-bottom: 4px; word-break: break-all; }
aside .foot .me-role { display: inline-block; padding: 1px 8px; border-radius: 9px; background: rgba(255, 255, 255, .14); color: #e2e8f0; font-size: 11px; }
.logout-btn { margin-top: 10px; width: 100%; }

/* 我的账号页 */
.me-box { display: flex; flex-wrap: wrap; gap: 26px; }
.me-row { font-size: 14px; color: #1f2937; }
.me-label { color: #6b7280; margin-right: 10px; font-size: 13px; }

/* ---------- 员工角色的界面差异 ---------- */
html.staff [data-del],
html.staff [data-wdel],
html.staff [data-ctdel],
html.staff #btn-clear,
html.staff #btn-seed,
html.staff .page[data-admin-only],
html.staff .admin-only,
html.staff .nav-item[data-page="users"],
html.staff #page-users { display: none !important; }
html.staff #page-account .staff-only-hint { display: block; }
.staff-only-hint { display: none; }

/* 账号管理表格里的下拉与按钮排布 */
#users-list table.grid td { vertical-align: middle; }
#users-list table.grid td .btn { margin: 1px 0; }
#users-list .tag { display: inline-block; padding: 1px 7px; border-radius: 9px; background: #eff6ff; color: #2563eb; font-size: 11px; }
/* 不可用的按钮要看得出来 */
.btn[disabled], .btn:disabled { opacity: .4; cursor: not-allowed; }
