/* ============================================
   脱水蔬菜订货系统 - Web 管理后台
   设计方向：有机自然实用主义
   ============================================ */

/* --- CSS Variables --- */
:root {
  --green: #4a7c3f;
  --green-light: #5d9a4f;
  --green-pale: #e8f3e4;
  --amber: #d4952a;
  --amber-light: #fdf3e0;
  --bg: #f7f3eb;
  --surface: #ffffff;
  --text: #3d3226;
  --text-subtle: #6b5e4f;
  --text-muted: #9a8d7f;
  --border: #e0d5c1;
  --border-light: #efe8da;
  --red: #c0392b;
  --red-pale: #fce8e6;
  --blue: #2e6b8a;
  --blue-pale: #e3f0f7;
  --radius: 8px;
  --radius-sm: 5px;
  --shadow-sm: 0 1px 3px rgba(61,50,38,0.06);
  --shadow: 0 2px 8px rgba(61,50,38,0.08);
  --font-heading: 'Georgia', 'Times New Roman', 'Noto Serif SC', serif;
  --font-body: 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', system-ui, sans-serif;
  --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

/* --- Reset & Base --- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;   /* 页面级横向滚动条兜底：任何内容不撑出页面，宽内容在自身容器内滚动 */
}

a { color: var(--green); text-decoration: none; }
a:hover { color: var(--green-light); }

/* --- Layout --- */
.layout { display: flex; min-height: 100vh; min-width: 0; }

/* --- Sidebar --- */
.sidebar {
  width: 220px;
  background: linear-gradient(180deg, #3d5a2e 0%, #2d4420 100%);
  color: #e8e0d0;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  box-shadow: 2px 0 12px rgba(0,0,0,0.15);
}

.sidebar-brand {
  padding: 24px 20px 20px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  position: relative;
}
.sidebar-brand h1 {
  font-family: var(--font-heading);
  font-size: 18px;
  font-weight: 700;
  color: #fff;
  letter-spacing: 0.5px;
}
.sidebar-brand .subtitle {
  font-size: 11px;
  color: rgba(255,255,255,0.5);
  margin-top: 4px;
}

/* 侧边栏收起/展开按钮 */
.sidebar-toggle {
  position: absolute;
  top: 12px;
  right: 10px;
  width: 26px;
  height: 26px;
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 6px;
  background: rgba(255,255,255,0.08);
  color: rgba(255,255,255,0.7);
  font-size: 11px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  line-height: 1;
}
.sidebar-toggle:hover { background: rgba(255,255,255,0.2); color: #fff; }

/* 侧边栏整体收起（只显示图标） */
body.sidebar-collapsed .sidebar { width: 60px; }
body.sidebar-collapsed .main { margin-left: 60px; }
body.sidebar-collapsed .sidebar-brand { padding: 22px 4px; text-align: center; }
body.sidebar-collapsed .sidebar-brand h1,
body.sidebar-collapsed .sidebar-brand .subtitle,
body.sidebar-collapsed .nav-section,
body.sidebar-collapsed .sidebar-footer { display: none; }
/* 导航项文字用 font-size:0 隐藏（裸文本节点无需包 span），图标单独恢复字号 */
body.sidebar-collapsed .nav-item { font-size: 0; justify-content: center; padding: 12px 0; margin: 2px 6px; width: calc(100% - 12px); gap: 0; }
body.sidebar-collapsed .nav-item .icon { width: auto; font-size: 17px; }
body.sidebar-collapsed .nav-item .badge { display: none; }
body.sidebar-collapsed .sidebar-toggle { position: static; margin: 0 auto; }
body.sidebar-collapsed .sidebar-nav { padding: 8px 0; }

.sidebar-nav {
  flex: 1;
  padding: 12px 0;
  overflow-y: auto;
}
.sidebar-nav::-webkit-scrollbar { width: 4px; }
.sidebar-nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); border-radius: 2px; }

