:root {
  --bg: #f4f5f7;
  --card: #ffffff;
  --border: #e5e7eb;
  --border-strong: #d5d8de;
  --text: #1b1f27;
  --text-2: #5b6472;
  --text-3: #8a92a0;
  --navy: #1f3864;
  --navy-2: #2e5496;
  --blue: #378add;
  --teal: #1d9e75;
  --amber: #c47d16;
  --red: #c0261f;
  --red-bg: #fdf1f0;
  --green: #1e8e5a;
  --green-bg: #eff8f2;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 1px 3px rgba(16, 24, 40, .03);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

.wrap { max-width: 1480px; margin: 0 auto; padding: 0 24px 56px; }

/* ---------- 顶栏 ---------- */
header.topbar {
  position: sticky; top: 0; z-index: 40;
  background: rgba(244, 245, 247, .92);
  backdrop-filter: saturate(180%) blur(8px);
  border-bottom: 1px solid var(--border);
}
.topbar-inner {
  max-width: 1480px; margin: 0 auto; padding: 14px 24px;
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
}
.brand { display: flex; align-items: baseline; gap: 10px; flex: 1 1 320px; min-width: 0; }
.brand h1 { font-size: 19px; font-weight: 600; margin: 0; letter-spacing: .2px; white-space: nowrap; }
.brand .sub { font-size: 12px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; flex: 1 1 auto; }

.update-box { display: flex; align-items: center; gap: 12px; }
.update-meta { text-align: right; font-size: 12px; color: var(--text-2); line-height: 1.4; }
.update-meta b { font-weight: 500; color: var(--text); font-variant-numeric: tabular-nums; }
.status { display: inline-flex; align-items: center; gap: 5px; }
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--green); display: inline-block; }
.dot.warn { background: var(--amber); }
.dot.bad { background: var(--red); }
.dot.busy { background: var(--blue); animation: pulse 1s infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .3; } }

button.btn {
  font: inherit; font-size: 13px; padding: 8px 14px; border-radius: 8px;
  border: 1px solid var(--border-strong); background: #fff; color: var(--text);
  cursor: pointer; transition: .15s; white-space: nowrap;
}
button.btn:hover { border-color: var(--navy-2); color: var(--navy-2); }
button.btn:disabled { opacity: .55; cursor: not-allowed; }
button.btn.primary { background: var(--navy); border-color: var(--navy); color: #fff; }
button.btn.primary:hover { background: var(--navy-2); border-color: var(--navy-2); color: #fff; }

/* ---------- 筛选栏 ---------- */
.toolbar {
  position: sticky; top: 61px; z-index: 30;
  background: #fff; border: 1px solid var(--border); border-radius: var(--radius);
  padding: 12px 16px; margin: 16px 0 20px;
  display: flex; align-items: center; gap: 18px; flex-wrap: wrap;
  box-shadow: var(--shadow);
}
.tool-group { display: flex; align-items: center; gap: 8px; }
.tool-group > label { font-size: 12px; color: var(--text-3); white-space: nowrap; }
select, input[type="number"] {
  font: inherit; font-size: 13px; padding: 6px 8px; border: 1px solid var(--border-strong);
  border-radius: 7px; background: #fff; color: var(--text); outline: none;
}
select:focus, input[type="number"]:focus { border-color: var(--navy-2); }
input[type="number"] { width: 62px; text-align: center; }

.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  font-size: 12.5px; padding: 5px 11px; border-radius: 999px; cursor: pointer;
  border: 1px solid var(--border-strong); background: #fff; color: var(--text-2);
  transition: .15s; user-select: none;
}
.chip:hover { border-color: var(--navy-2); color: var(--navy-2); }
.chip.on { background: var(--navy); border-color: var(--navy); color: #fff; }
.spacer { flex: 1 1 auto; }

/* ---------- 区块 ---------- */
section.block { margin: 26px 0 0; }
.block-head { display: flex; align-items: baseline; gap: 10px; margin: 0 0 12px; flex-wrap: wrap; }
.block-head h2 {
  font-size: 15px; font-weight: 600; margin: 0; letter-spacing: .2px;
  display: flex; align-items: center; gap: 8px;
}
.block-head h2 .idx {
  display: inline-flex; align-items: center; justify-content: center;
  width: 20px; height: 20px; border-radius: 6px; background: var(--navy); color: #fff;
  font-size: 11.5px; font-weight: 600;
}
.block-head .hint { font-size: 12px; color: var(--text-3); }

.card {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 16px;
}

/* ---------- 月度 KPI ---------- */
.month-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(238px, 1fr)); gap: 14px; }
.mcard {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 14px 16px 12px; position: relative; overflow: hidden;
}
.mcard::before {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--navy);
}
.mcard.is-latest::before { background: var(--blue); }
.mcard h3 { margin: 0 0 2px; font-size: 13px; font-weight: 600; color: var(--text-2); }
.mcard .exams { font-size: 11.5px; color: var(--text-3); margin-bottom: 10px; }
.mrow { display: flex; align-items: flex-end; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
.mrow > div { min-width: 0; }
.metric-name { font-size: 12px; color: var(--text-3); }
.metric-val { font-size: 25px; font-weight: 600; letter-spacing: -.4px; font-variant-numeric: tabular-nums; line-height: 1.1; white-space: nowrap; }
.metric-val small { font-size: 14px; font-weight: 500; margin-left: 1px; }
.mrow.right { text-align: right; flex-direction: column; align-items: flex-end; gap: 1px; }
.delta { font-size: 12px; font-weight: 500; white-space: nowrap; }
.delta.up { color: var(--green); }
.delta.down { color: var(--red); }
.delta.flat { color: var(--text-3); }
.mfoot { border-top: 1px dashed var(--border); margin-top: 10px; padding-top: 8px; font-size: 11.5px; color: var(--text-3); display: flex; justify-content: space-between; gap: 8px; }

/* ---------- 图表 ---------- */
.chart-row { display: grid; grid-template-columns: 1.25fr 1fr; gap: 14px; margin-top: 14px; }
@media (max-width: 1080px) { .chart-row { grid-template-columns: 1fr; } }
.chart-card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px 16px 8px; }
.chart-card h4 { margin: 0 0 2px; font-size: 13px; font-weight: 600; }
.chart-card .cap { font-size: 11.5px; color: var(--text-3); margin-bottom: 10px; }
.chart-legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 11.5px; color: var(--text-2); margin-bottom: 6px; }
.chart-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 5px; vertical-align: -1px; }
svg.chart { display: block; width: 100%; height: auto; overflow: visible; }
svg.chart text { font-family: inherit; }

