:root {
  --bg: #f4f6f9;
  --panel: #ffffff;
  --panel-2: #fafbfc;
  --border: #e3e8ef;
  --border-strong: #cfd7e3;
  --text: #1a2332;
  --text-2: #5a6a80;
  --text-3: #8a99ad;
  --brand: #1a5fb4;
  --brand-soft: #e8f0fb;
  --up: #c0392b;          /* 涨/优 → 红 */
  --down: #1e8449;        /* 跌/弱 → 绿 */
  --gold: #b8860b;
  --shadow: 0 1px 3px rgba(20, 35, 60, .06), 0 6px 20px rgba(20, 35, 60, .05);
  --radius: 10px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0; height: 100%;
  background: var(--bg); color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
               "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-size: 14px; line-height: 1.55;
}

.app { display: flex; flex-direction: column; height: 100vh; }

/* ---------- 顶栏 ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 20px; padding: 14px 22px;
  background: var(--panel); border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow); flex-shrink: 0;
}
.brand { display: flex; align-items: center; gap: 13px; }
.logo {
  width: 46px; height: 46px; border-radius: 11px; flex-shrink: 0;
  background: linear-gradient(140deg, #1a5fb4, #3b8eea);
  color: #fff; display: grid; place-items: center;
  font-weight: 800; font-size: 13px; letter-spacing: .5px;
}
.topbar h1 { margin: 0; font-size: 17px; font-weight: 700; letter-spacing: -.2px; }
.sub { margin: 2px 0 0; font-size: 12px; color: var(--text-3); }
.syncLine { font-size: 11px; font-weight: 600; }
.syncLine.ok { color: #16803c; }
.syncLine.err { color: #c0392b; }
.syncLine.sync { color: var(--brand); }

.topActions { display: flex; align-items: center; gap: 10px; }
.btn:disabled { opacity: .55; cursor: wait; }
#searchBox {
  width: 300px; padding: 8px 13px; font-size: 13px; font-family: inherit;
  border: 1px solid var(--border-strong); border-radius: 8px; background: var(--panel-2);
  outline: none; transition: .15s;
}
#searchBox:focus { border-color: var(--brand); background: #fff; box-shadow: 0 0 0 3px var(--brand-soft); }

.btn {
  padding: 8px 15px; font-size: 13px; font-family: inherit; font-weight: 600;
  border-radius: 8px; border: 1px solid transparent; cursor: pointer; transition: .15s;
  white-space: nowrap;
}
.btn.primary { background: var(--brand); color: #fff; }
.btn.primary:hover { background: #17509a; }
.btn.ghost { background: var(--panel-2); color: var(--text-2); border-color: var(--border-strong); }
.btn.ghost:hover { background: #eef1f6; color: var(--text); }

/* ---------- 主体 ---------- */
.body { display: flex; flex: 1; min-height: 0; }

.sidebar {
  width: 262px; flex-shrink: 0; background: var(--panel);
  border-right: 1px solid var(--border); overflow-y: auto; padding: 16px 18px 40px;
}
.filterGroup { margin-bottom: 24px; }
.filterGroup h3 {
  margin: 0 0 10px; font-size: 11px; font-weight: 700;
  color: var(--text-3); text-transform: uppercase; letter-spacing: .8px;
}
.chk { display: flex; align-items: center; gap: 8px; padding: 4px 0; cursor: pointer; font-size: 13px; }
.chk input { accent-color: var(--brand); width: 14px; height: 14px; cursor: pointer; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  padding: 4px 11px; font-size: 12px; border-radius: 999px; cursor: pointer;
  border: 1px solid var(--border-strong); background: var(--panel-2); color: var(--text-2);
  transition: .15s; user-select: none;
}
.chip:hover { border-color: var(--brand); color: var(--brand); }
.chip.on { background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 600; }
.chip .n { opacity: .6; margin-left: 3px; font-size: 11px; }

#unitSelect {
  width: 100%; padding: 6px; font-size: 12px; font-family: inherit;
  border: 1px solid var(--border-strong); border-radius: 8px;
  background: var(--panel-2); color: var(--text);
}
.hint { margin: 6px 0 0; font-size: 11px; color: var(--text-3); }

