:root {
  --bg: #f6f7f9;
  --card: #ffffff;
  --line: #e8e9ed;
  --line-soft: #f0f1f4;
  --text: #1d1e22;
  --text-2: #5f6067;
  --text-3: #8b8d96;
  --accent: #185fa5;
  --accent-soft: #e6f1fb;
  --warn: #854f0b;
  --warn-soft: #faeeda;
  --warn-line: #fac775;
  --radius: 12px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Helvetica Neue",
               "Microsoft YaHei", "Source Han Sans SC", sans-serif;
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }

button { font-family: inherit; cursor: pointer; }

/* ---------------------------------------------------------- 上传页 */

#upload-view {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px;
}

.upload-card {
  width: 100%;
  max-width: 620px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 40px;
  text-align: center;
}

.upload-card h1 {
  font-size: 20px;
  font-weight: 500;
  margin: 0 0 6px;
}

.upload-card .sub {
  color: var(--text-2);
  font-size: 13px;
  margin: 0 0 28px;
}

#dropzone {
  border: 1.5px dashed #cfd2da;
  border-radius: var(--radius);
  padding: 44px 24px;
  cursor: pointer;
  transition: border-color .15s, background .15s;
  background: #fbfbfc;
}

#dropzone:hover, #dropzone.over {
  border-color: var(--accent);
  background: var(--accent-soft);
}

#dropzone .big {
  font-size: 15px;
  font-weight: 500;
  margin-bottom: 6px;
}

#dropzone .small {
  font-size: 13px;
  color: var(--text-3);
}

.upload-note {
  margin-top: 20px;
  font-size: 12px;
  color: var(--text-3);
  text-align: left;
  background: #fbfbfc;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  padding: 12px 14px;
  line-height: 1.7;
}

.upload-note code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11.5px;
  background: #eef0f3;
  padding: 1px 5px;
  border-radius: 4px;
}

.spin {
  display: inline-block;
  width: 14px; height: 14px;
  border: 2px solid #cfd2da;
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: sp .7s linear infinite;
  vertical-align: -2px;
  margin-right: 6px;
}

@keyframes sp { to { transform: rotate(360deg); } }

/* ---------------------------------------------------------- 主体 */

.topbar {
  background: var(--card);
  border-bottom: 1px solid var(--line);
  padding: 14px 28px;
  display: flex;
  align-items: center;
  gap: 14px;
  position: sticky;
  top: 0;
  z-index: 20;
}

.topbar h1 {
  font-size: 15px;
  font-weight: 500;
  margin: 0;
}

.topbar .exam {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  background: var(--accent-soft);
  color: var(--accent);
  padding: 2px 8px;
  border-radius: 6px;
}

.topbar .fname {
  font-size: 12px;
  color: var(--text-3);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 260px;
}

.topbar .spacer { flex: 1; }

.btn {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--text-2);
  border-radius: 8px;
  padding: 6px 14px;
  font-size: 13px;
  transition: border-color .15s, color .15s;
}

