/* ─── 后台管理样式 ─────────────────────────────── */
:root {
  --primary: #667eea;
  --primary-dark: #764ba2;
  --gradient: linear-gradient(135deg, #667eea, #764ba2);
  --bg: #f5f6fa;
  --card: #fff;
  --border: #e8e8f0;
  --text: #333;
  --text-secondary: #888;
  --text-muted: #aaa;
  --success: #2e7d32;
  --warning: #f57c00;
  --error: #d32f2f;
  --cost-price: #e44;
  --sell-price: #333;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Microsoft YaHei', sans-serif;
  background: var(--bg);
  color: var(--text);
  height: 100vh;
  overflow: hidden;
}

.hidden { display: none !important; }

/* ─── 登录遮罩 ─────────────────────────────── */
.login-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: var(--gradient);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}

.login-box {
  background: white;
  border-radius: 16px;
  padding: 36px 32px;
  width: 360px;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0,0,0,0.2);
}

.login-box h2 {
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 24px;
  color: var(--text);
}

.login-box .form-group {
  text-align: left;
}

.btn-block {
  width: 100%;
  padding: 10px;
  font-size: 15px;
  margin-top: 8px;
}

.login-error {
  margin-top: 12px;
  padding: 8px 12px;
  background: #fff0f0;
  color: var(--error);
  border-radius: 6px;
  font-size: 13px;
}

/* ─── 布局 ─────────────────────────────── */
.admin-layout {
  display: flex;
  height: 100vh;
}

