/* ═══════════════════════════════════════════════════════════════
   采购录入 · 设计系统
   极简现代主义：大面积留白、单一强调色、极轻阴影、8px 栅格
   ═══════════════════════════════════════════════════════════════ */

:root {
  /* ── 色板 ── */
  --bg:          #FAFAFB;
  --surface:     #FFFFFF;
  --surface-2:   #F4F5F7;

  --ink:         #1C1E21;
  --ink-2:       #6B7280;
  --ink-3:       #9BA1AA;

  --line:        #ECEDF1;
  --line-2:      #DFE1E7;

  --brand:       #5B63C7;
  --brand-press: #4A52B4;
  --brand-soft:  #EFF0FB;
  --brand-line:  #E3E5F7;
  --brand-ring:  rgba(91, 99, 199, .16);

  --danger:      #D14B4B;
  --danger-soft: #FDF1F1;
  --danger-ring: rgba(209, 75, 75, .14);
  --success:     #2E9E6B;
  --success-soft:#EFF9F3;

  /* ── 圆角（三级） ── */
  --r-md: 12px;
  --r-lg: 16px;
  --r-xl: 20px;

  /* ── 阴影（极轻） ── */
  --sh-1: 0 1px 2px rgba(28,30,33,.04);
  --sh-2: 0 6px 20px rgba(28,30,33,.06);
  --sh-lift: 0 -6px 28px rgba(28,30,33,.09);

  /* ── 动效 ── */
  --dur: 240ms;
  --ease: cubic-bezier(.32, .72, 0, 1);

  /* ── 尺寸 ── */
  --pad: 24px;
  --nav-h: 52px;
  --dock-h: 76px;
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Inter",
               "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-size: 15px;
  line-height: 1.55;
  font-variant-numeric: tabular-nums;
  -webkit-tap-highlight-color: transparent;
  -webkit-font-smoothing: antialiased;
}

/* ═══════════════ 屏幕容器 ═══════════════ */

#app {
  position: relative;
  max-width: 520px;
  margin: 0 auto;
  height: 100vh;
  height: 100dvh;
  background: var(--bg);
  overflow: hidden;
}

.screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  will-change: transform, opacity;
}
.screen[hidden] { display: none; }

.screen.enter-right { animation: enterRight var(--dur) var(--ease) both; }
.screen.enter-left  { animation: enterLeft  var(--dur) var(--ease) both; }
.screen.exit-left   { animation: exitLeft   var(--dur) var(--ease) both; }
.screen.exit-right  { animation: exitRight  var(--dur) var(--ease) both; }

@keyframes enterRight { from { opacity:.35; transform: translateX(26px); } to { opacity:1; transform:none; } }
@keyframes enterLeft  { from { opacity:.35; transform: translateX(-26px); } to { opacity:1; transform:none; } }
@keyframes exitLeft   { from { opacity:1; transform:none; } to { opacity:0; transform: translateX(-18px); } }
@keyframes exitRight  { from { opacity:1; transform:none; } to { opacity:0; transform: translateX(18px); } }

/* ═══════════════ 顶部导航 ═══════════════ */

.nav {
  flex: none;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 var(--pad);
  height: calc(var(--nav-h) + env(safe-area-inset-top, 0));
  padding-top: env(safe-area-inset-top, 0);
}

.nav-title {
  flex: 1;
  font-size: 17px;
  font-weight: 640;
  letter-spacing: -.01em;
}

.nav-progress {
  flex: 1;
  text-align: center;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-3);
  letter-spacing: .05em;
  font-variant-numeric: tabular-nums;
}
.nav-progress b { color: var(--ink); font-weight: 640; }

.icon-btn {
  appearance: none;
  flex: none;
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--ink);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  transition: background .16s;
}
.icon-btn:active { background: var(--line); }
.icon-btn.left { margin-left: -8px; }
.icon-btn.right { margin-right: -8px; }
.icon-btn.text {
  width: auto;
  padding: 0 8px;
  font-size: 15px;
  font-weight: 600;
  color: var(--brand);
}

