:root{
  --bg:#0f1419; --bg2:#151c24; --bg3:#1b242e; --line:#26313d;
  --fg:#dce3ea; --fg2:#8fa1b3; --fg3:#5f7183;
  --acc:#4fc3f7; --ok:#4caf7d; --warn:#e0a63c; --bad:#e0605a;
  --c1:#4fc3f7; --c2:#ffb74d; --c3:#81c784; --c4:#e57373; --c5:#ba68c8;
}
*{box-sizing:border-box}
html,body{height:100%;margin:0}
body{
  background:var(--bg); color:var(--fg);
  font:13px/1.5 -apple-system,"Segoe UI","Microsoft YaHei",system-ui,sans-serif;
  display:grid; grid-template-rows:auto 1fr auto; overflow:hidden;
}
header{
  display:flex; align-items:center; gap:14px; flex-wrap:wrap;
  padding:9px 16px; background:var(--bg2); border-bottom:1px solid var(--line);
}
header h1{font-size:14px; font-weight:600; margin:0; letter-spacing:.3px}
header h1 span{color:var(--acc)}
.filebtn{
  display:inline-flex; align-items:center; gap:7px; cursor:pointer;
  background:var(--bg3); border:1px solid var(--line); color:var(--fg);
  padding:5px 12px; border-radius:6px; font-size:12.5px; white-space:nowrap;
}
.filebtn:hover{border-color:var(--acc); color:var(--acc)}
.filebtn input{display:none}
.filebtn.sub{opacity:.85}
.filebtn[disabled]{opacity:.4; cursor:default; border-color:var(--line); color:var(--fg3)}
#status{color:var(--fg2); font-size:12px; margin-left:auto; text-align:right}
#status b{color:var(--fg); font-weight:600}
#status .bad{color:#e0605a}
#status .busy{color:var(--acc)}

main{display:grid; grid-template-columns:272px 1fr; min-height:0; overflow:hidden}

aside{
  border-right:1px solid var(--line); background:var(--bg2);
  display:flex; flex-direction:column; min-height:0;
}
.ptitle{
  padding:7px 12px; font-size:11.5px; letter-spacing:.6px; color:var(--fg3);
  text-transform:uppercase; border-bottom:1px solid var(--line); display:flex; gap:8px;
}
.ptitle button{
  margin-left:auto; background:none; border:none; color:var(--fg2); cursor:pointer;
  font-size:11px; padding:0 3px;
}
.ptitle button:hover{color:var(--acc)}
#legend{overflow:auto; flex:1; padding:4px 0}
.lg{
  display:flex; align-items:center; gap:7px; padding:3px 11px; cursor:pointer;
  user-select:none; font-size:12px; border-left:2px solid transparent;
}
.lg:hover{background:var(--bg3)}
.lg.off{opacity:.34}
.lg .sw{width:9px; height:9px; border-radius:2px; flex:none}
/* 英文在前、中文在后；超长的两条允许换行，别把中文名截掉 */
.lg .nm{flex:1; overflow:hidden; white-space:normal; line-height:1.35; word-break:break-word}
.lg .nm em{color:var(--fg3); font-style:normal; font-size:10.5px}
.lg .rg{color:var(--fg3); font-size:10.5px; font-variant-numeric:tabular-nums}

section#chartArea{display:flex; flex-direction:column; min-width:0; min-height:0}
#toolbar{
  display:flex; align-items:center; gap:12px; flex-wrap:wrap;
  padding:6px 12px; border-bottom:1px solid var(--line); background:var(--bg2);
  font-size:12px; color:var(--fg2);
}
#toolbar label{display:inline-flex; align-items:center; gap:5px; cursor:pointer}
#toolbar select,#toolbar input[type=number]{
  background:var(--bg3); color:var(--fg); border:1px solid var(--line);
  border-radius:4px; padding:2px 6px; font-size:12px; font-family:inherit;
}
#toolbar .sep{width:1px; height:16px; background:var(--line)}
#wrap{position:relative; flex:1; min-height:0}
canvas{display:block; width:100%; height:100%; cursor:crosshair}
/* 放大后出现的横向滚动条：宽度对应可视区间，拖动即平移 */
#hscroll{
  position:absolute; bottom:5px; height:12px; z-index:6;
  left:56px; right:12px; display:none; border-radius:6px;
  background:rgba(40,52,64,.92); border:1px solid var(--line); cursor:pointer;
}
#hscroll.on{display:block}
#hsThumb{
  position:absolute; top:-1px; bottom:-1px; min-width:26px;
  background:#5e7a94; border:1px solid #74919f; border-radius:6px;
  cursor:grab; transition:background .12s;
}
#hsThumb:hover{background:#708fa9}
#hsThumb:active{cursor:grabbing; background:var(--acc); border-color:var(--acc)}
#tip{
  position:absolute; pointer-events:none; display:none; z-index:9;
  background:rgba(15,20,25,.96); border:1px solid var(--line); border-radius:6px;
  padding:7px 9px; font-size:11.5px; box-shadow:0 6px 20px rgba(0,0,0,.5);
  max-height:68%; overflow:hidden; min-width:150px; max-width:380px;
}
#tip .t{color:var(--fg2); margin-bottom:4px; font-variant-numeric:tabular-nums}
#tip .r{display:flex; gap:8px; align-items:baseline; white-space:nowrap}
#tip .r i{width:8px;height:8px;border-radius:2px;display:inline-block;flex:none}
#tip .r span{flex:1; overflow:hidden; text-overflow:ellipsis}
#tip .r b{font-weight:600; font-variant-numeric:tabular-nums; color:var(--fg)}

