:root {
  --brand: #0f4c5c;
  --brand-2: #12707f;
  --truck: #1a5fc4;   /* logo 里的车身蓝（与黄红渐变底形成对比） */
  --accent: #e85d3f;
  --ok: #1a8f5a;
  --warn: #c9821a;
  --bad: #c0392b;
  --bg: #f2f4f7;
  --card: #ffffff;
  --line: #e3e8ee;
  --text: #1c2733;
  --muted: #6b7a8c;
  --radius: 14px;
}

* { 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", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.55;
}

a { color: var(--brand-2); text-decoration: none; }

.app {
  max-width: 680px;
  margin: 0 auto;
  min-height: 100vh;
  background: var(--bg);
  padding-bottom: 84px;
}

/* 顶部标语条 + 标题 */
.slogan {
  background: linear-gradient(90deg, #f6c344, #e85d3f);
  color: #3a2408;
  font-size: 12px;
  letter-spacing: 1px;
  padding: 6px 14px;
  text-align: center;
  font-weight: 600;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--brand);
  color: #fff;
  padding: 12px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.topbar h1 {
  font-size: 17px;
  margin: 0;
  font-weight: 600;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.topbar .sub { font-size: 11px; opacity: .75; font-weight: 400; }

/* 顶栏小货车标（自绘 SVG） */
.topbar-ic {
  width: 28px; height: 28px; flex: 0 0 auto;
  border-radius: 9px;
  background: rgba(255,255,255,.16);
  display: flex; align-items: center; justify-content: center;
}
.topbar-ic svg { display: block; }

.topbar .back {
  background: rgba(255,255,255,.16);
  border: 0;
  color: #fff;
  border-radius: 9px;
  padding: 6px 10px;
  font-size: 13px;
}

.page { padding: 14px; }

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

.card h3 {
  margin: 0 0 10px;
  font-size: 15px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.muted { color: var(--muted); }
.small { font-size: 12px; }
.tiny { font-size: 11px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.center { text-align: center; }
.row { display: flex; gap: 8px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.grow { flex: 1; }
.mt { margin-top: 10px; }
.mb { margin-bottom: 10px; }

/* KPI */
.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.kpi {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 8px;
  text-align: center;
}
.kpi b { display: block; font-size: 22px; line-height: 1.2; color: var(--brand); }
.kpi span { font-size: 11px; color: var(--muted); }
.kpi.alert b { color: var(--bad); }

/* 大按钮 */
.actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.big-btn {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 10px;
  text-align: center;
  color: var(--text);
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
}
.big-btn .ic { display: block; font-size: 26px; margin-bottom: 6px; }
.big-btn .ic svg { display: block; margin: 0 auto; }
.big-btn.primary { background: var(--brand); color: #fff; border-color: var(--brand); }
.big-btn.warn { background: #fff7ee; border-color: #f0d9bd; color: #8a5512; }

/* 列表项 */
.item {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 14px;
  margin-bottom: 10px;
  cursor: pointer;
}
.item .no { font-weight: 600; font-size: 14px; }
.item .meta { color: var(--muted); font-size: 12px; margin-top: 3px; }
.item .right { text-align: right; }

.tag {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 99px;
  font-size: 11px;
  background: #eef3f5;
  color: var(--brand);
  border: 1px solid #dbe6ea;
}
.tag.ok { background: #e8f6ee; color: var(--ok); border-color: #c8e8d6; }
.tag.warn { background: #fdf3e3; color: var(--warn); border-color: #f3ddb8; }
.tag.bad { background: #fdecea; color: var(--bad); border-color: #f5c6c0; }

/* 表单 */
label.field { display: block; margin-bottom: 12px; }
label.field span { display: block; font-size: 12px; color: var(--muted); margin-bottom: 5px; }
input[type=text], input[type=number], textarea, select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 11px 12px;
  font-size: 15px;
  background: #fff;
  color: var(--text);
  outline: none;
}
input:focus, textarea:focus { border-color: var(--brand-2); box-shadow: 0 0 0 3px rgba(18,112,127,.12); }
textarea { min-height: 76px; resize: vertical; }

button.primary, button.ghost, button.danger {
  border: 0;
  border-radius: 11px;
  padding: 12px 16px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}
button.primary { background: var(--brand); color: #fff; }
button.primary:disabled { opacity: .5; }
button.ghost { background: #eef3f5; color: var(--brand); }
button.danger { background: var(--bad); color: #fff; }
button.wide { width: 100%; }

.scan-box {
  display: flex;
  gap: 8px;
  align-items: center;
}
.scan-box input { flex: 1; font-size: 16px; letter-spacing: .5px; }
.scan-box button { white-space: nowrap; }

/* 责任链 */
.person {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px dashed var(--line);
}
.person:last-child { border-bottom: 0; }
.avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--brand); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; flex: 0 0 34px;
}
.person .role { font-size: 11px; color: var(--muted); }

.alert {
  border-radius: 11px;
  padding: 10px 12px;
  font-size: 13px;
  margin: 10px 0;
}
.alert.warn { background: #fdf3e3; border: 1px solid #f0d9bd; color: #8a5512; }
.alert.bad { background: #fdecea; border: 1px solid #f5c6c0; color: #9c2f22; }
.alert.ok { background: #e8f6ee; border: 1px solid #c8e8d6; color: #166b44; }
.alert.info { background: #eef3f5; border: 1px solid #dbe6ea; color: var(--brand); }

/* 底部 tab */
.tabbar {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: 0;
  width: 100%;
  max-width: 680px;
  background: #fff;
  border-top: 1px solid var(--line);
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  padding: 6px 0 calc(6px + env(safe-area-inset-bottom));
}
.tabbar a {
  text-align: center;
  font-size: 11px;
  color: var(--muted);
  padding: 4px 0;
}
.tabbar a .ic { display: block; height: 20px; line-height: 1.2; }
.tabbar a .ic svg { display: block; margin: 0 auto; }
.tabbar a.on { color: var(--brand); font-weight: 600; }

/* 开屏 / 登录（调试入口）
   浅灰底：进入页不是企微里的正式门面，用中性浅灰一眼可辨「这是调试入口」（R/G/B 通道差 ≤ 8）；
   logo = 黄→红渐变色块 + 蓝色自绘小货车（车比原来大一倍，手机上先看见车）。 */
.splash {
  min-height: 100vh;
  background: linear-gradient(165deg, #f7f8f9 0%, #eceef1 58%, #e2e5e9 100%);
  color: var(--text);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 34px 22px 40px;
  text-align: center;
  position: relative;
}
.splash .dbg {
  position: absolute; top: 14px; left: 14px;
  font-size: 10px; letter-spacing: 2px;
  padding: 3px 9px; border-radius: 999px;
  color: #5b6672;
  border: 1px solid rgba(28,39,51,.16);
  background: rgba(255,255,255,.72);
}
.splash.debug { background: linear-gradient(165deg, #f7f8f9 0%, #eceef1 58%, #e2e5e9 100%); }
.splash .logo {
  width: 148px; height: 148px; border-radius: 36px;
  background: linear-gradient(135deg, #fbd24a 0%, #f59a34 48%, #e43f2c 100%);
  box-shadow: 0 12px 28px rgba(228,63,44,.26), inset 0 1px 0 rgba(255,255,255,.45);
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 20px;
  color: var(--truck);
}
.splash .logo svg { display: block; }
.splash h1 { font-size: 22px; margin: 0 0 6px; letter-spacing: 1px; }
.splash .code { font-size: 12px; color: var(--muted); letter-spacing: 3px; margin-bottom: 6px; }
.splash .tip { font-size: 11px; color: #8d97a3; margin-bottom: 22px; }

/* 模拟人员：点一下就进（名单已按 ERP 档案核验，见 server /api/demo/users） */
.splash .demo { width: 100%; max-width: 360px; }
.splash .demo-t {
  font-size: 11px; color: #8d97a3; letter-spacing: 2px;
  margin-bottom: 10px;
}
.splash .demo-list { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.pchip {
  display: flex; align-items: center; gap: 9px;
  background: #fff;
  border: 1px solid #e1e5ea;
  border-radius: 14px;
  padding: 7px 13px 7px 7px;
  box-shadow: 0 1px 2px rgba(16,24,40,.05);
  cursor: pointer;
  font: inherit;
  color: inherit;
  text-align: left;
  transition: transform .08s, box-shadow .12s;
}
.pchip:active { transform: scale(.97); box-shadow: 0 0 0 2px rgba(26,95,196,.16); }
.pchip .av {
  width: 30px; height: 30px; flex: 0 0 30px;
  border-radius: 50%;
  background: linear-gradient(135deg, #fbd24a, #e43f2c);
  color: #fff; font-size: 13px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}
.pchip b { display: block; font-size: 13.5px; font-weight: 600; line-height: 1.25; }
.pchip small { display: block; font-size: 10.5px; color: var(--muted); line-height: 1.3; }
.splash .demo-note { color: #98a2ae; margin-top: 8px; line-height: 1.5; }

/* 兜底：其他账号手输 */
.splash .alt { width: 100%; max-width: 340px; margin-top: 24px; }
.splash .alt > span {
  display: block; text-align: left;
  font-size: 11px; color: #8d97a3; letter-spacing: 1px; margin-bottom: 7px;
}
.splash .alt-row { display: flex; gap: 8px; }
.splash .alt-row input { flex: 1; background: #fff; border-color: #dfe3e8; }
.splash .enter {
  background: var(--truck); color: #fff;
  border: 0; border-radius: 11px;
  padding: 0 20px; font-size: 15px; font-weight: 700;
  white-space: nowrap;
}
.splash .enter:disabled { opacity: .6; }
.splash .hint { font-size: 11px; color: #8d97a3; margin-top: 22px; }

/* 矮屏（如 iPhone SE 667px）：内容顶对齐，避免 flex 居中把顶部裁掉且滚不回来 */
@media (max-height: 720px) {
  .splash { justify-content: flex-start; padding-top: 28px; padding-bottom: 26px; }
  .splash .logo { width: 132px; height: 132px; border-radius: 32px; margin-bottom: 16px; }
  .splash .tip { margin-bottom: 16px; }
  .splash .alt { margin-top: 18px; }
}

.empty { text-align: center; color: var(--muted); padding: 36px 10px; font-size: 13px; }
.spinner { display: inline-block; width: 14px; height: 14px; border: 2px solid rgba(255,255,255,.35); border-top-color: #fff; border-radius: 50%; animation: spin .8s linear infinite; vertical-align: -2px; }
@keyframes spin { to { transform: rotate(360deg); } }

.toast {
  position: fixed;
  left: 50%;
  bottom: 96px;
  transform: translateX(-50%);
  background: rgba(28,39,51,.94);
  color: #fff;
  padding: 10px 16px;
  border-radius: 10px;
  font-size: 13px;
  max-width: 88vw;
  z-index: 90;
  opacity: 0;
  pointer-events: none;
  transition: opacity .18s;
}
.toast.show { opacity: 1; }

/* ───────────────────────── 摄像头扫码遮罩（scanner.js） */
.scan-overlay {
  position: fixed; inset: 0; z-index: 95;
  background: rgba(10,14,18,.88);
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
}
.scan-panel { width: min(88vw, 360px); text-align: center; }
.scan-viewfinder {
  position: relative; width: 100%; aspect-ratio: 1;
  border-radius: 18px; overflow: hidden;
  background: #14181d;
  border: 2px solid rgba(255,255,255,.35);
}
.scan-viewfinder video { width: 100%; height: 100%; object-fit: cover; display: block; }
/* 取景四角 */
.scan-viewfinder::before, .scan-viewfinder::after {
  content: ''; position: absolute; width: 34px; height: 34px; z-index: 2; pointer-events: none;
}
.scan-viewfinder::before {
  top: 10px; left: 10px; border-top: 3px solid var(--brand-2); border-left: 3px solid var(--brand-2);
  border-radius: 6px 0 0 0;
}
.scan-viewfinder::after {
  bottom: 10px; right: 10px; border-bottom: 3px solid var(--brand-2); border-right: 3px solid var(--brand-2);
  border-radius: 0 0 6px 0;
}
.scan-laser {
  position: absolute; left: 8%; right: 8%; top: 12%; height: 2px; z-index: 2;
  background: linear-gradient(90deg, transparent, var(--brand-2), transparent);
  animation: scanline 2.2s ease-in-out infinite; pointer-events: none;
}
@keyframes scanline { 0%,100% { top: 12%; } 50% { top: 86%; } }
.scan-tip { color: rgba(255,255,255,.85); font-size: 13px; margin-top: 14px; }
.scan-err {
  color: #ffd9d4; font-size: 13px; margin-top: 10px;
  background: rgba(196,60,48,.5); border: 1px solid rgba(255,150,140,.4);
  border-radius: 10px; padding: 10px 12px;
}
.scan-close {
  margin-top: 16px; background: rgba(255,255,255,.14); color: #fff;
  border: 1px solid rgba(255,255,255,.4); border-radius: 12px;
  padding: 11px 40px; font-size: 15px; font-weight: 700;
}
