/* ===== CSS Variables ===== */
:root {
  --primary: #BA7517;
  --primary-light: #D4A04A;
  --primary-dark: #8B5610;
  --bg: #FBF9F4;
  --card: #FFFFFF;
  --text: #4A3F35;
  --text-secondary: #8B7E6E;
  --border: #E8E4DA;
  --danger: #C0392B;
  --success: #27AE60;
  --shadow: 0 2px 8px rgba(74, 63, 53, 0.08);
  --radius: 8px;
  --sidebar-width: 200px;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

/* ===== Layout ===== */
.app-container {
  display: flex;
  min-height: 100vh;
}

/* ===== Sidebar ===== */
.sidebar {
  width: var(--sidebar-width);
  background: var(--card);
  border-right: 1px solid var(--border);
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 100;
  display: flex;
  flex-direction: column;
}

.sidebar-header {
  padding: 24px 20px;
  border-bottom: 1px solid var(--border);
  text-align: center;
}

.sidebar-logo {
  font-size: 18px;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 4px;
}

.sidebar-subtitle {
  font-size: 12px;
  color: var(--text-secondary);
}

.sidebar-nav {
  flex: 1;
  padding: 12px 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-item {
  display: block;
  padding: 12px 24px;
  color: var(--text);
  text-decoration: none;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s;
  border-left: 3px solid transparent;
}

.nav-item:hover {
  background: #FAF6F0;
  color: var(--primary);
}

.nav-item.active {
  background: #FAF6F0;
  color: var(--primary);
  border-left-color: var(--primary);
  font-weight: 600;
}

/* ===== Main Content ===== */
.main-content {
  flex: 1;
  margin-left: var(--sidebar-width);
  padding: 24px 32px;
  max-width: 1200px;
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

/* ===== Panel Header ===== */
.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.panel-header h2 {
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
}

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

.card-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

/* ===== Table Toolbar ===== */
.table-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  gap: 12px;
  flex-wrap: wrap;
}

.search-box input {
  padding: 8px 14px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
  width: 240px;
  outline: none;
  transition: border-color 0.2s;
}

.search-box input:focus {
  border-color: var(--primary);
}

/* ===== Table ===== */
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.table thead th {
  background: #FAF7F0;
  color: var(--text-secondary);
  font-weight: 600;
  padding: 12px 16px;
  text-align: left;
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
}

.table tbody td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
}

.table tbody tr:nth-child(even) {
  background: #FAF9F5;
}

.table tbody tr:hover {
  background: #F5F0E8;
}

.table-empty {
  text-align: center;
  color: var(--text-secondary);
  padding: 40px 0;
  font-size: 14px;
  display: none;
}

/* ===== Status Badges ===== */
.status-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 500;
}

.status-on {
  background: #E8F8F0;
  color: var(--success);
}

.status-off {
  background: #FFF0F0;
  color: var(--danger);
}

.status-pending {
  background: #FFF8E6;
  color: #D4A000;
}

.status-paid {
  background: #E8F0FF;
  color: #2E7BD6;
}

.status-shipped {
  background: #F0E8FF;
  color: #7B3FCF;
}

.status-done {
  background: #E8F8F0;
  color: var(--success);
}

.status-refund {
  background: #FFF0F0;
  color: var(--danger);
}

/* ===== Buttons ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 18px;
  border: none;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
}

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

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

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

.btn-danger {
  background: var(--danger);
  color: #fff;
}

.btn-danger:hover {
  background: #A93226;
}

.btn-sm {
  padding: 4px 12px;
  font-size: 12px;
}

.btn-xs {
  padding: 2px 8px;
  font-size: 11px;
}

.table .btn {
  margin-right: 4px;
}

/* ===== Form ===== */
.form-group {
  margin-bottom: 16px;
}

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

.form-input,
.form-select {
  width: 100%;
  padding: 9px 14px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
  color: var(--text);
  background: var(--card);
  outline: none;
  transition: border-color 0.2s;
}

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

.form-select {
  cursor: pointer;
}

.form-row {
  display: flex;
  gap: 16px;
}

.form-row .form-group {
  flex: 1;
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.form-message {
  margin-top: 12px;
  font-size: 14px;
  color: var(--success);
}

/* ===== Settings Card ===== */
.settings-card {
  max-width: 560px;
}

.settings-card .form-input {
  max-width: 400px;
}

/* ===== Modal ===== */
.modal-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(74, 63, 53, 0.4);
  z-index: 200;
  justify-content: center;
  align-items: center;
}

