:root {
  --primary: #185FA5;
  --primary-light: #E6F1FB;
  --primary-dark: #0C447C;
  --success: #0F6E56;
  --success-light: #E1F5EE;
  --warning: #BA7517;
  --warning-light: #FAEEDA;
  --danger: #A32D2D;
  --danger-light: #FCEBEB;
  --gray-50: #F9F9F7;
  --gray-100: #F1EFE8;
  --gray-200: #E5E3DC;
  --gray-300: #D3D1C7;
  --gray-400: #888780;
  --gray-500: #5F5E5A;
  --gray-600: #444441;
  --gray-700: #2C2C2A;
  --bg: #F5F4F0;
  --surface: #FFFFFF;
  --text: #2C2C2A;
  --text-secondary: #5F5E5A;
  --text-tertiary: #888780;
  --border: #E5E3DC;
  --radius: 8px;
  --radius-lg: 12px;
  --sidebar-w: 200px;
  --shadow: 0 1px 3px rgba(0,0,0,0.06);
}

* { margin:0; padding:0; box-sizing:border-box; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

#app { display:flex; min-height:100vh; }

/* Sidebar */
.sidebar {
  width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
}
.sidebar-logo {
  padding: 20px 18px;
  display: flex;
  align-items: center;
  gap: 8px;
  border-bottom: 1px solid var(--border);
}
.logo-text { font-size: 16px; font-weight: 600; color: var(--primary-dark); }
.nav-list { list-style: none; padding: 8px; flex: 1; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: var(--radius);
  cursor: pointer;
  color: var(--text-secondary);
  font-size: 14px;
  margin-bottom: 2px;
  transition: all 0.15s;
}
.nav-item:hover { background: var(--gray-50); color: var(--text); }
.nav-item.active { background: var(--primary-light); color: var(--primary-dark); font-weight: 500; }
.nav-item svg { flex-shrink: 0; }
/* 侧边栏折叠分组 */
.nav-group { margin: 0; }
.nav-group-header { display: flex; align-items: center; gap: 8px; padding: 9px 12px; cursor: pointer; border-radius: var(--radius); font-size: 14px; color: var(--text-secondary); transition: background 0.15s; user-select: none; }
.nav-group-header:hover { background: var(--gray-50); color: var(--text); }
.nav-group.expanded .nav-group-header { color: var(--primary-dark); font-weight: 500; }
.nav-group-arrow { margin-left: auto; font-size: 10px; color: var(--text-tertiary); transition: transform 0.2s; }
.nav-sub-list { list-style: none; padding: 0; margin: 0; display: none; }
.nav-sub-list .nav-item { padding-left: 36px; font-size: 13px; }
.sidebar.collapsed .nav-group-header span:not(.nav-icon),
.sidebar.collapsed .nav-group-arrow,
.sidebar.collapsed .nav-sub-list { display: none; }
.sidebar.collapsed .nav-group-header { justify-content: center; padding: 10px; }
.sidebar-footer { padding: 12px 18px; border-top: 1px solid var(--border); }
.sync-status { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-tertiary); }
.sync-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--gray-400); }
.sync-status.online .sync-dot { background: var(--success); }
.sync-status.online .sync-text { color: var(--success); }

/* Main content */
.main-content {
  flex: 1;
  margin-left: var(--sidebar-w);
  padding: 24px 32px;
  min-height: 100vh;
}

/* Views */
.view { display: none; }
.view.active { display: block; }

/* Page header */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}
.page-title { font-size: 20px; font-weight: 600; }
.page-actions { display: flex; gap: 8px; }

/* Cards */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  margin-bottom: 16px;
}
.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}
.card-title { font-size: 15px; font-weight: 600; }

/* Buttons */
.btn {
  padding: 8px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}
.btn:hover { background: var(--gray-50); }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-outline { background: transparent; border-color: var(--gray-300); color: var(--text-secondary); }
.btn-outline:hover { border-color: var(--primary); color: var(--primary); }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-text { border: none; background: none; color: var(--primary); padding: 4px 8px; }
.btn-text:hover { background: var(--primary-light); }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }

/* Inputs */
.input {
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
  width: 100%;
  background: var(--surface);
  color: var(--text);
  transition: border-color 0.15s;
}
.input:focus { outline: none; border-color: var(--primary); }
select.input { cursor: pointer; }
textarea.input { resize: vertical; font-family: inherit; }

