/* ===== 基础重置 ===== */
* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
*:focus { outline: none; }

:root {
  --primary: #2563eb;
  --primary-light: #dbeafe;
  --primary-dark: #1d4ed8;
  --success: #16a34a;
  --success-light: #dcfce7;
  --warning: #f59e0b;
  --warning-light: #fef3c7;
  --danger: #dc2626;
  --danger-light: #fee2e2;
  --info: #0891b2;
  --info-light: #cffafe;

  --bg: #f1f5f9;
  --surface: #ffffff;
  --surface-alt: #f8fafc;
  --border: #e2e8f0;
  --text: #1e293b;
  --text-secondary: #64748b;
  --text-tertiary: #94a3b8;

  --sidebar-bg: #1e293b;
  --sidebar-text: #cbd5e1;
  --sidebar-active: #2563eb;

  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -2px rgba(0,0,0,0.05);
  --transition: 0.2s ease;

  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --mobile-nav-h: 60px;
}

/* ===== 移动端优先: 默认样式 ===== */
html, body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.6;
  height: 100%;
  -webkit-font-smoothing: antialiased;
}

#app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
}

/* ===== 侧边栏 — 桌面端 ===== */
.sidebar {
  display: none;
}

/* ===== 移动端底部导航 ===== */
.mobile-nav {
  display: flex;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--mobile-nav-h);
  background: var(--surface);
  border-top: 1px solid var(--border);
  z-index: 900;
  padding-bottom: var(--safe-bottom);
  box-shadow: 0 -2px 10px rgba(0,0,0,0.05);
}

.mobile-nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  color: var(--text-tertiary);
  text-decoration: none;
  font-size: 10px;
  cursor: pointer;
  transition: var(--transition);
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  padding: 4px 0;
}

.mobile-nav-item .mni-icon { font-size: 22px; line-height: 1; }
.mobile-nav-item .mni-label { font-size: 10px; font-weight: 500; }
.mobile-nav-item.active { color: var(--primary); }

/* ===== 主内容区 ===== */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding-bottom: calc(var(--mobile-nav-h) + var(--safe-bottom) + 8px);
  min-height: 0;
}

/* ===== 顶部栏 ===== */
.top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  flex-wrap: wrap;
  gap: 8px;
}

.top-bar h1 { font-size: 18px; font-weight: 600; flex-shrink: 0; }
.top-bar-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* 设置齿轮按钮 - 移动端显示 */
.btn-icon-settings {
  width: 38px;
  height: 38px;
  border: none;
  background: var(--surface-alt);
  border-radius: var(--radius-sm);
  font-size: 20px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
  flex-shrink: 0;
}
.btn-icon-settings:active { background: var(--border); transform: scale(0.95); }
.btn-icon-settings.active { background: var(--primary); }

.month-picker {
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}

/* ===== 页面内容 ===== */
.page-content {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 12px;
  -webkit-overflow-scrolling: touch;
  min-height: 0;
  overscroll-behavior: contain;
}

/* ===== 按钮 ===== */
.btn {
  padding: 10px 16px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 14px;
  cursor: pointer;
  transition: var(--transition);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 500;
  white-space: nowrap;
  min-height: 40px;
}

