/* =====================================
   豆阵 · 拼豆图纸生成器
   响应式 CSS
   Mobile-first, 支持 手机/平板/PC
   ===================================== */

/* === CSS Variables / Theme === */
:root {
  /* 主色调：焦糖杏（温柔手工质感） */
  --primary: #E8A87C;
  --primary-dark: #D4916A;
  --primary-light: #FBE4D0;
  --secondary: #5C4A3E;
  --accent: #9DC08B;
  --danger: #E8877A;
  --warning: #F0C17A;
  
  /* 背景层级 */
  --bg: #FBF7F2;
  --bg-card: #FFFFFF;
  --bg-cream: #FDF3E7;
  --bg-mint: #F4F9F2;
  --bg-dark: #1A1A2E;
  
  /* 文字 */
  --text: #3D2E28;
  --text-light: #8B7355;
  --text-muted: #B8A99A;
  --text-white: #FFFFFF;
  
  /* 边框/阴影 */
  --border: #EDE4D8;
  --border-strong: #D4C4B0;
  --shadow-sm: 0 1px 3px rgba(139,115,85,0.06);
  --shadow: 0 2px 12px rgba(139,115,85,0.08);
  --shadow-lg: 0 4px 24px rgba(139,115,85,0.10);
  
  /* 圆角 */
  --radius: 14px;
  --radius-sm: 10px;
  --radius-lg: 20px;
  --radius-xl: 28px;
  
  --header-h: 52px;
  --nav-h: 60px;
  --max-w: 480px;
}

/* === Reset === */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

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

body {
  font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", -apple-system, sans-serif;
  color: var(--text);
  background: var(--bg);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

h1, h2, h3, .card-title, .brand-name, .logo {
  font-family: "PingFang SC", "Noto Serif SC", "STSong", "Songti SC", Georgia, serif;
}

a { color: var(--primary); text-decoration: none; }
button { cursor: pointer; font-family: inherit; }
img { max-width: 100%; display: block; }
input, select, textarea { font-family: inherit; font-size: inherit; }

/* === Layout === */
.app-container {
  max-width: var(--max-w);
  margin: 0 auto;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* === Header === */
.app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--bg-card);
  color: var(--text);
  height: var(--header-h);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 16px;
  border-bottom: 1px solid var(--border);
  box-shadow: 0 1px 6px rgba(139,115,85,0.06);
}

.app-header .logo {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 1px;
  color: var(--text);
}

.app-header .brand-sub {
  font-size: 13px;
  color: var(--text-light);
  margin-left: 6px;
  font-weight: 400;
}

/* === Main Content === */
.app-main {
  flex: 1;
  padding: 0 0 calc(var(--nav-h) + 20px) 0;
}

/* === Page Container === */
.page {
  display: none;
  padding: 16px;
  animation: fadeIn 0.25s ease;
}

.page.active { display: block; }
#page-warehouse { background: var(--bg); }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* === Navigation Bar === */
.app-nav {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  max-width: var(--max-w);
  width: 100%;
  height: var(--nav-h);
  background: var(--bg-card);
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-around;
  align-items: center;
  z-index: 100;
  padding-bottom: env(safe-area-inset-bottom);
  box-shadow: 0 -1px 6px rgba(139,115,85,0.05);
}

.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 6px 14px;
  border: none;
  background: none;
  color: var(--text-light);
  font-size: 11px;
  font-weight: 500;
  transition: color 0.2s;
  position: relative;
}

.nav-item.active {
  color: var(--primary-dark);
}

.nav-item.active::after {
  content: '';
  position: absolute;
  bottom: -2px;
  width: 20px;
  height: 3px;
  background: var(--primary);
  border-radius: 2px;
}

.nav-item .nav-icon {
  font-size: 20px;
  line-height: 1;
}

/* 3-Tab 导航增强 */
.app-nav-3 .nav-item {
  padding: 6px 28px;
  font-size: 13px;
  gap: 5px;
}

.app-nav-3 .nav-item .nav-icon {
  font-size: 24px;
}

/* 4-Tab 导航（含会员套餐）— 缩小内边距/字号，避免手机端拥挤 */
.app-nav-4 .nav-item {
  padding: 6px 12px;
  font-size: 12px;
  gap: 4px;
}

.app-nav-4 .nav-item .nav-icon {
  font-size: 22px;
}

/* 会员入口 — 轻微吸睛金橙色 */
.nav-membership {
  color: #E8A23C;
}

.nav-membership.active {
  color: #E8A23C;
}

.nav-membership.active::after {
  background: #E8A23C;
}

/* === Components === */

/* Card */
.card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}

.card-title {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 8px;
  color: var(--text);
  letter-spacing: 0.3px;
}

.card-desc {
  font-size: 14px;
  color: var(--text-light);
  line-height: 1.6;
}

/* Button */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 11px 22px;
  border: none;
  border-radius: 24px;
  font-size: 14px;
  font-weight: 600;
  transition: all 0.2s;
  white-space: nowrap;
  letter-spacing: 0.3px;
}

.btn:active { transform: scale(0.97); }

.btn-primary {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 2px 8px rgba(232,168,124,0.35);
}

.btn-primary:hover { background: var(--primary-dark); }

.btn-secondary {
  background: var(--secondary);
  color: white;
}

.btn-outline {
  background: transparent;
  color: var(--primary);
  border: 1.5px solid var(--primary);
}

.btn-accent {
  background: var(--accent);
  color: white;
}

.btn-large {
  padding: 14px 32px;
  font-size: 16px;
  border-radius: 28px;
}

.btn-block {
  display: flex;
  width: 100%;
}

