/* ============================================================
   AI 数据中心 — Editorial Data Almanac
   A refined print-journal aesthetic: warm paper, deep ink,
   Fraunces display type, tabular mono figures, and data-viz
   with real atmosphere. All structural class names preserved.
   ============================================================ */

:root {
  /* Paper & ink */
  --paper: #f6f2e9;
  --paper-2: #efe9db;
  --surface: #fdfbf4;
  --surface-2: #eae3d3;
  --ink: #16130c;
  --ink-soft: #3a352a;
  --muted: #766d5c;
  --muted-2: #948a76;
  --line: #ddd4c1;
  --line-strong: #c4b9a0;

  /* Signature accents */
  --teal: #0e6a58;
  --teal-deep: #0a4c40;
  --blue: #235f8f;
  --red: #bb3f28;
  --gold: #b9821c;

  /* Data ramp (bars, charts) */
  --data-1: #0e6a58;
  --data-2: #227a70;
  --data-3: #3f8a86;
  --data-hi: #b9821c;

  --shadow-sm: 0 2px 8px rgba(48, 39, 22, 0.06);
  --shadow: 0 20px 46px -22px rgba(48, 39, 22, 0.34);
  --shadow-lift: 0 30px 60px -26px rgba(48, 39, 22, 0.42);

  --radius: 10px;
  --radius-sm: 6px;

  color-scheme: light;
  font-family: "Hanken Grotesk", "PingFang SC", "Microsoft YaHei", "Segoe UI", system-ui, sans-serif;
  --serif: "Fraunces", Georgia, "Times New Roman", "Songti SC", "SimSun", serif;
  --mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, monospace;

  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

html {
  scroll-behavior: smooth;
  scroll-padding-top: 110px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(120% 90% at 12% -8%, rgba(14, 106, 88, 0.07), transparent 55%),
    radial-gradient(90% 70% at 100% 0%, rgba(185, 130, 28, 0.06), transparent 50%),
    linear-gradient(90deg, rgba(22, 19, 12, 0.028) 1px, transparent 1px) 0 0 / 36px 36px,
    linear-gradient(rgba(22, 19, 12, 0.022) 1px, transparent 1px) 0 0 / 36px 36px,
    var(--paper);
  background-attachment: fixed, fixed, scroll, scroll, scroll;
}

/* Fine grain overlay for paper texture */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 9999;
  pointer-events: none;
  opacity: 0.4;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='120' height='120' filter='url(%23n)' opacity='0.5'/%3E%3C/svg%3E");
  mix-blend-mode: multiply;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

::selection {
  background: rgba(14, 106, 88, 0.22);
}

.page-shell {
  position: relative;
  width: min(1460px, calc(100% - 40px));
  margin: 0 auto;
  padding: 40px 0 72px;
}

#overview,
#structure,
#advanced,
#records {
  scroll-margin-top: 116px;
}

/* ---------- Hero ---------- */
.hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 32px;
  align-items: end;
  min-height: 170px;
  padding: 4px 0 22px;
  border-bottom: 2.5px solid var(--ink);
  position: relative;
}

.hero::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: -2.5px;
  width: 120px;
  height: 2.5px;
  background: var(--red);
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  margin: 0 0 16px;
  color: var(--teal-deep);
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.eyebrow::before {
  content: "";
  width: 22px;
  height: 2px;
  background: var(--gold);
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  max-width: 960px;
  margin-bottom: 12px;
  font-family: var(--serif);
  font-optical-sizing: auto;
  font-size: clamp(3rem, 6.8vw, 6.8rem);
  font-weight: 600;
  line-height: 0.9;
  letter-spacing: -0.02em;
}

.lede {
  max-width: 700px;
  margin-bottom: 0;
  color: var(--ink-soft);
  font-size: clamp(0.96rem, 1.2vw, 1.1rem);
  line-height: 1.52;
}

.hero-side {
  display: grid;
  gap: 18px;
  justify-items: end;
}