/* Forms */
.form-group { margin-bottom: 14px; }
.form-group label {
  display: block;
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 5px;
  font-weight: 500;
}

/* Tables */
.table-wrapper { overflow-x: auto; }
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.data-table th {
  text-align: left;
  padding: 10px 12px;
  background: var(--gray-50);
  color: var(--text-secondary);
  font-weight: 500;
  font-size: 12px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.data-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
}
.data-table tr:hover td { background: var(--gray-50); }
.data-table .num-col { text-align: right; }
.data-table .text-right { text-align: right; }
.empty-row td { text-align: center; color: var(--text-tertiary); padding: 32px 12px; }
.total-amount { font-weight: 600; color: var(--danger); font-size: 15px; }

/* Billing layout */
.billing-grid { display: grid; grid-template-columns: 1fr 280px; gap: 16px; }
.product-search-bar { display: flex; gap: 8px; margin-bottom: 12px; }
.search-results {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  max-height: 240px;
  overflow-y: auto;
  margin-bottom: 12px;
}
.search-result-item {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.search-result-item:hover { background: var(--primary-light); }
.search-result-item:last-child { border-bottom: none; }
.result-info { display: flex; flex-direction: column; }
.result-name { font-weight: 500; }
.result-meta { font-size: 12px; color: var(--text-tertiary); }
.result-stock { font-size: 12px; color: var(--success); font-weight: 500; }
.result-stock.low { color: var(--warning); }
.result-stock.out { color: var(--danger); }

/* Product images */
.product-thumb {
  width: 44px;
  height: 44px;
  border-radius: 6px;
  object-fit: cover;
  border: 1px solid var(--border);
  vertical-align: middle;
}
.product-thumb-placeholder {
  width: 44px;
  height: 44px;
  border-radius: 6px;
  border: 1px dashed var(--gray-300);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--gray-50);
  color: var(--text-tertiary);
  font-size: 11px;
}
.search-result-item .result-info { flex: 1; }
.product-img-upload {
  display: flex;
  align-items: center;
  gap: 12px;
}
.product-img-preview {
  width: 80px;
  height: 80px;
  border-radius: 8px;
  border: 1px solid var(--border);
  object-fit: cover;
  cursor: pointer;
}
.product-img-preview.empty {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--gray-50);
  color: var(--text-tertiary);
  font-size: 12px;
  border-style: dashed;
  cursor: pointer;
}
.upload-hint { font-size: 12px; color: var(--text-tertiary); }

/* 多图画廊 */
.image-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: 8px;
  margin-bottom: 8px;
}
.image-gallery-item {
  position: relative;
  width: 100%;
  aspect-ratio: 1;
  border-radius: 6px;
  overflow: hidden;
  border: 2px solid transparent;
  background: var(--gray-50);
  cursor: pointer;
  transition: all 0.15s;
}
.image-gallery-item:hover { border-color: var(--primary); }
.image-gallery-item.is-primary { border-color: var(--primary); }
.image-gallery-item img {
  width: 100%; height: 100%; object-fit: cover;
}
.image-gallery-item .primary-badge {
  position: absolute; top: 4px; left: 4px;
  background: var(--primary); color: #fff;
  padding: 2px 6px; border-radius: 3px;
  font-size: 11px; font-weight: 500;
}
.image-gallery-item .set-primary-btn {
  position: absolute; top: 4px; left: 4px;
  width: 22px; height: 22px;
  background: rgba(0,0,0,0.5); color: #fff;
  border: none; border-radius: 3px;
  font-size: 12px; cursor: pointer;
  opacity: 0; transition: opacity 0.15s;
}
.image-gallery-item:hover .set-primary-btn { opacity: 1; }
.image-gallery-item .remove-img-btn {
  position: absolute; top: 4px; right: 4px;
  width: 22px; height: 22px;
  background: rgba(220, 38, 38, 0.85); color: #fff;
  border: none; border-radius: 3px;
  font-size: 14px; line-height: 1; cursor: pointer;
  opacity: 0; transition: opacity 0.15s;
}
.image-gallery-item:hover .remove-img-btn { opacity: 1; }
.image-gallery-add {
  width: 100%;
  aspect-ratio: 1;
  border: 2px dashed var(--border-light);
  border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  font-size: 32px; color: var(--text-tertiary);
  cursor: pointer;
  transition: all 0.15s;
}
.image-gallery-add:hover {
  border-color: var(--primary);
  color: var(--primary);
}
.image-gallery-empty {
  padding: 40px 20px;
  text-align: center;
  background: var(--gray-50);
  border-radius: 6px;
  color: var(--text-tertiary);
  border: 2px dashed var(--border-light);
}