.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:active { background: var(--primary-dark); transform: scale(0.97); }
.btn-secondary { background: var(--surface-alt); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:active { background: var(--border); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:active { opacity: 0.9; }
.btn-success { background: var(--success); color: #fff; }
.btn-sm { padding: 5px 10px; font-size: 12px; min-height: 32px; }
.btn-icon {
  padding: 8px;
  background: transparent;
  border: none;
  cursor: pointer;
  font-size: 18px;
  border-radius: 6px;
  min-width: 36px;
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.btn-icon:active { background: var(--surface-alt); }

/* ===== 卡片 ===== */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  margin-bottom: 12px;
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  flex-wrap: wrap;
  gap: 8px;
}

.card-title { font-size: 15px; font-weight: 600; }

/* ===== 统计卡片 ===== */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-bottom: 12px;
}

.stat-card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px;
  position: relative;
  overflow: hidden;
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0;
  width: 3px; height: 100%;
}

.stat-card.blue::before { background: var(--primary); }
.stat-card.green::before { background: var(--success); }
.stat-card.orange::before { background: var(--warning); }
.stat-card.red::before { background: var(--danger); }
.stat-card.cyan::before { background: var(--info); }

.stat-icon { font-size: 22px; margin-bottom: 4px; }
.stat-label { font-size: 12px; color: var(--text-secondary); margin-bottom: 2px; }
.stat-value { font-size: 20px; font-weight: 700; }
.stat-sub { font-size: 11px; color: var(--text-tertiary); margin-top: 2px; }

/* ===== 表格 ===== */
.table-container {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin: 0 -4px;
  padding: 0 4px;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

th {
  text-align: left;
  padding: 8px 10px;
  background: var(--surface-alt);
  color: var(--text-secondary);
  font-weight: 600;
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
  font-size: 12px;
}

td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
}

tr:active td { background: var(--surface-alt); }

/* ===== 状态标签 ===== */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 500;
  white-space: nowrap;
}

.badge-blue { background: var(--primary-light); color: var(--primary-dark); }
.badge-green { background: var(--success-light); color: var(--success); }
.badge-yellow { background: var(--warning-light); color: #92400e; }
.badge-red { background: var(--danger-light); color: var(--danger); }
.badge-gray { background: #f1f5f9; color: var(--text-secondary); }
.badge-cyan { background: #e0f2fe; color: #0c4a6e; }

.bill-extra-row td {
  padding: 6px 12px !important;
  font-size: 12px;
  background: var(--surface-alt);
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border);
}
.badge-cyan { background: var(--info-light); color: var(--info); }
.badge-purple { background: #f3e8ff; color: #7e22ce; }

/* ===== 表单 ===== */
.form-group { margin-bottom: 14px; }
.form-row, .form-row-3 { display: flex; flex-direction: column; gap: 14px; }

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

.form-label .required { color: var(--danger); }

.form-input, .form-select, .form-textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 15px;
  background: var(--surface);
  color: var(--text);
  transition: var(--transition);
  -webkit-appearance: none;
  appearance: none;
}

.form-select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2364748b' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
}

.form-input:focus, .form-select:focus, .form-textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,0.15);
}

.form-textarea { resize: vertical; min-height: 60px; }
.form-hint { font-size: 12px; color: var(--text-tertiary); margin-top: 2px; }

/* ===== 模态框 ===== */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 1000;
  animation: fadeIn 0.2s ease;
}

.modal {
  background: var(--surface);
  border-radius: 16px 16px 0 0;
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-height: 90vh;
  max-height: 90dvh;
  overflow-y: auto;
  animation: slideUp 0.3s ease;
}

.modal.modal-sm { max-height: 70vh; max-height: 70dvh; }
.modal.modal-lg { max-height: 92vh; max-height: 92dvh; }

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--surface);
  z-index: 1;
  border-radius: 16px 16px 0 0;
}

.modal-title { font-size: 16px; font-weight: 600; }
.modal-close {
  font-size: 24px;
  cursor: pointer;
  color: var(--text-tertiary);
  background: none;
  border: none;
  padding: 4px 8px;
  min-width: 40px;
  min-height: 40px;
}
.modal-close:active { color: var(--danger); }

.modal-body { padding: 16px; }
.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  position: sticky;
  bottom: 0;
  background: var(--surface);
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { transform: translateY(30%); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

/* ===== Toast ===== */
#toast-container {
  position: fixed;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 6px;
  pointer-events: none;
  width: 90%;
  max-width: 400px;
}

.toast {
  padding: 10px 16px;
  border-radius: 8px;
  box-shadow: var(--shadow-lg);
  font-size: 13px;
  color: #fff;
  animation: slideDown 0.3s ease;
  text-align: center;
  pointer-events: auto;
}

