/* 全局样式 - 左侧导航布局 */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: "Microsoft YaHei", sans-serif;
  font-size: 14px;
  color: #333;
  background: #f5f5f5;
}

/* 布局容器 */
.app-container {
  display: flex;
  height: 100vh;
}

/* 左侧导航栏 */
.sidebar {
  width: 200px;
  background: #2c3e50;
  color: #ecf0f1;
  display: flex;
  flex-direction: column;
  box-shadow: 2px 0 8px rgba(0,0,0,0.1);
}

.sidebar-header {
  padding: 20px;
  background: #1a252f;
  border-bottom: 1px solid #34495e;
}

.sidebar-header h1 {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 5px;
}

.sidebar-header .subtitle {
  font-size: 12px;
  color: #95a5a6;
}

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

.nav-item {
  display: flex;
  align-items: center;
  padding: 12px 20px;
  color: #ecf0f1;
  text-decoration: none;
  transition: background 0.2s;
  cursor: pointer;
}

.nav-item:hover {
  background: #34495e;
}

.nav-item.active {
  background: #3498db;
  border-left: 3px solid #2980b9;
}

.nav-item-icon {
  width: 20px;
  margin-right: 10px;
  font-size: 16px;
}

/* 主内容区 */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* 顶部栏 */
.topbar {
  height: 60px;
  background: #fff;
  border-bottom: 1px solid #e0e0e0;
  display: flex;
  align-items: center;
  padding: 0 30px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.topbar h2 {
  font-size: 20px;
  font-weight: 500;
}

.topbar-actions {
  margin-left: auto;
  display: flex;
  gap: 10px;
}

/* 内容区域 */
.content {
  flex: 1;
  overflow-y: auto;
  padding: 20px 30px;
}

/* 卡片容器 */
.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 20px;
  margin-bottom: 20px;
}

.metric-card {
  background: #fff;
  border-radius: 8px;
  padding: 20px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
  transition: transform 0.2s, box-shadow 0.2s;
}

.metric-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.12);
}

.metric-card .label {
  font-size: 13px;
  color: #777;
  margin-bottom: 8px;
}

.metric-card .value {
  font-size: 28px;
  font-weight: 600;
  color: #2c3e50;
}

.metric-card .change {
  font-size: 12px;
  margin-top: 5px;
}

.metric-card .change.positive {
  color: #27ae60;
}

.metric-card .change.negative {
  color: #e74c3c;
}

/* 表格样式 */
.data-table-container {
  background: #fff;
  border-radius: 8px;
  padding: 20px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
  margin-bottom: 20px;
}

.data-table-container h3 {
  font-size: 16px;
  margin-bottom: 15px;
  font-weight: 500;
}

table {
  width: 100%;
  border-collapse: collapse;
}

table thead {
  background: #f8f9fa;
}

table th {
  padding: 12px;
  text-align: left;
  font-weight: 500;
  color: #555;
  border-bottom: 2px solid #e0e0e0;
}

table td {
  padding: 12px;
  border-bottom: 1px solid #f0f0f0;
}

table tbody tr:hover {
  background: #f8f9fa;
}