.btn-sm {
  padding: 6px 14px;
  font-size: 13px;
  border-radius: 20px;
}

/* Upload Zone */
.upload-zone {
  border: 2px dashed var(--border-strong);
  border-radius: var(--radius);
  padding: 40px 20px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
  background: var(--bg-cream);
}

.upload-zone:hover, .upload-zone.drag-over {
  border-color: var(--primary);
  background: var(--primary-light);
}

.upload-zone .upload-icon {
  font-size: 48px;
  margin-bottom: 12px;
}

.upload-zone .upload-text {
  font-size: 16px;
  color: var(--text);
  margin-bottom: 4px;
}

.upload-zone .upload-hint {
  font-size: 13px;
  color: var(--text-light);
}

/* Grid Size Selector */
.grid-size-group {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin: 12px 0;
}

.grid-size-btn {
  padding: 8px 16px;
  border: 1.5px solid var(--border);
  border-radius: 20px;
  background: white;
  font-size: 14px;
  transition: all 0.2s;
}

.grid-size-btn.active {
  border-color: var(--primary);
  background: var(--primary-light);
  color: var(--primary-dark);
  font-weight: 600;
}

/* Brand Selector */
.brand-selector {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 12px 0;
}

.brand-btn {
  flex: 1 1 calc(33% - 6px);
  min-width: 90px;
  padding: 8px 6px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  background: white;
  text-align: center;
  font-size: 13px;
  transition: all 0.2s;
}

.brand-btn.active {
  border-color: var(--primary);
  background: var(--primary-light);
}

.brand-btn .brand-name {
  font-weight: 600;
  display: block;
}

.brand-btn .brand-count {
  font-size: 12px;
  color: var(--text-light);
}

/* Preview Canvas */
.canvas-wrapper {
  position: relative;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  min-height: 200px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.canvas-wrapper canvas {
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

/* Color Legend */
.color-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 12px 0;
}

.color-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: 12px;
  font-size: 12px;
  background: var(--border);
}

.color-chip .swatch {
  width: 16px;
  height: 16px;
  border-radius: 3px;
  border: 1px solid rgba(0,0,0,0.1);
  flex-shrink: 0;
}

/* Pricing Cards */
.pricing-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin: 16px 0;
}

.pricing-card {
  background: var(--bg-card);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  text-align: center;
  transition: all 0.2s;
  position: relative;
}

.pricing-card.featured {
  border-color: var(--primary);
  box-shadow: var(--shadow-lg);
}

.pricing-card .badge {
  position: absolute;
  top: -10px;
  right: -10px;
  background: var(--primary);
  color: white;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 10px;
}

.pricing-card .price {
  font-size: 28px;
  font-weight: 700;
  color: var(--primary);
  margin: 8px 0;
}

.pricing-card .price small {
  font-size: 14px;
  font-weight: 400;
  color: var(--text-light);
}

.pricing-card .features {
  list-style: none;
  font-size: 13px;
  color: var(--text-light);
  text-align: left;
  margin: 8px 0;
}

.pricing-card .features li {
  padding: 3px 0;
}

.pricing-card .features li::before {
  content: "✓ ";
  color: var(--accent);
  font-weight: bold;
}

/* Slider */
input[type="range"] {
  -webkit-appearance: none;
  width: 100%;
  height: 6px;
  border-radius: 3px;
  background: var(--border);
  outline: none;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--primary);
  cursor: pointer;
  box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

/* Pixel Canvas (Drawing) */
.pixel-canvas {
  display: grid;
  gap: 0;
  border: 1px solid var(--border);
  background: white;
}

.pixel-canvas .pixel {
  aspect-ratio: 1;
  cursor: pointer;
  border: 1px solid rgba(0,0,0,0.06);
  transition: background 0.1s;
  /* 移动端防止意外选中/滚动 */
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}

.pixel-canvas .pixel:hover {
  border-color: rgba(0,0,0,0.3);
}

/* 移动端画布容器防止页面滚动 */
#pixel-canvas-container {
  touch-action: none;
  -webkit-overflow-scrolling: auto;
}

/* Drawing Tools */
.toolbar {
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 8px 0;
  flex-wrap: wrap;
}

.tool-btn {
  width: 36px;
  height: 36px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  background: white;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}

.tool-btn.active {
  border-color: var(--primary);
  background: var(--primary-light);
}

.tool-btn:hover {
  border-color: var(--primary);
}

/* Current Color Display */
.current-color {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 2px solid var(--border);
  cursor: pointer;
}

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.65);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: fadeIn 0.2s;
}

.modal {
  background: white;
  border-radius: var(--radius-lg);
  padding: 24px;
  max-width: 90vw;
  width: 360px;
  box-shadow: var(--shadow-lg);
}

.modal h3 {
  font-size: 18px;
  margin-bottom: 12px;
}

.modal p {
  font-size: 14px;
  color: var(--text-light);
  margin-bottom: 16px;
}

.modal-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

/* Toast */
.toast {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 300;
  background: var(--secondary);
  color: white;
  padding: 12px 24px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  animation: slideDown 0.3s ease;
}