/* Nav icons (emoji) */
.nav-icon { font-size: 18px; flex-shrink: 0; line-height: 1; }

/* Size grid for purchase (6 sizes) */
.size-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 8px;
  margin-top: 6px;
}
.size-grid .size-cell {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
}
.size-grid .size-label {
  font-size: 12px; color: var(--text-secondary); font-weight: 600;
}
.size-grid .size-label.optional { color: var(--text-tertiary); font-weight: 400; }
.size-grid .size-input {
  width: 100%; padding: 6px 4px; text-align: center;
  border: 1px solid var(--border-light); border-radius: 4px;
  font-size: 14px;
}
.size-grid .size-input:focus { outline: none; border-color: var(--primary); }
.size-grid .size-input:invalid { border-color: var(--danger); }
@media (max-width: 600px) {
  .size-grid { grid-template-columns: repeat(3, 1fr); }
}

/* Purchase mode tabs */
.purchase-tabs {
  display: flex; gap: 4px; margin-bottom: 12px;
  background: var(--gray-100); padding: 4px; border-radius: 6px;
}
.purchase-tabs button {
  flex: 1; padding: 8px 12px;
  border: none; background: transparent;
  border-radius: 4px; cursor: pointer;
  font-size: 13px; color: var(--text-secondary);
}
.purchase-tabs button.active {
  background: #fff; color: var(--primary); font-weight: 600;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

/* Customer info box */
.customer-info-box {
  background: var(--gray-50);
  border-radius: var(--radius);
  padding: 10px 12px;
  margin-bottom: 14px;
  border-left: 3px solid var(--primary);
}
.customer-info-box .info-row { display: flex; gap: 8px; font-size: 13px; margin-bottom: 3px; }
.customer-info-box .info-label { color: var(--text-tertiary); min-width: 36px; font-size: 12px; }
.customer-info-box .info-value { color: var(--text); flex: 1; word-break: break-all; }

/* Image capture area */
.image-capture-area { text-align: center; }
.capture-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px;
  border: 2px dashed var(--gray-300);
  border-radius: var(--radius-lg);
  color: var(--text-tertiary);
}

/* Print preview modal */
#printPreviewOverlay { background: rgba(0,0,0,0.5); }
.print-receipt { background: #fff; padding: 16px; border-radius: 8px; }
.print-receipt table { font-size: 12px; }

/* Hidden product row */
.data-table tr.row-hidden { background: var(--gray-100); color: var(--text-tertiary); }
.data-table tr.row-hidden td { opacity: 0.7; }
.badge-hidden { background: var(--gray-300); color: var(--text-secondary); padding: 1px 6px; border-radius: 8px; font-size: 10px; margin-left: 4px; }

/* Settlement */
.settlement-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 16px; }
.amount-summary { border-top: 1px solid var(--border); padding-top: 12px; }
.amount-row {
  display: flex;
  justify-content: space-between;
  padding: 4px 0;
  font-size: 13px;
  color: var(--text-secondary);
}
.amount-row span:last-child { font-weight: 500; color: var(--text); }
.total-row { font-size: 16px; font-weight: 600; color: var(--text); border-top: 1px solid var(--border); margin-top: 4px; padding-top: 8px; }
.total-row span:last-child { color: var(--danger); }

/* Filter bar */
.filter-bar { display: flex; gap: 8px; margin-bottom: 16px; }
.filter-bar .input { max-width: 200px; }

/* Pagination */
.pagination { display: flex; justify-content: center; gap: 4px; margin-top: 16px; }
.pagination button {
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  cursor: pointer;
  font-size: 13px;
}
.pagination button.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.pagination button:disabled { opacity: 0.4; cursor: not-allowed; }

/* Stats */
.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 16px; }
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
}
.stat-label { font-size: 12px; color: var(--text-secondary); margin-bottom: 8px; }
.stat-value { font-size: 24px; font-weight: 600; }