/* 按钮 */
.btn {
  padding: 8px 16px;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.btn-primary {
  background: #3498db;
  color: #fff;
}

.btn-primary:hover {
  background: #2980b9;
}

.btn-success {
  background: #27ae60;
  color: #fff;
}

.btn-success:hover {
  background: #229954;
}

.btn-secondary {
  background: #95a5a6;
  color: #fff;
}

.btn-secondary:hover {
  background: #7f8c8d;
}

/* 表单 */
.form-group {
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  margin-bottom: 8px;
  font-weight: 500;
  color: #555;
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 10px;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 14px;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: #3498db;
}

/* 配置面板 */
.config-section {
  background: #fff;
  border-radius: 8px;
  padding: 20px;
  margin-bottom: 20px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

.config-section h3 {
  font-size: 16px;
  margin-bottom: 15px;
  font-weight: 500;
  color: #2c3e50;
  border-bottom: 2px solid #3498db;
  padding-bottom: 10px;
}

.config-actions {
  display: flex;
  gap: 10px;
  margin-top: 15px;
}

/* 隐藏类 */
.hidden {
  display: none !important;
}

/* 加载动画 */
.loading {
  text-align: center;
  padding: 40px;
  color: #999;
}

.loading::after {
  content: "加载中...";
}

/* 空状态 */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: #999;
}

.empty-state-icon {
  font-size: 48px;
  margin-bottom: 15px;
  opacity: 0.3;
}

/* 筛选器 */
.filters-bar {
  background: #fff;
  border-radius: 8px;
  padding: 20px;
  margin-bottom: 20px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
  display: flex;
  gap: 15px;
  flex-wrap: wrap;
  align-items: flex-end;
}

.filter-item {
  flex: 0 0 auto;
  min-width: 150px;
}

.filter-item label {
  display: block;
  margin-bottom: 5px;
  font-size: 13px;
  color: #666;
}

.filter-item input,
.filter-item select {
  width: 100%;
  padding: 8px;
  border: 1px solid #ddd;
  border-radius: 4px;
}

/* ===== 可展开导航 ===== */
.nav-expandable {
  position: relative;
}

.nav-caret {
  margin-left: auto;
  font-size: 11px;
  transition: transform 0.15s;
}

.nav-caret.open {
  transform: rotate(90deg);
}

.nav-submenu {
  background: #22313f;
  padding: 4px 0;
}

.nav-subitem {
  display: block;
  padding: 10px 20px 10px 50px;
  color: #bdc3c7;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.15s;
  border-left: 3px solid transparent;
}

.nav-subitem:hover {
  background: #2c3e50;
  color: #ecf0f1;
}

.nav-subitem.active {
  background: #2c3e50;
  color: #fff;
  border-left-color: #3498db;
}

.nav-subitem .sub-meta {
  font-size: 11px;
  color: #7f8c8d;
  margin-top: 2px;
}

.nav-subitem-loading {
  padding: 10px 20px 10px 50px;
  color: #7f8c8d;
  font-size: 12px;
}

/* ===== 产品页内的 tab 切换 ===== */
.product-tabs {
  display: flex;
  gap: 0;
  border-bottom: 2px solid #e0e0e0;
  margin-bottom: 20px;
  background: #fff;
  border-radius: 8px 8px 0 0;
  padding: 0 10px;
}

.product-tab {
  padding: 14px 24px;
  cursor: pointer;
  font-size: 14px;
  color: #666;
  border-bottom: 3px solid transparent;
  margin-bottom: -2px;
  transition: all 0.15s;
}

.product-tab:hover {
  color: #3498db;
}

.product-tab.active {
  color: #3498db;
  font-weight: 500;
  border-bottom-color: #3498db;
}

/* 筛选器网格：10个筛选器自动换行 */
.filters-grid {
  background: #fff;
  border-radius: 8px;
  padding: 20px;
  margin-bottom: 20px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px 15px;
  align-items: end;
}

.filters-grid .filter-item {
  min-width: 0;
}

.filters-grid .filter-actions {
  display: flex;
  gap: 8px;
  grid-column: 1 / -1;
  margin-top: 4px;
}

/* 分页控件 */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 14px 0 4px;
  border-top: 1px solid #f0f0f0;
  margin-top: 12px;
}

.pagination .btn {
  padding: 6px 16px;
  font-size: 13px;
}

.pagination .btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

/* 透视表行维度选择 chip */
.dim-chip {
  padding: 5px 13px;
  border: 1px solid #ddd;
  border-radius: 15px;
  font-size: 12px;
  cursor: pointer;
  background: #fff;
  color: #666;
  transition: all 0.15s;
  user-select: none;
}

.dim-chip:hover {
  border-color: #3498db;
  color: #3498db;
}

.dim-chip.on {
  background: #3498db;
  border-color: #3498db;
  color: #fff;
}

.dim-chip .ord {
  display: inline-block;
  margin-right: 4px;
  font-weight: 600;
  opacity: 0.85;
}

/* 字段配置表 */
.field-config-table td {
  padding: 8px 12px;
}

.field-config-table input[type="text"] {
  width: 100%;
  padding: 6px 8px;
  border: 1px solid #ddd;
  border-radius: 4px;
}

.field-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
  margin-right: 4px;
}

