/**
 * 佳为ERP 数字店长 - Jade Breeze 翡翠清风主题
 *
 * 美学方向：微信设计语言 · 小清新 · 通透轻盈
 * 字体：Plus Jakarta Sans (标题) + Source Code Pro (数据)
 * 特色：浅色基底 · 微信绿强调 · 柔和阴影 · 圆润边角
 */

/* ========== Google Fonts ========== */
@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700;800&family=Source+Code+Pro:wght@400;500;600;700&display=swap');

/* ========== CSS 变量 ========== */
:root {
  /* 核心色板 */
  --bg-page: #F0F0F0;
  --bg-card: #FFFFFF;
  --bg-sidebar: #FFFFFF;
  --bg-header: #FFFFFF;
  --bg-input: #F5F5F5;
  --bg-hover: #F5F5F5;
  --bg-active: #E8F8EE;

  /* 微信绿 */
  --green: #07C160;
  --green-hover: #06AD56;
  --green-light: #E8F8EE;
  --green-glow: rgba(7, 193, 96, 0.12);

  /* 辅助色 */
  --blue: #576B95;
  --blue-light: #EEF1F6;
  --orange: #FA9D3B;
  --orange-light: #FFF4E6;
  --red: #FA5151;
  --red-light: #FEF0f0;
  --teal: #10AEFF;
  --teal-light: #E6F4FF;

  /* 文字色阶 */
  --text-primary: #1A1A1A;
  --text-secondary: #666666;
  --text-muted: #999999;
  --text-placeholder: #CCCCCC;

  /* 边框 */
  --border: #E5E5E5;
  --border-light: #F0F0F0;

  /* 阴影 */
  --shadow-sm: 0 1px 4px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 2px 12px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 4px 24px rgba(0, 0, 0, 0.08);

  /* 圆角 */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;

  /* 侧边栏 */
  --sidebar-width: 220px;

  /* 动画 */
  --ease: cubic-bezier(0.25, 0.1, 0.25, 1);
  --transition: 0.25s var(--ease);
}

/* ========== 重置样式 ========== */
*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html, body {
  height: 100%;
  font-family: 'Plus Jakarta Sans', -apple-system, 'PingFang SC', 'Hiragino Sans GB',
    'Microsoft YaHei', 'Helvetica Neue', sans-serif;
  font-size: 14px;
  color: var(--text-primary);
  background: var(--bg-page);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow: hidden;
}

/* ========== 滚动条 ========== */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: #D9D9D9;
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: #BFBFBF;
}

/* ========== 整体布局 ========== */
.layout {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ========== 左侧菜单栏 ========== */
.sidebar {
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  background: var(--bg-sidebar);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  z-index: 100;
  border-right: 1px solid var(--border-light);
}

.sidebar-header {
  padding: 24px 20px 20px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo-icon {
  font-size: 30px;
  line-height: 1;
}

.logo-text h1 {
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 17px;
  font-weight: 800;
  color: var(--text-primary);
  line-height: 1.2;
  letter-spacing: -0.02em;
}

.logo-text p {
  font-size: 11px;
  font-weight: 600;
  color: var(--green);
  margin-top: 2px;
  letter-spacing: 0.1em;
}

.sidebar-nav {
  flex: 1;
  padding: 8px 10px;
}

.menu-list {
  list-style: none;
}

.menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 14px;
  margin-bottom: 2px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 500;
  transition: var(--transition);
  position: relative;
}

.menu-item:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.menu-item.active {
  background: var(--green-light);
  color: var(--green);
  font-weight: 600;
}

.menu-icon {
  font-size: 18px;
  line-height: 1;
}

.menu-text {
  white-space: nowrap;
}

.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--border-light);
  text-align: center;
}

.sidebar-footer p {
  font-size: 11px;
  color: var(--text-muted);
}

/* ========== 右侧内容区 ========== */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
  background: var(--bg-page);
}

.content-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 28px;
  background: var(--bg-header);
  border-bottom: 1px solid var(--border-light);
  z-index: 10;
}

.page-title {
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 20px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.01em;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 14px;
}

.current-time {
  font-family: 'Source Code Pro', monospace;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  letter-spacing: 0.02em;
  padding: 5px 12px;
  background: var(--bg-input);
  border-radius: var(--radius-sm);
}

