/* ================= 基础 ================= */
:root {
  --bg: #f5f7fa;
  --card: #ffffff;
  --text: #1f2937;
  --text-sub: #6b7280;
  --border: #e5e7eb;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --green: #16a34a;      /* 正常 */
  --green-bg: #ecfdf5;
  --red: #dc2626;        /* 异常 */
  --red-bg: #fef2f2;
  --amber: #f59e0b;
  --shadow: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.04);
  --shadow-lg: 0 10px 30px rgba(0,0,0,.12);
  --radius: 12px;

  /* 移动端 16:9 显示模式 */
  --ratio: 16 / 9;                     /* 统一宽高比 */
  --ratio-gap: 10px;                   /* 卡片间距 */
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  --bottom-nav-h: 58px;                /* 底部导航实高（不含安全区） */
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", "PingFang SC", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.6;
}

.hidden { display: none !important; }
b { font-weight: 600; }

/* ================= 登录页 ================= */
.login-wrap {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: linear-gradient(140deg, #1e3a8a 0%, #2563eb 45%, #3b82f6 100%);
}

.login-card {
  width: 100%;
  max-width: 400px;
  background: var(--card);
  border-radius: 18px;
  padding: 32px 28px 24px;
  box-shadow: var(--shadow-lg);
  animation: rise .35s ease;
}
@keyframes rise { from { opacity:0; transform: translateY(14px);} to {opacity:1;transform:none;} }

.login-brand { text-align: center; margin-bottom: 22px; }
.login-brand .logo {
  display: inline-flex; align-items: center; justify-content: center;
  width: 56px; height: 56px; border-radius: 16px;
  background: linear-gradient(135deg, #2563eb, #3b82f6);
  color: #fff; font-weight: 800; font-size: 19px; letter-spacing: .5px;
  margin-bottom: 12px; box-shadow: 0 6px 16px rgba(37,99,235,.32);
}
.login-brand h1 { font-size: 20px; margin: 0 0 2px; }
.login-brand p { margin: 0; color: var(--text-sub); font-size: 12px; letter-spacing: 1px; text-transform: uppercase; }

.tabs {
  display: flex; background: #f1f5f9; border-radius: 10px; padding: 4px; margin-bottom: 20px;
}
.tab {
  flex: 1; border: 0; background: transparent; padding: 9px 0; border-radius: 8px;
  font-size: 14px; color: var(--text-sub); cursor: pointer; font-family: inherit; transition: .18s;
}
.tab.active { background: #fff; color: var(--primary); font-weight: 600; box-shadow: var(--shadow); }

.login-form label { display: block; margin-bottom: 14px; font-size: 13px; color: var(--text-sub); font-weight: 500; }
.login-form input {
  width: 100%; margin-top: 6px; padding: 12px 14px; border: 1.5px solid var(--border);
  border-radius: 10px; font-size: 15px; font-family: inherit; background: #fff; color: var(--text);
  transition: .18s; outline: none;
}
.login-form input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,.12); }

.card-scan-area { text-align: center; padding: 14px 0 18px; }
.card-icon { font-size: 40px; margin-bottom: 6px; animation: pulse 2s infinite; }
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:.45} }
.card-scan-area p { margin: 0 0 14px; font-weight: 600; font-size: 15px; }
.card-input {
  text-align: center; font-size: 18px; letter-spacing: 3px; font-weight: 600;
  background: #f8fafc !important; border-style: dashed !important;
}
.card-scan-area small { display: block; margin-top: 10px; color: #9ca3af; font-size: 12px; font-weight: 400; }

.login-msg { min-height: 20px; margin-top: 12px; font-size: 13px; text-align: center; color: var(--red); font-weight: 500; }
.login-hint { margin-top: 8px; padding-top: 14px; border-top: 1px dashed var(--border); font-size: 12px; color: #9ca3af; text-align: center; }

/* ================= 按钮 ================= */
.btn {
  border: 0; border-radius: 10px; padding: 11px 18px; font-size: 14px; font-family: inherit;
  font-weight: 600; cursor: pointer; transition: .18s; display: inline-flex;
  align-items: center; justify-content: center; gap: 6px; white-space: nowrap;
}
.btn:active { transform: scale(.97); }
.btn-block { width: 100%; }
.btn-sm { padding: 7px 12px; font-size: 13px; border-radius: 8px; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-ghost { background: transparent; color: var(--text-sub); border: 1.5px solid var(--border); }
.btn-ghost:hover { background: #f3f4f6; }
.btn-danger { background: var(--red); color: #fff; }
.btn-warn { background: #fff; color: var(--amber); border: 1.5px solid #fde68a; position: relative; }
.btn-warn:hover { background: #fffbeb; }
.btn-green { background: var(--green); color: #fff; }
.btn-outline { background: #fff; color: var(--primary); border: 1.5px solid #bfdbfe; }
.btn-outline:hover { background: #eff6ff; }

/* ================= 主应用 ================= */
.topbar {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 20px; background: #fff; border-bottom: 1px solid var(--border);
  box-shadow: 0 1px 4px rgba(0,0,0,.03);
}
.topbar-left { display: flex; align-items: center; gap: 10px; }
.logo-sm {
  width: 32px; height: 32px; border-radius: 9px; background: linear-gradient(135deg,#2563eb,#3b82f6);
  color: #fff; display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 12px; flex-shrink: 0;
}
.app-title { font-weight: 600; font-size: 16px; }
.topbar-right { display: flex; align-items: center; gap: 10px; }

/* 顶栏按钮：桌面端只显示文字，图标留给窄屏；用 !important 避免 style 属性干扰 */
.btn .ico { display: none; }
.btn .btn-label { display: inline; }
.user-chip {
  padding: 6px 12px; background: #f1f5f9; border-radius: 20px; font-size: 13px;
  color: var(--text-sub); font-weight: 500;
}
.mail-badge { font-size: 15px; color: var(--text-sub); cursor: help; }
.mail-badge.off { opacity: .35; }

.container { max-width: 1100px; margin: 0 auto; padding: 20px 20px 100px; }

/* 统计卡片 */
.stat-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 12px; margin-bottom: 20px;
}
.stat-card {
  background: #fff; border-radius: var(--radius); padding: 16px 18px;
  box-shadow: var(--shadow); border-left: 4px solid var(--border);
}
.stat-card .num { font-size: 26px; font-weight: 700; line-height: 1.2; }
.stat-card .lbl { font-size: 13px; color: var(--text-sub); margin-top: 2px; }
.stat-card.normal { border-left-color: var(--green); }
.stat-card.normal .num { color: var(--green); }
.stat-card.abnormal { border-left-color: var(--red); }
.stat-card.abnormal .num { color: var(--red); }
.stat-card.done { border-left-color: #0ea5e9; }
.stat-card.done .num { color: #0ea5e9; }
.stat-card.total { border-left-color: var(--primary); }
.stat-card.total .num { color: var(--primary); }

/* 工具栏 */
.toolbar { display: flex; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; }
.search-box { flex: 1; min-width: 200px; }
.search-box input, .toolbar select {
  width: 100%; padding: 10px 14px; border: 1.5px solid var(--border); border-radius: 10px;
  font-size: 14px; font-family: inherit; background: #fff; color: var(--text); outline: none; transition: .18s;
}
.toolbar select { width: auto; min-width: 120px; cursor: pointer; }
.search-box input:focus, .toolbar select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,.1); }

/* 物料卡片 */
.material-list { display: grid; gap: 12px; }
.mat-card {
  position: relative;                       /* 承载「进度 +N%」浮标 */
  background: #fff; border-radius: var(--radius); padding: 16px 18px;
  box-shadow: var(--shadow); border-left: 5px solid var(--green);
  cursor: pointer; transition: .18s; animation: rise .25s ease;
}
.mat-card:hover { box-shadow: var(--shadow-lg); transform: translateY(-1px); }
.mat-card.abnormal { border-left-color: var(--red); background: var(--red-bg); }
.mat-card.done { border-left-color: #0ea5e9; }

.mat-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 8px; }
.mat-code { font-size: 12px; color: var(--text-sub); font-weight: 600; letter-spacing: .4px; font-family: ui-monospace, monospace; }
.mat-name { font-size: 16px; font-weight: 600; margin: 2px 0 0; }
.mat-spec { font-size: 12.5px; color: var(--text-sub); margin-top: 2px; }

.badge {
  padding: 4px 11px; border-radius: 20px; font-size: 12px; font-weight: 600;
  display: inline-flex; align-items: center; gap: 4px; white-space: nowrap; flex-shrink: 0;
}
.badge.normal { background: var(--green-bg); color: var(--green); }
.badge.abnormal { background: #fee2e2; color: var(--red); animation: blink 1.6s infinite; }
.badge.done { background: #e0f2fe; color: #0284c7; }
@keyframes blink { 0%,100%{opacity:1} 50%{opacity:.55} }

.mat-meta {
  display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 12.5px; color: var(--text-sub);
  margin-top: 10px; padding-top: 10px; border-top: 1px dashed var(--border);
}
.mat-meta span { display: inline-flex; align-items: center; gap: 4px; }

.progress-track { height: 6px; background: #eef2f7; border-radius: 4px; overflow: hidden; margin-top: 10px; }
.progress-fill { height: 100%; border-radius: 4px; background: var(--green); transition: width .4s; }
.mat-card.abnormal .progress-fill { background: var(--red); }
.mat-card.done .progress-fill { background: #0ea5e9; }

.mat-note {
  margin-top: 10px; padding: 8px 11px; border-radius: 8px; font-size: 12.5px;
  background: #f8fafc; color: var(--text-sub); border-left: 3px solid var(--border);
}
.mat-card.abnormal .mat-note { background: #fff5f5; color: #b91c1c; border-left-color: var(--red); font-weight: 500; }

.empty { text-align: center; padding: 60px 20px; color: #9ca3af; }
.empty .icon { font-size: 46px; margin-bottom: 10px; opacity: .5; }

/* 移动端底部导航 */
.bottom-nav {
  display: none; position: fixed; bottom: 0; left: 0; right: 0; z-index: 60;
  background: #fff; border-top: 1px solid var(--border);
  padding: 6px 0 calc(6px + env(safe-area-inset-bottom));
  box-shadow: 0 -2px 12px rgba(0,0,0,.05);
}
.nav-item {
  flex: 1; border: 0; background: transparent; padding: 6px 0; cursor: pointer;
  font-size: 11px; color: var(--text-sub); font-family: inherit;
  display: flex; flex-direction: column; align-items: center; gap: 2px; position: relative;
}
.nav-item span { font-size: 19px; line-height: 1; }
.nav-item.active { color: var(--primary); font-weight: 600; }
.nav-dot {
  position: absolute; top: 2px; right: 50%; margin-right: -18px;
  width: 8px; height: 8px; border-radius: 50%; background: var(--red);
}

/* ================= 弹窗 ================= */
.modal { position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center; padding: 16px; }
.modal-mask { position: absolute; inset: 0; background: rgba(15,23,42,.5); backdrop-filter: blur(2px); }
.modal-panel {
  position: relative; background: #fff; border-radius: 16px; width: 100%; max-width: 560px;
  max-height: 88vh; display: flex; flex-direction: column; box-shadow: var(--shadow-lg);
  animation: rise .25s ease;
}
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; border-bottom: 1px solid var(--border); flex-shrink: 0;
}
.modal-head h3 { margin: 0; font-size: 16px; }
.icon-btn {
  border: 0; background: #f1f5f9; width: 30px; height: 30px; border-radius: 8px;
  cursor: pointer; color: var(--text-sub); font-size: 14px; transition: .18s; flex-shrink: 0;
}
.icon-btn:hover { background: #e2e8f0; color: var(--text); }
.modal-body { padding: 20px; overflow-y: auto; flex: 1; }
.modal-foot {
  padding: 14px 20px; border-top: 1px solid var(--border); display: flex; gap: 10px;
  justify-content: flex-end; flex-shrink: 0; flex-wrap: wrap;
}

/* ---- 摄像头扫码层 ----
   独立于 .modal，z-index 更高，这样「新增/编辑物料」表单不会被覆盖，
   扫码结果可以正确回填到下方表单的输入框。 */
.cam-layer { position: fixed; inset: 0; z-index: 150; display: flex; align-items: center; justify-content: center; padding: 16px; }
.cam-layer-mask { position: absolute; inset: 0; background: rgba(15,23,42,.62); backdrop-filter: blur(3px); }
.cam-layer-panel {
  position: relative; background: #fff; border-radius: 16px; width: 100%; max-width: 560px;
  max-height: 92vh; display: flex; flex-direction: column; box-shadow: var(--shadow-lg);
  animation: rise .25s ease;
}
.cam-layer-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; border-bottom: 1px solid var(--border); flex-shrink: 0;
}
.cam-layer-head h3 { margin: 0; font-size: 16px; }
.cam-layer-body { padding: 20px; overflow-y: auto; flex: 1; }
.cam-layer-foot {
  padding: 14px 20px; border-top: 1px solid var(--border); display: flex; gap: 10px;
  justify-content: flex-end; flex-shrink: 0; flex-wrap: wrap;
}

/* 表单 */
.form-row { display: flex; gap: 12px; flex-wrap: wrap; }
.form-row > label { flex: 1; min-width: 140px; }
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; color: var(--text-sub); font-weight: 500; margin-bottom: 6px; }
.field input, .field select, .field textarea {
  width: 100%; padding: 11px 13px; border: 1.5px solid var(--border); border-radius: 9px;
  font-size: 14px; font-family: inherit; background: #fff; color: var(--text); outline: none; transition: .18s;
}
.field textarea { resize: vertical; min-height: 76px; line-height: 1.6; }
.field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,.1);
}
.field .tip { font-size: 12px; color: #9ca3af; margin-top: 5px; }

.status-pick { display: flex; gap: 10px; }
.status-pick label {
  flex: 1; border: 2px solid var(--border); border-radius: 10px; padding: 12px;
  text-align: center; cursor: pointer; font-size: 14px; font-weight: 600; transition: .18s;
  display: flex; align-items: center; justify-content: center; gap: 6px; color: var(--text-sub);
}
.status-pick input { display: none; }
.status-pick label.sel-normal { border-color: var(--green); background: var(--green-bg); color: var(--green); }
.status-pick label.sel-abnormal { border-color: var(--red); background: var(--red-bg); color: var(--red); }

/* 详情 */
.detail-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 16px; }
.detail-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px 18px;
  padding: 14px; background: #f8fafc; border-radius: 10px; margin-bottom: 18px;
}
.detail-grid div .k { font-size: 12px; color: var(--text-sub); }
.detail-grid div .v { font-size: 14px; font-weight: 600; margin-top: 1px; word-break: break-all; }

.section-title {
  font-size: 14px; font-weight: 600; margin: 0 0 12px;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
}

/* 时间轴 */
.timeline { position: relative; padding-left: 22px; }
.timeline::before {
  content: ''; position: absolute; left: 5px; top: 4px; bottom: 4px; width: 2px; background: var(--border);
}
.tl-item { position: relative; padding-bottom: 18px; }
.tl-item::before {
  content: ''; position: absolute; left: -21px; top: 5px; width: 10px; height: 10px;
  border-radius: 50%; background: var(--green); border: 2px solid #fff; box-shadow: 0 0 0 2px var(--green);
}
.tl-item.abnormal::before { background: var(--red); box-shadow: 0 0 0 2px var(--red); }
.tl-head { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; flex-wrap: wrap; }
.tl-stage { font-weight: 600; font-size: 14px; }
.tl-date { font-size: 12px; color: var(--text-sub); font-family: ui-monospace, monospace; }
.tl-note { font-size: 13px; color: var(--text-sub); margin-top: 4px; line-height: 1.6; white-space: pre-wrap; }
.tl-blocker {
  margin-top: 6px; padding: 7px 10px; background: var(--red-bg); color: #b91c1c;
  border-radius: 7px; font-size: 12.5px; border-left: 3px solid var(--red); font-weight: 500;
}

/* 告警列表 */
.alert-item {
  display: flex; gap: 11px; padding: 12px 13px; border-radius: 10px; margin-bottom: 9px;
  background: #fff; border: 1px solid var(--border); border-left: 4px solid var(--red);
}
.alert-item.warning { border-left-color: var(--amber); }
.alert-item.handled { opacity: .5; border-left-color: var(--border); }
.alert-item .ai-icon { font-size: 17px; flex-shrink: 0; }
.alert-item .ai-body { flex: 1; min-width: 0; }
.alert-item .ai-title { font-size: 13.5px; font-weight: 600; }
.alert-item .ai-msg { font-size: 13px; color: var(--text-sub); margin-top: 2px; word-break: break-word; }
.alert-item .ai-meta { font-size: 11.5px; color: #9ca3af; margin-top: 5px; display: flex; gap: 12px; flex-wrap: wrap; }

/* Toast */
.toast-wrap {
  position: fixed; top: 16px; left: 50%; transform: translateX(-50%); z-index: 200;
  display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none;
  width: calc(100% - 32px); max-width: 400px;
}
.toast {
  padding: 11px 18px; border-radius: 10px; background: #1f2937; color: #fff; font-size: 13.5px;
  box-shadow: var(--shadow-lg); animation: toastIn .25s ease; max-width: 100%; font-weight: 500;
}
.toast.ok { background: var(--green); }
.toast.err { background: var(--red); }
.toast.warn { background: var(--amber); }
@keyframes toastIn { from { opacity:0; transform: translateY(-10px);} to {opacity:1;transform:none;} }


/* ================= 扫码 ================= */
.scan-tip {
  display: flex; align-items: center; gap: 10px; padding: 12px 16px; margin-bottom: 16px;
  background: #eff6ff; border: 1.5px solid #bfdbfe; border-radius: 10px;
  color: #1e40af; font-size: 13.5px; font-weight: 500; animation: rise .25s ease;
}
.scan-pulse {
  width: 9px; height: 9px; border-radius: 50%; background: var(--primary);
  flex-shrink: 0; animation: pulse 1.4s infinite;
}
.scan-tip .icon-btn { margin-left: auto; background: transparent; }
.scan-tip .icon-btn:hover { background: #dbeafe; }

.bc-tag {
  display: inline-block; margin-left: 6px; padding: 1px 7px; border-radius: 5px;
  background: #f1f5f9; color: #475569; font-size: 10.5px; font-weight: 600;
  letter-spacing: 0; vertical-align: 1px;
}

/* ================= 报表 ================= */
.report-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 12px; margin-bottom: 14px; flex-wrap: wrap;
}
.report-range-text { font-size: 12.5px; color: var(--text-sub); }

.range-bar { display: flex; gap: 8px; margin-bottom: 18px; flex-wrap: wrap; }
.range-btn {
  border: 1.5px solid var(--border); background: #fff; color: var(--text-sub);
  padding: 7px 15px; border-radius: 20px; font-size: 13px; font-family: inherit;
  cursor: pointer; transition: .18s; font-weight: 500;
}
.range-btn:hover { border-color: var(--primary); color: var(--primary); }
.range-btn.active { background: var(--primary); border-color: var(--primary); color: #fff; font-weight: 600; }

.report-section {
  background: #fff; border-radius: var(--radius); padding: 18px;
  box-shadow: var(--shadow); margin-bottom: 14px;
}
.report-title {
  margin: 0 0 14px; font-size: 14.5px; font-weight: 600;
  display: flex; align-items: baseline; gap: 8px;
}
.report-title small { font-size: 12px; color: var(--text-sub); font-weight: 400; }

/* 异常率大卡片 */
.rate-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; }
.rate-card {
  padding: 15px 16px; border-radius: 11px; background: #f8fafc;
  border: 1.5px solid var(--border);
}
.rate-card.has-err { background: var(--red-bg); border-color: #fecaca; }
.rate-label { font-size: 12.5px; color: var(--text-sub); font-weight: 500; }
.rate-value {
  font-size: 30px; font-weight: 700; line-height: 1.25; color: var(--green); margin: 4px 0 2px;
}
.rate-value span { font-size: 15px; font-weight: 600; margin-left: 1px; }
.rate-card.has-err .rate-value { color: var(--red); }
.rate-sub { font-size: 12px; color: var(--text-sub); }
.rate-bar { height: 4px; background: #e2e8f0; border-radius: 3px; overflow: hidden; margin-top: 9px; }
.rate-bar i { display: block; height: 100%; background: var(--red); border-radius: 3px; transition: width .5s; }
.rate-card:not(.has-err) .rate-bar i { background: var(--green); }

/* 维度条形列表 */
.dim-list { display: flex; flex-direction: column; gap: 11px; }
.dim-row { display: flex; align-items: center; gap: 12px; }
.dim-name {
  width: 110px; flex-shrink: 0; font-size: 13px; font-weight: 500;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.dim-bar-wrap { flex: 1; height: 22px; background: #f1f5f9; border-radius: 6px; overflow: hidden; }
.dim-bar { height: 100%; border-radius: 6px; transition: width .5s; min-width: 0; }
.dim-bar.low { background: #86efac; }
.dim-bar.mid { background: #fbbf24; }
.dim-bar.high { background: #f87171; }
.dim-stat { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.dim-count { font-size: 12px; color: var(--text-sub); font-family: ui-monospace, monospace; }

.rate-pill {
  display: inline-block; padding: 2px 9px; border-radius: 12px;
  font-size: 12px; font-weight: 600; font-family: ui-monospace, monospace;
}
.rate-pill.low { background: var(--green-bg); color: var(--green); }
.rate-pill.mid { background: #fffbeb; color: #b45309; }
.rate-pill.high { background: #fee2e2; color: var(--red); }

/* 图表 */
.chart-wrap { width: 100%; overflow: hidden; }

/* 原因 TOP */
.reason-list { display: flex; flex-direction: column; gap: 8px; }
.reason-item {
  display: flex; align-items: center; gap: 11px; padding: 10px 13px;
  background: #f8fafc; border-radius: 9px; border-left: 3px solid var(--red);
}
.reason-rank {
  width: 20px; height: 20px; border-radius: 6px; background: var(--red); color: #fff;
  font-size: 11px; font-weight: 700; display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.reason-text { flex: 1; font-size: 13px; word-break: break-word; }
.reason-count { font-size: 12.5px; color: var(--red); font-weight: 600; flex-shrink: 0; }

/* 数据表格 */
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.data-table { width: 100%; border-collapse: collapse; font-size: 13px; min-width: 560px; }
.data-table th {
  background: #f8fafc; color: var(--text-sub); font-weight: 600; font-size: 12.5px;
  padding: 9px 11px; text-align: left; border-bottom: 1.5px solid var(--border); white-space: nowrap;
}
.data-table td { padding: 9px 11px; border-bottom: 1px solid #f1f5f9; }
.data-table tbody tr:hover { background: #f8fafc; }
.data-table .mono { font-family: ui-monospace, monospace; font-size: 12px; }
.data-table .err-cell { color: var(--red); font-weight: 600; }

/* 导出按钮 */
.export-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 10px; }
.export-btn {
  display: flex; flex-direction: column; align-items: flex-start; gap: 3px;
  padding: 14px 15px; border: 1.5px solid var(--border); border-radius: 11px;
  background: #fff; cursor: pointer; font-family: inherit; font-size: 13.5px;
  font-weight: 600; color: var(--text); transition: .18s; text-align: left;
}
.export-btn span { font-size: 19px; line-height: 1.2; }
.export-btn i { font-style: normal; font-size: 11.5px; color: var(--text-sub); font-weight: 400; }
.export-btn:hover { border-color: var(--primary); background: #eff6ff; }
.export-btn:active { transform: scale(.98); }

/* ================= 管理员操作 ================= */
.card-actions {
  display: flex; gap: 8px; margin-top: 10px; padding-top: 10px;
  border-top: 1px dashed var(--border);
}
.act-btn {
  flex: 0 0 auto; border: 1.5px solid var(--border); background: #fff; color: var(--text-sub);
  padding: 6px 13px; border-radius: 8px; font-size: 12.5px; font-family: inherit;
  font-weight: 500; cursor: pointer; transition: .18s;
}
.act-btn:hover { border-color: var(--primary); color: var(--primary); background: #eff6ff; }
.act-btn.danger:hover { border-color: var(--red); color: var(--red); background: var(--red-bg); }
.act-btn.sm { padding: 4px 11px; font-size: 12px; }

.tl-actions { display: flex; gap: 7px; margin-top: 7px; }

/* 批量操作栏 */
.batch-bar {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  padding: 12px 16px; margin-bottom: 14px; border-radius: 11px;
  background: #eff6ff; border: 1.5px solid #bfdbfe; animation: rise .2s ease;
}
.batch-check {
  display: flex; align-items: center; gap: 6px; font-size: 13.5px;
  font-weight: 600; color: #1e40af; cursor: pointer; user-select: none;
}
.batch-check input, .batch-pick {
  width: 16px; height: 16px; accent-color: var(--primary); cursor: pointer;
}
.batch-info { font-size: 13.5px; color: #1e40af; }
.batch-info b { font-size: 15px; }
.batch-bar .btn { margin-left: auto; }
.batch-bar .btn + .btn { margin-left: 0; }

.mat-card .batch-pick { margin-right: 4px; flex-shrink: 0; align-self: flex-start; margin-top: 3px; }

/* 危险确认框 */
.danger-box {
  display: flex; gap: 12px; padding: 14px 16px; margin-bottom: 16px;
  background: var(--red-bg); border: 1.5px solid #fecaca; border-radius: 11px;
}
.danger-icon { font-size: 22px; flex-shrink: 0; line-height: 1.3; }

.batch-preview {
  max-height: 200px; overflow-y: auto; border: 1px solid var(--border);
  border-radius: 9px; padding: 8px;
}
.bp-item {
  padding: 6px 9px; font-size: 13px; border-radius: 6px;
  display: flex; gap: 8px; align-items: baseline;
}
.bp-item:nth-child(odd) { background: #f8fafc; }
.bp-item .mono { font-family: ui-monospace, monospace; font-size: 11.5px; color: var(--text-sub); }

/* ================= 侧边导航栏 ================= */
.app { display: flex; min-height: 100vh; min-height: 100dvh; }

.sidebar {
  width: 232px; flex-shrink: 0; background: #1e293b; color: #cbd5e1;
  display: flex; flex-direction: column;
  position: fixed; top: 0; bottom: 0; left: 0; z-index: 80;
  transition: transform .25s ease;
}
.sidebar-brand {
  display: flex; align-items: center; gap: 10px;
  padding: 18px 18px 16px; border-bottom: 1px solid rgba(255,255,255,.08);
}
.sidebar-brand .logo-sm { width: 36px; height: 36px; font-size: 13px; }
.sb-brand-text { display: flex; flex-direction: column; line-height: 1.3; }
.sb-brand-text b { color: #fff; font-size: 14px; }
.sb-brand-text small { color: #64748b; font-size: 10px; letter-spacing: .6px; text-transform: uppercase; }

.sidebar-nav { flex: 1; overflow-y: auto; padding: 14px 10px; }
.nav-group { margin-bottom: 18px; }
.nav-group-title {
  padding: 0 10px 7px; font-size: 11px; font-weight: 600;
  color: #64748b; letter-spacing: .8px;
}
.nav-link {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 9px 11px; margin-bottom: 2px; border: 0; border-radius: 8px;
  background: transparent; color: #cbd5e1; font-size: 13.5px; font-family: inherit;
  cursor: pointer; transition: .16s; text-align: left; position: relative;
}
.nav-link:hover { background: rgba(255,255,255,.07); color: #fff; }
.nav-link.active {
  background: linear-gradient(90deg, #2563eb, #3b82f6);
  color: #fff; font-weight: 600;
  box-shadow: 0 2px 8px rgba(37,99,235,.35);
}
.nl-icon { font-size: 15px; width: 18px; text-align: center; flex-shrink: 0; }
.nl-label { flex: 1; }
.nl-badge {
  min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
  background: var(--red); color: #fff; font-size: 10.5px; font-style: normal;
  font-weight: 700; display: inline-flex; align-items: center; justify-content: center;
}

.sidebar-foot { padding: 14px; border-top: 1px solid rgba(255,255,255,.08); }
.sb-user { display: flex; align-items: center; gap: 10px; margin-bottom: 11px; }
.sb-avatar {
  width: 34px; height: 34px; border-radius: 9px; flex-shrink: 0;
  background: linear-gradient(135deg, #3b82f6, #60a5fa); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 14px;
}
.sb-user-info { display: flex; flex-direction: column; line-height: 1.3; min-width: 0; }
.sb-user-info b { color: #fff; font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sb-user-info small { color: #64748b; font-size: 11.5px; }
.sidebar-foot .btn-ghost { color: #cbd5e1; border-color: rgba(255,255,255,.15); }
.sidebar-foot .btn-ghost:hover { background: rgba(255,255,255,.08); color: #fff; }

.sidebar-mask {
  display: none; position: fixed; inset: 0; z-index: 79;
  background: rgba(15,23,42,.5); backdrop-filter: blur(2px);
}
.sidebar-mask.show { display: block; }

/* 主内容区让出侧栏宽度 */
.app-main { flex: 1; min-width: 0; margin-left: 232px; display: flex; flex-direction: column; }
.app-main .container { width: 100%; }

/* 汉堡按钮（PC 默认隐藏） */
.hamburger {
  display: none; flex-direction: column; gap: 4px; justify-content: center;
  width: 34px; height: 34px; padding: 0 8px; margin-right: 8px;
  border: 1.5px solid var(--border); border-radius: 8px;
  background: #fff; cursor: pointer; flex-shrink: 0;
}
.hamburger span { display: block; height: 2px; background: var(--text-sub); border-radius: 2px; transition: .2s; }
.mobile-only { display: none !important; }

/* 系统管理表单 */
.sys-status-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; flex-wrap: wrap; margin-bottom: 16px;
}
.sys-badge {
  padding: 6px 14px; border-radius: 20px; font-size: 13px; font-weight: 600;
}
.sys-badge.on { background: var(--green-bg); color: var(--green); }
.sys-badge.off { background: #fffbeb; color: #b45309; }
.sys-form { display: flex; flex-direction: column; }

/* 打印 */
/* ================= 移动端 16:9 显示模式 ================= */
/*
 * 目标：手机竖屏下，统计卡片 / 物料卡片 / 报表卡片统一按 16:9 宽高比排布，
 *      两列网格，卡片内容垂直居中；同时兼容平板横屏。
 * 关键：用 aspect-ratio 锁定比例，配合 overflow:hidden 防止长文本撑破比例。
 */

/* ---- 手机竖屏 / 小屏：两列 16:9 ---- */
@media (max-width: 768px) {
  .container {
    padding: 12px 12px calc(var(--bottom-nav-h) + var(--safe-b) + 16px);
  }
  .topbar {
    padding: calc(8px + var(--safe-t)) 12px 8px;
    position: sticky; top: 0; z-index: 50;
  }
  .app-title { font-size: 14px; }
  .user-chip { display: none; }
  /* 窄屏：改密 / 退出 只显示图标，省出横向空间 */
  #changePwdBtn .ico, #logoutBtn .ico { display: inline-flex; font-size: 15px; line-height: 1; }
  #changePwdBtn .btn-label, #logoutBtn .btn-label { display: none; }
  #changePwdBtn, #logoutBtn { padding: 6px 9px; min-width: 34px; justify-content: center; }
  .bottom-nav { display: flex; }

  /* ---- 统计卡片：16:9 两列 ---- */
  .stat-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: var(--ratio-gap);
    margin-bottom: 14px;
  }
  .stat-card {
    aspect-ratio: var(--ratio);
    padding: 10px 12px;
    border-left-width: 3px;
    display: flex; flex-direction: column; justify-content: center;
    overflow: hidden;
  }
  .stat-card .num { font-size: clamp(19px, 6.4vw, 26px); line-height: 1.15; }
  .stat-card .lbl { font-size: 11.5px; margin-top: 3px; white-space: nowrap;
                    overflow: hidden; text-overflow: ellipsis; }

  /* ---- 物料卡片：16:9 两列 ---- */
  .material-list {
    grid-template-columns: repeat(2, 1fr);
    gap: var(--ratio-gap);
  }
  .mat-card {
    aspect-ratio: var(--ratio);
    padding: 11px 12px;
    border-left-width: 3px;
    display: flex; flex-direction: column;
    overflow: hidden;
    animation: none;                        /* 网格内动画会抖动，关掉 */
  }
  .mat-card:hover { transform: none; }
  .mat-top { gap: 6px; margin-bottom: 4px; min-width: 0; }
  .mat-top > div:first-child { min-width: 0; flex: 1; }
  .mat-code { font-size: 10.5px; display: block; white-space: nowrap;
              overflow: hidden; text-overflow: ellipsis; }
  .mat-name { font-size: 14px; margin-top: 1px; line-height: 1.3;
              display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
              overflow: hidden; }
  .mat-spec { font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .badge { padding: 2px 7px; font-size: 10.5px; }

  /* 卡片中部信息：超出部分省略，保证 16:9 不被撑高 */
  .mat-meta {
    flex: 1; min-height: 0; overflow: hidden;
    gap: 2px 10px; font-size: 11px;
    margin-top: 6px; padding-top: 6px;
    align-content: flex-start;
  }
  .mat-meta span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
  .progress-track { height: 4px; margin-top: 6px; flex-shrink: 0; }
  .mat-note {
    margin-top: 6px; padding: 4px 7px; font-size: 11px;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    flex-shrink: 0;
  }

  .toolbar { gap: 8px; margin-bottom: 12px; }
  .toolbar select, .search-box { width: 100%; flex: 1 1 100%; }
  .toolbar .btn { flex: 1 1 calc(50% - 4px); min-width: 0; padding: 9px 8px; font-size: 13px; }

  /* 空状态与网格共存时跨列 */
  .empty { grid-column: 1 / -1; }

  .modal { padding: 0; align-items: flex-end; }
  .modal-panel { max-width: 100%; border-radius: 16px 16px 0 0; max-height: 92dvh; }
  .modal-foot { flex-direction: column-reverse; }
  .modal-foot .btn { width: 100%; }
  .form-row > label { min-width: 100%; }
}

/* ---- 超窄屏（≤380px）：统计卡片仍两列但压缩字号 ---- */
@media (max-width: 380px) {
  .stat-grid { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .stat-card { padding: 8px 9px; }
  .stat-card .num { font-size: 18px; }
  .stat-card .lbl { font-size: 10.5px; }
  .material-list { gap: 8px; }
  .mat-card { padding: 9px 10px; }
  .mat-name { font-size: 13px; }
}

/* ---- 报告/报表移动端 ---- */
@media (max-width: 768px) {
  /* 侧栏改为抽屉 */
  .sidebar { transform: translateX(-100%); width: 250px; }
  .sidebar.open { transform: translateX(0); box-shadow: 4px 0 24px rgba(0,0,0,.25); }
  .app-main { margin-left: 0; }
  .hamburger { display: flex; }
  .mobile-only { display: flex !important; }
  .topbar-left .app-title { font-size: 14.5px; }

  /* 异常率卡片：16:9 两列 */
  .rate-grid { grid-template-columns: repeat(2, 1fr); gap: var(--ratio-gap); }
  .rate-card {
    aspect-ratio: var(--ratio);
    padding: 10px 12px;
    display: flex; flex-direction: column; justify-content: center;
    overflow: hidden;
  }
  .rate-value { font-size: clamp(20px, 6.2vw, 26px); line-height: 1.15; }
  .rate-label { font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .rate-card:last-child { grid-column: 1 / -1; }   /* 收尾卡片通栏，不收比例约束 */

  .dim-name { width: 72px; font-size: 12px; }
  .dim-bar-wrap { height: 18px; }
  .dim-count { display: none; }

  .report-section { padding: 13px; margin-bottom: 12px; }
  .report-head { flex-direction: column; align-items: stretch; }
  .report-head .btn { width: 100%; }
  .range-bar { gap: 6px; margin-bottom: 14px; }
  .range-btn { padding: 6px 11px; font-size: 12.5px; flex: 1 1 auto; text-align: center; }

  .export-grid { grid-template-columns: repeat(2, 1fr); gap: var(--ratio-gap); }
  .export-btn { aspect-ratio: var(--ratio); padding: 10px; font-size: 12.5px;
                display: flex; flex-direction: column; align-items: center; justify-content: center; }
}

/* ---- 平板横屏 / 大屏手机横屏（769 ~ 1024px）：16:9 三列 ---- */
@media (min-width: 769px) and (max-width: 1024px) {
  .container { padding: 16px 16px 90px; }
  .stat-grid { grid-template-columns: repeat(4, 1fr); gap: 12px; }
  .stat-card { aspect-ratio: var(--ratio); display: flex; flex-direction: column;
               justify-content: center; padding: 12px 14px; overflow: hidden; }
  .material-list { grid-template-columns: repeat(3, 1fr); gap: 12px; }
  .mat-card { aspect-ratio: var(--ratio); display: flex; flex-direction: column;
              overflow: hidden; padding: 13px 14px; }
  .mat-card .mat-meta { flex: 1; min-height: 0; overflow: hidden; }
  .mat-note { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .rate-grid { grid-template-columns: repeat(3, 1fr); gap: 12px; }
  .rate-card { aspect-ratio: var(--ratio); display: flex; flex-direction: column;
               justify-content: center; overflow: hidden; }
  .rate-card:last-child { grid-column: auto; }
  .export-grid { grid-template-columns: repeat(3, 1fr); gap: 12px; }
}

/* ---- 横屏矮屏（高度受限）时放宽比例，避免卡片被压扁 ---- */
@media (max-width: 1024px) and (orientation: landscape) and (max-height: 520px) {
  .stat-card, .mat-card, .rate-card, .export-btn { aspect-ratio: auto; min-height: 92px; }
}
/* ================= 手机扫一扫 / 摄像头扫码 ================= */

/* ---- 扫码视图：大号入口 ---- */
.scan-panel { grid-column: 1 / -1; display: flex; flex-direction: column; gap: 14px; }

.scan-big-btn {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  width: 100%; padding: 34px 20px; cursor: pointer; font-family: inherit;
  background: linear-gradient(135deg, #eff6ff 0%, #dbeafe 100%);
  border: 2px dashed #93c5fd; border-radius: 16px; color: #1e40af;
  transition: .18s;
}
.scan-big-btn:hover { border-color: var(--primary); background: linear-gradient(135deg,#dbeafe,#bfdbfe); transform: translateY(-1px); }
.scan-big-btn:active { transform: scale(.99); }
.scan-big-btn .sbb-icon { font-size: 42px; line-height: 1; }
.scan-big-btn .sbb-title { font-size: 19px; font-weight: 700; }
.scan-big-btn .sbb-sub { font-size: 12.5px; color: #3b82f6; }

.scan-dest-line {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 10px 14px; background: var(--card, #fff); border: 1px solid var(--border);
  border-radius: 10px; font-size: 13px;
}
.scan-dest-line b { color: var(--primary); }

.scan-tips { display: flex; flex-direction: column; gap: 7px; }
.scan-tip-item {
  display: flex; align-items: center; gap: 9px; font-size: 12.5px; color: var(--text-sub);
  padding: 8px 12px; background: #f8fafc; border-radius: 8px;
}
.scan-tip-item .sti-icon { font-size: 15px; }

.scan-desktop-note {
  padding: 11px 14px; background: #fffbeb; border: 1px solid #fde68a; border-radius: 10px;
  font-size: 12.5px; color: #92400e; line-height: 1.7;
}

/* ---- 摄像头面板 ---- */
.cam-wrap { display: flex; flex-direction: column; gap: 12px; }

.cam-stage {
  position: relative; width: 100%; aspect-ratio: 3 / 4; max-height: 58vh;
  background: #0f172a; border-radius: 14px; overflow: hidden;
}
.cam-stage video {
  width: 100%; height: 100%; object-fit: cover; display: block; background: #0f172a;
}
.cam-stage.cam-hit { box-shadow: 0 0 0 4px #22c55e inset; }

/* 取景遮罩 + 四角 */
.cam-mask {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  pointer-events: none;
}
.cam-frame {
  /* 取景框：略偏扁的圆角矩形，既能框住方形二维码，也够容纳长条码
     （解码时会按这个框的实际像素区域裁剪，框越大码的像素密度越高） */
  position: relative; width: 78%; aspect-ratio: 6 / 5; max-width: 320px;
  border: 2px solid rgba(255,255,255,.25); border-radius: 14px;
}
.cam-corner {
  position: absolute; width: 26px; height: 26px; border: 3px solid #22d3ee;
}
.cam-corner.tl { top: -2px; left: -2px; border-right: 0; border-bottom: 0; border-radius: 8px 0 0 0; }
.cam-corner.tr { top: -2px; right: -2px; border-left: 0; border-bottom: 0; border-radius: 0 8px 0 0; }
.cam-corner.bl { bottom: -2px; left: -2px; border-right: 0; border-top: 0; border-radius: 0 0 0 8px; }
.cam-corner.br { bottom: -2px; right: -2px; border-left: 0; border-top: 0; border-radius: 0 0 8px 0; }

/* 扫描线动画 */
.cam-line {
  position: absolute; left: 12%; right: 12%; height: 2px; top: 14%;
  background: linear-gradient(90deg, transparent, #22d3ee, transparent);
  box-shadow: 0 0 10px #22d3ee; animation: camScan 2.1s ease-in-out infinite;
  pointer-events: none;
}
@keyframes camScan {
  0%   { top: 14%; opacity: .25; }
  50%  { top: 86%; opacity: 1; }
  100% { top: 14%; opacity: .25; }
}

/* 识别中：取景框高亮 + 扫描线加速，给用户「正在读」的反馈 */
.cam-stage.cam-reading .cam-frame { border-color: rgba(34,211,238,.75); }
.cam-stage.cam-reading .cam-line { animation-duration: .8s; }

.cam-hint {
  position: absolute; left: 0; right: 0; bottom: 64px; text-align: center;
  color: #fff; font-size: 12.5px; padding: 0 16px;
  text-shadow: 0 1px 4px rgba(0,0,0,.75); pointer-events: none;
}

.cam-actions {
  position: absolute; right: 10px; top: 10px; display: flex; flex-direction: column; gap: 8px;
}
.cam-icon-btn {
  width: 38px; height: 38px; border-radius: 50%; border: 0; cursor: pointer;
  background: rgba(15,23,42,.55); color: #fff; font-size: 17px; line-height: 1;
  display: flex; align-items: center; justify-content: center;
  backdrop-filter: blur(4px); transition: .16s;
}
.cam-icon-btn:disabled { opacity: .35; cursor: not-allowed; }
.cam-icon-btn.on { background: #f59e0b; color: #1f2937; }

/* 去向切换 */
.cam-dest { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; }
.cam-dest-label { font-size: 12.5px; color: var(--text-sub); flex-shrink: 0; }
.cam-dest-opts { display: flex; gap: 7px; flex: 1; }
.cam-dest-opts label {
  flex: 1; text-align: center; padding: 7px 10px; font-size: 12.5px; cursor: pointer;
  border: 1.5px solid var(--border); border-radius: 8px; background: #fff;
  color: var(--text-sub); transition: .16s; white-space: nowrap;
}
.cam-dest-opts label.on { border-color: var(--primary); background: #eff6ff; color: var(--primary); font-weight: 600; }

/* 手动输入兜底 */
.cam-manual { font-size: 12.5px; }
.cam-manual summary { cursor: pointer; color: var(--text-sub); padding: 4px 0; }
.cam-manual-row { display: flex; gap: 8px; margin-top: 8px; }
.cam-manual-row input { flex: 1; min-width: 0; }

.cam-engine { font-size: 11.5px; color: #94a3b8; text-align: center; }

/* 降级面板 */
.cam-fallback { text-align: center; }
.cam-fallback-icon { font-size: 40px; margin-bottom: 10px; }
.cam-fallback-text {
  font-size: 13px; color: var(--text-sub); line-height: 1.85; text-align: left;
  background: #f8fafc; border-radius: 10px; padding: 13px 15px;
}
.cam-fallback .field { text-align: left; }

/* 移动端微调 */
@media (max-width: 768px) {
  .scan-big-btn { padding: 28px 16px; }
  .scan-big-btn .sbb-icon { font-size: 38px; }
  .scan-big-btn .sbb-title { font-size: 17.5px; }
  .cam-stage { max-height: 50vh; aspect-ratio: 4 / 5; }
  .cam-dest-opts label { padding: 8px 8px; font-size: 12px; }
}
@media (max-width: 380px) {
  .cam-dest { flex-direction: column; align-items: stretch; }
  .cam-dest-label { margin-bottom: -2px; }
}

@media print {
  .topbar, .bottom-nav, .toolbar, .btn { display: none !important; }
}

/* ================= 轨迹现场图片 + 上传进度 + 灯箱 ================= */
.lbl-sub { font-weight: 400; color: #9ca3af; font-size: 12px; }

.img-picker { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.img-add {
  flex: 1; min-width: 120px; padding: 10px 12px;
  border: 1px dashed var(--border); border-radius: 10px;
  background: #f8fafc; color: var(--text); font-size: 13.5px; cursor: pointer;
  transition: .18s; font-family: inherit;
}
.img-add:hover { border-color: var(--primary); color: var(--primary); background: #eff6ff; }
.img-add:active { transform: scale(.98); }

.img-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(72px, 1fr)); gap: 8px; }
.img-grid:empty { display: none; }
.img-thumb { position: relative; padding-top: 100%; border-radius: 9px; overflow: hidden; border: 1px solid var(--border); background: #f1f5f9; }
.img-thumb img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.img-del {
  position: absolute; top: 3px; right: 3px; width: 20px; height: 20px; border: none; border-radius: 50%;
  background: rgba(15,23,42,.62); color: #fff; font-size: 12px; line-height: 1; cursor: pointer;
  display: flex; align-items: center; justify-content: center; padding: 0;
}
.img-del:hover { background: var(--red); }
.img-tip { font-size: 12px; color: #9ca3af; margin-top: 6px; }

/* 上传进度条（实时） */
.up-wrap { margin: 4px 0 14px; padding: 10px 12px; background: #eff6ff; border-radius: 10px; border: 1px solid #dbeafe; }
.up-head { display: flex; justify-content: space-between; align-items: center; font-size: 12.5px; color: #1e40af; margin-bottom: 7px; gap: 10px; }
.up-head span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.up-bar { height: 8px; border-radius: 6px; background: #dbeafe; overflow: hidden; }
.up-fill { height: 100%; width: 0; border-radius: 6px; background: linear-gradient(90deg, var(--primary), #60a5fa); transition: width .18s ease; }

/* ---------- 保存流程实时进度（多阶段清单 + 总进度条） ---------- */
.save-prog {
  margin: 16px 0 4px; padding: 12px 13px; background: #f8fafc;
  border: 1px solid #e2e8f0; border-radius: 12px;
}
.sp-list { display: flex; flex-direction: column; gap: 7px; margin-bottom: 11px; }
.sp-item {
  display: flex; align-items: baseline; gap: 8px; font-size: 13px;
  color: var(--text-sub); transition: color .2s;
}
.sp-item .sp-ico {
  flex: 0 0 16px; text-align: center; font-size: 12px; line-height: 1.5;
  color: #cbd5e1; transition: color .2s, transform .2s;
}
.sp-item .sp-name { font-weight: 500; }
.sp-item .sp-note {
  flex: 1; min-width: 0; font-size: 12px; color: #94a3b8;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: right;
}
.sp-item.is-running { color: var(--primary); }
.sp-item.is-running .sp-ico { color: var(--primary); animation: spPulse 1s ease-in-out infinite; }
.sp-item.is-running .sp-note { color: var(--primary); }
.sp-item.is-done { color: var(--green); }
.sp-item.is-done .sp-ico { color: var(--green); }
.sp-item.is-done .sp-note { color: var(--green); opacity: .85; }
.sp-item.is-fail { color: var(--red); }
.sp-item.is-fail .sp-ico { color: var(--red); }
.sp-item.is-fail .sp-note { color: var(--red); }

@keyframes spPulse { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }

.sp-bar { height: 9px; }
.sp-overall {
  display: flex; justify-content: space-between; align-items: center;
  margin-top: 8px; font-size: 12.5px; color: var(--text-sub); gap: 10px;
}
.sp-overall span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sp-overall b { color: var(--primary); font-variant-numeric: tabular-nums; }

/* ---------- 阶段自动进度（v1.0.16）：只读展示，替代原人工进度滑块 ---------- */
.auto-prog { display: flex; align-items: center; gap: 10px; }
.auto-prog-bar {
  flex: 1; height: 10px; border-radius: 999px; overflow: hidden;
  background: #e2e8f0; box-shadow: inset 0 1px 2px rgba(15,23,42,.06);
}
.auto-prog-fill {
  height: 100%; width: 0; border-radius: 999px;
  background: linear-gradient(90deg, #60a5fa, var(--primary));
  transition: width .35s cubic-bezier(.22,1,.36,1);
}
.auto-prog b {
  flex: 0 0 auto; min-width: 42px; text-align: right;
  font-size: 14px; color: var(--primary); font-variant-numeric: tabular-nums;
}
.field .tip.warn { color: #b45309; }
.field .tip.warn::before { content: '⚠ '; }

/* 卡片列表：记录轨迹后的一次性高亮脉冲 + 进度增量提示 */
.mat-card.just-updated { animation: cardPulse 1.5s ease-out; }
@keyframes cardPulse {
  0% { box-shadow: 0 0 0 0 rgba(37,99,235,.45); }
  70% { box-shadow: 0 0 0 9px rgba(37,99,235,0); }
  100% { box-shadow: var(--shadow); }
}
.sp-delta {
  position: absolute; top: 10px; right: 12px; z-index: 4;
  padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 700;
  color: #fff; background: var(--green); pointer-events: none;
  animation: deltaFloat 1.8s ease-out forwards;
}
@keyframes deltaFloat {
  0% { opacity: 0; transform: translateY(6px) scale(.9); }
  18% { opacity: 1; transform: translateY(0) scale(1); }
  75% { opacity: 1; transform: translateY(-4px); }
  100% { opacity: 0; transform: translateY(-12px); }
}

/* 详情时间轴内图片 */
.tl-imgs { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; align-items: center; }
.tl-img { width: 56px; height: 56px; object-fit: cover; border-radius: 8px; border: 1px solid var(--border); cursor: pointer; transition: .15s; }
.tl-img:hover { transform: scale(1.04); border-color: var(--primary); }
.tl-img-count { font-size: 12px; color: var(--text-sub); }

/* 图片灯箱 */
.lightbox { position: fixed; inset: 0; z-index: 300; display: flex; align-items: center; justify-content: center; padding: 20px; }
.lb-mask { position: absolute; inset: 0; background: rgba(15,23,42,.86); }
.lb-body { position: relative; max-width: 92vw; max-height: 88vh; display: flex; align-items: center; justify-content: center; }
.lb-img { max-width: 92vw; max-height: 88vh; border-radius: 10px; box-shadow: var(--shadow-lg); display: block; }
.lb-close { position: absolute; top: -12px; right: -12px; width: 34px; height: 34px; border-radius: 50%; border: none; background: rgba(255,255,255,.92); color: #1f2937; font-size: 15px; cursor: pointer; box-shadow: var(--shadow); }
.lb-nav { position: absolute; top: 50%; transform: translateY(-50%); width: 42px; height: 42px; border-radius: 50%; border: none; background: rgba(255,255,255,.9); color: #1f2937; font-size: 24px; line-height: 1; cursor: pointer; box-shadow: var(--shadow); }
.lb-prev { left: -50px; }
.lb-next { right: -50px; }
.lb-count { position: absolute; bottom: -30px; left: 50%; transform: translateX(-50%); color: #e5e7eb; font-size: 13px; }

@media (max-width: 768px) {
  .img-add { min-width: 0; }
  .lb-prev { left: 4px; }
  .lb-next { right: 4px; }
  .tl-img { width: 50px; height: 50px; }
}

/* 扫码能力提示条（如实告知本机能否扫一维条码） */
.cam-capability {
  margin: 10px 0 0; padding: 9px 12px; border-radius: 9px;
  font-size: 12.5px; line-height: 1.65;
}
.cam-capability.ok { background: var(--green-bg); color: #166534; border: 1px solid #bbf7d0; }
.cam-capability.warn { background: #fffbeb; color: #92400e; border: 1px solid #fde68a; }

/* ============================================================
   确认完成 / 超期报警（v1.0.17）
   ============================================================ */

/* ---------- 状态横幅（详情页顶部） ---------- */
.state-banner {
  display: flex; gap: 11px; align-items: flex-start;
  padding: 12px 14px; margin: 0 0 14px; border-radius: 10px;
  font-size: 13px; line-height: 1.7;
}
.state-banner .sb-icon { font-size: 19px; line-height: 1.2; flex: 0 0 auto; }
.state-banner .sb-body { min-width: 0; }
.state-banner .sb-title { font-weight: 600; margin-bottom: 3px; }
.state-banner .sb-sub { color: #4b5563; font-size: 12.5px; }

.state-banner.locked { background: var(--green-bg); border: 1px solid #bbf7d0; border-left: 3px solid var(--green); }
.state-banner.locked .sb-title { color: #166534; }

.state-banner.overdue { background: #fffbeb; border: 1px solid #fde68a; border-left: 3px solid var(--amber); }
.state-banner.overdue .sb-title { color: #92400e; }

/* ---------- 列表卡片：锁定 / 超期徽标 ---------- */
.badge-group { display: flex; flex-direction: column; align-items: flex-end; gap: 5px; flex: 0 0 auto; }
.badge.overdue { background: #fffbeb; color: #92400e; border: 1px solid #fde68a; }
.badge.done.locked-badge, .badge-group .badge.done { white-space: nowrap; }

/* 已锁定的卡片：弱化视觉，提示「已完结」 */
.mat-card.is-locked { background: linear-gradient(180deg, #fbfefc, var(--card)); }
.mat-card.is-locked .mat-name { color: #374151; }

/* ---------- 「确认完成」信息区块（表单内） ---------- */
.complete-well {
  margin: 14px 0; border: 1px dashed #bbf7d0; border-radius: 10px;
  background: var(--green-bg); overflow: hidden;
}
.complete-well.overdue { border-color: #fde68a; background: #fffbeb; }
.cw-head { display: flex; align-items: baseline; gap: 9px; padding: 11px 14px; flex-wrap: wrap; }
.cw-title { font-weight: 600; font-size: 13.5px; color: #166534; }
.complete-well.overdue .cw-title { color: #92400e; }
.cw-sub { font-size: 12px; color: var(--text-sub); }
.cw-body { padding: 0 14px 13px; }
.cw-warn {
  margin-top: 10px; padding: 9px 11px; border-radius: 8px;
  background: #fff7ed; border: 1px solid #fed7aa; color: #9a3412;
  font-size: 12.5px; line-height: 1.65;
}

/* ---------- 锁定提示弹窗 ---------- */
.lock-box { display: flex; gap: 13px; align-items: flex-start; padding: 4px 0 2px; }
.lock-box .lock-icon { font-size: 30px; line-height: 1; flex: 0 0 auto; }

/* ---------- 时间轴：完成 / 撤销确认两类记账轨迹 ---------- */
.tl-item.tl-complete { border-left-color: var(--green); background: linear-gradient(90deg, var(--green-bg), transparent 55%); }
.tl-item.tl-complete .tl-stage { color: #166534; font-weight: 600; }
.tl-item.tl-undo { border-left-color: var(--amber); background: linear-gradient(90deg, #fffbeb, transparent 55%); }
.tl-item.tl-undo .tl-stage { color: #92400e; }

@media (max-width: 768px) {
  .badge-group { align-items: flex-end; gap: 4px; }
  .badge.overdue, .badge-group .badge { font-size: 11px; padding: 2px 6px; }
  .state-banner { padding: 10px 12px; font-size: 12.5px; }
}