.badge-core { background: #eaf4fc; color: #2980b9; }
.badge-ext  { background: #f0f0f0; color: #7f8c8d; }

/* 数据入口卡片 */
.import-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
}

.import-card {
  border: 1px solid #e8e8e8;
  border-radius: 8px;
  padding: 18px;
}

.import-card h4 {
  font-size: 14px;
  margin-bottom: 6px;
  color: #2c3e50;
}

.import-card .hint {
  font-size: 12px;
  color: #999;
  margin-bottom: 12px;
  min-height: 32px;
}

/* ===== 产品页：左列表 + 右视图 ===== */
.products-layout {
  display: flex;
  gap: 20px;
  align-items: flex-start;
}

.products-sidebar {
  width: 220px;
  flex: 0 0 220px;
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
  overflow: hidden;
  position: sticky;
  top: 0;
}

.products-sidebar-header {
  padding: 14px 16px;
  font-weight: 500;
  color: #2c3e50;
  border-bottom: 2px solid #3498db;
}

.product-list {
  padding: 8px;
}

.product-item {
  padding: 12px 14px;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.15s;
  margin-bottom: 4px;
  border-left: 3px solid transparent;
}

.product-item:hover {
  background: #f4f8fb;
}

.product-item.active {
  background: #eaf4fc;
  border-left-color: #3498db;
}

.product-item .p-name {
  font-weight: 500;
  color: #2c3e50;
  margin-bottom: 3px;
}

.product-item .p-meta {
  font-size: 12px;
  color: #95a5a6;
}

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

/* 视图切换 tabs */
.view-tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.view-tab {
  padding: 8px 16px;
  background: #fff;
  border: 1px solid #e0e0e0;
  border-radius: 20px;
  cursor: pointer;
  font-size: 13px;
  color: #666;
  transition: all 0.15s;
}

.view-tab:hover {
  border-color: #3498db;
  color: #3498db;
}

.view-tab.active {
  background: #3498db;
  border-color: #3498db;
  color: #fff;
}

/* 表格数值列右对齐 */
#prod-table td.num,
#prod-table th.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.val-pos { color: #27ae60; }
.val-neg { color: #e74c3c; }

/* 文件上传 */
.file-upload {
  border: 2px dashed #ddd;
  border-radius: 8px;
  padding: 30px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
}

.file-upload:hover {
  border-color: #3498db;
  background: #f8f9fa;
}

.file-upload input[type="file"] {
  display: none;
}

/* 小按钮 */
.btn-sm {
  padding: 3px 10px;
  font-size: 12px;
}

/* 筛选器输入框（可搜索下拉） */
.filter-input {
  padding: 6px 10px;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 13px;
  width: 100%;
  box-sizing: border-box;
}

/* 通用弹窗 */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.45);
  z-index: 9999;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 30px;
}

.modal-dialog {
  background: #fff;
  border-radius: 8px;
  width: 95vw;
  max-width: 1100px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 8px 32px rgba(0,0,0,0.2);
}

.modal-header {
  padding: 14px 20px;
  border-bottom: 1px solid #e0e0e0;
  font-size: 16px;
  font-weight: 600;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-shrink: 0;
}

.modal-body {
  padding: 20px;
  overflow: auto;
  flex: 1;
}

/* 弹窗内指标卡片 */
.modal-body .metric-cards {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 16px;
}

.modal-body .metric-cards .metric-card {
  flex: 1;
  min-width: 110px;
  padding: 10px 12px;
  background: #f8f9fa;
  border-radius: 6px;
  text-align: center;
}

.modal-body .metric-cards .metric-card .label {
  font-size: 12px;
  color: #666;
  margin-bottom: 4px;
}

.modal-body .metric-cards .metric-card .value {
  font-size: 18px;
  font-weight: 600;
}

/* 弹窗内表格 */
.modal-body table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.modal-body table th,
.modal-body table td {
  padding: 6px 10px;
  border-bottom: 1px solid #eee;
  white-space: nowrap;
}

.modal-body table th {
  background: #f8f9fa;
  font-weight: 600;
  text-align: left;
  position: sticky;
  top: 0;
}

.modal-body table td.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* 弹窗内表单 */
.modal-body .filter-item {
  display: inline-block;
  width: 48%;
  margin-bottom: 10px;
  vertical-align: top;
  padding-right: 8px;
  box-sizing: border-box;
}

.modal-body .filter-item label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 4px;
}

.modal-body .filter-item input,
.modal-body .filter-item select {
  width: 100%;
  padding: 6px 10px;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 13px;
  box-sizing: border-box;
}
