/* ========== Reset & Base ========== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
@keyframes spin { to { transform: rotate(360deg); } }

:root {
  --primary: #ea580c; /* 从 #f97316 改为更深色，提升对比度 */
  --primary-dark: #c2410c;
  --primary-light: #fff7ed;
  --bg: #f1f5f9;
  --sidebar-bg: #1e2334;
  --sidebar-active: #ea580c;
  --card-bg: #ffffff;
  --text-primary: #1e293b;
  --text-secondary: #475569; /* 从 #64748b 改为更深的颜色，提升对比度 */
  --text-muted: #94a3b8;
  --border: #e2e8f0;
  --success: #10b981;
  --danger: #ef4444;
  --warning: #f59e0b;
  --info: #3b82f6;
  --sidebar-width: 220px;
  --topbar-height: 60px;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(0,0,0,.07), 0 4px 12px rgba(0,0,0,.05);
  --shadow-md: 0 4px 16px rgba(0,0,0,.1);
}

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text-primary);
  font-size: 14px;
  line-height: 1.5;
}

/* ========== Layout ========== */
.sidebar {
  position: fixed;
  left: 0; top: 0; bottom: 0;
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  z-index: 100;
  transition: transform .25s ease;
}

.main-wrapper {
  margin-left: var(--sidebar-width);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: margin-left .25s ease;
}

/* ========== Sidebar ========== */
.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 18px;
  border-bottom: 1px solid rgba(255,255,255,.07);
}

.logo-icon {
  width: 34px; height: 34px;
  background: var(--primary);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 18px; color: #fff;
  flex-shrink: 0;
}

.logo-text {
  font-weight: 700;
  font-size: 16px;
  color: #fff;
  letter-spacing: .5px;
}

.sidebar-nav {
  flex: 1;
  padding: 12px 10px;
  overflow-y: auto;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  color: rgba(255,255,255,.6);
  text-decoration: none;
  margin-bottom: 2px;
  transition: all .18s ease;
  font-size: 13.5px;
}

.nav-item svg {
  width: 18px; height: 18px;
  fill: currentColor;
  flex-shrink: 0;
}

.nav-item:hover {
  color: #fff;
  background: rgba(255,255,255,.07);
}

.nav-item.active {
  color: #fff;
  background: var(--primary);
}

.nav-divider {
  height: 1px;
  background: rgba(255,255,255,.07);
  margin: 10px 4px;
}

.sidebar-footer {
  padding: 14px 16px;
  border-top: 1px solid rgba(255,255,255,.07);
}

.last-update {
  font-size: 11px;
  color: rgba(255,255,255,.3);
}

/* ========== Topbar ========== */
.topbar {
  height: var(--topbar-height);
  background: var(--card-bg);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: 0 1px 4px rgba(0,0,0,.04);
}

.menu-toggle {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 6px;
  border-radius: 6px;
  color: var(--text-secondary);
}

.menu-toggle svg { width: 20px; height: 20px; fill: currentColor; }
.menu-toggle:hover { background: var(--bg); }

.topbar-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
  flex: 1;
  min-width: 0;          /* 允许 flex 子项压缩 */
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
  position: relative;   /* userMenu absolute 定位的父容器 */
}

.date-range select {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 7px 12px;
  font-size: 13px;
  color: var(--text-primary);
  background: var(--bg);
  cursor: pointer;
  outline: none;
}

.btn-primary {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background .18s;
}

.btn-primary svg { width: 15px; height: 15px; fill: currentColor; }
.btn-primary:hover { background: var(--primary-dark); }

.btn-secondary {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--bg);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all .18s;
}
.btn-secondary:hover { background: var(--border); }

/* ========== Main Content ========== */
.main-content {
  flex: 1;
  padding: 24px;
  overflow-y: auto;
}

/* ========== KPI Cards ========== */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.kpi-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
}

.kpi-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
}