@keyframes slideDown {
  from { opacity: 0; transform: translateX(-50%) translateY(-20px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* Empty State */
.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-light);
}

.empty-state .empty-icon {
  font-size: 64px;
  margin-bottom: 16px;
  opacity: 0.5;
}

.empty-state p {
  font-size: 15px;
}

/* === Tablet & PC === */
@media (min-width: 768px) {
  :root {
    --max-w: 720px;
    --header-h: 64px;
  }
  
  .page { padding: 24px; }
  
  .pricing-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

@media (min-width: 1024px) {
  :root {
    --max-w: 960px;
  }
  
  .pricing-grid {
    max-width: 800px;
    margin: 16px auto;
  }
}

/* === Utility === */
.text-center { text-align: center; }
.text-right { text-align: right; }
.mt-8 { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.mb-8 { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
.gap-8 { gap: 8px; }
.flex { display: flex; }
.flex-wrap { flex-wrap: wrap; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.hidden { display: none !important; }

/* === Preset Selector (推荐参数) === */
.preset-group {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin: 12px 0;
}

.preset-btn {
  padding: 10px 6px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  background: white;
  text-align: center;
  font-size: 13px;
  transition: all 0.2s;
  cursor: pointer;
}

.preset-btn .preset-icon {
  font-size: 24px;
  display: block;
  margin-bottom: 2px;
}

.preset-btn .preset-label {
  font-size: 11px;
  color: var(--text-light);
}

.preset-btn.active {
  border-color: var(--primary);
  background: var(--primary-light);
}
.preset-btn.active .preset-label { color: var(--primary); }

/* === Style Tabs (鲜艳/柔和) === */
.style-tabs {
  display: flex;
  gap: 0;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  margin: 12px 0;
}

.style-tab {
  flex: 1;
  padding: 8px 0;
  border: none;
  background: white;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s;
}

.style-tab.active {
  background: var(--primary);
  color: white;
}

/* === Background Removal Toggle === */
.option-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 0;
}

.option-label {
  font-size: 14px;
  font-weight: 500;
}

.option-hint {
  font-size: 11px;
  color: var(--text-light);
  display: block;
  margin-top: 2px;
}

.toggle-switch {
  position: relative;
  width: 48px;
  height: 26px;
  background: var(--border);
  border-radius: 13px;
  cursor: pointer;
  transition: background 0.2s;
  flex-shrink: 0;
}

.toggle-switch.on {
  background: var(--primary);
}

.toggle-switch::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: white;
  transition: transform 0.2s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.toggle-switch.on::after {
  transform: translateX(22px);
}

/* === Compare View (原图/图纸对比) === */
.compare-tabs {
  display: flex;
  gap: 0;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  margin-bottom: 12px;
}

.compare-tab {
  flex: 1;
  padding: 6px 0;
  border: none;
  background: white;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s;
}

.compare-tab.active {
  background: var(--secondary);
  color: white;
}

.compare-tab.active .compare-label {
  font-weight: 600;
}

.compare-view-container {
  position: relative;
  min-height: 200px;
}

.compare-view-container .compare-item {
  display: none;
  width: 100%;
}

.compare-view-container .compare-item.active {
  display: block;
}

/* === Result Info Card === */
.result-info {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  text-align: center;
  padding: 12px 0;
}

.result-info .info-cell {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.info-cell .info-value {
  font-size: 18px;
  font-weight: 700;
  color: var(--primary);
}

.info-cell .info-label {
  font-size: 11px;
  color: var(--text-light);
}

/* === Re-parameterize bar === */
.reparam-bar {
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 10px;
  background: var(--bg);
  border-radius: var(--radius-sm);
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.reparam-bar .reparam-label {
  font-size: 12px;
  color: var(--text-light);
  white-space: nowrap;
}

.reparam-bar .btn {
  font-size: 12px;
  padding: 5px 12px;
}

/* === Save/Export bar === */
.action-bar {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

.action-bar .btn {
  flex: 1;
}

/* === Section divider === */
.section-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  margin: 16px 0 8px 0;
}

/* Improve slider hint */
.slider-hint {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--text-light);
  margin-top: 4px;
}

/* ============================================
   结果页布局 · 对标拼豆星球
   ============================================ */

/* 整体结果容器 */
.result-page {
  background: var(--bg-card);
  border-radius: var(--radius);
  overflow: hidden;
}

/* 预览区：左侧缩略图 + 右侧大图 */
.preview-section {
  display: flex;
  gap: 10px;
  padding: 12px;
  background: var(--bg);
  position: relative;
}

.preview-left {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 80px;
  flex-shrink: 0;
}

.preview-thumb {
  width: 80px;
  height: 80px;
  border-radius: 8px;
  overflow: hidden;
  border: 2px solid transparent;
  cursor: pointer;
  position: relative;
  background: #fff;
}

.preview-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.preview-thumb .thumb-label {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  text-align: center;
  background: rgba(0,0,0,0.55);
  color: #fff;
  font-size: 10px;
  padding: 2px 0;
}

.preview-thumb.active {
  border-color: var(--primary);
}

.preview-thumb .thumb-badge {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: rgba(255,255,255,0.85);
  font-size: 11px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* 右侧主预览 */
.preview-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 180px;
  background: #fff;
  border-radius: 8px;
  position: relative;
}

.preview-main img, .preview-main canvas {
  max-width: 100%;
  border-radius: 4px;
  image-rendering: auto;
}
.preview-main canvas {
  max-height: 520px;
  image-rendering: pixelated;
}

.preview-main .preview-label {
  position: absolute;
  top: 6px;
  left: 8px;
  font-size: 11px;
  color: #fff;
  background: var(--primary);
  padding: 1px 6px;
  border-radius: 3px;
}

.preview-main .ai-badge {
  position: absolute;
  bottom: 6px;
  right: 8px;
  font-size: 10px;
  color: var(--text-light);
  opacity: 0.7;
}

/* 多尺寸缩略图行 */
.size-preview-row {
  display: flex;
  gap: 10px;
  padding: 12px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.size-preview-item {
  flex-shrink: 0;
  text-align: center;
  cursor: pointer;
}

.size-preview-item canvas {
  border-radius: 6px;
  border: 2px solid var(--border);
  display: block;
}

.size-preview-item.size-active canvas {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(255,107,53,0.25);
}

.size-preview-item .size-label {
  font-size: 10px;
  color: var(--text-light);
  margin-top: 3px;
}

.size-preview-item.size-active .size-label {
  color: var(--primary);
  font-weight: 600;
}

/* 免费预览次数行 */
.free-counter {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background: var(--primary-light);
  font-size: 12px;
  color: #8B6914;
  flex-wrap: wrap;
  gap: 6px;
}

.free-counter a {
  color: var(--primary);
  text-decoration: none;
  font-size: 11px;
}

/* 会员横幅（黄色渐变） */
.member-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  margin: 8px 12px;
  background: linear-gradient(135deg, var(--primary-light), var(--warning));
  border-radius: 10px;
  font-size: 12px;
  gap: 10px;
}

.member-banner .banner-text strong {
  display: block;
  font-size: 13px;
  color: var(--text);
}

.member-banner .banner-text span {
  font-size: 11px;
  color: var(--text-secondary);
}

.member-banner .banner-btn {
  flex-shrink: 0;
  padding: 6px 14px;
  background: var(--primary-dark);
  color: white;
  border: none;
  border-radius: 16px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

/* 推荐参数 - 横向滚动药丸 */
.preset-scroll {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  padding: 8px 0;
  flex-wrap: nowrap;
}

.preset-pill {
  flex-shrink: 0;
  padding: 6px 14px;
  border: 1.5px solid var(--border);
  border-radius: 16px;
  background: #fff;
  font-size: 12px;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s;
}

.preset-pill.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
  font-weight: 600;
}

/* 尺寸选择器 */
.size-selector {
  padding: 8px 0;
}

.size-btns {
  display: flex;
  gap: 6px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}

.size-btn {
  flex: 1;
  min-width: 48px;
  padding: 6px 0;
  text-align: center;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: #fff;
  font-size: 13px;
  cursor: pointer;
  font-weight: 500;
  transition: all 0.2s;
}

.size-btn.active {
  border-color: var(--primary);
  background: var(--primary-light);
  color: var(--primary);
  font-weight: 700;
}

/* 自定义尺寸行（加减号 + 滑块） */
.size-custom {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}

.size-custom .size-stepper {
  width: 32px;
  height: 32px;
  border: 1.5px solid var(--border);
  border-radius: 50%;
  background: #fff;
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s;
}

.size-custom .size-stepper:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.size-custom input[type="range"] {
  flex: 1;
}

.size-custom .size-val {
  font-size: 13px;
  font-weight: 700;
  color: var(--primary);
  min-width: 36px;
  text-align: center;
}

.size-hint {
  font-size: 11px;
  color: var(--text-light);
  margin-top: 2px;
}

/* 底部固定栏 */
.bottom-action-bar {
  position: sticky;
  bottom: 60px;
  left: 0;
  right: 0;
  display: flex;
  gap: 8px;
  padding: 10px 12px;
  background: #fff;
  border-top: 1px solid var(--border);
  z-index: 50;
  box-shadow: 0 -2px 8px rgba(0,0,0,0.06);
}

.bottom-action-bar .btn-member {
  flex-shrink: 0;
  padding: 12px 16px;
  background: var(--secondary);
  color: #fff;
  border: none;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 600;
  text-align: center;
  cursor: pointer;
  line-height: 1.3;
}

.bottom-action-bar .btn-member small {
  display: block;
  font-weight: 400;
  font-size: 11px;
  opacity: 0.8;
}

.bottom-action-bar .btn-save {
  flex: 1;
  padding: 12px 0;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 10px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  text-align: center;
}

.bottom-action-bar .btn-save small {
  display: block;
  font-weight: 400;
  font-size: 11px;
  opacity: 0.85;
}

/* 调整：结果页不再需要间距，卡片之间的间距由结果页自己控制 */
#convert-result .card {
  margin: 0 12px 10px 12px;
}

#convert-result .card:first-child { margin-top: 10px; }

/* 信息统计小行 */
.stats-row {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  font-size: 11px;
  color: var(--text-light);
  padding: 4px 0;
}

.stats-row .stat-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--primary);
  margin-right: 2px;
}

/* ============================================
   进度加载覆盖层
   ============================================ */
.progress-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.35);
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.2s ease;
}

