/* ============================================================
   A股选股工具 - 全局样式
   深色主题 / 涨红跌绿 / 专业金融风格
   ============================================================ */

/* ========== 变量定义 ========== */
:root {
  /* 背景色 */
  --bg-primary: #0f1419;
  --bg-secondary: #1a1f2e;
  --bg-card: #1e2433;
  --bg-card-hover: #252d40;
  --bg-input: #252d40;
  --bg-modal: rgba(0, 0, 0, 0.8);

  /* 文字色 */
  --text-primary: #e6e9ef;
  --text-secondary: #8b95a7;
  --text-tertiary: #5c6678;
  --text-white: #ffffff;

  /* 主题色 */
  --primary: #f5a623;
  --primary-hover: #ffb73d;
  --accent: #00d4aa;

  /* 涨跌色 (A股习惯: 涨红跌绿) */
  --up-color: #ff4d4f;
  --up-bg: rgba(255, 77, 79, 0.12);
  --down-color: #00c853;
  --down-bg: rgba(0, 200, 83, 0.12);
  --flat-color: #8b95a7;

  /* 边框色 */
  --border-color: #2d3748;
  --border-light: #374151;

  /* 渐变色 */
  --gradient-gold: linear-gradient(135deg, #f5a623 0%, #ff7e3d 100%);
  --gradient-red: linear-gradient(135deg, #ff4d4f 0%, #ff7875 100%);
  --gradient-green: linear-gradient(135deg, #00c853 0%, #52c41a 100%);
  --gradient-blue: linear-gradient(135deg, #1890ff 0%, #096dd9 100%);

  /* 阴影 */
  --shadow-card: 0 4px 20px rgba(0, 0, 0, 0.3);
  --shadow-hover: 0 8px 30px rgba(0, 0, 0, 0.4);
  --shadow-glow: 0 0 20px rgba(245, 166, 35, 0.3);

  /* 圆角 */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;

  /* 间距 */
  --gap-xs: 6px;
  --gap-sm: 12px;
  --gap-md: 16px;
  --gap-lg: 24px;
  --gap-xl: 32px;

  /* 过渡 */
  --transition: all 0.2s ease;
}

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

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

a {
  color: inherit;
  text-decoration: none;
}

ul, ol {
  list-style: none;
}

button {
  border: none;
  background: none;
  cursor: pointer;
  font-family: inherit;
  color: inherit;
}

input, select {
  border: none;
  outline: none;
  font-family: inherit;
  background: transparent;
  color: inherit;
}

/* 数字等宽字体 */
.number-font {
  font-family: 'SF Mono', 'Monaco', 'Inconsolata', 'Roboto Mono',
               'Consolas', 'Liberation Mono', 'Courier New', monospace;
  font-variant-numeric: tabular-nums;
}

/* ========== 颜色工具类 ========== */
.up { color: var(--up-color) !important; }
.down { color: var(--down-color) !important; }
.flat { color: var(--flat-color) !important; }
.up-bg { background: var(--up-bg) !important; }
.down-bg { background: var(--down-bg) !important; }
.primary { color: var(--primary) !important; }
.text-secondary { color: var(--text-secondary) !important; }
.text-tertiary { color: var(--text-tertiary) !important; }

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

/* 侧边栏 */
.sidebar {
  width: 220px;
  background: var(--bg-secondary);
  border-right: 1px solid var(--border-color);
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 100;
  display: flex;
  flex-direction: column;
  transition: var(--transition);
}

.sidebar-logo {
  padding: 20px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid var(--border-color);
}

.sidebar-logo-icon {
  width: 36px;
  height: 36px;
  background: var(--gradient-gold);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  font-weight: bold;
  color: #1a1f2e;
}

.sidebar-logo-text {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
}

.sidebar-logo-text span {
  color: var(--primary);
}

.sidebar-nav {
  flex: 1;
  padding: 12px 8px;
  overflow-y: auto;
}

.nav-section-title {
  padding: 12px 12px 8px;
  font-size: 12px;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  cursor: pointer;
  transition: var(--transition);
  margin-bottom: 2px;
}

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

.nav-item.active {
  background: var(--gradient-gold);
  color: #1a1f2e;
  font-weight: 600;
}

.nav-item-icon {
  font-size: 18px;
  width: 24px;
  text-align: center;
}

.nav-item-text {
  flex: 1;
}

.nav-item-badge {
  background: var(--up-color);
  color: white;
  font-size: 11px;
  padding: 2px 6px;
  border-radius: 10px;
}

/* 主内容区 */
.main-content {
  flex: 1;
  margin-left: 220px;
  padding: 0;
}

/* 顶部导航栏 */
.topbar {
  height: 60px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 50;
}

.topbar-left {
  display: none;
  align-items: center;
  gap: 12px;
}

.topbar-title {
  font-size: 18px;
  font-weight: 600;
}

.topbar-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 16px;
}

/* 搜索框 */
.search-box {
  position: relative;
  width: 280px;
}

.search-box input {
  width: 100%;
  height: 38px;
  padding: 0 16px 0 40px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: 20px;
  color: var(--text-primary);
  font-size: 14px;
  transition: var(--transition);
}

.search-box input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(245, 166, 35, 0.15);
}

.search-box-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-tertiary);
  font-size: 16px;
}

