:root {
  /* Design Spec v3 · 令牌一处定义（Q1-Q7 拍板后） */
  /* 中性 ink 阶梯 */
  --ink-900: #1d1d1f;
  --ink-700: #424245;
  --ink-500: #6e6e73;
  --ink-300: #aeaeb2;
  /* 表面 */
  --surface-0: #ffffff;
  --surface-1: #fbfbfd;
  --surface-2: #ebebed;
  /* 描边 */
  --line-1: #e5e5e7;
  --line-2: #d2d2d7;
  /* 交互色（D2：全站唯一交互色） */
  --accent-600: #0066cc;
  --accent-700: #004f9e;
  --accent-100: #e8f1fb;
  --accent-dark: #4da3ff;   /* 深色预留；Q6：P0/P1 不上线 */
  /* 语义色 */
  --danger-700: #b3261e;
  --danger-100: #fce8e6;
  --success-700: #1e7a3c;
  --success-100: #e6f4ea;
  --warning-700: #8a5a00;
  --warning-100: #fff4e5;
  /* 字阶（Q1：最小 13px，无例外） */
  --fs-caption: 13px;
  --fs-label: 14px;
  --fs-body: 16px;
  --fs-h1: 22px;
  --fs-display: 28px;
  /* 4px 空间阶梯 */
  --sp-1: 4px;  --sp-2: 8px;  --sp-3: 12px; --sp-4: 16px;
  --sp-5: 20px; --sp-6: 24px; --sp-8: 32px; --sp-10: 40px; --sp-12: 48px;
  /* 圆角 */
  --r-sm: 6px; --r-md: 10px; --r-lg: 14px; --r-xl: 20px;
  /* 层级 2 阴影：仅浮层与底栏（D6） */
  --shadow-2: 0 4px 16px rgba(0, 0, 0, .08);
  /* 动效 */
  --dur-instant: 100ms;
  --dur-normal: 200ms;
  --dur-slow: 280ms;
  --ease: cubic-bezier(0.2, 0, 0, 1);
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--surface-0);
  color: var(--ink-900);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  padding-bottom: calc(72px + env(safe-area-inset-bottom, 0px));
}

img { max-width: 100%; }
a { color: var(--accent-600); text-decoration: none; }
button, input, textarea, select { font-family: inherit; -webkit-tap-highlight-color: transparent; }
input::placeholder, textarea::placeholder { color: var(--ink-500); opacity: 1; }
input, textarea, select { font-size: 16px; }
[hidden] { display: none !important; }

button:focus-visible, a:focus-visible, input:focus-visible,
textarea:focus-visible, select:focus-visible {
  outline: 2px solid var(--accent-600);
  outline-offset: 2px;
}

/* ---------- layout ---------- */
.app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
}

/* 控制台：左右两栏各自独立滚动，页面本身不滚 */
.app-split {
  min-height: 0;                 /* 覆盖 .app 的 min-height:100dvh */
  height: 100vh;
  height: calc(100dvh - 72px - env(safe-area-inset-bottom, 0px));
  overflow: hidden;
}
.app-split .split { overflow: hidden; }
.app-split .pane {
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 52px;
  padding: 0 16px;
  padding-top: env(safe-area-inset-top, 0px);
  background: var(--surface-0);
  border-bottom: 1px solid var(--line-1);
}

.brand {
  margin-right: auto;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -.01em;
  white-space: nowrap;
}

.nav { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }

.nav-item {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0 12px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--ink-500);
  font-size: 13px;
  white-space: nowrap;
  cursor: pointer;
}
.nav-item:hover { background: var(--surface-1); color: var(--ink-900); }
.nav-item.active { background: var(--surface-1); color: var(--ink-900); font-weight: 600; }

.split {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
}

.pane { min-width: 0; }
.pane-list { border-right: 1px solid var(--line-1); }
.pane-detail { padding: 24px 28px; }

.bottombar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px));
  background: var(--surface-0);
  border-top: 1px solid var(--line-1);
}
.bottombar .btn { flex: 1; }

.safe-bottom {
  height: env(safe-area-inset-bottom, 0px);
  flex-shrink: 0;
}

/* ---------- buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 44px;
  padding: 0 16px;
  border: 1px solid transparent;
  border-radius: var(--r-md);
  background: transparent;
  color: var(--ink-900);
  font-size: 14px;
  font-weight: 500;
  line-height: 1;
  white-space: nowrap;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
}
.btn:hover { opacity: .85; }
.btn:active { opacity: .7; }
.btn:disabled { opacity: .4; cursor: default; }

.btn-primary { background: var(--accent-600); border-color: var(--accent-600); color: var(--surface-0); }

.btn-ghost { background: var(--surface-0); border-color: var(--line-1); color: var(--ink-900); }
.btn-ghost:hover { background: var(--surface-1); opacity: 1; }

.btn-icon { width: 44px; min-width: 44px; padding: 0; font-size: 18px; }

/* ---------- list ---------- */
.list { display: flex; flex-direction: column; }

.list-item {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 2px;
  min-height: 56px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--line-1);
  border-left: 3px solid transparent;
  cursor: pointer;
}
.list-item:hover { background: var(--surface-1); }
.list-item.active { background: var(--surface-1); border-left-color: var(--accent-600); }

.list-title {
  font-size: 14px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.list-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: var(--fs-caption);
  color: var(--ink-500);
}

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: var(--fs-caption);
  font-weight: 600;
  line-height: 1.6;
  white-space: nowrap;
}
.badge-draft { background: var(--surface-2); color: var(--ink-500); }
.badge-submitted { background: var(--accent-100); color: var(--accent-600); }
.badge-approved { background: var(--success-100); color: var(--success-700); }