/* ═══════════════ 进度条（4 段） ═══════════════ */

.progress {
  flex: none;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  padding: 4px var(--pad) 0;
}
.progress i {
  height: 3px;
  border-radius: 2px;
  background: var(--line-2);
  transition: background var(--dur) var(--ease);
}
.progress i.on { background: var(--brand); }

/* ═══════════════ 滚动区 ═══════════════ */

.scroll {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  padding: 0 var(--pad);
}

/* ═══════════════ 标题区 ═══════════════ */

.head { padding: 20px 0 28px; }

.head h1 {
  margin: 0 0 8px;
  font-size: 26px;
  line-height: 1.25;
  font-weight: 660;
  letter-spacing: -.022em;
}

.head p {
  margin: 0;
  font-size: 15px;
  line-height: 1.55;
  color: var(--ink-2);
}

/* ═══════════════ 输入字段（浮动标签） ═══════════════ */

.field {
  position: relative;
  margin-bottom: 16px;
}

.field input,
.field textarea {
  appearance: none;
  display: block;
  width: 100%;
  min-height: 56px;
  padding: 22px 16px 6px;
  border: 1px solid var(--line-2);
  border-radius: var(--r-md);
  background: var(--surface);
  color: var(--ink);
  font-family: inherit;
  font-size: 17px;
  line-height: 1.4;
  transition: border-color .18s, box-shadow .18s, background .18s;
}

.field textarea {
  min-height: 136px;
  padding-top: 26px;
  resize: none;
  line-height: 1.6;
}

.field label {
  position: absolute;
  left: 17px;
  top: 18px;
  font-size: 17px;
  color: var(--ink-3);
  pointer-events: none;
  transform-origin: left top;
  transition: transform .16s var(--ease), color .16s var(--ease);
}

.field input:focus + label,
.field input:not(:placeholder-shown) + label,
.field textarea:focus + label,
.field textarea:not(:placeholder-shown) + label {
  transform: translateY(-9px) scale(.74);
  color: var(--brand);
  font-weight: 600;
}

.field input:focus,
.field textarea:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 4px var(--brand-ring);
}

.field.is-error input,
.field.is-error textarea {
  border-color: var(--danger);
  background: var(--danger-soft);
}
.field.is-error input:focus,
.field.is-error textarea:focus {
  box-shadow: 0 0 0 4px var(--danger-ring);
}
.field.is-error label { color: var(--danger); }
/* 与浮动标签规则同特异性 (0,2,2)，且在其之后，
   否则有值时会被浮动规则的 brand 色覆盖。 */
.field.is-error input + label,
.field.is-error textarea + label { color: var(--danger); }

.err {
  display: none;
  margin: 6px 0 0 2px;
  font-size: 13px;
  color: var(--danger);
}
.field.is-error .err { display: block; }

.field input:disabled,
.field textarea:disabled {
  background: var(--surface-2);
  color: var(--ink-3);
  border-color: var(--line);
}
.field.is-disabled label { color: var(--ink-3); }
.field.is-disabled input + label,
.field.is-disabled textarea + label { color: var(--ink-3); }

.field.num input { text-align: right; font-variant-numeric: tabular-nums; }

.field input[type="date"] { text-align: left; color-scheme: light; }

/* ═══════════════ 选择字段（点开 Bottom Sheet） ═══════════════ */

.field-btn {
  appearance: none;
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-height: 56px;
  padding: 22px 14px 6px 16px;
  border: 1px solid var(--line-2);
  border-radius: var(--r-md);
  background: var(--surface);
  text-align: left;
  font-family: inherit;
  cursor: pointer;
  transition: border-color .18s, box-shadow .18s, background .18s;
}
.field-btn:active { background: var(--surface-2); }
.field-btn:focus-visible {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 4px var(--brand-ring);
}

.fb-label {
  position: absolute;
  left: 17px;
  top: 10px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--brand);
  pointer-events: none;
}