.search-results {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  margin-top: 4px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-card);
  max-height: 400px;
  overflow-y: auto;
  z-index: 200;
  display: none;
}

.search-results.show {
  display: block;
}

.search-result-item {
  display: flex;
  align-items: center;
  padding: 10px 16px;
  cursor: pointer;
  transition: var(--transition);
  border-bottom: 1px solid var(--border-color);
}

.search-result-item:last-child {
  border-bottom: none;
}

.search-result-item:hover {
  background: var(--bg-card-hover);
}

.search-result-code {
  width: 80px;
  color: var(--text-secondary);
  font-size: 13px;
}

.search-result-name {
  flex: 1;
  font-weight: 500;
}

.search-result-industry {
  color: var(--text-tertiary);
  font-size: 12px;
}

/* 页面内容 */
.page-content {
  padding: 24px;
}

.page-header {
  margin-bottom: 24px;
}

.page-title {
  font-size: 22px;
  font-weight: 600;
  margin-bottom: 6px;
}

.page-subtitle {
  color: var(--text-secondary);
  font-size: 14px;
}

/* ========== 卡片 ========== */
.card {
  background: var(--bg-card);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-card);
  transition: var(--transition);
}

.card:hover {
  box-shadow: var(--shadow-hover);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-color);
}

.card-title {
  font-size: 16px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
}

.card-title-icon {
  font-size: 18px;
}

.card-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.card-body {
  padding: 20px;
}

.card-footer {
  padding: 12px 20px;
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: center;
}

/* ========== 按钮 ========== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  transition: var(--transition);
  cursor: pointer;
  white-space: nowrap;
}

.btn-primary {
  background: var(--gradient-gold);
  color: #1a1f2e;
}

.btn-primary:hover {
  box-shadow: var(--shadow-glow);
  transform: translateY(-1px);
}

.btn-secondary {
  background: var(--bg-input);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
}

.btn-secondary:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-light);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
}

.btn-ghost:hover {
  background: var(--bg-input);
  color: var(--text-primary);
}

.btn-sm {
  padding: 4px 10px;
  font-size: 12px;
}

.btn-lg {
  padding: 12px 24px;
  font-size: 15px;
}

/* ========== 标签 ========== */
.tag {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 500;
}

.tag-up {
  background: var(--up-bg);
  color: var(--up-color);
}

.tag-down {
  background: var(--down-bg);
  color: var(--down-color);
}