/* Settings */
.settings-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.sync-info { padding: 8px 12px; background: var(--gray-50); border-radius: var(--radius); font-size: 13px; color: var(--text-secondary); }

/* Status badges */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 500;
}
.badge-confirmed { background: var(--success-light); color: var(--success); }
.badge-draft { background: var(--gray-100); color: var(--gray-500); }
.badge-void { background: var(--danger-light); color: var(--danger); }
.badge-returned { background: var(--warning-light); color: var(--warning); }
.badge-tier-vip { background: var(--warning-light); color: var(--warning); }
.badge-tier-large { background: var(--primary-light); color: var(--primary); }
.badge-tier-wholesale { background: var(--success-light); color: var(--success); }
.badge-tier-retail { background: var(--gray-100); color: var(--gray-500); }

/* Modal */
.modal-overlay {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.4);
  z-index: 200;
  justify-content: center;
  align-items: center;
}
.modal-overlay.active { display: flex; }
.modal {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 24px;
  max-width: 560px;
  width: 90%;
  max-height: 85vh;
  overflow-y: auto;
}
.modal.modal-wide { max-width: 720px; }
.modal-title { font-size: 18px; font-weight: 600; margin-bottom: 20px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }

/* Toast */
.toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 300;
}
.toast {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 20px;
  margin-bottom: 8px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
  font-size: 13px;
  animation: slideIn 0.2s ease;
  max-width: 360px;
}
.toast.success { border-left: 3px solid var(--success); }
.toast.error { border-left: 3px solid var(--danger); }
.toast.info { border-left: 3px solid var(--primary); }
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* Bottom nav (mobile) */
.bottom-nav { display: none; }

/* Print */
@media print {
  .sidebar, .bottom-nav, .page-header, .filter-bar, .pagination { display: none !important; }
  .main-content { margin: 0; padding: 0; }
  .card { border: none; box-shadow: none; }
}

/* Responsive - mobile */
@media (max-width: 768px) {
  .sidebar { display: none; }
  .main-content { margin-left: 0; padding: 12px; padding-bottom: 70px; }
  .bottom-nav {
    display: flex;
    position: fixed;
    bottom: 0; left: 0; right: 0;
    background: var(--surface);
    border-top: 1px solid var(--border);
    z-index: 100;
    justify-content: space-around;
    padding: 6px 0;
  }
  .bottom-nav-item {
    background: none;
    border: none;
    padding: 8px 16px;
    font-size: 13px;
    color: var(--text-tertiary);
    cursor: pointer;
  }
  .bottom-nav-item.active { color: var(--primary); font-weight: 500; }

  /* 更多菜单 */
  .more-menu-overlay {
    position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.4); z-index: 199;
  }
  .more-menu-panel {
    position: fixed; bottom: 0; left: 0; right: 0;
    background: var(--surface); border-radius: 16px 16px 0 0;
    z-index: 200; padding: 16px; animation: slideUp 0.2s ease;
  }
  @keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }
  .more-menu-header {
    display: flex; justify-content: space-between; align-items: center;
    font-size: 16px; font-weight: 600; margin-bottom: 16px; padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
  }
  .more-menu-grid {
    display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px;
  }
  .more-menu-item {
    display: flex; flex-direction: column; align-items: center; gap: 6px;
    background: none; border: none; cursor: pointer; padding: 12px 4px;
    font-size: 12px; color: var(--text); border-radius: 8px;
  }
  .more-menu-item:active { background: var(--gray-100); }
  .more-menu-icon { font-size: 28px; }
  .billing-grid { grid-template-columns: 1fr; }
  .settlement-grid { grid-template-columns: 1fr 1fr; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .settings-grid { grid-template-columns: 1fr; }
  .page-header { flex-direction: column; align-items: flex-start; gap: 8px; }
  .page-actions { width: 100%; }
  .page-actions .btn { flex: 1; text-align: center; }
  .filter-bar { flex-direction: column; }
  .filter-bar .input { max-width: none; }
  .data-table { font-size: 12px; }
  .data-table th, .data-table td { padding: 8px 6px; }
  .modal { width: 95%; padding: 16px; }
  .card { padding: 14px; }
}

