/* ═══════════════ JQERP Styles ═══════════════
 * Base styles from prototype + extensions for:
 * - Toast notifications
 * - Error pages (403/500)
 * - Settlement countdown cards (Fix #13, Phase 4)
 */

:root {
  --profit-green: #10b981;
  --loss-red: #ef4444;
  --warn-yellow: #f59e0b;
  --info-blue: #3b82f6;
  --border-light: #e5e7eb;
  --bg-card: #ffffff;
  --bg-page: #f3f4f6;
  --text-primary: #111827;
  --text-secondary: #6b7280;
  --text-muted: #6b7280;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --shadow-card: 0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
  --shadow-card-hover: 0 4px 12px rgba(0,0,0,.08);
  --transition-fast: 150ms ease;

  /* Semantic colors */
  --primary-dark: #1e293b;
  --primary-dark-hover: #334155;
  --danger-red: #dc2626;
  --danger-bg: #fef2f2;
  --danger-border: #fecaca;
  --commission-purple: #8b5cf6;
  --warning-amber: #f59e0b;
  --success-emerald: #10b981;
  --info-blue-bright: #3b82f6;
  --indigo-accent: #6366f1;
  --text-slate: #475569;
  --text-slate-light: #64748b;
  --text-slate-muted: #94a3b8;
  --bg-darkest: #0f172a;
}

* { box-sizing: border-box; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg-page);
  color: var(--text-primary);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ── Top Nav ────────────────────── */
.app-header {
  background: var(--primary-dark);
  color: #fff;
  padding: 0 20px;
  height: 50px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 1000;
  box-shadow: 0 1px 4px rgba(0,0,0,.15);
}
.app-logo {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: .5px;
  display: flex; align-items: center; gap: 8px;
}
.app-logo .dot { width: 8px; height: 8px; border-radius: 50%; background: #10b981; }

/* ── Tab Bar ────────────────────── */
.tab-bar {
  background: #fff;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  gap: 0;
  padding: 0 16px;
  overflow-x: auto;
  position: sticky;
  top: 50px;
  z-index: 999;
  box-shadow: 0 1px 2px rgba(0,0,0,.03);
}
.tab-item {
  padding: 12px 18px;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  background: none;
  border: none;
  border-bottom: 2.5px solid transparent;
  white-space: nowrap;
  transition: all var(--transition-fast);
  user-select: none;
  position: relative;
  font-family: inherit;
  outline: none;
}
.tab-item:hover { color: var(--text-primary); background: #f9fafb; }
.tab-item.active { color: #1e293b; font-weight: 600; border-bottom-color: #1e293b; }
.tab-item:focus-visible { outline: 2px solid #6366f1; outline-offset: -2px; border-radius: 2px; }
.tab-item .badge-pill {
  font-size: 10px; padding: 1px 6px; border-radius: 10px;
  background: #e5e7eb; color: #6b7280; margin-left: 4px; font-weight: 500;
}

/* ── Main Content ───────────────── */
.main-content {
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px 16px 40px;
}
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ── Cards & Sections ───────────── */
.card-flat {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-card);
}
.section-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: .5px;
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border-light);
}

/* ── Settings Layout (sidebar + single column) ── */
.settings-layout {
  display: flex;
  gap: 24px;
  align-items: flex-start;
}

.settings-sidebar {
  width: 180px;
  flex-shrink: 0;
  position: sticky;
  top: 106px;
  transition: width .2s ease;
}

.settings-sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 0 10px;
}

.settings-toggle-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 2px 4px;
  font-size: 10px;
  line-height: 1;
  border-radius: 3px;
  transition: color .12s, transform .2s;
}

.settings-toggle-btn:hover {
  color: var(--text-primary);
  background: #f3f4f6;
}

.settings-nav-title {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  padding: 0 0 0 12px;
  white-space: nowrap;
  overflow: hidden;
  transition: opacity .15s;
}

.settings-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.settings-nav-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  font-size: 13px;
  color: var(--text-secondary);
  text-decoration: none;
  border-radius: var(--radius-sm);
  transition: all .12s;
  white-space: nowrap;
  overflow: hidden;
}

.settings-nav-icon {
  flex-shrink: 0;
  width: 18px;
  text-align: center;
  font-size: 14px;
}

.settings-nav-text {
  transition: opacity .15s;
}

.settings-nav-item:hover {
  background: #f3f4f6;
  color: var(--text-primary);
}

.settings-nav-item.active {
  background: #eef2ff;
  color: #4338ca;
  font-weight: 500;
}