.btn:hover { border-color: #b9bcc6; color: var(--text); }

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.btn-primary:hover { background: #134b85; color: #fff; }

.wrap {
  max-width: 1360px;
  margin: 0 auto;
  padding: 20px 28px 60px;
}

/* ---------------------------------------------------------- KPI */

.kpis {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.kpi {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
}

.kpi .label {
  font-size: 12px;
  color: var(--text-3);
}

.kpi .val {
  font-size: 24px;
  font-weight: 500;
  line-height: 1.25;
  margin-top: 2px;
  font-variant-numeric: tabular-nums;
}

.kpi .sub {
  font-size: 12px;
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
}

@media (max-width: 1100px) {
  .kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

/* ---------------------------------------------------------- 筛选 */

.filters {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.filters .ftitle {
  font-size: 12px;
  color: var(--text-3);
  margin-right: 2px;
}

select {
  font-family: inherit;
  font-size: 13px;
  color: var(--text);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 6px 10px;
  max-width: 190px;
  cursor: pointer;
}

select:focus { outline: none; border-color: var(--accent); }

.filters .active-count {
  font-size: 12px;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 3px 9px;
  border-radius: 6px;
  font-variant-numeric: tabular-nums;
}

/* ---------------------------------------------------------- 卡片与图表 */

.grid-2 {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 16px;
  margin-bottom: 16px;
}

.grid-2 .wide { grid-column: 1 / -1; }

@media (max-width: 1000px) {
  .grid-2 { grid-template-columns: minmax(0, 1fr); }
}

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

.card-head {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 4px;
}

.card-head h3 {
  font-size: 14px;
  font-weight: 500;
  margin: 0;
}

.card-head .hint {
  font-size: 12px;
  color: var(--text-3);
}

.card-head .spacer { flex: 1; }

.chart-box { position: relative; width: 100%; }

/* ---------------------------------------------------------- 图例 */

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin: 8px 0 4px;
  font-size: 12px;
  color: var(--text-2);
  font-variant-numeric: tabular-nums;
}

.legend span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.legend i {
  width: 9px; height: 9px;
  border-radius: 2px;
  display: inline-block;
}

/* ---------------------------------------------------------- 下钻 */

.drill-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
  flex-wrap: wrap;
}

.crumb {
  font-size: 12px;
  color: var(--text-2);
}

.crumb button {
  background: none;
  border: none;
  padding: 0;
  font-size: 12px;
  color: var(--accent);
  text-decoration: none;
}

.crumb button:hover { text-decoration: underline; }

.crumb .sep { color: var(--text-3); margin: 0 4px; }

.crumb .cur { color: var(--text); font-weight: 500; }

.drill-tip {
  font-size: 12px;
  color: var(--text-3);
}

.empty {
  padding: 40px 0;
  text-align: center;
  color: var(--text-3);
  font-size: 13px;
}

/* ---------------------------------------------------------- 表格 */

.tbl-wrap { overflow-x: auto; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

th {
  text-align: left;
  font-weight: 500;
  color: var(--text-3);
  font-size: 12px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
  user-select: none;
}

th.sortable { cursor: pointer; }
th.sortable:hover { color: var(--text); }
th .arrow { color: var(--accent); font-size: 10px; }

td {
  padding: 9px 10px;
  border-bottom: 1px solid var(--line-soft);
  white-space: nowrap;
}

tbody tr.main-row { cursor: pointer; }
tbody tr.main-row:hover { background: #fafbfc; }
tbody tr.main-row.open { background: var(--accent-soft); }

td.num { text-align: right; }

.bar-cell {
  position: relative;
  min-width: 130px;
}

.bar-cell .bg {
  position: absolute;
  left: 10px; top: 50%;
  transform: translateY(-50%);
  height: 16px;
  background: #e6f1fb;
  box-shadow: inset 0 0 0 1px #b9d7f2;
  border-radius: 3px;
  z-index: 0;
}

.bar-cell .fg {
  position: relative;
  z-index: 1;
  padding-left: 6px;
}

.search {
  font-family: inherit;
  font-size: 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 5px 10px;
  width: 190px;
}

.search:focus { outline: none; border-color: var(--accent); }

tr.detail-row > td {
  background: #fafbfc;
  white-space: normal;
  padding: 12px 10px 14px;
}

.detail-title {
  font-size: 12px;
  color: var(--text-3);
  margin-bottom: 8px;
}

.chip-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.chip {
  font-size: 12px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 3px 9px;
  color: var(--text-2);
  font-variant-numeric: tabular-nums;
}

/* 强基诊断：赛道详情 */
.qj-block {
  padding: 10px 0;
  border-top: 1px solid var(--line-soft);
}
.qj-block:first-child { border-top: 0; padding-top: 0; }
.qj-block:last-child { padding-bottom: 0; }

.qj-block-t {
  font-size: 12px;
  color: var(--text-3);
  margin-bottom: 8px;
}

#qj-thead th { white-space: nowrap; }
#qj-body td { font-variant-numeric: tabular-nums; }

/* ---------------------------------------------------------- 质量 */

.quality {
  background: var(--warn-soft);
  border: 1px solid var(--warn-line);
  border-radius: var(--radius);
  padding: 12px 16px;
  margin-bottom: 16px;
}

.quality-head {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: var(--warn);
}

.quality-head .spacer { flex: 1; }

.quality-head button {
  background: none;
  border: 1px solid var(--warn-line);
  border-radius: 7px;
  padding: 3px 10px;
  font-size: 12px;
  color: var(--warn);
}

.qsum {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.qtag {
  font-size: 12px;
  background: #fff;
  border: 1px solid var(--warn-line);
  border-radius: 6px;
  padding: 3px 9px;
  color: var(--warn);
  font-variant-numeric: tabular-nums;
}

.qbody { margin-top: 14px; }

.qgroup { margin-bottom: 16px; }

.qgroup h4 {
  font-size: 13px;
  font-weight: 500;
  margin: 0 0 6px;
  color: var(--text);
}

.qgroup .desc {
  font-size: 12px;
  color: var(--text-2);
  margin-bottom: 8px;
}

/* 非问题项：仅作告知，不计入待核查数 */
.qgroup.info h4 { color: var(--text-2); }

.qgroup h4 .q-ok {
  display: inline-block;
  margin-left: 8px;
  font-size: 11px;
  font-weight: 400;
  color: #0f6e56;
  background: #e4f5ee;
  border: 1px solid #a9ddc9;
  border-radius: 5px;
  padding: 1px 7px;
  vertical-align: 1px;
}

.mini-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.mini-table th, .mini-table td {
  padding: 6px 10px;
  border-bottom: 1px solid var(--line-soft);
  white-space: nowrap;
}

.mini-table tr:last-child td { border-bottom: none; }

.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11.5px;
}

.scroll-box { max-height: 260px; overflow-y: auto; }

/* ---------------------------------------------------------- 提示 */

.toast {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  bottom: 24px;
  background: #1d1e22;
  color: #fff;
  font-size: 13px;
  padding: 9px 16px;
  border-radius: 8px;
  z-index: 99;
}

.err {
  color: #a32d2d;
  font-size: 13px;
  margin-top: 12px;
}

/* ---------------------------------------------------------- 视图切换 */

.tabs {
  display: flex;
  gap: 2px;
  background: #f1f2f5;
  border-radius: 9px;
  padding: 3px;
}

.tab {
  background: none;
  border: none;
  border-radius: 7px;
  padding: 5px 16px;
  font-size: 13px;
  color: var(--text-2);
  transition: background .15s, color .15s;
}

.tab:hover { color: var(--text); }

.tab.active {
  background: #fff;
  color: var(--text);
  font-weight: 500;
  box-shadow: 0 1px 2px rgba(0, 0, 0, .06);
}

/* ---------------------------------------------------------- 同盟校 */

.al-help {
  background: #fbfbfc;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  padding: 12px 14px;
  margin-bottom: 14px;
  font-size: 12.5px;
  color: var(--text-2);
  line-height: 1.75;
}

.al-help code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11.5px;
  background: #eef0f3;
  padding: 1px 5px;
  border-radius: 4px;
}

.al-table td { vertical-align: middle; }

.al-table tr.unmatched td { color: var(--text-3); }
.al-table tr.unmatched td:nth-child(2) { color: var(--text-2); }

.pill {
  display: inline-block;
  font-size: 11.5px;
  padding: 1px 8px;
  border-radius: 999px;
  line-height: 1.7;
  white-space: nowrap;
}

.pill.matched { background: #e1f5ee; color: #0f6e56; }
.pill.suspect { background: var(--warn-soft); color: var(--warn); }
.pill.missing { background: #f1f1f3; color: #7b7d86; }

.al-sel {
  font-size: 12px;
  padding: 3px 6px;
  max-width: 100%;
  width: 100%;
  border-radius: 6px;
}

tr.al-hint td {
  background: #fdfaf3;
  font-size: 12px;
  color: var(--warn);
  white-space: normal;
  padding-top: 4px;
  padding-bottom: 8px;
}

tr.al-hint button {
  background: #fff;
  border: 1px solid var(--warn-line);
  border-radius: 6px;
  padding: 2px 10px;
  font-size: 12px;
  color: var(--warn);
  margin-left: 8px;
}

.al-foot {
  margin-top: 12px;
  font-size: 12px;
  color: var(--text-3);
  line-height: 1.9;
}

.al-foot b { font-weight: 500; color: var(--text-2); }

/* 结构对比条 */

.cmp-dim { margin-bottom: 18px; }
.cmp-dim:last-child { margin-bottom: 0; }

.cmp-head {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 7px;
}

.cmp-head > span:first-child {
  font-size: 13px;
  font-weight: 500;
}

.cmp-legend {
  font-size: 11.5px;
  color: var(--text-3);
  display: inline-flex;
  gap: 10px;
  flex-wrap: wrap;
}

.cmp-legend i {
  width: 8px; height: 8px;
  border-radius: 2px;
  display: inline-block;
  margin-right: 3px;
}

.cmp-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 5px;
}

.cmp-lab {
  width: 46px;
  flex: 0 0 46px;
  font-size: 12px;
  color: var(--text-3);
  text-align: right;
}

.cmp-bar {
  flex: 1;
  display: flex;
  height: 22px;
  border-radius: 4px;
  overflow: hidden;
  background: #f4f5f7;
}

.cmp-seg {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  /* 段填充为浅色，文字改用深色才看得清 */
  color: #1d1e22;
  font-variant-numeric: tabular-nums;
  overflow: hidden;
  white-space: nowrap;
  min-width: 0;
}

.cmp-seg.zero { color: transparent; }

/* 表中的同盟校标记 */

.tag-ally {
  display: inline-block;
  font-size: 10.5px;
  line-height: 1.5;
  padding: 0 4px;
  margin-right: 5px;
  border-radius: 3px;
  background: #e1f5ee;
  color: #0f6e56;
  vertical-align: 1px;
}