.progress-modal {
  background: white;
  border-radius: 16px;
  padding: 32px 28px;
  text-align: center;
  width: 280px;
  box-shadow: 0 12px 40px rgba(0,0,0,0.25);
}

.progress-spinner {
  width: 44px;
  height: 44px;
  border: 3.5px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  margin: 0 auto 16px;
  animation: spin 0.7s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.progress-text {
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  margin-bottom: 14px;
  line-height: 1.4;
}

.progress-bar-track {
  height: 5px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--primary-dark));
  border-radius: 3px;
  width: 0%;
  transition: width 0.4s ease;
}

/* ============================================
   色卡调色板 · 横向滚动条
   ============================================ */
.color-palette-bar {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 8px 0;
  -webkit-overflow-scrolling: touch;
  scroll-behavior: smooth;
  margin-top: 8px;
  flex-wrap: nowrap;
  /* 隐藏滚动条但可滚动 */
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.color-palette-bar::-webkit-scrollbar {
  height: 4px;
}

.color-palette-bar::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 2px;
}

.color-swatch-item {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  border-radius: 6px;
  cursor: pointer;
  border: 2px solid transparent;
  position: relative;
  transition: all 0.15s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.color-swatch-item:hover {
  transform: scale(1.15);
  z-index: 2;
  border-color: rgba(0,0,0,0.3);
}

.color-swatch-item.active {
  border-color: #333;
  transform: scale(1.18);
  z-index: 3;
  box-shadow: 0 2px 8px rgba(0,0,0,0.25);
}

.color-swatch-item .swatch-label {
  position: absolute;
  bottom: -14px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 8px;
  color: var(--text-light);
  white-space: nowrap;
  opacity: 0;
  transition: opacity 0.15s;
}

.color-swatch-item.active .swatch-label,
.color-swatch-item:hover .swatch-label {
  opacity: 1;
}

/* ============================================
   激活码弹窗
   ============================================ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.65);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.2s ease;
  padding: 20px;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal-card {
  background: #fff;
  border-radius: 16px;
  width: 100%;
  max-width: 380px;
  box-shadow: 0 12px 48px rgba(0,0,0,0.25);
  animation: modalSlideUp 0.25s ease;
}

@keyframes modalSlideUp {
  from { opacity: 0; transform: translateY(30px); }
  to { opacity: 1; transform: translateY(0); }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}

.modal-header h3 {
  margin: 0;
  font-size: 17px;
  font-weight: 700;
}

.modal-close {
  width: 32px;
  height: 32px;
  border: none;
  background: var(--border);
  border-radius: 50%;
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-light);
  transition: all 0.15s;
}

.modal-close:hover {
  background: var(--border-strong);
  color: var(--text);
}

.modal-body {
  padding: 20px;
}

.activate-input {
  letter-spacing: 2px;
  font-family: 'Courier New', monospace;
}

.activate-input:focus {
  outline: none;
  border-color: var(--primary) !important;
  box-shadow: 0 0 0 3px rgba(255,107,53,0.15);
}

/* 价格页激活码卡片 */
.activate-card {
  transition: all 0.2s;
}

.activate-card:hover {
  background: var(--primary-light) !important;
  border-color: var(--primary-dark) !important;
}

/* === 支付弹窗 === */
#pay-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.2s;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.pay-modal {
  background: #fff;
  border-radius: 16px;
  padding: 28px 24px 20px;
  width: 320px;
  max-width: 90vw;
  text-align: center;
  position: relative;
  box-shadow: 0 12px 40px rgba(0,0,0,0.25);
}
.pay-modal-close {
  position: absolute;
  top: 10px;
  right: 14px;
  background: none;
  border: none;
  font-size: 22px;
  color: #999;
  cursor: pointer;
}
.pay-modal-title { font-size: 18px; font-weight: 700; margin-bottom: 4px; }
.pay-modal-amount { font-size: 36px; font-weight: 800; color: var(--primary); margin-bottom: 6px; }
.pay-modal-desc { font-size: 14px; color: var(--text-light); margin-bottom: 16px; }
.pay-qr-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 200px;
  margin-bottom: 12px;
}
.pay-qr-img { width: 200px; height: 200px; display: none; }
.pay-qr-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  color: var(--text-light);
  font-size: 13px;
}
.spinner {
  width: 32px; height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.pay-modal-hint {
  font-size: 12px;
  color: var(--primary);
  margin-bottom: 8px;
}
.pay-modal-status {
  font-size: 13px;
  color: var(--text-light);
  margin-bottom: 12px;
}
.pay-modal-status.pay-success {
  color: var(--accent);
  font-weight: 700;
  font-size: 15px;
}
.pay-modal-actions { margin-top: 8px; }

/* =====================================
   AI豆仓样式
   ===================================== */

/* 子导航 */
.wh-subnav {
  display: flex;
  gap: 4px;
  padding: 8px 12px;
  background: var(--bg-card);
  border-radius: var(--radius);
  margin-bottom: 12px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.05);
  overflow-x: auto;
}
.wh-subtab {
  flex: 1;
  padding: 10px 6px;
  border: none;
  background: transparent;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-light);
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: all 0.2s;
  white-space: nowrap;
  text-align: center;
}
.wh-subtab.active {
  background: var(--primary);
  color: white;
}
.wh-subtab span { margin-right: 2px; }
/* 4 个子tab 适配：缩小内边距与字号，手机端不拥挤 */
.wh-subnav-4 .wh-subtab { padding: 9px 3px; font-size: 12px; }
.wh-subnav-4 .wh-subtab span { margin-right: 1px; }

