/* ============================================
   AI量化管理系统 - 现代化样式
   ============================================ */

:root {
  --bg: #070b14;
  --surface: #0d1424;
  --card: #111d35;
  --card-hover: #152040;
  --border: #1e2d4a;
  --border-bright: #2a3f66;
  --text: #e2e8f0;
  --text-muted: #8899aa;
  --text-dim: #4a5568;
  --red: #f56565;
  --red-bg: rgba(245, 101, 101, 0.12);
  --green: #48bb78;
  --green-bg: rgba(72, 187, 120, 0.12);
  --yellow: #ecc94b;
  --yellow-bg: rgba(236, 201, 75, 0.12);
  --blue: #4299e1;
  --blue-bg: rgba(66, 153, 225, 0.12);
  --purple: #9f7aea;
  --purple-bg: rgba(159, 122, 234, 0.12);
  --cyan: #00d4ff;
  --cyan-bg: rgba(0, 212, 255, 0.12);
  --gradient-blue: linear-gradient(135deg, #4299e1, #2563eb);
  --gradient-green: linear-gradient(135deg, #48bb78, #38a169);
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 4px 20px rgba(0,0,0,0.3);
  --transition: all 0.2s ease;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 14px;
  line-height: 1.6;
  min-height: 100vh;
}

/* ===== 顶部导航 ===== */
.header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(10px);
}

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

.logo {
  width: 36px;
  height: 36px;
  background: var(--gradient-blue);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
}

.logo-text {
  font-weight: 700;
  font-size: 16px;
  letter-spacing: -0.3px;
}

.logo-sub {
  font-size: 11px;
  color: var(--text-muted);
  display: block;
  margin-top: -2px;
}

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

.live-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--green-bg);
  color: var(--green);
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
}

.live-dot {
  width: 7px;
  height: 7px;
  background: var(--green);
  border-radius: 50%;
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(0.85); }
}

.market-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--card);
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 11px;
}

.market-tag .up { color: var(--red); }
.market-tag .down { color: var(--green); }

/* ===== 导航栏 ===== */
.nav-bar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  display: flex;
  gap: 4px;
  overflow-x: auto;
  scrollbar-width: none;
}
.nav-bar::-webkit-scrollbar { display: none; }

.nav-item {
  padding: 12px 18px;
  font-size: 13px;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  transition: var(--transition);
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 6px;
}

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

.nav-item.active {
  color: var(--blue);
  background: var(--card);
  border-color: var(--border-bright);
  font-weight: 600;
}

.nav-item .icon { font-size: 15px; }

/* ===== 主内容区 ===== */
.main {
  max-width: 1400px;
  margin: 0 auto;
  padding: 20px 24px;
}

/* ===== 页面面板 ===== */
.page { display: none; }
.page.active { display: block; }

/* ===== 通用卡片 ===== */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 16px;
  overflow: hidden;
}

.card-header {
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
  font-weight: 600;
}

.card-header .sub {
  font-size: 11px;
  color: var(--text-dim);
  font-weight: 400;
}

.card-body { padding: 16px 20px; }

/* ===== KPI网格 ===== */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 16px;
}

@media (max-width: 900px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
}

.kpi-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  transition: var(--transition);
}

.kpi-card:hover {
  border-color: var(--border-bright);
  transform: translateY(-1px);
}