/* 分组标题（可折叠）——字号与功能模块一致（13.5px），避免看不清 */
.nav-section {
  padding: 18px 20px 8px;
  font-size: 13.5px;
  text-transform: none;
  letter-spacing: 0.3px;
  color: rgba(255,255,255,0.55);
  font-weight: 600;
  cursor: pointer;
  user-select: none;
  display: flex;
  align-items: center;
  gap: 6px;
}
.nav-section:hover { color: rgba(255,255,255,0.6); }
.nav-section .nav-arrow {
  font-size: 9px;
  opacity: 0.7;
  transition: transform 0.2s;
}
.nav-section.collapsed .nav-arrow { transform: rotate(-90deg); }

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 20px;
  margin: 2px 8px;
  border-radius: var(--radius-sm);
  color: rgba(255,255,255,0.7);
  cursor: pointer;
  transition: all var(--transition);
  font-size: 13.5px;
  border: none;
  background: none;
  width: calc(100% - 16px);
  text-align: left;
  font-family: var(--font-body);
}
.nav-item:hover {
  background: rgba(255,255,255,0.08);
  color: #fff;
}
.nav-item.active {
  background: rgba(255,255,255,0.15);
  color: #fff;
  font-weight: 600;
}

.nav-item .icon { font-size: 16px; width: 20px; text-align: center; flex-shrink: 0; }
.nav-item .badge {
  margin-left: auto;
  background: var(--red);
  color: #fff;
  font-size: 10px;
  padding: 2px 7px;
  border-radius: 10px;
  font-weight: 600;
}

.sidebar-footer {
  padding: 12px 20px;
  border-top: 1px solid rgba(255,255,255,0.08);
  font-size: 12px;
  color: rgba(255,255,255,0.4);
}

/* --- Main Content --- */
.main {
  flex: 1;
  margin-left: 220px;
  padding: 0;
  min-height: 100vh;
  min-width: 0;   /* flex 子项防内容撑宽（宽表格等不再撑出页面滚动条） */
}

/* --- Top Bar --- */
.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border-light);
  padding: 14px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: var(--shadow-sm);
  min-width: 0;
  /* 注意：不能设 overflow:hidden —— 会裁剪管理员下拉菜单/… 菜单（绝对定位子元素）
     横向滚动条由 body overflow-x:hidden + .main min-width:0 兜底（v215） */
}
.page-title {
  font-family: var(--font-heading);
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  flex-shrink: 0;
  margin-right: 14px;
  white-space: nowrap;
}
.topbar-actions {
  display: flex;
  align-items: center;
  gap: 16px;
  font-size: 13px;
  color: var(--text-subtle);
}

/* --- Content Area --- */
.content { padding: 24px 28px 40px; min-width: 0; }
.page { display: none; }
.page.active { display: block; }

/* --- Stats Grid --- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  padding: 20px 22px;
  transition: all var(--transition);
}
.stat-card:hover {
  border-color: var(--green);
  box-shadow: var(--shadow);
}
.stat-card .stat-label {
  font-size: 12px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 6px;
}
.stat-card .stat-value {
  font-family: var(--font-heading);
  font-size: 28px;
  font-weight: 700;
  color: var(--text);
}
.stat-card.amber .stat-value { color: var(--amber); }
.stat-card.red .stat-value { color: var(--red); }
.stat-card.blue .stat-value { color: var(--blue); }
.stat-card.green .stat-value { color: var(--green); }
.stat-card .stat-sub {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* --- Cards --- */
.card {
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  margin-bottom: 20px;
}

.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.card-header h3 {
  font-family: var(--font-heading);
  font-size: 15px;
  font-weight: 600;
}

.card-body { padding: 20px; }
.card-body.no-padding { padding: 0; }