/* 内容区 */
.wh-content {
  padding: 0 4px;
}

/* 概览卡片 */
.wh-summary {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}
.wh-stat-card {
  flex: 1;
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 12px 8px;
  text-align: center;
  box-shadow: var(--shadow);
}
.wh-stat-num {
  font-size: 22px;
  font-weight: 700;
  color: var(--primary);
  line-height: 1.2;
}
.wh-stat-label {
  font-size: 11px;
  color: var(--text-light);
  margin-top: 2px;
}

/* 品牌切换条 */
.wh-brand-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: var(--bg-card);
  border-radius: var(--radius-sm);
  margin-bottom: 12px;
  font-size: 13px;
  color: var(--text-light);
}
.wh-brand-select {
  padding: 4px 8px;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 12px;
  color: var(--text);
}
.wh-brand-name {
  font-weight: 600;
  color: var(--text);
}

/* 快捷操作按钮 */
.wh-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.wh-btn {
  padding: 10px 16px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.wh-btn-primary {
  background: var(--primary);
  color: white;
}
.wh-btn-primary:active { background: var(--primary-dark); }
.wh-btn-outline {
  background: transparent;
  border: 1.5px solid var(--primary);
  color: var(--primary);
}
.wh-btn-outline:active { background: var(--primary-light); }
.wh-btn-block { width: 100%; justify-content: center; margin-top: 8px; }
.wh-btn-sm {
  padding: 4px 10px;
  font-size: 12px;
  border-radius: 4px;
}

/* 搜索框 */
.wh-search-bar { margin-bottom: 12px; }
.wh-search-input {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  font-size: 14px;
  color: var(--text);
  background: var(--bg-card);
  box-sizing: border-box;
  transition: border-color 0.2s;
}
.wh-search-input:focus {
  outline: none;
  border-color: var(--primary);
}

/* 色系分组 */
.wh-series-groups { display: flex; flex-direction: column; gap: 8px; }
.wh-series-group {
  background: var(--bg-card);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}
.wh-series-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 14px;
  cursor: pointer;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  transition: background 0.15s;
  user-select: none;
}
.wh-series-header:active { background: var(--primary-light); }
.wh-series-header-left {
  display: flex;
  align-items: center;
  gap: 8px;
}
.wh-series-arrow {
  font-size: 10px;
  color: var(--text-light);
  transition: transform 0.2s;
}
.wh-series-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
}
.wh-series-subtotal {
  font-size: 12px;
  color: var(--text-light);
  background: var(--bg-card);
  padding: 2px 8px;
  border-radius: 10px;
}
.wh-series-body { padding: 4px 8px 8px; }

