:root {
  --paper: #F5F1E8; --card: #FFFDF9; --ink: #1E1B16; --ink2: #453F36;
  --muted: #857B6D; --line: #E6DECD; --line2: #EFE7D8;
  --red: #C0392B; --red-soft: #F8E8E4; --green: #2E7D5B; --green-soft: #E5F0EA;
  --gold: #B08D57; --blue: #2F5D8A;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { background: var(--paper); color: var(--ink); font-family: "PingFang SC","Hiragino Sans GB",-apple-system,sans-serif; }
body { min-height: 100vh; overflow-x: hidden; }
.serif { font-family: "Songti SC","STSong","PingFang SC",serif; }
.num { font-variant-numeric: tabular-nums; }
.app { max-width: 1480px; margin: 0 auto; padding: 18px 26px 40px; }
.hidden { display: none !important; }

/* header */
.topbar { display:flex; align-items:center; gap:14px; padding-bottom:14px; border-bottom:1px solid var(--line); }
.logo { width:42px; height:42px; border-radius:12px; background:var(--red); color:#FFF8EE; display:flex; align-items:center; justify-content:center; font-family:"Songti SC"; font-size:25px; font-weight:700; box-shadow:0 2px 8px rgba(192,57,43,.25); flex:0 0 auto; }
.brand h1 { font-family:"Songti SC"; font-size:21px; letter-spacing:1px; line-height:1.15; }
.brand p { font-size:11px; color:var(--muted); margin-top:3px; letter-spacing:.3px; }
.nav { display:flex; gap:4px; margin-left:26px; background:#ECE5D6; border-radius:12px; padding:4px; overflow-x:auto; }
.nav button { border:0; background:transparent; color:var(--muted); font-size:13px; padding:8px 16px; border-radius:9px; cursor:pointer; font-family:inherit; }
.nav button.on { background:var(--card); color:var(--ink); font-weight:600; box-shadow:0 1px 3px rgba(60,48,30,.12); }
.topmeta { margin-left:auto; text-align:right; font-size:12px; color:var(--muted); line-height:1.7; }
.topmeta b { color:var(--ink); font-weight:600; }
.dot-online { display:inline-block; width:7px; height:7px; border-radius:50%; background:var(--green); margin-right:5px; }

/* cards + common */
.card { background:var(--card); border:1px solid var(--line); border-radius:14px; box-shadow:0 1px 2px rgba(60,48,30,.04); }
.sec-title { display:flex; align-items:center; gap:8px; font-size:14px; font-weight:600; letter-spacing:.4px; }
.sec-title .bar { width:3px; height:15px; border-radius:2px; background:var(--red); }
.sec-sub { font-size:11.5px; color:var(--muted); font-weight:400; }
.row { display:flex; align-items:center; }
.btn { height:32px; padding:0 13px; border-radius:9px; border:1px solid var(--line); background:var(--card); color:var(--ink2); font-size:12.5px; cursor:pointer; font-family:inherit; display:inline-flex; align-items:center; gap:6px; }
.btn:hover { border-color:#D6C9B2; }
.btn-dark { background:var(--ink); border-color:var(--ink); color:#F5F1E8; }
.btn-red { background:var(--red); border-color:var(--red); color:#fff; }
.tabs { display:flex; gap:3px; background:#EFE9DC; border-radius:9px; padding:3px; }
.tabs button { border:0; background:transparent; color:var(--muted); font-size:12px; padding:6px 12px; border-radius:7px; cursor:pointer; font-family:inherit; }
.tabs button.on { background:var(--card); color:var(--ink); font-weight:600; box-shadow:0 1px 2px rgba(60,48,30,.1); }
.input { height:34px; border:1px solid var(--line); border-radius:9px; background:var(--card); padding:0 11px; font-size:13px; font-family:inherit; color:var(--ink); outline:none; }
.input:focus { border-color:#C9B48E; }
select.input { padding-right:6px; }
.red { color:var(--red); } .green { color:var(--green); } .muted { color:var(--muted); }
.mono { font-variant-numeric: tabular-nums; }

/* view market */
.kpis { display:grid; grid-template-columns:repeat(4,1fr); gap:14px; margin:16px 0; }
.kpi { padding:14px 16px; }
.kpi .lb { font-size:12px; color:var(--muted); }
.kpi .vl { font-size:26px; font-weight:700; margin-top:4px; letter-spacing:-.5px; }
.kpi .ft { font-size:11px; color:var(--muted); margin-top:3px; }
.grid2 { display:grid; grid-template-columns: 1.15fr 1fr; gap:14px; margin-bottom:14px; }
.rankcard { padding:14px 16px 10px; }
.ranks { display:grid; grid-template-columns:1fr 1fr; gap:0 18px; margin-top:8px; }
.rankrow { display:flex; align-items:center; gap:8px; padding:6px 0; border-bottom:1px dashed var(--line); cursor:pointer; }
.rankrow:last-child { border-bottom:none; }
.rankrow:hover { background:#FBF6EC; }
.rk { width:16px; font-size:11px; color:var(--muted); }
.rk.top { color:var(--red); font-weight:700; }
.rnm { font-size:12.5px; line-height:1.25; }
.rbd { font-size:10px; color:var(--muted); }
.rhr { margin-left:auto; text-align:right; }
.rpc { font-size:12.5px; font-weight:600; }
.rpr { font-size:10.5px; color:var(--muted); }
.heatcard { padding:14px 16px; }
.heatgrid { display:grid; grid-template-columns:repeat(4,1fr); gap:7px; margin-top:10px; }
.heat { border-radius:8px; padding:7px 8px; font-size:11px; cursor:pointer; }
.heat b { display:block; font-size:11.5px; }
.heat span { font-size:10px; opacity:.85; }
.h-flat { background:#F0EDE5; color:var(--muted); }
.h-up1 { background:#F3DED8; } .h-up2 { background:#EDC9C0; color:#8E2B20; }
.h-dn1 { background:#D6E8DD; } .h-dn2 { background:#BFDCCB; color:#1F5A40; }
.summary { margin-top:10px; padding:10px 12px; background:#F2ECDF; border-radius:9px; font-size:11.5px; line-height:1.65; color:var(--ink2); }
.tablecard { padding:14px 16px 10px; }
.tablebar { display:flex; gap:10px; align-items:center; margin:10px 0 6px; flex-wrap:wrap; }
.tablebar .input { width:220px; }
.tbl { width:100%; border-collapse:collapse; }
.tbl th { position:sticky; top:0; z-index:2; text-align:left; font-size:11.5px; color:var(--muted); font-weight:500; padding:8px; border-bottom:1px solid var(--line); white-space:nowrap; background:#FBF7EE; position:sticky; top:0; }
.tbl td { font-size:12.5px; padding:8px; border-bottom:1px solid #F0EADD; white-space:nowrap; }
.tbl tr:hover td { background:#FBF6EC; }
.tbl .r { text-align:right; }
.tbl-wrap { max-height:540px; overflow:auto; border:1px solid var(--line); border-radius:10px; }
.badge { display:inline-block; padding:1px 6px; border-radius:5px; background:#F0EADD; color:var(--ink2); font-size:10.5px; margin-left:6px; }
.star { border:0; background:transparent; cursor:pointer; font-size:15px; color:#C9BFAE; padding:0 4px; line-height:1; }
.star.on { color:var(--gold); }

/* compare view */
.cmp { display:grid; grid-template-columns: 310px 1fr; gap:14px; margin-top:16px; align-items:start; }
.side { padding:14px; position:sticky; top:14px; }
.side .sec-title { margin-bottom:8px; }
.searchbox { position:relative; }
.searchbox .input { width:100%; }
.results { margin-top:6px; max-height:240px; overflow:auto; border:1px solid var(--line); border-radius:9px; background:var(--card); }
.results:empty { display:none; }
.resrow { padding:8px 10px; font-size:12px; cursor:pointer; border-bottom:1px solid #F3EEE3; display:flex; gap:6px; align-items:center; }
.resrow:last-child { border-bottom:none; }
.resrow:hover { background:#FBF6EC; }
.resrow .b { color:var(--muted); font-size:10.5px; }
.resrow .star { margin-left:auto; }
.selected { display:flex; flex-wrap:wrap; gap:6px; margin:10px 0; min-height:26px; }
.chip { display:inline-flex; align-items:center; gap:6px; height:26px; padding:0 9px; border-radius:8px; background:#F1EADD; font-size:11.5px; }
.chip i { width:8px; height:8px; border-radius:50%; }
.chip .x { cursor:pointer; color:var(--muted); font-size:11px; }
.chip .x:hover { color:var(--red); }
.field { margin-top:12px; }
.field .lb { font-size:11px; color:var(--muted); margin-bottom:5px; }
.opts { display:flex; flex-wrap:wrap; gap:6px; }
.opts button { border:1px solid var(--line); background:var(--card); color:var(--ink2); height:28px; padding:0 10px; border-radius:8px; font-size:11.5px; cursor:pointer; font-family:inherit; }
.opts button.on { background:var(--ink); border-color:var(--ink); color:#F5F1E8; }
.hint { font-size:10.5px; color:var(--muted); line-height:1.6; margin-top:8px; }
.mainarea { display:flex; flex-direction:column; gap:14px; }
.chartcard { padding:14px 16px 10px; }
.charthead { display:flex; align-items:center; gap:10px; flex-wrap:wrap; margin-bottom:6px; }
.legend { display:flex; flex-wrap:wrap; gap:12px; font-size:11.5px; color:var(--ink2); }
.legend span { display:inline-flex; align-items:center; gap:5px; }
.legend i { width:9px; height:9px; border-radius:50%; display:inline-block; }
.rangeinfo { font-size:11px; color:var(--muted); margin:2px 0 4px; }
#chart { width:100%; height:460px; }
#spreadNote { font-size:11px; color:var(--muted); }
.statcard { padding:12px 16px; }
.statcard table { width:100%; border-collapse:collapse; }
.statcard th, .statcard td { font-size:11.5px; padding:6px 8px; border-bottom:1px solid #F0EADD; text-align:right; }
.statcard th:first-child, .statcard td:first-child { text-align:left; }
.favcard { display:flex; flex-direction:column; gap:6px; }
.favname { font-size:13px; font-weight:600; }
.favmeta { font-size:10.5px; color:var(--muted); }
.favprice { font-size:20px; font-weight:700; }
.favpct { font-size:11.5px; }
.favlist { display:grid; grid-template-columns:repeat(auto-fill,minmax(220px,1fr)); gap:12px; margin-top:14px; }
.empty { padding:40px; text-align:center; color:var(--muted); font-size:13px; }
.foot { margin-top:26px; font-size:10.5px; color:var(--muted); display:flex; justify-content:space-between; gap:10px; flex-wrap:wrap; }

@media (max-width: 980px) {
  .app { padding:12px 14px 30px; }
  .topbar { flex-wrap:wrap; gap:10px; }
  .nav { margin-left:0; order:3; width:100%; }
  .nav button { flex:1; }
  .topmeta { text-align:left; margin-left:0; }
  .kpis { grid-template-columns:repeat(2,1fr); }
  .grid2 { grid-template-columns:1fr; }
  .cmp { grid-template-columns:1fr; }
  .side { position:static; }
  #chart { height:340px; }
  .tbl-wrap { max-height:420px; }
  .nav button { flex:1 1 0; min-width:0; padding:6px 8px; font-size:12px; white-space:nowrap; }
  .ranks { grid-template-columns:1fr; }
  .rankrow .rnm { white-space:nowrap; overflow:hidden; text-overflow:ellipsis; max-width:170px; }
  .chip { max-width:100%; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
  .tablebar { flex-wrap:wrap; }
  .tablebar .input { width:100%; }
  .charthead .legend { font-size:10.5px; gap:8px; }
  .topmeta { font-size:11px; }
}
@media (max-width: 700px) {
  .tbl th:nth-child(5), .tbl td:nth-child(5),
  .tbl th:nth-child(7), .tbl td:nth-child(7),
  .tbl th:nth-child(8), .tbl td:nth-child(8) { display:none; }
  .tbl th, .tbl td { padding:7px 6px; font-size:11.5px; }
}
@media (max-width: 520px) {
  .kpis { gap:8px; margin:12px 0; }
  .kpi { padding:10px 12px; }
  .kpi .vl { font-size:20px; }
  .kpi .lb { font-size:11px; }
  .kpi .ft { font-size:10px; }
  .rankcard, .heatcard, .tablecard { padding:10px 12px; }
  .statcard th, .statcard td { padding:5px 5px; font-size:10.5px; }
}

.zoomctl { display:flex; gap:4px; margin-left:auto; }
.zoomctl button { height:26px; min-width:30px; padding:0 8px; border:1px solid var(--line); background:var(--card); border-radius:7px; font-size:12px; color:var(--ink2); cursor:pointer; font-family:inherit; }
.zoomctl button:hover { border-color:#C9B48E; }
#chart { cursor: grab; }
#chart:active { cursor: grabbing; }
@media (max-width: 700px) { .zoomctl { margin-left:0; } }

.fetchstatus { display:inline-flex; align-items:center; gap:5px; height:22px; padding:0 9px; border-radius:11px; font-size:11px; }
.fetchstatus.ok { background: var(--green-soft); color: var(--green); }
.fetchstatus.warn { background: #F7EBD9; color: #A0522D; }
.fetchstatus.loading { background: #F0EDE5; color: var(--muted); }

.chart-loading { display:flex; align-items:center; justify-content:center; height:100%; color:var(--muted); font-size:14px; }

/* ===== 核心品种（默认曲线） ===== */
.corecard { padding:14px 16px 10px; margin-bottom:14px; }
.corestats { display:grid; grid-template-columns:repeat(5,1fr); gap:10px; margin:10px 0 2px; }
.corestat { background:#F7F2E7; border:1px solid var(--line); border-radius:10px; padding:8px 10px; }
.corestat .nm { font-size:11.5px; color:var(--muted); display:flex; align-items:center; gap:6px; }
.corestat .nm i { width:8px; height:8px; border-radius:2px; display:inline-block; flex:0 0 auto; }
.corestat .vl { font-size:19px; font-weight:700; margin-top:2px; font-variant-numeric:tabular-nums; }
.corestat .ft { font-size:11.5px; margin-top:1px; }
.corechart { height:330px; width:100%; }
.corenote { font-size:11px; color:var(--muted); margin-top:2px; line-height:1.5; }
@media (max-width:760px) {
  .corestats { grid-template-columns:repeat(2,1fr); }
  .corechart { height:260px; }
}