/* ---------- 表格 ---------- */
.table-wrap { overflow-x: auto; }
.table-wrap.scroll { max-height: 520px; overflow-y: auto; }
.table-wrap.scroll thead th { box-shadow: inset 0 -1px 0 var(--border); }
table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13px; }
thead th {
  position: sticky; top: 0; z-index: 2;
  background: #f7f8fa; color: var(--text-2); font-weight: 500; font-size: 12px;
  text-align: right; padding: 9px 10px; border-bottom: 1px solid var(--border);
  white-space: nowrap; cursor: pointer; user-select: none;
}
thead th:first-child, thead th.txt { text-align: left; }
thead th:hover { color: var(--navy-2); }
thead th .arrow { color: var(--text-3); font-size: 10px; margin-left: 3px; }
thead th.sorted .arrow { color: var(--navy); }
tbody td { padding: 8px 10px; border-bottom: 1px solid #f0f1f4; text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
tbody td.txt { text-align: left; }
tbody tr:hover { background: #fafbfc; }
tbody tr:last-child td { border-bottom: none; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--text-3); }
.strong { font-weight: 600; }
.bad-val { color: var(--red); font-weight: 600; }
.good-val { color: var(--green); }
tr.row-warn { background: var(--red-bg); }
tr.row-warn:hover { background: #fbe9e7; }
tr.row-streak { background: #fff7ea; }
tr.row-streak:hover { background: #fdf0dc; }

td.pplcell { white-space: normal; min-width: 380px; line-height: 1.9; }
td.pplcell .plist { margin-left: 6px; color: var(--text-2); }
td.pplcell .pn { color: var(--text); }
td.pplcell .sc { font-weight: 600; color: var(--red); font-variant-numeric: tabular-nums; }
td.nowrap { white-space: nowrap; }

.streak-list { display: flex; flex-wrap: wrap; gap: 8px; padding: 2px 0 6px; }
.streak-list .sitem {
  font-size: 12.5px; padding: 5px 12px; border-radius: 7px;
  background: #fdf0dc; color: #8a5312; border: 1px solid #f0e0c0;
  white-space: nowrap;
}
svg.spark { display: block; }
.tag {
  display: inline-block; font-size: 11px; line-height: 1.5; padding: 1px 7px; border-radius: 5px;
  background: #eef1f6; color: var(--text-2); white-space: nowrap;
}
.tag.red { background: #fbe4e2; color: #a11c16; }
.tag.amber { background: #fdf0dc; color: #96601a; }
.tag.blue { background: #e8f1fc; color: #1f5fa8; }
.tag.green { background: var(--green-bg); color: #166b45; }
.tag.grey { background: #f0f1f4; color: var(--text-3); }

/* ---------- 汇总条 ---------- */
.sumbar { display: flex; gap: 22px; flex-wrap: wrap; padding: 10px 4px 14px; font-size: 12.5px; color: var(--text-2); align-items: center; }
.sumbar b { font-size: 17px; font-weight: 600; color: var(--text); margin-right: 4px; font-variant-numeric: tabular-nums; }
.sumbar .unit { color: var(--text-3); font-size: 11.5px; }
.sumbar .sep { width: 1px; height: 20px; background: var(--border); }

/* ---------- 提示 ---------- */
.banner {
  border-radius: var(--radius); padding: 11px 14px; font-size: 13px; margin: 14px 0 0;
  border: 1px solid; display: flex; gap: 10px; align-items: flex-start;
}
.banner.err { background: var(--red-bg); border-color: #f2c9c5; color: #8f1c16; }
.banner.warn { background: #fdf8ec; border-color: #f0e2bd; color: #7a5a16; }
.banner.ok { background: var(--green-bg); border-color: #cfe8da; color: #166b45; }
.banner b { font-weight: 600; }

details.issues { margin-top: 14px; border: 1px solid var(--border); border-radius: var(--radius); background: #fff; padding: 0; }
details.issues > summary {
  cursor: pointer; padding: 11px 14px; font-size: 13px; font-weight: 500; list-style: none;
  display: flex; align-items: center; gap: 8px;
}
details.issues > summary::-webkit-details-marker { display: none; }
details.issues > summary::after { content: "展开"; margin-left: auto; font-size: 12px; color: var(--text-3); font-weight: 400; }
details.issues[open] > summary::after { content: "收起"; }
.issue-list { border-top: 1px solid var(--border); max-height: 320px; overflow: auto; }
.issue { display: flex; gap: 10px; padding: 8px 14px; border-bottom: 1px solid #f3f4f6; font-size: 12.5px; }
.issue:last-child { border-bottom: none; }
.issue .f { color: var(--text-2); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 11.5px; flex: 0 0 46%; word-break: break-all; }
.issue .m { color: var(--text-2); }

.empty { text-align: center; padding: 46px 20px; color: var(--text-3); font-size: 13px; }
.empty .big { font-size: 15px; color: var(--text-2); margin-bottom: 6px; }

footer.foot { margin-top: 34px; padding-top: 16px; border-top: 1px solid var(--border); font-size: 11.5px; color: var(--text-3); line-height: 1.8; }

.toast {
  position: fixed; right: 24px; bottom: 24px; z-index: 99;
  background: #1b1f27; color: #fff; font-size: 13px; padding: 10px 16px; border-radius: 9px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .18); opacity: 0; transform: translateY(8px);
  transition: .22s; pointer-events: none; max-width: 420px;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast.err { background: #8f1c16; }

/* ---------- 响应式 ---------- */
@media (max-width: 900px) {
  .wrap { padding: 0 14px 40px; }
  .topbar-inner { padding: 12px 14px; }
  .toolbar { top: 0; position: static; }
  .brand h1 { font-size: 17px; }
  .metric-val { font-size: 22px; }
  .update-meta { text-align: left; }
}
@media (max-width: 620px) {
  .month-grid { grid-template-columns: 1fr; }
  .sumbar { gap: 14px; }
  .issue .f { flex-basis: 100%; }
  .issue { flex-direction: column; gap: 2px; }
  .brand .sub { display: none; }
  .brand h1 { font-size: 16px; }
  .brand { flex: 1 1 auto; }
  .update-box { gap: 8px; }
  .update-meta { font-size: 11px; }
  button.btn { padding: 7px 11px; font-size: 12.5px; }
}
