:root {
  --purple: #82318E;
  --purple-dark: #5c2065;
  --purple-pale: #f5eef7;
  --ink: #1f2229;
  --ink-soft: #565c68;
  --line: #e6e2ea;
  --bg: #faf9fb;
  --card: #ffffff;
  --green: #1a7f4f;
  --amber: #a06a00;
  --gray: #8a8f99;
  --teal: #0f6f74;
  --radius: 10px;
  font-size: 16px;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  color: var(--ink); background: var(--bg); line-height: 1.65;
}
h1, h2, h3, .brand-text, .stat-num { font-family: "Songti SC", "Noto Serif SC", "SimSun", serif; }
a { color: var(--purple); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- header ---------- */
.site-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0.7rem 1.4rem; background: #fff; border-bottom: 3px solid var(--purple);
  position: sticky; top: 0; z-index: 50; flex-wrap: wrap; gap: 0.5rem;
}
.brand { display: flex; align-items: center; gap: 0.6rem; }
.brand:hover { text-decoration: none; }
.brand-mark {
  width: 2.4rem; height: 2.4rem; border-radius: 6px; background: var(--purple);
  color: #fff; font-size: 1.4rem; display: flex; align-items: center; justify-content: center;
  font-family: "Songti SC", serif; font-weight: 700;
}
.brand-text { font-size: 1.15rem; font-weight: 700; color: var(--ink); display: flex; flex-direction: column; line-height: 1.2; }
.brand-text small { font-size: 0.7rem; font-weight: 400; color: var(--ink-soft); }
.site-nav a { margin-left: 1.1rem; color: var(--ink-soft); font-weight: 500; padding: 0.3rem 0; border-bottom: 2px solid transparent; }
.site-nav a.active { color: var(--purple); border-bottom-color: var(--purple); }
.site-nav a:hover { text-decoration: none; color: var(--purple); }

main { max-width: 1080px; margin: 0 auto; padding: 1.6rem 1.2rem 3rem; min-height: 60vh; }
.loading { text-align: center; color: var(--ink-soft); padding: 4rem 0; }

/* ---------- home ---------- */
.hero { text-align: center; padding: 1.6rem 0 0.8rem; }
.hero h1 { font-size: 1.9rem; letter-spacing: 0.04em; }
.hero p.sub { color: var(--ink-soft); margin-top: 0.4rem; }
.hero .asof { font-size: 0.8rem; color: var(--gray); margin-top: 0.3rem; }
.stats-row { display: flex; gap: 1rem; justify-content: center; margin: 1.4rem 0; flex-wrap: wrap; }
.stat-card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 0.9rem 1.6rem; text-align: center; min-width: 8.5rem;
}
.stat-num { font-size: 2rem; font-weight: 700; color: var(--purple); }
.stat-label { font-size: 0.82rem; color: var(--ink-soft); }
.section-title { font-size: 1.25rem; margin: 2rem 0 0.8rem; border-left: 4px solid var(--purple); padding-left: 0.6rem; }
.chart-box { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 0.6rem; }
#field-treemap { width: 100%; height: 380px; }
.top-people { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 0.8rem; }

/* ---------- cards & lists ---------- */
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 0.9rem 1rem; transition: box-shadow 0.15s;
}
.card:hover { box-shadow: 0 3px 14px rgba(130, 49, 142, 0.12); }
.card a.card-title { font-weight: 600; font-size: 1.02rem; }
.card .meta { font-size: 0.8rem; color: var(--ink-soft); margin-top: 0.2rem; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 0.8rem; margin-top: 1rem; }