.content-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px 28px;
}

/* ========== 页面容器 ========== */
.page {
  animation: pageIn 0.35s var(--ease);
}

@keyframes pageIn {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ========== 占位页面 ========== */
.placeholder-page {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 400px;
  color: var(--text-muted);
}

.placeholder-icon {
  font-size: 56px;
  margin-bottom: 16px;
}

.placeholder-page h3 {
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 18px;
  color: var(--text-secondary);
  margin-bottom: 8px;
  font-weight: 600;
}

.placeholder-page p {
  font-size: 14px;
}

/* ========== 筛选栏 ========== */
.filter-bar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  padding: 14px 18px;
  background: var(--bg-card);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  margin-bottom: 20px;
}

.filter-group {
  display: flex;
  align-items: center;
  gap: 6px;
}

.filter-group label {
  font-size: 13px;
  color: var(--text-secondary);
  white-space: nowrap;
  font-weight: 500;
}

.filter-input {
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: 'Source Code Pro', monospace;
  font-size: 12px;
  color: var(--text-primary);
  background: var(--bg-input);
  outline: none;
  transition: var(--transition);
}

.filter-input:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px var(--green-glow);
  background: #fff;
}

.quick-filters {
  display: flex;
  gap: 6px;
  margin-left: 6px;
}

/* ========== 按钮 ========== */
.btn {
  padding: 7px 16px;
  border: none;
  border-radius: var(--radius-sm);
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
}

.btn-primary {
  background: var(--green);
  color: #fff;
}

.btn-primary:hover {
  background: var(--green-hover);
  box-shadow: 0 2px 8px var(--green-glow);
}

.btn-primary:active {
  transform: scale(0.97);
}

.btn-outline {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border);
}

.btn-outline:hover {
  border-color: var(--green);
  color: var(--green);
  background: var(--green-light);
}

.btn-outline.active {
  border-color: var(--green);
  color: var(--green);
  background: var(--green-light);
}

/* ========== 汇总卡片 ========== */
.summary-cards {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 14px;
  margin-bottom: 20px;
}

.summary-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 18px;
  background: var(--bg-card);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  transition: var(--transition);
  animation: cardIn 0.4s var(--ease) backwards;
}

.summary-card:nth-child(1) { animation-delay: 0.03s; }
.summary-card:nth-child(2) { animation-delay: 0.06s; }
.summary-card:nth-child(3) { animation-delay: 0.09s; }
.summary-card:nth-child(4) { animation-delay: 0.12s; }
.summary-card:nth-child(5) { animation-delay: 0.15s; }

@keyframes cardIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.summary-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.card-icon {
  font-size: 30px;
  line-height: 1;
}

.card-info {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.card-label {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 500;
}

.card-value {
  font-family: 'Source Code Pro', monospace;
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.02em;
}

.card-value.positive {
  color: var(--green);
}

.card-value.negative {
  color: var(--red);
}

/* ========== 图表区域 ========== */
.charts-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  margin-bottom: 20px;
}

.charts-row-narrow {
  grid-template-columns: repeat(2, 1fr);
}

.chart-container {
  background: var(--bg-card);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  transition: var(--transition);
}

.chart-container:hover {
  box-shadow: var(--shadow-md);
}

.chart-container.chart-full {
  grid-column: 1 / -1;
}

.chart-title {
  padding: 13px 18px;
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  border-bottom: 1px solid var(--border-light);
}

.chart-body {
  width: 100%;
  height: 320px;
  padding: 8px;
}