.sliderRow {
  display: grid; grid-template-columns: 1fr auto; gap: 4px 8px;
  align-items: center; margin-bottom: 12px; font-size: 12px; color: var(--text-2);
}
.sliderRow input[type=range] { grid-column: 1 / -1; width: 100%; accent-color: var(--brand); }
.sliderRow b { color: var(--brand); font-size: 13px; font-variant-numeric: tabular-nums; }
.sliderRow select {
  grid-column: 1 / -1; width: 100%; padding: 5px 8px; font-size: 12px;
  font-family: inherit; border: 1px solid var(--border-strong);
  border-radius: 7px; background: var(--panel-2); color: var(--text);
}
#paperKw {
  width: 100%; padding: 7px 11px; font-size: 13px; font-family: inherit;
  border: 1px solid var(--border-strong); border-radius: 8px;
  background: var(--panel-2); outline: none;
}
#paperKw:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }

/* ---------- 统计条 ---------- */
.main { flex: 1; display: flex; flex-direction: column; min-width: 0; padding: 16px 20px 0; }
.statBar { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.stat {
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 9px 15px; box-shadow: var(--shadow); min-width: 104px;
}
.stat .v { font-size: 19px; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: -.4px; }
.stat .k { font-size: 11px; color: var(--text-3); margin-top: 1px; }
.stat.hl .v { color: var(--brand); }

/* ---------- 表格 ---------- */
.tableWrap {
  flex: 1; overflow: auto; background: var(--panel);
  border: 1px solid var(--border); border-radius: var(--radius) var(--radius) 0 0;
  box-shadow: var(--shadow);
}
.tbl { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13px; }
.tbl thead th {
  position: sticky; top: 0; z-index: 2; background: #f7f9fc;
  text-align: left; padding: 10px 12px; font-size: 11.5px; font-weight: 700;
  color: var(--text-2); white-space: nowrap; border-bottom: 1px solid var(--border);
  user-select: none;
}
.tbl thead th.sortable { cursor: pointer; }
.tbl thead th.sortable:hover { color: var(--brand); }
.tbl thead th.sorted::after { content: ' ▾'; color: var(--brand); }
.tbl thead th.sorted.asc::after { content: ' ▴'; }

.tbl tbody tr { border-bottom: 1px solid #eef1f5; cursor: pointer; transition: background .12s; }
.tbl tbody tr:hover { background: #f7faff; }
.tbl tbody tr.sel { background: var(--brand-soft); }
.tbl td { padding: 9px 12px; vertical-align: middle; }

.colRank { width: 76px; }
.score {
  display: inline-block; min-width: 42px; text-align: center;
  padding: 3px 8px; border-radius: 6px; font-weight: 700; font-size: 13px;
  font-variant-numeric: tabular-nums;
}
.score.s5 { background: #fdecec; color: var(--up); }
.score.s4 { background: #fdf3e0; color: var(--gold); }
.score.s3 { background: #e8f0fb; color: var(--brand); }
.score.s2 { background: #eef2f7; color: var(--text-2); }
.score.s1, .score.s0 { background: #f2f4f7; color: var(--text-3); }

.colName { min-width: 88px; white-space: nowrap; }
.nm { font-weight: 600; }
.colUnit {
  max-width: 190px; min-width: 130px; font-size: 12px; color: var(--text-2);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.colTitle { white-space: nowrap; font-size: 12px; }
.colFlag { white-space: nowrap; }
.tbl td { overflow: hidden; }
.colFlag { white-space: nowrap; }
.colNum { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.colDir {
  max-width: 280px; min-width: 180px; font-size: 12px; color: var(--text-2);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.colLink { white-space: nowrap; }

.tag {
  display: inline-block; padding: 1px 7px; border-radius: 5px;
  font-size: 11px; font-weight: 600; margin-right: 3px; white-space: nowrap;
}
.tag.doc { background: #fdecec; color: var(--up); }
.tag.mas { background: var(--brand-soft); color: var(--brand); }
.tag.quota { background: #e7f6ec; color: var(--down); }
.tag.honor { background: #fdf3e0; color: var(--gold); }
.tag.none { background: #f2f4f7; color: var(--text-3); }

.num { font-weight: 600; }
.num.zero { color: var(--text-3); font-weight: 400; }
.num.good { color: var(--up); }
.link { color: var(--brand); text-decoration: none; font-size: 12px; }
.link:hover { text-decoration: underline; }

.empty { padding: 60px 20px; text-align: center; color: var(--text-3); font-size: 13px; }

.pager {
  display: flex; gap: 5px; justify-content: center; align-items: center;
  padding: 12px 0 16px; flex-wrap: wrap;
}
.pg {
  min-width: 30px; height: 30px; padding: 0 9px; border: 1px solid var(--border-strong);
  background: var(--panel); border-radius: 7px; cursor: pointer; font-size: 12.5px;
  font-family: inherit; color: var(--text-2);
}
.pg:hover:not(:disabled) { border-color: var(--brand); color: var(--brand); }
.pg.on { background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 600; }
.pg:disabled { opacity: .4; cursor: default; }
.pgInfo { font-size: 12px; color: var(--text-3); padding: 0 8px; }

/* ---------- 抽屉 ---------- */
.drawerMask { position: fixed; inset: 0; background: rgba(18, 28, 45, .38); z-index: 40; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: 620px; max-width: 94vw;
  background: var(--panel); z-index: 41; overflow-y: auto;
  box-shadow: -8px 0 32px rgba(18, 28, 45, .16);
  animation: slideIn .2s ease;
}
/* 抽屉以叠加方式覆盖右侧，表格保持原宽（避免列被挤压换行） */
body.drawerOpen .drawerMask { background: rgba(18, 28, 45, .18); }
@keyframes slideIn { from { transform: translateX(28px); opacity: .4; } to { transform: none; opacity: 1; } }
.drawerClose {
  position: absolute; top: 14px; right: 16px; width: 30px; height: 30px;
  border: none; background: var(--panel-2); border-radius: 7px; cursor: pointer;
  font-size: 19px; color: var(--text-2); line-height: 1; z-index: 2;
}
.drawerClose:hover { background: #e7ebf1; color: var(--text); }
.drawerBody { padding: 26px 26px 50px; }

.dHead { margin-bottom: 18px; padding-right: 36px; }
.dHead h2 { margin: 0 0 5px; font-size: 21px; font-weight: 700; }
.dHead .dUnit { color: var(--text-2); font-size: 13px; }
.dTags { margin-top: 9px; display: flex; flex-wrap: wrap; gap: 5px; }

.dScoreRow { display: flex; gap: 9px; margin-bottom: 20px; }
.dScore {
  flex: 1; background: var(--panel-2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 11px 13px;
}
.dScore .v { font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums; }
.dScore .k { font-size: 11px; color: var(--text-3); }

.dSection { margin-bottom: 22px; }
.dSection h4 {
  margin: 0 0 9px; font-size: 12px; font-weight: 700; color: var(--text-3);
  text-transform: uppercase; letter-spacing: .7px;
  padding-bottom: 6px; border-bottom: 1px solid var(--border);
}
.dList { margin: 0; padding: 0; list-style: none; }
.dList li {
  padding: 8px 0; border-bottom: 1px dashed #eef1f5; font-size: 13px;
  display: flex; gap: 10px; align-items: flex-start; line-height: 1.5;
}
.dList li:last-child { border-bottom: none; }
.dList .lv {
  flex-shrink: 0; width: 22px; text-align: center; font-size: 10.5px; font-weight: 700;
  padding: 2px 0; border-radius: 4px; background: var(--brand-soft); color: var(--brand);
  margin-top: 2px;
}
.dList .lv.l9, .dList .lv.l10 { background: #fdecec; color: var(--up); }
.dList .lv.l7, .dList .lv.l8 { background: #fdf3e0; color: var(--gold); }
.dList .tt { flex: 1; min-width: 0; }
.dList .tt > div:first-child { color: var(--text); }
.dList .mt { font-size: 11.5px; color: var(--text-3); margin-top: 3px; }

.kv { display: grid; grid-template-columns: 88px 1fr; gap: 6px 12px; font-size: 13px; }
.kv dt { color: var(--text-3); font-size: 12.5px; }
.kv dd { margin: 0; word-break: break-word; }

.introBox {
  background: var(--panel-2); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 12px 14px; font-size: 13px; line-height: 1.72; color: var(--text-2);
  max-height: 320px; overflow-y: auto; white-space: pre-wrap;
}

.bars { display: flex; flex-direction: column; gap: 8px; }
.barRow { display: grid; grid-template-columns: 68px 1fr 42px; gap: 9px; align-items: center; font-size: 12px; }
.barTrack { height: 7px; background: #eef1f5; border-radius: 4px; overflow: hidden; }
.barFill { height: 100%; background: var(--brand); border-radius: 4px; }
.barVal { text-align: right; color: var(--text-2); font-variant-numeric: tabular-nums; }

@media (max-width: 900px) {
  .sidebar { width: 210px; }
  .topbar { flex-wrap: wrap; gap: 10px; }
  #searchBox { width: 100%; }
}

/* ---------- 加载动画 ---------- */
.splash {
  position: fixed; inset: 0; z-index: 9999;
  display: grid; place-items: center;
  background: radial-gradient(circle at 50% 42%, #17335e 0%, #0d1b2e 55%, #08111d 100%);
  transition: opacity .55s ease, visibility .55s ease;
}
.splash.hide { opacity: 0; visibility: hidden; pointer-events: none; }

.splashInner { display: flex; flex-direction: column; align-items: center; gap: 16px; padding: 24px; }
.splashLogo { position: relative; width: 152px; height: 152px; filter: drop-shadow(0 0 18px rgba(90,170,255,.35)); }

.ring { stroke-linecap: round; transform-origin: 60px 60px; }
.ring1 { stroke: rgba(100,175,255,.95); stroke-width: 2.6; stroke-dasharray: 88 239; animation: spin 2.4s linear infinite; }
.ring2 { stroke: rgba(130,220,255,.8); stroke-width: 2.2; stroke-dasharray: 62 189; animation: spin 1.7s linear infinite reverse; }
.ring3 { stroke: rgba(190,225,255,.5); stroke-width: 1.8; stroke-dasharray: 36 140; animation: spin 1.15s linear infinite; }

.splashMark { font: 700 19px/1 var(--font-sans, sans-serif); fill: #f4f9ff; letter-spacing: 1px; }

@keyframes spin { to { transform: rotate(360deg); } }

.splashTitle {
  margin: 10px 0 0; font-size: 22px; font-weight: 600; color: #eef5ff;
  letter-spacing: 1.2px; text-shadow: 0 0 24px rgba(120,190,255,.35);
}
.splashSub {
  margin: 0; font-size: 13px; color: #9dc0e8; min-height: 19px;
  transition: color .3s; letter-spacing: .4px;
}

.splashBar {
  width: 300px; height: 3.5px; margin-top: 10px;
  background: rgba(255,255,255,.12); border-radius: 3px; overflow: hidden;
}
.splashBarFill {
  width: 0%; height: 100%; border-radius: 3px;
  background: linear-gradient(90deg, #3b8eea, #7fd4ff);
  transition: width .45s cubic-bezier(.3,.8,.3,1);
  box-shadow: 0 0 12px rgba(120,200,255,.55);
}

.splashSteps { display: flex; gap: 18px; margin-top: 4px; }
.splashSteps .step {
  font-size: 11px; color: #5b7899; letter-spacing: .5px;
  position: relative; transition: color .3s;
}
.splashSteps .step.done { color: #7fd4ff; }
.splashSteps .step.done::before { content: "✓ "; }
.splashSteps .step.active { color: #cfe6ff; animation: pulse 1.2s ease-in-out infinite; }
.splashSteps .step.active::before { content: "◌ "; }

@keyframes pulse { 0%,100% { opacity: .5; } 50% { opacity: 1; } }

@media (prefers-reduced-motion: reduce) {
  .ring1, .ring2, .ring3 { animation: none; }
  .splashSteps .step.active { animation: none; }
}

/* 详情按需加载提示 */
.dLoading {
  padding: 60px 24px; text-align: center;
  color: var(--text-3); font-size: 13px;
}
.dLoading::before {
  content: ""; display: block; width: 28px; height: 28px; margin: 0 auto 14px;
  border: 2.5px solid var(--border-strong); border-top-color: var(--brand);
  border-radius: 50%; animation: spin .9s linear infinite;
}
