/* ===== 基础重置 ===== */
* { margin:0; padding:0; box-sizing:border-box; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
  background: #f0f2f5;
  color: #333;
  font-size: 14px;
  line-height: 1.5;
}

/* ===== 页面 ===== */
.page { display: none; min-height: 100vh; }
.page.active { display: flex; }

/* ===== 登录页 ===== */
#login-page {
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #1677ff 0%, #0958d9 100%);
}
.login-container {
  background: #fff;
  padding: 40px;
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
  width: 400px;
  max-width: 90%;
}
.login-header { text-align: center; margin-bottom: 30px; }
.login-header h1 { font-size: 24px; color: #1677ff; margin-bottom: 8px; }
.login-header p { color: #999; font-size: 14px; }
.login-footer { text-align: center; margin-top: 20px; color: #999; font-size: 12px; }

/* ===== 主应用布局 ===== */
#app-page { flex-direction: row; }
.sidebar {
  width: 220px;
  background: #fff;
  color: #333;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  border-right: 1px solid #e8e8e8;
}
.sidebar-header {
  padding: 20px;
  border-bottom: 1px solid #f0f0f0;
}
.sidebar-header h2 { font-size: 16px; font-weight: 600; color: #1677ff; }
.sidebar-nav { flex: 1; padding: 10px 0; }
.nav-item {
  display: flex;
  align-items: center;
  padding: 12px 20px;
  color: #555;
  text-decoration: none;
  transition: all 0.2s;
  cursor: pointer;
  border: none;
  background: none;
  width: 100%;
  font-size: 14px;
}
.nav-item:hover { background: #f5f5f5; color: #1677ff; }
.nav-item.active { background: #e6f4ff; color: #1677ff; font-weight: 600; }
.nav-icon { font-size: 18px; margin-right: 12px; width: 24px; text-align: center; }
.sidebar-footer { padding: 15px; border-top: 1px solid #f0f0f0; color: #888; font-size: 12px; }

/* ===== 主内容区 ===== */
.main-content { flex: 1; padding: 24px; overflow-y: auto; max-height: 100vh; }
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
}
.page-header h1 { font-size: 22px; font-weight: 600; color: #1f1f1f; }
.page-actions { display: flex; gap: 10px; }

/* ===== 统计卡片 ===== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.stat-card {
  background: #fff;
  border-radius: 12px;
  padding: 20px;
  display: flex;
  align-items: center;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}
.stat-icon { font-size: 36px; margin-right: 16px; }
.stat-info h3 { font-size: 28px; font-weight: 700; color: #1f1f1f; }
.stat-info p { color: #888; font-size: 13px; margin-top: 4px; }

/* ===== 图表 ===== */
.chart-container {
  background: #fff;
  border-radius: 12px;
  padding: 20px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}

/* ===== 搜索栏 ===== */
.search-bar { margin-bottom: 16px; }
.search-bar input {
  width: 300px;
  padding: 10px 14px;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s;
}
.search-bar input:focus { border-color: #1677ff; }

/* ===== 表格 ===== */
.table-container {
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
  overflow: hidden;
}
table { width: 100%; border-collapse: collapse; }
th, td { padding: 12px 16px; text-align: left; }
th {
  background: #f8f9fa;
  font-weight: 600;
  color: #666;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
tr { border-bottom: 1px solid #f0f0f0; }
tr:hover { background: #fafafa; }
tbody tr:last-child { border-bottom: none; }

/* ===== 按钮 ===== */
.btn {
  padding: 8px 16px;
  border: none;
  border-radius: 6px;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.btn:hover { transform: translateY(-1px); box-shadow: 0 4px 12px rgba(0,0,0,0.15); }
.btn:active { transform: translateY(0); }
.btn-primary { background: #1677ff; color: #fff; }
.btn-primary:hover { background: #0958d9; }
.btn-secondary { background: #f0f0f0; color: #555; }
.btn-secondary:hover { background: #e0e0e0; }
.btn-danger { background: #ef4444; color: #fff; }
.btn-danger:hover { background: #dc2626; }
.btn-success { background: #10b981; color: #fff; }
.btn-success:hover { background: #059669; }
.btn-info { background: #3b82f6; color: #fff; }
.btn-info:hover { background: #2563eb; }
.btn-warning { background: #f59e0b; color: #fff; }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-block { width: 100%; padding: 12px; font-size: 16px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

/* ===== 表单 ===== */
.form-group { margin-bottom: 16px; }
.form-group label {
  display: block;
  margin-bottom: 6px;
  font-weight: 500;
  color: #555;
  font-size: 13px;
}
.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  font-size: 14px;
  outline: none;
  font-family: inherit;
  transition: border-color 0.2s;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus { border-color: #667eea; }
.error-message {
  color: #ef4444;
  font-size: 13px;
  margin-top: 8px;
  display: none;
}

/* ===== 弹窗 ===== */
.modal {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.5);
  z-index: 1000;
  align-items: center;
  justify-content: center;
}
.modal.active { display: flex; }
.modal-content {
  background: #fff;
  border-radius: 16px;
  width: 500px;
  max-width: 90%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
  animation: modalSlideIn 0.3s ease;
}
@keyframes modalSlideIn {
  from { opacity: 0; transform: translateY(-30px); }
  to { opacity: 1; transform: translateY(0); }
}
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 24px;
  border-bottom: 1px solid #f0f0f0;
}
.modal-header h2 { font-size: 18px; font-weight: 600; }
.modal-close {
  font-size: 24px;
  cursor: pointer;
  color: #999;
  line-height: 1;
}
.modal-close:hover { color: #333; }
.modal form { padding: 24px; }
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 8px;
}

/* ===== 导入导出 ===== */
.import-section, .export-section, .settings-section {
  display: grid;
  gap: 16px;
}
.import-card, .settings-card {
  background: #fff;
  border-radius: 12px;
  padding: 24px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}
.import-card h3, .settings-card h3 { margin-bottom: 8px; font-size: 16px; }
.import-card p, .settings-card p { color: #888; margin-bottom: 16px; font-size: 13px; }
.import-card input[type="file"] { display: none; }
.import-card input[type="text"] {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  margin-bottom: 12px;
  font-size: 14px;
}

/* ===== 树形图 ===== */
.tree-container {
  background: #fff;
  border-radius: 12px;
  padding: 24px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
  min-height: 400px;
}
.tree-node {
  margin-left: 24px;
  border-left: 2px solid #e0e0e0;
  padding-left: 16px;
  margin-top: 8px;
}
.tree-root { margin-left: 0; border-left: none; padding-left: 0; }
.tree-card {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: #fff;
  border-radius: 10px;
  font-weight: 500;
  cursor: pointer;
  transition: transform 0.2s;
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}
.tree-card:hover { transform: scale(1.02); }
.tree-avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: rgba(255,255,255,0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
}
.tree-info { display: flex; flex-direction: column; }
.tree-name { font-weight: 600; }
.tree-meta { font-size: 12px; opacity: 0.8; margin-top: 2px; }
.tree-toggle {
  margin-left: auto;
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  transition: background 0.2s;
}
.tree-toggle:hover { background: rgba(255,255,255,0.2); }
.tree-children { margin-top: 8px; }
.tree-children.collapsed { display: none; }
.tree-empty {
  text-align: center;
  color: #999;
  padding: 60px 20px;
  font-size: 15px;
}
.tree-empty-icon { font-size: 48px; margin-bottom: 16px; }

/* ===== 用户管理 ===== */
.user-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 500;
}
.badge-admin { background: #fef3c7; color: #92400e; }
.badge-user { background: #dbeafe; color: #1e40af; }
.badge-active { background: #d1fae5; color: #065f46; }
.badge-inactive { background: #fee2e2; color: #991b1b; }

/* ===== 加载状态 ===== */
.loading-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(255,255,255,0.8);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 2000;
}
.loading-overlay.active { display: flex; }
.spinner {
  width: 40px; height: 40px;
  border: 3px solid #e0e0e0;
  border-top-color: #667eea;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== Toast ===== */
.toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 3000;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.toast {
  padding: 12px 20px;
  border-radius: 8px;
  color: #fff;
  font-size: 14px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  animation: toastSlideIn 0.3s ease;
  max-width: 350px;
}
.toast-success { background: #10b981; }
.toast-error { background: #ef4444; }
.toast-warning { background: #f59e0b; }
.toast-info { background: #3b82f6; }
@keyframes toastSlideIn {
  from { opacity: 0; transform: translateX(100px); }
  to { opacity: 1; transform: translateX(0); }
}

/* ===== 分页 ===== */
.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  padding: 16px;
}
.pagination button {
  padding: 6px 12px;
  border: 1px solid #e0e0e0;
  background: #fff;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
}
.pagination button:hover { background: #f0f0f0; }
.pagination button.active { background: #667eea; color: #fff; border-color: #667eea; }
.pagination button:disabled { opacity: 0.5; cursor: not-allowed; }

/* ===== 响应式 ===== */
@media (max-width: 768px) {
  .sidebar { width: 60px; }
  .sidebar-header h2, .nav-item span:not(.nav-icon) { display: none; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ===== 内容页切换 ===== */
.content-page { display: none; }
.content-page.active { display: block; }

/* ===== 推荐关系树 - 方案B：缩进色块式 ===== */
.tree-indent { font-size: 13px; }
.tree-indent .ti-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 12px;
  border-radius: 6px;
  transition: background 0.15s;
}
.tree-indent .ti-row:hover { background: #f1f5f9; }

.tree-indent .ti-row .color-bar {
  width: 4px;
  border-radius: 2px;
  flex-shrink: 0;
  height: 22px;
}

.tree-indent .ti-row .node-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  border-radius: 6px;
  background: #fff;
  border: 1px solid #e2e8f0;
  font-size: 13px;
  cursor: default;
  position: relative;
  transition: all 0.2s;
}
.tree-indent .ti-row .node-tag:hover {
  border-color: #3b82f6;
  background: #eff6ff;
  box-shadow: 0 2px 8px rgba(59,130,246,0.10);
}

/* 悬停浮层 */
.tree-indent .ti-row .node-tag .ttip {
  display: none;
  position: absolute;
  left: 50%;
  bottom: calc(100% + 8px);
  transform: translateX(-50%);
  background: #1e293b;
  color: #fff;
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 12px;
  line-height: 1.8;
  white-space: nowrap;
  z-index: 200;
  box-shadow: 0 4px 12px rgba(0,0,0,0.18);
  pointer-events: none;
}
.tree-indent .ti-row .node-tag .ttip::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 5px solid transparent;
  border-top-color: #1e293b;
}
.tree-indent .ti-row .node-tag:hover .ttip { display: block; }

/* 节点ID（悬停时名字在浮层中显示） */
.tree-indent .ti-row .ti-id {
  font-weight: 700;
  font-size: 13px;
  margin-left: 6px;
  color: #1f1f1f;
}

/* 层级标签 */
.tree-indent .ti-row .level-label {
  font-size: 11px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 4px;
  color: #fff;
  flex-shrink: 0;
}

/* 计数徽章 */
.tree-indent .ti-badge {
  font-size: 11px;
  padding: 1px 6px;
  border-radius: 4px;
  font-weight: 600;
}
.tree-indent .ti-badge.blue  { background: #dbeafe; color: #1d4ed8; }
.tree-indent .ti-badge.gray  { background: #f1f5f9; color: #475569; }

/* 展开/折叠按钮 */
.tree-indent .ti-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: bold;
  cursor: pointer;
  user-select: none;
  transition: all 0.15s;
  flex-shrink: 0;
}
.tree-indent .ti-toggle:hover { background: #e0e7ff; color: #3b82f6; }

/* 子节点容器（缩进） */
.tree-indent .ti-children {
  margin-left: 0;
  /* 缩进通过 ti-row 的 spacer 实现 */
}

/* ========== 表格斑马纹 ========== */
/* 会员管理、团队统计 表格行交替颜色 */
.data-table tbody tr:nth-child(odd) {
  background-color: #ffffff;
}
.data-table tbody tr:nth-child(even) {
  background-color: #f8fafc;
}
.data-table tbody tr:hover {
  background-color: #e0e7ff !important;
  transition: background-color 0.15s;
}