/* 补豆入库三Tab */
.wh-restock-tabs {
  display: flex;
  margin: 0 16px;
  border-bottom: 2px solid var(--border);
}
.wh-restock-tab {
  flex: 1;
  padding: 10px 8px;
  background: none;
  border: none;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-light);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: all 0.2s;
}
.wh-restock-tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

/* 手动补豆色号选择 */
.wh-restock-color-opt {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  cursor: pointer;
  background: var(--bg-card);
  transition: background 0.15s;
  border-bottom: 1px solid var(--border);
}
.wh-restock-color-opt:last-child { border-bottom: none; }
.wh-restock-color-opt:hover { background: var(--bg); }
.wh-restock-color-opt input[type="radio"] { flex-shrink: 0; }
.wh-restock-swatch {
  width: 24px; height: 24px;
  border-radius: 4px;
  border: 1px solid #ddd;
  flex-shrink: 0;
}
.wh-restock-code-label {
  font-size: 14px;
  font-weight: 700;
  flex-shrink: 0;
  min-width: 36px;
}
.wh-restock-name-label {
  font-size: 12px;
  color: var(--text-light);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* 套装卡片优化 */
.wh-set-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: var(--bg-card);
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
  cursor: pointer;
  transition: all 0.2s;
  border: 1px solid var(--border);
  box-shadow: 0 1px 4px rgba(0,0,0,0.05);
}
.wh-set-card:hover { border-color: var(--primary); background: var(--primary-light); }
.wh-set-card:active { transform: scale(0.98); }
.wh-set-icon { font-size: 28px; flex-shrink: 0; }
.wh-set-info { flex: 1; min-width: 0; }
.wh-set-name { font-size: 15px; font-weight: 600; color: var(--text); }
.wh-set-detail { font-size: 12px; color: var(--text-light); margin-top: 2px; }
.wh-set-arrow { font-size: 14px; color: var(--text-light); flex-shrink: 0; }

/* 库存列表 */
.wh-stock-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.wh-stock-item {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-card);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}
.wh-stock-low {
  background: var(--accent-pink);
  border: 1px solid var(--danger);
}
.wh-stock-color {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  border: 1px solid var(--border);
  flex-shrink: 0;
}
.wh-stock-info {
  flex: 1;
  min-width: 0;
}
.wh-stock-code {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
}
.wh-stock-warn {
  display: inline-block;
  background: var(--danger);
  color: white;
  font-size: 10px;
  padding: 1px 5px;
  border-radius: 3px;
  margin-left: 4px;
  vertical-align: middle;
  font-weight: 600;
}
.wh-stock-name {
  font-size: 11px;
  color: var(--text-light);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.wh-stock-count {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}
.wh-stock-num {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  min-width: 40px;
  text-align: center;
}
.wh-stock-num-editable {
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
  transition: background 0.15s;
}
.wh-stock-num-editable:hover {
  background: var(--primary-light);
}
.wh-stock-edit-input {
  /* 由 JS 内联设置 */
.wh-stock-btn {
  width: 28px;
  height: 28px;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: white;
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}
.wh-stock-btn:active { background: var(--bg); }

/* 空状态 */
.wh-empty {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-light);
}
.wh-empty-icon { font-size: 48px; margin-bottom: 12px; }
.wh-empty-title { font-size: 16px; font-weight: 600; color: var(--text); margin-bottom: 4px; }
.wh-empty-desc { font-size: 13px; }

/* 图纸统计条 */
.wh-drawing-stats {
  display: flex;
  gap: 4px;
  margin-bottom: 12px;
}
.wh-ds-item {
  flex: 1;
  text-align: center;
  padding: 8px 4px;
  font-size: 12px;
  color: var(--text-light);
  background: var(--bg-card);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s;
  border: 1px solid transparent;
}
.wh-ds-item.active {
  border-color: var(--primary);
  color: var(--primary);
  font-weight: 600;
}
.wh-ds-item span {
  display: block;
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 2px;
}

/* 图纸卡片 */
.wh-drawing-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
/* 图纸卡片 - 温柔女性风 */
.wh-drawing-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}
.wh-frame-card {
  background: var(--bg-card);
  border-radius: 16px;
  padding: 12px 12px 14px;
  cursor: pointer;
  transition: transform 0.25s, box-shadow 0.25s;
  box-shadow: 0 2px 8px rgba(0,0,0,0.04);
  border: 1px solid var(--border);
}
.wh-frame-card:hover { transform: translateY(-3px); box-shadow: 0 6px 20px rgba(0,0,0,0.08); border-color: var(--border-strong); }
.wh-frame-card:active { transform: scale(0.97); }