/* ---------- sheet ---------- */
.sheet-tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--line-1);
  margin-bottom: 20px;
}

.sheet-tab {
  min-height: 44px;
  padding: 0 18px;
  border: 0;
  border-bottom: 2px solid transparent;
  background: transparent;
  color: var(--ink-500);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
}
.sheet-tab.active { color: var(--ink-900); border-bottom-color: var(--accent-600); }

.sheet-panel { padding-bottom: 8px; }

/* ---------- form ---------- */
.section { padding: 20px 0; border-bottom: 1px solid var(--line-1); }
.section:last-child { border-bottom: 0; }

.section-title {
  margin: 0 0 14px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: .01em;
}

.grid { display: grid; gap: 14px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }

.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }

.field-label { font-size: var(--fs-caption); font-weight: 500; color: var(--ink-500); }

.field-input,
.field-textarea,
.login-input,
.dt-cell input {
  width: 100%;
  border: 1px solid var(--line-1);
  border-radius: var(--r-md);
  background: var(--surface-0);
  color: var(--ink-900);
  font-size: 16px;
  outline: none;
  -webkit-appearance: none;
  appearance: none;
}

.field-input, .login-input, .dt-cell input { height: 44px; padding: 0 12px; }

.field-textarea {
  min-height: 88px;
  padding: 10px 12px;
  line-height: 1.5;
  resize: vertical;
}

.field-input:focus {
  border-color: var(--accent-600);
}
.field-textarea:focus,
.login-input:focus,
.dt-cell input:focus {
  border-color: var(--accent-600);
}

/* ---------- detail table ---------- */
.dt {
  width: 100%;
  margin: 10px 0;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border: 1px solid var(--line-1);
  border-radius: var(--r-md);
}

.dt-head, .dt-row {
  display: flex;
  width: max-content;
  min-width: 100%;
}

.dt-head { background: var(--surface-1); }
.dt-row { border-top: 1px solid var(--line-1); }

.dt-cell {
  flex: 1 0 140px;
  min-width: 140px;
  min-height: 44px;
  padding: 8px 10px;
  border-right: 1px solid var(--line-1);
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
}
.dt-cell:last-child { border-right: 0; }
.dt-head .dt-cell { font-size: var(--fs-caption); font-weight: 600; color: var(--ink-500); }

.dt-cell input { flex: 1; min-width: 0; }

.dt-no {
  flex: 0 0 56px;
  min-width: 56px;
  justify-content: center;
  color: var(--ink-500);
  font-variant-numeric: tabular-nums;
}

.dt-add {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 44px;
  border: 0;
  border-top: 1px solid var(--line-1);
  background: var(--surface-1);
  color: var(--accent-600);
  font-size: 14px;
  cursor: pointer;
}
.dt-add:hover { background: var(--surface-2); }

.dt-del {
  flex: 0 0 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  min-height: 44px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--ink-500);
  font-size: 16px;
  cursor: pointer;
}
.dt-del:hover { color: var(--danger-700); background: var(--danger-100); }

/* ---------- photos ---------- */
.photos { padding: 4px 0 8px; }

.photo-dim { position: relative; padding: 16px 0 20px; border-bottom: 1px solid var(--line-1); }
.photo-dim:last-child { border-bottom: 0; }

.photo-dim-title { margin: 0 0 12px; font-size: 13px; font-weight: 600; }

.photo-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.photo-tile {
  position: relative;
  aspect-ratio: 1 / 1;
  min-height: 96px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line-1);
  border-radius: var(--r-md);
  background: var(--surface-1);
  overflow: hidden;
}

.photo-tile img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.photo-add {
  aspect-ratio: 1 / 1;
  min-height: 96px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px dashed var(--line-1);
  border-radius: var(--r-md);
  background: var(--surface-1);
  color: var(--accent-600);
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
}
.photo-add:hover { background: var(--surface-2); }

.photo-del {
  position: absolute;
  top: 0;
  right: 0;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-left: 1px solid var(--line-1);
  border-bottom: 1px solid var(--line-1);
  border-radius: 0 var(--r-md) 0 0;
  background: var(--surface-0);
  color: var(--danger-700);
  font-size: 16px;
  cursor: pointer;
}

/* ---------- sign ---------- */
.sign { padding: 4px 0; }

.sign-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.sign-box {
  position: relative;
  aspect-ratio: 3 / 2;
  min-height: 120px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px dashed var(--line-1);
  border-radius: var(--r-md);
  background: var(--surface-1);
  overflow: hidden;
  cursor: pointer;
}

.sign-img { display: block; width: 100%; height: 100%; object-fit: contain; }

.sign-pad {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  flex-direction: column;
  padding-top: env(safe-area-inset-top, 0px);
  background: var(--surface-0);
}

.sign-pad canvas {
  flex: 1;
  min-height: 0;
  display: block;
  width: 100%;
  border: 1px solid var(--line-1);
  background: var(--surface-0);
  touch-action: none;
}

.sign-actions {
  display: flex;
  gap: 12px;
  padding: 12px 16px;
  padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid var(--line-1);
}
.sign-actions .btn { flex: 1; }

/* ---------- history ---------- */
.history { border: 1px solid var(--line-1); border-radius: var(--r-md); overflow: hidden; }

.history-item {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 48px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line-1);
  border-left: 3px solid transparent;
  font-size: 13px;
  cursor: pointer;
}
.history-item:last-child { border-bottom: 0; }
.history-item:hover { background: var(--surface-1); }
.history-item.active {
  background: var(--surface-1);
  border-left-color: var(--accent-600);
  font-weight: 600;
}

