/* 排行范式通用样式 — 空状态 / 进度条 / 面包屑 / 筛选栏 */

.ranking-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  margin-bottom: 16px;
  padding: 12px 16px;
  background: #f9fafb;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
}

.ds-selector-wrap {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 260px;
}

.ds-label {
  font-size: 13px;
  color: #374151;
  font-weight: 500;
  white-space: nowrap;
}

.ds-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.ds-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: 4px;
  font-size: 12px;
  color: #1d4ed8;
}

.ds-tag-remove {
  cursor: pointer;
  color: #6b7280;
  font-size: 14px;
  line-height: 1;
  border: none;
  background: none;
  padding: 0 2px;
}

.ds-tag-remove:hover {
  color: #ef4444;
}

.ds-dropdown-wrap {
  position: relative;
}

.ds-dropdown-btn {
  padding: 5px 10px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  background: #fff;
  cursor: pointer;
  font-size: 13px;
}

.ds-dropdown-panel {
  position: absolute;
  top: 100%;
  left: 0;
  z-index: 100;
  min-width: 240px;
  max-height: 280px;
  overflow-y: auto;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  padding: 8px 0;
  margin-top: 4px;
}

.ds-dropdown-panel label {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  cursor: pointer;
  font-size: 13px;
}

.ds-dropdown-panel label:hover {
  background: #f3f4f6;
}

.ds-dropdown-panel .ds-all-warn {
  padding: 6px 14px;
  font-size: 12px;
  color: #d97706;
  background: #fffbeb;
  border-bottom: 1px solid #fde68a;
}

.ds-count {
  font-size: 12px;
  color: #6b7280;
}

.ds-locked {
  font-size: 13px;
  color: #374151;
}

.ranking-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-bottom: 16px;
}

.ranking-filters .period-group {
  display: flex;
  gap: 0;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  overflow: hidden;
}

.ranking-filters .period-btn {
  padding: 5px 12px;
  border: none;
  background: #fff;
  font-size: 13px;
  cursor: pointer;
  border-right: 1px solid #d1d5db;
}

.ranking-filters .period-btn:last-child {
  border-right: none;
}

.ranking-filters .period-btn.active {
  background: #2563eb;
  color: #fff;
}

.mode-switch {
  display: flex;
  gap: 0;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  overflow: hidden;
  margin-bottom: 16px;
}

.mode-btn {
  padding: 8px 20px;
  border: none;
  background: #fff;
  font-size: 13px;
  cursor: pointer;
  border-right: 1px solid #d1d5db;
}

.mode-btn:last-child {
  border-right: none;
}

.mode-btn.active {
  background: #1e293b;
  color: #fff;
}

.ranking-breadcrumb {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 12px;
  font-size: 13px;
  color: #64748b;
}

.breadcrumb-item {
  cursor: pointer;
  color: #2563eb;
}

.breadcrumb-item:hover {
  text-decoration: underline;
}

.breadcrumb-sep {
  color: #cbd5e1;
}

.back-btn {
  margin-right: 8px;
}

.empty-state {
  text-align: center;
  padding: 60px 24px;
  color: #9ca3af;
}

.empty-state .empty-icon {
  font-size: 48px;
  margin-bottom: 12px;
}

.empty-state .empty-title {
  font-size: 16px;
  font-weight: 600;
  color: #374151;
  margin: 0 0 8px;
}

.empty-state .empty-hint {
  font-size: 13px;
  line-height: 1.6;
  max-width: 400px;
  margin: 0 auto;
}

.ranking-loading {
  text-align: center;
  padding: 48px;
  color: #6b7280;
}

.ranking-error {
  text-align: center;
  padding: 48px;
  color: #ef4444;
}

.stat-cards-row {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}

.stat-card-rank {
  background: #f9fafb;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 14px 16px;
}

.stat-card-rank .label {
  font-size: 12px;
  color: #6b7280;
}

.stat-card-rank .value {
  font-size: 22px;
  font-weight: 700;
  color: #111827;
  margin-top: 4px;
}

.pct-bar-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 100px;
}

.pct-bar {
  flex: 1;
  height: 8px;
  background: #e5e7eb;
  border-radius: 4px;
  overflow: hidden;
}

.pct-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #fbbf24, #f59e0b);
  border-radius: 4px;
  transition: width 0.3s;
}