/* --- Tables --- */
.table-wrap { overflow-x: auto; }
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
th {
  background: #faf7f1;
  padding: 12px 16px;
  text-align: left;
  font-weight: 600;
  color: var(--text-subtle);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  border-bottom: 1px solid var(--border-light);
  white-space: nowrap;
}
td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-light);
  color: var(--text);
  vertical-align: middle;
}
tr:last-child td { border-bottom: none; }
tr:hover td { background: #fdfbf7; }

/* --- Buttons --- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 18px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all var(--transition);
  font-family: var(--font-body);
  white-space: nowrap;
  line-height: 1.4;
}
.btn:active { transform: scale(0.97); }

.btn-primary {
  background: var(--green);
  color: #fff;
  border-color: var(--green);
}
.btn-primary:hover { background: var(--green-light); }

.btn-outline {
  background: transparent;
  color: var(--green);
  border-color: var(--green);
}
.btn-outline:hover { background: var(--green-pale); }

.btn-danger {
  background: var(--red);
  color: #fff;
  border-color: var(--red);
}
.btn-danger:hover { background: #a93226; }

.btn-sm { padding: 5px 12px; font-size: 12px; }

.btn-ghost {
  background: transparent;
  color: var(--text-subtle);
  padding: 4px 8px;
}
.btn-ghost:hover { background: var(--bg); color: var(--text); }

/* --- Status Badges --- */
.status {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
}
.status-pending { background: var(--amber-light); color: var(--amber); }
.status-shipped { background: var(--blue-pale); color: var(--blue); }
.status-completed { background: var(--green-pale); color: var(--green); }
.status-cancelled { background: var(--red-pale); color: var(--red); }

.status-text {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
}
.status-on { background: var(--green-pale); color: var(--green); }
.status-off { background: #f0ece6; color: var(--text-muted); }

/* --- Forms --- */
.form-group { margin-bottom: 16px; }
.form-group label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-subtle);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-family: var(--font-body);
  color: var(--text);
  background: var(--surface);
  transition: border-color var(--transition);
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--green);
  box-shadow: 0 0 0 2px var(--green-pale);
}
.form-group textarea { resize: vertical; min-height: 80px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }

.form-hint {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 4px;
}

/* --- Search Bar --- */
.search-bar {
  display: flex;
  gap: 10px;
  margin-bottom: 20px;
  align-items: center;
  flex-wrap: wrap;
}
.search-bar input {
  flex: 1;
  min-width: 200px;
  max-width: 320px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-family: var(--font-body);
  background: var(--surface);
}
.search-bar input:focus { outline: none; border-color: var(--green); }
.search-bar select {
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-family: var(--font-body);
  background: var(--surface);
}

/* --- Empty State --- */
.empty-state {
  text-align: center;
  padding: 48px 20px;
  color: var(--text-muted);
}
.empty-state .empty-icon { font-size: 40px; margin-bottom: 12px; }
.empty-state p { font-size: 13px; }

/* --- Modal --- */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(30,25,18,0.5);
  z-index: 1500;             /* 高于登录页(1000)，登录页扫码弹窗才能显示 */
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal-overlay.show {
  display: flex;
}
.modal {
  background: var(--surface);
  border-radius: var(--radius);
  width: 100%;
  max-width: 1100px;            /* 加宽，让批量打单弹窗一行排开 */
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: 0 8px 32px rgba(0,0,0,0.2);
}
.modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal-header h3 { font-family: var(--font-heading); font-size: 16px; }
.modal-close {
  background: none;
  border: none;
  font-size: 22px;
  cursor: pointer;
  color: var(--text-muted);
  padding: 0 4px;
  line-height: 1;
}
.modal-close:hover { color: var(--text); }
.modal-body { padding: 20px; }
.modal-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--border-light);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

