:root {
  --primary: #1a6fb5; --primary-dark: #145a93; --bg: #f2f4f7; --card: #fff;
  --text: #1f2733; --muted: #8a94a6; --ok: #2e9e5b; --warn: #e08a00; --bad: #d8453b;
  --border: #e3e8ef; --radius: 12px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body { font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg); color: var(--text); font-size: 15px; line-height: 1.5;
  max-width: 520px; margin: 0 auto; padding-bottom: 70px; }

.app-header { position: sticky; top: 0; z-index: 20; background: var(--primary); color: #fff;
  padding: 12px 16px; display: flex; align-items: center; justify-content: space-between; box-shadow: 0 2px 8px rgba(0,0,0,.12); }
.app-header h1 { font-size: 16px; margin: 0; font-weight: 600; }
.app-header .me { font-size: 12px; opacity: .85; }

.tabs { display: flex; background: #fff; border-bottom: 1px solid var(--border); position: fixed; top: 46px; left: 50%; transform: translateX(-50%); width: 100%; max-width: 520px; z-index: 15; }
.tabs .tab { flex: 1; text-align: center; padding: 12px 0; font-size: 13px; color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent; position: relative; }
.tabs .tab.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }
.qbadge { position: absolute; top: 6px; right: 18px; background: var(--bad); color: #fff; font-size: 10px; border-radius: 10px; padding: 0 5px; }

.search { padding: 10px 12px; margin-top: 46px; }
.search input { width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; font-size: 14px; outline: none; }
.search input:focus { border-color: var(--primary); }

.list { padding: 0 12px; }
.card { background: var(--card); border-radius: var(--radius); padding: 14px; margin-bottom: 10px;
  box-shadow: 0 1px 3px rgba(0,0,0,.06); cursor: pointer; border: 1px solid var(--border); }
.card:active { background: #f7f9fc; }
.card .row1 { display: flex; justify-content: space-between; align-items: center; }
.card .cno { font-weight: 700; font-size: 15px; color: var(--primary); }
.card .cname { color: var(--text); margin: 4px 0; font-weight: 600; }
.card .cmeta { color: var(--muted); font-size: 13px; }
.badge { font-size: 12px; padding: 2px 8px; border-radius: 20px; color: #fff; white-space: nowrap; }
.badge.pending { background: var(--warn); }
.badge.accepted { background: var(--ok); }
.badge.partial { background: #c9a227; }
.badge.rework { background: var(--bad); }
.empty { text-align: center; color: var(--muted); padding: 40px 0; }

.detail { padding: 12px; }
.back { color: #fff; font-size: 14px; cursor: pointer; }
.section { background: #fff; border-radius: var(--radius); padding: 14px; margin-bottom: 12px; border: 1px solid var(--border); }
.section h3 { margin: 0 0 10px; font-size: 14px; color: var(--primary); border-left: 3px solid var(--primary); padding-left: 8px; }
.info-row { display: flex; justify-content: space-between; padding: 6px 0; border-bottom: 1px dashed var(--border); font-size: 13px; }
.info-row:last-child { border-bottom: none; }
.info-row .k { color: var(--muted); }
.info-row .v { color: var(--text); text-align: right; max-width: 65%; }
.door-code { font-size: 20px; font-weight: 800; color: var(--primary); letter-spacing: 1px; background: #eef5fb; padding: 10px; border-radius: 8px; text-align: center; margin-bottom: 10px; word-break: break-all; }

.node-row { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px dashed var(--border); }
.node-row:last-child { border-bottom: none; }
.node-row .nname { flex: 1; font-size: 14px; }
.node-row .nstat { font-size: 12px; padding: 2px 8px; border-radius: 20px; color: #fff; }
.nstat.todo { background: var(--muted); }
.nstat.pending { background: var(--warn); }
.nstat.approved { background: var(--ok); }
.nstat.rejected { background: var(--bad); }
.cam-btn { width: 46px; height: 46px; border-radius: 50%; background: var(--primary); color: #fff; border: none; font-size: 20px; cursor: pointer; flex-shrink: 0; }
.cam-btn:active { background: var(--primary-dark); }

.submit-bar { position: fixed; bottom: 0; left: 50%; transform: translateX(-50%); width: 100%; max-width: 520px; padding: 10px 12px; background: #fff; border-top: 1px solid var(--border); z-index: 30; }
.btn-primary { width: 100%; padding: 13px; background: var(--primary); color: #fff; border: none; border-radius: 10px; font-size: 16px; font-weight: 600; cursor: pointer; }
.btn-primary:active { background: var(--primary-dark); }

.login-mask { position: fixed; inset: 0; background: var(--primary); display: flex; flex-direction: column; align-items: center; justify-content: center; z-index: 100; color: #fff; padding: 24px; }
.login-mask .logo { font-size: 22px; font-weight: 700; margin-bottom: 6px; }
.login-mask .sub { opacity: .8; margin-bottom: 28px; font-size: 13px; }
.login-mask input { width: 100%; max-width: 300px; padding: 12px; border-radius: 10px; border: none; margin-bottom: 12px; font-size: 15px; }
.login-mask .btn { width: 100%; max-width: 300px; padding: 12px; border-radius: 10px; border: none; background: #fff; color: var(--primary); font-weight: 700; font-size: 15px; cursor: pointer; }
.login-mask .hint { margin-top: 14px; font-size: 12px; opacity: .7; }

.toast { position: fixed; bottom: 90px; left: 50%; transform: translateX(-50%); background: rgba(0,0,0,.82); color: #fff; padding: 10px 18px; border-radius: 22px; font-size: 14px; z-index: 200; opacity: 0; transition: opacity .25s; pointer-events: none; max-width: 80%; text-align: center; }
.toast.show { opacity: 1; }

.scan-box { text-align: center; padding: 20px 0; }
.scan-box input { width: 100%; padding: 12px; border: 1px solid var(--border); border-radius: 10px; font-size: 16px; text-align: center; letter-spacing: 1px; margin-bottom: 12px; }
.scan-box .cam-btn-big { width: 100%; padding: 14px; background: var(--primary); color: #fff; border: none; border-radius: 10px; font-size: 16px; font-weight: 600; cursor: pointer; }
.scan-box .cam-btn-big.wecom-scan { background: #07c160; margin-top: 10px; }
.scan-box .cam-btn-big.wecom-scan:active { background: #06ad56; }
.js-err { background: #fff3f3; border: 1px solid #ffb4b4; color: #c0392b; border-radius: 10px; padding: 10px 12px; font-size: 13px; line-height: 1.6; margin-bottom: 12px; }
.js-err b { color: #c0392b; }

.sub-card { background: #fff; border-radius: var(--radius); padding: 12px; margin-bottom: 10px; border: 1px solid var(--border); }
.sub-card .s-top { display: flex; justify-content: space-between; font-size: 13px; }
.sub-card .s-code { font-weight: 700; color: var(--primary); }
.sub-card .s-node { color: var(--text); }
.sub-card .s-meta { color: var(--muted); font-size: 12px; margin: 4px 0; }
.sub-card img { width: 100%; border-radius: 8px; margin-top: 6px; }
.sub-card .approve-actions { display: flex; gap: 8px; margin-top: 8px; }
.sub-card .approve-btn { flex: 1; padding: 10px; background: var(--ok); color: #fff; border: none; border-radius: 8px; font-size: 14px; font-weight: 600; cursor: pointer; }
.sub-card .reject-btn { flex: 1; padding: 10px; background: var(--bad); color: #fff; border: none; border-radius: 8px; font-size: 14px; font-weight: 600; cursor: pointer; }
.queue-tip { background: #fff7e6; color: #a86a00; font-size: 12px; padding: 8px 12px; border-radius: 8px; margin: 0 12px 10px; border: 1px solid #ffe1a8; }
.img-preview { width: 100%; border-radius: 8px; margin-top: 8px; }

/* 照片预览网格 */
.photo-preview-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin-top: 12px; }
.photo-preview-item { position: relative; background: #fff; border-radius: 10px; overflow: hidden; border: 1px solid var(--border); }
.photo-preview-item img { width: 100%; aspect-ratio: 1; object-fit: cover; cursor: pointer; }
.photo-preview-item .photo-node-name { padding: 6px 8px; font-size: 12px; color: var(--text); text-align: center; background: #f8f9fa; }
.photo-preview-item .remove-photo-btn { position: absolute; top: 4px; right: 4px; width: 24px; height: 24px; background: rgba(0,0,0,0.6); color: #fff; border: none; border-radius: 50%; font-size: 14px; cursor: pointer; display: flex; align-items: center; justify-content: center; }

/* 方案B：卡片翻转式布局 */
.progress-bar-section { background: #fff; border-radius: var(--radius); padding: 14px; margin-bottom: 14px; border: 1px solid var(--border); }
.progress-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.progress-header h3 { font-size: 14px; color: var(--primary); border-left: 3px solid var(--primary); padding-left: 8px; margin: 0; }
.progress-stats { font-size: 13px; color: var(--muted); }
.progress-stats .done { color: var(--ok); font-weight: 700; }
.progress-bar { height: 8px; background: var(--border); border-radius: 4px; overflow: hidden; }
.progress-fill { height: 100%; background: linear-gradient(90deg, var(--ok), #4caf50); border-radius: 4px; transition: width .3s; }

.card-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 14px; }
.node-card { background: #fff; border-radius: var(--radius); padding: 0; border: 2px solid var(--border); text-align: center; cursor: pointer; transition: all .15s; position: relative; overflow: hidden; aspect-ratio: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.node-card:active { transform: scale(0.97); }
.node-card.has-photo { border-color: var(--primary); }

/* 未拍摄状态：相机图标 + 灰色节点名 */
.card-placeholder { display: flex; flex-direction: column; align-items: center; justify-content: center; width: 100%; height: 100%; padding: 8px; }
.card-camera-icon { font-size: 28px; color: #b0b8c4; margin-bottom: 6px; }
.card-name-placeholder { font-size: 11px; color: #9aa3b0; line-height: 1.3; word-break: break-all; }

/* 已拍摄状态：图片铺满 + 右上角删除 */
.card-photo-wrap { position: relative; width: 100%; height: 100%; }
.card-photo-wrap img { width: 100%; height: 100%; object-fit: cover; display: block; }
.card-photo-label { position: absolute; bottom: 0; left: 0; right: 0; background: linear-gradient(transparent, rgba(0,0,0,0.55)); color: #fff; font-size: 10px; padding: 12px 4px 4px; text-align: center; line-height: 1.2; }
.card-delete-btn { position: absolute; top: 4px; right: 4px; width: 22px; height: 22px; background: rgba(0,0,0,0.55); color: #fff; border: none; border-radius: 50%; font-size: 13px; cursor: pointer; display: flex; align-items: center; justify-content: center; line-height: 1; z-index: 2; }
.card-delete-btn:active { background: rgba(216,69,59,0.9); }

/* 状态角标（已拍摄后隐藏） */
.card-badge { position: absolute; top: 8px; right: 8px; font-size: 10px; padding: 2px 6px; border-radius: 8px; color: #fff; font-weight: 600; }
.card-badge.todo { background: var(--muted); }
.card-badge.pending { background: var(--warn); }
.card-badge.approved { background: var(--ok); }
.card-badge.rejected { background: var(--bad); }

/* 兼容旧样式（保留但不再主用） */
.card-icon { display: none; }
.card-name { display: none; }
.card-photos { display: none; }

/* 固定返回按钮 */
.sticky-header {
  position: sticky;
  top: 0;
  background: #fff;
  z-index: 100;
  padding: 12px 16px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.cat-back {
  color: #1890ff;
  font-size: 14px;
  cursor: pointer;
  margin-bottom: 8px;
}

/* 触摸滑动返回区域 */
.swipe-back-area {
  position: fixed;
  left: 0;
  top: 0;
  width: 30px;
  height: 100%;
  z-index: 999;
  background: transparent;
}

/* 项目明细卡片 */
.door-card { background: #fff; border-radius: var(--radius); padding: 14px; margin-bottom: 12px; border: 1px solid var(--border); }
.door-card .door-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.door-card .door-code { font-size: 16px; font-weight: 700; color: var(--primary); margin: 0; padding: 0; background: none; text-align: left; }
.door-progress-text { font-size: 13px; color: var(--muted); }
.door-info-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.door-card .door-info { color: var(--muted); font-size: 13px; flex: 1; }
.go-photo-mini { padding: 6px 12px; background: var(--primary); color: #fff; border: none; border-radius: 6px; font-size: 14px; cursor: pointer; margin-left: 8px; }
.go-photo-mini:active { background: var(--primary-dark); }
.go-photo-btn { display: block; width: 100%; margin-top: 10px; padding: 10px; background: var(--primary); color: #fff; border: none; border-radius: 8px; font-size: 14px; font-weight: 600; cursor: pointer; text-align: center; }
.go-photo-btn:active { background: var(--primary-dark); }
.door-actions { margin-top: 8px; }
.door-card .progress-bar { height: 6px; background: var(--border); border-radius: 3px; overflow: hidden; margin-bottom: 10px; }
.door-card .progress-fill { height: 100%; background: var(--ok); border-radius: 3px; transition: width .3s; }
.node-grid-2col { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 12px; }
.node-item { font-size: 13px; padding: 10px 12px; background: #f5f5f5; border-radius: 6px; display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.node-item.approved { background: #d4edda; }
.node-item.pending { background: #fff3cd; }
.node-item.todo { background: #f5f5f5; }
.node-status { font-size: 14px; font-weight: 600; flex-shrink: 0; }
.node-item.approved .node-status { color: #155724; }
.node-item.pending .node-status { color: #856404; }
.node-item.todo .node-status { color: #999; }
.node-label { font-size: 13px; color: #333; flex: 1; text-align: right; }

/* 照片预览弹窗 */
.photo-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.9); z-index: 300; display: flex; align-items: center; justify-content: center; flex-direction: column; }
.photo-overlay .photo-zoom-container { max-width: 95%; max-height: 80vh; overflow: hidden; display: flex; align-items: center; justify-content: center; }
.photo-overlay img { max-width: 100%; max-height: 80vh; border-radius: 8px; transition: transform 0.2s; }
.photo-overlay .close-btn { position: absolute; top: 16px; right: 16px; width: 40px; height: 40px; background: rgba(255,255,255,.2); color: #fff; border: none; border-radius: 50%; font-size: 20px; cursor: pointer; }
.photo-overlay .zoom-controls { margin-top: 16px; display: flex; gap: 12px; }
.photo-overlay .zoom-controls button { width: 44px; height: 44px; background: rgba(255,255,255,.2); color: #fff; border: none; border-radius: 8px; font-size: 20px; font-weight: bold; cursor: pointer; }
.photo-overlay .zoom-controls button:active { background: rgba(255,255,255,.4); }

/* Phase 2: Category cards */
.category-card { background: #fff; border-radius: var(--radius); padding: 14px; margin-bottom: 10px; border: 1px solid var(--border); cursor: pointer; transition: all .15s; }
.category-card:active { transform: scale(0.98); background: #f8f9fa; }
.cat-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.cat-name { font-size: 15px; font-weight: 600; color: var(--text); }
.cat-count { font-size: 13px; color: var(--muted); }
.cat-progress-text { font-size: 12px; color: var(--muted); margin-top: 6px; }
.cat-back { display: inline-block; color: var(--primary); font-size: 14px; cursor: pointer; margin-bottom: 10px; padding: 4px 0; }
.cat-back:active { opacity: 0.7; }

/* Phase 3: Transition overlay */
.transition-overlay { position: fixed; inset: 0; background: rgba(26, 111, 181, 0.95); z-index: 500; display: flex; align-items: center; justify-content: center; animation: fadeIn .3s; }
.transition-content { text-align: center; color: #fff; }
.transition-icon { font-size: 64px; margin-bottom: 20px; animation: bounce 1s infinite; }
.transition-title { font-size: 20px; font-weight: 600; margin-bottom: 10px; }
.transition-hint { font-size: 14px; opacity: 0.9; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes bounce { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-10px); } }

/* Phase 4: Photo delete button */
.photo-thumb-wrap { position: relative; display: inline-block; width: 100%; }
.photo-delete-btn { position: absolute; top: 4px; right: 4px; width: 20px; height: 20px; background: rgba(216, 69, 59, 0.85); color: #fff; border: none; border-radius: 50%; font-size: 12px; cursor: pointer; display: flex; align-items: center; justify-content: center; line-height: 1; z-index: 2; }
.photo-delete-btn:active { background: rgba(216, 69, 59, 1); transform: scale(0.9); }