.diff {
  margin-top: 12px;
  border: 1px solid var(--line-1);
  border-radius: var(--r-md);
  overflow: hidden;
}

.diff-row {
  display: grid;
  grid-template-columns: minmax(90px, 1.2fr) minmax(0, 1fr) 24px minmax(0, 1fr);
  gap: 8px;
  align-items: start;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line-1);
  font-size: 13px;
}
.diff-row:last-child { border-bottom: 0; }

.diff-path { font-size: var(--fs-caption); font-weight: 600; word-break: break-all; }
.diff-before {
  padding: 2px 6px;
  border-radius: 6px;
  background: var(--danger-100);
  color: var(--ink-500);
  text-decoration: line-through;
  word-break: break-all;
}
.diff-after {
  padding: 2px 6px;
  border-radius: 6px;
  background: var(--success-100);
  color: var(--success-700);
  word-break: break-all;
}
.diff-arrow { color: var(--ink-500); text-align: center; }

/* ---------- preview ---------- */
.preview { max-width: none; width: 100%; margin: 0; padding: 28px 24px 40px; }

.preview-title {
  margin: 0 0 24px;
  font-size: 20px;
  font-weight: 600;
  letter-spacing: .04em;
  text-align: center;
}

.preview-table { width: 100%; margin: 12px 0; border-collapse: collapse; font-size: 13px; }
.preview-table th, .preview-table td {
  padding: 8px 10px;
  border: 1px solid var(--line-1);
  text-align: left;
  vertical-align: top;
  word-break: break-word;
}
.preview-table th { background: var(--surface-1); font-weight: 600; color: var(--ink-500); }

.preview-photos {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin: 12px 0;
}
.preview-photos img {
  width: 100%;
  aspect-ratio: 1 / 1;
  min-height: 96px;
  object-fit: contain;
  border: 1px solid var(--line-1);
  border-radius: var(--r-md);
  background: var(--surface-1);
}

.preview-sign { display: flex; gap: 14px; margin: 12px 0; }
.preview-sign img {
  width: 50%;
  max-width: 240px;
  height: 120px;
  object-fit: contain;
  border: 1px solid var(--line-1);
  border-radius: var(--r-md);
  background: var(--surface-1);
}

/* ---------- login ---------- */
.login {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: var(--surface-1);
}

.login-card {
  width: 100%;
  max-width: 360px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 32px 28px;
  border: 1px solid var(--line-1);
  border-radius: var(--r-md);
  background: var(--surface-0);
}

.login-input { height: 48px; padding: 0 14px; }

.login-btn {
  width: 100%;
  height: 48px;
  border: 0;
  border-radius: var(--r-md);
  background: var(--accent-600);
  color: var(--surface-0);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}
.login-btn:hover { opacity: .9; }

.login-alt {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  margin-top: 4px;
  padding-top: 14px;
  border: 0;
  border-top: 1px solid var(--line-1);
  background: transparent;
  color: var(--accent-600);
  font-size: 14px;
  cursor: pointer;
}

/* ---------- misc ---------- */
.empty { padding: 56px 16px; text-align: center; color: var(--ink-500); font-size: 14px; }

.status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 4px 10px;
  border: 1px solid var(--line-1);
  border-radius: 999px;
  color: var(--ink-500);
  font-size: var(--fs-caption);
}

.divider { height: 1px; margin: 16px 0; border: 0; background: var(--line-1); }

.spinner {
  width: 18px;
  height: 18px;
  border: 2px solid var(--line-1);
  border-top-color: var(--accent-600);
  border-radius: 50%;
  animation: qc-spin .7s linear infinite;
}
@keyframes qc-spin { to { transform: rotate(360deg); } }

/* ---------- <=768px : single column, sidebar collapses, JS toggles panes ---------- */
@media (max-width: 768px) {
  .topbar { gap: 8px; padding-left: 12px; padding-right: 12px; }
  .brand { font-size: 14px; }
  .nav { gap: 2px; }
  .nav-item { padding: 0 10px; }

  .split { display: block; }
  .pane { width: 100%; }
  .app-split { height: auto; min-height: 100dvh; overflow: visible; }
  .app-split .split { overflow: visible; }
  .app-split .pane { overflow: visible; }
  .pane-list { border-right: 0; border-bottom: 1px solid var(--line-1); }
  .pane-detail { padding: 16px; }

  .grid-2, .grid-3 { grid-template-columns: minmax(0, 1fr); }
  .section { padding: 16px 0; }

  .photo-grid, .preview-photos { grid-template-columns: repeat(2, minmax(0, 1fr)); }

  .sign-row { grid-template-columns: minmax(0, 1fr); }

  .diff-row { grid-template-columns: minmax(0, 1fr); gap: 6px; }
  .diff-arrow { display: none; }

  .preview { padding: 20px 16px 32px; }
  .preview-title { font-size: 18px; }
  .preview-sign { flex-direction: column; }
  .preview-sign img { width: 100%; max-width: none; }

  .login { padding: 16px; }
  .login-card { padding: 28px 20px; }
}

@media (prefers-reduced-motion: reduce) {
  .spinner { animation-duration: 2s; }
}

/* ================================================================== *
 * 个人中心首页（登录后第一屏）
 * ================================================================== */