/* --- 手工建单表单布局 --- */
.mc-container {
  width: 600px;
  max-width: 100%;
}
.mc-row {
  margin-bottom: 14px;
}
.mc-row > label {
  display: block;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--text);
  font-size: 14px;
}
.mc-row .modal-input {
  width: 100%;
  box-sizing: border-box;
  min-height: 40px;
  padding: 8px 12px;
  border: 1px solid var(--border, #e5e7eb);
  border-radius: 8px;
  font-size: 14px;
}
.mc-row-flex {
  display: flex;
  gap: 12px;
}
.mc-row-flex > .mc-field {
  flex: 1;
  min-width: 0;
}
.mc-results {
  margin-top: 8px;
}
.mc-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 10px;
  margin-top: 6px;
  border-top: 1px solid var(--border-light);
}
.mc-cart-line {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
  border-bottom: 1px solid #f3f4f6;
}
.mc-cart-line > .mc-name {
  flex: 1;
  font-size: 13px;
  word-break: break-all;
}
.mc-cart-line > .mc-num {
  width: 80px;
  padding: 4px 6px;
  border: 1px solid var(--border, #e5e7eb);
  border-radius: 6px;
  font-size: 13px;
  box-sizing: border-box;
}
.mc-cart-line > .mc-qty {
  width: 60px;
  padding: 4px 6px;
  border: 1px solid var(--border, #e5e7eb);
  border-radius: 6px;
  font-size: 13px;
  box-sizing: border-box;
}
.mc-cart-line > .mc-subtotal {
  width: 90px;
  text-align: right;
  font-size: 13px;
}
.mc-result-item { cursor: pointer; padding: 8px 10px; border: 1px solid var(--border, #e5e7eb); border-radius: 8px; margin-bottom: 6px; }
.mc-result-item:hover { background: #f9fafb; }
.mc-selected {
  padding: 8px 10px;
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  border-radius: 8px;
  font-size: 13px;
  margin-top: 8px;
}

/* --- Alert / Inactive --- */
.inactive-list { list-style: none; }
.inactive-item {
  padding: 14px 20px;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.inactive-item:last-child { border-bottom: none; }
.inactive-item .customer-info { flex: 1; min-width: 180px; }
.inactive-item .customer-name { font-weight: 600; font-size: 14px; }
.inactive-item .customer-company { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.inactive-item .days-badge {
  padding: 4px 14px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}
.days-danger { background: var(--red-pale); color: var(--red); }
.days-warning { background: var(--amber-light); color: var(--amber); }
.days-info { background: var(--blue-pale); color: var(--blue); }

/* --- Filter Pills --- */
.filter-pills {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.pill {
  padding: 5px 14px;
  border-radius: 16px;
  font-size: 12px;
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-subtle);
  transition: all var(--transition);
  font-family: var(--font-body);
}
.pill:hover { border-color: var(--green); color: var(--green); }
.pill.active { background: var(--green); color: #fff; border-color: var(--green); }

/* --- Price Tag --- */
.price-normal { color: var(--text); font-weight: 600; }
.price-custom { color: var(--amber); font-weight: 600; }
.price-original { text-decoration: line-through; color: var(--text-muted); font-size: 12px; margin-right: 6px; }

/* --- Order detail --- */
.order-detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 20px;
}
.detail-block h4 {
  font-family: var(--font-heading);
  font-size: 13px;
  margin-bottom: 8px;
  color: var(--text-subtle);
}
.detail-block p { font-size: 13px; margin-bottom: 3px; }

/* --- Stats Tabs --- */
.stats-tabs {
  display: flex;
  gap: 0;
  margin-bottom: 20px;
  border-bottom: 2px solid var(--border-light);
}
.stats-tab {
  padding: 10px 24px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  border: none;
  background: none;
  font-family: var(--font-body);
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: all var(--transition);
}
.stats-tab:hover { color: var(--text); }
.stats-tab.active {
  color: var(--green);
  border-bottom-color: var(--green);
}

/* --- Highlight Number --- */
.highlight-num {
  font-family: var(--font-heading);
  font-size: 22px;
  font-weight: 700;
}
.highlight-num.green { color: var(--green); }
.highlight-num.amber { color: var(--amber); }
.highlight-num.red { color: var(--red); }
.highlight-num.blue { color: var(--blue); }

/* --- Stat Row (for top summary cards in stats page) --- */
.stat-summary-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}
.stat-summary-card {
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  padding: 18px 20px;
}
.stat-summary-card .ss-label {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 4px;
}
.stat-summary-card .ss-value {
  font-family: var(--font-heading);
  font-size: 24px;
  font-weight: 700;
}

/* --- Product Distribution Bar --- */
.dist-bar-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 6px;
}
.dist-bar-label {
  width: 90px;
  font-size: 12px;
  color: var(--text-subtle);
  text-align: right;
  flex-shrink: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.dist-bar-track {
  flex: 1;
  height: 20px;
  background: var(--bg);
  border-radius: 10px;
  overflow: hidden;
}
.dist-bar-fill {
  height: 100%;
  border-radius: 10px;
  transition: width 0.5s ease;
}
.dist-bar-val {
  width: 80px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  flex-shrink: 0;
}

/* --- Period Filter Bar --- */
.period-filter-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
  padding: 14px 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  flex-wrap: wrap;
}
.period-label {
  font-size: 13px;
  color: var(--text-subtle);
  font-weight: 600;
  white-space: nowrap;
}
.period-mode-group {
  display: flex;
  gap: 4px;
  background: var(--bg);
  border-radius: 8px;
  padding: 3px;
}
.pmode {
  padding: 6px 16px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  background: transparent;
  color: var(--text-subtle);
  transition: all var(--transition);
  font-family: var(--font-body);
}
.pmode:hover { color: var(--green); }
.pmode.active {
  background: var(--green);
  color: #fff;
  box-shadow: 0 1px 3px rgba(76, 175, 80, 0.25);
}
.period-select {
  padding: 6px 32px 6px 12px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 13px;
  font-family: var(--font-body);
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%23666'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  min-width: 130px;
  outline: none;
  transition: border-color var(--transition);
}
.period-select:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 2px rgba(76, 175, 80, 0.1);
}

/* --- Monthly Trend Chart --- */
.trend-summary {
  text-align: center;
  font-size: 12px;
  color: var(--text-subtle);
  margin-bottom: 20px;
}
.trend-summary strong {
  color: var(--text);
  font-family: var(--font-heading);
}
.trend-chart {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 24px;
  height: 200px;
  padding: 0 20px 10px;
  border-bottom: 1px solid var(--border-light);
}
.trend-bar-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 1;
  max-width: 80px;
  height: 100%;
}
.trend-bar-val {
  font-size: 10px;
  color: var(--text-muted);
  font-weight: 600;
  margin-bottom: 4px;
  white-space: nowrap;
}
.trend-bar-wrap {
  flex: 1;
  width: 36px;
  background: var(--bg);
  border-radius: 6px 6px 0 0;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  overflow: hidden;
}
.trend-bar-fill {
  width: 100%;
  border-radius: 6px 6px 0 0;
  transition: height 0.5s ease;
  min-height: 4px;
}
.trend-bar-month {
  font-size: 11px;
  color: var(--text-subtle);
  font-weight: 600;
  margin-top: 6px;
}

/* --- SMS Section --- */
.sms-section {
  margin-top: 20px;
  padding-top: 20px;
  border-top: 1px solid var(--border-light);
}
.sms-section h4 {
  font-family: var(--font-heading);
  font-size: 14px;
  margin-bottom: 12px;
}
.sms-log-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid var(--border-light);
  font-size: 13px;
  gap: 12px;
  flex-wrap: wrap;
}
.sms-log-item:last-child { border-bottom: none; }
.sms-log-info { flex: 1; min-width: 150px; }
.sms-log-info strong { display: block; }
.sms-log-info span { font-size: 11px; color: var(--text-muted); }
.sms-log-status {
  padding: 3px 10px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}
.sms-log-status.success { background: var(--green-pale); color: var(--green); }
.sms-log-status.pending { background: var(--amber-light); color: var(--amber); }

/* SMS Template Preview */
.sms-preview {
  background: #f5f0e8;
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  font-size: 13px;
  color: var(--text);
  line-height: 1.8;
  margin: 12px 0;
  white-space: pre-wrap;
  font-family: var(--font-body);
}

/* SMS Toast (larger, on top) */
.sms-toast {
  position: fixed;
  top: 80px;
  right: 20px;
  background: var(--green);
  color: #fff;
  padding: 12px 20px;
  border-radius: var(--radius);
  font-size: 13px;
  z-index: 400;
  box-shadow: 0 4px 16px rgba(0,0,0,0.2);
  transform: translateX(120%);
  transition: transform 0.3s ease;
}
.sms-toast.show { transform: translateX(0); }

/* --- Toast --- */
.toast {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: #2d4420;
  color: #fff;
  padding: 10px 24px;
  border-radius: var(--radius);
  font-size: 13px;
  z-index: 2000;   /* 高于弹窗(1500)：弹窗内的异常提示必须可见 */
  opacity: 0;
  transition: opacity 0.3s, transform 0.3s;
  pointer-events: none;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* --- Responsive --- */
@media (max-width: 900px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .form-row, .form-row-3 { grid-template-columns: 1fr; }
  .order-detail-grid { grid-template-columns: 1fr; }
  .sidebar { width: 180px; }
  .main { margin-left: 180px; }
}
@media (max-width: 640px) {
  .sidebar { display: none; }
  .main { margin-left: 0; }
  .content { padding: 16px; }
  .topbar { padding: 12px 16px; }
  .stats-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
}

/* === 商品图片上传 === */
.product-image-upload {
  margin-bottom: 20px;
}

.image-upload-area {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: var(--transition);
}

.image-upload-area:hover {
  border-color: var(--green-light);
  background: var(--green-pale);
}

.image-preview-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 20px;
  gap: 16px;
}

.image-preview-img {
  width: 200px;
  height: 200px;
  object-fit: cover;
  border-radius: var(--radius);
  border: 1px solid var(--border-light);
}

.image-preview-actions {
  display: flex;
  gap: 10px;
}

.image-upload-prompt {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
  cursor: pointer;
  gap: 8px;
}

.upload-icon {
  font-size: 48px;
  opacity: 0.5;
}

.upload-text {
  font-size: 15px;
  color: var(--text);
  font-weight: 500;
}

.upload-hint {
  font-size: 12px;
  color: var(--text-muted);
}

.upload-tip {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 8px;
  text-align: center;
}

/* === 多图画廊上传 === */
.multi-image-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 8px;
}

.multi-image-item {
  position: relative;
  width: 120px;
  height: 120px;
  border-radius: 8px;
  overflow: hidden;
  border: 2px solid var(--border-light);
  transition: var(--transition);
}

.multi-image-item.is-main {
  border: 3px solid var(--green);
  box-shadow: 0 2px 12px rgba(76, 175, 80, 0.3);
}

.multi-image-thumb {
  width: 100%;
  height: 100%;
  object-fit: cover;
  cursor: pointer;
}

.multi-image-badge {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--green);
  color: #fff;
  font-size: 11px;
  text-align: center;
  padding: 3px 0;
  font-weight: 600;
}