.pct-bar-label {
  font-size: 11px;
  color: #6b7280;
  min-width: 36px;
  text-align: right;
}

.stock-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 500;
}

.stock-badge.in-stock {
  background: #dcfce7;
  color: #166534;
}

.stock-badge.no-stock {
  background: #f3f4f6;
  color: #9ca3af;
}

.ranking-chart-box {
  width: 100%;
  height: 280px;
  margin-bottom: 20px;
}

.model-link,
.customer-link,
.buyer-count-link,
.customer-frequency-link {
  color: #2563eb;
  cursor: pointer;
  text-decoration: none;
}

.model-link:hover,
.customer-link:hover,
.buyer-count-link:hover,
.customer-frequency-link:hover {
  text-decoration: underline;
}

.ranking-tab-group {
  display: flex;
  gap: 0;
  border-bottom: 2px solid #e5e7eb;
  margin-bottom: 16px;
}

.ranking-tab {
  padding: 8px 18px;
  border: none;
  background: none;
  font-size: 13px;
  color: #6b7280;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
}

.ranking-tab.active {
  color: #2563eb;
  border-bottom-color: #2563eb;
  font-weight: 600;
}

.ranking-actions {
  display: flex;
  gap: 6px;
}

.ranking-actions .btn-icon {
  padding: 2px 6px;
  font-size: 12px;
  border: 1px solid #e5e7eb;
  border-radius: 4px;
  background: #fff;
  cursor: pointer;
}

.ranking-actions .btn-icon:hover {
  background: #f3f4f6;
}

/* —— 全系数据 v2 —— */
.market-data-page .main,
#market-page {
  background: #f0f2f5;
}

.market-data-page .page-sub {
  font-size: 14px;
  font-weight: 400;
  color: #8c8c8c;
}

.market-stat-cards .stat-card-rank {
  background: #fff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
  border: none;
}

.market-stat-cards .stat-card-rank .label {
  font-size: 12px;
  color: #8c8c8c;
}

.market-stat-cards .stat-card-rank .value {
  font-size: 28px;
  color: #1a1a1a;
}

.card-panel {
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
  padding: 16px;
  margin-bottom: 16px;
}

.market-filters {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
}

.market-filters .period-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  border: none;
}

.market-filters .period-btn {
  padding: 6px 14px;
  border: 1px solid #d9d9d9;
  border-radius: 6px;
  background: #fff;
  color: #595959;
  font-size: 13px;
  cursor: pointer;
}

.market-filters .period-btn.active {
  background: #1677ff;
  border-color: #1677ff;
  color: #fff;
}

.market-tabs-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.ranking-tab-group .ranking-tab.active {
  color: #1677ff;
  border-bottom-color: #1677ff;
}

.market-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
}

.md-total {
  margin-left: auto;
  font-size: 13px;
  color: #8c8c8c;
}

.pct-fill {
  height: 100%;
  background: linear-gradient(90deg, #4096ff, #1677ff);
  border-radius: 4px;
}

.model-pill {
  border: none;
  background: none;
  color: #1677ff;
  cursor: default;
  font-size: 13px;
  padding: 0;
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.model-copy-cell {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.btn-copy {
  border: none;
  background: none;
  cursor: pointer;
  padding: 2px 4px;
  font-size: 14px;
  opacity: 0.7;
}

.btn-copy:hover {
  opacity: 1;
}

.stock-tag.green {
  color: #52c41a;
  font-size: 12px;
  font-weight: 500;
}

.stock-leadtime {
  display: block;
  font-size: 11px;
  color: #8c8c8c;
}

.customer-cell {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.cust-name {
  font-weight: 500;
  color: #1a1a1a;
}

.cust-wxid {
  font-size: 11px;
  color: #8c8c8c;
}

.market-table thead th {
  background: #fafafa;
}

.btn-primary {
  background: #1677ff;
  color: #fff;
  border-color: #1677ff;
}

.svg-chart-box.svg-chart-vertical {
  height: auto;
  min-height: 280px;
  max-height: 320px;
  margin-bottom: 24px;
  overflow: hidden;
  box-sizing: border-box;
}

.svg-vbar-wrap {
  width: 100%;
}

.svg-vbar-wrap svg {
  display: block;
}

.svg-vbar-rect {
  transition: fill 0.15s;
}

.svg-vbar-rect:hover {
  fill: #4096ff;
}

/* 右侧详情抽屉 */
.drawer-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 10000;
  background: rgba(0, 0, 0, 0.45);
  opacity: 0;
  transition: opacity 0.28s ease;
}

.drawer-overlay.open {
  opacity: 1;
}

.drawer-panel {
  position: fixed;
  top: 0;
  right: 0;
  width: min(560px, 92vw);
  height: 100vh;
  max-height: 100vh;
  background: #fff;
  box-shadow: -4px 0 24px rgba(0, 0, 0, 0.12);
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.28s ease;
}

.drawer-overlay.open .drawer-panel {
  transform: translateX(0);
}

.drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid #f0f0f0;
  flex-shrink: 0;
}

.drawer-header #md-drawer-title {
  font-size: 16px;
  font-weight: 600;
  color: #1a1a1a;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.drawer-close-btn {
  border: none;
  background: #f5f5f5;
  width: 32px;
  height: 32px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  color: #595959;
  flex-shrink: 0;
}

.drawer-close-btn:hover {
  background: #e8e8e8;
  color: #1a1a1a;
}

.drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px 24px;
}