/* Polaroid 风格图纸框 */
.wh-polaroid {
  background: var(--bg-card);
  padding: 6px 6px 26px 6px;
  border-radius: 3px;
  border: 1px solid var(--border);
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
  margin-bottom: 10px;
}
.wh-polaroid-inner {
  width: 100%;
  aspect-ratio: 1;
  background: var(--bg);
  border-radius: 2px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.wh-polaroid-inner img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}
.wh-polaroid-empty {
  font-size: 40px;
  opacity: 0.25;
}

/* 信息区 */
.wh-frame-info {
  padding: 0 2px;
}
.wh-frame-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  margin-bottom: 6px;
}
.wh-frame-nm {
  font-size: 13px;
  font-weight: 600;
  color: #444;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}
.wh-frame-tag {
  font-size: 10px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 10px;
  white-space: nowrap;
  flex-shrink: 0;
}
.wh-frame-stats {
  display: flex;
  gap: 6px;
  font-size: 11px;
  color: #aaa;
  margin-bottom: 6px;
}
.wh-frame-foot {
  display: flex;
  justify-content: space-between;
  font-size: 10px;
  color: #bbb;
}

/* 图纸详情 */
.wh-detail-info {
  background: var(--bg-card);
  border-radius: var(--radius-sm);
  padding: 12px;
  margin-bottom: 12px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.05);
  border: 1px solid var(--border);
}
.wh-detail-row {
  display: flex;
  justify-content: space-between;
  padding: 4px 0;
  font-size: 13px;
  color: var(--text);
}
.wh-detail-label { color: var(--text-light); }

/* 图纸详情 - 紧凑芯片布局 */
.wh-detail-row-compact {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}
.wh-detail-chip {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 10px;
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
}

/* 库存对比 */
.wh-compare-section {
  background: var(--bg-card);
  border-radius: var(--radius-sm);
  padding: 12px;
  margin-bottom: 12px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.05);
  border: 1px solid var(--border);
}
.wh-compare-section h4 {
  font-size: 14px;
  margin-bottom: 8px;
  color: var(--text);
}
.wh-compare-ok {
  padding: 8px 12px;
  background: var(--bg-mint);
  border-radius: 6px;
  color: #2E7D32;
  font-size: 13px;
  font-weight: 600;
}
.wh-compare-warn {
  padding: 8px 12px;
  background: var(--primary-light);
  border-radius: 6px;
  color: var(--warning);
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 8px;
}

/* 出库确认弹窗 */
.wh-checkout-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 0;
  font-size: 13px;
  border-bottom: 1px solid var(--border);
}
.wh-checkout-item:last-child { border-bottom: none; }
.wh-checkout-code { font-weight: 600; min-width: 36px; }
.wh-checkout-detail { flex: 1; color: var(--text-light); font-size: 12px; }
.wh-checkout-cost { color: var(--danger); font-weight: 600; font-size: 13px; }

.wh-insufficient-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.wh-insufficient-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  background: white;
  border-radius: 4px;
  font-size: 13px;
}
.wh-ins-code { font-weight: 700; min-width: 40px; }
.wh-color-swatch {
  display: inline-block;
  width: 16px;
  height: 16px;
  border-radius: 3px;
  border: 1px solid rgba(0,0,0,0.12);
  vertical-align: middle;
  flex-shrink: 0;
}
.wh-ins-detail { color: var(--text-light); flex: 1; }
.wh-ins-shortage { color: var(--danger); font-weight: 600; }

/* 补豆清单 */
.wh-restock-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px;
  background: var(--bg-card);
  border-radius: 4px;
  margin-bottom: 4px;
  border: 1px solid var(--border);
}
.wh-restock-code { font-weight: 700; min-width: 44px; }
.wh-restock-detail { color: var(--text-light); font-size: 13px; flex: 1; }
.wh-restock-badge {
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 12px;
  font-weight: 600;
}
.wh-restock-badge.wh-critical { background: var(--accent-pink); color: var(--danger); }
.wh-restock-badge.wh-warning { background: var(--primary-light); color: var(--warning); }

/* 记录页 */
.wh-section {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
  box-shadow: var(--shadow);
}
.wh-section-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 12px;
}

/* 消耗排行 */
.wh-ranking { display: flex; flex-direction: column; gap: 4px; }
.wh-rank-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 8px;
  background: var(--bg-card);
  border-radius: 4px;
  font-size: 13px;
  border: 1px solid var(--border);
}
.wh-rank-num {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--primary);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
}
.wh-rank-num:first-child { background: var(--primary-dark); }
.wh-rank-num:nth-child(2),
.wh-rank-item:nth-child(2) .wh-rank-num { background: var(--primary); }
.wh-rank-item:nth-child(3) .wh-rank-num { background: var(--primary-light); }
.wh-rank-code { flex: 1; font-weight: 600; }
.wh-rank-count { color: var(--text-light); }