.multi-image-setmain {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(0, 0, 0, 0.6);
  color: #fff;
  font-size: 11px;
  text-align: center;
  padding: 4px 0;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.2s;
}

.multi-image-item:hover .multi-image-setmain {
  opacity: 1;
}

.multi-image-remove {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 22px;
  height: 22px;
  background: rgba(0, 0, 0, 0.6);
  color: #fff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.2s;
}

.multi-image-item:hover .multi-image-remove {
  opacity: 1;
}

.multi-upload-btn {
  width: 120px;
  height: 120px;
  border: 2px dashed var(--border);
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  gap: 4px;
  transition: var(--transition);
  background: var(--bg-alt, #fafafa);
}

.multi-upload-btn:hover {
  border-color: var(--green);
  background: var(--green-pale);
}

.multi-upload-btn .upload-icon {
  font-size: 32px;
  opacity: 0.5;
}

.multi-upload-btn .upload-text {
  font-size: 13px;
  color: var(--text);
  font-weight: 500;
}

.multi-upload-btn .upload-hint {
  font-size: 11px;
  color: var(--text-muted);
}

/* === 商品列表缩略图 === */
.product-thumb {
  width: 48px;
  height: 48px;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid var(--border-light);
  vertical-align: middle;
}

.product-thumb-placeholder {
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--green-pale);
  border-radius: 6px;
  font-size: 24px;
}

