/* ===== CSS Variables ===== */
:root {
  --primary: #2a5fb0;
  --primary-light: #3270c0;
  --primary-dark: #1e4a8e;
  --bg-dark: #0a1628;
  --bg-sidebar: #0d1a30;
  --bg-content: #0f1f38;
  --bg-card: rgba(15, 25, 50, 0.65);
  --border: rgba(100, 160, 255, 0.1);
  --border-hover: rgba(100, 160, 255, 0.25);
  --text: #d0dff5;
  --text-dim: rgba(160, 190, 230, 0.6);
  --text-label: rgba(160, 190, 230, 0.7);
  --accent: #7eb8ff;
  --success: #4ade80;
  --warning: #fbbf24;
  --danger: #f87171;
  --sidebar-w: 220px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;
  background: var(--bg-dark);
  color: var(--text);
  height: 100vh;
  overflow: hidden;
}

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

/* ===== Sidebar ===== */
.sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: all .3s ease;
}
.sidebar.collapsed { width: 60px; min-width: 60px; }
.sidebar.collapsed .nav-text,
.sidebar.collapsed .sidebar-title,
.sidebar.collapsed .user-info-text { display: none; }
.sidebar.collapsed .nav-item { justify-content: center; padding: 12px 0; }

.sidebar-header {
  padding: 20px 16px 12px;
  border-bottom: 1px solid var(--border);
}
.sidebar-title {
  font-size: 18px;
  font-weight: 700;
  background: linear-gradient(135deg, #7eb8ff, #4a8ee7);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  letter-spacing: 2px;
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 8px 0;
}
.sidebar-nav::-webkit-scrollbar { width: 4px; }
.sidebar-nav::-webkit-scrollbar-thumb { background: rgba(100,160,255,.15); border-radius: 4px; }

.nav-group-title {
  font-size: 11px;
  color: var(--text-dim);
  padding: 12px 16px 4px;
  letter-spacing: 1px;
  text-transform: uppercase;
}
.nav-item {
  display: flex;
  align-items: center;
  padding: 10px 16px;
  color: var(--text-dim);
  cursor: pointer;
  transition: all .2s ease;
  font-size: 14px;
  text-decoration: none;
  gap: 10px;
  border-left: 3px solid transparent;
}
.nav-item:hover {
  color: var(--accent);
  background: rgba(40, 80, 160, .1);
}
.nav-item.active {
  color: var(--accent);
  background: rgba(40, 80, 160, .18);
  border-left-color: var(--accent);
}
.nav-icon {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex-shrink: 0;
}

/* Sidebar footer - user info */
.sidebar-footer {
  border-top: 1px solid var(--border);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, #2a5fb0, #1e4a8e);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 600;
  color: #e0ecff;
  flex-shrink: 0;
}
.user-info-text { overflow: hidden; }
.user-name { font-size: 13px; font-weight: 500; }
.user-role { font-size: 11px; color: var(--text-dim); }

/* ===== Main Content ===== */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg-content);
}

/* Top bar */
.topbar {
  height: 52px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  background: rgba(13, 26, 48, .8);
  backdrop-filter: blur(10px);
}
.topbar-left { display: flex; align-items: center; gap: 12px; }
.topbar-title { font-size: 16px; font-weight: 600; }
.toggle-btn {
  width: 32px; height: 32px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: transparent;
  color: var(--text-dim);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all .2s;
}
.toggle-btn:hover { color: var(--accent); border-color: var(--border-hover); }
.topbar-right { display: flex; align-items: center; gap: 12px; }
.company-badge {
  padding: 4px 12px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 500;
  background: rgba(40, 80, 160, .25);
  border: 1px solid rgba(80, 140, 240, .3);
  color: var(--accent);
  cursor: pointer;
  transition: all .2s;
}
.company-badge:hover { background: rgba(40, 80, 160, .35); }
.logout-btn {
  padding: 4px 12px;
  border-radius: 8px;
  font-size: 12px;
  background: transparent;
  border: 1px solid rgba(248, 113, 113, .2);
  color: var(--danger);
  cursor: pointer;
  transition: all .2s;
}
.logout-btn:hover { background: rgba(248, 113, 113, .1); }

/* Page content area */
.page-content {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
}
.page-content::-webkit-scrollbar { width: 6px; }
.page-content::-webkit-scrollbar-thumb { background: rgba(100,160,255,.15); border-radius: 6px; }

/* ===== Cards ===== */
.card {
  background: var(--bg-card);
  backdrop-filter: blur(10px);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 20px;
  transition: all .2s ease;
}
.card:hover { border-color: var(--border-hover); }