.modal-overlay.active {
  display: flex;
}

.modal {
  background: var(--card);
  border-radius: 12px;
  width: 90%;
  max-width: 520px;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: 0 12px 40px rgba(74, 63, 53, 0.16);
}

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

.modal-header h3 {
  font-size: 18px;
  font-weight: 600;
  color: var(--text);
}

.modal-close {
  background: none;
  border: none;
  font-size: 24px;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 0;
  line-height: 1;
}

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

.modal form {
  padding: 24px;
}

/* ===== Banner List ===== */
.banner-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

.banner-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: box-shadow 0.2s;
}

.banner-card:hover {
  box-shadow: var(--shadow);
}

.banner-image {
  width: 100%;
  height: 150px;
  object-fit: cover;
  background: #F5F0E8;
}

.banner-info {
  padding: 12px 16px;
}

.banner-info h4 {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 4px;
  color: var(--text);
}

.banner-info p {
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 2px;
}

.banner-actions {
  padding: 0 16px 12px;
  display: flex;
  gap: 8px;
}

/* ===== Summary Cards ===== */
.summary-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}

.summary-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  text-align: center;
}

.summary-label {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.summary-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--primary);
}

/* ===== Report Filter ===== */
.report-filter {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.report-filter .date-range {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.report-filter .date-range label {
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  margin-bottom: 0;
}

.report-filter .form-input {
  width: 160px;
}

/* ===== Chart ===== */
.chart-container {
  padding: 16px 0;
  overflow-x: auto;
}

.chart-container canvas {
  display: block;
  max-width: 100%;
}

/* ===== Toast ===== */
.toast {
  position: fixed;
  top: 24px;
  left: 50%;
  transform: translateX(-50%);
  padding: 12px 28px;
  border-radius: 8px;
  color: #fff;
  font-size: 14px;
  z-index: 300;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s;
}

.toast.show {
  opacity: 1;
}

.toast.success {
  background: var(--success);
}

.toast.error {
  background: var(--danger);
}

/* ===== Image Upload Zone ===== */
.image-upload-zone {
  display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-start;
}
.image-preview-list {
  display: flex; flex-wrap: wrap; gap: 10px;
}
.image-preview-item {
  width: 80px; height: 80px; border-radius: 8px; position: relative;
  overflow: hidden; border: 1px solid var(--border);
}
.image-preview-item img {
  width: 100%; height: 100%; object-fit: cover;
}
.image-preview-delete {
  position: absolute; top: 0; right: 0;
  width: 22px; height: 22px; background: rgba(0,0,0,0.5);
  color: #fff; border: none; border-radius: 0 8px 0 8px;
  cursor: pointer; font-size: 14px; line-height: 22px;
  display: flex; align-items: center; justify-content: center;
}
.image-upload-btn {
  width: 80px; height: 80px; border: 2px dashed var(--border);
  border-radius: 8px; display: flex; flex-direction: column;
  align-items: center; justify-content: center; cursor: pointer;
  color: var(--text-secondary); transition: border-color 0.2s;
}
.image-upload-btn:hover { border-color: var(--primary); color: var(--primary); }

/* Spec / Detail items */
.spec-item, .detail-block {
  display: flex; gap: 8px; align-items: center; margin-bottom: 8px;
}
.spec-item input { flex: 1; min-width: 0; }
.detail-block select { width: 80px; }
.detail-block input, .detail-block textarea { flex: 1; min-width: 0; }
.detail-delete, .spec-delete {
  color: var(--danger); cursor: pointer; font-size: 18px;
  padding: 0 4px; line-height: 1;
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
  .sidebar {
    width: 160px;
  }
  .sidebar {
    --sidebar-width: 160px;
  }
  .main-content {
    padding: 16px;
  }
  .table-toolbar {
    flex-direction: column;
  }
  .search-box input {
    width: 100%;
  }
  .summary-cards {
    grid-template-columns: repeat(2, 1fr);
  }
  .form-row {
    flex-direction: column;
    gap: 0;
  }
  .banner-list {
    grid-template-columns: 1fr;
  }
}

/* ==========================================================
   以下为 PC 后台改造新增样式（登录页 / 账号管理 / 订单详情等）
   ========================================================== */

/* ===== 修正响应式侧边栏宽度变量作用域 ===== */
@media (max-width: 768px) {
  :root {
    --sidebar-width: 160px;
  }
}

/* ===== 侧边栏底部用户区 ===== */
.sidebar-user {
  border-top: 1px solid var(--border);
  padding: 14px 16px 16px;
}
.sidebar-user-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sidebar-user-role {
  font-size: 11px;
  color: var(--text-secondary);
  margin-top: 2px;
  line-height: 1.4;
  word-break: break-all;
}
.sidebar-user-actions {
  display: flex;
  gap: 6px;
  margin-top: 10px;
  flex-wrap: wrap;
}

/* ===== 登录页 ===== */
.login-body {
  background: linear-gradient(135deg, #FBF9F4 0%, #F3EADA 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
}
.login-wrap {
  width: 100%;
  padding: 24px;
  display: flex;
  justify-content: center;
}
.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 36px 32px 28px;
  box-shadow: 0 12px 40px rgba(74, 63, 53, 0.12);
}
.login-brand {
  text-align: center;
  margin-bottom: 28px;
}
.login-logo {
  font-size: 24px;
  font-weight: 700;
  color: var(--primary);
  letter-spacing: 2px;
}
.login-sub {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 6px;
}
.login-btn {
  width: 100%;
  padding: 11px 18px;
  font-size: 15px;
  margin-top: 6px;
}
.login-msg {
  min-height: 20px;
  margin-top: 12px;
  font-size: 13px;
  color: var(--success);
  text-align: center;
}
.login-msg-error {
  color: var(--danger);
}
.login-foot {
  margin-top: 22px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-secondary);
  text-align: center;
  line-height: 1.8;
}

/* ===== 通用小元素 ===== */
.form-hint {
  font-size: 12px;
  color: var(--text-secondary);
  font-weight: 400;
}
.muted {
  color: var(--text-secondary);
  font-size: 12px;
}
.hint-bar {
  background: #FAF7F0;
  border-left: 3px solid var(--primary-light);
  border-radius: 4px;
  padding: 10px 14px;
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 16px;
  line-height: 1.7;
}
.row-actions {
  white-space: nowrap;
}
.card {
  overflow-x: auto;
}

/* ===== 商品缩略图 / 标签 ===== */
.thumb {
  width: 44px;
  height: 44px;
  border-radius: 6px;
  object-fit: cover;
  border: 1px solid var(--border);
  background: #F5F0E8;
  display: block;
}
.thumb-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  color: var(--text-secondary);
}
.tag-rec,
.tag-self,
.tag-owner {
  display: inline-block;
  padding: 1px 7px;
  border-radius: 10px;
  font-size: 11px;
  vertical-align: middle;
}
.tag-rec {
  background: #FFF4E0;
  color: var(--primary);
}
.tag-self {
  background: #E8F0FF;
  color: #2E7BD6;
}
.tag-owner {
  background: #FFF0E0;
  color: var(--primary-dark);
  font-weight: 600;
}