.fb-value {
  grid-column: 1;
  padding-top: 5px;
  font-size: 17px;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.fb-value.is-empty { color: var(--ink-3); }

.chev { grid-column: 2; width: 18px; height: 18px; color: var(--ink-3); }

.field.is-error .field-btn {
  border-color: var(--danger);
  background: var(--danger-soft);
}
.field.is-error .fb-label { color: var(--danger); }

/* ═══════════════ 合计卡片 ═══════════════ */

.total-card {
  margin: 4px 0 28px;
  padding: 20px;
  border-radius: var(--r-lg);
  background: var(--brand-soft);
  border: 1px solid var(--brand-line);
}

.total-card .tc-label {
  font-size: 13px;
  font-weight: 640;
  color: var(--brand);
}

.total-card .tc-value {
  display: block;
  margin-top: 4px;
  font-size: 30px;
  font-weight: 680;
  letter-spacing: -.025em;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  line-height: 1.15;
}

.total-card .tc-note {
  margin: 6px 0 0;
  font-size: 13px;
  color: var(--ink-2);
}

.total-card.is-zero .tc-value { color: var(--ink-3); }

/* ═══════════════ 确认页 ═══════════════ */

.summary {
  margin: 8px 0 28px;
  border-radius: var(--r-lg);
  background: var(--surface);
  border: 1px solid var(--line);
  overflow: hidden;
}

.summary .sgroup {
  padding: 12px 20px 7px;
  background: var(--surface-2);
  font-size: 12.5px;
  font-weight: 640;
  color: var(--ink-2);
  letter-spacing: .02em;
  border-bottom: 1px solid var(--line);
}

.summary .srow {
  display: grid;
  grid-template-columns: 92px 1fr;
  gap: 12px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--line);
}
.summary .srow:last-child { border-bottom: 0; }

.summary .sk { font-size: 14px; color: var(--ink-2); }
.summary .sv {
  font-size: 15px;
  color: var(--ink);
  text-align: right;
  overflow-wrap: anywhere;
}
.summary .sv.muted { color: var(--ink-3); }
.summary .sv.strong { font-weight: 660; font-variant-numeric: tabular-nums; }

/* ═══════════════ 底部操作区 ═══════════════ */

.dock {
  flex: none;
  display: flex;
  gap: 10px;
  padding: 12px var(--pad) calc(12px + env(safe-area-inset-bottom, 0px));
  background: var(--bg);
}
.dock .btn { flex: 1; }
.dock .btn-ghost { flex: 0 0 auto; padding: 0 22px; }

/* ═══════════════ 按钮 ═══════════════ */

.btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 52px;
  padding: 0 24px;
  border: 0;
  border-radius: var(--r-md);
  font-family: inherit;
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -.005em;
  cursor: pointer;
  transition: transform .12s var(--ease), background .16s, opacity .16s;
}

.btn:active:not(:disabled) { transform: scale(.975); }
.btn:disabled { opacity: .42; cursor: default; }