.language-switch {
  display: inline-grid;
  grid-template-columns: repeat(2, minmax(56px, 1fr));
  border: 1.5px solid var(--ink);
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.language-switch button {
  border: 0;
  border-right: 1.5px solid var(--ink);
  background: transparent;
  color: var(--ink);
  padding: 8px 12px;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  transition: background 0.18s ease, color 0.18s ease;
}

.language-switch button:last-child {
  border-right: 0;
}

.language-switch button:hover {
  background: rgba(14, 106, 88, 0.1);
}

.language-switch button.active {
  background: var(--ink);
  color: var(--surface);
}

.source-note {
  min-width: 250px;
  border-left: 3px solid var(--red);
  padding: 6px 0 6px 18px;
  text-align: left;
}

.source-note span,
.metric-card span,
.controls span {
  display: block;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.source-note strong {
  display: block;
  margin-top: 7px;
  font-family: var(--mono);
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--ink);
}

/* ---------- Section navigation ---------- */
.section-nav {
  position: sticky;
  top: 0;
  z-index: 70;
  display: flex;
  gap: 8px;
  align-items: center;
  margin: 14px 0 0;
  padding: 8px 0;
  overflow-x: auto;
  background: color-mix(in srgb, var(--paper) 92%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid rgba(196, 185, 160, 0.65);
}

.section-nav a {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  color: var(--ink-soft);
  padding: 5px 11px;
  font-size: 0.82rem;
  font-weight: 800;
  text-decoration: none;
  white-space: nowrap;
  transition: border-color 0.16s ease, background 0.16s ease, color 0.16s ease;
}

.section-nav a:hover,
.section-nav a:focus-visible,
.section-nav a.is-active {
  border-color: var(--line-strong);
  background: var(--surface);
  color: var(--teal-deep);
  outline: none;
}

.section-nav a.is-active {
  border-color: var(--ink);
  box-shadow: inset 0 -2px 0 var(--gold);
}

.overview-section {
  position: relative;
  margin-top: 6px;
  padding: 1px 0 10px;
}

.overview-section::before {
  content: "";
  position: absolute;
  inset: 38px -18px 0;
  z-index: -1;
  border-top: 1px solid rgba(196, 185, 160, 0.55);
  border-bottom: 1px solid rgba(196, 185, 160, 0.45);
  background:
    linear-gradient(180deg, rgba(253, 251, 244, 0.48), rgba(239, 233, 219, 0.2)),
    rgba(253, 251, 244, 0.18);
}

/* ---------- Controls ---------- */
.controls {
  display: grid;
  grid-template-columns: minmax(220px, 1.8fr) repeat(3, minmax(150px, 0.8fr));
  gap: 10px;
  margin: 18px 0 6px;
}

.controls label {
  display: grid;
  gap: 8px;
}

.controls input,
.controls select {
  min-width: 0;
  width: 100%;
  height: 38px;
  border: 1.5px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink);
  padding: 0 14px;
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

.controls input:focus,
.controls select:focus {
  outline: none;
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(14, 106, 88, 0.14);
}

.controls input::placeholder {
  color: var(--muted-2);
}

/* ---------- Filter Chips ---------- */
.filter-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 4px 0 2px;
  min-height: 0;
}

.filter-chips:empty {
  display: none;
}

.view-summary {
  margin: 8px 0 0;
  border-left: 3px solid var(--teal);
  background: rgba(14, 106, 88, 0.07);
  color: var(--ink-soft);
  padding: 8px 12px;
  font-size: 0.88rem;
  line-height: 1.45;
}
.view-return {
  margin-left: 8px;
  border: 1px solid rgba(14, 106, 88, 0.28);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--teal);
  padding: 3px 9px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}
.view-return:hover,
.view-return:focus-visible {
  border-color: var(--teal);
  outline: none;
}

.geo-signal {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 8px;
  margin: 12px 0 0;
}

.geo-tile {
  position: relative;
  display: grid;
  gap: 5px;
  min-height: 72px;
  overflow: hidden;
  border: 1.5px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink);
  padding: 10px;
  text-align: left;
  cursor: pointer;
  isolation: isolate;
  transition: border-color 0.16s ease, transform 0.16s ease, box-shadow 0.16s ease;
}

.geo-tile::before {
  content: "";
  position: absolute;
  inset: auto 0 0 0;
  height: var(--geo-size);
  min-height: 8px;
  background: linear-gradient(180deg, rgba(232, 176, 63, 0.3), rgba(14, 106, 88, 0.22));
  z-index: -1;
}

.geo-tile:hover,
.geo-tile:focus-visible {
  border-color: var(--teal);
  box-shadow: 0 8px 18px rgba(48, 39, 22, 0.08);
  outline: none;
  transform: translateY(-1px);
}

.geo-tile.selected {
  border-color: var(--teal);
  background: rgba(14, 106, 88, 0.08);
}

.geo-tile strong {
  font-size: 0.9rem;
  line-height: 1.15;
}

.geo-tile span {
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.72rem;
  line-height: 1.35;
}

.filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1.5px solid var(--line-strong);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink);
  padding: 5px 12px;
  font-size: 0.8rem;
  line-height: 1;
  transition: border-color 0.16s ease, background 0.16s ease;
}

.filter-chip:hover {
  border-color: var(--teal);
  background: rgba(14, 106, 88, 0.08);
}

.filter-chip-key {
  color: var(--muted);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-size: 0.68rem;
}

.filter-chip-val {
  font-weight: 600;
}

.filter-chip-x {
  color: var(--red);
  font-size: 1rem;
  font-weight: 700;
}

.filter-chip-clear {
  border-style: dashed;
  color: var(--muted);
}

/* ---------- Status ---------- */
.status {
  min-height: 20px;
  margin-top: 18px;
  color: var(--muted);
  font-size: 0.88rem;
  font-family: var(--mono);
}

.status.error {
  color: var(--red);
  font-weight: 600;
}

/* ---------- Metric cards ---------- */
.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin: 16px 0 14px;
}

.metric-card,
.panel {
  border: 1.5px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.metric-card {
  position: relative;
  min-height: 116px;
  padding: 17px 18px 15px;
  overflow: hidden;
  transition: transform 0.22s ease, box-shadow 0.22s ease;
}

.metric-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 3px;
  background: var(--teal);
}

