:root {
  --bg: #0a0f1e;
  --bg2: #0e1527;
  --panel: #121a2f;
  --panel2: #16203a;
  --line: rgba(255, 255, 255, .08);
  --line2: rgba(255, 255, 255, .14);
  --txt: #e9eefb;
  --muted: #8b98b4;
  --blue: #5b8cff;
  --teal: #22d3a7;
  --gold: #ffb020;
  --purple: #b47cff;
  --pink: #ff5d8f;
  --red: #ff5f6d;
  --radius: 16px;
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  background:
    radial-gradient(1100px 520px at 12% -8%, rgba(91, 140, 255, .22), transparent 62%),
    radial-gradient(900px 480px at 88% -12%, rgba(180, 124, 255, .16), transparent 60%),
    var(--bg);
  color: var(--txt);
  font-family: "PingFang SC", "Microsoft YaHei", "Segoe UI", system-ui, sans-serif;
  font-size: 14px;
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

.wrap { max-width: 1320px; margin: 0 auto; padding: 0 22px 60px; }

/* ---------- 顶部 ---------- */
.topbar {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 18px; flex-wrap: wrap; padding: 34px 0 18px;
}
.brand { display: flex; align-items: center; gap: 14px; }
.logo {
  width: 46px; height: 46px; border-radius: 14px; flex: none;
  background: linear-gradient(140deg, #5b8cff, #9a5cff 55%, #ff5d8f);
  display: grid; place-items: center; font-weight: 800; font-size: 17px;
  box-shadow: 0 10px 26px rgba(91, 140, 255, .35);
}
h1 { font-size: 21px; margin: 0; letter-spacing: .4px; }
.sub { color: var(--muted); font-size: 12.5px; margin-top: 2px; }
.meta { display: flex; gap: 8px; flex-wrap: wrap; }
.pill {
  border: 1px solid var(--line2); background: rgba(255, 255, 255, .04);
  color: var(--muted); border-radius: 999px; padding: 5px 12px; font-size: 12px;
  white-space: nowrap;
}
.pill b { color: var(--txt); font-weight: 600; }

/* ---------- 标签页 ---------- */
.tabs {
  display: flex; gap: 6px; flex-wrap: wrap; margin: 8px 0 22px;
  padding: 6px; border-radius: 14px; border: 1px solid var(--line);
  background: rgba(18, 26, 47, .7); backdrop-filter: blur(8px);
  width: fit-content; max-width: 100%;
}
.tab-btn {
  border: 0; background: transparent; color: var(--muted); cursor: pointer;
  padding: 8px 16px; border-radius: 10px; font-size: 13.5px; font-family: inherit;
  transition: .18s;
}
.tab-btn:hover { color: var(--txt); background: rgba(255, 255, 255, .05); }
.tab-btn.active {
  color: #fff; background: linear-gradient(135deg, #3d6bff, #7b53ff);
  box-shadow: 0 8px 20px rgba(75, 110, 255, .32);
}

.tab-panel { display: none; animation: fade .28s ease; }
.tab-panel.active { display: block; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ---------- 卡片 ---------- */
.card {
  background: linear-gradient(180deg, rgba(22, 32, 58, .95), rgba(17, 24, 44, .95));
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px 20px; box-shadow: 0 16px 40px rgba(0, 0, 0, .28);
}
.card-h { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.card-h h2 { font-size: 15px; margin: 0; font-weight: 600; letter-spacing: .3px; }
.card-h .hint { color: var(--muted); font-size: 12px; }

.grid { display: grid; gap: 16px; }
.g-kpi { grid-template-columns: repeat(auto-fit, minmax(158px, 1fr)); margin-bottom: 16px; }
.g-2 { grid-template-columns: 1.25fr 1fr; }
.g-2b { grid-template-columns: 1fr 1.2fr; }
.g-3 { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
@media (max-width: 860px) { .g-2, .g-2b { grid-template-columns: 1fr; } }

.kpi { position: relative; overflow: hidden; }
.kpi .k-label { color: var(--muted); font-size: 12px; }
.kpi .k-val { font-size: 30px; font-weight: 700; letter-spacing: -.5px; margin-top: 2px; line-height: 1.15; }
.kpi .k-val small { font-size: 14px; font-weight: 500; color: var(--muted); margin-left: 3px; }
.kpi .k-foot { color: var(--muted); font-size: 11.5px; margin-top: 2px; }
.kpi::after {
  content: ""; position: absolute; inset: auto -30px -50px auto; width: 130px; height: 130px;
  border-radius: 50%; background: radial-gradient(circle, rgba(91, 140, 255, .22), transparent 70%);
}
.kpi.teal::after { background: radial-gradient(circle, rgba(34, 211, 167, .2), transparent 70%); }
.kpi.gold::after { background: radial-gradient(circle, rgba(255, 176, 32, .2), transparent 70%); }
.kpi.purple::after { background: radial-gradient(circle, rgba(180, 124, 255, .2), transparent 70%); }

/* ---------- 横向条形 ---------- */
.hbars { display: flex; flex-direction: column; gap: 9px; }
.hb { display: grid; grid-template-columns: 92px 1fr 122px; align-items: center; gap: 10px; font-size: 12.5px; }
.hb .hb-name { color: var(--txt); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hb .hb-track { height: 9px; border-radius: 6px; background: rgba(255, 255, 255, .06); overflow: hidden; }
.hb .hb-fill {
  height: 100%; border-radius: 6px; width: 0;
  background: linear-gradient(90deg, #4a7dff, #7b53ff);
}
.hb .hb-val { text-align: right; color: var(--txt); font-variant-numeric: tabular-nums; white-space: nowrap; }
.hb .hb-val em { color: var(--muted); font-style: normal; font-size: 10.5px; margin-left: 5px; }
.hb.clickable { cursor: pointer; }
.hb.clickable:hover .hb-name { color: #9fc0ff; }

/* ---------- 图例/环形 ---------- */
.donut-wrap { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.legend { display: flex; flex-direction: column; gap: 8px; flex: 1; min-width: 130px; }
.lg { display: flex; align-items: center; gap: 8px; font-size: 12.5px; }
.lg .dot { width: 9px; height: 9px; border-radius: 3px; flex: none; }
.lg .lg-name { color: var(--muted); }
.lg .lg-val { margin-left: auto; font-variant-numeric: tabular-nums; }

svg { display: block; width: 100%; height: auto; overflow: visible; }

/* ---------- 表格 ---------- */
.table-wrap { overflow: auto; max-height: 620px; border-radius: 12px; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead th {
  position: sticky; top: 0; z-index: 2; text-align: left; font-weight: 600; font-size: 12px;
  color: var(--muted); background: #16203a; padding: 10px 10px; white-space: nowrap;
  border-bottom: 1px solid var(--line2);
}
thead th.sortable { cursor: pointer; user-select: none; }
thead th.sortable:hover { color: var(--txt); }
thead th .arrow { font-size: 10px; opacity: .5; margin-left: 3px; }
thead th.sorted .arrow { opacity: 1; color: var(--blue); }
tbody td { padding: 9px 10px; border-bottom: 1px solid rgba(255, 255, 255, .05); white-space: nowrap; }
tbody tr:hover { background: rgba(91, 140, 255, .08); }
tbody tr.rank-tr { cursor: pointer; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.name-cell { display: flex; align-items: center; gap: 8px; }
.rank-badge {
  width: 22px; height: 22px; border-radius: 7px; display: grid; place-items: center;
  font-size: 11px; font-weight: 700; background: rgba(255, 255, 255, .07); color: var(--muted); flex: none;
}
.rank-badge.t1 { background: linear-gradient(135deg, #ffb020, #ff7a1a); color: #241300; }
.rank-badge.t2 { background: linear-gradient(135deg, #cfd8e8, #9aa8bf); color: #1b2130; }
.rank-badge.t3 { background: linear-gradient(135deg, #e08a4b, #b8642c); color: #241300; }

.grade { font-weight: 700; font-size: 12px; padding: 1px 8px; border-radius: 6px; display: inline-block; }
.grade.S { color: #ffcf5c; background: rgba(255, 176, 32, .15); }
.grade.A { color: #6fd4ff; background: rgba(91, 140, 255, .16); }
.grade.B { color: #6fe3bd; background: rgba(34, 211, 167, .14); }
.grade.C { color: #c9b3ff; background: rgba(180, 124, 255, .14); }
.grade.D { color: #ff97a8; background: rgba(255, 95, 109, .14); }

.tag { font-size: 11px; padding: 1px 7px; border-radius: 6px; background: rgba(255, 176, 32, .12); color: #ffcf8a; border: 1px solid rgba(255, 176, 32, .25); }

/* ---------- 控件 ---------- */
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
input[type="search"], select {
  background: #101829; border: 1px solid var(--line2); color: var(--txt);
  border-radius: 10px; padding: 8px 12px; font-size: 13px; font-family: inherit; outline: none;
}
input[type="search"] { min-width: 190px; }
input[type="search"]:focus, select:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(91, 140, 255, .16); }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  border: 1px solid var(--line2); background: rgba(255, 255, 255, .03); color: var(--muted);
  border-radius: 999px; padding: 5px 12px; font-size: 12.5px; cursor: pointer; font-family: inherit;
}
.chip.on { background: rgba(91, 140, 255, .18); border-color: rgba(91, 140, 255, .55); color: #cfe0ff; }

/* ---------- 提示框 ---------- */
.tip {
  position: fixed; top: 0; left: 0; z-index: 99; pointer-events: none; opacity: 0;
  transition: opacity .12s; background: #0b1224; border: 1px solid var(--line2);
  border-radius: 10px; padding: 8px 11px; font-size: 12px; line-height: 1.5;
  box-shadow: 0 14px 30px rgba(0, 0, 0, .5); max-width: 260px;
}
.tip b { color: #9fc0ff; }

/* ---------- 弹层 ---------- */
.modal {
  position: fixed; inset: 0; z-index: 80; display: none;
  background: rgba(5, 9, 18, .72); backdrop-filter: blur(4px);
  padding: 30px 18px; overflow: auto;
}
.modal.open { display: block; }
.modal-box {
  max-width: 940px; margin: 0 auto; background: linear-gradient(180deg, #16203a, #0f1729);
  border: 1px solid var(--line2); border-radius: 18px; padding: 22px 24px;
  box-shadow: 0 30px 70px rgba(0, 0, 0, .6); animation: fade .22s ease;
}
.modal-h { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; margin-bottom: 16px; }
.modal-h h3 { margin: 0; font-size: 19px; }
.modal-h .id { color: var(--muted); font-size: 12px; margin-top: 2px; }
.close {
  border: 1px solid var(--line2); background: rgba(255, 255, 255, .05); color: var(--txt);
  width: 32px; height: 32px; border-radius: 9px; cursor: pointer; font-size: 16px; line-height: 1; flex: none;
}
.close:hover { background: rgba(255, 95, 109, .2); border-color: rgba(255, 95, 109, .5); }
.mini-kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(134px, 1fr)); gap: 10px; margin-bottom: 16px; }
.mini-kpis div { background: rgba(255, 255, 255, .04); border: 1px solid var(--line); border-radius: 11px; padding: 9px 11px; }
.mini-kpis div > span:first-child { display: block; color: var(--muted); font-size: 11.5px; white-space: nowrap; }
.mini-kpis b { display: block; font-size: 17px; font-weight: 650; font-variant-numeric: tabular-nums; white-space: nowrap; }
.mini-kpis .grade { font-size: 10.5px; vertical-align: 3px; }
.modal-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
@media (max-width: 780px) { .modal-grid { grid-template-columns: 1fr; } }

.note-list { display: grid; gap: 10px; }
.note { display: grid; grid-template-columns: 150px 1fr; gap: 14px; padding: 11px 0; border-bottom: 1px dashed var(--line); font-size: 13px; }
.note:last-child { border-bottom: 0; }
.note .n-k { color: #9fc0ff; }
.note .n-v { color: #c8d2e6; }
@media (max-width: 640px) { .note { grid-template-columns: 1fr; gap: 2px; } }

.pager { display: flex; align-items: center; gap: 10px; justify-content: flex-end; margin-top: 12px; font-size: 12.5px; }
.pager button {
  background: rgba(255, 255, 255, .05); border: 1px solid var(--line2); color: var(--txt);
  border-radius: 8px; padding: 5px 11px; cursor: pointer; font-family: inherit; font-size: 12.5px;
}
.pager button:disabled { opacity: .35; cursor: default; }

.empty { color: var(--muted); text-align: center; padding: 26px 0; font-size: 13px; }
footer { color: var(--muted); font-size: 12px; text-align: center; padding: 26px 0 0; }

/* ---------- 导入 Excel ---------- */
.datatools { display: flex; align-items: center; gap: 8px; flex: none; margin-left: 14px; }
.dt-btn {
  background: linear-gradient(180deg, rgba(91, 140, 255, .28), rgba(91, 140, 255, .14));
  border: 1px solid rgba(91, 140, 255, .5); color: #dbe6ff; border-radius: 10px;
  padding: 7px 13px; font-family: inherit; font-size: 12.5px; cursor: pointer; white-space: nowrap;
}
.dt-btn:hover { background: rgba(91, 140, 255, .34); border-color: rgba(91, 140, 255, .8); }

.import-banner {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px;
  margin: 14px 0 0; padding: 11px 14px; border-radius: 12px; font-size: 12.5px;
  background: rgba(255, 176, 32, .1); border: 1px solid rgba(255, 176, 32, .35); color: #f3e2c0;
}
.import-banner .ib-text { flex: 1 1 340px; line-height: 1.7; }
.import-banner .ib-dim { display: block; color: rgba(255, 255, 255, .55); font-size: 11.5px; }
.import-banner .ib-warn { display: block; color: #ff9db0; font-size: 11.5px; }
.import-banner .ib-actions { display: flex; gap: 8px; flex: none; }
.import-banner button {
  background: rgba(255, 255, 255, .07); border: 1px solid rgba(255, 255, 255, .22); color: var(--txt);
  border-radius: 9px; padding: 6px 11px; font-family: inherit; font-size: 12px; cursor: pointer; white-space: nowrap;
}
.import-banner button:hover { background: rgba(255, 255, 255, .14); }

.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translate(-50%, 14px);
  max-width: min(560px, calc(100vw - 36px)); padding: 12px 16px; border-radius: 12px;
  background: rgba(18, 26, 47, .97); border: 1px solid var(--line2); color: var(--txt);
  font-size: 13px; line-height: 1.6; box-shadow: 0 18px 44px rgba(0, 0, 0, .55);
  opacity: 0; pointer-events: none; transition: opacity .18s, transform .18s; z-index: 999;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }
.toast.err { border-color: rgba(255, 95, 109, .6); color: #ffd7dc; }
.toast.ok { border-color: rgba(34, 211, 167, .6); color: #d6fff2; }

@media (max-width: 620px) {
  .topbar { align-items: flex-start; }
  .datatools { margin-left: 0; }
}