.btn-primary { background: var(--brand); color: #fff; box-shadow: var(--sh-1); }
.btn-primary:active:not(:disabled) { background: var(--brand-press); }

.btn-ghost { background: transparent; color: var(--ink-2); }
.btn-ghost:active:not(:disabled) { background: var(--line); }

.btn-quiet { background: var(--surface); color: var(--ink); border: 1px solid var(--line-2); }

.btn .spin {
  width: 18px; height: 18px;
  border: 2px solid rgba(255,255,255,.34);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.btn-ghost .spin, .btn-quiet .spin {
  border-color: rgba(28,30,33,.16);
  border-top-color: var(--ink-2);
}

/* ═══════════════ 记录列表 ═══════════════ */

.list { list-style: none; margin: 0; padding: 4px 0 24px; }

.rec {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: start;
  gap: 2px 16px;
  padding: 16px 0;
  border-bottom: 1px solid var(--line);
}
.rec:last-child { border-bottom: 0; }

.rec-name {
  font-size: 16px;
  font-weight: 560;
  letter-spacing: -.01em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rec-meta {
  grid-column: 1;
  font-size: 13px;
  color: var(--ink-2);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rec-amt {
  grid-column: 2;
  grid-row: 1 / span 2;
  align-self: center;
  font-size: 16px;
  font-weight: 640;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.pull-hint {
  height: 0;
  overflow: hidden;
  display: grid;
  place-items: center;
  font-size: 13px;
  color: var(--ink-3);
  transition: height .2s var(--ease);
}
.pull-hint.on { height: 44px; }

/* ═══════════════ 空状态 ═══════════════ */

.empty {
  display: grid;
  justify-items: center;
  text-align: center;
  padding: 56px 16px 40px;
}

/* 关键：hidden 属性只提供 UA 的 display:none，
   会被上面的 display:grid 覆盖，必须显式声明。 */
.empty[hidden] { display: none; }

.empty-art {
  width: 88px;
  height: 88px;
  display: grid;
  place-items: center;
  border-radius: 22px;
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--ink-3);
  margin-bottom: 20px;
}

.empty-title { margin: 0 0 6px; font-size: 17px; font-weight: 620; }

.empty-desc {
  margin: 0 0 24px;
  max-width: 260px;
  font-size: 14px;
  line-height: 1.6;
  color: var(--ink-2);
}

/* ═══════════════ Bottom Sheet ═══════════════ */

.scrim {
  position: fixed;
  inset: 0;
  z-index: 80;
  background: rgba(28,30,33,.28);
  opacity: 0;
  transition: opacity var(--dur) var(--ease);
}
.scrim.on { opacity: 1; }
.scrim[hidden] { display: none; }

.sheet {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 90;
  max-width: 520px;
  margin: 0 auto;
  max-height: 78vh;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-radius: var(--r-xl) var(--r-xl) 0 0;
  box-shadow: var(--sh-lift);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  transform: translateY(100%);
  transition: transform var(--dur) var(--ease);
}
.sheet.on { transform: none; }
.sheet[hidden] { display: none; }

.sheet-grab {
  flex: none;
  width: 36px; height: 4px;
  margin: 10px auto 0;
  border-radius: 2px;
  background: var(--line-2);
}

.sheet-head {
  flex: none;
  padding: 16px var(--pad) 8px;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}
.sheet-head h3 { margin: 0; font-size: 18px; font-weight: 640; letter-spacing: -.01em; }
.sheet-head .sheet-sub { font-size: 13px; color: var(--ink-2); }

.sheet-body {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 4px 0 8px;
}

.opt {
  appearance: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  min-height: 52px;
  padding: 0 var(--pad);
  border: 0;
  background: transparent;
  font-family: inherit;
  font-size: 16px;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
}
.opt:active { background: var(--surface-2); }
.opt.on { color: var(--brand); font-weight: 620; }
.opt.danger { color: var(--danger); }
.opt .tick { width: 18px; height: 18px; opacity: 0; color: var(--brand); }
.opt.on .tick { opacity: 1; }

.sheet-foot {
  flex: none;
  display: flex;
  gap: 10px;
  padding: 8px var(--pad) 16px;
}
.sheet-foot .btn { flex: 1; }

/* ═══════════════ Toast ═══════════════ */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--dock-h) + 28px + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%) translateY(10px);
  z-index: 100;
  max-width: min(86vw, 380px);
  padding: 12px 18px;
  border-radius: var(--r-md);
  background: #24262A;
  color: #fff;
  font-size: 14px;
  line-height: 1.4;
  box-shadow: var(--sh-2);
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s, transform .2s var(--ease);
}
.toast.on { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.is-err { background: var(--danger); }
.toast.is-ok { background: var(--success); }

/* ═══════════════ 提交成功 ═══════════════ */

.done {
  position: fixed;
  inset: 0;
  z-index: 110;
  display: grid;
  place-items: center;
  background: var(--bg);
  opacity: 0;
  transition: opacity .2s;
}
.done.on { opacity: 1; }
.done[hidden] { display: none; }

.done-inner { display: grid; justify-items: center; gap: 18px; text-align: center; }

.done-ring {
  width: 76px; height: 76px;
  display: grid; place-items: center;
  border-radius: 50%;
  background: var(--success-soft);
  color: var(--success);
}

.done-ring svg { width: 34px; height: 34px; }
.done-ring path {
  fill: none;
  stroke: currentColor;
  stroke-width: 2.6;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 26;
  stroke-dashoffset: 26;
  animation: draw .42s var(--ease) .06s forwards;
}
@keyframes draw { to { stroke-dashoffset: 0; } }

.done-title { margin: 0; font-size: 20px; font-weight: 660; letter-spacing: -.015em; }
.done-desc { margin: 0; font-size: 14px; color: var(--ink-2); }

/* ═══════════════ 无障碍 ═══════════════ */

:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.field input:focus-visible,
.field textarea:focus-visible,
.field-btn:focus-visible { outline: none; }

.sr-only {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    transition-duration: .01ms !important;
  }
}

/* ═══════════════ 身份 / 项目 ═══════════════ */

.nav-sub {
  display: block;
  margin-top: 1px;
  font-size: 12.5px;
  font-weight: 400;
  color: var(--ink-2);
  letter-spacing: 0;
}

.proj-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 20px;
  padding: 12px 16px;
  border-radius: var(--r-md);
  background: var(--brand-soft);
  border: 1px solid var(--brand-line);
}
.pb-label { font-size: 13px; font-weight: 640; color: var(--brand); }
.pb-value {
  flex: 1;
  font-size: 15px;
  font-weight: 560;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.pb-lock { font-size: 11.5px; color: var(--ink-3); }

/* 链接无效拦截 */
.gate {
  position: fixed;
  inset: 0;
  z-index: 120;
  display: grid;
  place-items: center;
  background: var(--bg);
  padding: 24px;
}
.gate[hidden] { display: none; }
.gate-inner { display: grid; justify-items: center; text-align: center; max-width: 300px; }

/* 填报人在记录里的小标记 */
.rec-who {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--surface-2);
  font-size: 11px;
  color: var(--ink-2);
}

