:root {
  --primary: #3455db;
  --primary-dark: #2742ad;
  --bg: #f2f4f9;
  --card: #ffffff;
  --text: #1c2333;
  --text-sub: #6b7686;
  --ok: #0e9f6e;
  --warn: #c27803;
  --danger: #d92d20;
  --radius: 14px;
  --shadow: 0 1px 3px rgba(16, 24, 40, .08), 0 4px 12px rgba(16, 24, 40, .05);
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg); color: var(--text); -webkit-font-smoothing: antialiased;
}
a { color: var(--primary); text-decoration: none; }

/* ---- 顶栏 ---- */
.topbar {
  background: var(--card); padding: 0 16px; height: 56px;
  display: flex; align-items: center; gap: 10px;
  box-shadow: 0 1px 0 rgba(16,24,40,.06); position: sticky; top: 0; z-index: 10;
}
.topbar .logo {
  width: 34px; height: 34px; border-radius: 9px; flex: none;
  background: linear-gradient(135deg, #3455db, #6d8bff);
  color: #fff; display: flex; align-items: center; justify-content: center;
  font-size: 17px; font-weight: 700;
}
.topbar h1 { font-size: 16px; font-weight: 600; }
.topbar h1 small { display: block; font-size: 11px; color: var(--text-sub); font-weight: 400; }
.topbar nav { margin-left: auto; display: flex; gap: 8px; }
.topbar nav a {
  font-size: 13px; color: var(--text-sub); padding: 6px 12px;
  border-radius: 8px; background: var(--bg);
}
.topbar nav a:hover { color: var(--primary); }

/* ---- 状态徽章 ---- */
.badge {
  display: inline-block; padding: 3px 10px; border-radius: 999px;
  font-size: 12px; background: #eef1f6; color: #556; white-space: nowrap;
}
.badge.识别中 { background: #fef3c7; color: #92400e; }
.badge.待验收 { background: #dbe4ff; color: #2742ad; }
.badge.识别失败 { background: #fee2e2; color: #b91c1c; }
.badge.待录入ERP { background: #d1fae5; color: #047857; }
.badge.已完成 { background: #e5e7eb; color: #4b5563; }
.badge.已丢弃 { background: #f3f4f6; color: #9ca3af; text-decoration: line-through; }

.container { max-width: 1080px; margin: 0 auto; padding: 16px; }
@media (max-width: 640px) { .container { padding: 12px; } }

/* ---- 步骤条 ---- */
.steps { display: flex; justify-content: center; gap: 6px; margin: 20px 0 4px; }
.steps .step { text-align: center; flex: 1; max-width: 120px; }
.steps .step .dot {
  width: 34px; height: 34px; margin: 0 auto 6px; border-radius: 50%;
  background: var(--card); color: var(--primary); border: 2px solid #c8d4f5;
  display: flex; align-items: center; justify-content: center; font-size: 15px;
}
.steps .step .label { font-size: 12px; color: var(--text-sub); }

/* ---- 上传卡片 ---- */
.upload-card { background: var(--card); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); margin-top: 14px; }
.photo-btn {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 8px; width: 100%; padding: 44px 0;
  border: 2px dashed #b7c6ee; border-radius: var(--radius);
  background: linear-gradient(180deg, #f7f9ff, #eef3ff);
  cursor: pointer; transition: .15s;
}
.photo-btn:active { transform: scale(.985); background: #e6edff; }
.photo-btn .cam { font-size: 34px; }
.photo-btn .t1 { font-size: 17px; color: var(--primary); font-weight: 600; }
.photo-btn .t2 { font-size: 12px; color: var(--text-sub); }
#preview { width: 100%; border-radius: 10px; margin-top: 14px; display: none; box-shadow: var(--shadow); }

.q-pills { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.q-pills .pill {
  font-size: 12px; padding: 5px 12px; border-radius: 999px;
  background: #ecfdf3; color: var(--ok); border: 1px solid #a6f4c5;
}
.q-pills .pill.warn { background: #fffaeb; color: var(--warn); border-color: #fedf89; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: none; border-radius: 10px; cursor: pointer;
  padding: 12px 22px; font-size: 16px; font-weight: 600;
  background: var(--primary); color: #fff; transition: .15s;
}
.btn:active { transform: scale(.98); }
.btn:disabled { background: #a9b8e8; cursor: not-allowed; }
.btn.secondary { background: #5b6472; }
.btn.ghost { background: #eef1f6; color: #374151; font-weight: 500; }
.btn.danger { background: var(--danger); }
#uploadBtn { width: 100%; margin-top: 14px; display: none; padding: 15px 22px; font-size: 17px; }
.status-line { margin-top: 12px; font-size: 14px; color: var(--text-sub); text-align: center; min-height: 20px; }
.mode-tip { font-size: 12px; color: #9aa3b2; margin: 16px 0 8px; text-align: center; }
.entry-link { display: block; text-align: center; margin-top: 14px; font-size: 14px; }

/* ---- 后台 ---- */
.stats { display: flex; gap: 10px; margin: 14px 0 4px; overflow-x: auto; padding-bottom: 4px; }
.stat-card {
  flex: 1; min-width: 96px; background: var(--card); border-radius: 12px;
  padding: 12px 14px; box-shadow: var(--shadow); text-align: center;
}
.stat-card .num { font-size: 22px; font-weight: 700; color: var(--primary); }
.stat-card .name { font-size: 12px; color: var(--text-sub); margin-top: 2px; }

.filters { display: flex; gap: 8px; flex-wrap: wrap; margin: 12px 0; }
.filters button {
  border: 1px solid #d7dde8; background: var(--card); border-radius: 999px;
  padding: 6px 15px; font-size: 13px; cursor: pointer; color: #445;
}
.filters button.active { background: var(--primary); color: #fff; border-color: var(--primary); }

.list-card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
table.list { width: 100%; border-collapse: collapse; }
table.list th, table.list td { padding: 11px 12px; font-size: 14px; border-bottom: 1px solid #f0f2f6; text-align: left; }
table.list th { background: #f8fafc; color: var(--text-sub); font-weight: 600; font-size: 13px; }
table.list tr:last-child td { border-bottom: none; }
.thumb { width: 60px; height: 45px; object-fit: cover; border-radius: 6px; }
@media (max-width: 640px) {
  table.list .hide-s { display: none; }
  .thumb { width: 48px; height: 36px; }
}

/* ---- 详情/验收 ---- */
.detail { display: grid; grid-template-columns: 1fr; gap: 14px; margin-top: 14px; }
@media (min-width: 900px) { .detail { grid-template-columns: 1.05fr 1fr; } }
.panel { background: var(--card); border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow); }
.panel h3 { font-size: 14px; margin-bottom: 10px; color: #334; }
.panel img.sheet { width: 100%; border-radius: 8px; cursor: zoom-in; }
.field-row { display: flex; gap: 10px; margin-bottom: 8px; align-items: center; font-size: 14px; }
.field-row label { width: 84px; flex: none; color: var(--text-sub); font-size: 13px; }
.field-row input, .field-row textarea {
  flex: 1; padding: 8px 10px; border: 1px solid #d9dfe9; border-radius: 8px;
  font-size: 14px; background: #fbfcfe; font-family: inherit;
}
.field-row input:focus, .field-row textarea:focus { outline: 2px solid #c8d4f5; border-color: var(--primary); }
.low-conf { background: #fffbeb !important; border-color: #f59e0b !important; }
table.edit { width: 100%; border-collapse: collapse; font-size: 12px; margin-bottom: 10px; }
table.edit th, table.edit td { border: 1px solid #e7ebf1; padding: 2px; }
table.edit th { background: #f8fafc; font-size: 12px; color: var(--text-sub); }
table.edit input { width: 100%; border: none; padding: 5px 4px; font-size: 12px; background: transparent; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 14px; }
.actions .btn { flex: 1; min-width: 120px; }

/* ---- 语音录入 ---- */
.voice-box {
  background: linear-gradient(135deg, #f5f8ff, #eef3ff);
  border: 1px solid #d5e0fa; border-radius: var(--radius); padding: 14px; margin-bottom: 14px;
}
.voice-box textarea {
  width: 100%; min-height: 110px; border: 1px solid #d9dfe9; border-radius: 10px;
  padding: 10px 12px; font-size: 15px; font-family: inherit; background: #fff; resize: vertical;
}
.mic-row { display: flex; gap: 10px; margin-top: 10px; align-items: center; flex-wrap: wrap; }
.mic-btn {
  width: 52px; height: 52px; border-radius: 50%; border: none; cursor: pointer;
  background: var(--primary); color: #fff; font-size: 22px;
  display: flex; align-items: center; justify-content: center; transition: .15s;
}
.mic-btn.recording { background: var(--danger); animation: pulse 1.2s infinite; }
@keyframes pulse { 0%,100% { box-shadow: 0 0 0 0 rgba(217,45,32,.4); } 50% { box-shadow: 0 0 0 12px rgba(217,45,32,0); } }
.voice-hint { font-size: 12px; color: var(--text-sub); }

.overlay {
  position: fixed; inset: 0; background: rgba(10,14,24,.88); display: none;
  align-items: center; justify-content: center; z-index: 99;
}
.overlay img { max-width: 96vw; max-height: 92vh; border-radius: 6px; }
.overlay.show { display: flex; }
.toast {
  position: fixed; left: 50%; bottom: 46px; transform: translateX(-50%);
  background: rgba(20,26,40,.92); color: #fff; padding: 11px 20px; border-radius: 10px;
  font-size: 14px; display: none; z-index: 100; box-shadow: var(--shadow);
}
.empty-state { text-align: center; color: #9aa3b2; padding: 40px 0; font-size: 14px; }

/* ---- 验收页紧凑单屏布局 ---- */
.meta-bar {
  display: flex; gap: 14px; align-items: center; flex-wrap: wrap;
  margin: 10px 0; font-size: 13px; color: var(--text-sub);
}
.scalar-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 6px 10px; margin-bottom: 10px;
}
.sg-item { display: flex; align-items: center; gap: 6px; font-size: 13px; }
.sg-item span { flex: none; color: var(--text-sub); white-space: nowrap; }
.sg-item input {
  flex: 1; min-width: 0; padding: 5px 8px; border: 1px solid #d9dfe9;
  border-radius: 6px; font-size: 13px; background: #fbfcfe;
}
.sg-item input:focus { outline: 2px solid #c8d4f5; border-color: var(--primary); }

.table-wrap { overflow-x: auto; }
table.sheet-table { width: 100%; border-collapse: collapse; font-size: 12px; }
table.sheet-table th, table.sheet-table td { border: 1px solid #e7ebf1; padding: 0; }
table.sheet-table th {
  background: #f8fafc; font-size: 12px; color: var(--text-sub);
  font-weight: 600; padding: 5px 3px; white-space: nowrap;
}
table.sheet-table input {
  width: 100%; min-width: 44px; border: none; padding: 5px 4px;
  font-size: 12px; background: transparent; text-align: center;
}
table.sheet-table input:focus { outline: 2px solid #c8d4f5; }
table.sheet-table .col-seq { width: 38px; text-align: center; color: var(--text-sub); background: #fbfcfe; }
table.sheet-table .col-op { width: 34px; text-align: center; }
table.sheet-table .col-op a { color: var(--danger); font-size: 12px; }
table.sheet-table .section-row td {
  background: #eef3ff; color: var(--primary); font-weight: 600;
  font-size: 12px; padding: 5px 10px; text-align: left;
}
table.sheet-table .fee-head td, table.sheet-table .fee-head th {
  background: #f8fafc; font-size: 12px; color: var(--text-sub); font-weight: 600;
  padding: 5px 3px; border: 1px solid #e7ebf1; white-space: nowrap; text-align: center;
}
.add-link { font-size: 12px; margin-left: 8px; }
.low-conf { background: #fffbeb !important; border-color: #f59e0b !important; }

/* ---- 上传页一屏自适应 ---- */
.upload-page .container { display: flex; flex-direction: column; min-height: calc(100vh - 56px); padding-top: 8px; }
.upload-page .steps { margin: 6px 0 2px; flex: none; }
.upload-page .steps .step .dot { width: 28px; height: 28px; font-size: 13px; margin-bottom: 3px; }
.upload-page .upload-card { flex: 1; display: flex; flex-direction: column; margin-top: 8px; padding: 14px; }
.upload-page .photo-btn { padding: 18px 0; flex: none; }
.upload-page #preview { flex: 1; min-height: 0; max-height: 38vh; object-fit: contain; background: #0e1220; }
.upload-page .entry-link { flex: none; margin: 8px 0 4px; }

/* ---- 备注框 ---- */
.remark-input {
  width: 100%; margin-top: 10px; padding: 8px 10px; font-size: 13px;
  border: 1px solid #d9dfe9; border-radius: 8px; background: #fbfcfe;
  font-family: inherit; resize: none;
}
.remark-input:focus { outline: 2px solid #c8d4f5; border-color: var(--primary); }

/* ---- 智能录入多图 ---- */
.img-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.img-chip { position: relative; width: 64px; height: 64px; border-radius: 8px; overflow: hidden; box-shadow: var(--shadow); }
.img-chip img { width: 100%; height: 100%; object-fit: cover; }
.img-chip .del {
  position: absolute; top: 2px; right: 2px; width: 18px; height: 18px;
  background: rgba(0,0,0,.55); color: #fff; border-radius: 50%;
  font-size: 12px; line-height: 18px; text-align: center; cursor: pointer;
}
.img-chip.add {
  border: 1.5px dashed #b7c6ee; display: flex; align-items: center; justify-content: center;
  font-size: 22px; color: var(--primary); cursor: pointer; background: #f4f8ff; box-shadow: none;
}

/* ---- 顶栏当前页高亮 ---- */
.topbar nav a.active { background: var(--primary); color: #fff; }
.topbar nav a.active:hover { color: #fff; }

/* 笔迹学习卡片 */
.corr-card { background: #fffdf5; border: 1px solid #f0e3b6; border-radius: 10px; padding: 12px 14px; margin-bottom: 12px; }
.corr-title { font-size: 14px; font-weight: 600; color: #7a5c00; margin-bottom: 8px; }
.corr-title small { font-weight: 400; color: #a08c5a; margin-left: 6px; }
.corr-list { display: flex; flex-wrap: wrap; gap: 6px; }
.corr-item { background: #fff; border: 1px solid #eee3c0; border-radius: 6px; padding: 4px 8px; font-size: 12px; color: #555; }
.corr-field { color: #999; margin-right: 4px; }
.corr-before { color: #c0392b; text-decoration: line-through; }
.corr-after { color: #27ae60; font-weight: 600; }
.corr-count { color: #bbb; margin-left: 4px; }

/* 顶栏用户芯片 */
.user-chip { margin-left: auto; display: flex; align-items: center; gap: 10px; font-size: 13px; }
.chip-name { color: #1a3a6b; font-weight: 600; }
.chip-balance { background: #eef8f1; color: #27ae60; border-radius: 10px; padding: 2px 10px; font-weight: 600; }
.chip-out { color: #98a4b5; text-decoration: none; }
.chip-out:hover { color: #d63a2f; }

/* ===== 手机端整体优化（≤640px）===== */
@media (max-width: 640px) {
  /* 顶栏改两行：第一行 标题+用户芯片，第二行 菜单横排可滑动 */
  .topbar { flex-wrap: wrap; height: auto; padding: 10px 12px 0; row-gap: 4px; }
  .topbar h1 { font-size: 15px; line-height: 1.2; }
  .topbar h1 small { display: none; }
  .user-chip { margin-left: auto; gap: 8px; font-size: 12px; flex: none; }
  .chip-name { max-width: 80px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .chip-balance { padding: 2px 8px; white-space: nowrap; }
  .chip-out { white-space: nowrap; }
  .topbar nav {
    order: 3; flex-basis: 100%; margin-left: 0;
    display: flex; gap: 6px; overflow-x: auto; padding: 4px 0 10px;
    -webkit-overflow-scrolling: touch; scrollbar-width: none;
  }
  .topbar nav::-webkit-scrollbar { display: none; }
  .topbar nav a { flex: none; white-space: nowrap; font-size: 13px; padding: 6px 14px; }

  /* 上传页：卡片不再强行撑满整屏，内容自然排列 */
  .upload-page .container { min-height: auto; }
  .upload-page .upload-card { flex: none; }
  .upload-page #preview { max-height: 46vh; }

  /* 控件加大，更适合手指 */
  .btn { padding: 13px 22px; }
  .photo-btn { padding: 34px 0; }
  .steps { margin: 10px 0 2px; }
  .steps .step .label { font-size: 11px; }

  /* 验收页输入框更易点按 */
  .sg-item input { font-size: 14px; padding: 7px 8px; }
  table.sheet-table { font-size: 13px; }
  table.sheet-table input { font-size: 13px; padding: 7px 4px; }
  table.sheet-table th { padding: 6px 3px; }

  /* 后台统计卡更紧凑 */
  .stat-card { min-width: 84px; padding: 10px 10px; }
  .stat-card .num { font-size: 19px; }
}

/* 拍照 / 相册 双按钮 */
.photo-row { display: flex; gap: 10px; width: 100%; }
.photo-row .photo-btn { flex: 1; padding: 17px 0; }
.photo-row .photo-btn.album { background: linear-gradient(180deg, #f6fbf7, #edf7f0); border-color: #b7e0c8; }
.photo-row .photo-btn.album .t1 { color: #0e9f6e; }
@media (max-width: 640px) { .photo-row .photo-btn { padding: 15px 0; } }

/* SVG 图标尺寸 */
.photo-btn .cam svg { width: 34px; height: 34px; }
.photo-row .photo-btn .cam { color: var(--primary); }
.photo-row .photo-btn.album .cam { color: #0e9f6e; }

/* 余额流水弹窗 */
.tx-modal { position: fixed; inset: 0; background: rgba(15,22,40,.45); display: none; align-items: flex-start; justify-content: center; z-index: 120; padding: 8vh 14px 14px; }
.tx-modal.show { display: flex; }
.tx-card { background: #fff; border-radius: 14px; width: 460px; max-width: 100%; max-height: 76vh; display: flex; flex-direction: column; box-shadow: 0 12px 40px rgba(10,20,50,.25); overflow: hidden; }
.tx-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 14px; border-bottom: 1px solid #eef1f5; }
.tx-tabs { display: flex; gap: 6px; }
.tx-tabs button { border: 1px solid #d7dde8; background: #f7f9fc; border-radius: 999px; padding: 5px 18px; font-size: 13px; cursor: pointer; color: #556; }
.tx-tabs button.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.tx-close { font-size: 22px; color: #98a4b5; cursor: pointer; padding: 0 6px; line-height: 1; }
.tx-list { overflow-y: auto; padding: 6px 14px 12px; }
.tx-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px dashed #eef1f5; font-size: 13px; }
.tx-note { color: #334; flex: 1; min-width: 0; }
.tx-side { text-align: right; flex: none; }
.tx-side .tx-pos, .tx-side .tx-neg { display: block; font-weight: 700; font-size: 14px; }
.tx-pos { color: #0e9f6e; } .tx-neg { color: #d92d20; }
.tx-meta { font-size: 11px; color: #aab2bd; }
.tx-empty { text-align: center; color: #aab2bd; padding: 30px 0; font-size: 13px; }

/* 备注框更醒目 */
.remark-label { font-size: 14px; font-weight: 600; color: #7a5c00; margin: 14px 0 6px; }
.remark-label small { font-weight: 400; color: #a08c5a; }
.remark-input {
  border: 2px solid #f0c93f !important; background: #fffdf2 !important;
  font-size: 15px !important; padding: 12px 14px !important; border-radius: 10px;
}
.remark-input:focus { outline: none !important; border-color: #e6a800 !important; box-shadow: 0 0 0 3px rgba(240,201,63,.25); }
.remark-input::placeholder { color: #c0a86a; }

/* 可放大图片手势提示 */
.img-chip img, img.thumb { cursor: zoom-in; }

/* 拖拽上传高亮 */
.photo-row.dragover .photo-btn { border-color: var(--primary); background: #e6edff; }
.photo-row.dragover .photo-btn.album { border-color: #0e9f6e; background: #e3f6ec; }