/* ===== Stat Cards ===== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--bg-card);
  backdrop-filter: blur(10px);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 20px;
  transition: all .2s ease;
}
.stat-card:hover { border-color: var(--border-hover); transform: translateY(-2px); }
.stat-label { font-size: 13px; color: var(--text-dim); margin-bottom: 8px; }
.stat-value { font-size: 28px; font-weight: 700; }
.stat-sub { font-size: 12px; color: var(--text-dim); margin-top: 4px; }
.stat-value.green { color: var(--success); }
.stat-value.red { color: var(--danger); }
.stat-value.blue { color: var(--accent); }
.stat-value.yellow { color: var(--warning); }

/* ===== Tables ===== */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.data-table th {
  text-align: left;
  padding: 10px 12px;
  color: var(--text-dim);
  font-weight: 500;
  border-bottom: 1px solid var(--border);
  font-size: 12px;
}
.data-table td {
  padding: 10px 12px;
  border-bottom: 1px solid rgba(100, 160, 255, .05);
}
.data-table tr:hover td { background: rgba(40, 80, 160, .06); }

/* ===== Buttons ===== */
.btn-primary {
  padding: 8px 16px;
  border-radius: 8px;
  background: linear-gradient(135deg, #2a5fb0, #1e4a8e);
  color: #e0ecff;
  border: none;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all .2s;
}
.btn-primary:hover { background: linear-gradient(135deg, #3270c0, #2560a0); }

/* ===== Grid ===== */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

/* ===== Toolbar ===== */
.page-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 12px;
}
.toolbar-left {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}
.toolbar-right {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

/* ===== Search & Filter ===== */
.search-input {
  background: rgba(15, 25, 50, 0.6);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 14px;
  color: var(--text);
  font-size: 13px;
  min-width: 180px;
  transition: all .2s;
}
.search-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(126, 184, 255, .1);
}
.search-input::placeholder { color: var(--text-dim); }

.filter-select {
  background: linear-gradient(135deg, #2a5fb0, #1e4a8e);
  border: 1px solid rgba(80,140,240,.3);
  border-radius: 8px;
  padding: 8px 32px 8px 12px;
  color: #e0ecff;
  font-size: 14px;
  min-width: 140px;
  appearance: none;
  cursor: pointer;
  transition: all .2s;
  font-weight: 500;
  white-space: nowrap;
}
.filter-select:hover {
  background: linear-gradient(135deg, #3270c0, #2560a0);
}
.filter-select:focus {
  outline: none;
  border-color: rgba(126,184,255,.5);
  box-shadow: 0 0 0 3px rgba(126,184,255,.1);
}
.filter-select option {
  background: #1a2a4a;
  color: #e0ecff;
  padding: 8px;
}

/* ===== Buttons ===== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  border: none;
  font-size: 13px;
  color: var(--text);
}
.btn-primary {
  padding: 8px 18px;
  border-radius: 8px;
  background: linear-gradient(135deg, #2a5fb0, #1e4a8e);
  color: #e0ecff;
  border: none;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all .2s;
  white-space: nowrap;
}
.btn-primary:hover { background: linear-gradient(135deg, #3270c0, #2560a0); }

.btn-outline {
  padding: 8px 16px;
  border-radius: 8px;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-dim);
  cursor: pointer;
  font-size: 13px;
  transition: all .2s;
}
.btn-outline:hover { border-color: var(--border-hover); color: var(--text); }

.btn-sm {
  padding: 5px 12px;
  border-radius: 6px;
  font-size: 12px;
  border: 1px solid var(--border);
  background: rgba(40, 80, 160, .08);
  color: var(--accent);
  cursor: pointer;
  transition: all .2s;
}
.btn-sm:hover { background: rgba(40, 80, 160, .15); }
.btn-sm.btn-primary { background: rgba(40,80,160,.15); color: var(--accent); border-color: rgba(80,140,240,.3); }
.btn-sm.btn-success { background: rgba(80,200,120,.12); color: #50c878; border-color: rgba(80,200,120,.2); }
.btn-sm.btn-danger { background: rgba(255,80,80,.1); color: #ff6b6b; border-color: rgba(255,80,80,.15); }
.btn-sm.btn-info { background: rgba(80,180,230,.1); color: #50b4e6; border-color: rgba(80,180,230,.2); }

.btn-link {
  background: none;
  border: none;
  color: var(--accent);
  cursor: pointer;
  font-size: 12px;
  padding: 2px 6px;
}
.btn-link:hover { text-decoration: underline; }
.btn-link.btn-danger { color: var(--danger); }

/* ===== Modal ===== */
.modal-overlay {
  display: flex;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .55);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(4px);
}
.modal-card, .modal-box {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  width: 560px;
  max-width: 92vw;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 60px rgba(0,0,0,.4);
  backdrop-filter: blur(20px);
}
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.modal-title {
  font-size: 16px;
  font-weight: 600;
}
.modal-close {
  font-size: 22px;
  color: var(--text-dim);
  cursor: pointer;
  background: none;
  border: none;
  padding: 0 4px;
  line-height: 1;
  transition: color .2s;
}
.modal-close:hover { color: var(--danger); }
.modal-body {
  padding: 20px;
  overflow-y: auto;
  flex: 1;
}
.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 14px 20px;
  border-top: 1px solid var(--border);
}

/* ===== Form ===== */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
}
.form-group label {
  font-size: 12px;
  color: var(--text-dim);
  font-weight: 500;
  min-height: 18px;
}
.form-group input,
.form-group select,
.form-group textarea,
.form-input {
  background: rgba(15, 25, 50, 0.5);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 9px 12px;
  color: var(--text);
  font-size: 13px;
  transition: all .2s;
  width: 100%;
}
.form-group input:focus,
.form-group select:focus,
.form-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(126, 184, 255, .08);
}
.form-row {
  display: flex;
  gap: 14px;
  margin-bottom: 4px;
}
.form-row .flex-1 { flex: 1; }

