/* 中吉安策 · 量化研究终端 —— 设计系统
   机构级量化终端：暗色为底，香槟金为魂。留白/对齐/字重/金色点睛。 */
:root {
  /* 背景层次 */
  --bg-base:      #0E0E12;
  --bg-panel:     #16161C;
  --bg-elevated:  #1F1F27;
  --bg-hover:     #26262F;
  /* 边框 */
  --border:        #2C2C36;
  --border-strong: #3A3A46;
  /* 品牌香槟金 */
  --gold:        #C9A35C;
  --gold-bright: #E0BC6E;
  --gold-dim:    #8C7A4A;
  /* 文字 */
  --text-primary:   #ECEAE1;
  --text-secondary: #A29C8E;
  --text-muted:     #6E6A60;
  /* 涨跌（A股：红涨绿跌） */
  --up:      #E54B4B;
  --up-bg:   rgba(229,75,75,0.12);
  --down:    #2FB67A;
  --down-bg: rgba(47,182,122,0.12);
  --flat:    #8A8A8A;
  /* 功能色 */
  --info: #5B8DEF;
  --warn: #E0A030;
  /* 字体 */
  --font-sans: "PingFang SC", "Microsoft YaHei", "Source Han Sans CN", -apple-system, sans-serif;
  --font-mono: "JetBrains Mono", "Roboto Mono", "DIN Alternate", "Consolas", monospace;
  --font-serif: "Noto Serif SC", "Source Han Serif SC", serif;
  /* 尺寸 */
  --topbar-h: 56px;
  --rail-w: 64px;
  --rail-w-open: 200px;
  --riskbar-h: 32px;
  --radius-card: 8px;
  --radius-ctrl: 6px;
  --shadow-pop: 0 8px 24px rgba(0,0,0,0.45);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: var(--font-sans);
  background: var(--bg-base);
  color: var(--text-primary);
  font-size: 13px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}
.num { font-family: var(--font-mono); font-feature-settings: "tnum"; font-variant-numeric: tabular-nums; }
.up { color: var(--up); }
.down { color: var(--down); }
.flat { color: var(--flat); }
.muted { color: var(--text-muted); }
.sec { color: var(--text-secondary); }
.gold { color: var(--gold); }
a { color: var(--gold); text-decoration: none; }
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 6px; }
::-webkit-scrollbar-track { background: transparent; }

/* ---------- 布局 ---------- */
.app { display: grid; grid-template-rows: var(--topbar-h) 1fr var(--riskbar-h); height: 100vh; }

