/* =====================================================
   比耶科技订单管理系统 — 主样式 (美化版)
   ===================================================== */

/* ---------- CSS Variables ---------- */
:root {
  --primary:        #5b50f0;
  --primary-hover:  #4840d4;
  --primary-light:  #f0effe;
  --primary-mid:    #ddd9fd;
  --primary-dark:   #3730a3;
  --danger:         #f04848;
  --danger-hover:   #dc2626;
  --danger-light:   #fff1f1;
  --success:        #10b981;
  --success-light:  #ecfdf5;
  --warning:        #f59e0b;
  --warning-light:  #fffbeb;
  --info:           #3b82f6;
  --info-light:     #eff6ff;
  --gray-50:        #f8f9fc;
  --gray-100:       #f1f3f8;
  --gray-150:       #eaecf3;
  --gray-200:       #e2e5ef;
  --gray-300:       #c9cede;
  --gray-400:       #9ba3b8;
  --gray-500:       #6b7494;
  --gray-600:       #4b5372;
  --gray-700:       #353d5e;
  --gray-800:       #1e2541;
  --gray-900:       #10152e;
  --white:          #ffffff;
  --shadow-xs:      0 1px 2px rgba(15,20,60,.04);
  --shadow-sm:      0 1px 4px rgba(15,20,60,.07), 0 1px 2px rgba(15,20,60,.04);
  --shadow-md:      0 4px 16px rgba(15,20,60,.10), 0 2px 6px rgba(15,20,60,.05);
  --shadow-lg:      0 12px 40px rgba(15,20,60,.14), 0 4px 12px rgba(15,20,60,.06);
  --shadow-primary: 0 4px 16px rgba(91,80,240,.28);
  --radius-xs:      4px;
  --radius-sm:      8px;
  --radius:         12px;
  --radius-lg:      16px;
  --radius-xl:      20px;
  --topbar-h:       62px;
  --transition:     .18s cubic-bezier(.4,0,.2,1);
  --transition-fast:.12s cubic-bezier(.4,0,.2,1);
}

/* ---------- Reset ---------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; scroll-behavior: smooth; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
               "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: var(--gray-50);
  color: var(--gray-800);
  min-height: 100vh;
  line-height: 1.5;
}
a { color: inherit; text-decoration: none; }
input, textarea, select, button { font-family: inherit; font-size: inherit; }
img { max-width: 100%; }

/* ---------- Topbar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 100;
  height: var(--topbar-h);
  background: rgba(255,255,255,.92);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--gray-150);
  box-shadow: 0 1px 12px rgba(15,20,60,.06);
}
.topbar-inner {
  max-width: 1320px; margin: 0 auto; padding: 0 28px;
  height: 100%; display: flex; align-items: center; gap: 20px;
}
.topbar-brand { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.brand-icon {
  height: 32px; width: auto;
  flex-shrink: 0;
  display: block;
  object-fit: contain;
}

.brand-name {
  font-size: 17px; font-weight: 800; color: var(--gray-900);
  letter-spacing: -.4px;
  background: linear-gradient(135deg, var(--primary-dark), var(--primary));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text;
}

.back-link {
  display: flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; border-radius: var(--radius-sm);
  color: var(--gray-500); transition: background var(--transition), color var(--transition);
}
.back-link:hover { background: var(--gray-100); color: var(--primary); }
.back-link svg { width: 18px; height: 18px; }

/* 导航 */
.topbar-nav { display: flex; align-items: center; gap: 2px; flex: 1; }
.nav-link {
  padding: 7px 14px; border-radius: var(--radius-sm);
  font-size: 14px; font-weight: 500;
  color: var(--gray-500); transition: all var(--transition);
  position: relative;
}
.nav-link:hover { background: var(--gray-100); color: var(--gray-800); }
.nav-link.active {
  background: var(--primary-light);
  color: var(--primary);
  font-weight: 700;
}