.tag-primary {
  background: rgba(245, 166, 35, 0.15);
  color: var(--primary);
}

.tag-info {
  background: rgba(24, 144, 255, 0.15);
  color: #1890ff;
}

.tag-success {
  background: var(--down-bg);
  color: var(--down-color);
}

.tag-warning {
  background: rgba(250, 173, 20, 0.15);
  color: #faad14;
}

/* ========== 表格 ========== */
.data-table {
  width: 100%;
  border-collapse: collapse;
}

.data-table th {
  text-align: left;
  padding: 12px 16px;
  font-weight: 500;
  color: var(--text-secondary);
  font-size: 13px;
  border-bottom: 1px solid var(--border-color);
  background: rgba(255, 255, 255, 0.02);
  white-space: nowrap;
}

.data-table td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-color);
  white-space: nowrap;
}

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

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

.data-table tbody tr:last-child td {
  border-bottom: none;
}

.sortable-th {
  cursor: pointer;
  user-select: none;
}

.sortable-th:hover {
  color: var(--text-primary);
}

.sort-icon {
  display: inline-block;
  margin-left: 4px;
  font-size: 10px;
}

/* ========== Grid 网格 ========== */
.grid {
  display: grid;
  gap: 20px;
}

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

.grid-3 {
  grid-template-columns: repeat(3, 1fr);
}

.grid-4 {
  grid-template-columns: repeat(4, 1fr);
}

.grid-5 {
  grid-template-columns: repeat(5, 1fr);
}

/* ========== 加载骨架屏 ========== */
.skeleton {
  background: linear-gradient(
    90deg,
    var(--bg-card) 25%,
    var(--bg-card-hover) 50%,
    var(--bg-card) 75%
  );
  background-size: 200% 100%;
  animation: skeleton-loading 1.5s infinite;
  border-radius: 4px;
}

@keyframes skeleton-loading {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.skeleton-line {
  height: 14px;
  margin-bottom: 10px;
}

.skeleton-line.short {
  width: 60%;
}

/* ========== 数字滚动动画 ========== */
.count-up {
  display: inline-block;
}

/* ========== 脉冲动画 ========== */
@keyframes pulse-dot {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

.pulse-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  background: var(--down-color);
  border-radius: 50%;
  animation: pulse-dot 1.5s ease-in-out infinite;
}

.pulse-dot.up {
  background: var(--up-color);
}

/* ========== Tab 切换 ========== */
.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--border-color);
  margin-bottom: 20px;
}

.tab-item {
  padding: 12px 20px;
  color: var(--text-secondary);
  cursor: pointer;
  position: relative;
  transition: var(--transition);
  font-size: 14px;
}

.tab-item:hover {
  color: var(--text-primary);
}

.tab-item.active {
  color: var(--primary);
  font-weight: 500;
}

.tab-item.active::after {
  content: '';
  position: absolute;
  bottom: -1px;
  left: 20px;
  right: 20px;
  height: 2px;
  background: var(--gradient-gold);
  border-radius: 1px;
}

/* 小型tab */
.tabs-sm {
  display: inline-flex;
  padding: 3px;
  background: var(--bg-input);
  border-radius: 8px;
  border: 1px solid var(--border-color);
}

.tabs-sm .tab-item {
  padding: 6px 14px;
  border-radius: 6px;
  font-size: 13px;
}

.tabs-sm .tab-item.active {
  background: var(--bg-card);
  color: var(--primary);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

.tabs-sm .tab-item.active::after {
  display: none;
}

/* ========== 进度条 ========== */
.progress-bar {
  height: 6px;
  background: var(--bg-input);
  border-radius: 3px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.6s ease;
}

.progress-fill.up {
  background: var(--gradient-red);
}

.progress-fill.down {
  background: var(--gradient-green);
}

.progress-fill.primary {
  background: var(--gradient-gold);
}

/* ========== 评分胶囊 ========== */
.score-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 22px;
  border-radius: 11px;
  font-size: 12px;
  font-weight: 600;
  background: var(--gradient-gold);
  color: #1a1f2e;
}