/* Responsive - tablet */
@media (max-width: 1024px) and (min-width: 769px) {
  .billing-grid { grid-template-columns: 1fr; }
}

/* ===== 商品列表专用样式 ===== */
.goods-card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; }
.goods-card { background: var(--bg-primary); border: 1px solid var(--border); border-radius: 8px; overflow: hidden; transition: box-shadow 0.2s; }
.goods-card:hover { box-shadow: 0 2px 12px rgba(0,0,0,0.08); }
.goods-card.card-disabled { opacity: 0.55; }
.goods-card-top { position: relative; height: 120px; background: var(--gray-50); display: flex; align-items: center; justify-content: center; }
.goods-card-top .product-thumb { width: 100%; height: 100%; object-fit: cover; }
.goods-card-top .product-thumb-placeholder { font-size: 12px; color: var(--text-tertiary); }
.goods-card-check { position: absolute; top: 6px; left: 6px; z-index: 1; background: rgba(255,255,255,0.9); padding: 2px 4px; border-radius: 4px; }
.goods-card-body { padding: 10px 12px; }
.goods-card-title { font-size: 14px; font-weight: 600; margin-bottom: 4px; }
.goods-card-meta { font-size: 12px; color: var(--text-secondary); margin-bottom: 8px; }
.goods-card-prices { display: flex; justify-content: space-between; font-size: 13px; }
.goods-card-actions { display: flex; gap: 4px; padding: 0 12px 12px; }
.goods-card-actions .btn { flex: 1; font-size: 12px; }

/* 分组折叠样式 */
.goods-group-row { cursor: pointer; transition: background 0.15s; }
.goods-group-row:hover { background: var(--gray-50); }
.goods-group-row td { border-top: 2px solid var(--border) !important; }
.group-toggle { display: inline-block; width: 14px; text-align: center; color: var(--text-tertiary); font-size: 10px; transition: transform 0.2s; }
.group-toggle.expanded { color: var(--primary); }
.goods-color-row { cursor: pointer; transition: background 0.15s; }
.goods-color-row:hover { background: var(--gray-100) !important; }
.goods-sub-row td { font-size: 12px !important; }
.goods-sub-row:hover { background: var(--gray-200) !important; }
.goods-card-subs { margin-top: 8px; border-top: 1px dashed var(--border); padding-top: 6px; }
.goods-card-color-group { margin-bottom: 4px; }
.goods-card-color-header { display: flex; align-items: center; gap: 6px; padding: 4px 0; font-size: 13px; }
.goods-card-color-header:hover { background: var(--gray-50); border-radius: 4px; }
.goods-card-size-list { padding-left: 20px; }
.goods-card-sub { display: flex; justify-content: space-between; align-items: center; padding: 3px 0; font-size: 12px; gap: 4px; }
.goods-card-sub.stock-warn label { color: var(--danger); }
.goods-card-sub.stock-low label { color: var(--warning); }
.goods-card-title { cursor: pointer; }

