/* ════════════════════════════════════════════════════════════
   智析股市 · 视觉系统
   色板规范：红涨绿跌（中国市场惯例）
   ════════════════════════════════════════════════════════════ */
:root {
  --bg:        #070b14;
  --bg-2:      #0b1220;
  --card:      #111a29;
  --card-2:    #16202f;
  --card-3:    #1d2a3d;
  --border:    rgba(148,163,184,0.10);
  --border-2:  rgba(148,163,184,0.20);

  --accent:    #38bdf8;   /* 主色 科技蓝 */
  --accent-2:  #8b5cf6;   /* 辅色 紫 */
  --up:        #f5464d;   /* 涨 —— 红 */
  --down:      #12b886;   /* 跌 —— 绿 */
  --yellow:    #f59e0b;
  --orange:    #f97316;

  --text:      #e6edf6;
  --muted:     #93a4bd;
  --dim:       #5b6b82;

  --r:  14px;
  --r2: 10px;
  --r3: 8px;
  --shadow: 0 10px 30px -12px rgba(0,0,0,0.6);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 14px; scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  background:
    radial-gradient(1200px 600px at 12% -10%, rgba(56,189,248,0.09), transparent 60%),
    radial-gradient(900px 500px at 100% 0%, rgba(139,92,246,0.08), transparent 55%),
    var(--bg);
  color: var(--text);
  font-family: 'Inter','SF Pro Display',-apple-system,BlinkMacSystemFont,'Segoe UI','PingFang SC','Microsoft YaHei',Helvetica,sans-serif;
  min-height: 100vh; overflow-x: hidden;
  font-variant-numeric: tabular-nums;
}
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #223247; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #2e4159; }
a { color: inherit; }

/* ════════ 涨跌语义 ════════ */
.up { color: var(--up) !important; }
.dn { color: var(--down) !important; }
.flat { color: var(--muted) !important; }
.num { font-variant-numeric: tabular-nums; }

/* ════════ 全局加载 ════════ */
.global-loader {
  position: fixed; inset: 0; z-index: 9999;
  background: var(--bg);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px;
  transition: opacity 0.4s ease;
}
.loader-mark { font-size: 44px; animation: floatY 2s ease-in-out infinite; }
.spinner {
  width: 34px; height: 34px; border-radius: 50%;
  border: 3px solid rgba(56,189,248,0.15); border-top-color: var(--accent);
  animation: spin 0.8s linear infinite;
}
.loader-title { font-size: 16px; font-weight: 800; letter-spacing: 1px; color: var(--accent); }
.loader-status { color: var(--dim); font-size: 12px; max-width: 280px; text-align: center; line-height: 1.6; }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes floatY { 0%,100%{transform:translateY(0)} 50%{transform:translateY(-6px)} }