.topbar {
  display: flex; align-items: center; gap: 16px; padding: 0 16px;
  background: var(--bg-panel); border-bottom: 1px solid var(--border);
  z-index: 30;
}
.brand { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.brand img { height: 34px; width: auto; object-fit: contain; display: block;
  filter: drop-shadow(0 0 6px rgba(201,163,92,0.18)); }
.brand .sub { font-family: var(--font-serif); color: var(--text-secondary);
  font-size: 12px; letter-spacing: 1px; padding-left: 10px; border-left: 1px solid var(--border-strong); }

.ticker { flex: 1; display: flex; gap: 18px; overflow: hidden; align-items: center; height: 100%; }
.ticker .tk { display: flex; align-items: baseline; gap: 6px; white-space: nowrap; }
.ticker .tk .nm { color: var(--text-secondary); font-size: 12px; }
.ticker .tk .pv { font-family: var(--font-mono); font-size: 12px; font-variant-numeric: tabular-nums; }
.ticker .tk .ch { font-family: var(--font-mono); font-size: 11px; font-variant-numeric: tabular-nums; }

.topbar .tools { display: flex; align-items: center; gap: 12px; flex-shrink: 0; }
.search { display: flex; align-items: center; gap: 6px; background: var(--bg-base);
  border: 1px solid var(--border); border-radius: var(--radius-ctrl); padding: 5px 10px; width: 190px; }
.search input { background: transparent; border: none; outline: none; color: var(--text-primary);
  font-size: 12px; width: 100%; }
.search input::placeholder { color: var(--text-muted); }
.clock { font-family: var(--font-mono); font-size: 12px; color: var(--text-secondary); font-variant-numeric: tabular-nums; }
.ds-badge { font-size: 11px; padding: 3px 8px; border-radius: 999px; border: 1px solid var(--border-strong); }
.ds-badge.live { color: var(--down); border-color: var(--down); }
.ds-badge.synthetic { color: var(--warn); border-color: var(--warn); }
.icon-btn { background: var(--bg-elevated); border: 1px solid var(--border); color: var(--text-secondary);
  border-radius: var(--radius-ctrl); width: 30px; height: 30px; cursor: pointer; display: grid; place-items: center; }
.icon-btn:hover { color: var(--gold); border-color: var(--gold-dim); }

.body { display: flex; overflow: hidden; }

.nav { width: var(--rail-w); background: var(--bg-panel); border-right: 1px solid var(--border);
  transition: width .16s ease; overflow: hidden; flex-shrink: 0; z-index: 20; }
.nav:hover { width: var(--rail-w-open); box-shadow: var(--shadow-pop); }
.nav .item { display: flex; align-items: center; gap: 14px; height: 46px; padding: 0 20px; cursor: pointer;
  color: var(--text-secondary); border-left: 3px solid transparent; white-space: nowrap; }
.nav .item svg { width: 20px; height: 20px; flex-shrink: 0; stroke: currentColor; }
.nav .item .lbl { font-size: 13px; opacity: 0; transition: opacity .16s; }
.nav:hover .item .lbl { opacity: 1; }
.nav .item:hover { background: var(--bg-hover); color: var(--text-primary); }
.nav .item.active { color: var(--gold); border-left-color: var(--gold); background: rgba(201,163,92,0.06); }

.main { flex: 1; overflow-y: auto; padding: 18px 22px; }
.riskbar { display: flex; align-items: center; justify-content: center; background: var(--bg-panel);
  border-top: 1px solid var(--border); color: var(--text-muted); font-size: 11px; letter-spacing: .3px; padding: 0 16px; text-align: center; }

/* ---------- 通用 ---------- */
.page-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 16px; }
.page-head h1 { font-size: 20px; font-weight: 600; letter-spacing: .5px; }
.page-head .desc { color: var(--text-muted); font-size: 12px; margin-top: 3px; }
.grid { display: grid; gap: 14px; }
.cols-2 { grid-template-columns: repeat(2, 1fr); }
.cols-3 { grid-template-columns: repeat(3, 1fr); }
.cols-4 { grid-template-columns: repeat(4, 1fr); }
.span-2 { grid-column: span 2; }
@media (max-width: 1300px){ .cols-4 { grid-template-columns: repeat(2,1fr);} }

.card { background: var(--bg-panel); border: 1px solid var(--border); border-radius: var(--radius-card); padding: 16px; }
.card .card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.card .card-head h3 { font-size: 13px; font-weight: 600; color: var(--text-primary); }
.card .card-head .tools { display: flex; gap: 6px; }

/* Metric Tile */
.tile { background: var(--bg-panel); border: 1px solid var(--border); border-radius: var(--radius-card); padding: 14px 16px; }
.tile .label { color: var(--text-muted); font-size: 11px; letter-spacing: .5px; text-transform: uppercase; margin-bottom: 8px; }
.tile .value { font-family: var(--font-mono); font-size: 24px; font-weight: 600; font-variant-numeric: tabular-nums; line-height: 1.1; }
.tile .sub { font-family: var(--font-mono); font-size: 12px; margin-top: 6px; font-variant-numeric: tabular-nums; }

/* Tag / Pill */
.pill { display: inline-flex; align-items: center; gap: 4px; padding: 2px 9px; border-radius: 999px;
  background: var(--bg-elevated); border: 1px solid var(--gold-dim); color: var(--gold-bright); font-size: 11px; }
.pill.plain { border-color: var(--border-strong); color: var(--text-secondary); }

/* Button */
.btn { font-family: var(--font-sans); font-size: 12px; padding: 7px 16px; border-radius: var(--radius-ctrl);
  border: 1px solid var(--gold); color: var(--gold); background: transparent; cursor: pointer; transition: all .12s; }