.home-body{
  width:100%;max-width:none;margin:0;
  padding:20px 16px calc(40px + env(safe-area-inset-bottom, 0px));
}
.top-id{font-size:16px;color:var(--ink-500);font-variant-numeric:tabular-nums}
.me{
  display:flex;align-items:center;gap:16px;background:var(--surface-0);
  border:1px solid var(--line-1);border-radius:18px;padding:22px;margin-bottom:16px;
}
.me-avatar{
  width:62px;height:62px;border-radius:31px;background:var(--ink-900);color:var(--surface-0);
  font-size:26px;font-weight:600;display:flex;align-items:center;justify-content:center;flex:none;
}
.me-name{font-size:23px;font-weight:700;line-height:1.3}
.me-sub{font-size:16px;color:var(--ink-500);margin-top:4px}
.stats{display:grid;grid-template-columns:repeat(3,1fr);gap:12px;margin-bottom:22px}
.stat{background:var(--surface-0);border:1px solid var(--line-1);border-radius:16px;padding:18px 10px;text-align:center}
.stat-n{font-size:30px;font-weight:700;line-height:1.1;font-variant-numeric:tabular-nums}
.stat-l{font-size:14px;color:var(--ink-500);margin-top:6px}
.zone{margin-bottom:22px}
.zone-t{font-size:15px;font-weight:600;color:var(--ink-500);letter-spacing:1.2px;margin:0 4px 12px}
.fn-grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(220px,1fr));gap:12px}
.fn{
  background:var(--surface-0);border:1px solid var(--line-1);border-radius:16px;padding:18px;
  text-align:left;min-height:104px;display:flex;flex-direction:column;justify-content:space-between;
  font-family:inherit;cursor:pointer;position:relative;color:var(--ink-900);
}
.fn:active{background:var(--surface-1)}
.fn-i{font-size:28px;line-height:1}
.fn-t{font-size:18px;font-weight:600;margin-top:12px}
.fn-c{position:absolute;right:16px;top:16px;font-size:15px;color:var(--ink-500);font-variant-numeric:tabular-nums}

/* ================================================================== *
 * 六步分步填写
 * ================================================================== */
.app-flow{
  height:100vh;height:100dvh;min-height:0;overflow:hidden;
}
.app-flow .flow-body{
  flex:1;min-height:0;overflow-y:auto;-webkit-overflow-scrolling:touch;
  overscroll-behavior:contain;
  padding:20px 16px calc(96px + env(safe-area-inset-bottom, 0px));
  max-width:none;width:100%;margin:0;
}
.app-flow .safe-bottom{display:none}

.flow-steps{
  flex:none;display:flex;gap:8px;overflow-x:auto;scrollbar-width:none;
  padding:10px 16px;background:var(--surface-0);border-bottom:1px solid var(--line-1);
}
.flow-steps::-webkit-scrollbar{display:none}
.flow-step{
  flex:none;display:flex;align-items:center;gap:6px;height:40px;padding:0 14px;
  border-radius:20px;border:1px solid var(--line-1);background:var(--surface-0);color:var(--ink-500);
  font-family:inherit;font-size:16px;font-weight:600;cursor:pointer;
}
.flow-step.on{background:var(--ink-900);color:var(--surface-0);border-color:var(--ink-900)}
.flow-step-n{
  display:inline-flex;align-items:center;justify-content:center;
  width:22px;height:22px;border-radius:11px;background:var(--surface-1);
  font-size:13px;color:var(--ink-500);
}
.flow-step.on .flow-step-n{background:var(--accent-700);color:var(--surface-0)}

.flow-title{
  display:flex;align-items:center;gap:12px;font-size:25px;font-weight:700;
  margin:0 4px 20px;
}
.flow-no{
  display:inline-flex;align-items:center;justify-content:center;
  width:34px;height:34px;border-radius:17px;background:var(--ink-900);color:var(--surface-0);font-size:18px;
}
.card{
  background:var(--surface-0);border:1px solid var(--line-1);border-radius:18px;
  padding:20px;margin-bottom:16px;
}
.card-h{font-size:15px;font-weight:600;color:var(--ink-500);letter-spacing:1px;margin-bottom:16px}
.card-table{overflow-x:auto}
.card-list{display:grid;gap:14px}
.check{display:flex;flex-direction:column;gap:6px}

.flow-bar{gap:10px}
.flow-meta{flex:1;min-width:0;display:flex;flex-direction:column;gap:2px}
.flow-meta .nav{display:flex;gap:8px}
.flow-prev,.flow-next{
  flex:none;height:48px;min-width:100px;padding:0 18px;border-radius:14px;
  font-size:16px;font-weight:600;font-family:inherit;cursor:pointer;
}
.flow-prev{border:1px solid var(--line-1);background:var(--surface-0);color:var(--ink-900)}
.flow-next{border:0;background:var(--ink-900);color:var(--surface-0)}
.flow-next[data-stepbtn="save"]{background:var(--accent-600)}

/* 照片维度分组 */
.photo-block{font-size:15px;font-weight:600;color:var(--ink-500);margin:8px 0 12px}
.photo-group{display:grid;grid-template-columns:1fr 1fr;gap:14px;align-items:start}
.photo-group .photo-dim{
  border:1px solid var(--line-1);border-radius:16px;padding:16px;
}
.photo-group .photo-dim:last-child{border-bottom:1px solid var(--line-1)}

/* ================================================================== *
 * 移动端：字大、点击区大
 * ================================================================== */