.admin-sidebar {
  width: 200px;
  background: linear-gradient(180deg, #2d2d3f, #1e1e2e);
  color: white;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
}

.sidebar-header {
  padding: 20px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
}

.sidebar-header h2 {
  font-size: 16px;
  font-weight: 600;
}

.sidebar-nav {
  padding: 10px 0;
  flex: 1;
}

.nav-item {
  display: block;
  width: 100%;
  padding: 12px 20px;
  border: none;
  background: transparent;
  color: rgba(255,255,255,0.6);
  cursor: pointer;
  font-size: 14px;
  text-align: left;
  transition: all 0.2s;
}

.nav-item:hover {
  background: rgba(255,255,255,0.05);
  color: rgba(255,255,255,0.9);
}

.nav-item.active {
  background: rgba(102,126,234,0.2);
  color: white;
  border-left: 3px solid var(--primary);
}

.admin-main {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
}

.admin-section {
  max-width: 1200px;
}

/* ─── 区域头部 ─────────────────────────────── */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.section-header h2 {
  font-size: 20px;
  font-weight: 600;
}

.section-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* ─── 按钮 ─────────────────────────────── */
.btn {
  padding: 8px 16px;
  border-radius: 6px;
  border: none;
  cursor: pointer;
  font-size: 13px;
  transition: all 0.2s;
}

.btn-primary {
  background: var(--gradient);
  color: white;
}
.btn-primary:hover { opacity: 0.9; }

.btn-outline {
  background: white;
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-outline:hover { border-color: var(--primary); color: var(--primary); }

.btn-danger {
  background: var(--error);
  color: white;
}
.btn-danger:hover { opacity: 0.9; }

.btn-sm {
  padding: 4px 10px;
  font-size: 12px;
  border-radius: 4px;
  border: none;
  cursor: pointer;
}

.btn-edit {
  background: #e3f2fd;
  color: #1565c0;
}
.btn-edit:hover { background: #bbdefb; }

.btn-delete {
  background: #ffebee;
  color: var(--error);
}
.btn-delete:hover { background: #ffcdd2; }

.btn-success-sm {
  background: #e8f5e9;
  color: #27ae60;
}
.btn-success-sm:hover { background: #c8e6c9; }

.btn-warning-sm {
  background: #fff3e0;
  color: #f39c12;
}
.btn-warning-sm:hover { background: #ffe0b2; }

.btn-warning {
  background: var(--warning);
  color: white;
}
.btn-warning:hover { opacity: 0.9; }

.btn-success {
  background: var(--success);
  color: white;
}
.btn-success:hover { opacity: 0.9; }

/* ─── 筛选和搜索 ─────────────────────────────── */
.admin-select, .admin-search, .admin-filter-select {
  padding: 7px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
  outline: none;
  background: white;
}

.admin-search {
  width: 220px;
}

.admin-filter-select {
  width: 150px;
}

.admin-select:focus, .admin-search:focus, .admin-filter-select:focus {
  border-color: var(--primary);
}

/* ─── 分类筛选树 ─────────────────────────────── */
.category-filter-tree {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 8px 0;
  align-items: center;
  width: 100%;
  clear: both;
}

.cat-filter-item {
  padding: 4px 14px;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: var(--bg);
  font-size: 12px;
  color: var(--text-secondary);
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s;
}

.cat-filter-item:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.cat-filter-item.active {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

.cat-filter-all {
  font-weight: 500;
}

.cat-filter-parent {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.cat-filter-arrow {
  font-size: 10px;
  width: 12px;
  display: inline-block;
}

.cat-filter-children {
  display: none;
  gap: 8px;
  margin-left: 4px;
}

.cat-filter-sub {
  font-size: 12px;
  padding: 4px 14px;
  color: var(--text-secondary);
}

.cat-filter-sub.active {
  color: white;
}

.cat-filter-group {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
}

/* ─── 批量操作栏 ─────────────────────────────── */
.batch-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  background: white;
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 12px;
}

.batch-check-all {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  cursor: pointer;
}

.batch-count {
  font-size: 13px;
  color: var(--text-secondary);
}

.batch-count strong {
  color: var(--primary);
}

/* ─── 表格 ─────────────────────────────── */
.product-table-wrap {
  background: white;
  border-radius: 10px;
  border: 1px solid var(--border);
  overflow: auto;
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
}

.admin-table th {
  background: var(--bg);
  padding: 10px 12px;
  text-align: left;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.admin-table td {
  padding: 10px 12px;
  font-size: 13px;
  border-bottom: 1px solid #f0f0f5;
}

.admin-table tr:hover { background: #f8f8ff; }
.admin-table tr.row-out-of-stock { background: #fff8f0; }
.admin-table tr.row-out-of-stock:hover { background: #fff0e0; }

.col-check {
  width: 40px;
  text-align: center;
}

.model-cell {
  font-family: 'Consolas', 'Monaco', monospace;
  color: var(--primary);
  font-size: 12px;
}

.cost-price { color: var(--cost-price); font-weight: 500; }
.sell-price { color: var(--sell-price); font-weight: 700; font-size: 14px; }

.action-cell {
  white-space: nowrap;
}

.action-cell .btn-sm {
  margin-right: 4px;
}

/* ─── 缺货/正常状态徽章 ─────────────────────────────── */
.stock-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 600;
}

.stock-badge.in-stock {
  background: #e8f5e9;
  color: var(--success);
}

.stock-badge.out-of-stock {
  background: #ffebee;
  color: var(--error);
}

.oos-badge {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 600;
  background: #ffebee;
  color: var(--error);
  vertical-align: middle;
  margin-left: 4px;
}

.col-oos {
  font-weight: 600;
  color: var(--error);
}

/* ─── 分类列表 ─────────────────────────────── */
.category-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.cat-card {
  background: white;
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
}

.cat-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 18px;
  background: var(--bg);
}

.cat-icon { font-size: 20px; }
.cat-name { font-size: 15px; font-weight: 600; }
.cat-id { font-size: 11px; color: var(--text-muted); font-family: monospace; }
.cat-count { font-size: 12px; color: var(--text-secondary); }

.sub-list {
  padding: 8px 18px;
}

.sub-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
  border-bottom: 1px solid #f0f0f5;
  font-size: 13px;
}

.sub-item:last-child { border-bottom: none; }
.sub-name { font-weight: 500; }
.sub-id { font-size: 11px; color: var(--text-muted); font-family: monospace; }

.cat-actions, .sub-actions {
  margin-left: auto;
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

/* ─── 系统设置 ─────────────────────────────── */
.settings-panel {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.setting-item {
  background: white;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.setting-label {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 4px;
}

.setting-desc {
  font-size: 13px;
  color: var(--text-secondary);
}

.setting-desc strong {
  color: var(--primary);
}

/* ─── 弹窗 ─────────────────────────────── */
.modal {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal-content {
  background: white;
  border-radius: 12px;
  width: 560px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
}

.modal-sm { width: 400px; }

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

.modal-header h3 { font-size: 16px; }

.modal-close {
  background: none;
  border: none;
  font-size: 22px;
  cursor: pointer;
  color: var(--text-secondary);
}

.modal-body {
  padding: 20px;
  overflow-y: auto;
  flex: 1;
}

.modal-footer {
  padding: 12px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

/* ─── 表单 ─────────────────────────────── */
.form-group {
  margin-bottom: 14px;
}

.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 4px;
  color: var(--text);
}

.form-input, .form-select {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
  outline: none;
  transition: border-color 0.2s;
}

.form-input:focus, .form-select:focus {
  border-color: var(--primary);
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

/* ─── 确认弹窗 ─────────────────────────────── */
#confirmMessage {
  font-size: 14px;
  line-height: 1.6;
  color: var(--text);
}

/* ─── 移动端响应式 ─────────────────────────────── */
@media (max-width: 768px) {
  body { overflow: auto; height: auto; }

  .admin-layout { flex-direction: column; height: auto; min-height: 100vh; }

  .admin-sidebar {
    width: 100%;
    flex-direction: row;
    align-items: center;
    overflow-x: auto;
  }

  .sidebar-header {
    padding: 12px 16px;
    border-bottom: none;
    border-right: 1px solid rgba(255,255,255,0.1);
    flex-shrink: 0;
  }

  .sidebar-header h2 { font-size: 14px; white-space: nowrap; }

  .sidebar-nav {
    display: flex;
    padding: 0;
    flex: 1;
  }

  .nav-item {
    padding: 12px 16px;
    white-space: nowrap;
    font-size: 13px;
  }

  .nav-item.active {
    border-left: none;
    border-bottom: 3px solid var(--primary);
  }

  .admin-main { padding: 14px; }

  .section-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }

  .section-actions {
    width: 100%;
    flex-wrap: wrap;
  }

  .admin-search { flex: 1; min-width: 0; width: auto; }
  .admin-select { flex: 1; min-width: 0; }

  .batch-bar {
    position: sticky;
    bottom: 0;
    z-index: 100;
    border-radius: 0;
    margin: 0 -14px;
    width: calc(100% + 28px);
    flex-wrap: wrap;
    gap: 8px;
  }

  .product-table-wrap {
    border: none;
    background: transparent;
  }

  .admin-table thead { display: none; }

  .admin-table,
  .admin-table tbody,
  .admin-table tr,
  .admin-table td {
    display: block;
  }

  .admin-table tr {
    background: white;
    border: 1px solid var(--border);
    border-radius: 10px;
    margin-bottom: 10px;
    padding: 12px;
  }

  .admin-table tr.row-out-of-stock {
    border-color: #ffcdd2;
  }

  .admin-table td {
    padding: 3px 0;
    border-bottom: none;
    font-size: 13px;
  }

  .admin-table td.col-check {
    position: absolute;
    right: 12px;
    top: 12px;
  }

  .admin-table td:nth-child(2)::before { content: '分类: '; color: var(--text-secondary); font-size: 12px; }
  .admin-table td:nth-child(3)::before { content: '子分类: '; color: var(--text-secondary); font-size: 12px; }
  .admin-table td:nth-child(5)::before { content: '型号: '; color: var(--text-secondary); font-size: 12px; }
  .admin-table td:nth-child(6)::before { content: '品牌: '; color: var(--text-secondary); font-size: 12px; }
  .admin-table td:nth-child(7)::before { content: '进货价: '; color: var(--text-secondary); font-size: 12px; }
  .admin-table td:nth-child(8)::before { content: '报价: '; color: var(--text-secondary); font-size: 12px; }
  .admin-table td:nth-child(9)::before { content: '缺货: '; color: var(--text-secondary); font-size: 12px; }

  .admin-table td:nth-child(4) {
    font-size: 15px;
    margin-bottom: 4px;
  }

  .action-cell {
    display: flex;
    gap: 6px;
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid #f0f0f5;
  }

  .form-row { grid-template-columns: 1fr; }

  .modal-content { width: calc(100vw - 24px); }
  .modal-sm { width: calc(100vw - 24px); }

  .setting-item {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }

  .setting-item .btn { width: 100%; text-align: center; }

  .login-box {
    width: calc(100vw - 32px);
    padding: 28px 20px;
  }
}

@media (max-width: 480px) {
  .nav-item { padding: 10px 12px; font-size: 12px; }
  .section-header h2 { font-size: 17px; }
  .admin-table td:nth-child(4) { font-size: 14px; }
}

/* ─── 模板映射页面样式 ─────────────────────────────── */
.template-badge {
  display: inline-block;
  padding: 6px 12px;
  background: var(--gradient);
  color: white;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
}

.template-layout {
  display: flex;
  gap: 16px;
  height: calc(100vh - 120px);
  overflow: hidden;
}

.grid-panel {
  flex: 1;
  background: white;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.panel-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px;
  border-bottom: 1px solid var(--border);
  background: #f9fafb;
}

.sheet-tabs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
}

.sheet-tab {
  padding: 6px 12px;
  background: white;
  border: 1px solid var(--border);
  border-radius: 4px;
  cursor: pointer;
  font-size: 13px;
  white-space: nowrap;
}

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

.grid-info {
  padding: 40px;
  text-align: center;
  color: var(--text-muted);
  font-size: 14px;
}

.grid-container {
  flex: 1;
  overflow: auto;
}

.data-grid {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.data-grid thead {
  position: sticky;
  top: 0;
  z-index: 10;
  background: #f5f6fa;
}

.data-grid th {
  padding: 8px;
  border: 1px solid var(--border);
  font-weight: 600;
  text-align: center;
  background: #f5f6fa;
}

.data-grid td {
  padding: 6px 8px;
  border: 1px solid var(--border);
  position: relative;
  cursor: pointer;
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.data-grid td:hover {
  background: #f0f4ff;
}

.data-grid td.selected {
  outline: 2px solid var(--primary);
  outline-offset: -2px;
  z-index: 5;
}

.data-grid td.mapped-cost {
  background: #fff5f5;
}

.data-grid td.mapped-sell {
  background: #f0fff0;
}

.data-grid td.mapped-text {
  background: #f5f5ff;
}

.mapping-dot {
  position: absolute;
  right: 4px;
  top: 4px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.mapping-dot.cost { background: #e44; }
.mapping-dot.sell { background: #4a4; }
.mapping-dot.text { background: #44e; }

/* 合并单元格 */
.data-grid td.merged-cell {
  background: #fafbff;
  border: 2px solid #d0d5e8;
  font-weight: 500;
  white-space: normal;
  vertical-align: middle;
}

/* 图片单元格 */
.data-grid td.has-image {
  vertical-align: middle;
  text-align: center;
  padding: 4px;
}

.cell-image {
  display: inline-block;
  line-height: 0;
}

.cell-image img {
  display: block;
  border: 1px solid #e0e0e0;
  border-radius: 3px;
  object-fit: contain;
}

.grid-pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 12px;
  padding: 10px;
  border-top: 1px solid var(--border);
  background: #f9fafb;
}

.mapping-panel {
  width: 380px;
  background: white;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
  overflow-y: auto;
  padding: 16px;
}

.mapping-section {
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}

.mapping-section:last-child {
  border-bottom: none;
}

.mapping-section h3 {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 12px;
  color: var(--text);
}

.mapping-count {
  display: inline-block;
  padding: 2px 8px;
  background: var(--primary);
  color: white;
  border-radius: 10px;
  font-size: 11px;
  margin-left: 6px;
}

.selected-cell-info {
  padding: 12px;
  background: #f5f6fa;
  border-radius: 6px;
  margin-bottom: 12px;
}

.hint-text {
  color: var(--text-muted);
  font-size: 13px;
  text-align: center;
  padding: 8px;
}

.mapping-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.form-group label {
  display: block;
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

.form-input, .form-select {
  width: 100%;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 13px;
}

.form-input[readonly] {
  background: #f5f6fa;
  color: var(--text-secondary);
}

.product-list {
  max-height: 200px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 4px;
}

.product-item {
  padding: 8px;
  border-bottom: 1px solid #f0f0f5;
  cursor: pointer;
}

.product-item:hover {
  background: #f5f6fa;
}

.product-item:last-child {
  border-bottom: none;
}

.p-name {
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 2px;
}

.p-meta {
  font-size: 11px;
  color: var(--text-muted);
}

.selected-product {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px;
  background: #f0fff0;
  border-radius: 4px;
}

.product-tag {
  flex: 1;
  font-size: 12px;
  color: var(--success);
}

.create-product-hint {
  padding: 8px;
  background: #fff8e1;
  border-radius: 4px;
  text-align: center;
}

.create-product-hint p {
  margin: 0 0 6px 0;
  font-size: 12px;
  color: var(--warning);
}

.form-actions {
  display: flex;
  gap: 8px;
}

.mapping-list {
  max-height: 250px;
  overflow-y: auto;
}

.mapping-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px;
  border-bottom: 1px solid #f0f0f5;
  cursor: pointer;
}

.mapping-item:hover {
  background: #f5f6fa;
}

.mi-cell {
  font-weight: 600;
  color: var(--primary);
  min-width: 40px;
}

.mi-product {
  flex: 1;
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mi-field {
  padding: 2px 8px;
  border-radius: 3px;
  font-size: 11px;
  font-weight: 500;
}

.mi-field.cost { background: #fff5f5; color: #e44; }
.mi-field.sell { background: #f0fff0; color: #4a4; }
.mi-field.text { background: #f5f5ff; color: #44e; }

.mi-delete {
  color: var(--error);
  font-size: 18px;
  cursor: pointer;
  padding: 0 4px;
}

.mi-delete:hover {
  color: #c62828;
}

.mapping-actions {
  margin-top: 12px;
}

.category-form {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
}

.category-list {
  list-style: none;
  padding: 0;
}

.category-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px;
  border-bottom: 1px solid #f0f0f5;
}

.category-item:last-child {
  border-bottom: none;
}

.category-item-name {
  font-size: 13px;
}

.io-buttons {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.import-row {
  position: relative;
}

.import-result {
  margin-top: 12px;
  padding: 10px;
  border-radius: 4px;
  font-size: 13px;
}

.import-result.success {
  background: #f0fff0;
  color: var(--success);
}

.import-result.error {
  background: #fff5f5;
  color: var(--error);
}

/* 新增产品弹窗样式 */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
}

.modal-box {
  background: white;
  border-radius: 8px;
  width: 500px;
  max-width: 90vw;
  max-height: 90vh;
  overflow-y: auto;
}

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

.modal-header h3 {
  font-size: 16px;
  font-weight: 600;
}

.modal-close-btn {
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  color: var(--text-secondary);
}

.modal-body {
  padding: 20px;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 20px;
  border-top: 1px solid var(--border);
}

/* 上传进度遮罩 */
.overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10001;
}

.overlay-content {
  background: white;
  border-radius: 8px;
  padding: 32px;
  text-align: center;
}

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

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

.overlay-content p {
  font-size: 14px;
  color: var(--text);
  margin: 0;
}

/* 响应式 */
@media (max-width: 1024px) {
  .template-layout {
    flex-direction: column;
    height: auto;
  }

  .grid-panel {
    max-height: 500px;
  }

  .mapping-panel {
    width: 100%;
  }
}

/* 批量映射 - 字段配对状态 */
.field-row.paired {
  background: #e8f5e9;
  border-left: 3px solid #4caf50;
}

.field-row.paired:hover {
  background: #c8e6c9;
}

.pairing-badge {
  display: inline-block;
  margin-left: 8px;
  padding: 2px 8px;
  background: #4caf50;
  color: white;
  font-size: 12px;
  border-radius: 12px;
  font-weight: 600;
}

.temporary-message {
  animation: fadeInOut 2s ease-in-out;
}

@keyframes fadeInOut {
  0% { opacity: 0; transform: translateX(-50%) translateY(-10px); }
  10% { opacity: 1; transform: translateX(-50%) translateY(0); }
  90% { opacity: 1; transform: translateX(-50%) translateY(0); }
  100% { opacity: 0; transform: translateX(-50%) translateY(-10px); }
}

/* ─── 批量映射UI样式 ─────────────────────────────── */

/* 产品列表（批量映射版） */
.product-list-batch {
  max-height: 300px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: white;
}

/* 产品卡片（可展开） */
.product-card-batch {
  border-bottom: 1px solid #f0f0f5;
}

.product-card-batch:last-child {
  border-bottom: none;
}

.product-card-header {
  display: flex;
  align-items: center;
  padding: 10px 12px;
  cursor: pointer;
  transition: background 0.2s;
}

.product-card-header:hover {
  background: #f8f9fc;
}

.product-card-header.expanded {
  background: #f0f4ff;
  border-left: 3px solid var(--primary);
}

.product-expand-icon {
  margin-right: 8px;
  font-size: 12px;
  color: var(--text-muted);
  transition: transform 0.2s;
}

.product-card-header.expanded .product-expand-icon {
  transform: rotate(90deg);
}

.product-card-name {
  flex: 1;
  font-size: 14px;
  font-weight: 500;
}

.product-card-meta {
  font-size: 11px;
  color: var(--text-muted);
  margin-left: 8px;
}

/* 产品字段列表 */
.product-fields {
  display: none;
  padding: 8px 12px;
  background: #fafbfc;
}

.product-card-header.expanded + .product-fields {
  display: block;
}

.field-row {
  display: flex;
  align-items: center;
  padding: 6px 8px;
  margin-bottom: 4px;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.2s;
}

.field-row:hover {
  background: #eef0f7;
}

.field-row.selected {
  background: #e3f2fd;
  border-left: 3px solid var(--primary);
}

.field-checkbox {
  margin-right: 8px;
}

.field-label {
  font-size: 12px;
  color: var(--text-secondary);
  min-width: 70px;
}

.field-value {
  flex: 1;
  font-size: 13px;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.field-highlight-btn {
  margin-left: 8px;
  padding: 2px 8px;
  font-size: 11px;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 3px;
  cursor: pointer;
}

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

/* 已选字段汇总 */
.selected-fields-summary {
  margin-top: 12px;
  padding: 12px;
  background: #f0f4ff;
  border: 1px solid #c5d0f0;
  border-radius: 6px;
}

.summary-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
  font-size: 13px;
}

.selected-fields-list {
  max-height: 150px;
  overflow-y: auto;
  margin-bottom: 12px;
}

.selected-field-item {
  display: flex;
  align-items: center;
  padding: 6px 8px;
  background: white;
  border-radius: 4px;
  margin-bottom: 4px;
  font-size: 12px;
}

.selected-field-product {
  font-weight: 500;
  color: var(--text);
  margin-right: 8px;
}

.selected-field-type {
  color: var(--primary);
  font-weight: 600;
  margin-right: 8px;
}

.selected-field-value {
  flex: 1;
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.selected-field-remove {
  margin-left: 8px;
  color: var(--danger);
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
}

.selected-field-remove:hover {
  color: #c0392b;
}

/* 网格单元格高亮 */
.data-grid td.highlight-match {
  background: #fff3cd !important;
  outline: 2px solid #ffc107;
  animation: pulse-highlight 1.5s ease-in-out infinite;
}

@keyframes pulse-highlight {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}

/* 映射分类选择器 */
#mappingCategorySelect {
  margin-bottom: 8px;
}

.category-item-actions {
  display: flex;
  gap: 4px;
}

/* ─── 登录/注册页脚链接 ─────────────────────────────── */
.login-footer {
  margin-top: 16px;
  font-size: 13px;
  color: #888;
}

.login-footer a {
  color: var(--primary);
  text-decoration: none;
  font-weight: 500;
}

.login-footer a:hover {
  text-decoration: underline;
}

.login-success {
  margin-top: 12px;
  padding: 8px 12px;
  background: #f0fff0;
  color: #27ae60;
  border-radius: 6px;
  font-size: 13px;
}

/* ─── 侧边栏底部 ─────────────────────────────── */
.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid rgba(255,255,255,0.1);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.sidebar-user {
  font-size: 13px;
  color: rgba(255,255,255,0.7);
}

.sidebar-logout {
  font-size: 13px;
  color: rgba(255,255,255,0.5);
  text-decoration: none;
  cursor: pointer;
}

.sidebar-logout:hover {
  color: rgba(255,255,255,0.9);
}

/* ─── 用户管理 ─────────────────────────────── */
.user-table-wrap {
  overflow-x: auto;
}

.user-status {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 500;
}

.user-status.active {
  background: #e8f5e9;
  color: #27ae60;
}

.user-status.pending {
  background: #fff3e0;
  color: #f39c12;
}

.user-status.disabled {
  background: #fce4ec;
  color: #c0392b;
}

.user-role-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 12px;
  background: #ede7f6;
  color: #6c5ce7;
}

.user-perm-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.perm-tag {
  display: inline-block;
  padding: 2px 8px;
  background: #e3f2fd;
  color: #1976d2;
  border-radius: 4px;
  font-size: 11px;
}

.perm-tag.super {
  background: #ede7f6;
  color: #6c5ce7;
}

/* ─── 权限编辑弹窗 ─────────────────────────────── */
.perm-user-label {
  margin-bottom: 16px;
  font-size: 14px;
  color: var(--text);
}

.perm-checkbox-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.perm-checkbox-list label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  cursor: pointer;
  padding: 8px 12px;
  border-radius: 6px;
  transition: background 0.15s;
}

.perm-checkbox-list label:hover {
  background: #f5f6fa;
}

.perm-checkbox-list input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--primary);
}

/* ─── 我的价格设置 ─── */

.price-mode-checks {
  display: flex;
  align-items: center;
  gap: 20px;
  flex-wrap: wrap;
  padding: 12px 0;
}

.price-mode-checks .check-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  cursor: pointer;
  user-select: none;
}

.price-mode-checks .check-item input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--primary);
  cursor: pointer;
}

#customPriceTable {
  width: 100%;
  margin-top: 16px;
}

#customPriceTable .custom-price-cell {
  display: flex;
  align-items: center;
  gap: 8px;
}

#customPriceTable .custom-price-input {
  width: 120px;
  padding: 6px 10px;
  border: 1px solid #ddd;
  border-radius: 6px;
  font-size: 14px;
  text-align: right;
  transition: border-color 0.2s;
}

#customPriceTable .custom-price-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.15);
}

.custom-badge {
  display: inline-block;
  padding: 2px 8px;
  font-size: 11px;
  color: #27ae60;
  background: #e8f8ef;
  border-radius: 10px;
  white-space: nowrap;
}

.custom-price-search-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.custom-price-search-bar input {
  flex: 1;
  max-width: 300px;
  padding: 8px 14px;
  border: 1px solid #ddd;
  border-radius: 8px;
  font-size: 14px;
}

.custom-price-search-bar input:focus {
  outline: none;
  border-color: var(--primary);
}

/* ─── 订单管理 ─────────────────────────────── */
.admin-order-card {
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  margin-bottom: 12px;
  overflow: hidden;
}

.admin-order-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 16px;
  background: #f9fafb;
  border-bottom: 1px solid #e5e7eb;
  flex-wrap: wrap;
  gap: 8px;
}

.admin-order-info {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.admin-order-user {
  font-weight: 600;
  color: #6366f1;
}

.admin-order-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.shipping-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  font-size: 13px;
}

.shipping-toggle input[type="checkbox"] {
  width: 16px;
  height: 16px;
  cursor: pointer;
}

.order-items-table {
  width: 100%;
  margin: 0;
  border: none;
}

/* ─── 发货状态标签 ─────────────────────────────── */
.status-badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 600;
  line-height: 20px;
}

.status-shipped {
  background: #dcfce7;
  color: #16a34a;
}

.status-unshipped {
  background: #fef2f2;
  color: #ef4444;
}

.status-channel {
  background: #ede9fe;
  color: #7c3aed;
}

.status-time {
  background: #fef3c7;
  color: #d97706;
}

/* ─── 发货时间单选 ─────────────────────────────── */
.shipping-time-radios {
  display: flex;
  gap: 16px;
  padding: 8px 0;
}

.shipping-time-radios .radio-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  font-size: 14px;
}

.shipping-time-radios .radio-item input[type="radio"] {
  width: 16px;
  height: 16px;
  cursor: pointer;
  accent-color: var(--primary);
}