.kpi-card.orange::before { background: var(--primary); }
.kpi-card.green::before  { background: var(--success); }
.kpi-card.red::before    { background: var(--danger); }
.kpi-card.blue::before   { background: var(--info); }
.kpi-card.yellow::before { background: var(--warning); }
.kpi-card.purple::before { background: #8b5cf6; }
.kpi-card.cyan::before   { background: #06b6d4; }

.kpi-label {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 8px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: .4px;
}

.kpi-value {
  font-size: 26px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.2;
  margin-bottom: 8px;
  word-break: break-all;
  overflow-wrap: break-word;
}

.kpi-change {
  font-size: 12px;
  display: flex;
  align-items: center;
  gap: 3px;
}

.kpi-change.up   { color: var(--success); }
.kpi-change.down { color: var(--danger); }
.kpi-change.flat { color: var(--text-muted); }

/* ========== Chart Cards ========== */
.chart-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
  gap: 20px;
  margin-bottom: 24px;
}

.chart-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}

.chart-card.full-width {
  grid-column: 1 / -1;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.card-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}

.card-subtitle {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

.card-actions {
  display: flex;
  gap: 6px;
}

.tag {
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 500;
}

.tag-success { background: #d1fae5; color: #059669; }
.tag-danger  { background: #fee2e2; color: #dc2626; }
.tag-warning { background: #fef3c7; color: #d97706; }
.tag-info    { background: #dbeafe; color: #2563eb; }
.tag-muted   { background: var(--bg); color: var(--text-muted); }

/* ========== Table ========== */
.table-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  margin-bottom: 24px;
}

.table-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}

.table-title {
  font-size: 14px;
  font-weight: 600;
}

.search-box {
  display: flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 12px;
  background: var(--bg);
}

.search-box input {
  border: none;
  background: none;
  outline: none;
  font-size: 13px;
  color: var(--text-primary);
  width: 200px;
}

.search-box svg { width: 14px; height: 14px; fill: var(--text-muted); }

.data-table {
  width: 100%;
  border-collapse: collapse;
}

.data-table th {
  background: var(--bg);
  padding: 10px 16px;
  text-align: left;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .4px;
  white-space: nowrap;
}

.data-table td {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  font-size: 13px;
  color: var(--text-primary);
}

.data-table tbody tr {
  transition: all 0.15s ease;
  cursor: pointer;
}

.data-table tbody tr:hover {
  background: #f1f5f9;
  transform: translateX(2px);
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}

.data-table tbody tr.selected {
  background: #fff7ed;
  border-left: 3px solid var(--primary);
}

.data-table tr:hover td { background: transparent; }

.table-img {
  width: 36px; height: 36px;
  border-radius: 6px;
  object-fit: cover;
  background: var(--bg);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
}

.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  border-top: 1px solid var(--border);
  font-size: 13px;
  color: var(--text-muted);
}

.pagination-btns {
  display: flex;
  gap: 4px;
}

.page-btn {
  width: 30px; height: 30px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: none;
  cursor: pointer;
  font-size: 13px;
  display: flex; align-items: center; justify-content: center;
}

.page-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.page-btn:hover:not(.active) { background: var(--bg); }

/* ========== Import Page ========== */
.import-page { max-width: 860px; }

.import-tabs {
  display: flex;
  gap: 0;
  border-radius: 10px;
  background: var(--bg);
  padding: 4px;
  margin-bottom: 24px;
  width: fit-content;
}

.import-tab {
  padding: 8px 20px;
  border-radius: 7px;
  border: none;
  background: none;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  transition: all .18s;
}

.import-tab.active {
  background: var(--card-bg);
  color: var(--text-primary);
  box-shadow: var(--shadow);
}

.import-panel { display: none; }
.import-panel.active { display: block; }

.drop-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 48px 24px;
  text-align: center;
  cursor: pointer;
  transition: all .2s;
  background: var(--card-bg);
}

.drop-zone:hover, .drop-zone.drag-over {
  border-color: var(--primary);
  background: var(--primary-light);
}

.drop-icon {
  font-size: 48px;
  margin-bottom: 12px;
}

.drop-title {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 6px;
}

.drop-hint {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 16px;
}

.supported-types {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin-top: 12px;
}

.type-badge {
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  background: var(--bg);
  color: var(--text-secondary);
}

.import-mapping {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  margin-top: 16px;
  display: none;
}

.mapping-title {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.mapping-row {
  display: grid;
  grid-template-columns: 1fr 40px 1fr;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.mapping-arrow { text-align: center; color: var(--text-muted); font-size: 18px; }

.mapping-select {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 7px 10px;
  font-size: 13px;
  width: 100%;
  outline: none;
  background: var(--bg);
}

.manual-form {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 20px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-group label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: .4px;
}

.form-group input,
.form-group select,
.form-group textarea {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 13px;
  color: var(--text-primary);
  outline: none;
  transition: border-color .18s;
  background: var(--bg);
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  border-color: var(--primary);
  background: #fff;
}

.form-group.full { grid-column: 1 / -1; }

/* ========== Section Header ========== */
.section-header {
  margin-bottom: 20px;
}

.section-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
}

.section-desc {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 4px;
}

/* ========== Empty State ========== */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}

.empty-icon { font-size: 48px; margin-bottom: 12px; }
.empty-title { font-size: 16px; font-weight: 600; color: var(--text-secondary); margin-bottom: 6px; }
.empty-desc  { font-size: 13px; }

/* ========== Progress ========== */
.progress-bar {
  height: 6px;
  background: var(--bg);
  border-radius: 3px;
  overflow: hidden;
  margin-top: 6px;
}

.progress-fill {
  height: 100%;
  border-radius: 3px;
  background: var(--primary);
  transition: width .4s ease;
}

.progress-fill.green  { background: var(--success); }
.progress-fill.red    { background: var(--danger); }
.progress-fill.blue   { background: var(--info); }

/* ========== Tooltip-style metric ========== */
.metric-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.metric-row:last-child { border-bottom: none; }
.metric-label { font-size: 13px; color: var(--text-secondary); }
.metric-value { font-size: 13px; font-weight: 600; }

/* ========== Toast ========== */
.toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  background: #1e293b;
  color: #fff;
  padding: 12px 18px;
  border-radius: 10px;
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 8px;
  box-shadow: var(--shadow-md);
  animation: slideIn .25s ease;
  min-width: 220px;
}