.score-badge.high {
  background: var(--gradient-red);
  color: white;
}

.score-badge.medium {
  background: var(--gradient-gold);
}

.score-badge.low {
  background: linear-gradient(135deg, #8b95a7 0%, #5c6678 100%);
  color: white;
}

/* ========== 下拉选择 ========== */
.select-input {
  padding: 8px 30px 8px 12px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 13px;
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%238b95a7' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
}

.select-input:focus {
  border-color: var(--primary);
}

/* ========== 输入框 ========== */
.text-input {
  padding: 8px 12px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 13px;
}

.text-input:focus {
  border-color: var(--primary);
}

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

/* ========== 分割线 ========== */
.divider {
  height: 1px;
  background: var(--border-color);
  margin: 16px 0;
}

.divider-vertical {
  width: 1px;
  background: var(--border-color);
  margin: 0 16px;
}

/* ========== 弹窗 ========== */
.modal-mask {
  position: fixed;
  inset: 0;
  background: var(--bg-modal);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  backdrop-filter: blur(4px);
}

.modal-mask.show {
  display: flex;
}

.modal {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-color);
  width: 90%;
  max-width: 500px;
  max-height: 80vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  animation: modal-in 0.25s ease;
}

@keyframes modal-in {
  from {
    opacity: 0;
    transform: translateY(20px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.modal-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-title {
  font-size: 18px;
  font-weight: 600;
}

.modal-close {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: var(--transition);
}

.modal-close:hover {
  background: var(--bg-input);
  color: var(--text-primary);
}

.modal-body {
  padding: 24px;
  overflow-y: auto;
  flex: 1;
  line-height: 1.8;
  color: var(--text-secondary);
}

.modal-body h4 {
  color: var(--text-primary);
  margin-bottom: 8px;
  margin-top: 16px;
}

.modal-body h4:first-child {
  margin-top: 0;
}

.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: flex-end;
  gap: 12px;
}

/* ========== 空状态 ========== */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-tertiary);
}

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

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

/* ========== 底部Tab(移动端) ========== */
.mobile-tabbar {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 60px;
  background: var(--bg-secondary);
  border-top: 1px solid var(--border-color);
  z-index: 100;
  padding-bottom: env(safe-area-inset-bottom);
}

.mobile-tabbar-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  color: var(--text-tertiary);
  cursor: pointer;
  transition: var(--transition);
}

.mobile-tabbar-item.active {
  color: var(--primary);
}

.mobile-tabbar-icon {
  font-size: 22px;
}

.mobile-tabbar-label {
  font-size: 10px;
}

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

@media (max-width: 900px) {
  .sidebar {
    transform: translateX(-100%);
  }
  .sidebar.show {
    transform: translateX(0);
  }
  .main-content {
    margin-left: 0;
  }
  .topbar-left {
    display: flex;
  }
  .search-box {
    width: 200px;
  }
  .grid-3 { grid-template-columns: repeat(2, 1fr); }
  .page-content {
    padding: 16px;
    padding-bottom: 80px;
  }
  .mobile-tabbar {
    display: flex;
  }
}

@media (max-width: 600px) {
  .grid-2, .grid-3, .grid-4, .grid-5 {
    grid-template-columns: 1fr;
  }
  .page-title { font-size: 18px; }
  .search-box {
    display: none;
  }
  .topbar {
    padding: 0 16px;
  }
}

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

::-webkit-scrollbar-track {
  background: var(--bg-primary);
}

::-webkit-scrollbar-thumb {
  background: var(--border-light);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-tertiary);
}

/* ========== 涨跌色块 ========== */
.price-cell {
  font-weight: 600;
  font-family: 'SF Mono', 'Monaco', 'Consolas', monospace;
}