@media (max-width: 768px){
  .flow-body{padding-left:14px;padding-right:14px}
  .flow-step{height:44px;font-size:16px}
  .flow-prev,.flow-next{height: 48px;min-width:96px;font-size:17px}
  .field-label{font-size:15px}
  .field-input,.field-textarea,.dt-cell input,.login-input{font-size:17px}
  .field-input,.login-input,.dt-cell input{height: 48px}
  .field-textarea{min-height:110px}
  .card-h{font-size:16px}
  .dt-head .dt-cell{font-size:14px}
  .photo-dim-title{font-size:16px}
  .photo-group{grid-template-columns:minmax(0,1fr)}
  .photo-add{min-height: 48px}
  .flow-title{font-size:25px}
}

/* 疵点下拉：中英选项 + 「其他」手填 */
.defect-cell{display:flex;flex-direction:column;gap:6px}
.defect-cell select.field-input{height:auto;min-height: 48px;padding:8px 12px;font-size:15px;line-height:1.35}
.defect-cell .defect-other{min-height: 48px}

/* 疵点表：描述列加宽以容纳「中文 / English」选项 */
.dt[data-table="defects"] .dt-cell:nth-child(2){flex:2 0 240px;min-width:240px}

/* ===== UAT-16 移动端排版修复（追加覆盖，置于全部规则之后） ===== */
@media (max-width: 768px) {
  /* F-M1：顶部工具条允许折行，预览页 7 个按钮全部可见可达，不再撑动整页 */
  .topbar { flex-wrap: wrap; height: auto; min-height: 52px; padding-top: 8px; padding-bottom: 8px; }
  .topbar .btn { min-height: 44px; padding: 0 10px; font-size: 13px; }
  /* F-M3：取消疵点描述列 240px 硬宽度，收窄其余列；.dt 保留 overflow-x:auto 横滑 */
  .dt[data-table="defects"] .dt-cell:nth-child(2) { flex: 0 0 290px; min-width: 290px; }
  .dt-cell { min-width: 100px; }
  /* 疵点下拉保持 16px（≥16px 不触发 iOS 自动缩放），使 290px 列内中英对照可读 */
  .defect-cell select.field-input { font-size: 16px; }
  /* F-M2：步骤条保留可见的横滑提示（运行时 switchStep 会自动居中当前步） */
  .flow-steps { scrollbar-width: thin; }
  .flow-steps::-webkit-scrollbar { display: block; height: 3px; }
  .flow-steps::-webkit-scrollbar-thumb { background: var(--line-1); border-radius: 3px; }
}


/* ================================================================== *
 * Design Spec P0 落地层（Q1-Q7 拍板后；置于全部规则之后统一覆盖值）
 * 结构性改动见上方：令牌一处定义、旧令牌收敛、颜色去硬编码、去毛玻璃
 * ================================================================== */

/* ---- 全局 ---- */
body { padding-bottom: calc(72px + env(safe-area-inset-bottom, 0px)); }
a { color: var(--accent-600); }
button:focus-visible, a:focus-visible, input:focus-visible,
textarea:focus-visible, select:focus-visible {
  outline: 2px solid var(--accent-600); outline-offset: 2px;
}
.list-item:focus-visible, .history-item:focus-visible, .fn:focus-visible {
  outline: 2px solid var(--accent-600); outline-offset: -2px;
}

/* ---- 顶栏 / 分栏 ---- */
.topbar { min-height: 56px; background: var(--surface-0); border-bottom: 1px solid var(--line-1); }
.brand { font-size: var(--fs-label); }
.nav { gap: var(--sp-2); }
.nav-item { min-height: 48px; border-radius: var(--r-sm); font-size: var(--fs-caption); }
.split { grid-template-columns: 360px minmax(0, 1fr); }

/* ---- 底栏（§6.7 / Q4：左右各 50%，间距 12，层级 2 阴影） ---- */
.bottombar {
  min-height: 72px; gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  padding-bottom: calc(var(--sp-3) + env(safe-area-inset-bottom, 0px));
  background: var(--surface-0); border-top: 1px solid var(--line-1);
  box-shadow: var(--shadow-2);
}
.bottombar .btn { flex: 1; }