.toast.success { border-left: 3px solid var(--success); }
.toast.error   { border-left: 3px solid var(--danger); }
.toast.info    { border-left: 3px solid var(--info); }

@keyframes slideIn {
  from { transform: translateX(40px); opacity: 0; }
  to   { transform: translateX(0);    opacity: 1; }
}

/* ========== Table Scroll Wrapper ========== */
.table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* ========== SKU Tab ========== */
.sku-tab {
  padding: 12px 20px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-muted);
  background: transparent;
  border: none;
  border-bottom: 3px solid transparent;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
  margin-bottom: -2px;
}
.sku-tab:hover {
  color: var(--text-primary);
}
.sku-tab-active {
  color: var(--primary) !important;
  border-bottom-color: var(--primary) !important;
}

/* ========== Pager ========== */
.pager {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  gap: 12px;
  flex-wrap: wrap;
}
.pager-info {
  font-size: 13px;
  color: var(--text-muted);
}
.pager-btns {
  display: flex;
  gap: 4px;
}
.pager-btn {
  min-width: 32px;
  height: 32px;
  padding: 0 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg-card);
  color: var(--text-secondary);
  font-size: 13px;
  cursor: pointer;
  transition: all 0.15s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.pager-btn:hover:not(:disabled) {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}
.pager-btn.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
  font-weight: 600;
}
.pager-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

/* ========== Modal ========== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  animation: fadeIn .18s ease;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.modal-box {
  background: var(--card-bg);
  border-radius: 14px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, .25);
  width: 90%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  animation: slideUp .2s ease;
}

@keyframes slideUp {
  from { transform: translateY(20px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px 14px;
  border-bottom: 1px solid var(--border);
}

.modal-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
}

.modal-close {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: none;
  background: var(--bg);
  color: var(--text-muted);
  font-size: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .15s;
}

.modal-close:hover { background: var(--border); color: var(--text-primary); }

.form-input {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 9px 12px;
  font-size: 13px;
  color: var(--text-primary);
  outline: none;
  background: var(--bg);
  transition: border-color .18s;
}

.form-input:focus {
  border-color: var(--primary);
  background: #fff;
}

/* ========== KPI Icon ========== */
.kpi-icon {
  font-size: 22px;
  margin-bottom: 6px;
  display: block;
}

