:root {
  --bg: #f4f6f8;
  --surface: #ffffff;
  --surface-soft: #f8fafb;
  --text: #17212b;
  --muted: #66717d;
  --line: #dde3e8;
  --line-strong: #c8d0d8;
  --red: #b93b34;
  --green: #087f5b;
  --gold: #a56f08;
  --blue: #2463a7;
  --teal: #087c83;
  --amber: #b85c00;
  --shadow: 0 8px 24px rgba(23, 33, 43, 0.07);
}

* { box-sizing: border-box; }

html { background: var(--bg); }

body {
  margin: 0;
  color: var(--text);
  background: var(--bg);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 14px;
  line-height: 1.65;
}

a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
.muted { color: var(--muted); }

button, input { font: inherit; }

.shell {
  width: min(1480px, 100%);
  margin: 0 auto;
  padding: 18px 22px 42px;
}

.report-header {
  background: #20384d;
  color: #fff;
  border-radius: 8px;
  padding: 20px 24px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 20px;
  align-items: center;
  margin-bottom: 14px;
}

.report-header h1 {
  margin: 0;
  font-size: 23px;
  line-height: 1.3;
  letter-spacing: 0;
}

.report-header .subtitle {
  margin-top: 6px;
  color: rgba(255, 255, 255, 0.75);
  font-size: 12px;
}

.header-meta {
  text-align: right;
  font-size: 12px;
  color: rgba(255, 255, 255, 0.8);
  white-space: nowrap;
}

.header-meta strong {
  display: block;
  color: #fff;
  font-size: 14px;
  margin-bottom: 2px;
}

.type-nav {
  display: flex;
  gap: 4px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 4px;
  margin-bottom: 14px;
  width: fit-content;
}

.type-nav a {
  min-width: 72px;
  padding: 7px 12px;
  border-radius: 6px;
  color: var(--muted);
  text-align: center;
  font-size: 13px;
  font-weight: 650;
}

.type-nav a.active {
  color: #fff;
  background: #20384d;
  text-decoration: none;
}

.embedded .type-nav { display: none; }

.embedded .shell {
  width: 100%;
  max-width: none;
  padding: 10px 12px 32px;
}

.embedded .report-header { padding: 16px 18px; }
.embedded .metric { padding: 12px 14px; }
.embedded .report-section { padding: 14px 15px; }
.embedded .event-table { min-width: 780px; }
.embedded .anchor-table { min-width: 1040px; }
.embedded .candidate-table { min-width: 1080px; }

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.metric {
  min-height: 112px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.metric .label {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}

.metric .value {
  margin-top: 4px;
  font-size: 24px;
  line-height: 1.2;
  font-weight: 760;
  font-variant-numeric: tabular-nums;
}

.metric .detail {
  margin-top: 7px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.45;
}

.metric .value.red, .red { color: var(--red); }
.metric .value.green, .green { color: var(--green); }
.metric .value.gold, .gold { color: var(--gold); }
.metric .value.blue, .blue { color: var(--blue); }

.decision-band {
  display: grid;
  grid-template-columns: 180px minmax(0, 1fr) auto;
  gap: 18px;
  align-items: center;
  padding: 16px 18px;
  border: 1px solid #e4c38c;
  border-left: 5px solid var(--amber);
  border-radius: 8px;
  background: #fffaf1;
  margin-bottom: 14px;
}

.decision-band .decision {
  color: var(--amber);
  font-size: 22px;
  font-weight: 780;
}

.decision-band .reason {
  color: #4c5965;
  font-size: 13px;
}

.decision-band .confidence {
  color: var(--muted);
  font-size: 11px;
  text-align: right;
  white-space: nowrap;
}

.report-section {
  margin-bottom: 12px;
  padding: 17px 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.section-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 12px;
}

.section-head h2 {
  margin: 0;
  font-size: 16px;
  line-height: 1.4;
}

.section-head p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 11px;
}

.status {
  flex: 0 0 auto;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}