/* 右侧 */
.topbar-right { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.admin-info {
  display: flex; align-items: center; gap: 6px;
  font-size: 13px; color: var(--gray-500);
  background: var(--gray-100); padding: 5px 12px;
  border-radius: 999px;
}
.admin-info svg { color: var(--primary); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 0 18px; height: 38px; border-radius: var(--radius-sm);
  font-size: 14px; font-weight: 600; cursor: pointer;
  border: 1.5px solid transparent; transition: all var(--transition);
  white-space: nowrap; position: relative; overflow: hidden;
}
.btn::after {
  content: ''; position: absolute; inset: 0;
  background: rgba(255,255,255,0); transition: background var(--transition-fast);
  pointer-events: none;
}
.btn:hover::after { background: rgba(255,255,255,.12); }
.btn:active { transform: translateY(1px); }
.btn svg { width: 15px; height: 15px; flex-shrink: 0; }

.btn-primary {
  background: linear-gradient(135deg, var(--primary) 0%, #7c6ff7 100%);
  color: var(--white); border-color: var(--primary);
  box-shadow: 0 2px 10px rgba(91,80,240,.30);
}
.btn-primary:hover {
  background: linear-gradient(135deg, var(--primary-hover) 0%, #6a5ef5 100%);
  box-shadow: 0 4px 16px rgba(91,80,240,.40);
  transform: translateY(-1px);
}
.btn-primary:active { transform: translateY(0); box-shadow: 0 1px 6px rgba(91,80,240,.25); }

.btn-secondary {
  background: var(--white); color: var(--primary);
  border-color: var(--primary-mid);
}
.btn-secondary:hover { background: var(--primary-light); border-color: var(--primary); }

.btn-ghost {
  background: var(--white); color: var(--gray-600);
  border-color: var(--gray-200);
}
.btn-ghost:hover { background: var(--gray-100); color: var(--gray-800); border-color: var(--gray-300); }

.btn-danger {
  background: linear-gradient(135deg, var(--danger) 0%, #f97316 100%);
  color: var(--white); border-color: var(--danger);
  box-shadow: 0 2px 8px rgba(240,72,72,.25);
}
.btn-danger:hover {
  background: linear-gradient(135deg, var(--danger-hover) 0%, #ea6010 100%);
  box-shadow: 0 4px 12px rgba(240,72,72,.35);
  transform: translateY(-1px);
}

.btn-sm  { height: 32px; padding: 0 14px; font-size: 13px; border-radius: 7px; }
.btn-lg  { height: 46px; padding: 0 30px; font-size: 15px; border-radius: 10px; }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none !important; box-shadow: none !important; }

/* 警告色按钮 */
.btn-warn {
  background: #fffbeb; color: #92400e;
  border-color: #fde68a;
}
.btn-warn:hover { background: #fef3c7; border-color: #fbbf24; }

/* ---------- Main Content ---------- */
.main-content {
  max-width: 1320px; margin: 0 auto; padding: 28px 28px;
}

/* ---------- Search Bar ---------- */
.search-bar {
  display: flex; align-items: center; gap: 10px; margin-bottom: 20px; flex-wrap: wrap;
}
.search-input-wrap {
  position: relative; flex: 1; min-width: 200px; max-width: 440px;
}
.search-icon {
  position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
  width: 15px; height: 15px; color: var(--gray-400); pointer-events: none;
}
.search-input {
  width: 100%; height: 38px; padding: 0 14px 0 38px;
  border: 1.5px solid var(--gray-200); border-radius: var(--radius-sm);
  background: var(--white); color: var(--gray-800); outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.search-input:focus {
  border-color: var(--primary); box-shadow: 0 0 0 3px rgba(91,80,240,.12);
}
.search-input::placeholder { color: var(--gray-400); }

/* ---------- Stats Row ---------- */
.stats-row {
  display: flex; gap: 14px; margin-bottom: 22px; flex-wrap: wrap;
}
.stat-card {
  flex: 1; min-width: 130px; max-width: 200px;
  background: var(--white);
  border: 1.5px solid var(--gray-150);
  border-radius: var(--radius);
  padding: 12px 14px;
  box-shadow: var(--shadow-sm);
  display: flex; flex-direction: column; gap: 4px;
  transition: box-shadow var(--transition), transform var(--transition), border-color var(--transition);
  position: relative; overflow: hidden;
}
.stat-card::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 3px;
  background: linear-gradient(90deg, var(--primary), #7c6ff7);
  opacity: 0; transition: opacity var(--transition);
}
.stat-card:hover {
  box-shadow: var(--shadow-md); transform: translateY(-2px);
  border-color: var(--primary-mid);
}
.stat-card:hover::before { opacity: 1; }
.stat-label {
  font-size: 11px; color: var(--gray-500); font-weight: 600;
  text-transform: uppercase; letter-spacing: .04em;
}
.stat-value {
  font-size: 20px; font-weight: 800; color: var(--gray-900); line-height: 1.2;
}
.stat-sub { font-size: 11px; color: var(--gray-400); }
.stat-card-warn .stat-value { color: #d97706; }

/* ---------- Table Card ---------- */
.table-card {
  background: var(--white);
  border: 1.5px solid var(--gray-150);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  transition: box-shadow var(--transition);
}
.table-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 24px; border-bottom: 1.5px solid var(--gray-100);
  background: linear-gradient(to right, var(--white), var(--gray-50));
}
.table-title { font-size: 16px; font-weight: 700; color: var(--gray-900); }
.table-count {
  font-size: 12px; color: var(--gray-400);
  background: var(--gray-100); padding: 2px 10px; border-radius: 999px;
}
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.data-table {
  width: 100%; border-collapse: collapse; font-size: 14px;
}
.data-table th {
  background: var(--gray-50); padding: 10px 14px;
  text-align: left; font-size: 11px; font-weight: 700;
  color: var(--gray-500); letter-spacing: .05em; text-transform: uppercase;
  border-bottom: 1.5px solid var(--gray-150); white-space: nowrap;
  position: sticky; top: 0; z-index: 1;
}
.data-table td {
  padding: 12px 14px; border-bottom: 1px solid var(--gray-100);
  color: var(--gray-700); vertical-align: middle;
  white-space: nowrap;
}
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr { transition: background var(--transition-fast); }
.data-table tbody tr:hover td { background: #f5f3ff; }

.empty-cell { text-align: center; padding: 56px 0 !important; color: var(--gray-400); font-size: 14px; white-space: normal !important; }

/* 订单标题列允许换行 */
.order-title-cell {
  font-weight: 600; color: var(--gray-900);
  max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  cursor: pointer; transition: color var(--transition);
}
.order-title-cell:hover { color: var(--primary); }

/* 金额列 */
.amount-cell {
  font-weight: 700; color: var(--gray-900);
  font-variant-numeric: tabular-nums; font-size: 14px;
  white-space: nowrap;
}
.td-final-amt { color: #d97706 !important; }

/* 列宽语义 class */
.td-check   { width: 44px; padding-left: 16px !important; padding-right: 8px !important; }
.td-no      { width: 88px; }
.td-title   { min-width: 160px; }
.td-orderno { width: 130px; }
.td-final   { width: 148px; }
.td-expense-amt { width: 110px; }
.td-note-col    { width: 130px; }
.td-attach  { width: 60px; text-align: center; }
.td-meta    { width: 90px; font-size: 12px; color: var(--gray-400); }
.td-status  { width: 90px; }
.td-actions { width: 148px; }

/* 通用单元格辅助 class */
.td-empty { color: var(--gray-300); font-size: 13px; }
.td-mono  { font-family: 'Courier New', monospace; font-size: 12px; color: var(--gray-500); }
.td-note  { display: inline-block; max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; vertical-align: middle; font-size: 13px; color: var(--gray-600); }
.td-expense { color: #ef4444; font-weight: 700; font-size: 13px; }
.td-date  { font-size: 12px; color: var(--gray-400); }
.td-done  { font-size: 12px; color: var(--success); font-weight: 600; }

/* 尾款单元格包裹（badge + 撤销按钮） */
.final-cell-wrap { display: flex; align-items: center; gap: 6px; flex-wrap: nowrap; }

/* 超小按钮（撤销等） */
.btn-xs {
  height: 24px; padding: 0 8px; font-size: 11px; border-radius: 5px;
  font-weight: 600; cursor: pointer; display: inline-flex; align-items: center;
  border: 1.5px solid; transition: all var(--transition-fast); white-space: nowrap;
}
.btn-undo {
  background: #fffbeb; color: #d97706; border-color: #fde68a;
}
.btn-undo:hover { background: #fef3c7; border-color: #fbbf24; }

/* 尾款已付按钮（紧凑） */
.btn-final-pay { white-space: nowrap; font-size: 12px; }

/* 危险幽灵按钮 */
.btn-danger-ghost {
  background: transparent; color: #ef4444; border-color: #fca5a5;
}
.btn-danger-ghost:hover { background: var(--danger-light); border-color: var(--danger); }

/* 操作列按钮组 */
.action-group { display: flex; gap: 5px; align-items: center; flex-wrap: nowrap; }
.action-group .btn-sm { padding: 0 10px; height: 28px; font-size: 12px; }

.no-cell {
  font-family: 'Courier New', monospace; font-weight: 700;
  color: var(--primary); font-size: 13px;
  background: var(--primary-light); padding: 2px 8px;
  border-radius: 5px; display: inline-block;
}

/* Badge */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 10px; border-radius: 999px;
  font-size: 12px; font-weight: 600; letter-spacing: .01em;
}
.badge-yes    { background: #fef3c7; color: #92400e; }
.badge-no     { background: var(--gray-100); color: var(--gray-500); }
.badge-attach { background: #dbeafe; color: #1e40af; }
.badge-paid   { background: #d1fae5; color: #065f46; }
.badge-unpaid { background: #fef3c7; color: #92400e; }
.badge-super  { background: #ede9fe; color: #5b21b6; }

.action-group { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }

/* ---------- Pagination ---------- */
.pagination {
  display: flex; align-items: center; justify-content: flex-end; gap: 5px;
  padding: 16px 24px; border-top: 1.5px solid var(--gray-100);
}
.page-btn {
  min-width: 34px; height: 34px; padding: 0 10px;
  border: 1.5px solid var(--gray-200); border-radius: var(--radius-sm);
  background: var(--white); color: var(--gray-600); cursor: pointer;
  font-size: 13px; font-weight: 500;
  display: inline-flex; align-items: center; justify-content: center;
  transition: all var(--transition);
}
.page-btn:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-light); }
.page-btn.active {
  background: linear-gradient(135deg, var(--primary) 0%, #7c6ff7 100%);
  border-color: var(--primary); color: var(--white);
  box-shadow: 0 2px 8px rgba(91,80,240,.30);
}
.page-btn:disabled { opacity: .35; cursor: default; }
.page-info { font-size: 13px; color: var(--gray-400); margin: 0 6px; }

/* 日期筛选输入 */
.date-input { height: 38px; width: auto; min-width: 150px; }

/* ---------- Form Card ---------- */
.form-card {
  background: var(--white);
  border: 1.5px solid var(--gray-150);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-md);
  padding: 40px 44px; max-width: 900px; margin: 0 auto;
}
.form-group { margin-bottom: 24px; }
.form-label {
  display: block; font-size: 14px; font-weight: 700; color: var(--gray-700);
  margin-bottom: 8px; letter-spacing: .01em;
}
.form-label.required::after { content: " *"; color: var(--danger); }
.optional-tag {
  font-size: 12px; font-weight: 400; color: var(--gray-400);
  background: var(--gray-100); padding: 1px 7px; border-radius: 5px; margin-left: 6px;
}
.form-input {
  width: 100%; height: 42px; padding: 0 14px;
  border: 1.5px solid var(--gray-200); border-radius: var(--radius-sm);
  background: var(--white); color: var(--gray-800); outline: none;
  transition: border-color var(--transition), box-shadow var(--transition), background var(--transition);
}
.form-input:focus {
  border-color: var(--primary); box-shadow: 0 0 0 3px rgba(91,80,240,.12);
  background: #fdfcff;
}
.form-input:hover:not(:focus) { border-color: var(--gray-300); }
.form-input.is-error { border-color: var(--danger); box-shadow: 0 0 0 3px rgba(240,72,72,.10); }
.form-input::placeholder { color: var(--gray-400); }
.form-error { min-height: 20px; font-size: 13px; color: var(--danger); margin-top: 5px; }
.form-hint { font-size: 13px; color: var(--gray-400); margin-top: 6px; }

/* 金额前缀 */
.input-prefix-wrap { position: relative; }
.input-prefix {
  position: absolute; left: 0; top: 0; bottom: 0; width: 40px;
  display: flex; align-items: center; justify-content: center;
  font-size: 15px; font-weight: 600; color: var(--gray-500);
  border-right: 1.5px solid var(--gray-200); pointer-events: none;
}
.form-input.has-prefix { padding-left: 48px; }

/* 尾款/支出 开关行 */
.switch-row { margin: 4px 0; }
.switch-label { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; user-select: none; }
.switch-input { display: none; }
.switch-track {
  position: relative; width: 44px; height: 26px;
  background: var(--gray-300); border-radius: 13px; transition: background var(--transition);
  flex-shrink: 0;
}
.switch-input:checked + .switch-track {
  background: linear-gradient(135deg, var(--primary) 0%, #7c6ff7 100%);
  box-shadow: 0 2px 6px rgba(91,80,240,.30);
}
.switch-thumb {
  position: absolute; left: 3px; top: 3px; width: 20px; height: 20px;
  background: var(--white); border-radius: 50%;
  box-shadow: 0 1px 4px rgba(0,0,0,.22);
  transition: transform var(--transition);
}
.switch-input:checked + .switch-track .switch-thumb { transform: translateX(18px); }
.switch-text { font-size: 14px; color: var(--gray-700); font-weight: 500; }

/* ---------- Editor ---------- */
.editor-wrap {
  border: 1.5px solid var(--gray-200); border-radius: var(--radius-sm); overflow: hidden;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.editor-wrap.is-error { border-color: var(--danger); box-shadow: 0 0 0 3px rgba(240,72,72,.10); }
.editor-wrap:focus-within { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(91,80,240,.12); }
.editor-toolbar { border-bottom: 1.5px solid var(--gray-200) !important; background: var(--gray-50) !important; }
.editor-content { min-height: 240px; max-height: 600px; overflow-y: auto; }

/* ---------- Upload Zone ---------- */
.upload-zone {
  position: relative; border: 2px dashed var(--gray-300); border-radius: var(--radius);
  padding: 32px 24px; text-align: center; cursor: pointer;
  background: var(--gray-50);
  transition: border-color var(--transition), background var(--transition), box-shadow var(--transition);
}
.upload-zone:hover, .upload-zone.drag-over {
  border-color: var(--primary); background: var(--primary-light);
  box-shadow: 0 0 0 4px rgba(91,80,240,.06);
}
.upload-input { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; height: 100%; }
.upload-prompt { pointer-events: none; }
.upload-prompt svg { width: 40px; height: 40px; color: var(--gray-400); margin-bottom: 12px; }
.upload-text { display: block; font-size: 15px; font-weight: 600; color: var(--gray-600); margin-bottom: 6px; }
.upload-hint { display: block; font-size: 13px; color: var(--gray-400); line-height: 1.7; }

/* 文件列表 */
.file-list { margin-top: 14px; display: flex; flex-direction: column; gap: 8px; }
.file-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; background: var(--gray-50);
  border: 1.5px solid var(--gray-200); border-radius: var(--radius-sm);
  transition: border-color var(--transition), background var(--transition);
}
.file-item:hover { border-color: var(--primary-mid); background: var(--primary-light); }
.file-icon { width: 34px; height: 34px; flex-shrink: 0; display: flex; align-items: center; justify-content: center; border-radius: 8px; }
.file-icon.type-image   { background: #fce7f3; }
.file-icon.type-archive { background: #fef3c7; }
.file-icon.type-doc     { background: #dbeafe; }
.file-icon.type-sheet   { background: #d1fae5; }
.file-icon.type-pdf     { background: #fee2e2; }
.file-icon.type-other   { background: var(--gray-200); }
.file-icon svg { width: 18px; height: 18px; }
.file-info { flex: 1; min-width: 0; }
.file-name { font-size: 14px; color: var(--gray-800); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-size { font-size: 12px; color: var(--gray-400); margin-top: 2px; }
.file-remove {
  flex-shrink: 0; width: 28px; height: 28px; border: none; background: none;
  cursor: pointer; color: var(--gray-400); border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  transition: color var(--transition), background var(--transition);
}
.file-remove:hover { color: var(--danger); background: var(--danger-light); }
.file-remove svg { width: 15px; height: 15px; }

/* ---------- Form Actions ---------- */
.form-actions {
  display: flex; align-items: center; justify-content: flex-end; gap: 12px;
  margin-top: 36px; padding-top: 24px; border-top: 1.5px solid var(--gray-100);
}

/* ---------- Modal ---------- */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(10,14,40,.5);
  display: none; align-items: center; justify-content: center;
  z-index: 500; padding: 24px;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}
.modal-overlay.active { display: flex; }
.modal {
  background: var(--white); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg); width: 100%;
  animation: modal-in .22s cubic-bezier(.34,1.56,.64,1);
  border: 1.5px solid var(--gray-150);
}
.modal-sm { max-width: 440px; }
.modal-lg { max-width: 780px; max-height: 82vh; display: flex; flex-direction: column; }
.modal-xl { max-width: 920px; max-height: 87vh; display: flex; flex-direction: column; }
@keyframes modal-in {
  from { opacity: 0; transform: scale(.94) translateY(-10px); }
  to   { opacity: 1; transform: scale(1)  translateY(0);    }
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 26px; border-bottom: 1.5px solid var(--gray-100);
  background: linear-gradient(to right, var(--white), var(--gray-50));
}
.modal-title { font-size: 17px; font-weight: 800; color: var(--gray-900); }
.modal-close {
  width: 32px; height: 32px; border: none; background: var(--gray-100); cursor: pointer;
  font-size: 20px; color: var(--gray-500); border-radius: 8px; line-height: 1;
  display: flex; align-items: center; justify-content: center;
  transition: color var(--transition), background var(--transition);
}
.modal-close:hover { color: var(--gray-900); background: var(--gray-200); }
.modal-body { padding: 24px 26px; overflow-y: auto; }
.modal-footer {
  display: flex; align-items: center; justify-content: flex-end; gap: 10px;
  padding: 16px 26px; border-top: 1.5px solid var(--gray-100);
  background: var(--gray-50);
}

/* 详情内容 */
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; margin-bottom: 24px; }
.detail-item {}
.detail-label { font-size: 12px; color: var(--gray-400); margin-bottom: 4px; font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
.detail-value { font-size: 15px; color: var(--gray-800); font-weight: 600; }
.detail-section { margin-bottom: 20px; }
.detail-section-title {
  font-size: 13px; font-weight: 800; color: var(--gray-600); text-transform: uppercase; letter-spacing: .06em;
  margin-bottom: 12px; padding-bottom: 8px; border-bottom: 1.5px solid var(--gray-100);
}
.content-preview {
  border: 1.5px solid var(--gray-200); border-radius: var(--radius-sm);
  padding: 16px; background: var(--gray-50); max-height: 280px; overflow-y: auto;
  font-size: 14px; line-height: 1.8; color: var(--gray-700);
}
.content-preview img { max-width: 100%; border-radius: 6px; }
.attach-list { display: flex; flex-direction: column; gap: 8px; }
.attach-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; background: var(--white);
  border: 1.5px solid var(--gray-200); border-radius: var(--radius-sm);
  transition: border-color var(--transition);
}
.attach-item:hover { border-color: var(--primary-mid); }
.attach-thumb { width: 40px; height: 40px; object-fit: cover; border-radius: 6px; flex-shrink: 0; }
.attach-info { flex: 1; min-width: 0; }
.attach-name { font-size: 14px; color: var(--gray-800); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.attach-meta { font-size: 12px; color: var(--gray-400); margin-top: 2px; }
.attach-download { flex-shrink: 0; }

/* ---------- Toast ---------- */
.toast-wrap {
  position: fixed; top: 20px; right: 20px; z-index: 9999;
  display: flex; flex-direction: column; gap: 8px;
}
.toast {
  padding: 12px 18px; border-radius: var(--radius-sm);
  font-size: 14px; font-weight: 600; color: var(--white);
  box-shadow: var(--shadow-lg); animation: toast-in .22s cubic-bezier(.34,1.3,.64,1);
  max-width: 380px; display: flex; align-items: center; gap: 9px;
  backdrop-filter: blur(8px);
}
@keyframes toast-in {
  from { opacity: 0; transform: translateX(24px) scale(.96); }
  to   { opacity: 1; transform: translateX(0)   scale(1);   }
}
.toast-success { background: linear-gradient(135deg, #059669, #10b981); }
.toast-error   { background: linear-gradient(135deg, #dc2626, #f04848); }
.toast-warning { background: linear-gradient(135deg, #d97706, #f59e0b); }
.toast svg { width: 18px; height: 18px; flex-shrink: 0; }

/* ---------- Loading Spin ---------- */
.loading-spin {
  display: inline-block; width: 18px; height: 18px; margin-right: 8px;
  border: 2.5px solid var(--gray-200); border-top-color: var(--primary);
  border-radius: 50%; animation: spin .65s linear infinite; vertical-align: middle;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Tab 组件 ---------- */
.tab-bar {
  display: flex; gap: 4px;
  border-bottom: 2px solid var(--gray-200); padding-bottom: 0;
}
.tab-btn {
  padding: 9px 20px; border: none; background: transparent;
  font-size: 14px; font-weight: 500; color: var(--gray-500); cursor: pointer;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  margin-bottom: -2px; border-bottom: 2px solid transparent;
  transition: color var(--transition), border-color var(--transition);
}
.tab-btn:hover { color: var(--gray-800); }
.tab-btn.active {
  color: var(--primary); border-bottom-color: var(--primary);
  background: var(--white); font-weight: 700;
}

/* ---------- Toggle Switch ---------- */
.toggle-switch {
  position: relative; display: inline-flex; align-items: center; cursor: pointer;
}
.toggle-switch input[type="checkbox"] { position: absolute; opacity: 0; width: 0; height: 0; }
.toggle-slider {
  width: 44px; height: 24px; background: var(--gray-300); border-radius: 999px;
  transition: background var(--transition); position: relative; flex-shrink: 0;
}
.toggle-slider::after {
  content: ''; position: absolute; top: 3px; left: 3px;
  width: 18px; height: 18px; background: var(--white); border-radius: 50%;
  transition: transform var(--transition); box-shadow: 0 1px 3px rgba(0,0,0,.2);
}
.toggle-switch input:checked + .toggle-slider { background: var(--primary); }
.toggle-switch input:checked + .toggle-slider::after { transform: translateX(20px); }

/* =====================================================
   数据统计页
   ===================================================== */

/* 快速时间段按钮 */
.quick-btn.active {
  background: linear-gradient(135deg, var(--primary) 0%, #7c6ff7 100%);
  color: var(--white); border-color: var(--primary);
  box-shadow: 0 2px 8px rgba(91,80,240,.28);
}

/* 筛选栏 */
.filter-bar {
  background: var(--white); border: 1.5px solid var(--gray-150);
  border-radius: var(--radius); padding: 16px 20px;
  box-shadow: var(--shadow-sm);
}

/* 统计卡片图标装饰 */
.stat-icon {
  width: 32px; height: 32px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; margin-bottom: 4px;
}
.stat-icon svg {
  width: 16px !important; height: 16px !important;
  max-width: 16px !important; max-height: 16px !important;
  flex-shrink: 0;
}
.stat-icon-blue   { background: #eff6ff; color: #3b82f6; }
.stat-icon-purple { background: var(--primary-light); color: var(--primary); }
.stat-icon-amber  { background: #fffbeb; color: #d97706; }
.stat-icon-red    { background: #fff1f1; color: #ef4444; }
.stat-icon-green  { background: #ecfdf5; color: #10b981; }

/* =====================================================
   移动端响应式
   ===================================================== */

/* ---- 汉堡按钮 ---- */
.hamburger {
  display: none;
  flex-direction: column; justify-content: center; align-items: center;
  gap: 5px; width: 38px; height: 38px; border: 1.5px solid var(--gray-200);
  background: var(--white); cursor: pointer; border-radius: var(--radius-sm);
  transition: all var(--transition); flex-shrink: 0;
}
.hamburger:hover { background: var(--primary-light); border-color: var(--primary-mid); }
.hamburger span {
  display: block; width: 18px; height: 2px;
  background: var(--gray-600); border-radius: 2px;
  transition: all var(--transition);
}

/* 移动端抽屉导航 */
.mobile-nav-drawer {
  display: none;
  position: fixed; top: var(--topbar-h); left: 0; right: 0; bottom: 0;
  background: rgba(10,14,40,.45); z-index: 200;
  backdrop-filter: blur(4px);
}
.mobile-nav-drawer.active { display: block; }
.mobile-nav-panel {
  position: absolute; top: 0; left: 0; right: 0;
  background: var(--white); padding: 8px 0 20px;
  box-shadow: var(--shadow-lg);
  transform: translateY(-10px); opacity: 0;
  transition: transform .22s cubic-bezier(.34,1.2,.64,1), opacity .18s ease;
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}
.mobile-nav-drawer.active .mobile-nav-panel { transform: translateY(0); opacity: 1; }
.mobile-nav-panel a {
  display: flex; align-items: center; padding: 14px 24px;
  font-size: 15px; font-weight: 600; color: var(--gray-700);
  border-bottom: 1px solid var(--gray-100);
  transition: background var(--transition), color var(--transition);
}
.mobile-nav-panel a:last-child { border-bottom: none; }
.mobile-nav-panel a:hover { background: var(--gray-50); color: var(--primary); }
.mobile-nav-panel a.active {
  color: var(--primary); background: var(--primary-light); font-weight: 700;
  border-left: 3px solid var(--primary);
}

/* ---- 手机端订单卡片 ---- */
.order-card-list { display: none; }
.order-card {
  background: var(--white); border: 1.5px solid var(--gray-150);
  border-radius: var(--radius); padding: 14px 14px 12px;
  margin-bottom: 10px; box-shadow: var(--shadow-sm);
  position: relative; overflow: hidden;
  transition: box-shadow var(--transition), transform var(--transition);
}
.order-card::before {
  content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 3px;
  background: linear-gradient(to bottom, var(--primary), #7c6ff7);
}
.order-card:last-child { margin-bottom: 0; }
.order-card:active { transform: scale(.99); box-shadow: var(--shadow-xs); }

.order-card-header {
  display: flex; align-items: center; flex-wrap: wrap;
  gap: 6px; margin-bottom: 10px;
}
.order-card-no {
  font-family: 'Courier New', monospace; font-weight: 700;
  color: var(--primary); font-size: 11px; flex-shrink: 0;
  background: var(--primary-light); padding: 2px 7px; border-radius: 5px;
}
.order-card-title {
  font-size: 14px; font-weight: 700; color: var(--gray-900);
  flex: 1; min-width: 0; line-height: 1.4; cursor: pointer;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.order-card-title:hover { color: var(--primary); }
.order-card-check { flex-shrink: 0; }

/* 卡片状态小标签 */
.card-tag {
  font-size: 11px; font-weight: 700; padding: 2px 8px;
  border-radius: 999px; flex-shrink: 0; letter-spacing: .02em;
}
.card-tag-warn { background: #fef3c7; color: #92400e; }
.card-tag-paid { background: #d1fae5; color: #065f46; }

.order-card-body {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 8px 12px; margin-bottom: 10px;
}
.order-card-field {}
.order-card-label {
  font-size: 10px; color: var(--gray-400); margin-bottom: 2px;
  text-transform: uppercase; letter-spacing: .05em; font-weight: 700;
}
.order-card-value { font-size: 13px; color: var(--gray-700); font-weight: 500; }
.order-card-value.is-amount { font-weight: 800; color: var(--gray-900); font-size: 15px; }
.order-card-value.is-final  { font-weight: 800; color: #d97706; font-size: 15px; }
.order-card-value.is-expense { color: #ef4444; font-weight: 700; }
.order-card-actions {
  display: flex; gap: 6px; flex-wrap: wrap;
  padding-top: 10px; border-top: 1px solid var(--gray-100);
}
.order-card-actions .btn-sm { flex: 1; min-width: 56px; justify-content: center; font-size: 12px; }

/* 应收账款卡片 */
.recv-card-list { display: none; }
.recv-card {
  background: var(--white); border: 1.5px solid var(--gray-150);
  border-radius: var(--radius); padding: 14px 14px 12px;
  margin-bottom: 10px; box-shadow: var(--shadow-sm);
  position: relative; overflow: hidden;
  transition: box-shadow var(--transition), transform var(--transition);
}
.recv-card::before {
  content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 3px;
  background: linear-gradient(to bottom, #f59e0b, #f97316);
}
.recv-card:last-child { margin-bottom: 0; }
.recv-card:active { transform: scale(.99); }
.recv-card-header {
  display: flex; align-items: center; flex-wrap: wrap;
  gap: 6px; margin-bottom: 10px;
}
.recv-card-no {
  font-family: 'Courier New', monospace; font-weight: 700;
  color: var(--primary); font-size: 11px; flex-shrink: 0;
  background: var(--primary-light); padding: 2px 7px; border-radius: 5px;
}
.recv-card-title {
  font-size: 14px; font-weight: 700; color: var(--gray-900);
  flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.recv-card-body {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 8px 12px; margin-bottom: 10px;
}
.recv-card-actions {
  display: flex; gap: 6px; flex-wrap: wrap;
  padding-top: 10px; border-top: 1px solid var(--gray-100);
}
.recv-card-actions .btn-sm { flex: 1; justify-content: center; font-size: 12px; }


/* ---- 平板 ≤ 960px ---- */
@media (max-width: 960px) {
  .topbar-inner { padding: 0 18px; gap: 10px; }
  .main-content { padding: 22px 18px; }
}

/* ---- 手机 ≤ 768px ---- */
@media (max-width: 768px) {
  html { font-size: 14px; }

  /* 顶栏 */
  .topbar-nav { display: none; }
  .hamburger { display: flex; }
  .topbar-inner { padding: 0 14px; gap: 8px; }
  .topbar-right { gap: 6px; }
  .admin-info { display: none; }
  .brand-name { font-size: 15px; }
  #btnNewOrder .btn-text { display: none; }
  #btnNewOrder { padding: 0 10px; min-width: 36px; }
  .brand-icon { height: 26px; width: auto; }


  /* 主内容区 */
  .main-content { padding: 14px 12px; }

  /* 统计卡片 */
  .stats-row {
    gap: 10px; margin-bottom: 14px;
    display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  }
  .stat-card { min-width: 0; max-width: none; padding: 14px 16px; }
  .stat-label { font-size: 11px; margin-bottom: 4px; }
  .stat-value { font-size: 20px; }
  .stat-icon { width: 32px; height: 32px; border-radius: 8px; margin-bottom: 4px; }
  .stat-icon svg { width: 16px; height: 16px; }

  /* 搜索栏 */
  .search-bar {
    gap: 8px; margin-bottom: 14px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-areas:
      "search search"
      "from   to"
      "sbtn   rbtn";
  }
  .search-input-wrap { grid-area: search; max-width: none; min-width: 0; }
  #dateFrom { grid-area: from; min-width: 0; width: 100%; }
  #dateTo   { grid-area: to;   min-width: 0; width: 100%; }
  #btnSearch { grid-area: sbtn; }
  #btnReset  { grid-area: rbtn; }
  .date-input { min-width: 0; width: 100%; height: 38px; }

  /* 表格卡片头 */
  .table-header { padding: 14px 16px; flex-wrap: wrap; gap: 8px; }
  .table-title { font-size: 15px; }

  /* 订单列表：隐藏表格，显示卡片 */
  #ordersTable { display: none; }
  .order-card-list { display: block; padding: 10px 12px 6px; }

  /* 应收账款列表：隐藏表格，显示卡片 */
  #receivableTable { display: none; }
  .recv-card-list { display: block; padding: 10px 12px 6px; }

  /* 其他表格：横向滚动 */
  .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .data-table { min-width: 480px; font-size: 13px; }
  .data-table th, .data-table td { padding: 10px 10px; white-space: nowrap; }
  .order-title-cell { max-width: 160px; }

  /* 分页 */
  .pagination { padding: 12px 14px; gap: 4px; flex-wrap: wrap; justify-content: center; }
  .page-btn { min-width: 32px; height: 32px; font-size: 13px; }

  /* 表单卡片 */
  .form-card { padding: 20px 16px; border-radius: var(--radius-lg); }
  .form-group { margin-bottom: 18px; }
  .form-actions { margin-top: 24px; padding-top: 18px; flex-wrap: wrap; }
  .form-actions .btn { flex: 1; min-width: 100px; justify-content: center; }

  /* 管理员表单 */
  .admin-form-grid { grid-template-columns: 1fr !important; }

  /* 应收账款筛选框 */
  #filterPaid { min-width: 0; width: 120px !important; }

  /* 模态框：从底部弹出 */
  .modal-overlay { padding: 0; align-items: flex-end; backdrop-filter: none; }
  .modal {
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    width: 100%; animation: modal-up .26s cubic-bezier(.34,1.3,.64,1);
  }
  @keyframes modal-up {
    from { opacity: 0; transform: translateY(40px); }
    to   { opacity: 1; transform: translateY(0); }
  }
  .modal-sm { max-width: none; }
  .modal-lg { max-width: none; max-height: 90vh; }
  .modal-xl { max-width: none; max-height: 93vh; }
  .modal-header { padding: 16px 18px; }
  .modal-body   { padding: 16px 18px; }
  .modal-footer { padding: 12px 18px; }
  .modal-title  { font-size: 15px; }

  /* 详情弹窗 */
  .detail-grid { grid-template-columns: 1fr 1fr; gap: 12px; }
  .detail-value { font-size: 14px; }

  /* Toast：手机顶部居中 */
  .toast-wrap { top: 12px; right: 12px; left: 12px; align-items: center; }
  .toast { max-width: none; width: 100%; justify-content: center; font-size: 13px; }

  /* 上传区 */
  .upload-zone { padding: 22px 16px; }
  .upload-prompt svg { width: 32px; height: 32px; }
  .upload-text { font-size: 14px; }
  .upload-hint { font-size: 12px; }

  /* 附件项 */
  .attach-item { flex-wrap: wrap; gap: 8px; }
  .attach-info { min-width: calc(100% - 90px); }
  .attach-download { width: 100%; }
  .attach-download .btn { width: 100%; justify-content: center; }

  /* 编辑器 */
  .editor-content { min-height: 180px; }

  /* 数据统计页：筛选栏竖排 */
  .filter-bar { padding: 12px 14px; }
  .filter-bar-inner {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 10px !important;
  }
  .filter-bar .btn-group { display: flex; flex-wrap: wrap; gap: 6px; }
  .filter-bar .btn-group .btn-sm { flex: 1; min-width: calc(33% - 6px); justify-content: center; }
  .filter-bar-sep { display: none; }
  .filter-date-row {
    display: grid !important;
    grid-template-columns: 1fr auto 1fr auto !important;
    align-items: center !important;
    gap: 6px !important;
  }
  .filter-date-row input { width: 100% !important; }
  .filter-groupby { margin-left: 0 !important; }

  /* 图表高度 */
  .chart-wrap { height: 200px !important; }
  #barChart { max-height: 200px; }

  /* 批量操作按钮组 */
  .table-header > div:last-child { flex-wrap: wrap; gap: 6px; }
}

/* =====================================================
   订单流程状态样式
   ===================================================== */

/* ---------- 列宽 ---------- */
.td-status { width: 76px; white-space: nowrap; }

/* ---------- 状态 Badge ---------- */
.order-status-badge {
  display: inline-flex; align-items: center;
  padding: 3px 10px; border-radius: 999px;
  font-size: 11px; font-weight: 700; letter-spacing: .02em;
  white-space: nowrap; flex-shrink: 0;
}
.order-status-pending    { background: #fee2e2; color: #991b1b; }
.order-status-processing { background: #fef3c7; color: #78350f; }
.order-status-done       { background: #dbeafe; color: #1e3a8a; }

/* 详情弹窗中放大一号 */
.order-status-badge-lg { font-size: 13px; padding: 4px 14px; }

/* ---------- 列表行背景色 ---------- */
/* 未领取 → 浅红 */
.data-table tbody tr.tr-status-pending td {
  background: #fff5f5;
}
.data-table tbody tr.tr-status-pending:hover td {
  background: #fee2e2;
}
/* 已完成 → 浅蓝 */
.data-table tbody tr.tr-status-done td {
  background: #eff6ff;
}
.data-table tbody tr.tr-status-done:hover td {
  background: #dbeafe;
}

/* ---------- 移动端卡片背景色 ---------- */
.order-card.order-card-pending {
  border-color: #fca5a5;
  background: #fff5f5;
}
.order-card.order-card-pending::before {
  background: linear-gradient(to bottom, #f87171, #ef4444);
}
.order-card.order-card-done {
  border-color: #93c5fd;
  background: #eff6ff;
}
.order-card.order-card-done::before {
  background: linear-gradient(to bottom, #60a5fa, #3b82f6);
}

/* ---------- 流程操作按钮 ---------- */
/* 领取订单（绿色调） */
.btn-flow-take {
  background: #ecfdf5; color: #065f46;
  border: 1.5px solid #6ee7b7;
  font-weight: 600;
}
.btn-flow-take:hover { background: #d1fae5; border-color: #34d399; }

/* 标记完成（蓝色调） */
.btn-flow-done {
  background: #eff6ff; color: #1e3a8a;
  border: 1.5px solid #93c5fd;
  font-weight: 600;
}
.btn-flow-done:hover { background: #dbeafe; border-color: #60a5fa; }

/* 详情弹窗流程行：跨列全宽 */
.detail-item-flow { grid-column: 1 / -1; }


/* ---- 超小屏 ≤ 400px ---- */
@media (max-width: 400px) {
  .topbar-inner { padding: 0 10px; }
  .main-content { padding: 10px 10px; }
  .data-table { min-width: 420px; font-size: 12px; }
  .data-table th, .data-table td { padding: 8px 8px; }
  .detail-grid { grid-template-columns: 1fr; gap: 10px; }
  .stats-row { grid-template-columns: 1fr 1fr; }
  .stat-value { font-size: 18px; }
  .order-card-body { grid-template-columns: 1fr; }
  .recv-card-body  { grid-template-columns: 1fr; }
}

/* =====================================================
   Lightbox（图片全屏预览）
   ===================================================== */
#lightboxOverlay {
  display: none; position: fixed; inset: 0; z-index: 9999;
  background: rgba(6,8,24,.92);
  align-items: center; justify-content: center; cursor: zoom-out;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}
#lightboxOverlay.active { display: flex; }
#lightboxOverlay img {
  max-width: 90vw; max-height: 90vh; object-fit: contain;
  border-radius: 8px; box-shadow: 0 12px 60px rgba(0,0,0,.7);
  cursor: grab; transform-origin: center center;
  user-select: none; transition: transform .08s ease; will-change: transform;
}
#lightboxOverlay img.grabbing { cursor: grabbing; }
#lightboxClose {
  position: fixed; top: 20px; right: 24px;
  width: 38px; height: 38px; border-radius: 50%;
  background: rgba(255,255,255,.14); border: 1px solid rgba(255,255,255,.2);
  color: #fff; font-size: 20px; line-height: 1; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background .15s, transform .15s;
  z-index: 10000;
}
#lightboxClose:hover { background: rgba(255,255,255,.28); transform: scale(1.1); }
#lightboxHint {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  color: rgba(255,255,255,.4); font-size: 12px;
  pointer-events: none; white-space: nowrap; z-index: 10000;
  background: rgba(0,0,0,.3); padding: 5px 14px; border-radius: 999px;
}
.zoomable-img { cursor: zoom-in !important; transition: opacity .15s; }
.zoomable-img:hover { opacity: .88; }