.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }
.toast.info { background: var(--info); }
.toast.warning { background: var(--warning); color: #1e293b; }

@keyframes slideDown { from { transform: translateY(-20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

/* ===== 筛选栏 ===== */
.filter-bar {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
  flex-wrap: wrap;
  align-items: center;
}

.filter-bar .form-select, .filter-bar .form-input {
  width: auto;
  min-width: 120px;
  padding: 8px 10px;
  font-size: 13px;
}

.filter-spacer { flex: 1; min-width: 0; }

/* ===== 空状态 ===== */
.empty-state {
  text-align: center;
  padding: 36px 16px;
  color: var(--text-tertiary);
}

.empty-state .empty-icon { font-size: 42px; margin-bottom: 8px; }
.empty-state .empty-text { font-size: 14px; }
.empty-state .empty-hint { font-size: 12px; margin-top: 4px; }

/* ===== 标签页 ===== */
.tabs {
  display: flex;
  gap: 0;
  border-bottom: 2px solid var(--border);
  margin-bottom: 12px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.tab {
  padding: 8px 14px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text-secondary);
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  white-space: nowrap;
}
.tab.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }

/* ===== 进度条 ===== */
.progress-bar {
  height: 6px;
  background: var(--surface-alt);
  border-radius: 3px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.3s ease;
}

/* ===== 利润显示 ===== */
.profit-positive { color: var(--success); font-weight: 600; }
.profit-negative { color: var(--danger); font-weight: 600; }

/* ===== 快速记账标签 ===== */
.quick-categories {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.quick-cat {
  padding: 7px 12px;
  border-radius: 20px;
  border: 1px solid var(--border);
  cursor: pointer;
  font-size: 13px;
  transition: var(--transition);
  -webkit-tap-highlight-color: transparent;
}
.quick-cat:active { border-color: var(--primary); }
.quick-cat.selected { background: var(--primary); color: #fff; border-color: var(--primary); }

/* ===== 仓储卡片 ===== */
.storage-card-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

/* ===== 工具类 ===== */
.text-right { text-align: right; }
.text-center { text-align: center; }
.text-muted { color: var(--text-tertiary); font-size: 12px; }
.text-green { color: var(--success); }
.text-warning { color: var(--warning); }
.text-bold { font-weight: 600; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mb-16 { margin-bottom: 16px; }
.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.flex-wrap { flex-wrap: wrap; }
.w-full { width: 100%; }

/* ===== 滚动条 ===== */
::-webkit-scrollbar { width: 3px; height: 3px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 3px; }

/* ================================================================ */
/* 桌面端 (>=768px) */
/* ================================================================ */
@media (min-width: 768px) {
  body { overflow: hidden; height: 100vh; overscroll-behavior: none; }
  #app { flex-direction: row; min-height: auto; height: 100vh; }

  /* 显示侧边栏 */
  .sidebar {
    display: flex;
    flex-direction: column;
    width: 240px;
    flex-shrink: 0;
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
  }

  .sidebar-header {
    padding: 20px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
  }

  .sidebar-header .logo { font-size: 28px; }
  .sidebar-header h2 { font-size: 16px; color: #fff; }
  .sidebar-header .subtitle { font-size: 12px; color: var(--text-tertiary); }

  .nav-menu {
    flex: 1;
    padding: 12px 8px;
    overflow-y: auto;
  }

  .nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    color: var(--sidebar-text);
    text-decoration: none;
    font-size: 14px;
    margin-bottom: 2px;
    transition: var(--transition);
    cursor: pointer;
  }

  .nav-item:hover { background: rgba(255,255,255,0.06); color: #fff; }
  .nav-item.active { background: var(--sidebar-active); color: #fff; }
  .nav-icon { font-size: 18px; width: 24px; text-align: center; }

  .sidebar-footer {
    padding: 16px;
    border-top: 1px solid rgba(255,255,255,0.08);
  }

  .quick-stat {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    margin-bottom: 6px;
    border-radius: var(--radius-sm);
    background: rgba(255,255,255,0.04);
  }

  .sidebar-version {
    text-align: center;
    font-size: 11px;
    color: rgba(255,255,255,0.35);
    padding-top: 8px;
    margin-top: 4px;
    border-top: 1px solid rgba(255,255,255,0.06);
  }

  .qs-label { font-size: 12px; color: var(--text-tertiary); }
  .qs-value { font-size: 14px; font-weight: 600; color: #fff; }

  /* 隐藏移动端导航 */
  .mobile-nav { display: none; }

  /* 主内容区 */
  .main-content {
    flex: 1;
    flex-direction: column;
    overflow: hidden;
    padding-bottom: 0;
    height: 100%;
    min-height: 0;
  }

  .page-content {
    height: 100%;
    min-height: 0;
  }

  .top-bar { padding: 16px 24px; }
  .top-bar h1 { font-size: 20px; }
  .page-content { padding: 24px; }

  /* 桌面端隐藏齿轮按钮（侧边栏已有设置入口） */
  .btn-icon-settings { display: none; }

  /* 统计卡片 */
  .stat-grid { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; }
  .stat-card { padding: 20px; }
  .stat-icon { font-size: 28px; }
  .stat-value { font-size: 24px; }
  .stat-label { font-size: 13px; }
  .stat-card::before { width: 4px; }

  /* 表格 */
  table { font-size: 13px; }
  th { padding: 10px 12px; font-size: 13px; }
  td { padding: 10px 12px; }
  tr:hover td { background: var(--surface-alt); }

  /* 表单 - 桌面端并排 */
  .form-row { flex-direction: row; }
  .form-row > * { flex: 1; }
  .form-row-3 { flex-direction: row; }
  .form-row-3 > * { flex: 1; }

  /* 模态框 - 桌面端居中 */
  .modal-overlay { align-items: center; }
  .modal {
    border-radius: var(--radius);
    width: 90%;
    max-width: 600px;
    max-height: 85vh;
  }
  .modal.modal-lg { max-width: 800px; }
  .modal.modal-sm { max-width: 400px; max-height: 80vh; }
  .modal-header { border-radius: var(--radius) var(--radius) 0 0; padding: 16px 20px; }
  .modal-title { font-size: 18px; }
  .modal-body { padding: 20px; }
  .modal-footer { padding: 16px 20px; }
  @keyframes slideUp { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

  /* 按钮 */
  .btn { padding: 8px 16px; min-height: auto; font-size: 14px; }
  .btn-sm { padding: 4px 10px; font-size: 12px; min-height: auto; }
  .btn-icon { padding: 6px; font-size: 16px; min-width: auto; min-height: auto; }
  .btn-primary:hover { background: var(--primary-dark); }
  .btn-secondary:hover { background: var(--border); }
  .btn-icon:hover { background: var(--surface-alt); }

  /* Toast */
  #toast-container { top: 20px; right: 20px; left: auto; transform: none; width: auto; }
  @keyframes slideDown { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

  /* 仓储网格 */
  .storage-card-grid { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }

  /* 卡片 */
  .card { padding: 20px; margin-bottom: 16px; }
}

/* 合并售出订单标签 & 分组行 */
.order-tag {
  display: inline-block;
  font-size: 11px;
  padding: 1px 7px;
  border-radius: 10px;
  background: #eef2ff;
  color: #4338ca;
  border: 1px solid #c7d2fe;
  white-space: nowrap;
}
tr.order-merged > td { background: #f8faff; }
tr.order-detail-row > td { border-top: none; color: var(--text-muted); }

/* ================================================================ */
/* v71 移动端团购券卡片视图（仅在 window.innerWidth <= 767 生效） */
/* ================================================================ */
@media (max-width: 480px) {
  .coupon-card-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 12px;
  }
  .coupon-card {
    background: var(--surface);
    border: 0.5px solid var(--border);
    border-radius: 10px;
    padding: 12px 14px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.03);
  }
  .coupon-card:active { background: var(--surface-alt); }
  .cc-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 8px;
    margin-bottom: 6px;
  }
  .cc-name {
    font-size: 14px;
    font-weight: 500;
    color: var(--text);
    flex: 1;
    line-height: 1.4;
    word-break: break-word;
  }
  .cc-meta {
    font-size: 12px;
    color: var(--text-tertiary);
    margin-bottom: 6px;
    display: flex;
    flex-wrap: wrap;
    gap: 2px;
    align-items: center;
  }
  .cc-dot { color: var(--text-tertiary); margin: 0 2px; }
  .cc-pm { color: var(--text-secondary); }
  .cc-row {
    display: flex;
    align-items: baseline;
    gap: 10px;
    margin: 6px 0;
  }
  .cc-price {
    font-size: 16px;
    font-weight: 500;
    color: var(--primary);
  }
  .cc-date {
    font-size: 11px;
    color: var(--text-tertiary);
    margin-bottom: 8px;
    line-height: 1.5;
  }
  .cc-actions {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
    padding-top: 8px;
    border-top: 0.5px solid var(--border);
  }
  .cc-act {
    flex: 1;
    min-width: 36px;
    height: 32px;
    background: var(--surface-alt);
    border: 0.5px solid var(--border);
    border-radius: 6px;
    font-size: 14px;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
  }
  .cc-act:active { transform: scale(0.94); background: var(--border); }

  /* 状态徽章（仅移动端卡片用） */
  .cc-badge {
    display: inline-block;
    font-size: 10px;
    padding: 2px 7px;
    border-radius: 8px;
    font-weight: 500;
    white-space: nowrap;
    flex-shrink: 0;
  }
  .cc-badge-green { background: #e8f5ec; color: #1f7a3a; }
  .cc-badge-yellow { background: #fff5e0; color: #a35a00; }
  .cc-badge-red { background: #fceceb; color: #a32d2d; }
  .cc-badge-gray { background: #eef0f3; color: #5b6470; }
  .cc-badge-blue { background: #e8eef9; color: #185fa5; }

  /* 移动端 5 项底部导航（去掉 .mobile-nav 的 8 个 padding，5 个更宽松） */
  .mobile-nav-item .mni-icon { font-size: 24px; }
  .mobile-nav-item .mni-label { font-size: 11px; }

  /* 团购券顶部统计卡：移动端 2 列更紧凑 */
  .stat-grid { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .stat-card { padding: 12px 10px; }
  .stat-icon { font-size: 20px; }
  .stat-value { font-size: 18px; }
  .stat-label { font-size: 11px; }
  .stat-sub { font-size: 10px; }

  /* 筛选条：移动端允许换行 */
  .filter-bar { flex-wrap: wrap; gap: 6px; }
  .filter-bar .form-select,
  .filter-bar .form-input { font-size: 13px; padding: 6px 10px; min-width: 0; flex: 1 1 calc(50% - 4px); }
}

/* ================================================================ */
/* v71 更多抽屉（仅移动端显示） */
/* ================================================================ */
.more-drawer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--surface);
  border-radius: 14px 14px 0 0;
  box-shadow: 0 -4px 20px rgba(0,0,0,0.15);
  z-index: 950;
  transform: translateY(100%);
  transition: transform 0.25s ease;
  max-height: 70vh;
  overflow-y: auto;
  padding-bottom: var(--safe-bottom);
}
.more-drawer.open { transform: translateY(0); }
.more-drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 940;
  display: none;
}
.more-drawer-backdrop.open { display: block; }
.more-drawer-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 18px 8px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
}
.more-drawer-close {
  background: none;
  border: none;
  font-size: 22px;
  cursor: pointer;
  color: var(--text-secondary);
  padding: 0 4px;
  line-height: 1;
}
.more-drawer-group {
  padding: 8px 18px 14px;
}
.more-drawer-group-title {
  font-size: 11px;
  color: var(--text-tertiary);
  margin-bottom: 6px;
  font-weight: 500;
}
.more-drawer-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 8px;
  border-radius: 8px;
  color: var(--text);
  text-decoration: none;
  font-size: 14px;
  -webkit-tap-highlight-color: transparent;
}
.more-drawer-item:active { background: var(--surface-alt); }
.more-drawer-item .mdi-icon { font-size: 18px; width: 24px; text-align: center; }
.more-drawer-item .mdi-label { font-weight: 500; }

@media (min-width: 768px) {
  .more-drawer, .more-drawer-backdrop { display: none !important; }
}

/* ================================================================ */
/* v72 通用表格转卡片（消费/收入/服装/日用品/付款对账/售出 全部生效） */
/* 依赖：app.js applyMobileCardLabels() 给 td 打 data-label */
/* ================================================================ */
@media (max-width: 480px) {
  .table-container {
    overflow: visible;
    margin: 0;
    padding: 0;
  }
  .table-container table { display: block; width: 100%; }
  .table-container thead { display: none; }
  .table-container tfoot { display: block; margin-top: 10px; }

  /* 每一行 = 一张卡片（flex column 让主标题可以 order 到顶部） */
  .table-container tbody tr {
    display: flex;
    flex-direction: column;
    background: var(--surface);
    border: 0.5px solid var(--border);
    border-radius: 10px;
    padding: 12px 14px;
    margin-bottom: 10px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.03);
  }

  /* 单元格：左标签 / 右数值 */
  .table-container tbody td {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 12px;
    padding: 3px 0;
    border: none;
    font-size: 13px;
    text-align: right;
  }
  .table-container tbody td::before {
    content: attr(data-label);
    flex-shrink: 0;
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: 400;
    text-align: left;
  }
  .table-container tbody td[data-label=""]::before { content: none; }

  /* 主标题单元格（物品名 / 名称 / 付款方式 / 券名称 / 收入备注）
     order:-1 把它排到卡片最顶部，不管它在原表格里是第几列 */
  .table-container tbody td.cell-primary {
    order: -1;
    display: block;
    font-size: 15px;
    font-weight: 500;
    text-align: left;
    padding-bottom: 8px;
    margin-bottom: 4px;
    border-bottom: 0.5px solid var(--border);
    line-height: 1.4;
  }
  .table-container tbody td.cell-primary::before { content: none; }
  .table-container tbody td.cell-primary .text-muted { font-weight: 400; margin-top: 2px; }
  /* 主标题内的副标题小字（如付款方式名下面的备注） */
  .table-container tbody td.cell-primary div { font-size: 13px; }

  /* 整行单元格（colspan：合并订单明细、付款对账额外信息行） */
  .table-container tbody td.cell-full {
    display: block;
    text-align: left;
    background: var(--surface-alt);
    border-radius: 6px;
    padding: 6px 8px;
    margin-top: 6px;
    font-size: 12px;
    line-height: 1.5;
  }
  .table-container tbody td.cell-full::before { content: none; }

  /* 操作列：按钮横排等分，方便手指点 */
  .table-container tbody td.cell-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    justify-content: flex-start;
    padding-top: 8px;
    margin-top: 6px;
    border-top: 0.5px solid var(--border);
  }
  .table-container tbody td.cell-actions::before { content: none; }
  .table-container tbody td.cell-actions .btn-icon {
    flex: 1 1 0;
    min-width: 38px;
    min-height: 36px;
    padding: 0 6px;
    font-size: 15px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--surface-alt);
    border: 0.5px solid var(--border);
    border-radius: 6px;
  }
  .table-container tbody td.cell-actions .btn-icon:active {
    transform: scale(0.94);
    background: var(--border);
  }
  .table-container tbody td.cell-actions .btn {
    flex: 1 1 auto;
    min-height: 36px;
    padding: 0 10px;
    font-size: 13px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  /* 合计行 */
  .table-container tfoot tr {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 12px;
    background: var(--surface-alt);
    border: 0.5px solid var(--border);
    border-radius: 10px;
    padding: 10px 14px;
    font-weight: 500;
  }
  .table-container tfoot td.cell-total {
    display: block;
    padding: 0;
    border: none;
    font-size: 14px;
  }
  .table-container tfoot td.cell-total::before { content: none; }

  /* 售出的合并订单明细行：接在主卡下方弱化显示 */
  .table-container tbody tr.order-detail-row {
    margin-top: -12px;
    border-radius: 0 0 10px 10px;
    border-top: none;
    background: var(--surface-alt);
    padding: 4px 14px 10px;
  }
  .table-container tbody tr.order-detail-row > td {
    display: block;
    text-align: left;
    font-size: 12px;
  }
  .table-container tbody tr.order-detail-row > td::before { content: none; }
}

/* ===== v73 昨日过期图标 ===== */
.card-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.yexp-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  background: #fff;
  color: var(--danger);
  border: 1px solid var(--border);
  transition: all 0.15s ease;
  white-space: nowrap;
}
.yexp-btn:hover { background: #fff5f5; border-color: var(--danger); }
.yexp-btn:active { transform: translateY(1px); }
.yexp-btn.has-item { border-color: var(--danger); background: #fff1f1; }
.yexp-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  background: var(--danger);
  color: #fff;
  border-radius: 9px;
  font-size: 11px;
  font-weight: 600;
  line-height: 1;
}
.yexp-section { margin-bottom: 18px; }
.yexp-section-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 8px;
  padding-left: 8px;
  border-left: 3px solid var(--danger);
}
/* 移动端：两个按钮各占一半，加大点击区 */
@media (max-width: 480px) {
  .card-header { flex-wrap: wrap; }
  .card-header-actions { width: 100%; }
  .card-header-actions .yexp-btn,
  .card-header-actions .btn {
    flex: 1;
    justify-content: center;
    min-height: 38px;
  }
}

/* ================================================================
   v74 桌面端窗口自适应
   窗口缩小时按列优先级依次隐藏次要列，保证「操作」列（编辑/复制/删除）始终可见。
   断点已扣除左侧边栏（约 240px），按内容区实际可用宽度设计。
   手机端（≤767px）仍走 v72 的卡片视图，不受本段影响。
   ================================================================ */

/* 兜底最小宽度：列已精简后仍放不下时，才出现横向滚动条（按钮永远滚得到） */
@media (min-width: 768px) {
  .table-container table { min-width: 520px; }
}

/* 窗口 <1240px（内容区约 <1000px）：先隐藏 P2 辅助列（平台/品牌/分类/说明…） */
@media (min-width: 768px) and (max-width: 1239px) {
  .table-container .col-p2 { display: none; }
}

/* 窗口 <1040px（内容区约 <800px）：再隐藏 P1 次要列（数量/价格/日期…），只留名称/状态/操作 */
@media (min-width: 768px) and (max-width: 1039px) {
  .table-container .col-p1 { display: none; }
}

/* ================================================================
   v75 操作列钉在右边缘（sticky）
   桌面表格横向滚动时，「操作」列永远钉在右边缘可见
   必须把 table 改为 border-collapse: separate 才能让 sticky 在 td 上工作
   ================================================================ */

@media (min-width: 481px) {
  /* sticky 必需：separate 模式 + spacing 0 */
  .table-container table {
    border-collapse: separate;
    border-spacing: 0;
  }
  /* 单独画边框（替代 collapse 自带的合并边框） */
  .table-container table th,
  .table-container table td {
    border-bottom: 1px solid var(--border);
    border-right: 1px solid var(--border-light, #eef0f3);
  }
  .table-container table th {
    border-top: 1px solid var(--border);
  }
  .table-container table th:last-child,
  .table-container table td:last-child {
    border-right: none;
  }

  /* 「操作」列钉在右边缘：不透明背景 + 阴影 + 高 z-index */
  .table-container table thead th:last-child,
  .table-container table tbody td:last-child,
  .table-container table tfoot td:last-child {
    position: sticky;
    right: 0;
    background: var(--surface);
    z-index: 2;
    box-shadow: -3px 0 6px rgba(0, 0, 0, 0.1);
  }
  .table-container table thead th:last-child {
    background: var(--surface-alt);
  }
}

/* ================================================================
   v76 对账明细弹窗（账单流水）
   4 列紧凑布局：日期（短MM-DD）+ 说明（名称+备注两行）+ 金额 + 类别徽章
   顶部加一行统计条：支出/退款/收入/净额
   ================================================================ */

/* 顶部 4 项统计条 */
.bill-detail-stats {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
  flex-wrap: wrap;
  font-size: 12px;
}
.bds-item {
  padding: 6px 10px;
  border-radius: 6px;
  background: var(--surface-alt, #f5f7fa);
  color: var(--text-muted);
}
.bds-item strong { color: var(--text); margin-left: 4px; font-size: 13px; }
.bds-out { border-left: 3px solid #ff6b6b; }
.bds-out strong { color: #d63031; }
.bds-back { border-left: 3px solid #fdcb6e; }
.bds-back strong { color: #e17055; }
.bds-in { border-left: 3px solid #00b894; }
.bds-in strong { color: #00a381; }
.bds-net { border-left: 3px solid #6c5ce7; background: #f0efff; }
.bds-net strong { color: #5f4dd0; }

/* 主表格：4 列紧凑 */
.bill-detail-table {
  table-layout: fixed;
  width: 100%;
}
.bill-detail-table thead th {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  padding: 8px 10px;
  background: var(--surface-alt, #f5f7fa);
  border-bottom: 1px solid var(--border);
}
.bill-detail-table tbody td {
  padding: 10px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
  word-break: break-word;
}
.bill-detail-table tbody tr:hover {
  background: var(--surface-alt, #f9fafb);
}

/* 各列宽 */
.bd-date { width: 56px; text-align: center; }
.bd-amt { width: 100px; text-align: right; }
.bd-cat { width: 110px; text-align: center; }
.bd-date-cell { text-align: center; }
.bd-day {
  display: inline-block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  background: var(--surface-alt, #f5f7fa);
  padding: 4px 8px;
  border-radius: 6px;
}
.bd-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  line-height: 1.4;
  margin-bottom: 2px;
}
.bd-note {
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.4;
}
.bd-amt-cell {
  text-align: right;
  font-weight: 600;
  font-size: 14px;
  font-variant-numeric: tabular-nums;
}
.bd-pay { color: #d63031; }
.bd-refund { color: #00a381; }

/* 5 类别彩色徽章 */
.bd-badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 500;
  padding: 3px 8px;
  border-radius: 10px;
  white-space: nowrap;
  border: 1px solid;
}
.bd-团购券支出 { background: #fff5e6; color: #d97706; border-color: #fcd9a3; }
.bd-核销券支出 { background: #e3f2fd; color: #1976d2; border-color: #bbdefb; }
.bd-卖出券支出 { background: #e8f5e9; color: #2e7d32; border-color: #c8e6c9; }
.bd-消费支出 { background: #f3e5f5; color: #7b1fa2; border-color: #e1bee7; }
.bd-本期退款 { background: #fff8e1; color: #e65100; border-color: #ffe0b2; }
.bd-物品退货 { background: #fce4ec; color: #c2185b; border-color: #f8bbd0; }
.bd-已过期未核销 { background: #ffebee; color: #b71c1c; border-color: #ffcdd2; }
.bd-收入 { background: #e0f7fa; color: #00695c; border-color: #b2dfdb; }
.bd-提前计入支出 { background: #fff7ed; color: #c2410c; border-color: #fed7aa; }
.bd-未使用退款 { background: #ecfdf5; color: #047857; border-color: #a7f3d0; }

/* 团购券列表：未使用计入账单 标记 */
.coupon-flag { display: inline-block; font-size: 11px; font-weight: 600; padding: 1px 6px; border-radius: 8px; background: #fff7ed; color: #c2410c; border: 1px solid #fed7aa; margin-left: 4px; vertical-align: middle; }

/* 手机快捷指令待合并提示条 */
#mobile-pending-bar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 9999;
  display: none; align-items: center; gap: 12px;
  padding: 10px 16px;
  background: linear-gradient(90deg, #2563eb, #1d4ed8);
  color: #fff; font-size: 14px; box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}
#mobile-pending-bar .mpb-text { flex: 1; }
#mobile-pending-bar .mpb-text b { font-size: 16px; }
#mobile-pending-bar .mpb-btn {
  border: none; border-radius: 8px; padding: 6px 14px; font-size: 13px; font-weight: 600; cursor: pointer;
}
#mobile-pending-bar .mpb-merge { background: #ffffff; color: #1d4ed8; }
#mobile-pending-bar .mpb-merge:hover { background: #e0e7ff; }
#mobile-pending-bar .mpb-skip { background: rgba(255,255,255,0.2); color: #fff; }
#mobile-pending-bar .mpb-skip:hover { background: rgba(255,255,255,0.3); }