.kpi-label {
  font-size: 11px;
  color: var(--text-dim);
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.kpi-value {
  font-size: 24px;
  font-weight: 700;
  margin-bottom: 4px;
}

.kpi-sub {
  font-size: 11px;
  color: var(--text-muted);
}

.kpi-up { color: var(--green); }
.kpi-down { color: var(--red); }

/* ===== 表格 ===== */
.table-wrap { overflow-x: auto; }

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

th {
  text-align: left;
  padding: 10px 14px;
  font-size: 10px;
  color: var(--text-dim);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

td {
  padding: 12px 14px;
  font-size: 13px;
  border-bottom: 1px solid rgba(30, 45, 74, 0.5);
  vertical-align: middle;
}

tr:last-child td { border-bottom: none; }

tr:hover td { background: rgba(255, 255, 255, 0.02); }

.text-right { text-align: right; }
.text-center { text-align: center; }

/* ===== 涨跌标签 ===== */
.tag {
  display: inline-flex;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
}

.tag-red { background: var(--red-bg); color: var(--red); }
.tag-green { background: var(--green-bg); color: var(--green); }
.tag-yellow { background: var(--yellow-bg); color: var(--yellow); }
.tag-blue { background: var(--blue-bg); color: var(--blue); }
.tag-purple { background: var(--purple-bg); color: var(--purple); }

/* ===== 按钮 ===== */
.btn {
  padding: 7px 14px;
  border-radius: var(--radius-sm);
  border: none;
  cursor: pointer;
  font-size: 12px;
  font-weight: 500;
  transition: var(--transition);
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.btn-primary { background: var(--gradient-blue); color: white; }
.btn-primary:hover { opacity: 0.9; transform: translateY(-1px); }

.btn-success { background: var(--gradient-green); color: white; }
.btn-success:hover { opacity: 0.9; }

.btn-outline {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
}
.btn-outline:hover { background: var(--card); color: var(--text); border-color: var(--border-bright); }

.btn-danger { background: var(--red-bg); color: var(--red); border: 1px solid rgba(245,101,101,0.3); }
.btn-danger:hover { background: rgba(245, 101, 101, 0.2); }

.btn-sm { padding: 4px 10px; font-size: 11px; }
.btn-lg { padding: 10px 20px; font-size: 14px; }

/* ===== 输入框 ===== */
.input {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  color: var(--text);
  font-size: 13px;
  outline: none;
  width: 100%;
  transition: var(--transition);
}

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

.input-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

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

/* ===== 搜索框 ===== */
.search-box {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
}

.search-box .icon { color: var(--text-dim); font-size: 16px; }

.search-box input {
  flex: 1;
  background: none;
  border: none;
  color: var(--text);
  font-size: 13px;
  outline: none;
}

.search-box input::placeholder { color: var(--text-dim); }

/* ===== 标签页 ===== */
.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
}

.tab {
  padding: 10px 16px;
  font-size: 12px;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: var(--transition);
}

.tab:hover { color: var(--text); }
.tab.active { color: var(--blue); border-bottom-color: var(--blue); font-weight: 600; }

/* ===== 持仓进度条 ===== */
.holdings-bar {
  background: var(--bg);
  border-radius: var(--radius);
  padding: 10px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

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

.bar-label {
  font-size: 11px;
  color: var(--text-muted);
  width: 60px;
  flex-shrink: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bar-track {
  flex: 1;
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
}

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

.bar-fill.red { background: var(--red); }
.bar-fill.green { background: var(--green); }

.bar-value {
  font-size: 10px;
  color: var(--text-dim);
  width: 36px;
  text-align: right;
  flex-shrink: 0;
}

/* ===== 状态指示 ===== */
.status-ok { color: var(--green); }
.status-warn { color: var(--yellow); }
.status-error { color: var(--red); }

/* ===== 空状态 ===== */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-dim);
}

.empty-state .icon { font-size: 40px; margin-bottom: 12px; opacity: 0.5; }
.empty-state .title { font-size: 14px; margin-bottom: 6px; }
.empty-state .desc { font-size: 12px; }

/* ===== 模态框 ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  z-index: 200;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  backdrop-filter: blur(4px);
}

.modal-overlay.active { display: flex; }

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  width: 100%;
  max-width: 500px;
  overflow: hidden;
}

.modal-header {
  background: var(--card);
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  font-weight: 700;
  font-size: 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 20px;
  cursor: pointer;
  line-height: 1;
}

.modal-close:hover { color: var(--text); }

.modal-body { padding: 20px; }

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

/* ===== Toast 提示 ===== */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 18px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  z-index: 300;
  transform: translateY(100px);
  opacity: 0;
  transition: all 0.3s ease;
  box-shadow: var(--shadow);
}

.toast.show { transform: translateY(0); opacity: 1; }
.toast.success { border-color: rgba(72,187,120,0.4); }
.toast.error { border-color: rgba(245,101,101,0.4); }
.toast.warning { border-color: rgba(236,201,75,0.4); }

/* ===== 网格布局 ===== */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }

@media (max-width: 800px) {
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
}

/* ===== Flex工具 ===== */
.flex { display: flex; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }

/* ===== 间距 ===== */
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 16px; }
.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 12px; }
.mb-4 { margin-bottom: 16px; }

/* ===== 文字 ===== */
.text-sm { font-size: 12px; }
.text-xs { font-size: 11px; }
.text-muted { color: var(--text-muted); }
.text-dim { color: var(--text-dim); }
.text-red { color: var(--red); }
.text-green { color: var(--green); }
.font-bold { font-weight: 700; }

/* ===== 加载动画 ===== */
.loading {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--text-dim);
  font-size: 12px;
}

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

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

/* ===== 底部状态栏 ===== */
.footer {
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 12px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11px;
  color: var(--text-dim);
  margin-top: 24px;
}

.footer .status { display: flex; align-items: center; gap: 6px; }
.footer .dot { width: 6px; height: 6px; border-radius: 50%; }
.footer .dot.green { background: var(--green); }
.footer .dot.yellow { background: var(--yellow); }
.footer .dot.red { background: var(--red); }

/* ===== 个股详情弹窗 ===== */
.stock-detail-header {
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.font-lg { font-size: 18px; }
.font-xl { font-size: 22px; }

.market-status-bar {
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  font-size: 11px;
  font-weight: 600;
  display: inline-block;
}

.market-status-bar.open {
  background: var(--green-bg);
  color: var(--green);
  border: 1px solid rgba(72,187,120,0.3);
}

.market-status-bar.closed {
  background: var(--yellow-bg);
  color: var(--yellow);
  border: 1px solid rgba(236,201,75,0.3);
}

.chart-container {
  height: 360px;
  margin-top: 12px;
  position: relative;
}

.chart-container canvas {
  width: 100% !important;
}

/* 市场时段提示 */
.trade-warning {
  background: var(--yellow-bg);
  border: 1px solid rgba(236,201,75,0.3);
  border-radius: var(--radius-sm);
  padding: 8px 14px;
  font-size: 12px;
  color: var(--yellow);
  margin-bottom: 12px;
}

.trade-warning.error {
  background: var(--red-bg);
  border-color: rgba(245,101,101,0.3);
  color: var(--red);
}

.p-4 { padding: 16px; }
.pl-4 { padding-left: 16px; }
.pr-4 { padding-right: 16px; }
.pt-4 { padding-top: 16px; }
.pb-4 { padding-bottom: 16px; }

/* ===== AI分析面板 ===== */
.analysis-panel {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
}

.analysis-title {
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 12px;
  color: var(--text);
}

.analysis-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.analysis-item {
  background: var(--card);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
}

.analysis-label {
  font-size: 10px;
  color: var(--text-dim);
  margin-bottom: 4px;
}

.analysis-value {
  font-size: 13px;
  font-weight: 600;
}

.core-metrics {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.core-metric {
  background: var(--card);
  border-radius: var(--radius-sm);
  padding: 10px;
  text-align: center;
}

.core-label {
  font-size: 10px;
  color: var(--text-dim);
  margin-bottom: 4px;
}

.core-value {
  font-size: 18px;
  font-weight: 700;
}

.core-sub {
  font-size: 10px;
  color: var(--text-dim);
  margin-top: 2px;
}

.reason-box {
  background: var(--blue-bg);
  border: 1px solid rgba(66,153,225,0.2);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
}

.reason-title {
  font-size: 11px;
  font-weight: 600;
  color: var(--blue);
  margin-bottom: 6px;
}

.reason-text {
  font-size: 12px;
  color: var(--text);
  line-height: 1.6;
}

.ma-info {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.ma-tag {
  background: var(--card);
  border-radius: var(--radius-sm);
  padding: 4px 10px;
  font-size: 11px;
  font-weight: 600;
}

@media (max-width: 600px) {
  .analysis-grid { grid-template-columns: repeat(2, 1fr); }
  .core-metrics { grid-template-columns: repeat(2, 1fr); }
}


/* ===== 动画 ===== */
.fade-in { animation: fadeIn 0.3s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