/* ---- 按钮（§6.1 / D8 / Q3：48px、16/600、底色反馈） ---- */
.btn {
  min-height: 48px; padding: 0 var(--sp-4);
  border-radius: var(--r-md);
  font-size: var(--fs-body); font-weight: 600;
  transition: background-color var(--dur-instant) var(--ease),
              border-color var(--dur-instant) var(--ease),
              transform var(--dur-instant) var(--ease);
}
.btn:hover { background: var(--surface-2); }
.btn:active { background: var(--surface-2); transform: scale(.98); }
.btn:disabled { color: var(--ink-300); background: transparent; cursor: default; }
.btn-primary { background: var(--accent-600); border-color: var(--accent-600); color: var(--surface-0); }
.btn-primary:hover { background: var(--accent-700); border-color: var(--accent-700); }
.btn-primary:active { background: var(--accent-700); border-color: var(--accent-700); }
.btn-ghost { background: var(--surface-0); border-color: var(--line-2); color: var(--ink-900); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-icon { width: 48px; min-width: 48px; font-size: var(--fs-body); }

/* ---- 列表 / 徽章（§6.5 / D5：颜色 + 图标 + 文字，13px） ---- */
.list-item { min-height: 56px; gap: var(--sp-1); padding: var(--sp-3) var(--sp-4); }
.list-meta { font-size: var(--fs-caption); }
.list-title { font-size: var(--fs-label); }
.badge {
  gap: var(--sp-1); padding: 2px var(--sp-2);
  border-radius: var(--r-sm); font-size: var(--fs-caption); font-weight: 600;
}
.badge svg { width: 14px; height: 14px; flex: none; stroke-width: 1.5; }
.badge-draft     { background: var(--surface-2);   color: var(--ink-700); }
.badge-submitted { background: var(--accent-100);  color: var(--accent-700); }
.badge-approved  { background: var(--success-100); color: var(--success-700); }
.badge-error     { background: var(--danger-100);  color: var(--danger-700); }
.status { border-radius: var(--r-sm); font-size: var(--fs-caption); }

/* ---- 表单（§6.2：surface-1 底、line-2 描边、48 高、聚焦 2px） ---- */
.section { padding: var(--sp-5) 0; }
.section-title { margin: 0 0 var(--sp-4); font-size: var(--fs-caption); font-weight: 600; color: var(--ink-700); }
.grid { gap: var(--sp-4); }
.field { gap: var(--sp-2); }
.field-label { font-size: var(--fs-label); font-weight: 500; color: var(--ink-700); }
.field-input, .field-textarea, .login-input, .dt-cell input {
  border: 1px solid var(--line-2); border-radius: var(--r-md);
  background: var(--surface-1); color: var(--ink-900); font-size: var(--fs-body);
}
.field-input, .login-input, .dt-cell input { height: 48px; padding: 0 var(--sp-3); }
.field-textarea { min-height: 88px; padding: var(--sp-3); }
.field-input:hover, .field-textarea:hover, .login-input:hover, .dt-cell input:hover {
  border-color: var(--ink-300);
}
.field-input:focus, .field-textarea:focus, .login-input:focus, .dt-cell input:focus {
  border-color: var(--accent-600); border-width: 2px; box-shadow: none;
}
.field-input:disabled, .field-textarea:disabled, .login-input:disabled, .dt-cell input:disabled {
  background: var(--surface-2); color: var(--ink-300);
}
.sheet-tab { min-height: 48px; font-size: var(--fs-label); }

/* ---- 明细表（§6.8） ---- */
.dt { border-radius: var(--r-md); }
.dt-cell { min-height: 48px; padding: var(--sp-2) var(--sp-3); gap: var(--sp-2); font-size: var(--fs-caption); }
.dt-head .dt-cell { font-size: var(--fs-caption); font-weight: 600; color: var(--ink-700); }
.dt-no { justify-content: flex-end; text-align: right; font-variant-numeric: tabular-nums; }
.dt-cell input { text-align: right; font-variant-numeric: tabular-nums; }
.dt-head > .dt-cell:first-child, .dt-row > .dt-cell:first-child {
  position: sticky; left: 0; z-index: 1; background: var(--surface-0);
}
.dt-add { min-height: 48px; font-size: var(--fs-label); }
.dt-add:hover { background: var(--surface-2); }
.dt-del { min-height: 48px; border-radius: var(--r-sm); }
.dt-del:hover { color: var(--danger-700); background: var(--danger-100); }

/* ---- 卡片 / 照片 / 签字 ---- */
.card { background: var(--surface-0); border: 1px solid var(--line-1); border-radius: var(--r-lg); padding: var(--sp-5); margin-bottom: var(--sp-4); }
.card-h { font-size: var(--fs-body); font-weight: 600; color: var(--ink-700); margin-bottom: var(--sp-4); }
.photo-grid { gap: var(--sp-3); }
.photo-tile, .photo-add { border-radius: var(--r-md); }
.photo-add:hover { background: var(--surface-2); }
.photo-del { background: var(--surface-0); color: var(--danger-700); }
.photo-dim-title { font-size: var(--fs-caption); font-weight: 600; color: var(--ink-700); }
.sign-row { gap: var(--sp-4); }
.sign-box, .sign-pad canvas { border-radius: var(--r-md); background: var(--surface-1); }
.sign-actions { gap: var(--sp-3); padding: var(--sp-3) var(--sp-4); }

/* ---- 历史 / 预览 / 登录 / 杂项 ---- */
.history-item { padding: var(--sp-3) var(--sp-4); font-size: var(--fs-caption); }
.diff-row { gap: var(--sp-2); padding: var(--sp-3) var(--sp-4); font-size: var(--fs-caption); }
.diff-path { font-size: var(--fs-caption); }
.diff-before { background: var(--danger-100); border-radius: var(--r-sm); }
.diff-after  { background: var(--success-100); border-radius: var(--r-sm); }
.preview { max-width: none; }
.preview-title { font-size: var(--fs-h1); }
.preview-table { font-size: var(--fs-caption); }
.preview-table th { background: var(--surface-1); color: var(--ink-700); }
.preview-table td { font-variant-numeric: tabular-nums; }
.preview-photos { gap: var(--sp-3); }
.preview-sign { gap: var(--sp-4); }
.login-card { gap: var(--sp-4); padding: var(--sp-8) var(--sp-6); border-radius: var(--r-lg); }
.login-input { padding: 0 var(--sp-4); }
.login-btn { border-radius: var(--r-md); background: var(--accent-600); color: var(--surface-0); font-size: var(--fs-body); }
.login-btn:hover { background: var(--accent-700); }
.login-alt { font-size: var(--fs-label); }
.empty { padding: var(--sp-12) var(--sp-4); font-size: var(--fs-label); }
.empty::before {
  content: "\25CC"; display: block; margin-bottom: var(--sp-3);
  font-size: 48px; line-height: 1; color: var(--ink-300);
}
.divider { margin: var(--sp-4) 0; }
.spinner { width: 20px; height: 20px; border-top-color: var(--accent-600); }

/* ---- 首页（§5.2 / Q5：单列、唯一 accent 主按钮、无头像/计数/组织名） ---- */
.brand { margin: 0 auto 0 0; font-weight: 600; }
.home-body { padding: var(--sp-5) var(--sp-4) calc(var(--sp-12) + env(safe-area-inset-bottom, 0px)); }
.me { gap: var(--sp-4); padding: var(--sp-6); border-radius: var(--r-lg); margin-bottom: var(--sp-4); background: var(--surface-0); }
.me-name { font-size: var(--fs-h1); font-weight: 600; }
.me-sub  { font-size: var(--fs-body); margin-top: var(--sp-1); }
.stats { gap: var(--sp-3); margin-bottom: var(--sp-6); }
.stat { padding: var(--sp-5) var(--sp-3); border-radius: var(--r-lg); background: var(--surface-0); }
.stat-n { font-size: var(--fs-display); font-weight: 600; }
.stat-l { font-size: var(--fs-label); margin-top: var(--sp-2); }
.zone { margin-bottom: var(--sp-6); }
.zone-t { font-size: var(--fs-label); letter-spacing: 0; margin: 0 var(--sp-1) var(--sp-3); }
.fn-grid { gap: var(--sp-3); }
.fn {
  min-height: 88px; padding: var(--sp-5); border-radius: var(--r-lg);
  background: var(--surface-0); color: var(--ink-900);
  transition: background-color var(--dur-instant) var(--ease);
}
.fn:hover { background: var(--surface-1); }
.fn:active { background: var(--surface-2); }
.fn-i { display: inline-flex; width: 24px; height: 24px; line-height: 1; }
.fn-i svg { width: 24px; height: 24px; stroke: currentColor; fill: none; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.fn-t { font-size: var(--fs-body); font-weight: 600; margin-top: var(--sp-3); }
.fn-c { display: none; }
.fn-primary { background: var(--accent-600); border-color: var(--accent-600); color: var(--surface-0); }
.fn-primary:hover, .fn-primary:active { background: var(--accent-700); }
.me-avatar { display: none; }

/* ---- 六步填写（§5.3 / §6.6 / Q4） ---- */
.flow-steps { gap: var(--sp-2); padding: var(--sp-3) var(--sp-4); background: var(--surface-0); }
.flow-step {
  height: 44px; gap: var(--sp-2); padding: 0 var(--sp-4);
  border: 1px solid var(--line-1); border-bottom: 2px solid transparent;
  border-radius: var(--r-md); background: var(--surface-0);
  color: var(--ink-500); font-size: var(--fs-body); font-weight: 400;
  transition: background-color var(--dur-instant) var(--ease), border-color var(--dur-instant) var(--ease);
}
.flow-step.on {
  background: var(--surface-0); color: var(--ink-900);
  border-color: var(--line-1); border-bottom-color: var(--accent-600); font-weight: 600;
}
.flow-step-n { border-radius: var(--r-sm); font-size: var(--fs-caption); color: var(--ink-700); }
.flow-step.on .flow-step-n { background: var(--accent-100); color: var(--accent-700); }
.flow-step.done .flow-step-n { background: var(--success-100); color: var(--success-700); }
.flow-title { gap: var(--sp-3); font-size: var(--fs-h1); font-weight: 600; margin: 0 var(--sp-1) var(--sp-5); }
.flow-no { border-radius: var(--r-lg); background: var(--surface-2); color: var(--ink-700); font-size: var(--fs-body); }
.flow-bar { gap: var(--sp-3); }
.flow-prev, .flow-next {
  flex: 1; min-width: 0; height: 48px; padding: 0 var(--sp-5);
  border-radius: var(--r-md); font-size: var(--fs-body); font-weight: 600;
  transition: background-color var(--dur-instant) var(--ease), transform var(--dur-instant) var(--ease);
}
.flow-prev { border: 1px solid var(--line-2); background: var(--surface-0); color: var(--ink-900); }
.flow-prev:hover { background: var(--surface-2); }
.flow-next { border: 1px solid var(--accent-600); background: var(--accent-600); color: var(--surface-0); }
.flow-next:hover, .flow-next:active { background: var(--accent-700); border-color: var(--accent-700); }
.flow-next:active { transform: scale(.98); }
.flow-next[data-stepbtn="save"] { background: var(--accent-600); border-color: var(--accent-600); }
.topbar-status, .topbar-actions { display: inline-flex; align-items: center; gap: var(--sp-2); }
.flow-meta { display: none; }

/* ---- 预览工具条（§5.5 / P0-3 结构项） ---- */
.export-menu { position: relative; }
.export-menu > summary {
  list-style: none; display: inline-flex; align-items: center; justify-content: center;
  min-height: 48px; padding: 0 var(--sp-4); cursor: pointer;
  border: 1px solid var(--line-2); border-radius: var(--r-md);
  background: var(--surface-0); color: var(--ink-900);
  font-size: var(--fs-body); font-weight: 600; white-space: nowrap;
}
.export-menu > summary::-webkit-details-marker { display: none; }
.export-menu[open] > summary { background: var(--surface-2); }
.export-menu-list {
  position: absolute; right: 0; top: calc(100% + var(--sp-1)); z-index: 50;
  min-width: 140px; padding: var(--sp-1);
  background: var(--surface-0); border: 1px solid var(--line-1);
  border-radius: var(--r-md); box-shadow: var(--shadow-2);
}
.export-menu-list .btn { display: flex; width: 100%; justify-content: flex-start; border: 0; }
.seg { display: inline-flex; padding: 2px; gap: 2px; background: var(--ink-900); border-radius: var(--r-md); }
.seg .btn { min-height: 44px; border: 0; background: transparent; color: var(--surface-0); font-size: var(--fs-caption); }
.seg .btn.on { background: var(--surface-0); color: var(--ink-900); }

/* ---- 动效（§4.6 / Q2） ---- */
@keyframes qc-page-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: none; }
}
.flow-page:not([hidden]) { animation: qc-page-in var(--dur-slow) var(--ease); }