.metric-card:nth-child(2)::before {
  background: var(--blue);
}
.metric-card:nth-child(3)::before {
  background: var(--gold);
}
.metric-card:nth-child(4)::before {
  background: var(--red);
}

.metric-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-lift);
}

.metric-card strong {
  display: block;
  margin: 10px 0 6px;
  font-family: var(--serif);
  font-optical-sizing: auto;
  font-size: clamp(1.7rem, 2.4vw, 2.55rem);
  font-weight: 600;
  line-height: 1;
  letter-spacing: -0.015em;
  font-variant-numeric: tabular-nums;
}

.metric-card small {
  color: var(--muted);
  font-size: 0.82rem;
}

/* ---------- Panels ---------- */
.panel {
  min-width: 0;
  padding: 22px;
}

.panel-wide {
  grid-column: span 1;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 16px;
}

.panel h2 {
  margin-bottom: 5px;
  font-family: var(--serif);
  font-size: 1.15rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.panel p {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.5;
}

/* ---------- Custom analysis panel ---------- */
.analysis-panel {
  margin: 4px 0 16px;
  border-left: 4px solid var(--blue);
}

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

.analysis-card {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: linear-gradient(180deg, rgba(234, 227, 211, 0.55), rgba(234, 227, 211, 0.2));
  padding: 16px;
  transition: transform 0.2s ease, border-color 0.2s ease;
}

.analysis-card:hover {
  transform: translateY(-2px);
  border-color: var(--line-strong);
}

.analysis-card span {
  display: block;
  color: var(--muted);
  font-size: 0.69rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.analysis-card strong {
  display: block;
  margin: 10px 0 6px;
  font-family: var(--serif);
  font-optical-sizing: auto;
  font-size: clamp(1.55rem, 2.4vw, 2.3rem);
  font-weight: 600;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.analysis-card small {
  display: block;
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.4;
}

/* ---------- Clusters ---------- */
.analysis-cluster {
  margin: 26px 0;
}

.cluster-heading {
  display: grid;
  grid-template-columns: minmax(180px, 0.32fr) minmax(0, 1fr);
  gap: 22px;
  align-items: end;
  border-top: 2.5px solid var(--ink);
  padding: 18px 0 14px;
  position: relative;
}

.cluster-heading::before {
  content: "";
  position: absolute;
  top: -2.5px;
  left: 0;
  width: 68px;
  height: 2.5px;
  background: var(--gold);
}

.cluster-heading h2 {
  margin: 0;
  font-family: var(--serif);
  font-optical-sizing: auto;
  font-size: clamp(1.7rem, 2.8vw, 2.7rem);
  font-weight: 600;
  line-height: 1;
  letter-spacing: -0.02em;
}

.cluster-heading p {
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.55;
}

.cluster-columns {
  display: grid;
  gap: 16px;
  align-items: start;
}

.cluster-columns.one-column {
  grid-template-columns: 1fr;
}

.cluster-columns.two-columns {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.cluster-columns.three-columns {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.analysis-module {
  width: 100%;
  height: 560px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* 主体结构区:Owner 大表铺满整行 + 下方三张等高小卡 */
.structure-layout {
  display: grid;
  gap: 16px;
}

.structure-layout .wide-module {
  width: 100%;
  height: 440px;
}

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

.core-module-grid .analysis-module {
  height: 380px;
}

.core-summary-module .analysis-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.core-summary-module .analysis-card {
  min-height: 0;
  padding: 12px;
}

.core-summary-module .analysis-card strong {
  font-size: clamp(1.35rem, 2vw, 2rem);
}

.analysis-module.wide-module {
  grid-column: span 1;
}

.analysis-list {
  display: grid;
  gap: 10px;
}

.analysis-module .analysis-list,
.analysis-module .bar-chart.compact {
  flex: 1;
  min-height: 0;
  max-height: none;
  overflow: auto;
  padding-right: 6px;
}

/* Refined scrollbars */
.analysis-module .analysis-list::-webkit-scrollbar,
.analysis-module .bar-chart.compact::-webkit-scrollbar,
.mini-table-wrap::-webkit-scrollbar,
.report-preview::-webkit-scrollbar,
.table-wrap::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

.analysis-module .analysis-list::-webkit-scrollbar-thumb,
.analysis-module .bar-chart.compact::-webkit-scrollbar-thumb,
.mini-table-wrap::-webkit-scrollbar-thumb,
.report-preview::-webkit-scrollbar-thumb,
.table-wrap::-webkit-scrollbar-thumb {
  background: var(--line-strong);
  border-radius: 8px;
}

.insight-row {
  display: grid;
  gap: 6px;
  border-left: 3px solid var(--blue);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  background: linear-gradient(90deg, rgba(35, 95, 143, 0.08), rgba(234, 227, 211, 0.25));
  padding: 11px 12px;
  transition: background 0.18s ease;
}

.insight-row:hover {
  background: linear-gradient(90deg, rgba(35, 95, 143, 0.14), rgba(234, 227, 211, 0.3));
}

.insight-row strong {
  font-size: 0.94rem;
  font-weight: 700;
}

.insight-row span,
.insight-row small {
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.4;
}

/* ---------- Mini table ---------- */
.mini-table-wrap {
  flex: 1;
  min-height: 0;
  overflow: auto;
}

.mini-table {
  min-width: 620px;
}

.mini-table th,
.mini-table td {
  padding: 9px 6px;
  font-size: 0.82rem;
}

.mini-table td {
  font-variant-numeric: tabular-nums;
}

/* ---------- Report module ---------- */
.report-button {
  width: fit-content;
  border: 1.5px solid var(--ink);
  border-radius: var(--radius-sm);
  background: var(--ink);
  color: var(--surface);
  padding: 11px 18px;
  font-weight: 700;
  letter-spacing: 0.02em;
  transition: transform 0.16s ease, box-shadow 0.16s ease, background 0.16s ease;
}

.report-button:hover {
  background: var(--teal-deep);
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}

.report-button:active {
  transform: translateY(0);
}

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

.report-config label {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--ink-soft);
  font-size: 0.86rem;
  font-weight: 600;
}

.report-config input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--teal);
}

.report-config input[type="number"] {
  width: 72px;
  border: 1.5px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  padding: 6px 8px;
}

.report-preview {
  flex: 1;
  min-height: 0;
  max-height: none;
  overflow: auto;
  margin-top: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: #1c1912;
  color: #e9e2cf;
  padding: 16px;
  font-family: var(--mono);
  font-size: 0.82rem;
  white-space: pre-wrap;
  line-height: 1.55;
}

/* ---------- Dashboard grid ---------- */
.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(320px, 0.9fr);
  gap: 16px;
  margin-top: 4px;
}

/* ---------- Bar charts ---------- */
.bar-chart {
  display: grid;
  gap: 11px;
}

.bar-row {
  display: grid;
  grid-template-columns: minmax(130px, 0.9fr) minmax(120px, 2fr) 84px;
  gap: 14px;
  align-items: center;
  min-height: 34px;
}

.bar-button {
  display: grid;
  width: 100%;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: inherit;
  padding: 4px 5px;
  text-align: left;
  transition: background 0.16s ease;
}

.bar-button:hover,
.bar-button:focus-visible,
.bar-button.selected {
  background: rgba(14, 106, 88, 0.1);
  outline: 1px solid rgba(14, 106, 88, 0.28);
}

.bar-button.selected {
  outline: 1.5px solid var(--teal);
}

.bar-label {
  overflow: hidden;
  color: var(--ink);
  font-size: 0.88rem;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bar-track {
  position: relative;
  height: 20px;
  border-radius: 3px;
  background:
    repeating-linear-gradient(
      90deg,
      rgba(22, 19, 12, 0.04) 0,
      rgba(22, 19, 12, 0.04) 1px,
      transparent 1px,
      transparent 12px
    ),
    var(--surface-2);
  box-shadow: inset 0 0 0 1px rgba(22, 19, 12, 0.08);
  overflow: hidden;
}

.bar-fill {
  width: var(--width);
  height: 100%;
  border-radius: 3px 2px 2px 3px;
  background: linear-gradient(90deg, var(--data-1), var(--data-3));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.18);
  transform-origin: left center;
  animation: bar-grow 0.7s cubic-bezier(0.22, 1, 0.36, 1) both;
}

@keyframes bar-grow {
  from {
    transform: scaleX(0);
    opacity: 0.4;
  }
  to {
    transform: scaleX(1);
    opacity: 1;
  }
}

.bar-button.selected .bar-fill {
  background: linear-gradient(90deg, var(--gold), #d29b2f);
}

.bar-value {
  color: var(--ink-soft);
  font-family: var(--mono);
  font-size: 0.82rem;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

/* ---------- Country list ---------- */
.country-list {
  display: grid;
  gap: 11px;
}

.country-item {
  display: grid;
  grid-template-columns: minmax(70px, 1fr) auto;
  gap: 10px;
  align-items: center;
  width: 100%;
  border: 0;
  border-bottom: 1px solid var(--line);
  padding: 4px 6px 11px;
  background: transparent;
  color: inherit;
  text-align: left;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  transition: background 0.16s ease;
}

.country-item:hover,
.country-item:focus-visible {
  background: rgba(14, 106, 88, 0.08);
  outline: none;
}

.country-item.selected {
  background: rgba(14, 106, 88, 0.12);
  outline: 1.5px solid var(--teal);
}

.country-item:last-child {
  border-bottom: 0;
}

.country-name {
  font-weight: 700;
}

.country-meta {
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.8rem;
  text-align: right;
}

/* ---------- Timeline SVG ---------- */
.timeline-chart {
  width: 100%;
  overflow: hidden;
}

.timeline-chart svg {
  display: block;
  width: 100%;
  height: 268px;
}

.axis-label {
  fill: var(--muted);
  font-family: var(--mono);
  font-size: 11px;
}

.point-label {
  fill: var(--teal-deep);
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 600;
}

/* ---------- Detail panel ---------- */
.table-panel {
  margin-top: 16px;
}

.records-meta {
  align-self: start;
  margin: 0;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.78rem;
  white-space: nowrap;
}

.table-scroll-hint {
  margin: 4px 0 10px;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.4;
}

/* 右侧滑出详情抽屉 */
.detail-drawer {
  position: fixed;
  left: 50%;
  right: auto;
  bottom: 24px;
  top: auto;
  width: min(960px, 94vw);
  height: auto;
  max-height: 82vh;
  z-index: 900;
  margin: 0;
  border: 1.5px solid var(--line);
  border-top: 4px solid var(--teal);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lift);
  overflow-y: auto;
  transform: translate(-50%, calc(100% + 32px));
  transition: transform 0.28s cubic-bezier(0.22, 1, 0.36, 1);
}

.detail-drawer.open {
  transform: translate(-50%, 0);
}

.drawer-overlay {
  position: fixed;
  inset: 0;
  z-index: 890;
  background: rgba(22, 19, 12, 0.42);
  opacity: 0;
  transition: opacity 0.28s ease;
}

.drawer-overlay.open {
  opacity: 1;
}

.drawer-close {
  align-self: start;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 1.7rem;
  line-height: 1;
  padding: 0 2px;
  transition: color 0.16s ease;
}

.drawer-close:hover,
.drawer-close:focus-visible {
  color: var(--red);
  outline: none;
}

.detail-drawer .detail-grid {
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}

.detail-drawer .detail-metrics {
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
}

.detail-header {
  border-bottom: 1px solid var(--line);
  padding-bottom: 14px;
}

.detail-header h2 {
  font-size: 1.5rem;
}

.detail-metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin: 16px 0;
}

.detail-metric {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: linear-gradient(180deg, rgba(234, 227, 211, 0.55), rgba(234, 227, 211, 0.2));
  padding: 14px;
}

.detail-metric span,
.kv-item span,
.record-item span,
.event-item span {
  color: var(--muted);
  font-size: 0.78rem;
}

.detail-metric span {
  display: block;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-size: 0.68rem;
}

.detail-metric strong {
  display: block;
  margin-top: 8px;
  font-family: var(--serif);
  font-optical-sizing: auto;
  font-size: 1.6rem;
  font-weight: 600;
  line-height: 1.05;
  font-variant-numeric: tabular-nums;
}

.detail-grid {
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr) minmax(260px, 0.8fr);
  gap: 16px;
}

.detail-section {
  min-width: 0;
  border-top: 2.5px solid var(--ink);
  padding-top: 14px;
}

.detail-section-wide {
  grid-column: span 2;
}

.detail-section h3 {
  margin: 0 0 12px;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.kv-list,
.record-list,
.event-list,
.source-links {
  display: grid;
  gap: 10px;
}

.kv-item {
  display: grid;
  gap: 3px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 9px;
}

.kv-item strong {
  font-size: 0.92rem;
  line-height: 1.35;
}

.facet-link {
  border: 0;
  background: transparent;
  color: var(--blue);
  padding: 0;
  font: inherit;
  font-weight: 700;
  text-align: left;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

.facet-link:hover,
.facet-link:focus-visible {
  color: var(--red);
  outline: none;
}

.record-item,
.event-item {
  display: grid;
  gap: 4px;
  border-left: 3px solid var(--teal);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  background: linear-gradient(90deg, rgba(14, 106, 88, 0.07), rgba(234, 227, 211, 0.22));
  padding: 10px 12px;
}

.record-item strong {
  font-size: 0.95rem;
}

.event-item {
  border-left-color: var(--red);
  background: linear-gradient(90deg, rgba(187, 63, 40, 0.07), rgba(234, 227, 211, 0.22));
}

.event-item time {
  color: var(--red);
  font-family: var(--mono);
  font-size: 0.74rem;
  font-weight: 600;
}

.event-item p {
  margin: 0;
  color: var(--ink);
  font-size: 0.9rem;
  line-height: 1.4;
}

.source-links a {
  color: var(--blue);
  font-size: 0.9rem;
  font-weight: 600;
  line-height: 1.4;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
  transition: color 0.16s ease;
}

.source-links a:hover {
  color: var(--red);
}

/* ---------- Records table ---------- */
.table-wrap {
  max-height: 430px;
  overflow: auto;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

table {
  width: 100%;
  min-width: 840px;
  border-collapse: collapse;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 11px 8px;
  text-align: left;
  vertical-align: top;
}

th {
  position: sticky;
  top: 0;
  background: var(--surface);
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  border-bottom: 2px solid var(--ink);
}

.table-sort {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 0;
  background: transparent;
  color: inherit;
  padding: 0;
  font: inherit;
  letter-spacing: inherit;
  text-transform: inherit;
  cursor: pointer;
}

.table-sort::after {
  content: "↕";
  color: var(--muted-2);
  font-size: 0.72rem;
}

.table-sort[aria-sort="ascending"]::after {
  content: "↑";
  color: var(--teal);
}

.table-sort[aria-sort="descending"]::after {
  content: "↓";
  color: var(--teal);
}

.table-sort:hover,
.table-sort:focus-visible {
  color: var(--ink);
  outline: none;
}

td {
  font-size: 0.9rem;
}

tbody tr {
  transition: background 0.14s ease;
}

tbody tr:hover td {
  background: rgba(14, 106, 88, 0.05);
}

tr.selected-row td {
  background: rgba(14, 106, 88, 0.12);
}

.table-select {
  border: 0;
  background: transparent;
  color: var(--blue);
  padding: 0;
  font-weight: 700;
  text-align: left;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
  transition: color 0.14s ease;
}

.table-select:hover,
.table-select:focus-visible {
  color: var(--red);
  outline: none;
}

td.numeric {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  text-align: right;
}

code {
  font-family: var(--mono);
  color: var(--red);
}

/* ---------- Entrance choreography ---------- */
@media (prefers-reduced-motion: no-preference) {
  .hero,
  .controls,
  .metric-grid,
  .analysis-panel,
  .analysis-cluster,
  .dashboard-grid,
  .detail-panel,
  .table-panel {
    animation: rise 0.6s cubic-bezier(0.22, 1, 0.36, 1) both;
  }

  .controls {
    animation-delay: 0.05s;
  }
  .metric-grid {
    animation-delay: 0.1s;
  }
  .analysis-panel {
    animation-delay: 0.15s;
  }
  .analysis-cluster {
    animation-delay: 0.18s;
  }

  @keyframes rise {
    from {
      opacity: 0;
      transform: translateY(16px);
    }
    to {
      opacity: 1;
      transform: translateY(0);
    }
  }
}

/* ---------- Responsive ---------- */
@media (max-width: 980px) {
  .hero,
  .controls,
  .metric-grid,
  .analysis-grid,
  .dashboard-grid,
  .detail-metrics,
  .detail-grid {
    grid-template-columns: 1fr;
  }

  .cluster-heading {
    grid-template-columns: 1fr;
  }

  .cluster-columns,
  .cluster-columns.two-columns,
  .cluster-columns.three-columns {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .core-module-grid {
    grid-template-columns: 1fr;
  }

  .cluster-columns.one-column {
    grid-template-columns: 1fr;
  }

  .analysis-module.wide-module {
    grid-column: span 1;
  }

  .detail-section-wide {
    grid-column: span 1;
  }

  .source-note {
    min-width: 0;
  }

  .hero-side {
    justify-items: start;
  }
}

@media (max-width: 640px) {
  .page-shell {
    width: min(100% - 24px, 1460px);
    padding-top: 18px;
  }

  h1 {
    font-size: clamp(2.7rem, 13vw, 4.6rem);
  }

  .cluster-columns,
  .cluster-columns.one-column,
  .cluster-columns.two-columns,
  .cluster-columns.three-columns {
    grid-template-columns: 1fr;
  }

  .analysis-module {
    height: 540px;
  }

  .core-module-grid .analysis-module {
    height: 540px;
  }

  .core-module-grid .core-summary-module {
    height: auto;
  }

  .core-summary-module .analysis-grid {
    grid-template-columns: 1fr;
  }

  .bar-row {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 5px 10px;
    align-items: start;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--line);
  }

  .bar-label {
    grid-column: 1;
    grid-row: 1;
    min-width: 0;
  }

  .bar-track {
    grid-column: 1 / -1;
    grid-row: 2;
  }

  .bar-value {
    grid-column: 2;
    grid-row: 1;
    text-align: left;
    white-space: nowrap;
  }

  .geo-signal {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .tool-drawer > summary.cluster-heading {
    grid-template-columns: 1fr;
    padding-right: 30px;
  }

  .drawer-summary-stat {
    justify-self: start;
    white-space: normal;
  }
}

/* ---------- Task 6: Sticky command bar ---------- */
.controls {
  position: sticky;
  top: 47px;
  z-index: 60;
  background: var(--paper);
  padding-top: 12px;
  padding-bottom: 8px;
  box-shadow: 0 10px 20px -18px rgba(48, 39, 22, 0.5);
}

/* ---------- Task 6: Collapsible zone (<details>) ---------- */
.zone > summary {
  cursor: pointer;
  list-style: none;
  position: relative;
}

.zone > summary::-webkit-details-marker {
  display: none;
}

.zone > summary::after {
  content: "▸";
  position: absolute;
  right: 4px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  font-size: 0.9rem;
  transition: transform 0.2s ease;
}

.zone[open] > summary::after {
  transform: translateY(-50%) rotate(90deg);
}

.zone > summary:hover h2 {
  color: var(--teal-deep);
}

.tool-drawer {
  margin: 12px 0;
}

.tool-drawer > summary.cluster-heading {
  grid-template-columns: minmax(160px, 0.24fr) minmax(0, 1fr) auto;
  align-items: center;
  min-height: 58px;
  border-top: 1.5px solid var(--line-strong);
  padding: 11px 36px 11px 0;
}

.tool-drawer > summary.cluster-heading::before {
  width: 44px;
  height: 1.5px;
  top: -1.5px;
}

.tool-drawer > summary.cluster-heading h2 {
  font-size: clamp(1.15rem, 1.9vw, 1.65rem);
}

.tool-drawer > summary.cluster-heading p {
  font-size: 0.86rem;
}

.drawer-summary-stat {
  justify-self: end;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.5);
  color: var(--ink-soft);
  padding: 5px 10px;
  font-family: var(--mono);
  font-size: 0.72rem;
  line-height: 1.2;
  white-space: nowrap;
}

.tool-drawer[open] > summary.cluster-heading {
  border-top-color: var(--ink);
}

/* ---------- Task 6: Insight ribbon compaction ---------- */
.insight-ribbon .analysis-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.insight-ribbon .analysis-card {
  padding: 12px 14px;
}

.insight-ribbon .analysis-card strong {
  font-size: clamp(1.2rem, 1.8vw, 1.6rem);
  margin: 6px 0 4px;
}

.insight-ribbon .analysis-card small {
  font-size: 0.74rem;
}

/* ---------- Task 6: Insight feed + inline module conclusions ---------- */
.insight-feed {
  display: grid;
  gap: 12px;
  margin: 14px 0 14px;
}
.insight-feed:empty { display: none; }
.insight-feed-title {
  grid-column: 1 / -1;
  margin: 0;
  font-family: var(--serif);
  font-size: 1.28rem;
  font-weight: 600;
}
@media (min-width: 720px) {
  .insight-feed { grid-template-columns: minmax(0, 1.25fr) repeat(3, minmax(0, 0.9fr)); }
  .insight-feed-title { grid-column: 1 / -1; }
}
.insight-card {
  display: grid;
  gap: 4px;
  text-align: left;
  border: 1.5px solid var(--line);
  border-left: 4px solid var(--muted);
  border-radius: var(--radius-sm);
  background: var(--surface);
  padding: 12px 14px;
  transition: transform 0.16s ease, box-shadow 0.16s ease, border-color 0.16s ease;
}
.insight-card:hover,
.insight-card:focus-visible {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
  outline: none;
}
.insight-card strong { font-size: 0.95rem; line-height: 1.35; }
.insight-card span { color: var(--muted); font-size: 0.82rem; line-height: 1.4; }
.insight-primary {
  min-height: 132px;
  border-left-width: 6px;
  background:
    linear-gradient(135deg, rgba(253, 251, 244, 0.96), rgba(234, 227, 211, 0.5)),
    var(--surface);
  padding: 18px 20px;
}
.insight-primary strong {
  font-family: var(--serif);
  font-size: clamp(1.2rem, 1.8vw, 1.7rem);
  font-weight: 600;
  letter-spacing: -0.01em;
}
.insight-primary span {
  font-size: 0.9rem;
}
.insight-secondary {
  align-content: start;
  min-height: 132px;
  background: rgba(253, 251, 244, 0.82);
}
.insight-more {
  justify-self: start;
  grid-column: 1 / -1;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--ink-soft);
  padding: 7px 12px;
  font-size: 0.82rem;
  font-weight: 700;
}
.insight-more:hover,
.insight-more:focus-visible {
  border-color: var(--teal);
  color: var(--teal-deep);
  outline: none;
}
.insight-card.theme-concentration { border-left-color: var(--teal); }
.insight-card.theme-efficiency { border-left-color: var(--blue); }
.insight-card.theme-geochip { border-left-color: var(--gold); }
.insight-card.theme-growthquality { border-left-color: var(--red); }
.insight-inline {
  border: 0;
  border-left: 3px solid var(--muted);
  border-radius: 0;
  background: transparent;
  padding: 6px 0 6px 10px;
  margin-bottom: 10px;
}
.insight-inline:hover { transform: none; box-shadow: none; }
.insight-inline strong { font-size: 0.85rem; color: var(--ink-soft); font-weight: 600; }
.insight-empty { color: var(--muted); font-size: 0.9rem; }

.compare-panel { display: grid; gap: 12px; margin: 18px 0; }
.compare-panel[hidden] { display: none; }
.compare-heading { margin: 0; font-family: var(--serif); font-size: 1.2rem; font-weight: 600; }
.compare-block { padding: 18px; }
.compare-block h3 { margin: 0 0 6px; font-size: 1rem; font-weight: 700; }
.compare-conclusion { margin: 0 0 12px; color: var(--ink-soft); font-size: 0.92rem; line-height: 1.5; }
.compare-table { width: 100%; min-width: 0; border-collapse: collapse; }
.compare-table th[scope="row"] {
  text-align: left; color: var(--muted); font-size: 0.8rem; font-weight: 700;
  text-transform: none; letter-spacing: 0; border-bottom: 1px solid var(--line);
}
.compare-table thead th { border-bottom: 2px solid var(--ink); font-size: 0.85rem; }
.compare-table td.compare-winner { background: rgba(14, 106, 88, 0.12); font-weight: 700; }
.compare-strengths { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.compare-strength-tag {
  border: 1px solid var(--line-strong); border-radius: 999px;
  padding: 4px 10px; font-size: 0.78rem; color: var(--ink-soft);
}

.correlation-panel {
  height: auto;
  min-height: 0;
  overflow: visible;
  margin: 0;
}

.structure-layout .correlation-panel {
  height: auto;
  overflow: visible;
}
.correlation-plot {
  margin-top: 10px;
  border-top: 1px solid var(--line);
  padding-top: 10px;
}
.correlation-plot > summary {
  cursor: pointer;
  width: fit-content;
  color: var(--blue);
  font-size: 0.86rem;
  font-weight: 700;
}
.correlation-plot > summary:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 3px;
}
.scatter-axes { display: flex; flex-wrap: wrap; gap: 12px; }
.scatter-axes label { display: grid; gap: 4px; }
.scatter-axes span { color: var(--muted); font-size: 0.68rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; }
.scatter-axes select { height: 36px; border: 1.5px solid var(--line-strong); border-radius: var(--radius-sm); background: var(--surface); color: var(--ink); padding: 0 10px; }
.scatter-chart {
  width: 100%;
  min-height: 260px;
  overflow: visible;
  margin-top: 8px;
}
.scatter-chart svg { display: block; width: 100%; height: auto; }
.scatter-dot { cursor: pointer; transition: opacity 0.15s ease; }
.scatter-dot:hover, .scatter-dot:focus-visible { opacity: 0.7; outline: none; }
.correlation-conclusion { margin: 10px 0 0; color: var(--ink-soft); font-size: 0.95rem; line-height: 1.5; }

.whatif-panel { margin: 0; }
.whatif-controls { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
@media (max-width: 720px) { .whatif-controls { grid-template-columns: 1fr; } }
.whatif-form { display: grid; gap: 8px; border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 14px; }
.whatif-form h3 { margin: 0 0 4px; font-size: 0.9rem; font-weight: 700; }
.whatif-form input, .whatif-form select { min-width: 0; width: 100%; height: 34px; border: 1.5px solid var(--line-strong); border-radius: var(--radius-sm); background: var(--surface); color: var(--ink); padding: 0 10px; }
.whatif-btn { height: 36px; border: 1.5px solid var(--ink); border-radius: var(--radius-sm); background: var(--ink); color: var(--surface); font-weight: 700; }
.whatif-btn:hover { background: var(--teal-deep); }
.whatif-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.whatif-chips:empty { display: none; }
.whatif-reset { margin-top: 10px; border: 1px dashed var(--line-strong); border-radius: var(--radius-sm); background: transparent; color: var(--muted); padding: 6px 12px; }
.whatif-impact { display: grid; gap: 8px; margin-top: 14px; }
.whatif-emptystate { color: var(--muted); font-size: 0.9rem; margin: 12px 0 0; }
.impact-row { display: grid; grid-template-columns: minmax(120px, 0.5fr) minmax(0, 1fr); gap: 12px; align-items: center; border-bottom: 1px solid var(--line); padding-bottom: 8px; }
.impact-label { color: var(--muted); font-size: 0.82rem; font-weight: 700; }
.impact-values { font-variant-numeric: tabular-nums; }
.impact-delta { font-weight: 700; margin-left: 4px; }
.impact-delta.up { color: var(--teal); }
.impact-delta.down { color: var(--red); }
.impact-delta.flat { color: var(--muted); }

.whatif-insights { display: grid; gap: 8px; margin-top: 16px; }
.whatif-insights-title { margin: 0; font-size: 0.9rem; font-weight: 700; }
.whatif-insight-card { display: grid; gap: 3px; border-left: 3px solid var(--gold); background: rgba(185, 130, 28, 0.08); border-radius: 0 var(--radius-sm) var(--radius-sm) 0; padding: 8px 12px; }
.whatif-insight-card strong { font-size: 0.9rem; }
.whatif-insight-card span { color: var(--muted); font-size: 0.8rem; line-height: 1.4; }

.compare-empty {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.5;
}

/* ---------- Mobile refinements (kept last so source order wins over base rules) ---------- */
@media (max-width: 640px) {
  /* Definitive guard: never let anything scroll the page sideways on phones.
     `clip` (unlike `hidden`) does not create a scroll container, so the sticky
     section-nav keeps working. Per-element fixes below keep content from being
     clipped in the first place at common widths (360-430). */
  .page-shell {
    overflow-x: clip;
  }

  /* The filter bar stacks into a tall column on phones; sticky made it pin and
     cover most of the screen while scrolling. Let it scroll away normally. */
  .controls {
    position: static;
    top: auto;
    padding-top: 0;
    padding-bottom: 0;
    box-shadow: none;
  }

  /* Stat cards: 2-up grid instead of one tall full-width column. */
  .metric-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }

  .metric-card {
    min-height: 92px;
    padding: 13px 13px 12px;
  }

  .metric-card strong {
    margin: 7px 0 5px;
    font-size: clamp(1.35rem, 6.4vw, 1.9rem);
  }

  .metric-card small {
    font-size: 0.75rem;
  }

  /* Remove the ~6px horizontal decorative bleed that caused sideways scroll. */
  .overview-section::before {
    inset: 38px 0 0;
  }

  /* Collapse the tool-drawer summary to a single column and let its stat pill
     wrap. The earlier @media rules for these were clobbered by later base
     rules (source order), leaving a 3-column grid + nowrap pill that overflowed
     on 360/375px screens. Redeclared here so they win. */
  .tool-drawer > summary.cluster-heading {
    grid-template-columns: 1fr;
    padding-right: 30px;
  }

  .drawer-summary-stat {
    justify-self: start;
    white-space: normal;
  }
}
