:root {
  font-family: "PingFang SC", "Microsoft YaHei", sans-serif;
  color: #17212b;
  background: #e9eef2;
  --line: #c8d1d9;
  --muted: #657481;
  --ink: #17212b;
  --navy: #263b4c;
  --blue: #28648f;
  --green: #147452;
  --red: #b42336;
  --amber: #b77700;
}
* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; }
button, input { font: inherit; }
button { cursor: pointer; }
h1, h2, h3, p, figure { margin: 0; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 24px;
  min-height: 76px;
  padding: 13px 24px;
  color: #fff;
  background: #1e303e;
  border-bottom: 3px solid #d4a32f;
}
.topbar h1 { font-size: 23px; line-height: 1.15; }
.eyebrow, .section-kicker { color: #d4a32f; font-size: 10px; font-weight: 900; letter-spacing: 0; }
.global-summary { margin-top: 3px; color: #c8d3db; font-size: 10px; }
.primary-link { padding: 9px 14px; color: #fff; background: #b42336; border: 1px solid #d36372; border-radius: 4px; text-decoration: none; font-weight: 800; }

.workspace { display: grid; grid-template-columns: 176px minmax(0, 1fr); min-height: calc(100vh - 76px); }
.sidebar { position: sticky; top: 76px; align-self: start; height: calc(100vh - 76px); padding: 17px 14px; overflow: auto; background: #f7f9fa; border-right: 1px solid var(--line); }
.sidebar-head { padding-bottom: 12px; border-bottom: 1px solid var(--line); }
.sidebar-head b { display: block; font-size: 15px; }
.sidebar-head span { color: var(--muted); font-size: 11px; }
.focus-nav { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin: 12px 0; }
.focus-nav button { position: relative; min-height: 36px; border: 1px solid #d09aa2; color: #7e1c2a; background: #fff; font-weight: 900; border-radius: 3px; }
.focus-nav button::after { content: ""; position: absolute; top: 4px; right: 4px; width: 6px; height: 6px; border-radius: 50%; background: #8c9aa5; }
.focus-nav button[data-status="repaired"]::after { background: var(--green); }
.focus-nav button[data-status="pending"]::after { background: var(--amber); }
.focus-nav button[data-status="verified_no_change"]::after { background: var(--blue); }
.focus-nav button.active { color: #fff; background: var(--red); border-color: var(--red); }
.focus-only { display: flex; gap: 7px; align-items: flex-start; padding: 10px 0; color: #46545f; font-size: 11px; }
.legend { display: grid; gap: 7px; margin-top: 8px; padding-top: 12px; border-top: 1px solid var(--line); color: var(--muted); font-size: 10px; }
.legend span { display: flex; align-items: center; gap: 7px; }
.dot { width: 7px; height: 7px; border-radius: 50%; background: #8c9aa5; }
.dot.repaired { background: var(--green); }
.dot.verified { background: var(--blue); }
.dot.pending { background: var(--amber); }

main { width: min(1460px, 100%); margin: 0 auto; padding: 16px; }
.level-toolbar { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 18px; padding: 11px 13px; background: #fff; border: 1px solid var(--line); }
.level-nav, .level-nav form { display: flex; align-items: center; gap: 6px; }
.level-nav button, .level-nav input { height: 34px; border: 1px solid #9aa9b5; background: #fff; border-radius: 3px; }
.level-nav button { padding: 0 10px; }
.level-nav input { width: 58px; padding: 0 7px; }
.level-title h2 { font-size: 19px; }
.level-title p { margin-top: 2px; color: var(--muted); font-size: 11px; }
.version-state { padding: 5px 8px; border-radius: 3px; font-size: 11px; font-weight: 900; }
.version-state.repaired, .version-state.pending { color: #684300; background: #ffe7a6; }
.version-state.verified { color: #fff; background: var(--green); }
.version-state.neutral { color: #43525d; background: #e5eaee; }
.attention { display: grid; grid-template-columns: 190px 1fr; gap: 14px; align-items: center; margin-top: 9px; padding: 10px 13px; background: #fff1f2; border: 2px solid var(--red); color: #741d2a; }
.attention b, .attention span { display: block; }
.attention span { font-size: 10px; }
.attention p { font-size: 12px; }

.compare-toolbar { display: flex; justify-content: space-between; align-items: center; gap: 18px; margin-top: 9px; padding: 8px 10px; background: #fff; border: 1px solid var(--line); }
.segmented { display: inline-flex; padding: 2px; background: #dfe5e9; border-radius: 4px; }
.segmented button { min-height: 34px; padding: 0 13px; border: 0; color: #42515c; background: transparent; border-radius: 3px; font-size: 12px; font-weight: 800; }
.segmented button.active { color: #fff; background: var(--navy); }
.compare-toolbar p { color: var(--muted); font-size: 11px; }

.compare-stage { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-top: 10px; }
.compare-stage.overview { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.board-panel { min-width: 0; background: #fff; border: 1px solid #aebac4; }
.board-panel figcaption { display: flex; justify-content: space-between; align-items: center; min-height: 42px; padding: 8px 11px; color: #fff; background: var(--navy); }
.board-panel.candidate figcaption { background: #285d83; }
.board-panel.repaired figcaption { background: var(--green); }
.board-panel figcaption b { font-size: 14px; }
.board-panel figcaption span { font-size: 10px; opacity: .85; }
.board { display: grid; grid-template-columns: repeat(var(--cols), minmax(0, 1fr)); gap: 4px; padding: 4px; background: #c9d2d9; }
.person-card { position: relative; display: grid; grid-template-rows: minmax(66px, 1fr) auto auto; min-width: 0; height: clamp(126px, 9.8vw, 164px); overflow: hidden; background: #deebf4; border: 1px solid #507b9e; }
.person-card.female { background: #ecdeeb; border-color: #866783; }
.person-card.bad { box-shadow: inset 0 0 0 3px #c9364a; }
.person-card.initial { outline: 3px solid #e1a91d; outline-offset: -3px; }
.person-card.changed { box-shadow: inset 0 0 0 4px #e7a900; }
.person-card.blank { display: grid; place-items: center; height: clamp(126px, 9.8vw, 164px); color: #d9e0e5; background: #394651; border-color: #252f37; }
.person-card img { width: 100%; height: 100%; min-height: 0; object-fit: contain; object-position: center bottom; }
.coordinate { position: absolute; top: 3px; left: 3px; z-index: 2; padding: 1px 4px; background: rgba(255,255,255,.92); color: #17212b; border-radius: 2px; font-size: 10px; }
.initial-tag { position: absolute; top: 3px; right: 3px; z-index: 2; padding: 1px 4px; color: #503800; background: #f2c84b; border-radius: 2px; font-size: 9px; font-style: normal; }
.person-card strong { display: block; padding: 3px 5px; text-align: center; background: rgba(255,255,255,.72); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.person-card small { display: -webkit-box; min-height: 44px; padding: 4px 6px 6px; overflow: hidden; color: #25333d; font-size: 12px; line-height: 1.3; -webkit-line-clamp: 3; -webkit-box-orient: vertical; }
.board-foot { display: grid; grid-template-columns: 1fr; gap: 4px; padding: 8px 10px; color: #45545f; background: #f7f9fa; border-top: 1px solid var(--line); font-size: 10px; }
.board-foot b { color: var(--ink); }
.overview .person-card, .overview .person-card.blank { height: clamp(105px, 7.3vw, 132px); }
.overview .person-card small { -webkit-line-clamp: 2; }

.review-grid { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(360px, .85fr); align-items: start; gap: 10px; margin-top: 10px; }
.review-panel { background: #fff; border: 1px solid var(--line); }
.review-panel > header { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.review-panel h2 { font-size: 16px; }
.review-panel header > span { color: var(--muted); font-size: 11px; }
.change-panel #changes { padding: 12px 14px; }
.change { display: grid; grid-template-columns: 90px 1fr; gap: 12px; padding: 9px 0; border-bottom: 1px solid #e2e7eb; }
.change:last-child { border-bottom: 0; }
.change-person { font-weight: 900; }
.change-person span { display: block; margin-top: 3px; color: var(--muted); font-size: 11px; font-weight: 400; }
.copy-diff { display: grid; grid-template-columns: 1fr 26px 1fr; align-items: center; gap: 8px; }
.copy-diff p { min-height: 48px; padding: 8px 9px; background: #f4f6f8; border-left: 3px solid #98a6b1; font-size: 13px; line-height: 1.5; }
.copy-diff p:last-child { color: #0e5d42; background: #eaf7f1; border-color: var(--green); font-weight: 800; }
.copy-diff i { color: #76848e; text-align: center; font-style: normal; }
.empty { padding: 12px 14px; color: var(--muted); font-size: 11px; }
.integrity-facts { display: grid; grid-template-columns: 1fr 1fr; gap: 1px; background: var(--line); }
.fact { min-height: 70px; padding: 10px; background: #fff; }
.fact b { display: block; color: var(--green); font-size: 12px; }
.fact span { display: block; margin-top: 4px; color: var(--muted); font-size: 10px; line-height: 1.4; }

.chain-panel { margin-top: 10px; }
.chain-head { align-items: center !important; }
.chain-head #chainVerdict { margin-top: 3px; color: var(--muted); font-size: 11px; }
.chain-badges { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px; }
.chain-badges span { padding: 5px 8px; border-radius: 3px; font-size: 10px; font-weight: 900; }
.chain-ok { color: #0e6547; background: #e3f5ed; }
.chain-bad { color: #8e1728; background: #ffeaed; }
.chain-deltas { padding: 0 14px; }
.chain-delta { display: grid; grid-template-columns: 72px repeat(3, minmax(0, 1fr)); gap: 7px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.chain-delta > b { padding-top: 7px; font-size: 11px; }
.chain-copy { padding: 7px 8px; background: #f4f6f8; border-top: 3px solid #8c9aa5; }
.chain-copy.candidate { border-color: var(--blue); }
.chain-copy.repaired { background: #eaf7f1; border-color: var(--green); }
.chain-copy span, .chain-copy p { display: block; font-size: 12px; line-height: 1.45; }
.chain-copy span { margin-bottom: 4px; color: var(--muted); font-weight: 900; }
.chain-timeline { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1px; margin: 0; padding: 12px 14px 14px; list-style: none; background: #d6dde2; }
.chain-step { position: relative; min-height: 98px; padding: 9px 9px 9px 38px; background: #fff; }
.chain-step.changed { background: #fff8e5; }
.step-index { position: absolute; top: 9px; left: 9px; display: grid; place-items: center; width: 22px; height: 22px; color: #fff; background: var(--navy); border-radius: 50%; font-size: 10px; font-weight: 900; }
.chain-step strong, .chain-step span, .chain-step small { display: block; }
.chain-step strong { font-size: 12px; }
.chain-step span { margin-top: 4px; color: var(--blue); font-size: 12px; }
.chain-step small { margin-top: 5px; color: var(--muted); font-size: 11px; line-height: 1.4; }

.mapping-panel { margin-top: 10px; }
.table-wrap { overflow: auto; }
table { width: 100%; border-collapse: collapse; font-size: 11px; }
th, td { padding: 8px 10px; border-bottom: 1px solid #e0e5e9; text-align: left; white-space: nowrap; }
th { color: #53616c; background: #f2f5f7; }
td.moved { color: var(--blue); font-weight: 900; }
.role-bad { color: var(--red); font-weight: 900; }
.role-good { color: var(--green); font-weight: 900; }

.toast { position: fixed; bottom: 18px; left: 50%; z-index: 30; padding: 8px 12px; color: #fff; background: #111; opacity: 0; transform: translateX(-50%); pointer-events: none; }
.toast.show { opacity: 1; }

@media (max-width: 1120px) {
  .workspace { grid-template-columns: 1fr; }
  .sidebar { position: static; width: auto; height: auto; border-right: 0; border-bottom: 1px solid var(--line); }
  .focus-nav { display: flex; flex-wrap: wrap; }
  .focus-nav button { min-width: 48px; }
  .legend { display: flex; }
  .compare-stage, .compare-stage.overview, .review-grid { grid-template-columns: 1fr; }
  .person-card, .person-card.blank, .overview .person-card, .overview .person-card.blank { height: clamp(130px, 18vw, 180px); }
}
@media (max-width: 720px) {
  .topbar { padding: 11px 13px; }
  .topbar h1 { font-size: 18px; }
  .workspace main { padding: 9px; }
  .level-toolbar { grid-template-columns: 1fr auto; }
  .level-title { grid-row: 2; grid-column: 1 / -1; }
  .attention { grid-template-columns: 1fr; gap: 4px; }
  .compare-toolbar { display: block; }
  .segmented { display: grid; grid-template-columns: 1fr; width: 100%; }
  .compare-toolbar p { margin-top: 7px; }
  .copy-diff { grid-template-columns: 1fr; }
  .copy-diff i { transform: rotate(90deg); }
  .chain-timeline { grid-template-columns: 1fr; }
  .chain-delta { grid-template-columns: 1fr; }
  .integrity-facts { grid-template-columns: 1fr; }
}