/* ========== 表格 ========== */
.table-container {
  background: var(--bg-card);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.table-title {
  padding: 13px 18px;
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  border-bottom: 1px solid var(--border-light);
}

.table-wrapper {
  overflow-x: auto;
}

.data-table {
  width: 100%;
  table-layout: fixed;
  border-collapse: collapse;
  font-size: 13px;
}

.data-table thead {
  background: var(--bg-input);
}

.data-table colgroup .col-index { width: 36px; }
.data-table colgroup .col-name { width: 110px; }
.data-table colgroup .col-qty { width: 58px; }
.data-table colgroup .col-price { width: 68px; }
.data-table colgroup .col-cost { width: 68px; }
.data-table colgroup .col-amount { width: 82px; }
.data-table colgroup .col-cost-total { width: 76px; }
.data-table colgroup .col-profit { width: 76px; }
.data-table colgroup .col-margin { width: 70px; }

.data-table th,
.data-table td {
  padding: 10px 6px;
  border-bottom: 1px solid var(--border-light);
}

.data-table th {
  text-align: right;
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-weight: 600;
  color: var(--text-muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  white-space: nowrap;
  background: var(--bg-input);
  user-select: none;
}

.data-table th.sortable {
  cursor: pointer;
  transition: var(--transition);
}

.data-table th.sortable:hover {
  color: var(--green);
  background: var(--green-light);
}

.data-table th.sortable::after {
  content: ' ↕';
  font-size: 10px;
  opacity: 0.4;
}

.data-table th.sortable.sort-asc::after {
  content: ' ↑';
  opacity: 1;
  color: var(--green);
}

.data-table th.sortable.sort-desc::after {
  content: ' ↓';
  opacity: 1;
  color: var(--green);
}

.data-table th:first-child,
.data-table td:first-child {
  text-align: center;
}

.data-table th:nth-child(2),
.data-table td:nth-child(2) {
  text-align: left;
}

.data-table td {
  font-family: 'Source Code Pro', monospace;
  font-size: 12px;
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: right;
}

.data-table tbody tr {
  transition: var(--transition);
}

.data-table tbody tr:hover {
  background: var(--bg-hover);
}

.data-table tbody tr:nth-child(even) {
  background: #FAFAFA;
}

.data-table tbody tr:nth-child(even):hover {
  background: var(--bg-hover);
}

.data-table .text-right {
  text-align: right;
}

.data-table .text-positive {
  color: var(--green);
  font-weight: 600;
}

.data-table .text-negative {
  color: var(--red);
  font-weight: 600;
}

/* ========== 加载状态 ========== */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
  color: var(--text-muted);
}

.loading::before {
  content: '';
  width: 20px;
  height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--green);
  border-radius: 50%;
  margin-right: 10px;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ========== 空数据状态 ========== */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  color: var(--text-muted);
}

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

.empty-state p {
  font-size: 14px;
}

/* ========== 加载遮罩 ========== */
.loading-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  border-radius: var(--radius-md);
}

.loading-spinner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--green);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.loading-spinner span {
  font-size: 14px;
  color: var(--text-secondary);
  font-weight: 500;
}