/* === 登录页 === */
.login-page {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
  background: linear-gradient(160deg, #f0ead8 0%, #e3efdc 100%);
  padding: 24px;
}

.login-page::before {
  content: '';
  position: absolute;
  top: -80px;
  right: -80px;
  width: 320px;
  height: 320px;
  border-radius: 50%;
  background: rgba(122, 165, 100, 0.14);
  pointer-events: none;
}

.login-page::after {
  content: '';
  position: absolute;
  bottom: -60px;
  left: -60px;
  width: 240px;
  height: 240px;
  border-radius: 50%;
  background: rgba(212, 149, 42, 0.10);
  pointer-events: none;
}

.login-card {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border-radius: 16px;
  padding: 40px 36px 32px;
  box-shadow: 0 12px 40px rgba(61, 50, 38, 0.14);
  border: 1px solid var(--border-light);
  text-align: center;
}

.login-brand { margin-bottom: 28px; }

.login-logo {
  width: 64px;
  height: 64px;
  margin: 0 auto 12px;
  background: var(--green-pale);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
}

.login-brand h1 {
  font-family: var(--font-heading);
  font-size: 20px;
  color: var(--text);
  margin-bottom: 4px;
}

.login-brand p {
  font-size: 13px;
  color: var(--text-muted);
}

.login-section {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 8px;
}

.login-wx-btn {
  width: 100%;
  padding: 12px;
  font-size: 15px;
}

.login-tip {
  font-size: 12px;
  color: var(--text-muted);
}

.login-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 20px 0 16px;
  color: var(--text-muted);
  font-size: 12px;
}