.status.good { color: var(--green); background: #eaf7f1; }
.status.warn { color: var(--amber); background: #fff2df; }
.status.bad { color: var(--red); background: #fdeceb; }
.status.info { color: var(--blue); background: #eaf2fb; }

.two-col {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.three-col {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.analysis-block {
  padding: 12px 13px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface-soft);
}

.analysis-block h3 {
  margin: 0 0 7px;
  font-size: 13px;
}

.analysis-block p {
  margin: 5px 0;
  color: #46525d;
  font-size: 12px;
}

.analysis-block strong { color: var(--text); }

.table-scroll { overflow-x: auto; }

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

.event-table { min-width: 820px; }
.event-table th:nth-child(1) { width: 17%; }
.event-table th:nth-child(2) { width: 28%; }
.event-table th:nth-child(3) { width: 29%; }
.event-table th:nth-child(4) { width: 26%; }

.anchor-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}

.anchor-summary > div {
  min-width: 0;
  padding: 10px 11px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface-soft);
}

.anchor-summary strong { display: block; margin: 4px 0 2px; font-size: 12px; }
.anchor-summary small { display: block; color: var(--muted); font-size: 10px; line-height: 1.45; }

.anchor-level {
  display: inline-block;
  min-width: 24px;
  padding: 1px 5px;
  border-radius: 4px;
  text-align: center;
  font-size: 10px;
  font-weight: 750;
}

.anchor-level.high { color: var(--red); background: #fdeceb; }
.anchor-level.medium { color: var(--amber); background: #fff2df; }

.anchor-table { min-width: 1120px; }
.anchor-table th:nth-child(1) { width: 15%; }
.anchor-table th:nth-child(2) { width: 23%; }
.anchor-table th:nth-child(3) { width: 21%; }
.anchor-table th:nth-child(4) { width: 21%; }
.anchor-table th:nth-child(5) { width: 20%; }

.opportunity-headline {
  margin: 12px 0;
  padding: 11px 13px;
  border: 1px solid #bfd7d9;
  border-left: 5px solid var(--teal);
  border-radius: 7px;
  background: #eef8f8;
  color: #38565a;
  font-size: 12px;
}

.opportunity-headline strong { color: var(--text); }

.candidate-table { min-width: 1140px; }
.candidate-table th:nth-child(1) { width: 15%; }
.candidate-table th:nth-child(2) { width: 22%; }
.candidate-table th:nth-child(3) { width: 20%; }
.candidate-table th:nth-child(4) { width: 20%; }
.candidate-table th:nth-child(5) { width: 8%; }
.candidate-table th:nth-child(6) { width: 15%; }
.candidate-primary { background: #f1f8f8; }

.performance-table {
  min-width: 980px;
  table-layout: fixed;
}

.performance-table th:nth-child(1) { width: 18%; }
.performance-table th:nth-child(2) { width: 15%; }
.performance-table th:nth-child(3) { width: 14%; }
.performance-table th:nth-child(4) { width: 14%; }
.performance-table th:nth-child(5) { width: 14%; }
.performance-table th:nth-child(6) { width: 14%; }
.performance-table th:nth-child(7) { width: 11%; }
.performance-table td { vertical-align: middle; }
.performance-table td:first-child { font-weight: 700; }

.performance-notes {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-top: 10px;
}

.performance-notes > div {
  min-width: 0;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 11px;
  line-height: 1.5;
}

.performance-notes strong { color: var(--text); }

.exclusion-line {
  margin-top: 8px;
  color: var(--muted);
  font-size: 11px;
}

.exclusion-line strong { color: var(--text); }

.opportunity-callout {
  display: flex;
  flex-wrap: wrap;
  gap: 5px 12px;
  margin-top: 12px;
  padding: 10px 12px;
  border-left: 4px solid var(--teal);
  background: #eef8f8;
  color: #38565a;
  font-size: 12px;
}

.opportunity-callout strong { color: var(--text); }

th {
  padding: 8px 9px;
  border-bottom: 2px solid var(--line-strong);
  color: var(--muted);
  background: var(--surface-soft);
  text-align: left;
  font-size: 11px;
  font-weight: 750;
  white-space: nowrap;
}

td {
  padding: 9px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

tr:last-child td { border-bottom: 0; }

.num { text-align: right; white-space: nowrap; }
.nowrap { white-space: nowrap; }

.allocation {
  display: grid;
  grid-template-columns: 155px minmax(160px, 1fr) 68px;
  gap: 10px;
  align-items: center;
  margin: 9px 0;
  font-size: 12px;
}

.track {
  height: 9px;
  border-radius: 999px;
  background: #e9edf1;
  overflow: hidden;
}

.fill { height: 100%; border-radius: 999px; }
.fill.gold { background: #b5821b; }
.fill.purple { background: #8658a6; }
.fill.teal { background: #18868b; }
.fill.gray { background: #88949f; }

.note {
  margin-top: 10px;
  padding: 9px 11px;
  border-left: 3px solid var(--blue);
  background: #f2f7fc;
  color: #53606c;
  font-size: 11px;
}

.warning-list, .checkpoint-list {
  margin: 0;
  padding-left: 20px;
  color: #46525d;
  font-size: 12px;
}

.warning-list li, .checkpoint-list li { margin: 6px 0; }

.source-list {
  margin: 0;
  padding-left: 20px;
  color: var(--muted);
  font-size: 11px;
}

.source-list li { margin: 5px 0; }

.report-footer {
  padding: 10px 4px 0;
  color: var(--muted);
  font-size: 10px;
  text-align: center;
}

.archive-shell {
  display: grid;
  grid-template-columns: 248px minmax(0, 1fr);
  min-height: 100vh;
  width: 100%;
  margin: 0;
  border: 0;
  border-radius: 0;
  background: var(--surface);
  overflow: hidden;
  box-shadow: none;
}

.archive-shell.sidebar-collapsed { grid-template-columns: 0 minmax(0, 1fr); }
.archive-shell.sidebar-collapsed .archive-sidebar {
  width: 0;
  padding: 0;
  border-right: 0;
}

.archive-sidebar {
  min-width: 0;
  padding: 14px;
  border-right: 1px solid var(--line);
  background: #f8fafb;
  overflow: hidden;
}

.archive-brand {
  font-size: 18px;
  font-weight: 780;
}

.archive-brand small {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 500;
}

.archive-tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  margin: 16px 0 12px;
}

.archive-tabs button {
  padding: 7px 3px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
  font-size: 12px;
  font-weight: 700;
}

.archive-tabs button.active {
  color: #fff;
  border-color: #20384d;
  background: #20384d;
}

.archive-list { display: grid; gap: 7px; }

.archive-item {
  width: 100%;
  padding: 10px 11px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface);
  color: var(--text);
  text-align: left;
  cursor: pointer;
}

.archive-item:hover, .archive-item.active { border-color: #7ba2c7; background: #f1f6fb; }
.archive-item strong { display: block; font-size: 12px; }
.archive-item span { display: block; margin-top: 2px; color: var(--muted); font-size: 10px; }

.archive-empty {
  padding: 18px 8px;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

.archive-links {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 18px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
  font-size: 11px;
}

.archive-main { min-width: 0; background: var(--bg); }

.archive-toolbar {
  height: 46px;
  padding: 0 10px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.archive-toolbar-start {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 8px;
}

.sidebar-toggle {
  flex: 0 0 auto;
  width: 30px;
  height: 30px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
  font-size: 20px;
  line-height: 1;
}

.sidebar-toggle:hover {
  color: var(--text);
  border-color: #9fb4c6;
  background: #f3f7fa;
}

.archive-toolbar .current-title {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
  font-weight: 700;
}

.archive-toolbar a {
  flex: 0 0 auto;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: 11px;
}

.archive-frame {
  display: block;
  width: 100%;
  height: calc(100vh - 46px);
  border: 0;
  background: var(--bg);
}

@media (max-width: 920px) {
  .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .three-col { grid-template-columns: 1fr; }
  .decision-band { grid-template-columns: 145px minmax(0, 1fr); }
  .decision-band .confidence { grid-column: 1 / -1; text-align: left; }
  .archive-shell { grid-template-columns: 210px minmax(0, 1fr); }
  .anchor-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .performance-notes { grid-template-columns: 1fr; }
}

@media (max-width: 680px) {
  .shell { padding: 10px 8px 28px; }
  .report-header { grid-template-columns: 1fr; padding: 16px; }
  .report-header h1 { font-size: 19px; }
  .header-meta { text-align: left; white-space: normal; }
  .metric-grid, .two-col { grid-template-columns: 1fr; }
  .metric { min-height: 0; }
  .decision-band { grid-template-columns: 1fr; gap: 7px; }
  .decision-band .confidence { grid-column: auto; }
  .section-head { flex-direction: column; }
  .allocation { grid-template-columns: 118px minmax(100px, 1fr) 58px; }
  .archive-shell { display: block; width: 100%; margin: 0; border: 0; border-radius: 0; }
  .archive-shell.sidebar-collapsed { display: block; }
  .archive-sidebar { border-right: 0; border-bottom: 1px solid var(--line); }
  .archive-shell.sidebar-collapsed .archive-sidebar { display: block; }
  .sidebar-toggle { display: none; }
  .archive-list { grid-template-columns: 1fr; }
  .archive-frame { height: calc(100vh - 46px); }
  .anchor-summary { grid-template-columns: 1fr; }
}

@media print {
  body { background: #fff; }
  .shell { width: 100%; padding: 0; }
  .type-nav { display: none; }
  .metric, .report-section { box-shadow: none; break-inside: avoid; }
  .report-header { background: #20384d !important; print-color-adjust: exact; }
}