/* ===== 分页 ===== */
.pager {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 16px;
}
.pager-info {
  font-size: 13px;
  color: var(--text-secondary);
  margin-right: auto;
}
.pager .btn[disabled] {
  opacity: 0.45;
  cursor: not-allowed;
}

/* ===== 订单详情 ===== */
.detail-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px 20px;
  padding: 20px 24px 4px;
  font-size: 14px;
}
.detail-grid > div {
  line-height: 1.7;
  word-break: break-all;
}
.order-total {
  padding: 12px 24px 20px;
  text-align: right;
  font-size: 14px;
  color: var(--text-secondary);
}
.order-total strong {
  font-size: 20px;
  color: var(--primary);
  margin-left: 6px;
}
#orderModalBody .table {
  margin: 0 24px;
  width: calc(100% - 48px);
}
#orderModalBody .hint-bar {
  margin: 12px 24px 0;
}

/* ===== 权限勾选 ===== */
.perm-list {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}
.perm-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border: 1px solid var(--border);
  border-radius: 20px;
  font-size: 13px;
  cursor: pointer;
  user-select: none;
  transition: all 0.2s;
}
.perm-item:hover {
  border-color: var(--primary-light);
}
.perm-item input {
  width: 14px;
  height: 14px;
  accent-color: var(--primary);
  cursor: pointer;
}