.login-divider::before,
.login-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

.login-input {
  width: 100%;
  padding: 11px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
  background: #fdfcf9;
  transition: var(--transition);
}

.login-input:focus {
  outline: none;
  border-color: var(--green);
  background: #fff;
}

.login-submit-btn {
  width: 100%;
  padding: 11px;
  font-size: 14px;
}

.login-msg {
  min-height: 20px;
  margin-top: 14px;
  font-size: 13px;
  color: var(--green);
}

.login-msg.error {
  color: var(--red);
}

/* 测试环境登录页标识 */
.login-env-tag {
  margin-top: 14px;
  padding: 6px 12px;
  background: #FCEBEB;
  border: 1px solid #F09595;
  color: #A32D2D;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 500;
  text-align: center;
}

/* 登录页版本号 */
.login-version {
  margin-top: 20px;
  padding-top: 14px;
  border-top: 1px solid var(--border-light);
  font-size: 11px;
  color: var(--text-muted);
  font-family: var(--font-mono, monospace);
  letter-spacing: 0.5px;
}

/* 网站备案号（登录页底部） */
.login-beian {
  margin-top: 12px;
  text-align: center;
  font-size: 11px;
  color: var(--text-muted);
}
.login-beian a {
  color: var(--text-muted);
  text-decoration: none;
}
.login-beian a:hover {
  color: #2f7d3a;
  text-decoration: underline;
}

/* 顶部管理员名 */
.topbar-admin {
  font-weight: 500;
  margin-right: 8px;
}

/* === 右上角管理员下拉菜单 === */
.admin-menu-wrap {
  position: relative;
}

.admin-menu-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  cursor: pointer;
  font-family: var(--font-body);
  font-size: 13px;
  color: var(--text);
  transition: var(--transition);
}

.admin-menu-btn:hover {
  border-color: var(--green);
  background: var(--green-pale);
}

.admin-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: linear-gradient(135deg, #58a054, #2f6b43);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  line-height: 1;
  flex-shrink: 0;
}

.admin-name {
  font-weight: 500;
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.admin-caret {
  font-size: 10px;
  color: var(--text-muted);
}

.admin-dropdown {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  min-width: 200px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 8px 30px rgba(61, 50, 38, 0.16);
  padding: 8px;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-6px);
  transition: all 0.18s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 200;
}

.admin-dropdown.show {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.admin-dropdown-header {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border-light);
  margin-bottom: 6px;
}

.admin-dropdown-name {
  font-weight: 600;
  font-size: 14px;
  color: var(--text);
}

.admin-dropdown-role {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

.admin-dropdown-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 10px 12px;
  background: none;
  border: none;
  border-radius: 8px;
  font-family: var(--font-body);
  font-size: 13px;
  color: var(--text);
  cursor: pointer;
  transition: var(--transition);
}

.admin-dropdown-item:hover {
  background: var(--red-pale);
  color: var(--red);
}

/* 空数据引导 */
.empty-guide {
  text-align: center;
  padding: 48px 24px;
}

.empty-guide .guide-icon {
  font-size: 48px;
  margin-bottom: 12px;
}