.action-dropdown { position: relative; display: inline-block; }
.action-menu { position: fixed; z-index: 9999; background: #fff; border: 1px solid var(--border); border-radius: 6px; box-shadow: 0 4px 16px rgba(0,0,0,0.12); min-width: 140px; }
.action-menu button { display: block; width: 100%; padding: 8px 14px; text-align: left; border: none; background: none; font-size: 13px; cursor: pointer; color: var(--text-primary); }
.action-menu button:hover { background: var(--gray-50); }
.action-menu button:first-child { border-radius: 6px 6px 0 0; }
.action-menu button:last-child { border-radius: 0 0 6px 6px; }

.stat-box { background: var(--gray-50); border-radius: 8px; padding: 10px 8px; text-align: center; }
.stat-label { font-size: 11px; color: var(--text-tertiary); margin-bottom: 4px; }
.stat-value { font-size: 20px; font-weight: 700; }

.modal-subtitle { font-size: 14px; font-weight: 600; margin-bottom: 8px; color: var(--text-primary); }

.quick-filter-bar .btn.active { background: var(--primary); color: #fff; }
.view-toggle { display: flex; gap: 2px; }
.view-toggle .btn { padding: 4px 12px; font-size: 12px; }

@media (max-width: 768px) {
  .goods-card-grid { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .goods-card-top { height: 90px; }
  .goods-card-title { font-size: 13px; }
  .goods-card-meta { font-size: 11px; }
  .goods-card-prices { font-size: 12px; }
  .goods-card-actions .btn { font-size: 11px; padding: 4px 6px; }
  .goods-detail-stats { grid-template-columns: repeat(2, 1fr) !important; }
}

/* ===== 表格 sticky tfoot（合计行固定） ===== */
.data-table tfoot {
  position: sticky;
  bottom: 0;
  background: var(--surface);
  box-shadow: 0 -2px 6px rgba(0,0,0,0.06);
  z-index: 5;
}
.data-table tfoot td {
  font-weight: 600;
  border-top: 2px solid var(--primary);
  padding: 10px 12px;
}
.data-table tfoot .total-amount {
  color: var(--danger);
  font-size: 16px;
  font-weight: 700;
}

/* ===== 表格横向滚动容器（移动端自适应） ===== */
.table-wrapper {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.table-wrapper .data-table {
  min-width: 500px;
}

/* ===== 选中高亮反馈 ===== */
.input.active-choice {
  border-color: var(--primary);
  background: var(--primary-light);
  font-weight: 600;
  color: var(--primary-dark);
}

/* ===== 扫码弹窗 ===== */
.scan-modal-content {
  max-width: 460px;
  margin: 0 auto;
}
.scan-video-box {
  position: relative;
  background: #000;
  border-radius: 8px;
  overflow: hidden;
  margin-bottom: 12px;
  min-height: 200px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.scan-hint {
  position: absolute;
  bottom: 8px; left: 0; right: 0;
  text-align: center;
  color: #fff;
  font-size: 12px;
  background: rgba(0,0,0,0.5);
  padding: 4px;
}
.scan-fallback {
  padding: 12px;
  background: var(--gray-50);
  border-radius: 8px;
}

/* ===== 空状态组件 ===== */
.empty-state {
  text-align: center;
  padding: 48px 20px;
  color: var(--text-tertiary);
}
.empty-state-icon {
  font-size: 48px;
  margin-bottom: 12px;
  opacity: 0.5;
}
.empty-state-text {
  font-size: 14px;
  margin-bottom: 16px;
}
.empty-state .btn {
  margin: 0 auto;
}

/* ===== 加载遮罩 ===== */
.loading-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(255,255,255,0.7);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
}
.loading-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--gray-200);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-text {
  margin-top: 12px;
  font-size: 14px;
  color: var(--text-secondary);
}

/* ===== 草稿恢复提示条 ===== */
.draft-banner {
  background: var(--primary-light);
  border: 1px solid var(--primary);
  border-radius: 8px;
  padding: 8px 12px;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 13px;
  color: var(--primary-dark);
}

/* ===== 库存预警颜色标记 ===== */
.stock-warn { color: var(--danger) !important; font-weight: 600; }
.stock-low { color: var(--warning) !important; }
.stock-ok { color: var(--success); }

/* ===== 链接文字样式 ===== */
.link-text {
  color: var(--primary);
  text-decoration: none;
  cursor: pointer;
  font-weight: 500;
}
.link-text:hover { text-decoration: underline; }

/* ===== 侧边栏折叠 ===== */
.sidebar-toggle {
  background: none; border: none; cursor: pointer;
  font-size: 18px; color: var(--text-secondary);
  margin-left: auto; padding: 4px 8px; border-radius: 4px;
}
.sidebar-toggle:hover { background: var(--gray-100); }
.sidebar, .main-content { transition: width 0.2s ease, margin-left 0.2s ease; }
.sidebar.collapsed { width: 56px; }
.sidebar.collapsed .logo-text,
.sidebar.collapsed .nav-item span:not(.nav-icon),
.sidebar.collapsed .sync-text,
.sidebar.collapsed .sidebar-footer { display: none; }
.sidebar.collapsed .nav-item { justify-content: center; padding: 10px; }
.sidebar.collapsed .nav-icon { margin: 0; font-size: 20px; }
.main-content.sidebar-collapsed { margin-left: 56px; }

/* ===== 商品详情 - 图片轮播 ===== */
.goods-detail-noimg {
  width: 100%;
  height: 240px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--gray-50);
  color: var(--text-tertiary);
  border-radius: 8px;
  border: 1px dashed var(--border);
  font-size: 14px;
}
.goods-carousel {
  position: relative;
  width: 100%;
  height: 360px;
  background: #000;
  border-radius: 8px;
  overflow: hidden;
  user-select: none;
}
.goods-carousel-track {
  display: flex;
  height: 100%;
  transition: transform 0.3s ease;
}
.goods-carousel-slide {
  flex-shrink: 0;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #000;
}
.goods-carousel-slide img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  cursor: zoom-in;
  display: block;
}
.goods-carousel-btn {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(0,0,0,0.5);
  color: #fff;
  border: none;
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}
.goods-carousel-btn:hover { background: rgba(0,0,0,0.75); }
.goods-carousel-btn.prev { left: 10px; }
.goods-carousel-btn.next { right: 10px; }
.goods-carousel-dots {
  position: absolute;
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 6px;
  z-index: 2;
}
.goods-carousel-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: rgba(255,255,255,0.4);
  cursor: pointer;
  transition: background 0.2s, width 0.2s;
}
.goods-carousel-dot.active {
  background: #fff;
  width: 20px;
  border-radius: 4px;
}
.goods-carousel-counter {
  position: absolute;
  top: 12px;
  right: 12px;
  background: rgba(0,0,0,0.6);
  color: #fff;
  font-size: 12px;
  padding: 3px 10px;
  border-radius: 12px;
  z-index: 2;
}