.btn:hover { background: var(--gold); color: #1a1408; }
.btn.ghost { border-color: var(--border-strong); color: var(--text-secondary); }
.btn.ghost:hover { background: var(--bg-hover); color: var(--text-primary); border-color: var(--gold-dim); }
.btn.sm { padding: 4px 10px; font-size: 11px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* Form controls */
label.field { display: block; margin-bottom: 12px; }
label.field > span { display: block; color: var(--text-secondary); font-size: 12px; margin-bottom: 5px; }
select, input[type=text], input[type=number], input[type=date] {
  width: 100%; background: var(--bg-base); border: 1px solid var(--border); color: var(--text-primary);
  border-radius: var(--radius-ctrl); padding: 7px 10px; font-size: 12px; font-family: var(--font-sans); outline: none; }
input.num, select.num { font-family: var(--font-mono); }
select:focus, input:focus { border-color: var(--gold-dim); }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: var(--radius-ctrl); overflow: hidden; }
.seg button { background: var(--bg-base); border: none; color: var(--text-secondary); padding: 6px 12px; font-size: 12px; cursor: pointer; }
.seg button.active { background: var(--gold); color: #1a1408; }
.chip-row { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { padding: 4px 10px; border: 1px solid var(--border); border-radius: 999px; font-size: 11px; cursor: pointer; color: var(--text-secondary); }
.chip.on { border-color: var(--gold); color: var(--gold); background: rgba(201,163,92,0.08); }

/* DataTable */
.tbl-wrap { overflow: auto; }
table.dt { width: 100%; border-collapse: collapse; font-size: 12px; }
table.dt th { text-align: left; color: var(--text-muted); font-weight: 500; font-size: 11px; text-transform: uppercase;
  letter-spacing: .4px; padding: 8px 10px; border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--bg-panel); cursor: pointer; white-space: nowrap; }
table.dt th.num, table.dt td.num { text-align: right; font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
table.dt th .arr { color: var(--gold); margin-left: 3px; }
table.dt td { padding: 7px 10px; border-bottom: 1px solid var(--border); white-space: nowrap; }
table.dt tbody tr:hover { background: var(--bg-hover); }
table.dt td.name { color: var(--text-primary); }
table.dt .freeze { position: sticky; left: 0; background: var(--bg-panel); }
table.dt tbody tr:hover .freeze { background: var(--bg-hover); }

/* Tabs */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin-bottom: 14px; }
.tabs .tab { padding: 8px 16px; cursor: pointer; color: var(--text-secondary); font-size: 13px; border-bottom: 2px solid transparent; }
.tabs .tab:hover { color: var(--text-primary); }
.tabs .tab.active { color: var(--gold); border-bottom-color: var(--gold); }

/* Chart container */
.chart { width: 100%; height: 300px; }
.chart.tall { height: 360px; }
.chart.short { height: 220px; }

/* Skeleton / empty */
.skeleton { background: linear-gradient(90deg, var(--bg-elevated) 25%, var(--bg-hover) 50%, var(--bg-elevated) 75%);
  background-size: 200% 100%; animation: sk 1.3s infinite; border-radius: 4px; }
@keyframes sk { 0%{background-position:200% 0} 100%{background-position:-200% 0} }
.empty { display: grid; place-items: center; padding: 40px; color: var(--text-muted); text-align: center; gap: 8px; }
.empty svg { width: 40px; height: 40px; stroke: var(--border-strong); }
.loading-bar { height: 2px; background: var(--gold); animation: lb 1s infinite; }
@keyframes lb { 0%{opacity:.3} 50%{opacity:1} 100%{opacity:.3} }

.kv { display: flex; justify-content: space-between; padding: 6px 0; border-bottom: 1px solid var(--border); }
.kv:last-child { border-bottom: none; }
.kv .k { color: var(--text-secondary); font-size: 12px; }
.kv .v { font-family: var(--font-mono); font-variant-numeric: tabular-nums; font-size: 12px; }

.note { font-size: 11px; color: var(--text-muted); margin-top: 8px; line-height: 1.6; }
.divider { height: 1px; background: var(--border); margin: 14px 0; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }
.badge-xd { font-size: 10px; color: var(--warn); border: 1px solid var(--warn); border-radius: 4px; padding: 1px 5px; margin-left: 6px; }

/* 持仓卡片悬停微动效 */
.qcard { transition: transform .15s ease, box-shadow .15s ease, border-color .15s ease; }
.qcard:hover { transform: translateY(-3px); box-shadow: 0 10px 26px rgba(0,0,0,.38); border-color: var(--gold); }