/* 出库记录 */
.wh-records { display: flex; flex-direction: column; gap: 6px; }
.wh-record-item {
  padding: 10px 12px;
  background: var(--bg-card);
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.15s;
  border: 1px solid var(--border);
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}
.wh-record-item:active { background: var(--border); }
.wh-record-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}
.wh-record-name { font-size: 14px; font-weight: 600; color: var(--text); }
.wh-record-date { font-size: 11px; color: var(--text-light); }
.wh-record-detail { font-size: 12px; color: var(--text-light); margin-bottom: 4px; display: flex; align-items: center; gap: 6px; }
.wh-record-expand-arrow { font-size: 10px; color: var(--text-light); margin-left: auto; }
.wh-record-colors { font-size: 11px; color: var(--text); }
.wh-record-chip {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  background: white;
  padding: 1px 6px;
  border-radius: 3px;
  margin: 1px;
  font-size: 11px;
  border: 1px solid var(--border);
}
.wh-record-expand {
  margin-top: 8px;
  border-top: 1px dashed var(--border);
  padding-top: 8px;
}
.wh-record-expand-body {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}
.wh-record-detail-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: white;
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 12px;
  border: 1px solid var(--border);
}
.wh-record-detail-code { font-weight: 600; }
.wh-record-detail-count { color: var(--text-light); }

/* Modal 通用 */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.65);
  z-index: 1000;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 20px;
}
.modal-panel {
  background: white;
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 600px;
  margin: 0 auto;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px;
  border-bottom: 1px solid var(--border);
  background: white;
}
.modal-header h3 { font-size: 16px; margin: 0; }
.modal-close {
  background: none;
  border: none;
  font-size: 20px;
  cursor: pointer;
  color: var(--text-light);
  padding: 4px 8px;
}
.modal-body {
  padding: 16px;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  flex: 1;
  min-height: 0; /* 关键：允许 flex item 收缩，否则 overflow-y 不生效 */
  background: white;
  /* 桌面端滚动条可见 */
  scrollbar-width: thin;
  scrollbar-color: #d0d0d0 transparent;
}
.modal-body::-webkit-scrollbar { width: 8px; }
.modal-body::-webkit-scrollbar-track { background: transparent; }
.modal-body::-webkit-scrollbar-thumb { background: #d0d0d0; border-radius: 4px; }
.modal-body::-webkit-scrollbar-thumb:hover { background: #b0b0b0; }

/* 图纸详情弹窗 — 显式滚动条，适配桌面端 */
.wh-drawdetail-panel {
  max-height: 85vh;
  overflow: hidden !important;
  display: flex !important;
  flex-direction: column !important;
}
.wh-drawdetail-body {
  overflow-y: auto !important;
  overflow-x: hidden;
  max-height: none !important;
  flex: 1 1 0% !important;  /* flex-basis: 0 才能让 max-height 生效 + overflow 触发滚动 */
  /* 桌面端显示滚动条 */
  scrollbar-width: thin;
  scrollbar-color: #d0d0d0 transparent;
}
.wh-drawdetail-body::-webkit-scrollbar {
  width: 8px;
}
.wh-drawdetail-body::-webkit-scrollbar-track {
  background: transparent;
}
.wh-drawdetail-body::-webkit-scrollbar-thumb {
  background: #d0d0d0;
  border-radius: 4px;
}
.wh-drawdetail-body::-webkit-scrollbar-thumb:hover {
  background: #b0b0b0;
}

/* 精修编辑器弹窗 — body 可滚动，底部按钮可见 */
#wh-editor-body {
  overflow-y: auto !important;
  overflow-x: hidden;
  flex: 1 1 0% !important;
  min-height: 0;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  scrollbar-color: #d0d0d0 transparent;
}
#wh-editor-body::-webkit-scrollbar { width: 8px; }
#wh-editor-body::-webkit-scrollbar-track { background: transparent; }
#wh-editor-body::-webkit-scrollbar-thumb { background: #d0d0d0; border-radius: 4px; }
#wh-editor-body::-webkit-scrollbar-thumb:hover { background: #b0b0b0; }

/* 精修编辑器画布视口 — 缩放后可原生滚动 */
#wh-canvas-viewport {
  overflow: auto !important;
  scrollbar-width: thin;
  scrollbar-color: #c0c0c0 transparent;
}
#wh-canvas-viewport::-webkit-scrollbar { width: 8px; height: 8px; }
#wh-canvas-viewport::-webkit-scrollbar-track { background: transparent; }
#wh-canvas-viewport::-webkit-scrollbar-thumb { background: #c0c0c0; border-radius: 4px; }
#wh-canvas-viewport::-webkit-scrollbar-thumb:hover { background: #a0a0a0; }

/* 表单 */
.form-group { margin-bottom: 12px; }
.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 4px;
}
.form-input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  color: var(--text);
  box-sizing: border-box;
}
.form-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}
textarea.form-input { resize: none; min-height: 80px; }

/* ===== P0-P3: 库存匹配升级样式 ===== */

/* P0: 图纸卡片角标 */
.wb-corner-badge {
  position: absolute;
  top: 0;
  right: 0;
  padding: 3px 10px 3px 8px;
  border-radius: 0 12px 0 12px;
  font-size: 12px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 4px;
  z-index: 1;
}
.wb-badge-ready { background: #E8F5E9; color: #2E7D32; }
.wb-badge-refill { background: #FFF8E1; color: #F57F17; }
.wb-badge-short { background: #FFEBEE; color: #C62828; }
.wb-card-wrap { overflow: hidden; }

/* P3: 库存匹配面板 */
.ws-stock-wrap {
  background: white;
  border-radius: 10px;
  border: 1px solid var(--border);
  padding: 10px 12px;
  margin-top: 4px;
}
.ws-group-head { user-select: none; }
.ws-group-head:active { opacity: 0.8; }
.ws-arrow { display: inline-block; width: 14px; font-size: 10px; }

/* P2: 豆子库存管理 */
.wb-inv-item input[type="number"] {
  -moz-appearance: textfield;
}
.wb-inv-item input[type="number"]::-webkit-inner-spin-button,
.wb-inv-item input[type="number"]::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