.settings-content {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* scroll margin for anchor targets (clear sticky header + tab bar) */
.settings-content > .card-flat {
  scroll-margin-top: 106px;
}

/* ── Collapsed sidebar ── */
.settings-sidebar.collapsed {
  width: 42px;
}

.settings-sidebar.collapsed .settings-toggle-btn {
  transform: rotate(180deg);
}

.settings-sidebar.collapsed .settings-nav-title,
.settings-sidebar.collapsed .settings-nav-text {
  opacity: 0;
  pointer-events: none;
}

.settings-sidebar.collapsed .settings-nav-item {
  padding: 7px 10px;
  justify-content: center;
}

.settings-sidebar.collapsed .settings-sidebar-header {
  justify-content: center;
  padding: 0 0 10px;
}

/* ── Menu Order Drag ────────────── */
.menu-order-list {
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.menu-order-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  background: #fff;
  border-bottom: 1px solid #f3f4f6;
  cursor: default;
  transition: background .15s, opacity .15s;
}

.menu-order-row:last-child {
  border-bottom: none;
}

.menu-order-row:hover {
  background: #f9fafb;
}

.menu-order-row.dragging {
  opacity: .45;
  background: #eef2ff;
}

.menu-order-row.drag-over {
  background: #eef2ff;
  box-shadow: inset 0 2px 0 #6366f1;
}

.menu-drag-handle {
  color: #9ca3af;
  cursor: grab;
  font-size: 14px;
  line-height: 1;
  user-select: none;
  padding: 0 2px;
}

.menu-drag-handle:active {
  cursor: grabbing;
}

/* ── Order Cards ────────────────── */
.order-card {
  background: #fff;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  margin-bottom: 8px;
  transition: all var(--transition-fast);
  overflow: hidden;
}
.order-card:hover { box-shadow: var(--shadow-card-hover); }
.order-card.expanded { border-color: #94a3b8; box-shadow: 0 2px 8px rgba(0,0,0,.06); }

.order-card-header {
  display: flex;
  align-items: center;
  padding: 12px 16px;
  cursor: pointer;
  gap: 12px;
  user-select: none;
  transition: background var(--transition-fast);
}
.order-card-header:hover { background: #fafbfc; }

.order-card-header .expand-icon {
  font-size: 18px;
  color: #94a3b8;
  transition: transform var(--transition-fast);
  width: 20px; text-align: center; flex-shrink: 0;
}
.order-card.expanded .expand-icon { transform: rotate(90deg); }

.order-card-header .order-id {
  font-weight: 600; font-size: 13.5px; font-family: "SF Mono","Consolas",monospace;
  color: #1e293b; min-width: 120px;
}
.order-card-header .order-title {
  flex: 1; font-size: 13.5px; color: var(--text-primary);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.order-card-header .order-amount {
  font-weight: 700; font-size: 15px; color: #1e293b; min-width: 80px; text-align: right;
}
.order-card-header .order-badge {
  font-size: 11px; padding: 3px 10px; border-radius: 20px; font-weight: 500;
  white-space: nowrap;
}
.badge-pending { background: #fef3c7; color: #92400e; }
.badge-done { background: #d1fae5; color: #065f46; }
.badge-shipped { background: #dbeafe; color: #1e40af; }

.order-card-body {
  display: none;
  padding: 0 16px 16px;
  border-top: 1px solid var(--border-light);
  background: #fafbfc;
}
.order-card.expanded .order-card-body { display: block; }

/* ── Buttons ────────────────────── */
.btn-save {
  background: var(--primary-dark); color: #fff; border: none; padding: 8px 20px;
  border-radius: var(--radius-sm); font-size: 13.5px; font-weight: 500;
  cursor: pointer; transition: all var(--transition-fast);
}
.btn-save:hover { background: #334155; }
.btn-save-sm {
  background: var(--primary-dark); color: #fff; border: none; padding: 5px 14px;
  border-radius: var(--radius-sm); font-size: 12.5px; font-weight: 500; cursor: pointer;
}
.btn-outline-sm {
  background: #fff; color: #1e293b; border: 1.5px solid #d1d5db; padding: 5px 14px;
  border-radius: var(--radius-sm); font-size: 12.5px; font-weight: 500; cursor: pointer;
}
.btn-outline-sm:hover { background: #f9fafb; border-color: #9ca3af; }
.btn-outline-sm.active { background: #1e293b; color: #fff; border-color: #1e293b; }
.quick-date-btn { font-size: 12px; padding: 4px 12px; border-radius: var(--radius-sm); background: #fff; color: #374151; border: 1.5px solid #d1d5db; cursor: pointer; transition: all .15s; }
.quick-date-btn:hover { background: #f3f4f6; border-color: #9ca3af; }
.quick-date-btn.active { background: #1e293b; color: #fff; border-color: #1e293b; }

/* ── KPI Cards ──────────────────── */
.kpi-grid { display: grid; grid-template-columns: repeat(5,1fr); gap: 10px; margin-bottom: 16px; }
.kpi-card {
  background: #fff; border: 1px solid var(--border-light); border-radius: var(--radius-md);
  padding: 16px; text-align: center; border-left: 3px solid transparent;
	}
.kpi-card .kpi-label { font-size: 12px; color: var(--text-secondary); margin-bottom: 4px; }
.kpi-card .kpi-tip { font-size: 10px; color: #94a3b8; line-height: 1.4; margin-bottom: 4px; padding: 3px 6px; background: #f8fafc; border-radius: 4px; border: 1px dashed #e2e8f0; }
.kpi-card .kpi-value { font-size: 24px; font-weight: 700; font-family: "SF Mono","Consolas",monospace; }
.kpi-card .kpi-sub { font-size: 11px; color: var(--text-muted); margin-top: 2px; }
.kpi-card .kpi-pct { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

/* ── KPI TIPS Button ───────────── */
.kpi-tips-btn {
  font-size: 11px; padding: 3px 12px; border-radius: 12px;
  background: #fff; color: #64748b; border: 1px solid #e2e8f0;
  cursor: pointer; transition: all .15s; font-weight: 500;
  letter-spacing: 0.5px;
}
.kpi-tips-btn:hover { background: #f1f5f9; border-color: #94a3b8; color: #334155; }
.kpi-tips-btn.active { background: #1e293b; color: #fff; border-color: #1e293b; }
.kpi-card.profit-card { border-left-color: #10b981; }
.kpi-card.net-card { border-left-color: #1e293b; }
.kpi-blue { border-left-color: #3b82f6 !important; }
.kpi-indigo { border-left-color: #6366f1 !important; }
.kpi-red { border-left-color: #ef4444 !important; }
.kpi-orange { border-left-color: #f59e0b !important; }
.kpi-teal { border-left-color: #14b8a6 !important; }
.kpi-green { border-left-color: #10b981 !important; }
.kpi-gray { border-left-color: #94a3b8 !important; }

/* ── Reconciliation ─────────────── */
.coverage-bar {
  display: flex; height: 8px; border-radius: 4px; overflow: hidden; margin: 8px 0;
  background: #f3f4f6;
}
.coverage-bar .bar-match { background: #10b981; }
.coverage-bar .bar-supplier-only { background: #f59e0b; }
.coverage-bar .bar-our-only { background: #3b82f6; }
.stat-num { font-size: 20px; font-weight: 700; font-family: "SF Mono","Consolas",monospace; }
.stat-label { font-size: 11px; color: #6b7280; margin-top: 2px; }
.batch-row { transition: background .15s; }
.batch-row:hover { background: #f8fafc; }
.batch-row.active { background: #eff6ff; }
.btn-xs { padding: 1px 6px; font-size: 11px; line-height: 1.4; border-radius: 4px; }

/* ── Modal ──────────────────────── */
.modal-backdrop-custom {
  position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 2000;
  display: flex; align-items: center; justify-content: center;
}
.modal-custom {
  background: #fff; border-radius: var(--radius-lg); width: 480px; max-width: 95vw;
  box-shadow: 0 20px 60px rgba(0,0,0,.2); overflow: hidden;
}
.modal-custom-header {
  padding: 16px 20px; border-bottom: 1px solid var(--border-light);
  display: flex; align-items: center; justify-content: space-between;
}
.modal-custom-header h3 { font-size: 15px; font-weight: 600; margin: 0; }
.modal-custom-body { padding: 20px; }
.modal-custom-footer {
  padding: 12px 20px; border-top: 1px solid var(--border-light);
  display: flex; justify-content: flex-end; gap: 8px;
}

/* ── Misc ───────────────────────── */
.form-control-sm { font-size: 13px; padding: 8px 12px; border-radius: var(--radius-sm); }
.is-invalid { border-color: #dc2626 !important; box-shadow: 0 0 0 1px rgba(220,38,38,.15) !important; }
.field-error { animation: fadeIn .15s ease; }
.form-label-sm { font-size: 12.5px; font-weight: 500; color: var(--text-secondary); margin-bottom: 4px; }
.text-mono { font-family: "SF Mono","Consolas",monospace; }
.empty-state { text-align: center; padding: 48px 20px; color: var(--text-muted); }
.empty-state .icon { font-size: 40px; margin-bottom: 12px; }
.search-box { position: relative; }
.search-box input { padding-right: 28px !important; }
.search-clear-btn:hover { color: #111827; }
.filter-bar {
  display: flex; gap: 8px; align-items: center;
  margin-bottom: 16px;
}
.filter-bar select, .filter-bar input {
  border: 1px solid var(--border-light); border-radius: var(--radius-sm);
  padding: 7px 12px; font-size: 13px; background: #fff;
}
.status-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.status-dot.green { background: #10b981; }
.status-dot.yellow { background: #f59e0b; }
.status-dot.red { background: #ef4444; }

/* ── Margin Utilities ──────────── */
.mb-12 { margin-bottom: 12px; }
.mb-16 { margin-bottom: 16px; }

/* ── Daily Quote Bar ────────────── */
.daily-quote-bar {
  background: #f8fafc;
  color: #64748b; padding: 10px 16px; border-radius: var(--radius-sm);
  display: flex; align-items: center; gap: 8px; margin-top: 16px;
  font-size: 12.5px; line-height: 1.5;
  border: 1px solid var(--border-light);
}
.daily-quote-bar .quote-text { flex: 1; font-style: italic; }
.daily-quote-bar .quote-tag {
  font-size: 10px; padding: 2px 8px; border-radius: 10px; font-style: normal;
  font-weight: 500; white-space: nowrap;
  background: rgba(16,185,129,.15); color: #34d399;
}
.quote-tag.inspire { background: rgba(16,185,129,.2); color: #34d399; }
.quote-tag.funny { background: rgba(245,158,11,.2); color: #fbbf24; }
.quote-tag.trendy { background: rgba(59,130,246,.2); color: #60a5fa; }
.quote-tag.ai { background: rgba(139,92,246,.2); color: #a78bfa; }

/* ── Quote tag palette (15 emotional categories) ── */
.quote-tag.humor, .whisper-tag.humor       { background: rgba(245,158,11,.2);  color: #f59e0b; }  /* 幽默 */
.quote-tag.truth, .whisper-tag.truth       { background: rgba(239,68,68,.15);  color: #f87171; }  /* 走心/扎心 */
.quote-tag.insight, .whisper-tag.insight   { background: rgba(16,185,129,.2);  color: #34d399; }  /* 启迪 */
.quote-tag.sober, .whisper-tag.sober       { background: rgba(100,116,139,.2);  color: #94a3b8; }  /* 清醒 */
.quote-tag.cheer, .whisper-tag.cheer       { background: rgba(34,197,94,.2);   color: #4ade80; }  /* 打气 */
.quote-tag.resonate, .whisper-tag.resonate { background: rgba(59,130,246,.2);  color: #60a5fa; }  /* 共鸣 */
.quote-tag.clear, .whisper-tag.clear       { background: rgba(20,184,166,.2);  color: #2dd4bf; }  /* 通透 */
.quote-tag.warm, .whisper-tag.warm         { background: rgba(236,72,153,.15); color: #f472b6; }  /* 温暖 */
.quote-tag.heal, .whisper-tag.heal         { background: rgba(168,85,247,.15); color: #c084fc; }  /* 治愈 */
.quote-tag.romantic, .whisper-tag.romantic { background: rgba(244,114,182,.2); color: #f9a8d4; }  /* 浪漫 */
.quote-tag.fire, .whisper-tag.fire         { background: rgba(249,115,22,.2);  color: #fb923c; }  /* 燃 */
.quote-tag.relax, .whisper-tag.relax       { background: rgba(148,163,184,.15);color: #a5b4fc; }  /* 松弛/解压 */
.quote-tag.open, .whisper-tag.open         { background: rgba(34,211,238,.15); color: #67e8f9; }  /* 豁达 */
.quote-tag.peace, .whisper-tag.peace       { background: rgba(209,213,219,.2); color: #d1d5db; }  /* 自洽 */

/* ── Daily Footer Whisper ────────── */
.daily-footer-whisper {
  display: flex; align-items: center; gap: 8px;
  margin-top: 24px; padding: 6px 0;
  font-size: 11.5px; color: #94a3b8;
  opacity: 0.65; transition: opacity .3s;
  border-top: 1px solid #f1f5f9;
}
.daily-footer-whisper:hover { opacity: 1; }
.daily-footer-whisper .whisper-text { flex: 1; font-style: italic; letter-spacing: .3px; }
.daily-footer-whisper .whisper-tag {
  font-size: 10px; padding: 1px 7px; border-radius: 8px;
  font-style: normal; font-weight: 500; white-space: nowrap;
  letter-spacing: 0;
  background: rgba(148,163,184,.12); color: #94a3b8;
}

/* ── Staleness ──────────────────── */
.staleness-bar {
  display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px;
}
.staleness-tag {
  font-size: 11.5px; padding: 4px 10px; border-radius: 16px; font-weight: 500;
  display: flex; align-items: center; gap: 4px;
}
.staleness-tag.fresh { background: #d1fae5; color: #065f46; }
.staleness-tag.warning { background: #fef3c7; color: #92400e; animation: pulse-warn 2s ease-in-out infinite; }
.staleness-tag.danger { background: #fee2e2; color: #991b1b; animation: pulse-warn 1.5s ease-in-out infinite; }
	/* ── Action Bar (日报数据就绪) ── */
	.action-bar {
	  padding: 8px 14px;
	  border-radius: 8px;
	  font-size: 13px;
	  margin-bottom: 12px;
	  display: flex;
	  align-items: center;
	  gap: 8px;
	  flex-wrap: wrap;
	}
	.action-bar--ready { background: #f0fdf4; color: #166534; }
	.action-bar--action { background: #fffbeb; color: #92400e; }
	.action-bar a {
	  cursor: pointer;
	  font-weight: 600;
	  margin: 0 4px;
	  text-decoration: none;
	  color: inherit;
	}
	.action-bar a:hover { text-decoration: underline; }

	/* ── Readiness Dot ─────────────── */
	.readiness-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-left: 6px; }
	.readiness-dot.green { background: #10b981; }
	.readiness-dot.yellow { background: #f59e0b; }
	.readiness-dot.gray { background: #cbd5e1; }

/* ── Sub Navigation ─────────────── */
.sub-nav-bar {
  display: flex; gap: 4px; padding: 4px;
  background: #f1f5f9; border-radius: var(--radius-md);
  overflow-x: auto;
}
.sub-nav-item {
  padding: 8px 16px; font-size: 13px; font-weight: 500;
  color: var(--text-secondary); cursor: pointer;
  border: none; background: transparent; border-radius: var(--radius-sm);
  white-space: nowrap; transition: all var(--transition-fast);
}
.sub-nav-item:hover { color: var(--text-primary); background: #fff; }
.sub-nav-item.active {
  background: #fff; color: #1e293b; font-weight: 600;
  box-shadow: var(--shadow-card);
}
.sub-nav-item .badge-pill {
  font-size: 10px; padding: 1px 6px; border-radius: 10px;
  background: #e5e7eb; color: #6b7280; margin-left: 4px; font-weight: 500;
}
.sub-nav-item.active .badge-pill { background: #1e293b; color: #fff; }

.text-muted { color: #9ca3af; }
.page-btn {
  min-width: 32px; height: 32px; padding: 4px 8px;
  font-size: 12.5px; font-weight: 500;
  border: 1px solid var(--border-light); border-radius: var(--radius-sm);
  background: #fff; cursor: pointer; color: var(--text-primary);
  transition: all var(--transition-fast);
  display: inline-flex; align-items: center; justify-content: center;
}
.page-btn:hover { background: #f9fafb; border-color: #94a3b8; }
.page-btn.active { background: #1e293b; color: #fff; border-color: #1e293b; }
.page-btn:disabled { opacity: .35; cursor: not-allowed; }
.page-controls { display: flex; align-items: center; gap: 4px; }
.page-ellipsis { padding: 0 4px; color: var(--text-muted); font-size: 12px; }
.page-size-select {
  font-size: 12px; padding: 4px 8px; border: 1px solid var(--border-light);
  border-radius: var(--radius-sm); margin-left: 8px;
}

/* ── Animations ─────────────────── */
@keyframes pulse-warn {
  0%, 100% { opacity: 1; }
  50% { opacity: .7; }
}
@keyframes fadeIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }
.animate-in { animation: fadeIn .2s ease; }

/* ── View Toggle Buttons ────────── */
.view-btn {
  min-width: 32px; height: 30px; padding: 4px 12px;
  font-size: 12.5px; font-weight: 500;
  border: 1px solid var(--border-light); border-radius: var(--radius-sm);
  background: #fff; cursor: pointer; color: var(--text-primary);
  transition: all var(--transition-fast);
  display: inline-flex; align-items: center; justify-content: center;
  gap: 4px;
}
.view-btn:hover { background: #f9fafb; border-color: #94a3b8; }
.view-btn.active { background: #1e293b; color: #fff; border-color: #1e293b; }

/* ── Pivot Table ────────────────── */
.pivot-card { overflow: hidden; }
.pivot-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.pivot-table { margin-bottom: 0; white-space: nowrap; }
.pivot-table th, .pivot-table td { min-width: 110px; }
.pivot-table th:first-child, .pivot-table td:first-child { min-width: 100px; position: sticky; left: 0; background: #fff; z-index: 2; }
.pivot-table thead th:first-child { z-index: 4; }
.pivot-sticky-col {
  position: sticky; left: 0; background: #fff; z-index: 2;
  font-weight: 600; white-space: nowrap;
}
.pivot-total-row td {
  border-top: 2px solid #1e293b !important;
  background: #f8fafc;
  font-weight: 700;
}
.pivot-total-row .pivot-sticky-col { background: #f8fafc; }

/* ── Cost Order Card ──────────── */
.cost-order-card {
  background: #fff; border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  transition: all var(--transition-fast);
}
.cost-order-card:hover { box-shadow: var(--shadow-card-hover); }
.expand-arrow { display: inline-block; transition: transform var(--transition-fast); width: 16px; text-align: center; }
.cost-expand-panel { background: #fafbfc; min-height: 320px; }

/* ── SKU Autocomplete Dropdown ─── */
.sku-autocomplete-dropdown {
  position: absolute; z-index: 1000; background: #fff;
  border: 1px solid var(--border-light); border-radius: var(--radius-sm);
  max-height: 300px; overflow-y: auto; display: none;
  box-shadow: 0 4px 12px rgba(0,0,0,.1); width: 100%;
}
.sku-autocomplete-dropdown .sku-drop-item {
  padding: 8px 10px; cursor: pointer; font-size: 12px;
  display: flex; flex-direction: column; gap: 2px;
  border-bottom: 1px solid #f3f4f6;
}
.sku-drop-item:hover { background: #eff6ff; }
.sku-drop-item:last-child { border-bottom: none; }
.sku-drop-row1 { display: flex; align-items: center; gap: 4px; font-size: 12px; color: #334155; flex-wrap: wrap; }
.sku-drop-code { font-weight: 700; font-size: 12px; color: #1e293b; white-space: nowrap; }
.sku-drop-sep { color: #d1d5db; font-size: 10px; user-select: none; }
.sku-drop-alias { color: #6d28d9; font-weight: 500; white-space: nowrap; }
.sku-drop-price { font-weight: 600; font-size: 12px; color: #059669; white-space: nowrap; }
.sku-drop-logistics { font-size: 11px; color: #64748b; white-space: nowrap; }
.sku-drop-new { padding: 6px 10px; font-size: 12px; }
.sku-drop-new:hover { background: #eff6ff; }
.sku-drop-row2 { font-size: 11px; color: #64748b; line-height: 1.5; word-break: break-all; }
.sku-autocomplete-wrapper { position: relative; }
.sku-autocomplete-wrapper input { padding-right: 28px !important; }
#bomSearchWrapper input { padding-right: 28px !important; }

/* ── BOM Product Autocomplete ─── */
.bom-ac-item:last-child { border-bottom: none !important; }

/* ── Accounted radio buttons ─── */
.accounted-radio {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 12px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  user-select: none;
  transition: background 0.15s ease;
}
.accounted-radio input[type="radio"] { accent-color: #4f46e5; margin: 0; cursor: pointer; }

/* ── SKU info card (方案B) ─── */
.sku-info-card {
  display: flex;
  align-items: flex-start;
  gap: 4px;
  flex-wrap: wrap;
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 12px;
  line-height: 1.6;
}
.sku-card-code {
  display: inline-block;
  background: #166534;
  color: #fff;
  padding: 1px 6px;
  border-radius: 3px;
  font-weight: 600;
  font-size: 11px;
  font-family: monospace;
  white-space: nowrap;
}
.sku-card-spec {
  flex-basis: 100%;
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
  font-size: 12px;
  color: #334155;
}
.sku-card-sep { color: #d1d5db; font-size: 10px; user-select: none; }
.sku-card-alias { color: #6d28d9; font-weight: 700; }
.sku-card-price { font-weight: 700; color: #059669; white-space: nowrap; }
.sku-card-logistics { font-size: 11px; color: #64748b; white-space: nowrap; }
.sku-card-bom {
  flex-basis: 100%;
  font-size: 11px;
  color: #14532d;
  font-weight: 600;
  line-height: 1.6;
  word-break: break-all;
}
.sku-card-bom-plus { color: #86efac; font-weight: 400; }
.sku-card-change {
  margin-left: auto;
  flex-shrink: 0;
  background: none;
  border: 1px solid #fecaca;
  color: #dc2626;
  border-radius: 3px;
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  padding: 1px 6px;
  transition: all 0.15s;
}
.sku-card-change:hover {
  background: #fef2f2;
  border-color: #f87171;
}

.sku-info-card--manual {
  background: #f8fafc;
  border-color: #e2e8f0;
}
.sku-card-code--manual {
  display: inline-block;
  background: #64748b;
  color: #fff;
  padding: 1px 6px;
  border-radius: 3px;
  font-weight: 600;
  font-size: 11px;
  white-space: nowrap;
}
.sku-card-meta--manual {
  color: #94a3b8;
  font-size: 11px;
  white-space: nowrap;
}
.sku-card-change--manual {
  margin-left: auto;
  flex-shrink: 0;
  background: none;
  border: 1px solid #cbd5e1;
  color: #64748b;
  border-radius: 3px;
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  padding: 1px 6px;
  transition: all 0.15s;
}
.sku-card-change--manual:hover {
  background: #f1f5f9;
  border-color: #94a3b8;
  color: #475569;
}

/* ── Responsive ─────────────────── */
@media (max-width: 768px) {
  .kpi-grid { grid-template-columns: repeat(3,1fr); }
  .tab-item { padding: 10px 12px; font-size: 12px; }
  .main-content { padding: 12px 8px 32px; }
  .order-card-header { padding: 10px 12px; gap: 8px; }
  .order-card-header .order-id { min-width: 100px; font-size: 12px; }
  .order-card-header .order-title { font-size: 12px; }
  .order-card-header .order-amount { font-size: 13px; min-width: 60px; }
  .filter-bar { gap: 4px; }
  .filter-bar select, .filter-bar input { font-size: 12px; padding: 6px 10px; }
  .sub-nav-bar { gap: 2px; }
  .sub-nav-item { padding: 6px 10px; font-size: 11.5px; }
  .settings-layout { flex-direction: column; }
  .settings-sidebar { width: 100% !important; position: static; }
  .settings-sidebar-header { display: none; }
  .settings-nav { flex-direction: row; flex-wrap: wrap; gap: 4px; }
  .settings-nav-text { opacity: 1 !important; }
  .settings-nav-item { font-size: 12px; padding: 5px 10px; justify-content: flex-start !important; }
  .settings-nav-icon { width: auto; }
}
@media (max-width: 480px) {
  .kpi-grid { grid-template-columns: repeat(2,1fr); }
  .kpi-card { padding: 10px 8px; }
  .kpi-card .kpi-value { font-size: 16px; }
  .tab-item { padding: 8px 10px; font-size: 11px; }
}

/* ── Loading Skeleton ────────────── */
.skeleton {
  background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.5s ease-in-out infinite;
  border-radius: 4px;
}
@keyframes skeleton-shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ── Scrollbar ───────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #d1d5db; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #9ca3af; }
/* Firefox scrollbar */
html {
  scrollbar-width: thin;
  scrollbar-color: #d1d5db transparent;
}

/* ── Table Enhancements ──────────── */
.table-hover tbody tr { transition: background var(--transition-fast); }
.table>:not(caption)>*>* {
  padding: 8px 12px;
  font-size: 13px;
  vertical-align: middle;
}
.table thead th {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: .3px;
  white-space: nowrap;
}

/* ── Sortable Column Headers ───── */
th.sortable {
  cursor: pointer;
  user-select: none;
  transition: color var(--transition-fast), background var(--transition-fast);
}
th.sortable:hover {
  color: var(--text-primary);
  background: #f1f5f9;
}
th.sort-active {
  color: #1e293b !important;
}
.sort-icon {
  font-size: 10px;
  margin-left: 2px;
  color: #cbd5e1;
  transition: color var(--transition-fast);
}
th.sortable:hover .sort-icon {
  color: #94a3b8;
}
th.sort-active .sort-icon {
  color: #1e293b;
}

/* ── Row Number Column ──────────── */
.col-row-num {
  width: 40px;
  min-width: 40px;
  text-align: center;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 400;
}

/* ── Cell Truncation (text overflow + tooltip) ── */
.cell-truncate {
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.cell-truncate-sm { max-width: 100px; }
.cell-truncate-lg { max-width: 240px; }

/* ── Date Cell ──────────────────── */
.cell-date {
  white-space: nowrap;
  font-size: 12px;
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
}

/* ── Money Cell ─────────────────── */
.cell-money {
  text-align: right;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

/* ── Tab Panel Transitions ───────── */
.tab-panel {
  animation: panelFadeIn .2s ease;
}
@keyframes panelFadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ── Toast Enhancements ──────────── */
.toast-item {
  backdrop-filter: blur(8px);
  animation: toastSlideIn .25s ease;
}
@keyframes toastSlideIn {
  from { opacity: 0; transform: translateX(40px); }
  to { opacity: 1; transform: translateX(0); }
}

/* ── Startup Overlay ──────────────── */
.startup-overlay {
  position: fixed; inset: 0; z-index: 10000;
  background: linear-gradient(135deg, #0f172a 0%, #1e293b 40%, #0f172a 100%);
  display: flex; align-items: center; justify-content: center;
  flex-direction: column;
  transition: opacity .6s ease, visibility .6s ease;
}
.startup-overlay.fade-out { opacity: 0; visibility: hidden; pointer-events: none; }
.startup-logo {
  font-size: 42px; font-weight: 800; color: #fff; letter-spacing: 2px;
  display: flex; align-items: center; gap: 12px; margin-bottom: 6px;
}
.startup-logo .pulse-dot {
  width: 14px; height: 14px; border-radius: 50%; background: #10b981;
  animation: pulse-dot 1.2s ease-in-out infinite;
}
.startup-subtitle { font-size: 14px; color: #94a3b8; letter-spacing: 4px; margin-bottom: 28px; }
.startup-quote {
  font-size: 15px; color: #cbd5e1; max-width: 420px; text-align: center;
  line-height: 1.7; font-style: italic; margin-bottom: 24px;
  animation: quote-fade 2s ease;
}
.startup-quote .quote-author { font-size: 12px; color: #64748b; font-style: normal; margin-top: 6px; }
.startup-progress {
  width: 200px; height: 3px; background: rgba(255,255,255,.1); border-radius: 2px; overflow: hidden;
}
.startup-progress-bar {
  height: 100%; background: linear-gradient(90deg, #10b981, #3b82f6, #8b5cf6);
  border-radius: 2px; animation: progress-load 2.2s ease-out forwards;
}
.startup-particles {
  position: absolute; inset: 0; overflow: hidden; pointer-events: none;
}
.startup-particle {
  position: absolute; width: 3px; height: 3px; border-radius: 50%;
  background: rgba(255,255,255,.3);
  animation: float-up 3s ease-in infinite;
}

@keyframes pulse-dot {
  0%, 100% { box-shadow: 0 0 0 0 rgba(16,185,129,.4); }
  50% { box-shadow: 0 0 0 12px rgba(16,185,129,0); }
}
@keyframes progress-load {
  0% { width: 0; }
  60% { width: 85%; }
  100% { width: 100%; }
}
@keyframes quote-fade {
  0% { opacity: 0; transform: translateY(8px); }
  100% { opacity: 1; transform: translateY(0); }
}
@keyframes float-up {
  0% { transform: translateY(100vh) scale(0); opacity: 0; }
  20% { opacity: 1; }
  80% { opacity: 1; }
  100% { transform: translateY(-10vh) scale(1); opacity: 0; }
}

/* ── Pulse Animation for Cost-Refund Conflict Badge ── */
@keyframes pulse-border {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* ── Import Modal: Upload Drop Zone ── */
.upload-drop-zone {
  border: 2px dashed #cbd5e1;
  border-radius: 12px;
  padding: 40px 20px;
  text-align: center;
  cursor: pointer;
  transition: border-color .2s, background .2s;
}
.upload-drop-zone:hover,
.upload-drop-zone.drag-over {
  border-color: #6366f1;
  background: #eef2ff;
}

/* ── Import Modal: Preview Panel ── */
.preview-panel {
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  overflow: hidden;
}
.pp-header {
  padding: 10px 16px;
  background: #f8fafc;
  border-bottom: 1px solid #e2e8f0;
  font-weight: 600;
  font-size: 14px;
}
.pp-body {
  padding: 16px;
}

/* ── Column Mapping Chips ── */
.col-map-item {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 20px;
  font-size: 12px;
  margin: 2px 4px;
}
.col-map-item.matched {
  background: #d1fae5;
  color: #065f46;
}
.col-map-item.unmatched {
  background: #fee2e2;
  color: #991b1b;
}
.cm-arrow {
  margin: 0 3px;
  opacity: 0.5;
}

/* ── Import Tab: Top Action Bar ── */
.import-action-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 12px;
}
.import-action-bar .import-title {
  font-weight: 700;
  font-size: 16px;
}

/* ── Import Tab: Summary Cards Row ── */
.import-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}
.import-summary .summary-card {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 10px 14px;
  text-align: center;
}
.summary-card .sc-value {
  font-size: 20px;
  font-weight: 700;
}
.summary-card .sc-label {
  font-size: 12px;
  color: #64748b;
}

/* ── Semantic Color Utilities ────── */
.text-commission { color: var(--commission-purple); }
.text-danger-red { color: var(--danger-red); }
.text-slate-muted { color: var(--text-slate-muted); }
.border-commission { border-left-color: var(--commission-purple); }
.border-warning { border-left-color: var(--warning-amber); }
.border-info { border-left-color: var(--info-blue-bright); }
.border-danger { border-left-color: var(--danger-red); }

/* ── Login Page ──────────────────── */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--bg-darkest) 0%, var(--primary-dark) 60%, var(--bg-darkest) 100%);
}
.login-card {
  background: #fff;
  border-radius: var(--radius-lg);
  padding: 40px 36px;
  width: 380px;
  max-width: 95vw;
  box-shadow: 0 20px 60px rgba(0,0,0,.25);
}
.login-card .logo {
  text-align: center;
  margin-bottom: 8px;
  font-size: 22px;
  font-weight: 700;
  color: var(--primary-dark);
}
.login-card .subtitle {
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
  margin-bottom: 28px;
}
.login-card .form-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 6px;
}
.login-card .form-control {
  height: 44px;
  font-size: 15px;
  border-radius: var(--radius-sm);
  border: 2px solid var(--border-light);
  transition: border-color var(--transition-fast);
}
.login-card .form-control:focus {
  border-color: var(--primary-dark);
  box-shadow: none;
}
.login-card .btn-login {
  width: 100%;
  height: 44px;
  background: var(--primary-dark);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--transition-fast);
  margin-top: 8px;
}
.login-card .btn-login:hover { background: var(--primary-dark-hover); }
.login-error {
  background: var(--danger-bg);
  border: 1px solid var(--danger-border);
  color: #991b1b;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  margin-bottom: 16px;
  text-align: center;
}

/* ── SKU Form Sections ────────────────── */
.sku-form-section {
  padding: 8px 10px;
  margin-bottom: 2px;
  border-left: 3px solid #e5e7eb;
  transition: border-color 0.2s;
}
.sku-form-section:hover {
  border-left-color: #3b82f6;
}
.sku-form-section .form-label {
  font-size: 12px;
  margin-bottom: 2px;
  color: #374151;
}
.sku-form-section .form-control-sm,
.sku-form-section .form-select-sm {
  font-size: 12px;
}
.sku-form-section .input-group-text {
  font-size: 13px;
  background: #f9fafb;
}

/* BOM autocomplete items */
.bom-ac-item:hover {
  background: #eff6ff !important;
}

/* SKU table compact */
#bomTable th {
  font-size: 11px;
  font-weight: 600;
  color: #6b7280;
  padding: 6px 4px;
  white-space: nowrap;
}
#bomTable td {
  font-size: 12px;
  padding: 5px 4px;
  vertical-align: middle;
}

/* ── Logic Info Card (统一处理逻辑说明) ── */
.logic-info-card {
  background: #f0f7ff;
  border: 1px solid #bae0fd;
  border-left: 3px solid #3b82f6;
  border-radius: 8px;
  padding: 10px 14px;
  margin-bottom: 12px;
  font-size: 12px;
  color: #1e40af;
  line-height: 1.85;
}
.logic-info-card .logic-title {
  font-weight: 600;
  font-size: 13px;
  color: #1e40af;
  cursor: pointer;
  user-select: none;
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0;
}
.logic-info-card .logic-title .logic-arrow {
  transition: transform 0.2s ease;
  font-size: 10px;
  display: inline-block;
}
.logic-info-card .logic-body {
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px dashed #bae0fd;
}
.logic-info-card .logic-body.collapsed {
  display: none;
}
.logic-info-badge {
  display: inline-block;
  background: #dbeafe;
  color: #1e40af;
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 3px;
  font-weight: 600;
  margin-right: 4px;
}
.logic-info-card .logic-formula {
  background: #e0f2fe;
  padding: 2px 8px;
  border-radius: 4px;
  font-family: 'SF Mono', 'Consolas', 'Courier New', monospace;
  font-size: 11px;
  white-space: nowrap;
}
/* Compact variant for inline / summary hints */
.logic-info-card--sm {
  padding: 6px 10px;
  margin-bottom: 8px;
  font-size: 11px;
  line-height: 1.7;
}
/* Purple variant for commission/task hints */
.logic-info-card--purple {
  background: #f5f3ff;
  border-color: #c4b5fd;
  border-left-color: #8b5cf6;
  color: #5b21b6;
}
.logic-info-card--purple .logic-title {
  color: #5b21b6;
}
.logic-info-card--purple .logic-body {
  border-top-color: #c4b5fd;
}
.logic-info-card--purple .logic-info-badge {
  background: #ede9fe;
  color: #5b21b6;
}
.logic-info-card--purple .logic-formula {
  background: #ede9fe;
}

/* ── Print Styles ────────────────── */
@media print {
  .app-header, .tab-bar, #toastContainer, button { display: none !important; }
  .main-content { max-width: 100%; padding: 0; }
  .tab-panel { display: block !important; }
  .card-flat { box-shadow: none; border: 1px solid #ccc; break-inside: avoid; }
  .kpi-card { break-inside: avoid; }
}
