:root {
  --bg: #f6f7f4;
  --surface: #ffffff;
  --surface-2: #eef3f0;
  --text: #18211f;
  --muted: #66716c;
  --line: #d9dfdc;
  --accent: #0f766e;
  --accent-2: #2563eb;
  --accent-3: #b45309;
  --accent-4: #7c3aed;
  --danger: #b91c1c;
  --radius: 8px;
  --shadow: 0 1px 2px rgba(20, 30, 25, 0.08);
}
* { box-sizing: border-box; }
html { min-width: 320px; }
body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans CJK SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  letter-spacing: 0;
}
.topbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  padding: 20px clamp(16px, 3vw, 40px) 14px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  position: sticky;
  top: 0;
  z-index: 10;
}
h1 {
  margin: 0;
  font-size: 24px;
  line-height: 1.15;
  font-weight: 720;
}
p { margin: 0; }
#generatedAt {
  margin-top: 6px;
  color: var(--muted);
  font-size: 13px;
}
.tabs {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
}
.tabs button {
  appearance: none;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  padding: 8px 10px;
  min-height: 36px;
  border-radius: 6px;
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}
.tabs button.active {
  color: var(--text);
  border-color: var(--line);
  background: var(--surface-2);
}
main {
  padding: 18px clamp(16px, 3vw, 40px) 36px;
}
.section { display: none; }
.active-section { display: block; }
.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(170px, 1fr));
  gap: 10px;
}
.metric-card,
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.metric-card {
  min-height: 112px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}
.metric-card .label {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.25;
}
.metric-card .value {
  margin-top: 10px;
  font-size: 25px;
  line-height: 1.1;
  font-weight: 740;
  overflow-wrap: anywhere;
}
.metric-card .date {
  margin-top: 8px;
  color: var(--muted);
  font-size: 12px;
}
.layout-two {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 12px;
  margin-top: 12px;
}
.panel { padding: 14px; }
.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 12px;
}
.panel-head h2 {
  margin: 0;
  font-size: 16px;
  line-height: 1.2;
}
.panel-head span {
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}
.narrative,
.compact-list {
  margin: 0;
  padding-left: 18px;
  color: #24302d;
  line-height: 1.5;
  font-size: 14px;
}
.narrative li + li,
.compact-list li + li { margin-top: 8px; }
.chart-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(280px, 1fr));
  gap: 12px;
}
.chart-panel { min-height: 420px; position: relative; }
.chart-panel canvas {
  width: 100%;
  height: 340px;
  display: block;
}

.chart-tooltip {
  position: absolute;
  z-index: 5;
  display: none;
  min-width: 210px;
  max-width: min(320px, calc(100% - 20px));
  padding: 10px 11px;
  border: 1px solid rgba(24, 33, 31, 0.16);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 8px 24px rgba(20, 30, 25, 0.16);
  pointer-events: none;
  color: var(--text);
  font-size: 12px;
  backdrop-filter: blur(6px);
}
.tip-title {
  margin-bottom: 7px;
  color: var(--muted);
  font-weight: 680;
}
.tip-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
  line-height: 1.35;
}
.tip-row + .tip-row { margin-top: 6px; }
.tip-row span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  overflow-wrap: anywhere;
}
.tip-row i {
  width: 9px;
  height: 9px;
  border-radius: 2px;
  flex: 0 0 auto;
}
.tip-row strong {
  font-variant-numeric: tabular-nums;
  font-weight: 720;
  white-space: nowrap;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  margin-top: 10px;
  font-size: 12px;
  color: var(--muted);
}
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i {
  width: 10px;
  height: 10px;
  border-radius: 2px;
  display: inline-block;
}
.event-table {
  overflow-x: auto;
  border-top: 1px solid var(--line);
}
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
th, td {
  padding: 10px 8px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}
th {
  color: var(--muted);
  font-weight: 620;
  background: #fbfcfb;
}
td.value { font-variant-numeric: tabular-nums; white-space: nowrap; }
a { color: var(--accent-2); text-decoration: none; }
a:hover { text-decoration: underline; }
@media (max-width: 1040px) {
  .metric-grid { grid-template-columns: repeat(2, minmax(160px, 1fr)); }
  .chart-grid, .layout-two { grid-template-columns: 1fr; }
}
@media (max-width: 720px) {
  .topbar { align-items: flex-start; flex-direction: column; position: static; }
  .tabs { width: 100%; overflow-x: auto; flex-wrap: nowrap; padding-bottom: 2px; }
  .tabs button { flex: 0 0 auto; }
  .metric-grid { grid-template-columns: 1fr; }
  .metric-card .value { font-size: 22px; }
  .chart-panel { min-height: 360px; }
  .chart-panel canvas { height: 290px; }
}