@media (prefers-reduced-motion: reduce) {
  .spinner { animation: none; }
  .flow-page:not([hidden]) { animation: none; }
  .btn:active, .flow-next:active { transform: none; }
  .btn, .btn-primary, .btn-ghost, .nav-item, .fn, .flow-step, .flow-prev, .flow-next,
  .field-input, .field-textarea, .login-input, .dt-cell input {
    transition: background-color var(--dur-instant) var(--ease),
                border-color var(--dur-instant) var(--ease) !important;
  }
}

/* ---- 断点（§7：640 / 1024） ---- */
@media (max-width: 768px) {
  .nav { gap: var(--sp-2); }
  .fn-grid { grid-template-columns: minmax(0, 1fr); }
  .topbar .btn { min-height: 44px; font-size: var(--fs-caption); }
  .field-label { font-size: var(--fs-label); }
  .field-input, .field-textarea, .dt-cell input, .login-input { font-size: var(--fs-body); }
  .field-textarea { min-height: 88px; }
  .card-h { font-size: var(--fs-body); }
  .dt-head .dt-cell { font-size: var(--fs-caption); }
  .photo-dim-title { font-size: var(--fs-body); }
  .flow-title { font-size: var(--fs-h1); }
  .defect-cell select.field-input { font-size: var(--fs-body); }
}
@media (max-width: 640px) {
  .home-body { max-width: 100%; }
  .stats { gap: var(--sp-2); }
  .preview { padding: var(--sp-5) var(--sp-4) var(--sp-8); }
}
@media (min-width: 1024px) {
  .preview { max-width: none; }
  .home-body { max-width: none; }
}