#analysis{
  border-top:1px solid var(--line); background:var(--bg2);
  /* 31vh 图太高、判据全被挤出；46vh 图又偏矮。36vh + 参数区可折叠（见 #paramsHead）折中 */
  max-height:36vh; display:flex; flex-direction:column; min-height:0;
}
#abody{overflow:auto; padding:10px 14px 16px}
/* 参数区折叠头：默认收起，把高度让给下方的判据结果 */
#paramsHead{
  display:flex; align-items:center; gap:8px; padding:1px 2px 8px;
  cursor:pointer; user-select:none; font-size:12px; color:var(--fg2);
}
#paramsHead:hover b{color:var(--acc)}
#paramsHead b{color:var(--fg); font-weight:600; transition:color .12s}
#paramsHead .arw{color:var(--fg2); font-size:10px; line-height:1; transition:transform .15s}
#paramsHead .sum{color:var(--fg3); font-size:11.5px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; min-width:0}
#paramsHead .tip{margin-left:auto; flex:none; color:var(--fg3); font-size:11px}
#abody.fold #params{display:none}
#abody.fold #paramsHead .arw{transform:rotate(-90deg)}
/* 重新分析放在参数区底部：折叠时看不到，且只有改过参数才可点。
   吸底常驻，避免参数卡很长时按钮被滚出可视区 */
#paramActions{position:sticky; bottom:-2px; z-index:2;
  display:flex; align-items:center; justify-content:flex-end; gap:10px;
  padding:7px 2px 6px; margin:-2px 0 0;
  background:var(--bg); border-top:1px solid var(--line)}
#paramActions span{color:var(--fg3); font-size:11.5px; opacity:0; transition:opacity .15s ease;
  min-width:0; overflow:hidden; text-overflow:ellipsis; white-space:nowrap}
#paramActions span.on{opacity:1; color:var(--acc)}
#paramActions button{
  font-family:inherit; font-size:12px; padding:5px 14px; border-radius:6px; cursor:pointer;
  border:1px solid var(--acc); background:rgba(79,195,247,.1); color:var(--acc);
  /* 窄屏下不许把「重置」挤成竖排两个字 */
  flex:none; white-space:nowrap;
  transition:background .12s, border-color .12s, color .12s;
}
#paramActions button:hover:not(:disabled){background:rgba(79,195,247,.22)}
#paramActions button:disabled{border-color:var(--line); background:transparent; color:var(--fg3); cursor:not-allowed}
#paramActions button:disabled:hover{background:transparent}
/* 「重置」是次要动作：默认灰描边，不跟「重新分析」抢位置 */
#paramActions button.ghost{border-color:rgba(255,255,255,.16); background:transparent; color:var(--fg)}
#paramActions button.ghost:hover:not(:disabled){border-color:var(--fg2); color:var(--fg); background:rgba(255,255,255,.04)}
#paramActions button.ghost:disabled{color:var(--fg3); opacity:.55}
#paramActions button.ghost:disabled:hover{background:transparent; border-color:var(--line)}
.row{display:flex; gap:18px; flex-wrap:wrap}
.card{
  background:var(--bg); border:1px solid var(--line); border-radius:8px;
  padding:9px 12px; margin-bottom:10px; flex:1 1 320px; min-width:280px;
}
.card h3{margin:0 0 7px; font-size:12px; color:var(--fg2); font-weight:600; letter-spacing:.4px}
.grid{display:grid; grid-template-columns:repeat(auto-fill,minmax(158px,1fr)); gap:6px 12px}
.f{display:flex; align-items:center; gap:6px; font-size:11.5px; color:var(--fg2)}
.f input,.f select{
  background:var(--bg3); border:1px solid var(--line); color:var(--fg);
  border-radius:4px; padding:2px 5px; width:66px; font-size:11.5px; font-family:inherit;
  font-variant-numeric:tabular-nums;
}
.f select{width:112px}
.f span{flex:none}