/* ========== 响应式 ========== */
@media (max-width: 1200px) {
  .summary-cards {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (max-width: 992px) {
  .charts-row {
    grid-template-columns: 1fr;
  }

  .summary-cards {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 768px) {
  .sidebar {
    width: 60px;
    min-width: 60px;
  }

  .logo-text,
  .menu-text,
  .sidebar-footer p {
    display: none;
  }

  .sidebar-header {
    padding: 16px 8px;
    text-align: center;
  }

  .logo {
    justify-content: center;
  }

  .menu-item {
    justify-content: center;
    padding: 12px 8px;
  }

  .summary-cards {
    grid-template-columns: 1fr;
  }

  .filter-bar {
    flex-direction: column;
    align-items: stretch;
  }

  .quick-filters {
    margin-left: 0;
  }
}

/* ========== AI 店长浮动按钮（右下角） ========== */
.ai-fab {
  position: fixed;
  bottom: 28px;
  right: 28px;
  z-index: 999;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 22px;
  background: linear-gradient(135deg, var(--green) 0%, #2DB86A 100%);
  color: #fff;
  border: none;
  border-radius: 50px;
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  white-space: nowrap;
  box-shadow: 0 4px 16px var(--green-glow), 0 2px 6px rgba(0, 0, 0, 0.08);
  letter-spacing: 0.3px;
}

.ai-fab:hover {
  transform: translateY(-3px) scale(1.04);
  box-shadow: 0 8px 28px var(--green-glow), 0 4px 12px rgba(0, 0, 0, 0.12);
  background: linear-gradient(135deg, var(--green-hover) 0%, #25A55C 100%);
}

.ai-fab:active {
  transform: translateY(0) scale(0.98);
}

.ai-fab-icon {
  font-size: 22px;
  line-height: 1;
}

.ai-fab-label {
  line-height: 1;
}

/* 面板展开时隐藏浮动按钮 */
.ai-fab.ai-fab-hidden {
  transform: scale(0);
  opacity: 0;
  pointer-events: none;
}

/* ========== AI 店长悬浮面板 ========== */
.ai-panel {
  position: fixed;
  bottom: 28px;
  right: 28px;
  width: 480px;
  max-height: calc(100vh - 60px);
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  box-shadow: 0 12px 48px rgba(0, 0, 0, 0.15), 0 0 0 1px rgba(0, 0, 0, 0.04);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  transition: all 0.35s cubic-bezier(0.4, 0, 0.2, 1);
  overflow: hidden;
}

.ai-panel-hidden {
  transform: translateY(20px) scale(0.95);
  opacity: 0;
  pointer-events: none;
}

.ai-panel-expanded {
  transform: translateY(0) scale(1);
  opacity: 1;
}

.ai-panel-collapsed {
  transform: translateY(0) scale(1);
  opacity: 1;
}

.ai-panel-collapsed .ai-panel-body,
.ai-panel-collapsed .ai-panel-footer {
  display: none;
}

/* 面板头部 */
.ai-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  background: var(--green);
  color: #fff;
  flex-shrink: 0;
}

.ai-panel-title {
  display: flex;
  align-items: center;
  gap: 8px;
}

.ai-panel-title h3 {
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 15px;
  font-weight: 700;
  margin: 0;
}

.ai-panel-icon {
  font-size: 20px;
}

.ai-panel-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

.ai-btn-icon {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.2);
  border: none;
  border-radius: 6px;
  color: #fff;
  font-size: 14px;
  cursor: pointer;
  transition: var(--transition);
}

.ai-btn-icon:hover {
  background: rgba(255, 255, 255, 0.35);
}

.ai-toggle-icon {
  font-size: 12px;
  transition: transform 0.3s ease;
}

/* 面板内容区 */
.ai-panel-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px 18px;
  min-height: 200px;
  max-height: calc(100vh - 260px);
}

.ai-panel-body::-webkit-scrollbar {
  width: 6px;
}

.ai-panel-body::-webkit-scrollbar-thumb {
  background: #D9D9D9;
  border-radius: 3px;
}

.ai-panel-body::-webkit-scrollbar-thumb:hover {
  background: #BFBFBF;
}

/* 面板底部 */
.ai-panel-footer {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 18px;
  border-top: 1px solid var(--border-light);
  background: var(--bg-input);
  flex-shrink: 0;
}

/* 欢迎提示 */
.ai-welcome {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
  text-align: center;
  color: var(--text-secondary);
}

.ai-welcome-icon {
  font-size: 48px;
  margin-bottom: 16px;
}

.ai-welcome p {
  font-size: 14px;
  line-height: 1.6;
}

/* AI 分析输出区域 */
.ai-analysis-output {
  font-size: 14px;
  line-height: 1.8;
  color: var(--text-primary);
}

.ai-analysis-output h1,
.ai-analysis-output h2,
.ai-analysis-output h3,
.ai-analysis-output h4 {
  margin-top: 16px;
  margin-bottom: 8px;
  color: var(--text-primary);
  font-family: 'Plus Jakarta Sans', sans-serif;
}

.ai-analysis-output h2 {
  font-size: 16px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border-light);
}

.ai-analysis-output h3 {
  font-size: 15px;
}

.ai-analysis-output p {
  margin: 8px 0;
}

.ai-analysis-output ul,
.ai-analysis-output ol {
  padding-left: 20px;
  margin: 8px 0;
}

.ai-analysis-output li {
  margin: 4px 0;
}

.ai-analysis-output table {
  width: 100%;
  border-collapse: collapse;
  margin: 12px 0;
  font-size: 13px;
}

.ai-analysis-output th,
.ai-analysis-output td {
  padding: 8px 10px;
  border: 1px solid var(--border);
  text-align: left;
}

.ai-analysis-output th {
  background: var(--bg-input);
  font-weight: 600;
  color: var(--text-primary);
}

.ai-analysis-output td {
  color: var(--text-secondary);
}

.ai-analysis-output strong {
  color: var(--green);
}

.ai-analysis-output blockquote {
  margin: 12px 0;
  padding: 8px 16px;
  border-left: 3px solid var(--green);
  background: var(--green-light);
  color: var(--text-secondary);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

.ai-analysis-output hr {
  margin: 16px 0;
  border: none;
  border-top: 1px solid var(--border-light);
}

.ai-analysis-output code {
  font-family: 'Source Code Pro', monospace;
  background: var(--bg-input);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 13px;
  color: var(--green);
}

.ai-analysis-output pre {
  background: #1A1A1A;
  color: #E0E0E0;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  overflow-x: auto;
  margin: 12px 0;
}

.ai-analysis-output pre code {
  background: none;
  padding: 0;
  color: inherit;
}

/* 加载动画 */
.ai-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
  color: var(--text-secondary);
}

.ai-loading p {
  margin-top: 12px;
  font-size: 14px;
}

.ai-loading-dots {
  display: flex;
  gap: 6px;
}

.ai-loading-dots span {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--green);
  animation: ai-dot-bounce 1.4s infinite ease-in-out both;
}