.form-section-title {
  font-size: 13px;
  color: var(--text-dim);
  padding-top: 14px;
  margin-top: 10px;
  border-top: 1px solid var(--border);
  font-weight: 500;
  margin-bottom: 8px;
}

/* ===== Tags & Badges ===== */
.tag { display: inline-block; padding: 2px 8px; border-radius: 4px; font-size: 11px; font-weight: 500; }
.tag-default { background: rgba(100,160,255,.1); color: rgba(160,190,230,.7); }
.tag-success { background: rgba(80,200,120,.12); color: #50c878; }
.tag-info { background: rgba(80,180,230,.12); color: #50b4e6; }
.tag-danger { background: rgba(255,80,80,.1); color: #ff6b6b; }
.tag-warning { background: rgba(255,180,50,.12); color: #ffb432; }

.level-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 500;
}
.level-normal { background: rgba(100,160,255,.1); color: rgba(160,190,230,.7); }
.level-vip { background: rgba(255,180,50,.12); color: #ffb432; }
.level-wholesale { background: rgba(80,200,120,.12); color: #50c878; }
.level-retail { background: rgba(130,90,200,.12); color: #825ac8; }

.text-success { color: #50c878; }
.text-danger { color: #ff6b6b; }
.text-muted { color: rgba(160,190,230,.4); }
.link { color: #7eb8ff; cursor: pointer; text-decoration: none; }
.link:hover { text-decoration: underline; }
.detail-row { padding: 6px 0; font-size: 13px; color: #c0d4ee; }
.detail-row .label { color: rgba(160,190,230,.6); margin-right: 8px; }

/* ===== Checkbox ===== */
.chk-label {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  font-size: 13px;
  color: #d0dff5;
  white-space: nowrap;
}
.chk-label input[type="checkbox"] { width: 16px; height: 16px; accent-color: #5090e8; cursor: pointer; }

/* ===== Tab Buttons (统一按钮风格) ===== */
.tab-btn {
  padding: 8px 18px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid rgba(80,140,240,.25);
  background: linear-gradient(135deg, #2a5fb0, #1e4a8e);
  color: #e0ecff;
  transition: all .2s;
  white-space: nowrap;
}
.tab-btn:hover {
  background: linear-gradient(135deg, #3270c0, #2560a0);
}
.tab-btn-active, .tab-btn.tab-btn-active {
  background: linear-gradient(135deg, #1a4f9e, #143a7e);
  border-color: rgba(126,184,255,.4);
  color: #fff;
  font-weight: 600;
  box-shadow: 0 2px 8px rgba(40,80,160,.3);
}

[data-theme="light"] .tab-btn {
  background: linear-gradient(135deg, #4a7cc9, #3a6cb9);
  border-color: rgba(74,124,201,.25);
  color: #fff;
}
[data-theme="light"] .tab-btn:hover {
  background: linear-gradient(135deg, #5a8cd9, #4a7cb9);
}
[data-theme="light"] .tab-btn-active,
[data-theme="light"] .tab-btn.tab-btn-active {
  background: linear-gradient(135deg, #3a6cb9, #2a5ca9);
  border-color: rgba(74,124,201,.4);
  box-shadow: 0 2px 8px rgba(74,124,201,.2);
}

/* ===== Inventory ===== */
.inv-tab {
  padding: 10px 20px;
  cursor: pointer;
  font-size: 14px;
  color: rgba(160,190,230,.75);
  border-bottom: 2px solid transparent;
  transition: all .2s;
  font-weight: 500;
}
.inv-tab:hover { color: #7eb8ff; }
.inv-tab.active {
  color: #e0ecff;
  border-bottom-color: #4a8ee7;
  font-weight: 600;
  background: rgba(40,80,160,.1);
}
.summary-card { flex: 1; background: rgba(30,60,120,.08); border: 1px solid rgba(100,160,255,.06); border-radius: 10px; padding: 14px 18px; text-align: center; }
.sc-value { font-size: 22px; font-weight: 700; color: #e0ecff; }
.sc-label { font-size: 12px; color: rgba(160,190,230,.5); margin-top: 4px; }
.row-warning { background: rgba(255,80,80,.04); }

/* ===== Pagination ===== */
.pagination { display: flex; align-items: center; gap: 6px; margin-top: 16px; justify-content: center; }
.pager-info { font-size: 12px; color: rgba(160,190,230,.5); margin-right: 10px; }
.pager-btn {
  width: 32px; height: 32px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: transparent;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all .2s;
}
.pager-btn:hover { border-color: var(--border-hover); background: rgba(40,80,160,.06); }
.pager-btn.active { background: linear-gradient(135deg, #2a5fb0, #1e4a8e); color: #e0ecff; border-color: transparent; }

/* ===== Typeahead / CustomerPicker ===== */
.customer-picker { position: relative; }
.cp-input { width: 100%; }
.cp-dropdown {
  position: absolute; top: 100%; left: 0; right: 0;
  background: rgba(13, 26, 48, .98);
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-top: 4px;
  max-height: 200px;
  overflow-y: auto;
  z-index: 10;
  box-shadow: 0 8px 24px rgba(0,0,0,.3);
}
.cp-item { padding: 8px 12px; cursor: pointer; display: flex; gap: 10px; align-items: center; font-size: 13px; }
.cp-item:hover { background: rgba(40,80,160,.12); }
.cp-name { color: #e0ecff; }
.cp-phone { color: rgba(160,190,230,.5); font-size: 12px; }
.cp-level { font-size: 11px; }
.cp-empty { padding: 12px; text-align: center; color: var(--text-dim); font-size: 13px; }
.picked-customer {
  display: inline-block; padding: 4px 10px; border-radius: 6px;
  background: rgba(40,80,160,.12); border: 1px solid rgba(80,140,240,.2);
  color: var(--accent); font-size: 13px;
}
.typeahead-dropdown {
  position: absolute; top: 100%; left: 0; right: 0;
  background: rgba(13, 26, 48, .98);
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-top: 4px;
  max-height: 200px;
  overflow-y: auto;
  z-index: 10;
  box-shadow: 0 8px 24px rgba(0,0,0,.3);
}
.typeahead-item { padding: 8px 12px; cursor: pointer; font-size: 13px; color: #c0d4ee; }
.typeahead-item:hover { background: rgba(40,80,160,.12); }

/* ===== Quote Summary ===== */
.quote-summary { background: rgba(30,60,120,.08); border-radius: 8px; padding: 12px 16px; margin-top: 12px; }
.summary-row { display: flex; justify-content: space-between; padding: 4px 0; font-size: 13px; color: rgba(160,190,230,.7); }
.summary-row.total { color: var(--accent); font-weight: 600; font-size: 15px; border-top: 1px solid var(--border); padding-top: 8px; margin-top: 4px; }
.sale-unit-row { background: rgba(40,80,160,.06); padding: 6px 10px; border-radius: 6px; margin-top: 4px; }
/* ===== Responsive: Full Coverage ===== */
/* 断点体系:
   xs: 0-359px    (极小屏/老机型横屏)
   sm: 360-479px  (iPhone SE / 小屏手机)
   md: 480-767px  (标准手机 / 折叠屏外屏)
   lg: 768-1023px (折叠屏内屏 / 小平板)
   xl: 1024+      (平板横屏 / 桌面)
*/

/* ===== md及以下 (≤767px) - 所有手机 ===== */
@media (max-width: 767px) {
  /* Sidebar overlay */
  .sidebar {
    position: fixed;
    z-index: 100;
    left: -280px;
    width: 260px;
    min-width: 260px;
    top: 0;
    bottom: 0;
    box-shadow: none;
    transition: left .3s ease, box-shadow .3s ease;
  }
  .sidebar.mobile-open {
    left: 0;
    box-shadow: 4px 0 24px rgba(0,0,0,.4);
  }
  .sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.45);
    z-index: 99;
  }
  .sidebar-overlay.active { display: block; }

  /* Topbar compact */
  .topbar { padding: 0 10px; height: 48px; }
  .topbar-title { font-size: 14px; }
  .toggle-btn { width: 36px; height: 36px; }

  /* Page content */
  .page-content { padding: 10px 6px; }

  /* Stats grid - always 2x2 on phone */
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    margin-bottom: 16px;
  }
  .stat-card { padding: 12px 10px; border-radius: 10px; }
  .stat-label { font-size: 11px; margin-bottom: 4px; }
  .stat-value { font-size: 20px; }

  /* Grid-2 → single column */
  .grid-2 { grid-template-columns: 1fr; gap: 12px; }

  /* Card compact */
  .card { padding: 12px 10px; border-radius: 10px; }

  /* Summary cards - 2 per row */
  .summary-card { padding: 8px 10px; }

  /* Toolbar - stack */
  .page-toolbar {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    margin-bottom: 12px;
  }
  .toolbar-left { flex-wrap: wrap; gap: 6px; }
  .toolbar-right { justify-content: flex-start; flex-wrap: wrap; gap: 6px; }

  /* Search & filter */
  .search-input {
    min-width: 0;
    flex: 1 1 120px;
    width: 100%;
    font-size: 16px;
    height: 40px;
  }
  .filter-select { font-size: 14px; height: 40px; min-width: 0; }

  /* Table - responsive scroll */
  .table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin: 0 -6px;
    padding: 0 2px;
  }
  .data-table {
    min-width: 0;
    font-size: 12px;
    table-layout: auto;
  }
  .data-table th {
    padding: 8px 6px;
    font-size: 11px;
    white-space: nowrap;
  }
  .data-table td {
    padding: 8px 6px;
    white-space: nowrap;
  }

  /* Form rows stack */
  .form-row { flex-direction: column; gap: 8px; }
  .form-row .flex-1 { flex: auto; width: 100%; }
  .form-group input,
  .form-group select,
  .form-group textarea,
  .form-input {
    font-size: 16px;
    height: 42px;
  }
  .form-group label { font-size: 12px; }

  /* Modal - nearly full width */
  .modal-card, .modal-box {
    width: 96%;
    max-height: 90vh;
    border-radius: 12px;
  }
  .modal-body { padding: 12px; }
  .modal-header { padding: 12px 14px; }
  .modal-footer { padding: 10px 14px; }

  /* Buttons - bigger touch targets */
  .btn-primary { padding: 10px 16px; font-size: 14px; }
  .btn-sm { padding: 6px 10px; font-size: 12px; }

  /* Inventory tabs */
  .inv-tab { padding: 8px 12px; font-size: 13px; }

  /* Pagination compact */
  .pager-wrap { gap: 4px; }

  /* Company badge & logout */
  .company-badge { font-size: 11px; padding: 3px 8px; }
  .logout-btn { font-size: 11px; padding: 3px 8px; }

  /* Detail rows */
  .detail-row { font-size: 12px; }
}

/* ===== sm及以下 (≤479px) - 小屏手机 ===== */
@media (max-width: 479px) {
  .page-content { padding: 8px 4px; }

  .stats-grid { gap: 6px; }
  .stat-card { padding: 10px 8px; border-radius: 8px; }
  .stat-label { font-size: 10px; }
  .stat-value { font-size: 18px; }

  .card { padding: 10px 8px; border-radius: 8px; }

  .data-table { font-size: 11px; }
  .data-table th { padding: 6px 4px; font-size: 10px; }
  .data-table td { padding: 6px 4px; }

  .modal-card, .modal-box {
    width: 100%;
    max-height: 95vh;
    border-radius: 10px;
  }
  .modal-body { padding: 10px 8px; }

  .btn-primary { padding: 12px 18px; }

  .summary-card { padding: 6px 8px; }

  .inv-tab { padding: 6px 10px; font-size: 12px; }
}

/* ===== xs (≤359px) - 极小屏 ===== */
@media (max-width: 359px) {
  .stats-grid { grid-template-columns: 1fr 1fr; gap: 4px; }
  .stat-card { padding: 8px 6px; }
  .stat-value { font-size: 16px; }
  .stat-label { font-size: 10px; }

  .topbar-title { font-size: 12px; }
  .company-badge, .logout-btn { font-size: 10px; padding: 2px 6px; }

  .data-table { font-size: 10px; }
  .data-table th, .data-table td { padding: 5px 3px; }
}

/* ===== lg (768-1023px) - 折叠屏内屏 / 小平板 ===== */
@media (min-width: 768px) and (max-width: 1023px) {
  /* Sidebar narrower */
  :root { --sidebar-w: 180px; }
  .sidebar { width: 180px; min-width: 180px; }
  .sidebar.collapsed { width: 56px; min-width: 56px; }

  .nav-item { padding: 8px 12px; font-size: 13px; }
  .sidebar-title { font-size: 15px; }

  .page-content { padding: 16px 12px; }

  /* Stats - 4 columns ok on this width */
  .stats-grid { grid-template-columns: repeat(4, 1fr); gap: 10px; }
  .stat-card { padding: 14px; }
  .stat-value { font-size: 22px; }

  /* Grid-2 can stay 2 columns if cards are simple, otherwise 1fr */
  .grid-2 { grid-template-columns: 1fr 1fr; gap: 12px; }

  /* Tables need scroll on some pages */
  .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }

  /* Toolbar still inline but tighter */
  .page-toolbar { gap: 8px; }
  .search-input { min-width: 140px; }

  /* Modal medium */
  .modal-card, .modal-box { width: 90%; max-width: 700px; }

  /* Summary cards */
  .summary-card { padding: 10px 14px; }
}

/* ===== Foldable special: 竖折内屏 (典型840x2200) ===== */
@media (min-width: 768px) and (max-width: 900px) and (min-height: 1000px) {
  /* 竖折内屏：宽840左右，非常高 - 像大手机 */
  .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 12px; }
  .stat-value { font-size: 24px; }
  .grid-2 { grid-template-columns: 1fr; }
}

/* ===== Foldable special: 横折内屏 (典型2200x840) ===== */
@media (min-width: 1000px) and (max-width: 1400px) and (max-height: 900px) {
  /* 横折内屏：很宽但不高 - 像小笔记本 */
  .page-content { padding: 12px 16px; }
  .stats-grid { grid-template-columns: repeat(4, 1fr); }
}

/* ===== 触控设备通用 ===== */
@media (hover: none) and (pointer: coarse) {
  /* 所有触屏设备 - 增大可点击区域 */
  .nav-item { min-height: 44px; }
  .btn-sm { min-height: 36px; }
  .filter-select { min-height: 40px; }

  /* 禁用hover效果避免"粘滞" */
  .stat-card:hover { transform: none; }
  .nav-item:hover { background: transparent; }
}

/* ===== 打印 ===== */
@media print {
  .sidebar, .topbar, .page-toolbar, .toggle-btn { display: none !important; }
  .main-content { margin: 0; }
  .page-content { padding: 0; overflow: visible; }
  body { background: #fff; color: #000; height: auto; overflow: visible; }
}

[data-theme="light"] {
  --primary: #4a7cc9;
  --primary-light: #5a8cd9;
  --primary-dark: #3a6cb9;
  --bg-dark: #f0f2f7;
  --bg-sidebar: #f7f8fc;
  --bg-content: #f4f5fa;
  --bg-card: rgba(255, 255, 255, 0.75);
  --border: rgba(120, 140, 180, 0.12);
  --border-hover: rgba(120, 140, 180, 0.25);
  --text: #2c3e5a;
  --text-dim: rgba(80, 100, 140, 0.55);
  --text-label: rgba(80, 100, 140, 0.65);
  --accent: #4a7cc9;
  --success: #34a853;
  --warning: #e8a317;
  --danger: #d94040;
}

[data-theme="light"] body { background: #f0f2f7; }

[data-theme="light"] .sidebar {
  background: linear-gradient(180deg, #f7f8fc 0%, #eef0f6 100%);
  border-right: 1px solid rgba(120, 140, 180, 0.1);
}
[data-theme="light"] .sidebar-title {
  background: linear-gradient(135deg, #4a7cc9, #6a9ce9);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}
[data-theme="light"] .sidebar-header { border-bottom-color: rgba(120,140,180,.08); }
[data-theme="light"] .sidebar-footer { border-top-color: rgba(120,140,180,.08); }
[data-theme="light"] .sidebar-nav::-webkit-scrollbar-thumb { background: rgba(120,140,180,.15); }
[data-theme="light"] .nav-item { color: rgba(60,80,120,.5); }
[data-theme="light"] .nav-item:hover { color: #4a7cc9; background: rgba(74,124,201,.06); }
[data-theme="light"] .nav-item.active { color: #4a7cc9; background: rgba(74,124,201,.1); border-left-color: #4a7cc9; }
[data-theme="light"] .nav-group-title { color: rgba(80,100,140,.45); }

[data-theme="light"] .topbar {
  background: rgba(247,248,252,.85);
  border-bottom-color: rgba(120,140,180,.08);
  backdrop-filter: blur(16px);
}
[data-theme="light"] .toggle-btn { border-color: rgba(120,140,180,.12); color: rgba(80,100,140,.5); }
[data-theme="light"] .toggle-btn:hover { color: #4a7cc9; }
[data-theme="light"] .company-badge { background: rgba(74,124,201,.1); border-color: rgba(74,124,201,.2); color: #4a7cc9; }
[data-theme="light"] .company-badge:hover { background: rgba(74,124,201,.15); }
[data-theme="light"] .logout-btn { border-color: rgba(217,64,64,.15); color: #d94040; }
[data-theme="light"] .logout-btn:hover { background: rgba(217,64,64,.05); }

[data-theme="light"] .user-avatar {
  background: linear-gradient(135deg, #4a7cc9, #6a9ce9);
  color: #fff;
}
[data-theme="light"] .user-name { color: var(--text); }
[data-theme="light"] .user-role { color: var(--text-dim); }

[data-theme="light"] .page-content::-webkit-scrollbar-thumb { background: rgba(120,140,180,.15); }

[data-theme="light"] .stat-card {
  background: rgba(255,255,255,.8);
  border-color: rgba(120,140,180,.08);
  backdrop-filter: blur(12px);
  box-shadow: 0 2px 12px rgba(60,80,120,.04);
}
[data-theme="light"] .stat-card:hover { border-color: rgba(74,124,201,.2); }

[data-theme="light"] .card {
  background: rgba(255,255,255,.75);
  border-color: rgba(120,140,180,.08);
  box-shadow: 0 2px 12px rgba(60,80,120,.04);
}

[data-theme="light"] .table-wrap {
  background: rgba(255,255,255,.6);
  border-color: rgba(120,140,180,.08);
}
[data-theme="light"] .data-table th {
  background: rgba(74,124,201,.06);
  color: rgba(60,80,120,.6);
  border-bottom-color: rgba(120,140,180,.08);
}
[data-theme="light"] .data-table td {
  border-bottom-color: rgba(120,140,180,.05);
  color: #3a506e;
}
[data-theme="light"] .data-table tr:hover td { background: rgba(74,124,201,.04); }

[data-theme="light"] .search-input {
  background: rgba(255,255,255,.8);
  border-color: rgba(120,140,180,.12);
  color: #2c3e5a;
}
[data-theme="light"] .search-input:focus { border-color: rgba(74,124,201,.4); box-shadow: 0 0 0 3px rgba(74,124,201,.08); }
[data-theme="light"] .search-input::placeholder { color: rgba(80,100,140,.35); }

[data-theme="light"] .filter-select {
  background: rgba(255,255,255,.8);
  border-color: rgba(120,140,180,.12);
  color: #2c3e5a;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='none' stroke='rgba(80,100,140,.4)' stroke-width='2'%3E%3Cpath d='M2 4l4 4 4-4'/%3E%3C/svg%3E");
}
[data-theme="light"] .filter-select option { background: #fff; color: #2c3e5a; }

[data-theme="light"] .btn { color: #2c3e5a; }
[data-theme="light"] .btn-primary { background: linear-gradient(135deg, #4a7cc9, #3a6cb9); color: #fff; }
[data-theme="light"] .btn-primary:hover { background: linear-gradient(135deg, #5a8cd9, #4a7cb9); }
[data-theme="light"] .btn-outline { border-color: rgba(120,140,180,.2); color: rgba(60,80,120,.7); }

[data-theme="light"] .btn-sm { background: rgba(74,124,201,.08); color: #4a7cc9; border-color: rgba(74,124,201,.12); }
[data-theme="light"] .btn-sm:hover { background: rgba(74,124,201,.12); }
[data-theme="light"] .btn-sm.btn-primary { background: rgba(74,124,201,.12); border-color: rgba(74,124,201,.2); }
[data-theme="light"] .btn-sm.btn-success { background: rgba(52,168,83,.08); color: #34a853; border-color: rgba(52,168,83,.15); }
[data-theme="light"] .btn-sm.btn-danger { background: rgba(217,64,64,.06); color: #d94040; border-color: rgba(217,64,64,.12); }
[data-theme="light"] .btn-sm.btn-info { background: rgba(60,160,220,.08); color: #3aa0dc; border-color: rgba(60,160,220,.15); }

[data-theme="light"] .tag-default { background: rgba(74,124,201,.08); color: rgba(60,80,120,.6); }
[data-theme="light"] .tag-success { background: rgba(52,168,83,.08); color: #34a853; }
[data-theme="light"] .tag-info { background: rgba(60,160,220,.08); color: #3aa0dc; }
[data-theme="light"] .tag-danger { background: rgba(217,64,64,.06); color: #d94040; }
[data-theme="light"] .tag-warning { background: rgba(232,163,23,.08); color: #c89015; }
[data-theme="light"] .text-muted { color: rgba(80,100,140,.35); }
[data-theme="light"] .link { color: #4a7cc9; }

[data-theme="light"] .modal-overlay { background: rgba(30,40,60,.25); }
[data-theme="light"] .modal-card,
[data-theme="light"] .modal-box {
  background: #fff;
  border-color: rgba(120,140,180,.1);
  box-shadow: 0 20px 60px rgba(30,40,60,.12);
}
[data-theme="light"] .modal-header { border-bottom-color: rgba(120,140,180,.06); }
[data-theme="light"] .modal-close { color: rgba(80,100,140,.4); }
[data-theme="light"] .modal-close:hover { color: #d94040; }

[data-theme="light"] .form-group input,
[data-theme="light"] .form-group select,
[data-theme="light"] .form-group textarea,
[data-theme="light"] .form-input {
  background: rgba(248,249,253,.9);
  border-color: rgba(120,140,180,.12);
  color: #2c3e5a;
}
[data-theme="light"] .form-group input:focus,
[data-theme="light"] .form-group select:focus,
[data-theme="light"] .form-input:focus {
  border-color: rgba(74,124,201,.4);
  box-shadow: 0 0 0 3px rgba(74,124,201,.08);
}
[data-theme="light"] .form-group label { color: rgba(60,80,120,.6); }
[data-theme="light"] .form-section-title { color: rgba(60,80,120,.6); border-top-color: rgba(120,140,180,.06); }

[data-theme="light"] .typeahead-dropdown,
[data-theme="light"] .cp-dropdown {
  background: #fff;
  border-color: rgba(120,140,180,.12);
  box-shadow: 0 8px 24px rgba(30,40,60,.08);
}
[data-theme="light"] .typeahead-item { color: #3a506e; }
[data-theme="light"] .typeahead-item:hover { background: rgba(74,124,201,.06); }
[data-theme="light"] .cp-item:hover { background: rgba(74,124,201,.06); }
[data-theme="light"] .cp-name { color: #2c3e5a; }
[data-theme="light"] .cp-phone { color: rgba(80,100,140,.5); }
[data-theme="light"] .picked-customer {
  background: rgba(74,124,201,.06);
  border-color: rgba(74,124,201,.15);
  color: #4a7cc9;
}

[data-theme="light"] .level-normal { background: rgba(74,124,201,.08); color: rgba(60,80,120,.6); }
[data-theme="light"] .level-vip { background: rgba(232,163,23,.08); color: #c89015; }
[data-theme="light"] .level-wholesale { background: rgba(52,168,83,.08); color: #34a853; }
[data-theme="light"] .level-retail { background: rgba(130,90,200,.08); color: #825ac8; }

[data-theme="light"] .summary-card { background: rgba(255,255,255,.6); border-color: rgba(120,140,180,.06); }
[data-theme="light"] .sc-value { color: #2c3e5a; }
[data-theme="light"] .sc-label { color: rgba(80,100,140,.45); }
[data-theme="light"] .quote-summary { background: rgba(74,124,201,.04); }
[data-theme="light"] .summary-row { color: rgba(60,80,120,.6); }
[data-theme="light"] .summary-row.total { color: #4a7cc9; border-top-color: rgba(120,140,180,.08); }
[data-theme="light"] .sale-unit-row { background: rgba(74,124,201,.04); }
[data-theme="light"] .row-warning { background: rgba(217,64,64,.03); }

[data-theme="light"] .chk-label { color: #2c3e5a; }
[data-theme="light"] .chk-label input[type="checkbox"] { accent-color: #4a7cc9; }

[data-theme="light"] .inv-tab { color: rgba(60,80,120,.65); }
[data-theme="light"] .inv-tab:hover { color: #4a7cc9; }
[data-theme="light"] .inv-tab.active { color: #4a7cc9; border-bottom-color: #4a7cc9; background: rgba(74,124,201,.06); }

[data-theme="light"] .pager-btn { border-color: rgba(120,140,180,.12); color: rgba(80,100,140,.5); }
[data-theme="light"] .pager-btn:hover { border-color: rgba(74,124,201,.3); background: rgba(74,124,201,.04); }
[data-theme="light"] .pager-btn.active { background: linear-gradient(135deg, #4a7cc9, #3a6cb9); color: #fff; }

/* Theme toggle button */
.theme-toggle {
  width: 32px; height: 32px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: transparent;
  color: var(--text-dim);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all .2s;
  font-size: 16px;
}
.theme-toggle:hover { color: var(--accent); border-color: var(--border-hover); }