table{width:100%; border-collapse:collapse; font-size:12px}
th,td{text-align:left; padding:5px 8px; border-bottom:1px solid var(--line); vertical-align:top}
th{color:var(--fg3); font-weight:500; font-size:11px; letter-spacing:.3px}
td.num{font-variant-numeric:tabular-nums; white-space:nowrap}
/* 只有带超限明细的行才可点（点开明细列表） */
tr.clk{cursor:default}
tr.clk.expandable{cursor:pointer}
tr.clk.expandable:hover{background:var(--bg3)}
.tag{display:inline-block; padding:1px 7px; border-radius:10px; font-size:11px; white-space:nowrap}
.tag.ok{background:rgba(76,175,125,.16); color:var(--ok)}
.tag.bad{background:rgba(224,96,90,.16); color:var(--bad)}
.tag.na{background:rgba(143,161,179,.14); color:var(--fg2)}
.tag.warn{background:rgba(224,166,60,.16); color:var(--warn)}
.mono{font-variant-numeric:tabular-nums}
.caret{display:inline-block;width:9px;color:var(--fg3);transition:transform .15s ease}
tr.open .caret{transform:rotate(90deg); color:var(--acc)}
tr.clk:hover .caret{color:var(--acc)}
tr.det>td{padding:2px 10px 10px 26px; background:rgba(255,255,255,.018); border-bottom:1px solid var(--line)}
.ivtb{width:100%; font-size:11.5px; border-collapse:collapse}
.ivtb th,.ivtb td{padding:3px 7px; border-bottom:1px solid rgba(255,255,255,.045); white-space:nowrap}
.ivtb th{color:var(--fg3); font-weight:500; font-size:10.5px}
tr.iv{cursor:pointer}
tr.iv:hover{background:rgba(79,195,247,.09)}
/* 当前正在看的那一段（点了它才画图） */
tr.iv.cur{background:rgba(79,195,247,.13)}
tr.iv.cur td:first-child{color:var(--acc); box-shadow:inset 3px 0 0 var(--acc)}
tr.iv td:first-child{color:var(--fg3)}
tr.iv td:last-child{white-space:nowrap}
.ivhint{font-size:11px; color:var(--fg3); padding:4px 2px 6px}
.gotobtn{display:inline-block; padding:1px 9px; border-radius:4px; font-size:11px;
         color:var(--acc); border:1px solid rgba(79,195,247,.35); background:rgba(79,195,247,.08)}
tr.iv:hover .gotobtn{background:rgba(79,195,247,.2); border-color:var(--acc)}
.morebtn{background:var(--bg3); border:1px solid var(--line); color:var(--acc); cursor:pointer;
         border-radius:5px; padding:3px 10px; font-size:11.5px; margin-top:6px; font-family:inherit}
.morebtn:hover{border-color:var(--acc)}
tr.clk.expandable{cursor:pointer}
tr.clk.expandable:hover td{background:rgba(79,195,247,.055)}
/* 点行聚焦关联通道：被选中的判据行留一道左侧竖线 */
tr.clk.sel td{background:rgba(79,195,247,.07)}
tr.clk.sel td:first-child{box-shadow:inset 3px 0 0 var(--acc)}
/* 明细列跟着整行走：有超限的行整行可点 */
tr.clk.expandable td.detcell{cursor:pointer}
/* 工具栏上的「已聚焦」提示条 */
#focusChip{display:none; align-items:center; gap:8px; padding:1px 4px 1px 9px;
  border:1px solid rgba(79,195,247,.4); background:rgba(79,195,247,.09);
  border-radius:12px; color:var(--acc); font-size:11.5px; max-width:52%}
#focusChip.on{display:inline-flex}
#focusChip b{font-weight:600}
#focusChip em{font-style:normal; color:var(--fg2)}
#focusChip button{background:transparent; border:0; color:var(--fg2); cursor:pointer;
  font-size:11.5px; font-family:inherit; padding:1px 7px; border-radius:9px}
#focusChip button:hover{background:rgba(79,195,247,.18); color:var(--acc)}
.toast{position:fixed; left:50%; bottom:28px; transform:translate(-50%,14px); z-index:99;
       background:#1c2530; border:1px solid #2f3d4c; color:#dce3ea; padding:9px 16px;
       border-radius:8px; font-size:12.5px; box-shadow:0 8px 24px rgba(0,0,0,.45);
       opacity:0; pointer-events:none; transition:opacity .18s ease, transform .18s ease}
.toast.show{opacity:1; transform:translate(-50%,0)}
.hint{color:var(--fg3); font-size:11.5px; line-height:1.6}
.hint b{color:var(--fg2); font-weight:600}
#drop{
  position:fixed; inset:0; z-index:99; display:none; align-items:center; justify-content:center;
  background:rgba(15,20,25,.86); border:2px dashed var(--acc); color:var(--acc); font-size:16px;
}
#drop.on{display:flex}
.empty{color:var(--fg3); text-align:center; padding:26px 10px; font-size:12px; line-height:1.9}
::-webkit-scrollbar{width:9px;height:9px}
::-webkit-scrollbar-thumb{background:#2b3745;border-radius:5px}
::-webkit-scrollbar-track{background:transparent}

/* 上传进度条 */
#prog{position:fixed; left:0; top:0; height:2px; width:0; background:var(--acc);
      z-index:999; transition:width .2s ease, opacity .3s ease}
#prog.done{opacity:0}