.ai-loading-dots span:nth-child(1) {
  animation-delay: -0.32s;
}

.ai-loading-dots span:nth-child(2) {
  animation-delay: -0.16s;
}

@keyframes ai-dot-bounce {
  0%, 80%, 100% {
    transform: scale(0.6);
    opacity: 0.4;
  }
  40% {
    transform: scale(1);
    opacity: 1;
  }
}

/* 错误提示 */
.ai-error {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 30px 20px;
  text-align: center;
}

.ai-error-icon {
  font-size: 36px;
  margin-bottom: 12px;
}

.ai-error p {
  color: var(--red);
  font-size: 14px;
  line-height: 1.6;
}

/* ========== AI 设置面板 ========== */
.ai-settings {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--bg-card);
  flex-direction: column;
  z-index: 10;
}

.ai-settings-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border-light);
}

.ai-settings-header h4 {
  margin: 0;
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
}

.ai-settings-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px 18px;
}

.ai-form-group {
  margin-bottom: 14px;
}

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

.ai-form-input {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: 'Source Code Pro', monospace;
  font-size: 12px;
  color: var(--text-primary);
  background: var(--bg-input);
  transition: var(--transition);
}

.ai-form-input:focus {
  outline: none;
  border-color: var(--green);
  box-shadow: 0 0 0 3px var(--green-glow);
  background: #fff;
}

.ai-form-input::placeholder {
  color: var(--text-placeholder);
}

.ai-form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.ai-form-check label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  cursor: pointer;
  color: var(--text-primary);
}

.ai-form-check input[type="checkbox"] {
  width: 16px;
  height: 16px;
  cursor: pointer;
  accent-color: var(--green);
}

.ai-settings-footer {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 18px;
  border-top: 1px solid var(--border-light);
  background: var(--bg-input);
}

/* ========== 响应式适配 ========== */
@media (max-width: 768px) {
  .ai-panel {
    width: calc(100vw - 16px);
    right: 8px;
    bottom: 8px;
    max-height: calc(100vh - 70px);
  }

  .ai-fab {
    bottom: 16px;
    right: 16px;
    padding: 12px 18px;
    font-size: 13px;
  }

  .ai-fab-icon {
    font-size: 20px;
  }
}

/* ========== ECharts 图表适配 ========== */
.chart-body canvas {
  border-radius: var(--radius-sm);
}

/* ========== 库存页面 - 汇总卡片4列 ========== */
.summary-cards-4 {
  grid-template-columns: repeat(4, 1fr);
}

@media (max-width: 1200px) {
  .summary-cards-4 {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 768px) {
  .summary-cards-4 {
    grid-template-columns: 1fr;
  }
}

/* ========== 库存页面 - 下拉选择框 ========== */
.filter-select {
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: 'Source Code Pro', monospace;
  font-size: 12px;
  color: var(--text-primary);
  background: var(--bg-input);
  outline: none;
  transition: var(--transition);
  cursor: pointer;
  appearance: auto;
}

.filter-select:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px var(--green-glow);
  background: #fff;
}

/* ========== 库存页面 - 表格容器 ========== */
.stock-table-container {
  position: relative;
}

/* 库存表格使用自动列宽 */
.stock-table {
  table-layout: auto;
}