/* ═══════════════ 票据照片 ═══════════════ */

.photos { margin: 4px 0 28px; }

.ph-head {
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}
.ph-title { font-size: 14px; font-weight: 640; color: var(--ink); }
.ph-hint { font-size: 12.5px; color: var(--ink-2); }

.ph-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 10px;
}
.ph-grid[style*="display: none"] { display: none !important; }

.ph-item {
  position: relative;
  aspect-ratio: 1;
  border-radius: var(--r-md);
  overflow: hidden;
  border: 1px solid var(--line);
  background: var(--surface-2);
}
.ph-item img { width: 100%; height: 100%; object-fit: cover; display: block; }

.ph-del {
  position: absolute;
  top: 5px; right: 5px;
  width: 26px; height: 26px;
  display: grid; place-items: center;
  border: 0; border-radius: 50%;
  background: rgba(20, 22, 24, .66);
  color: #fff;
  font-size: 17px;
  line-height: 1;
  cursor: pointer;
}

.ph-add {
  appearance: none;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  min-height: 64px;
  border: 1px dashed var(--line-2);
  border-radius: var(--r-md);
  background: var(--surface);
  color: var(--ink-2);
  font-family: inherit;
  font-size: 15px;
  cursor: pointer;
}
.ph-add:active { background: var(--surface-2); }
.ph-add svg { width: 22px; height: 22px; }

.ph-note {
  margin: 10px 0 0;
  font-size: 12.5px;
  color: var(--ink-3);
  line-height: 1.6;
}

/* 确认页缩略图 */
.sum-thumbs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin: 0 0 24px;
}
.sum-thumbs img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: var(--r-md);
  border: 1px solid var(--line);
}

/* 全屏看票据 */
.viewer {
  position: fixed;
  inset: 0;
  z-index: 130;
  display: grid;
  gap: 12px;
  padding: 16px;
  overflow: auto;
  background: rgba(12, 13, 15, .94);
}
.viewer img { width: 100%; display: block; border-radius: var(--r-md); }