/* ===== Banner 上传预览 ===== */
.banner-upload-preview {
  width: 160px;
  height: 80px;
  border: 1px dashed var(--border);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background: #FAF9F5;
  flex: 0 0 auto;
}
.banner-upload-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* ===== 全局 Loading ===== */
.loading {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(251, 249, 244, 0.55);
  z-index: 400;
  align-items: center;
  justify-content: center;
}
.loading.active {
  display: flex;
}
.loading-box {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px 30px;
  font-size: 14px;
  color: var(--text-secondary);
  box-shadow: 0 8px 24px rgba(74, 63, 53, 0.14);
}

/* ===== 批量导入商品 ===== */
.import-steps {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.9;
}
.import-step {
  display: flex;
  align-items: baseline;
  gap: 8px;
}
.import-step b {
  flex: 0 0 18px;
  width: 18px;
  height: 18px;
  line-height: 18px;
  text-align: center;
  border-radius: 50%;
  background: #BA7517;
  color: #fff;
  font-size: 12px;
  font-weight: 400;
  transform: translateY(2px);
}
.import-report-block {
  border-radius: 6px;
  padding: 10px 14px;
  margin-bottom: 8px;
  font-size: 13px;
  line-height: 1.7;
}
.import-report-block ul {
  margin: 6px 0 0 18px;
  padding: 0;
}
.import-report-block li {
  margin: 3px 0;
}
.import-report-block.is-ok {
  background: #f0f9eb;
  border: 1px solid #c2e7b0;
}
.import-report-block.is-error {
  background: #fef0f0;
  border: 1px solid #fbc4c4;
}
.import-report-block.is-warn {
  background: #fdf6ec;
  border: 1px solid #f5dab1;
}

/* ============================================================
   库存管理 / 备货单 / 供货商 / 商品码（2026-09-30 新增）
   ============================================================ */

/* 子标签页 */
.subtabs {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
}
.subtab {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  padding: 9px 16px;
  font-size: 14px;
  color: var(--text-secondary);
  cursor: pointer;
  font-family: inherit;
}
.subtab:hover { color: var(--primary); }
.subtab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
  font-weight: 600;
}
.subpanel { display: none; }
.subpanel.active { display: block; }

/* 汇总卡 */
.stat-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 16px;
}
.stat-card {
  flex: 1 1 150px;
  min-width: 150px;
  background: #FAF7F0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
}
.stat-card .k {
  font-size: 12px;
  color: var(--text-secondary);
  display: block;
}
.stat-card .v {
  font-size: 20px;
  font-weight: 700;
  color: var(--primary);
  line-height: 1.4;
}

/* 表单底部操作区 */
.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 20px;
}

/* 流水变动着色 / 欠货标红 */
.qty-plus { color: var(--success); font-weight: 600; }
.qty-minus { color: var(--danger); font-weight: 600; }
.stock-negative { color: var(--danger); font-weight: 700; }
.muted { color: var(--text-secondary); }

/* 商品码标签：横排（左小程序码、右商品信息） */
.label-grid {
  display: grid;
  gap: 16px;
  margin-top: 8px;
}
.label {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 12px;
  border: 1px dashed #D9C9A6;
  background: #fff;
  border-radius: var(--radius);
  padding: 12px 14px;
  text-align: left;
  page-break-inside: avoid;
}
.label img {
  width: 110px;
  height: 110px;
  border: 1px solid var(--border);
  border-radius: 4px;
  flex: 0 0 auto;
  display: block;
}
.label .info {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.label .name { font-size: 15px; font-weight: 700; line-height: 1.3; }
.label .spec { font-size: 11px; color: var(--text-secondary); margin-top: 3px; }
.label .price { font-size: 16px; color: var(--primary); font-weight: 700; margin-top: 4px; }
.label .tip { font-size: 10px; color: var(--primary); margin-top: 6px; }
.label .code {
  font-size: 10px;
  color: var(--text-secondary);
  margin-top: 2px;
  font-family: Consolas, monospace;
}

/* 商品码弹窗里的商品勾选列表 */
.code-product-list {
  max-height: 180px;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 8px 12px;
  margin-bottom: 12px;
}
.code-pick {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  width: 48%;
  font-size: 13px;
  padding: 3px 0;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* 打印标签：隐藏后台框架，只留标签网格 */
@media print {
  .sidebar, .panel-header, .hint-bar, .subtabs,
  .table-toolbar, .form-actions, .modal-header, .modal-close { display: none !important; }
  .main-content { margin: 0 !important; padding: 0 !important; }
  .modal { max-width: none !important; box-shadow: none !important; }
  .modal-overlay { position: static !important; background: none !important; padding: 0 !important; }
}