/* ========== Sub Nav Item (商品成本等子菜单) ========== */
.nav-sub {
  padding-left: 36px !important;
  font-size: 13px;
}
.nav-sub svg {
  width: 16px !important;
  height: 16px !important;
  opacity: 0.8;
}

/* ========== Nav Group (交易结算等分组) ========== */
.nav-group {
  margin-bottom: 2px;
}
.nav-group-title {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  color: rgba(255,255,255,.7);
  font-size: 14px;
  font-weight: 500;
  user-select: none;
  border-radius: 8px;
  cursor: pointer;
  transition: background .15s, color .15s;
}
.nav-group-title:hover {
  color: #fff;
  background: rgba(255,255,255,.07);
}
.nav-group-title svg {
  width: 18px; height: 18px;
  fill: currentColor;
  flex-shrink: 0;
}
/* 折叠箭头 */
.nav-group-title .nav-arrow {
  margin-left: auto;
  width: 14px !important;
  height: 14px !important;
  opacity: .6;
  transition: transform .22s ease;
  flex-shrink: 0;
}
.nav-group.expanded .nav-group-title .nav-arrow {
  transform: rotate(180deg);
  opacity: .9;
}
/* 子项折叠动画 */
.nav-group .nav-group-children {
  overflow: hidden;
  max-height: 0;
  transition: max-height .25s ease;
}
.nav-group.expanded .nav-group-children {
  max-height: 400px;
}

/* ========== User Badge ========== */
#userBadge {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  background: var(--bg);
  border-radius: 20px;
  border: 1px solid var(--border);
  cursor: pointer;
  flex-shrink: 0;
  transition: background .18s;
}
#userBadge:hover { background: var(--border); }

#userAvatar {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  display: flex; align-items: center; justify-content: center;
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  flex-shrink: 0;
}

#userName {
  font-size: 13px;
  color: var(--text-secondary);
  max-width: 80px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.badge-arrow {
  width: 14px; height: 14px;
  fill: var(--text-muted);
  flex-shrink: 0;
}

#userMenu {
  display: none;
  position: absolute;
  top: 60px;
  right: 20px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0,0,0,.15);
  z-index: 1000;
  min-width: 160px;
  overflow: hidden;
}

/* ========== Scrollbar ========== */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #d1d5db; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #9ca3af; }

/* ========== Responsive - Tablet ========== */
@media (max-width: 1024px) {
  :root { --sidebar-width: 200px; }
  .kpi-grid { grid-template-columns: repeat(3, 1fr); }
  .chart-grid { grid-template-columns: 1fr; }
}