.empty-guide h3 {
  font-size: 16px;
  margin-bottom: 8px;
  color: var(--text);
}

.empty-guide p {
  font-size: 13px;
  color: var(--text-muted);
  max-width: 420px;
  margin: 0 auto 16px;
  line-height: 1.7;
}

/* 自助注册标记 */
.tag-self {
  display: inline-block;
  margin-top: 4px;
  padding: 2px 8px;
  background: var(--blue-pale);
  color: var(--blue);
  font-size: 11px;
  border-radius: 4px;
  font-weight: normal;
}


/* ===== 多标签页（Tab）— 顶部导航条样式（topbar 内、头像同一行） ===== */
#tab-bar {
  display: flex;
  flex-wrap: nowrap;
  gap: 2px;
  align-items: center;
  flex: 1;
  min-width: 0;
  max-width: 100%;
  padding: 2px 4px;
  margin: 0 180px 0 0;   /* 右侧留 ~2 个 tab 宽，不顶到头像 */
  background: transparent;
  border-radius: 6px;
  overflow: hidden;   /* 横向溢出隐藏，末尾 … 菜单收容 */
  position: relative;
}
.tab-item {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px 3px 12px;
  font-size: 13px;
  line-height: 1.4;
  color: #6b7280;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 6px;
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
  flex-shrink: 0;     /* 防止压缩；溢出时由 _applyOverflow 收进 … 菜单 */
  transition: all .12s;
}
.tab-item:hover { background: rgba(0,0,0,.05); color: #1f2937; }
.tab-item.active {
  background: #2563eb;
  border-color: #2563eb;
  color: #fff;
  font-weight: 600;
  box-shadow: 0 2px 6px rgba(37,99,235,.35);
}
.tab-item.active .tab-close:hover { background: rgba(255,255,255,.25); }
.tab-item .tab-close {
  font-style: normal;
  font-size: 14px;
  line-height: 1;
  padding: 0 3px;
  opacity: .45;
  border-radius: 3px;
  margin-left: 2px;
}
.tab-item .tab-close:hover { opacity: 1; background: rgba(0,0,0,.08); }
.tab-overflow {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 3px 10px;
  font-size: 14px;
  line-height: 1;
  color: #6b7280;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 6px;
  cursor: pointer;
  user-select: none;
  flex-shrink: 0;
  letter-spacing: 1px;
}
.tab-overflow:hover { background: rgba(0,0,0,.06); color: #111827; }
.tab-overflow-menu {
  position: fixed;   /* fixed：脱离 topbar/#tab-bar 的 overflow 裁剪 */
  min-width: 180px;
  max-width: 260px;
  max-height: 320px;
  overflow-y: auto;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,.14);
  z-index: 1000;
  padding: 4px;
}
.tab-overflow-menu .menu-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  font-size: 13px;
  color: #1f2937;
  border-radius: 4px;
  cursor: pointer;
  white-space: nowrap;
}
.tab-overflow-menu .menu-item:hover { background: #f3f4f6; }
.tab-overflow-menu .menu-item.active { background: #eff6ff; color: #1d4ed8; font-weight: 500; }
.tab-overflow-menu .menu-item .menu-close {
  margin-left: auto;
  font-size: 14px;
  opacity: .4;
  padding: 0 4px;
  border-radius: 3px;
}
.tab-overflow-menu .menu-item .menu-close:hover { opacity: 1; background: rgba(0,0,0,.08); }
.tab-overflow-menu .menu-divider {
  height: 1px;
  background: #e5e7eb;
  margin: 4px 0;
}

/* ===== 全局加载提示（云函数查询/保存时显示，屏幕中央淡入） ===== */
#global-loading-bar {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 9999;
  pointer-events: none;
  opacity: 0;
  transition: opacity .15s;
}
#global-loading-bar.show {
  opacity: 1;
}
#global-loading-bar .g-loading-inner {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  background: rgba(17, 24, 39, .9);
  color: #fff;
  font-size: 13px;
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0,0,0,.2);
}
#global-loading-bar .g-loading-spinner {
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255,255,255,.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: g-spin .7s linear infinite;
}
@keyframes g-spin { to { transform: rotate(360deg); } }