.drawer-body .stat-cards-row {
  grid-template-columns: repeat(2, 1fr);
}

.drawer-body .card-panel {
  margin-bottom: 12px;
  padding: 12px;
}

.drawer-body .section-t {
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 8px;
  color: #374151;
}

.svg-bar-tooltip {
  position: absolute;
  z-index: 50;
  background: #1a1a2e;
  color: #ffd700;
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 12px;
  pointer-events: none;
  white-space: nowrap;
}

.copy-toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: #1a1a2e;
  color: #ffd700;
  padding: 10px 24px;
  border-radius: 8px;
  font-size: 14px;
  z-index: 9999;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
  transition: opacity 0.3s;
  pointer-events: none;
}

.drill-header {
  margin-bottom: 16px;
}

.drill-title {
  font-size: 18px;
  margin: 8px 0 0;
}

.global-rank {
  font-weight: 600;
  color: #1677ff;
}

.info-tip {
  cursor: help;
  opacity: 0.6;
}

.chart-empty {
  text-align: center;
  color: #bfbfbf;
  padding: 40px;
}

/* 热销排行 — 竖向柱状图 */
.hot-rankings-page .svg-vbar-wrap,
#ranking-page .svg-vbar-wrap {
  overflow: hidden;
  margin-bottom: 20px;
  background: #fafafa;
  border-radius: 8px;
  border: 1px solid #f0f0f0;
  padding: 8px;
}

#ranking-page .svg-vbar-rect {
  cursor: pointer;
  transition: opacity 0.2s;
}

#ranking-page .svg-vbar-rect:hover {
  opacity: 0.75;
}

#ranking-page .svg-vbar-col {
  cursor: pointer;
}

#ranking-page .ranking-chart-box {
  min-height: 320px;
  margin-bottom: 20px;
  height: auto;
}

/* QQ 风格数据源选择器 */
.ds-qq-wrap {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 4px;
}
.ds-qq-select {
  min-width: 280px;
  max-width: 400px;
  padding: 4px 6px;
  border: 1px solid #d9d9d9;
  border-radius: 6px;
  font-size: 13px;
  background: #fff;
  cursor: pointer;
}
.ds-qq-select:focus {
  border-color: #1677ff;
  box-shadow: 0 0 0 2px rgba(22, 119, 255, 0.1);
  outline: none;
}
.ds-qq-select option {
  padding: 4px 8px;
}
.ds-qq-hint {
  margin: 0;
  font-size: 12px;
  color: #9ca3af;
  width: 100%;
}
.ds-qq-actions {
  display: flex;
  gap: 8px;
  padding: 6px 14px 8px;
  border-bottom: 1px solid #f3f4f6;
}
.ds-qq-actions button {
  padding: 2px 8px;
  font-size: 12px;
  border: 1px solid #d1d5db;
  border-radius: 4px;
  background: #fff;
  cursor: pointer;
}
.ds-qq-summary {
  font-size: 13px;
  color: #374151;
}
.ds-qq-warn {
  margin: 0;
  width: 100%;
  font-size: 12px;
  color: #b45309;
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-radius: 6px;
  padding: 6px 10px;
}
.ds-applied {
  margin: 0;
  width: 100%;
  font-size: 12px;
  color: #4b5563;
}
.ds-tag-fixed {
  cursor: default;
}