/* ---------- badges ---------- */
.badge {
  display: inline-block; font-size: 0.72rem; padding: 0.1rem 0.5rem; border-radius: 99px;
  border: 1px solid currentColor; vertical-align: 1px; white-space: nowrap;
}
.badge.conf-高 { color: var(--green); background: #eaf6f0; }
.badge.conf-中 { color: var(--amber); background: #fdf5e6; }
.badge.conf-低 { color: var(--gray); background: #f1f2f4; }
.badge.kind-登记 { color: var(--purple); background: var(--purple-pale); }
.badge.kind-间接 { color: var(--teal); background: #e8f4f4; }
.badge.kind-报道 { color: var(--amber); background: #fdf5e6; border-style: dashed; }
.badge.kind-未知 { color: var(--gray); background: #f1f2f4; }
.badge.status-已上市 { color: var(--purple); background: var(--purple-pale); }
.badge.status-存续 { color: var(--green); background: #eaf6f0; }
.badge.status-注销, .badge.status-吊销 { color: var(--gray); background: #f1f2f4; }
.badge.status-未知 { color: var(--gray); background: #f1f2f4; }
.badge.review { color: #b3261e; background: #fdecea; }
.badge.group-t { color: var(--purple); background: var(--purple-pale); }
.badge.group-s { color: #2f6fb1; background: #eaf1f9; }
.badge.group-u { color: var(--gray); background: #f1f2f4; }
.badge.office { color: var(--gray); background: #f1f2f4; border-style: dotted; }
.rank-split { display: block; font-size: 0.68rem; font-weight: 400; color: var(--ink-soft); text-align: right; }

/* ---------- rankings ---------- */
.rank-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.rank-col { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1.2rem; }
.rank-col h3 { font-size: 1.05rem; color: var(--purple-dark); margin-bottom: 0.6rem; }
.rank-col h3 small { font-weight: 400; color: var(--gray); font-size: 0.75rem; margin-left: 0.4rem; }
.rank-list { margin-left: 1.5rem; }
.rank-list li { padding: 0.35rem 0; border-bottom: 1px dashed var(--line); font-size: 0.92rem; }
.rank-list li:last-child { border-bottom: none; }
.rank-list li::marker { color: var(--purple); font-weight: 700; font-variant-numeric: tabular-nums; }
.rank-n { float: right; font-weight: 700; color: var(--purple); font-variant-numeric: tabular-nums; }
.rank-dept { display: block; font-size: 0.75rem; color: var(--gray); }
@media (max-width: 720px) { .rank-cols { grid-template-columns: 1fr; } }
.tag { display: inline-block; font-size: 0.75rem; background: var(--purple-pale); color: var(--purple-dark); border-radius: 4px; padding: 0.05rem 0.5rem; margin: 0 0.25rem 0.25rem 0; }

/* ---------- filter bar ---------- */
.filter-bar { display: flex; gap: 0.6rem; flex-wrap: wrap; align-items: center; margin: 0.8rem 0; }
.filter-bar input[type="search"] {
  flex: 1 1 220px; padding: 0.5rem 0.8rem; border: 1px solid var(--line); border-radius: 8px;
  font-size: 0.95rem; background: #fff;
}
.filter-bar select { padding: 0.45rem 0.5rem; border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--ink); }
.result-count { font-size: 0.8rem; color: var(--ink-soft); }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; font-size: 0.88rem; min-width: 640px; }
th, td { text-align: left; padding: 0.55rem 0.8rem; border-bottom: 1px solid var(--line); vertical-align: top; }
th { background: var(--purple-pale); color: var(--purple-dark); font-weight: 600; white-space: nowrap; }
tr:last-child td { border-bottom: none; }
td.num { font-variant-numeric: tabular-nums; font-weight: 600; white-space: nowrap; }
.src-link { font-size: 0.75rem; }
.asof-cell { font-size: 0.75rem; color: var(--ink-soft); }
.conflict { color: #b3261e; cursor: help; border-bottom: 1px dotted #b3261e; }

/* ---------- detail pages ---------- */
.detail-head { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.2rem 1.4rem; margin-bottom: 1.2rem; }
.detail-head h1 { font-size: 1.6rem; display: inline; margin-right: 0.6rem; }
.detail-head .meta-line { margin-top: 0.4rem; color: var(--ink-soft); font-size: 0.9rem; }
.evidence-toggle { cursor: pointer; font-size: 0.8rem; color: var(--purple); user-select: none; }
.evidence-list { margin: 0.5rem 0 0 1rem; font-size: 0.82rem; color: var(--ink-soft); display: none; }
.evidence-list.open { display: block; }
.evidence-list li { margin-bottom: 0.2rem; }
#ego-graph, #global-graph { width: 100%; height: 460px; }
.graph-hint { font-size: 0.78rem; color: var(--gray); margin: 0.4rem 0.2rem; }
.mobile-only { display: none; }

/* ---------- relation chain (mobile graph alternative) ---------- */
.chain-item { border-left: 3px solid var(--purple); padding: 0.4rem 0.8rem; margin-bottom: 0.6rem; background: var(--card); border-radius: 0 8px 8px 0; font-size: 0.88rem; }
.chain-item .pct { font-weight: 700; color: var(--purple); }

/* ---------- methodology ---------- */
.prose { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.4rem 1.6rem; }
.prose h2 { font-size: 1.15rem; margin: 1.2rem 0 0.5rem; color: var(--purple-dark); }
.prose h2:first-child { margin-top: 0; }
.prose ul { margin: 0.4rem 0 0.4rem 1.4rem; }
.prose li { margin-bottom: 0.25rem; }

/* ---------- footer ---------- */
.site-footer {
  max-width: 1080px; margin: 0 auto; padding: 1.2rem; border-top: 1px solid var(--line);
  font-size: 0.78rem; color: var(--ink-soft);
}
.site-footer p { margin-bottom: 0.4rem; }

/* ---------- responsive ---------- */
@media (max-width: 720px) {
  .site-header { padding: 0.6rem 0.9rem; }
  .site-nav a { margin-left: 0.7rem; font-size: 0.9rem; }
  .brand-text { font-size: 1rem; }
  .hero h1 { font-size: 1.45rem; }
  .stat-card { min-width: 7rem; padding: 0.7rem 1rem; }
  .stat-num { font-size: 1.5rem; }
  #ego-graph, #global-graph, .desktop-only { display: none !important; }
  .mobile-only { display: block; }
  table { min-width: 0; }
}