/* ========== Responsive - Mobile ========== */
@media (max-width: 768px) {
  /* 移动端按钮优化 */
  .btn-primary,
  .btn-secondary,
  .btn-outline {
    min-height: 44px !important; /* 符合移动端点击区域标准 */
    padding: 10px 16px !important;
    font-size: 14px !important;
  }

  /* 添加底部固定操作栏 */
  .mobile-action-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--card-bg);
    padding: 12px 16px;
    border-top: 1px solid var(--border);
    display: flex;
    gap: 8px;
    z-index: 100;
    box-shadow: 0 -2px 8px rgba(0,0,0,0.05);
  }

  .mobile-action-bar .btn-primary,
  .mobile-action-bar .btn-secondary {
    flex: 1;
    justify-content: center;
  }

  /* 侧边栏：抽屉式 */
  .sidebar {
    transform: translateX(-100%);
    z-index: 300;
    width: 240px;
  }
  .sidebar.open { transform: translateX(0); box-shadow: 4px 0 24px rgba(0,0,0,.3); }

  /* 遮罩层（侧边栏展开时覆盖内容区） */
  .sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.45);
    z-index: 299;
  }
  .sidebar-overlay.show { display: block; }

  /* 主区域不再偏移 */
  .main-wrapper { margin-left: 0; }

  /* 汉堡按钮显示 */
  .menu-toggle { display: flex; }

  /* ── Topbar ── */
  .topbar {
    padding: 0 12px;
    gap: 6px;
    height: 52px;
    position: sticky;
    top: 0;
    z-index: 200;
  }
  .topbar-title {
    font-size: 14px;
    font-weight: 600;
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .topbar-actions { gap: 4px; flex-shrink: 0; }

  /* 隐藏在手机上占位太多的元素 */
  .date-range { display: none !important; }
  .topbar-actions > .btn-primary { display: none !important; }
  #syncStatus { display: none !important; }

  /* 用户徽章只显示头像 */
  #userBadge {
    padding: 4px;
    border-radius: 50%;
    gap: 0;
    width: 36px;
    height: 36px;
    justify-content: center;
    border: none;
    background: transparent;
  }
  .badge-arrow { display: none; }
  #userName { display: none; }

  /* 用户菜单位置 */
  #userMenu { top: 48px; right: 0; }

  /* ── 主内容区 ── */
  .main-content { padding: 12px 10px 80px; /* 底部留出 FAB 空间 */ }

  /* ── KPI 卡片 ── */
  .kpi-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    margin-bottom: 16px;
  }
  .kpi-card { padding: 14px 12px; }
  .kpi-icon { font-size: 18px; margin-bottom: 4px; }
  .kpi-label { font-size: 11px; }
  .kpi-value { font-size: 18px; }
  .kpi-change { font-size: 11px; }

  /* ── 图表 ── */
  .chart-grid {
    grid-template-columns: 1fr;
    gap: 12px;
    margin-bottom: 16px;
  }
  .chart-card { padding: 14px 12px; }
  .chart-card canvas { max-height: 200px !important; }
  .card-title { font-size: 13px; }

  /* ── 表格 ── */
  .table-card { border-radius: 10px; }
  .table-header { padding: 12px 14px; flex-wrap: wrap; gap: 8px; }
  .table-title { font-size: 13px; }
  .table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .data-table { min-width: 560px; } /* 强制横向滚动 */
  .data-table th { padding: 8px 10px; font-size: 11px; }
  .data-table td { padding: 9px 10px; font-size: 12px; white-space: nowrap; }
  .pagination { padding: 10px 14px; font-size: 12px; flex-wrap: wrap; gap: 8px; }

  /* 搜索框 */
  .search-box { padding: 5px 10px; }
  .search-box input { width: 100px; font-size: 12px; }

  /* ── Section header ── */
  .section-header { margin-bottom: 14px; }
  .section-title { font-size: 15px; }
  .section-desc { font-size: 12px; }

  /* ── 表单/导入页 ── */
  .import-page { max-width: 100%; }
  .import-tabs { width: 100%; }
  .import-tab { flex: 1; text-align: center; padding: 7px 8px; font-size: 12px; }
  .form-grid { grid-template-columns: 1fr; }
  .drop-zone { padding: 32px 16px; }
  .drop-icon { font-size: 36px; }
  .drop-title { font-size: 14px; }

  /* ── mapping 行 ── */
  .mapping-row { grid-template-columns: 1fr 24px 1fr; gap: 6px; }

  /* ── modal ── */
  .modal-box { width: 95%; max-height: 85vh; }
}

/* ========== Loading Overlay ========== */
.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  animation: fadeIn 0.2s ease;
  backdrop-filter: blur(4px);
}

.loading-spinner {
  width: 48px;
  height: 48px;
  border: 4px solid rgba(255, 255, 255, 0.2);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.loading-text {
  color: #fff;
  margin-top: 16px;
  font-size: 14px;
  font-weight: 500;
}

.loading-progress {
  margin-top: 12px;
  width: 200px;
  height: 4px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 2px;
  overflow: hidden;
}

.loading-progress-bar {
  height: 100%;
  background: var(--primary);
  transition: width 0.3s ease;
}