/* ---- 窄屏预览表格：避免列被挤成竖排（静态快照复验后补） ---- */
@media (max-width: 640px) {
  .preview { overflow-x: auto; }
  .preview-table { min-width: 360px; }
}


/* ---- 登录后移动端：列表 / 详情互斥 + 回首页 + 防横向溢出 ---- */
.mobile-back { display: none; }
.topbar { flex-wrap: wrap; }
.app, .app-split, .split, .pane, .topbar, .bottombar { max-width: 100%; }
.pane-detail { min-width: 0; }
.pane-list, .pane-detail, .preview, .home-body { overflow-wrap: break-word; }

@media (max-width: 768px) {
  .app-split[data-pane="list"] .pane-detail { display: none; }
  .app-split[data-pane="detail"] .pane-list { display: none; }
  .app-split[data-pane="detail"] .mobile-back { display: inline-flex; }
  .pane-list { padding-bottom: var(--sp-4); }
}


/* ---- 铺满视口：容器 100% 宽，不居中（ego 多尺寸审计后） ---- */
.app > .home-body, .app > .preview, .app-flow > .flow-body {
  width: 100%;
  max-width: none;
  margin: 0;
  align-self: stretch;
}


/* ---- ego 多尺寸审计兜底：超长内容不得撑开文档 ---- */
.list-item, .list-title, .list-meta, .section-title, .detail-row,
.field-label, .field-input, .dt-cell, .preview-table td, .preview-table th {
  min-width: 0;
  max-width: 100%;
  overflow-wrap: anywhere;
}
.badge { flex-shrink: 0; max-width: 100%; }
.pane { overflow-x: hidden; }
@media (max-width: 768px) {
  /* 移动端整页纵向滚动保留，只锁死横向，避免任一子项撑开文档 */
  .app-split .pane { overflow-x: hidden; overflow-y: visible; }
}


/* ---- 顶栏用户/退出、统计卡可点、明细表格列对齐、照片双按钮 ---- */
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: var(--sp-2); }
.topbar-user { font-size: var(--fs-label); color: var(--ink-700); white-space: nowrap; }
.stat { width: 100%; font: inherit; cursor: pointer; }
.stat:active { background: var(--surface-2); }
.stat .stat-n, .stat .stat-l { display: block; }

.filter-bar {
  display: flex; align-items: center; justify-content: space-between; gap: var(--sp-2);
  padding: var(--sp-2) var(--sp-3); margin: 0 0 var(--sp-2);
  background: var(--accent-100); border-radius: var(--r-sm);
  font-size: var(--fs-caption); color: var(--ink-700);
}
.filter-bar .btn { min-height: 40px; }

/* 表头与数据行共用同一 grid 模板，逐列对齐；窄屏由 .dt 整表横滑 */
.dt-head, .dt-row {
  display: grid;
  grid-template-columns: var(--dt-tpl, repeat(auto-fit, minmax(140px, 1fr)));
  width: 100%;
  min-width: var(--dt-minw, 100%);
}
.dt .dt-cell, .dt .dt-no { flex: initial; min-width: 0; }
.dt-add { min-width: var(--dt-minw, 100%); }

/* 每个检查项下面两个按钮：拍照直连相机，上传走相册多选 */
.photo-actions { display: flex; gap: var(--sp-2); margin-top: var(--sp-2); }
.photo-action {
  flex: 1; min-width: 0; min-height: 48px;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid var(--line-2); border-radius: var(--r-md);
  background: var(--surface-0); color: var(--ink-900);
  font-size: var(--fs-label); font-weight: 600; cursor: pointer;
}
.photo-action svg { width: 20px; height: 20px; }
.photo-action:active { background: var(--surface-2); }

@media (max-width: 640px) {
  .topbar-right { width: 100%; justify-content: flex-end; }
}