/* 库存表格最小列宽 */
.stock-table th:nth-child(1),
.stock-table td:nth-child(1) { white-space: nowrap; } /* # */
.stock-table th:nth-child(2),
.stock-table td:nth-child(2) { white-space: nowrap; min-width: 60px; } /* 货号 */
.stock-table th:nth-child(3),
.stock-table td:nth-child(3) { min-width: 120px; max-width: 220px; } /* 品名 */
.stock-table th:nth-child(4),
.stock-table td:nth-child(4) { white-space: nowrap; min-width: 100px; } /* 条码 */
.stock-table th:nth-child(5),
.stock-table td:nth-child(5) { white-space: nowrap; } /* 品牌 */
.stock-table th:nth-child(6),
.stock-table td:nth-child(6) { white-space: nowrap; } /* 大类 */
.stock-table th:nth-child(7),
.stock-table td:nth-child(7) { white-space: nowrap; } /* 小类 */

/* 表头对齐类 */
.stock-table .th-center { text-align: center !important; }
.stock-table .th-left { text-align: left !important; }
.stock-table .th-right { text-align: right !important; }

.stock-table .stock-name-cell {
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stock-table .stock-empty-cell {
  padding: 0 !important;
}

/* 低库存警告 */
.text-low-stock {
  color: var(--orange);
  font-weight: 600;
}

/* 可点击的分类单元格 */
.stock-clickable-cell {
  cursor: pointer;
  color: var(--blue) !important;
  text-decoration: underline;
  text-decoration-style: dotted;
  text-underline-offset: 2px;
  transition: var(--transition);
}

.stock-clickable-cell:hover {
  color: var(--green) !important;
  background: var(--green-light) !important;
}

/* ========== 库存页面 - 分页控件 ========== */
.stock-pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 18px;
  border-top: 1px solid var(--border-light);
  background: var(--bg-input);
}

.pagination-info {
  font-size: 12px;
  color: var(--text-muted);
  font-family: 'Source Code Pro', monospace;
}

.pagination-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-page {
  min-width: 64px;
  padding: 5px 12px;
  font-size: 12px;
}

.btn-page:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  pointer-events: none;
}

.pagination-goto {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-secondary);
  margin-left: 8px;
}

@media (max-width: 768px) {
  .stock-pagination {
    flex-direction: column;
    gap: 10px;
    align-items: stretch;
  }

  .pagination-controls {
    flex-wrap: wrap;
    justify-content: center;
  }
}

/* ========== 库存详情页样式 ========== */

/* 可点击的表格行 */
.stock-row-clickable {
  cursor: pointer;
  transition: background-color 0.15s ease;
}

.stock-row-clickable:hover {
  background-color: #f0f7ff !important;
}

.stock-row-clickable:hover td {
  color: var(--text-primary);
}

/* 返回按钮栏 */
.detail-top-bar {
  display: flex;
  align-items: center;
  margin-bottom: 16px;
}

.detail-back-btn {
  font-size: 13px;
  padding: 6px 16px;
  border-radius: var(--radius-sm);
  transition: all 0.2s ease;
}

.detail-back-btn:hover {
  background-color: var(--green);
  color: #fff;
  border-color: var(--green);
}

/* 商品信息头部 */
.detail-header-info {
  background: #fff;
  border-radius: var(--radius-md);
  padding: 20px 24px;
  margin-bottom: 16px;
  border: 1px solid var(--border);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.detail-header-grid {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 24px;
}

.detail-header-main {
  flex: 1;
  min-width: 0;
}

.detail-product-name {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0 0 10px 0;
  line-height: 1.3;
}

.detail-header-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
}

.detail-tag {
  display: inline-block;
  padding: 2px 10px;
  background: #f1f5f9;
  border-radius: 4px;
  font-size: 12px;
  color: var(--text-secondary);
  white-space: nowrap;
}

.detail-tag-brand {
  background: #ecfdf5;
  color: #059669;
}

.detail-tag-muted {
  color: #94a3b8;
  font-style: italic;
}

.detail-category-path {
  font-size: 13px;
  color: var(--text-muted);
  margin: 0;
}

.detail-header-stats {
  display: flex;
  gap: 24px;
  flex-shrink: 0;
}

.detail-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.detail-stat-label {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
}

.detail-stat-value {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
  white-space: nowrap;
}

.detail-loading-text {
  color: var(--text-muted);
  font-size: 14px;
}

/* Tab 栏 */
.detail-tab-bar {
  display: flex;
  gap: 4px;
  background: #fff;
  border-radius: var(--radius-md) var(--radius-md) 0 0;
  padding: 8px 8px 0;
  border: 1px solid var(--border);
  border-bottom: none;
  overflow-x: auto;
}