/* ===== 全屏图片查看器 ===== */
.fs-image-viewer {
  position: fixed;
  inset: 0;
  z-index: 10000;
  background: rgba(0,0,0,0.95);
  display: flex;
  flex-direction: column;
  animation: fsImageFadeIn 0.2s ease;
}
@keyframes fsImageFadeIn { from { opacity: 0; } to { opacity: 1; } }
.fs-image-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  background: linear-gradient(180deg, rgba(0,0,0,0.6), rgba(0,0,0,0));
  color: #fff;
  z-index: 2;
  position: absolute;
  top: 0; left: 0; right: 0;
}
.fs-image-counter {
  background: rgba(255,255,255,0.18);
  font-size: 13px;
  padding: 4px 12px;
  border-radius: 12px;
  font-weight: 500;
}
.fs-image-product {
  font-size: 14px;
  font-weight: 500;
  flex: 1;
  text-align: center;
  margin: 0 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.fs-image-close {
  background: rgba(255,255,255,0.15);
  color: #fff;
  border: none;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}
.fs-image-close:hover { background: rgba(255,255,255,0.3); }
.fs-image-stage {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  position: relative;
  cursor: zoom-in;
}
.fs-image-stage img {
  max-width: 95vw;
  max-height: 85vh;
  object-fit: contain;
  transition: transform 0.15s ease;
  cursor: grab;
  user-select: none;
  -webkit-user-drag: none;
}
.fs-image-stage img:active { cursor: grabbing; }
.fs-image-btn {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: rgba(255,255,255,0.12);
  color: #fff;
  border: none;
  font-size: 28px;
  line-height: 1;
  cursor: pointer;
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}
.fs-image-btn:hover { background: rgba(255,255,255,0.25); }
.fs-image-btn.prev { left: 20px; }
.fs-image-btn.next { right: 20px; }
.fs-image-thumbs {
  position: absolute;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 6px;
  padding: 6px 10px;
  background: rgba(0,0,0,0.5);
  border-radius: 10px;
  max-width: 90vw;
  overflow-x: auto;
  z-index: 3;
  scrollbar-width: none;
}
.fs-image-thumbs::-webkit-scrollbar { display: none; }
.fs-image-thumb {
  width: 48px;
  height: 48px;
  object-fit: cover;
  border-radius: 4px;
  border: 2px solid transparent;
  cursor: pointer;
  flex-shrink: 0;
  opacity: 0.6;
  transition: opacity 0.2s, border-color 0.2s;
}
.fs-image-thumb:hover { opacity: 0.85; }
.fs-image-thumb.active {
  border-color: #07C160;
  opacity: 1;
}

@media (max-width: 768px) {
  .goods-carousel { height: 280px; }
  .fs-image-btn { width: 40px; height: 40px; font-size: 24px; }
  .fs-image-btn.prev { left: 8px; }
  .fs-image-btn.next { right: 8px; }
  .fs-image-thumb { width: 40px; height: 40px; }
}