/* ════════ 导航 ════════ */
.nav {
  position: fixed; top: 0; left: 0; right: 0; z-index: 200; height: 58px;
  display: flex; align-items: center; gap: 14px; padding: 0 18px;
  background: rgba(7,11,20,0.82);
  backdrop-filter: blur(20px) saturate(160%);
  -webkit-backdrop-filter: blur(20px) saturate(160%);
  border-bottom: 1px solid var(--border);
}
.nav-logo { display: flex; align-items: center; gap: 9px; flex-shrink: 0; }
.logo-icon {
  width: 32px; height: 32px; border-radius: 9px; display: flex; align-items: center; justify-content: center;
  font-size: 16px; background: linear-gradient(135deg, #0ea5e9, #8b5cf6);
  box-shadow: 0 4px 16px rgba(56,189,248,0.35);
}
.logo-text { font-size: 16px; font-weight: 800; letter-spacing: -0.3px;
  background: linear-gradient(90deg,#7dd3fc,#c4b5fd); -webkit-background-clip: text; background-clip: text; color: transparent; }
.nav-tabs { display: flex; gap: 3px; flex: 1; }
.nav-tab {
  padding: 7px 15px; border-radius: 9px; cursor: pointer; border: none; background: none;
  color: var(--muted); font-size: 13px; font-weight: 500; white-space: nowrap; transition: all 0.18s;
}
.nav-tab:hover { color: var(--text); background: rgba(148,163,184,0.08); }
.nav-tab.active { color: #fff; background: linear-gradient(135deg, rgba(56,189,248,0.22), rgba(139,92,246,0.22)); box-shadow: inset 0 0 0 1px rgba(56,189,248,0.25); font-weight: 600; }
.nav-right { margin-left: auto; display: flex; align-items: center; gap: 12px; flex-shrink: 0; }
.nav-time { font-size: 12px; color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.live-badge {
  display: flex; align-items: center; gap: 6px; padding: 4px 11px; border-radius: 100px;
  background: rgba(245,70,77,0.10); color: var(--up); border: 1px solid rgba(245,70,77,0.22);
  font-size: 11px; font-weight: 700;
}
.live-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--up); }
.pulse { animation: pulse 1.6s infinite; }
@keyframes pulse { 0%,100%{opacity:1;box-shadow:0 0 0 0 rgba(245,70,77,0.5)} 50%{opacity:0.55;box-shadow:0 0 0 5px rgba(245,70,77,0)} }
.hamburger { display: none; flex-direction: column; gap: 4px; justify-content: center; align-items: center; width: 36px; height: 36px; background: none; border: 1px solid var(--border); border-radius: 9px; cursor: pointer; }
.hamburger span { display: block; width: 17px; height: 2px; background: var(--text); border-radius: 2px; transition: all 0.25s; }
.hamburger.active span:nth-child(1) { transform: rotate(45deg) translate(4px,4px); }
.hamburger.active span:nth-child(2) { opacity: 0; }
.hamburger.active span:nth-child(3) { transform: rotate(-45deg) translate(4px,-4px); }

/* ════════ 行情条 ════════ */
.ticker {
  position: fixed; top: 58px; left: 0; right: 0; z-index: 199; height: 34px;
  overflow: hidden; white-space: nowrap; padding: 7px 0;
  background: rgba(11,18,32,0.9); backdrop-filter: blur(12px); border-bottom: 1px solid var(--border);
}
.ticker-track { display: inline-flex; animation: scrollLeft 70s linear infinite; }
.ticker-track:hover { animation-play-state: paused; }
.ticker-item { display: inline-flex; align-items: center; gap: 7px; padding: 0 18px; border-right: 1px solid var(--border); font-size: 12px; }
.t-sym { color: var(--muted); font-weight: 700; font-size: 11px; }
.t-price { color: var(--text); font-weight: 600; }
@keyframes scrollLeft { 0%{transform:translateX(0)} 100%{transform:translateX(-50%)} }

/* ════════ 布局 ════════ */
.layout { padding-top: 92px; display: flex; min-height: 100vh; }
.sidebar {
  width: 208px; min-width: 208px; height: calc(100vh - 92px); position: sticky; top: 92px;
  overflow-y: auto; padding: 16px 12px; flex-shrink: 0;
  border-right: 1px solid var(--border); background: rgba(11,18,32,0.4);
}
.s-section { margin-bottom: 20px; }
.s-label { font-size: 10px; font-weight: 700; color: var(--dim); text-transform: uppercase; letter-spacing: 1.4px; padding: 0 8px; margin-bottom: 7px; }
.s-item { display: flex; align-items: center; gap: 9px; padding: 8px 10px; border-radius: 9px; cursor: pointer; color: var(--muted); font-size: 13px; transition: all 0.15s; }
.s-item:hover { background: rgba(148,163,184,0.08); color: var(--text); }
.s-item.active { background: linear-gradient(90deg, rgba(56,189,248,0.16), rgba(56,189,248,0.04)); color: var(--accent); font-weight: 600; }
.s-icon { width: 18px; text-align: center; font-size: 13px; }
.s-stock { display: flex; justify-content: space-between; align-items: center; padding: 7px 9px; border-radius: 7px; cursor: pointer; font-size: 12px; transition: background 0.15s; }
.s-stock:hover { background: rgba(148,163,184,0.07); }
.s-stock-name { color: var(--text); font-weight: 500; }
.s-foot { margin-top: 8px; padding: 10px 9px; font-size: 10px; line-height: 1.7; color: var(--dim); border-top: 1px solid var(--border); }
.main { flex: 1; min-width: 0; padding: 20px 22px 40px; }

/* ════════ 页面 ════════ */
.page { display: none; animation: fadeIn 0.28s ease; }
.page.active { display: block; }
@keyframes fadeIn { from{opacity:0;transform:translateY(6px)} to{opacity:1;transform:translateY(0)} }

/* ════════ 网格 ════════ */
.g4  { display: grid; grid-template-columns: repeat(4,1fr); gap: 14px; margin-bottom: 18px; }
.g3  { display: grid; grid-template-columns: repeat(3,1fr); gap: 14px; margin-bottom: 18px; }
.g2  { display: grid; grid-template-columns: repeat(2,1fr); gap: 14px; margin-bottom: 18px; }
.g21 { display: grid; grid-template-columns: 2fr 1fr; gap: 14px; margin-bottom: 18px; }
.g12 { display: grid; grid-template-columns: 1fr 1.7fr; gap: 14px; margin-bottom: 18px; }
.mb18 { margin-bottom: 18px; }

/* ════════ 卡片 ════════ */
.card {
  background: linear-gradient(180deg, rgba(255,255,255,0.018), transparent), var(--card);
  border: 1px solid var(--border); border-radius: var(--r); padding: 18px 20px;
  transition: border-color 0.2s;
}
.card:hover { border-color: var(--border-2); }
.card-scroll { max-height: 384px; overflow-y: auto; }
.card-title { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 600; color: var(--muted); margin-bottom: 14px; }
.muted-note { font-size: 10px; color: var(--dim); font-weight: 500; margin-left: 4px; }
.dot { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 8px var(--accent); flex-shrink: 0; }
.dot-red { background: var(--up) !important; box-shadow: 0 0 8px var(--up) !important; }
.dot-green { background: var(--down) !important; box-shadow: 0 0 8px var(--down) !important; }
.dot-purple { background: var(--accent-2) !important; box-shadow: 0 0 8px var(--accent-2) !important; }
.dot-yellow { background: var(--yellow) !important; box-shadow: 0 0 8px var(--yellow) !important; }
.legend-pill { margin-left: auto; font-size: 10px; color: var(--dim); display: flex; gap: 4px; align-items: center; }
.legend-pill i { width: 7px; height: 7px; border-radius: 2px; display: inline-block; margin: 0 2px 0 6px; }
.legend-pill i.up { background: var(--up); } .legend-pill i.dn { background: var(--down); }

/* ════════ 指标卡 ════════ */
.metric {
  position: relative; overflow: hidden; cursor: default;
  background: linear-gradient(180deg, rgba(255,255,255,0.02), transparent), var(--card);
  border: 1px solid var(--border); border-radius: var(--r); padding: 16px 18px; transition: all 0.2s;
}
.metric::before { content:''; position:absolute; top:0; left:0; right:0; height:2px; background: linear-gradient(90deg,var(--accent),transparent); opacity:0; transition: opacity 0.2s; }
.metric:hover { border-color: var(--border-2); transform: translateY(-2px); box-shadow: var(--shadow); }
.metric:hover::before { opacity: 1; }
.metric-label { font-size: 11px; color: var(--dim); margin-bottom: 8px; letter-spacing: 0.4px; }
.metric-val { font-size: 23px; font-weight: 800; line-height: 1.05; }
.metric-change { margin-top: 8px; font-size: 12px; font-weight: 700; display: flex; align-items: center; gap: 4px; }
.metric-sub { font-size: 11px; color: var(--dim); margin-top: 5px; }

/* ════════ AI 分析框 ════════ */
.ai-box {
  background: linear-gradient(135deg, rgba(139,92,246,0.10), rgba(56,189,248,0.05));
  border: 1px solid rgba(139,92,246,0.22); border-radius: var(--r); padding: 20px; margin-bottom: 18px;
}
.ai-header { display: flex; align-items: center; gap: 11px; margin-bottom: 14px; }
.ai-icon { width: 36px; height: 36px; border-radius: 10px; display: flex; align-items: center; justify-content: center; font-size: 17px; background: linear-gradient(135deg,#8b5cf6,#38bdf8); box-shadow: 0 4px 18px rgba(139,92,246,0.4); flex-shrink: 0; }
.ai-title { font-size: 14px; font-weight: 700; }
.ai-subtitle { font-size: 11px; color: var(--muted); margin-top: 3px; }
.ai-body { font-size: 13px; color: #b9c6d8; line-height: 1.95; }
.report-body { line-height: 2.05; }
.ai-signal { display: flex; gap: 10px; margin-top: 15px; flex-wrap: wrap; }
.ai-sig-item { flex: 1; min-width: 84px; padding: 11px; border-radius: var(--r2); background: rgba(255,255,255,0.035); border: 1px solid var(--border); text-align: center; }
.ai-sig-label { font-size: 10px; color: var(--dim); letter-spacing: 0.4px; margin-bottom: 5px; }
.ai-sig-val { font-size: 16px; font-weight: 800; }
.ai-tags { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 15px; }
.ai-tag { padding: 4px 11px; border-radius: 100px; font-size: 11px; color: #a78bfa; border: 1px solid rgba(139,92,246,0.3); cursor: default; transition: all 0.15s; }
.ai-tag:hover { background: rgba(139,92,246,0.14); }

/* ════════ 图表 ════════ */
.chart-box { position: relative; width: 100%; }
.chart-box canvas { width: 100% !important; }
.chart-empty { display: flex; align-items: center; justify-content: center; height: 100%; min-height: 120px; color: var(--dim); font-size: 13px; text-align: center; padding: 12px; }
.chart-legend { display: flex; flex-wrap: wrap; gap: 16px; font-size: 11px; color: var(--muted); padding: 10px 0 8px; }
.chart-legend span { display: inline-flex; align-items: center; gap: 5px; }
.chart-legend i { width: 14px; height: 3px; border-radius: 2px; display: inline-block; }
.sub-chart-label { font-size: 10px; color: var(--dim); margin: 6px 0 4px; letter-spacing: 0.5px; }

/* ════════ 热力图 ════════ */
.heatmap { display: grid; grid-template-columns: repeat(6,1fr); gap: 5px; }
.hm-cell { padding: 11px 7px; border-radius: var(--r3); text-align: center; cursor: default; transition: transform 0.2s; border: 1px solid rgba(255,255,255,0.05); }
.hm-cell:hover { transform: scale(1.04); z-index: 2; }
.hm-name { font-weight: 700; color: #fff; font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hm-pct { color: rgba(255,255,255,0.92); font-size: 11px; margin-top: 2px; font-weight: 600; }
.hm-sub { color: rgba(255,255,255,0.55); font-size: 9px; margin-top: 1px; }

/* ════════ 表格 ════════ */
.table-scroll { overflow-x: auto; }
.stk-table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.stk-table th {
  text-align: left; padding: 9px 10px; font-size: 10px; font-weight: 700; color: var(--dim);
  text-transform: uppercase; letter-spacing: 0.5px; border-bottom: 1px solid var(--border); white-space: nowrap;
}
.stk-table td { padding: 10px; border-bottom: 1px solid rgba(148,163,184,0.06); vertical-align: middle; }
.stk-table tr:hover td { background: rgba(148,163,184,0.04); }
.stk-table tr:last-child td { border-bottom: none; }
.cell-name { font-weight: 700; color: var(--text); }
.cell-code { font-size: 10px; color: var(--dim); }
.cell-stock { display: flex; flex-direction: column; gap: 1px; }
.badge { display: inline-flex; align-items: center; padding: 3px 9px; border-radius: 100px; font-size: 11px; font-weight: 700; }
.badge-up { background: rgba(245,70,77,0.13); color: var(--up); }
.badge-dn { background: rgba(18,184,134,0.13); color: var(--down); }
.badge-flat { background: rgba(148,163,184,0.10); color: var(--muted); }
.range-bar { width: 84px; }
.range-track { position: relative; height: 5px; border-radius: 3px; background: linear-gradient(90deg, rgba(18,184,134,0.5), rgba(148,163,184,0.25), rgba(245,70,77,0.5)); }
.range-dot { position: absolute; top: 50%; width: 8px; height: 8px; border-radius: 50%; background: #fff; border: 2px solid var(--card); transform: translate(-50%,-50%); box-shadow: 0 0 6px rgba(255,255,255,0.5); }

/* ════════ 按钮 ════════ */
.btn-mini { padding: 4px 11px; font-size: 11px; font-weight: 600; cursor: pointer; border-radius: 7px; color: var(--accent); background: rgba(56,189,248,0.10); border: 1px solid rgba(56,189,248,0.20); transition: all 0.15s; white-space: nowrap; }
.btn-mini:hover { background: rgba(56,189,248,0.2); }
.btn-primary { padding: 9px 18px; font-size: 13px; font-weight: 700; cursor: pointer; border: none; border-radius: var(--r2); color: #04121e; background: linear-gradient(135deg,#38bdf8,#22d3ee); transition: opacity 0.15s; white-space: nowrap; }
.btn-primary:hover { opacity: 0.88; }
.btn-add { padding: 5px 12px; font-size: 11px; font-weight: 700; cursor: pointer; border-radius: 7px; color: var(--up); background: rgba(245,70,77,0.10); border: 1px solid rgba(245,70,77,0.22); transition: all 0.15s; }
.btn-add:hover { background: rgba(245,70,77,0.2); }
.btn-del { padding: 4px 11px; font-size: 11px; font-weight: 600; cursor: pointer; border-radius: 7px; color: var(--muted); background: rgba(148,163,184,0.08); border: 1px solid var(--border); transition: all 0.15s; }
.btn-del:hover { color: var(--up); background: rgba(245,70,77,0.12); border-color: rgba(245,70,77,0.25); }
.btn-ghost { padding: 9px 16px; font-size: 13px; font-weight: 600; cursor: pointer; border-radius: var(--r2); color: var(--muted); background: rgba(148,163,184,0.08); border: 1px solid var(--border); }
.btn-ghost:hover { color: var(--text); }

/* ════════ Tab ════════ */
.tab-group { display: flex; gap: 3px; flex-wrap: wrap; }
.tab { padding: 5px 12px; border-radius: 7px; cursor: pointer; font-size: 12px; color: var(--muted); border: 1px solid transparent; transition: all 0.15s; white-space: nowrap; }
.tab:hover { color: var(--text); background: rgba(148,163,184,0.08); }
.tab.active { color: var(--accent); border-color: rgba(56,189,248,0.3); background: rgba(56,189,248,0.09); font-weight: 600; }

/* ════════ 搜索 ════════ */
.search-wrap { position: relative; margin-bottom: 18px; }
.search-bar { display: flex; align-items: center; gap: 10px; padding: 10px 16px; border-radius: 100px; background: var(--card); border: 1px solid var(--border); transition: border-color 0.2s, box-shadow 0.2s; }
.search-bar:focus-within { border-color: rgba(56,189,248,0.4); box-shadow: 0 0 0 4px rgba(56,189,248,0.08); }
.search-ico { font-size: 14px; color: var(--dim); }
.search-bar input { flex: 1; min-width: 0; background: none; border: none; outline: none; color: var(--text); font-size: 13px; }
.search-bar input::placeholder { color: var(--dim); }
.search-btn { flex-shrink: 0; white-space: nowrap; padding: 6px 18px; border: none; border-radius: 100px; cursor: pointer; font-size: 12px; font-weight: 700; color: #04121e; background: linear-gradient(135deg,#38bdf8,#22d3ee); }
.search-btn:hover { opacity: 0.88; }
.search-dropdown { position: absolute; top: calc(100% + 6px); left: 0; right: 0; z-index: 300; border-radius: var(--r2); background: var(--card-3); border: 1px solid var(--border-2); box-shadow: 0 16px 40px rgba(0,0,0,0.5); overflow: hidden; }
.search-dropdown-item { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 11px 16px; cursor: pointer; font-size: 13px; transition: background 0.1s; }
.search-dropdown-item:hover, .search-dropdown-item.active { background: rgba(56,189,248,0.10); }
.mkt-chip { display: inline-block; margin-left: 6px; padding: 1px 7px; border-radius: 5px; font-size: 10px; background: rgba(148,163,184,0.12); color: var(--muted); }

/* ════════ 新闻 ════════ */
.news-item { display: flex; gap: 11px; padding: 12px 0; border-bottom: 1px solid rgba(148,163,184,0.07); cursor: pointer; transition: all 0.15s; }
.news-item:last-child { border-bottom: none; }
.news-item:hover .news-title { color: var(--accent); }
.news-tag { flex-shrink: 0; height: fit-content; margin-top: 2px; padding: 2px 8px; border-radius: 5px; font-size: 10px; font-weight: 700; background: rgba(56,189,248,0.10); color: var(--accent); white-space: nowrap; }
.news-tag.red { background: rgba(245,70,77,0.12); color: var(--up); }
.news-tag.green { background: rgba(18,184,134,0.12); color: var(--down); }
.news-title { font-size: 13px; line-height: 1.55; margin-bottom: 4px; transition: color 0.15s; }
.news-meta { font-size: 11px; color: var(--dim); }
.kw-wrap { display: flex; flex-wrap: wrap; gap: 8px; }
.kw-chip { padding: 5px 12px; border-radius: 100px; border: 1px solid; font-weight: 600; cursor: default; transition: opacity 0.15s; }
.kw-chip:hover { opacity: 0.72; }
.kw-chip b { margin-left: 4px; font-size: 0.8em; opacity: 0.7; }
.legend-row { display: flex; justify-content: center; gap: 18px; margin-top: 12px; font-size: 11px; color: var(--muted); }

/* ════════ 个股详情 ════════ */
.analyze-input-row { display: flex; gap: 8px; margin-bottom: 16px; }
.analyze-input-row input { flex: 1; min-width: 0; padding: 9px 13px; border-radius: var(--r2); background: var(--card-2); border: 1px solid var(--border); color: var(--text); font-size: 13px; outline: none; transition: border-color 0.2s; }
.analyze-input-row input:focus { border-color: rgba(56,189,248,0.4); }
.detail-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.detail-name { font-size: 17px; font-weight: 800; }
.detail-code { font-size: 12px; color: var(--dim); font-weight: 600; margin-left: 6px; }
.detail-tags { display: flex; gap: 6px; margin-top: 7px; }
.stock-mkt-tag { padding: 2px 8px; border-radius: 5px; font-size: 10px; font-weight: 700; background: rgba(56,189,248,0.12); color: var(--accent); }
.detail-price { text-align: right; }
.detail-big { font-size: 28px; font-weight: 800; line-height: 1; }
.detail-chg { font-size: 13px; font-weight: 700; margin-top: 5px; }
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 20px; font-size: 12px; }
.detail-row { display: flex; justify-content: space-between; gap: 8px; padding: 7px 0; border-bottom: 1px solid rgba(148,163,184,0.07); }
.detail-row span { color: var(--muted); }
.detail-actions { display: flex; align-items: center; gap: 12px; margin-top: 16px; }
.detail-upd { font-size: 11px; color: var(--dim); }
.tech-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px solid rgba(148,163,184,0.07); }
.tech-row:last-child { border-bottom: none; }
.tech-name { font-size: 12px; color: var(--muted); flex: 1; }
.tech-val { font-size: 12px; font-weight: 700; font-variant-numeric: tabular-nums; text-align: right; min-width: 84px; }
.tech-sig { font-size: 11px; font-weight: 600; text-align: right; min-width: 84px; }

/* ════════ 仪表盘 ════════ */
.gauge-wrap { display: flex; flex-direction: column; align-items: center; padding: 4px 0; }
.gauge-val { font-size: 26px; font-weight: 800; margin-top: 2px; }
.gauge-label { font-size: 12px; color: var(--muted); margin-top: 3px; }

/* ════════ 宏观 ════════ */
.macro-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 11px 0; border-bottom: 1px solid rgba(148,163,184,0.07); }
.macro-row:last-child { border-bottom: none; }
.macro-val { font-weight: 700; font-size: 15px; }
.macro-sub { font-size: 10px; color: var(--dim); margin-top: 2px; }
.macro-chg { font-size: 11px; font-weight: 600; margin-top: 2px; }
#worldmap { width: 100%; min-height: 300px; }
#worldmap svg { width: 100%; display: block; }
.map-legend { display: flex; justify-content: center; gap: 20px; margin-top: 10px; font-size: 11px; color: var(--muted); }
.map-legend i { display: inline-block; width: 11px; height: 11px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }
.heat-up { background: rgba(245,70,77,0.85); }
.heat-flat { background: rgba(148,163,184,0.4); }
.heat-dn { background: rgba(18,184,134,0.85); }

/* ════════ 自选 ════════ */
.add-pf-form { margin-bottom: 14px; padding: 14px; border-radius: var(--r2); background: var(--card-2); border: 1px solid var(--border); }
.add-pf-grid { display: grid; grid-template-columns: 1.4fr 1fr 1fr auto; gap: 10px; align-items: end; }
.add-pf-grid label { display: flex; flex-direction: column; gap: 5px; font-size: 11px; color: var(--dim); }
.add-pf-grid input { padding: 8px 11px; border-radius: var(--r3); background: var(--bg-2); border: 1px solid var(--border); color: var(--text); font-size: 12px; outline: none; }
.add-pf-grid input:focus { border-color: rgba(56,189,248,0.4); }
.add-pf-btns { display: flex; gap: 7px; }
.pie-legend-row { display: flex; justify-content: space-between; font-size: 11px; padding: 3px 0; color: var(--text); }

/* ════════ 空状态 ════════ */
.empty-state { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; padding: 40px 16px; color: var(--dim); }
.empty-icon { font-size: 30px; opacity: 0.6; }
.empty-text { font-size: 12.5px; text-align: center; line-height: 1.6; max-width: 420px; }

/* ════════ 提示气泡 ════════ */
#tooltip { position: fixed; z-index: 9999; display: none; max-width: 220px; padding: 8px 12px; border-radius: var(--r3); background: var(--card-3); border: 1px solid var(--border-2); color: var(--text); font-size: 12px; pointer-events: none; box-shadow: 0 6px 20px rgba(0,0,0,0.45); }
.notif { position: fixed; right: 20px; bottom: 20px; z-index: 9999; max-width: 300px; padding: 13px 18px; border-radius: var(--r2); background: var(--card-3); border: 1px solid var(--border-2); color: var(--text); font-size: 13px; box-shadow: 0 8px 28px rgba(0,0,0,0.5); transform: translateX(130%); transition: transform 0.32s cubic-bezier(0.2,0.8,0.2,1); }
.notif.show { transform: translateX(0); }

/* ════════ 骨架屏 ════════ */
.shimmer { background: linear-gradient(90deg, rgba(148,163,184,0.05) 25%, rgba(148,163,184,0.10) 50%, rgba(148,163,184,0.05) 75%); background-size: 400px 100%; animation: shimmer 1.5s infinite; border-radius: 4px; }
@keyframes shimmer { 0%{background-position:-400px 0} 100%{background-position:400px 0} }

/* ════════ 响应式 ════════ */
@media (max-width: 1280px) { .g4 { grid-template-columns: repeat(2,1fr); } }
@media (max-width: 1100px) {
  .sidebar { width: 186px; min-width: 186px; }
  .g21,.g12 { grid-template-columns: 1fr; }
  .g3 { grid-template-columns: repeat(2,1fr); }
}
@media (max-width: 900px) { .g2 { grid-template-columns: 1fr; } }

/* ════════ 移动端 / 平板竖屏（≤768） ════════ */
@media (max-width: 768px) {
  html { font-size: 15px; }

  /* ── 顶部导航：6 个 tab 弹性等分，永不溢出被截 ── */
  .hamburger { display: flex; }
  .nav { gap: 8px; padding: 0 12px; }
  .nav-logo { gap: 7px; }
  .logo-icon { width: 30px; height: 30px; font-size: 15px; }
  .logo-text { display: none; }
  .nav-tabs { flex: 1 1 auto; min-width: 0; gap: 2px; overflow: hidden; }
  .nav-tabs::-webkit-scrollbar { display: none; }
  .nav-tab { flex: 1 1 0; min-width: 0; text-align: center; font-size: 12px; padding: 7px 4px; overflow: hidden; text-overflow: ellipsis; }
  .nav-right { gap: 6px; }
  .nav-time { display: none; }
  .live-badge { padding: 4px 9px; }

  /* ── 侧栏 → 抽屉 ── */
  .sidebar { position: fixed; left: -280px; top: 58px; bottom: 0; z-index: 400; width: 256px; min-width: 256px; height: auto; background: var(--bg-2); transition: left 0.3s ease; }
  .sidebar.open { left: 0; box-shadow: 6px 0 30px rgba(0,0,0,0.55); }
  .sidebar-overlay { display: none; position: fixed; inset: 0; top: 58px; z-index: 399; background: rgba(0,0,0,0.5); backdrop-filter: blur(3px); }
  .sidebar-overlay.show { display: block; }

  .layout { padding-top: 92px; }
  .main { padding: 13px 13px calc(28px + env(safe-area-inset-bottom)); }

  /* ── 网格：指标/指数卡保持 2 列（关键！避免单列超长堆叠）；其余单列 ── */
  .g4 { grid-template-columns: repeat(2,1fr) !important; gap: 10px !important; }
  .g3,.g2,.g21,.g12 { grid-template-columns: 1fr !important; gap: 12px; }
  #portfolioSummary { grid-template-columns: repeat(2,1fr) !important; gap: 10px !important; }
  .mb18 { margin-bottom: 14px; }

  .card { padding: 14px 15px; }
  .ai-box { padding: 16px 15px; }

  /* ── 指标卡紧凑化（显著降低高度，避免大面积空白） ── */
  .metric { padding: 12px 13px; border-radius: var(--r2); }
  .metric-label { font-size: 10px; margin-bottom: 6px; letter-spacing: 0.3px; }
  .metric-val { font-size: 19px; }
  .metric-change { font-size: 11px; margin-top: 6px; }
  .metric-sub { font-size: 10px; margin-top: 4px; }

  /* ── 卡片标题：标题与 tab 自动分行，杜绝文字挤压 ── */
  .card-title { flex-wrap: wrap; row-gap: 9px; font-size: 13px; margin-bottom: 12px; }
  .card-title .tab-group { margin-left: 0 !important; flex-basis: 100%; }
  .tab { font-size: 11.5px; padding: 5px 10px; }

  /* ── AI 信号卡 2 列，避免挤成一排 ── */
  .ai-sig-item { flex: 1 1 calc(50% - 5px); min-width: 0; padding: 9px; }
  .ai-sig-val { font-size: 15px; }

  /* ── 热力图 / 表单 ── */
  .heatmap { grid-template-columns: repeat(3,1fr) !important; }
  .add-pf-grid { grid-template-columns: 1fr 1fr; }
  .notif { left: 14px; right: 14px; bottom: 14px; max-width: none; }
  .detail-grid { grid-template-columns: 1fr; }
  .analyze-input-row input { font-size: 16px; }

  /* ── 表格 → 卡片 ── */
  .stk-table { display: block; width: 100%; min-width: 0 !important; }
  .stk-table tbody { display: block; width: 100%; }
  .stk-table thead { display: none; }
  .stk-table tbody tr { display: grid; width: 100%; box-sizing: border-box; grid-template-columns: 1fr auto; gap: 4px 12px; align-items: center; padding: 13px 14px !important; margin-bottom: 8px; border-radius: var(--r2); background: rgba(148,163,184,0.035); border: 1px solid var(--border); }
  .stk-table tbody tr td { padding: 0 !important; border: none !important; }
  .stk-table tbody tr td:first-child { grid-column: 1 / -1; }
  .stk-table tbody tr td:nth-child(2) { text-align: right; font-size: 16px !important; font-weight: 800; }
  .stk-table tbody tr td:nth-last-child(2) { display: none; }
  .stk-table tbody tr td:last-child { grid-column: 1 / -1; text-align: right; }
  #page-dashboard .stk-table tbody tr td:nth-child(4),
  #page-dashboard .stk-table tbody tr td:nth-child(5) { display: none; }
  .table-scroll { overflow-x: visible; }

  /* ── 行情页表格（12 列：#/代码/名称/最新价/涨跌/涨跌幅/量/额/PE/市值/区间/操作）
        → 结构化卡片：名称+代码 / 涨跌幅+现价 / 量·额 / PE·市值 / 操作 ── */
  #page-market .stk-table tbody tr { grid-template-columns: 1fr auto; gap: 3px 12px; }
  #page-market .stk-table tbody tr td:nth-child(1) { display: none; }                                /* # 序号略去 */
  #page-market .stk-table tbody tr td:nth-child(3) { grid-column: 1; grid-row: 1; font-size: 14px; font-weight: 700; color: var(--text); }
  #page-market .stk-table tbody tr td:nth-child(2) { grid-column: 2; grid-row: 1; text-align: right; font-size: 10px; font-weight: 600; color: var(--dim); }
  #page-market .stk-table tbody tr td:nth-child(6) { grid-column: 1; grid-row: 2; }
  #page-market .stk-table tbody tr td:nth-child(4) { grid-column: 2; grid-row: 2; text-align: right; font-size: 17px; font-weight: 800; }
  #page-market .stk-table tbody tr td:nth-child(5) { display: none; }                                /* 涨跌额与涨跌幅重复 */
  #page-market .stk-table tbody tr td:nth-child(7)  { grid-column: 1; grid-row: 3; font-size: 11px; color: var(--muted); }
  #page-market .stk-table tbody tr td:nth-child(8)  { grid-column: 2; grid-row: 3; text-align: right; font-size: 11px; color: var(--muted); }
  #page-market .stk-table tbody tr td:nth-child(9)  { grid-column: 1; grid-row: 4; font-size: 11px; color: var(--muted); }
  #page-market .stk-table tbody tr td:nth-child(10) { grid-column: 2; grid-row: 4; text-align: right; font-size: 11px; color: var(--muted); }
  #page-market .stk-table tbody tr td:nth-child(7)::before  { content: '量 '; color: var(--dim); }
  #page-market .stk-table tbody tr td:nth-child(8)::before  { content: '额 '; color: var(--dim); }
  #page-market .stk-table tbody tr td:nth-child(9)::before  { content: 'PE '; color: var(--dim); }
  #page-market .stk-table tbody tr td:nth-child(10)::before { content: '市值 '; color: var(--dim); }
  #page-market .stk-table tbody tr td:nth-child(12) { grid-column: 1 / -1; grid-row: 5; text-align: right; margin-top: 4px; }

  /* ── 总览页表格（股票/最新价/涨跌幅/总市值/区间/操作）
        → 左侧名称+代码（垂直居中），右侧现价 / 涨跌幅 / 操作 三行 ── */
  #page-dashboard .stk-table tbody tr { grid-template-columns: 1fr auto; gap: 2px 12px; }
  #page-dashboard .stk-table tbody tr td:nth-child(1) { grid-column: 1; grid-row: 1 / 4; align-self: center; }
  #page-dashboard .stk-table tbody tr td:nth-child(2) { grid-column: 2; grid-row: 1; text-align: right; font-size: 16px; font-weight: 800; }
  #page-dashboard .stk-table tbody tr td:nth-child(3) { grid-column: 2; grid-row: 2; text-align: right; }
  #page-dashboard .stk-table tbody tr td:nth-child(6) { grid-column: 2; grid-row: 3; text-align: right; margin-top: 5px; }
}

/* ════════ 小屏手机（≤480） ════════ */
@media (max-width: 480px) {
  .nav { gap: 6px; padding: 0 10px; }
  .nav-tab { font-size: 11.5px; padding: 7px 2px; }
  .live-badge #liveText { display: none; }        /* 仅保留脉冲红点，腾出空间 */
  .g4 { gap: 8px !important; }
  .metric-val { font-size: 17px; }
  .metric-change { font-size: 10.5px; }
  .metric-sub { font-size: 9.5px; }
  .ticker { height: 0; padding: 0; opacity: 0; pointer-events: none; }
  .layout { padding-top: 58px; }
  .sidebar { top: 58px; }
  .heatmap { grid-template-columns: repeat(2,1fr) !important; }
  .add-pf-grid { grid-template-columns: 1fr; }
  .card-title { font-size: 12.5px; }
}

/* ════════ 超小屏（≤360，如 iPhone SE 1代 / 老安卓） ════════ */
@media (max-width: 360px) {
  .nav-tab { font-size: 11px; padding: 7px 1px; }
  .metric-val { font-size: 16px; }
  .metric-label { font-size: 9.5px; }
  .main { padding: 11px 10px calc(24px + env(safe-area-inset-bottom)); }
}