.detail-tab {
  padding: 10px 18px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  background: transparent;
  border: 1px solid transparent;
  border-bottom: none;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s ease;
}

.detail-tab:hover {
  color: var(--green);
  background: #f8faf8;
}

.detail-tab.active {
  color: var(--green);
  background: #f0fdf4;
  border-color: var(--border);
  font-weight: 600;
  position: relative;
}

.detail-tab.active::after {
  content: '';
  position: absolute;
  bottom: -1px;
  left: 0;
  right: 0;
  height: 2px;
  background: #fff;
}

/* Tab 内容区 */
.detail-tab-content {
  background: #fff;
  border: 1px solid var(--border);
  border-top: none;
  border-radius: 0 0 var(--radius-md) var(--radius-md);
  padding: 20px 24px;
  min-height: 200px;
}

/* 加载/空/错误状态 */
.detail-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  gap: 12px;
  color: var(--text-muted);
}

.detail-empty,
.detail-error {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
  font-size: 14px;
}

.detail-error {
  color: var(--red);
}

/* 指标卡片行 */
.detail-metrics {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}

.detail-metric-card {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  text-align: center;
  transition: all 0.2s ease;
}

.detail-metric-card:hover {
  border-color: var(--green);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.detail-metric-label {
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.detail-metric-value {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-primary);
}

.detail-metric-card.detail-metric-success .detail-metric-value {
  color: var(--green);
}

.detail-metric-card.detail-metric-warning .detail-metric-value {
  color: #d97706;
}

.detail-metric-card.detail-metric-info .detail-metric-value {
  color: #2563eb;
}

/* 区块 */
.detail-section {
  margin-bottom: 20px;
}

.detail-section:last-child {
  margin-bottom: 0;
}

.detail-section-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid #e2e8f0;
}

/* 信息网格 */
.detail-info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 10px 24px;
}

.detail-info-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 0;
  border-bottom: 1px dashed #f1f5f9;
}

.detail-info-label {
  font-size: 13px;
  color: var(--text-muted);
  white-space: nowrap;
}

.detail-info-value {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
  text-align: right;
}

/* 分店明细表格 */
.detail-table {
  font-size: 13px;
  table-layout: auto;
}

.detail-table th {
  padding: 8px 12px;
  font-size: 12px;
  white-space: nowrap;
  text-align: right;
}

.detail-table th:first-child {
  text-align: center;
}

.detail-table th:nth-child(2),
.detail-table th:nth-child(3),
.detail-table th:nth-child(4),
.detail-table th:nth-child(6),
.detail-table th:nth-child(9) {
  text-align: left;
}

.detail-table td {
  padding: 8px 12px;
  white-space: nowrap;
  text-align: right;
}

.detail-table td:first-child {
  text-align: center;
}

.detail-summary-row {
  background: #f8fafc;
  font-weight: 600;
}

.detail-summary-row td {
  border-top: 2px solid var(--border);
}

/* 周销柱状条 */
.detail-week-chart {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.detail-bar-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.detail-bar-label {
  font-size: 13px;
  color: var(--text-secondary);
  width: 48px;
  flex-shrink: 0;
}

.detail-bar-track {
  flex: 1;
  height: 20px;
  background: #f1f5f9;
  border-radius: 4px;
  overflow: hidden;
}

.detail-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--green), #34d399);
  border-radius: 4px;
  transition: width 0.5s ease;
  min-width: 2px;
}

.detail-bar-value {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  width: 48px;
  text-align: right;
  flex-shrink: 0;
}

/* 提示文字 */
.detail-note {
  font-size: 12px;
  color: var(--text-muted);
  margin: 0 0 8px;
  font-style: italic;
}

/* 详情页响应式 */
@media (max-width: 768px) {
  .detail-header-grid {
    flex-direction: column;
    gap: 16px;
  }

  .detail-header-stats {
    flex-wrap: wrap;
    gap: 16px;
  }

  .detail-metrics {
    grid-template-columns: repeat(2, 1fr);
  }

  .detail-info-grid {
    grid-template-columns: 1fr;
  }

  .detail-tab {
    padding: 8px 12px;
    font-size: 12px;
  }
}
