/* ==========================================================================
   National Development Index (国家发达程度指数 / NDI) Database & Web Platform
   Design System: Dual-Theme Empirical Editorial (school_ranking) + Celestial Hub (destination_rankings)
   ========================================================================== */

:root {
  --bg: #f6f4ef;
  --bg-elev: #ffffff;
  --bg-subtle: #eeeae0;
  --bg-hover: #e6e1d5;
  --ink: #15181e;
  --ink-2: #3b404c;
  --ink-muted: #6c727f;
  --rule: #dcd6c8;
  --rule-strong: #15181e;
  --accent: #1d4ed8;
  --accent-soft: rgba(29, 78, 216, 0.10);
  --accent-2: #b45309;
  --accent-3: #047857;
  --danger: #be123c;
  --card-shadow: 0 2px 10px rgba(20, 24, 30, 0.05);
  --card-shadow-hover: 0 10px 26px rgba(20, 24, 30, 0.10);

  /* Tier colors */
  --t1-bg: rgba(5, 150, 105, 0.13);
  --t1-fg: #065f46;
  --t1-bd: rgba(5, 150, 105, 0.35);
  --t2-bg: rgba(37, 99, 235, 0.13);
  --t2-fg: #1e40af;
  --t2-bd: rgba(37, 99, 235, 0.35);
  --t3-bg: rgba(8, 145, 178, 0.13);
  --t3-fg: #155e75;
  --t3-bd: rgba(8, 145, 178, 0.35);
  --t4-bg: rgba(217, 119, 6, 0.13);
  --t4-fg: #92400e;
  --t4-bd: rgba(217, 119, 6, 0.35);
  --t5-bg: rgba(234, 88, 12, 0.13);
  --t5-fg: #9a3412;
  --t5-bd: rgba(234, 88, 12, 0.35);
  --t6-bg: rgba(225, 29, 72, 0.12);
  --t6-fg: #9f1239;
  --t6-bd: rgba(225, 29, 72, 0.32);
  --t7-bg: rgba(107, 114, 128, 0.15);
  --t7-fg: #374151;
  --t7-bd: rgba(107, 114, 128, 0.35);

  --serif: "Noto Serif SC", "Source Han Serif SC", Georgia, "Times New Roman", serif;
  --sans: "Noto Sans SC", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", -apple-system, BlinkMacSystemFont, sans-serif;
  --mono: "IBM Plex Mono", "JetBrains Mono", ui-monospace, Menlo, Consolas, monospace;
}

html[data-theme="dark"] {
  --bg: #0b0f17;
  --bg-elev: #131a27;
  --bg-subtle: #1a2333;
  --bg-hover: #232f44;
  --ink: #f1f5f9;
  --ink-2: #cbd5e1;
  --ink-muted: #8b9bb4;
  --rule: #263248;
  --rule-strong: #e2e8f0;
  --accent: #60a5fa;
  --accent-soft: rgba(96, 165, 250, 0.14);
  --accent-2: #fbbf24;
  --accent-3: #34d399;
  --danger: #fb7185;
  --card-shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
  --card-shadow-hover: 0 12px 32px rgba(0, 0, 0, 0.55);

  --t1-bg: rgba(16, 185, 129, 0.18);
  --t1-fg: #6ee7b7;
  --t1-bd: rgba(16, 185, 129, 0.4);
  --t2-bg: rgba(59, 130, 246, 0.20);
  --t2-fg: #93c5fd;
  --t2-bd: rgba(59, 130, 246, 0.45);
  --t3-bg: rgba(6, 182, 212, 0.18);
  --t3-fg: #67e8f9;
  --t3-bd: rgba(6, 182, 212, 0.4);
  --t4-bg: rgba(245, 158, 11, 0.18);
  --t4-fg: #fcd34d;
  --t4-bd: rgba(245, 158, 11, 0.4);
  --t5-bg: rgba(249, 115, 22, 0.18);
  --t5-fg: #fdba74;
  --t5-bd: rgba(249, 115, 22, 0.4);
  --t6-bg: rgba(244, 63, 94, 0.18);
  --t6-fg: #fda4af;
  --t6-bd: rgba(244, 63, 94, 0.4);
  --t7-bg: rgba(148, 163, 184, 0.18);
  --t7-fg: #cbd5e1;
  --t7-bd: rgba(148, 163, 184, 0.4);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
  font-size: 15px;
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  transition: background-color 0.2s ease, color 0.2s ease;
}

a {
  color: var(--accent);
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
}

/* --------------------------------------------------------------------------
   Top Sticky Navigation Bar
   -------------------------------------------------------------------------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--bg-elev);
  border-bottom: 1px solid var(--rule);
  backdrop-filter: blur(12px);
}
.topbar-inner {
  max-width: 1440px;
  margin: 0 auto;
  padding: 0 24px;
  height: 58px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--serif);
  font-weight: 700;
  font-size: 1.12rem;
  color: var(--ink);
  text-decoration: none !important;
  white-space: nowrap;
}
.brand-badge {
  font-family: var(--mono);
  font-size: 0.72rem;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 4px;
  background: var(--accent);
  color: #fff;
  letter-spacing: 0.04em;
}
.brand-title {
  display: inline;
}
.nav-toggle-btn {
  display: none;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border: 1px solid var(--rule);
  border-radius: 8px;
  background: var(--bg-elev);
  color: var(--ink);
  cursor: pointer;
}
.mobile-nav-drawer {
  border-top: 1px solid var(--rule);
  background: var(--bg-elev);
  padding: 10px 16px 14px;
}
.mobile-nav-drawer[hidden] {
  display: none !important;
}
.mobile-nav-links {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.mobile-nav-links a,
.bottom-tabbar a {
  text-decoration: none !important;
}
.mobile-nav-link {
  display: block;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--rule);
  text-align: center;
  font-weight: 600;
  color: var(--ink-2);
  background: var(--bg-subtle);
}
.mobile-nav-link.active {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
}
.bottom-tabbar {
  display: none;
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 90;
  grid-template-columns: repeat(4, 1fr);
  gap: 0;
  border-top: 1px solid var(--rule);
  background: var(--bg-elev);
  padding: 6px 4px calc(6px + env(safe-area-inset-bottom, 0px));
  box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.08);
}
.bottom-tabbar a {
  padding: 8px 4px;
  font-size: 0.78rem;
  font-weight: 600;
  text-align: center;
  color: var(--ink-muted);
  border-radius: 6px;
}
.bottom-tabbar a.active {
  color: var(--accent);
  background: var(--accent-soft);
}
.topnav {
  display: flex;
  align-items: center;
  gap: 4px;
  overflow-x: auto;
}
.topnav a {
  padding: 7px 13px;
  border-radius: 6px;
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--ink-2);
  text-decoration: none;
  white-space: nowrap;
  transition: all 0.15s ease;
}
.topnav a:hover {
  background: var(--bg-subtle);
  color: var(--ink);
}
.topnav a.active {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}
.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}
.search-trigger-btn,
.theme-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 11px;
  border-radius: 6px;
  border: 1px solid var(--rule);
  background: var(--bg-subtle);
  color: var(--ink-2);
  font-size: 0.82rem;
  font-family: var(--sans);
  cursor: pointer;
  transition: all 0.15s ease;
}
.search-trigger-btn:hover,
.theme-btn:hover {
  border-color: var(--accent);
  color: var(--ink);
}
.kbd-hint {
  font-family: var(--mono);
  font-size: 0.72rem;
  padding: 1px 5px;
  border-radius: 3px;
  background: var(--bg-elev);
  border: 1px solid var(--rule);
  color: var(--ink-muted);
}

/* --------------------------------------------------------------------------
   Container & Masthead
   -------------------------------------------------------------------------- */
.container {
  max-width: 1440px;
  margin: 0 auto;
  padding: 28px 24px 72px;
}

.masthead {
  border-bottom: 2px solid var(--rule-strong);
  padding-bottom: 26px;
  margin-bottom: 32px;
}
.kicker {
  font-family: var(--mono);
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--accent);
  font-weight: 600;
  margin-bottom: 8px;
}
.masthead h1 {
  font-family: var(--serif);
  font-size: clamp(1.85rem, 3.2vw, 2.75rem);
  font-weight: 700;
  line-height: 1.2;
  color: var(--ink);
  margin-bottom: 12px;
}
.masthead .sub {
  font-size: 1rem;
  color: var(--ink-2);
  max-width: 980px;
  line-height: 1.65;
}
.meta-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 24px;
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--rule);
  font-size: 0.83rem;
  color: var(--ink-muted);
}
.meta-bar strong {
  color: var(--ink);
  font-family: var(--mono);
}

/* KPI Strip */
.kpi-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 14px;
  margin-bottom: 32px;
}
.kpi-card {
  background: var(--bg-elev);
  border: 1px solid var(--rule);
  border-radius: 8px;
  padding: 16px 18px;
  box-shadow: var(--card-shadow);
}
.kpi-label {
  font-size: 0.78rem;
  color: var(--ink-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-family: var(--mono);
  margin-bottom: 4px;
}
.kpi-val {
  font-family: var(--serif);
  font-size: 1.65rem;
  font-weight: 700;
  color: var(--ink);
  line-height: 1.2;
}
.kpi-sub {
  font-size: 0.8rem;
  color: var(--ink-2);
  margin-top: 4px;
}

/* --------------------------------------------------------------------------
   Section Headers (modeled after college.html 01..04)
   -------------------------------------------------------------------------- */
.section {
  margin-bottom: 52px;
  scroll-margin-top: 74px;
}
.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  border-bottom: 2px solid var(--rule-strong);
  padding-bottom: 10px;
  margin-bottom: 18px;
}
.section-head-left {
  display: flex;
  align-items: baseline;
  gap: 12px;
}
.section-head .num {
  font-family: var(--mono);
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 2px 8px;
  border-radius: 4px;
}
.section-head h2 {
  font-family: var(--serif);
  font-size: 1.45rem;
  font-weight: 700;
  color: var(--ink);
}
.section-head .sub {
  font-size: 0.83rem;
  color: var(--ink-muted);
  font-family: var(--mono);
}
.section-desc {
  color: var(--ink-2);
  font-size: 0.94rem;
  margin-bottom: 18px;
  max-width: 1050px;
}

/* --------------------------------------------------------------------------
   Callout & Note Boxes
   -------------------------------------------------------------------------- */
.note-box {
  background: var(--bg-elev);
  border: 1px solid var(--rule);
  border-left: 4px solid var(--accent);
  border-radius: 6px;
  padding: 16px 20px;
  margin-bottom: 22px;
  font-size: 0.9rem;
  color: var(--ink-2);
  box-shadow: var(--card-shadow);
}
.note-box strong {
  color: var(--ink);
}
.note-box.warn {
  border-left-color: var(--accent-2);
}
.note-box.success {
  border-left-color: var(--accent-3);
}

/* --------------------------------------------------------------------------
   Tier Badges & Pills
   -------------------------------------------------------------------------- */
.tier-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid transparent;
  white-space: nowrap;
}
.tier-T1 { background: var(--t1-bg); color: var(--t1-fg); border-color: var(--t1-bd); }
.tier-T2 { background: var(--t2-bg); color: var(--t2-fg); border-color: var(--t2-bd); }
.tier-T3 { background: var(--t3-bg); color: var(--t3-fg); border-color: var(--t3-bd); }
.tier-T4 { background: var(--t4-bg); color: var(--t4-fg); border-color: var(--t4-bd); }
.tier-T5 { background: var(--t5-bg); color: var(--t5-fg); border-color: var(--t5-bd); }
.tier-T6 { background: var(--t6-bg); color: var(--t6-fg); border-color: var(--t6-bd); }
.tier-T7 { background: var(--t7-bg); color: var(--t7-fg); border-color: var(--t7-bd); }

/* 7 Development Tiers Grid on Index */
.tier-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 14px;
  margin-bottom: 24px;
}
.tier-card {
  background: var(--bg-elev);
  border: 1px solid var(--rule);
  border-radius: 8px;
  padding: 15px 16px;
  box-shadow: var(--card-shadow);
}
.tier-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}
.tier-countries {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.country-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: 5px;
  background: var(--bg-subtle);
  border: 1px solid var(--rule);
  color: var(--ink);
  font-size: 0.8rem;
  text-decoration: none !important;
  transition: all 0.15s ease;
}
.country-chip:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
  transform: translateY(-1px);
}
.country-chip .chip-score {
  font-family: var(--mono);
  font-size: 0.73rem;
  color: var(--ink-muted);
}

/* --------------------------------------------------------------------------
   11 Pillar Cards Grid (destination_rankings style)
   -------------------------------------------------------------------------- */
.pillar-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
  gap: 18px;
}
.pillar-card {
  background: var(--bg-elev);
  border: 1px solid var(--rule);
  border-radius: 10px;
  padding: 20px;
  box-shadow: var(--card-shadow);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}
.pillar-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--card-shadow-hover);
  border-color: var(--accent);
}
.pillar-card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}
.pillar-title-group {
  display: flex;
  align-items: center;
  gap: 10px;
}
.pillar-icon {
  font-size: 1.55rem;
  line-height: 1;
}
.pillar-title {
  font-family: var(--serif);
  font-size: 1.18rem;
  font-weight: 700;
  color: var(--ink);
}
.pillar-en {
  font-family: var(--mono);
  font-size: 0.73rem;
  color: var(--ink-muted);
}
.pillar-weight-badge {
  font-family: var(--mono);
  font-size: 0.78rem;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 6px;
  background: var(--accent-soft);
  color: var(--accent);
  white-space: nowrap;
}
.pillar-desc {
  font-size: 0.86rem;
  color: var(--ink-2);
  margin-bottom: 12px;
}
.pillar-subinds {
  background: var(--bg-subtle);
  border-radius: 6px;
  padding: 9px 11px;
  margin-bottom: 12px;
  font-size: 0.8rem;
}
.pillar-subind-row {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 3px 0;
  border-bottom: 1px dashed var(--rule);
}
.pillar-subind-row:last-child {
  border-bottom: none;
}
.pillar-leaders {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-bottom: 12px;
}
.pillar-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 10px;
  border-top: 1px solid var(--rule);
  font-size: 0.8rem;
}

/* --------------------------------------------------------------------------
   Controls, Filter Pills, Search Input, Tabs
   -------------------------------------------------------------------------- */
.controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}
.search-input,
.select-input {
  padding: 8px 12px;
  border: 1px solid var(--rule);
  border-radius: 6px;
  background: var(--bg-elev);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 0.88rem;
  outline: none;
  transition: border-color 0.15s ease;
}
.search-input {
  min-width: 240px;
}
.search-input:focus,
.select-input:focus {
  border-color: var(--accent);
}
.pill-group {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}
.pill-btn {
  padding: 6px 11px;
  border: 1px solid var(--rule);
  border-radius: 6px;
  background: var(--bg-elev);
  color: var(--ink-2);
  font-size: 0.81rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.14s ease;
}
.pill-btn:hover {
  background: var(--bg-subtle);
  color: var(--ink);
}
.pill-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #ffffff;
  font-weight: 600;
}
.count-label {
  margin-left: auto;
  font-family: var(--mono);
  font-size: 0.8rem;
  color: var(--ink-muted);
}

/* --------------------------------------------------------------------------
   Data Tables (modeled after college.html empirical tables)
   -------------------------------------------------------------------------- */
.table-wrap {
  width: 100%;
  overflow-x: auto;
  background: var(--bg-elev);
  border: 1px solid var(--rule);
  border-radius: 8px;
  box-shadow: var(--card-shadow);
}
table.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}
table.data-table th,
table.data-table td {
  padding: 9px 11px;
  border-bottom: 1px solid var(--rule);
  text-align: left;
  white-space: nowrap;
}
table.data-table th {
  background: var(--bg-subtle);
  color: var(--ink-2);
  font-weight: 600;
  font-size: 0.78rem;
  letter-spacing: 0.02em;
  position: sticky;
  top: 0;
  z-index: 2;
  user-select: none;
}
table.data-table th.sortable {
  cursor: pointer;
}
table.data-table th.sortable:hover {
  color: var(--accent);
  background: var(--bg-hover);
}
table.data-table th.sorted-asc::after {
  content: " ▲";
  font-size: 0.68rem;
  color: var(--accent);
}
table.data-table th.sorted-desc::after {
  content: " ▼";
  font-size: 0.68rem;
  color: var(--accent);
}
table.data-table th.num,
table.data-table td.num {
  text-align: right;
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
}
table.data-table tbody tr {
  transition: background-color 0.12s ease;
}
table.data-table tbody tr:hover {
  background: var(--bg-hover);
}
table.data-table tbody tr.highlight-row {
  background: rgba(29, 78, 216, 0.08);
}
table.data-table tbody tr.clickable-row {
  cursor: pointer;
}
table.data-table tbody tr.clickable-row:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}
table.data-table th.col-sticky,
table.data-table td.col-sticky {
  position: sticky;
  left: 0;
  z-index: 3;
  background: var(--bg-elev);
  box-shadow: 2px 0 6px rgba(0, 0, 0, 0.04);
}
table.data-table thead th.col-sticky {
  z-index: 4;
  background: var(--bg-subtle);
}
table.data-table tbody tr:hover td.col-sticky {
  background: var(--bg-hover);
}
table.data-table tbody tr.highlight-row td.col-sticky {
  background: rgba(29, 78, 216, 0.08);
}

.weight-sim-grid {
  display: grid;
  grid-template-columns: minmax(280px, 380px) 1fr;
  gap: 20px;
}
.masthead-details {
  margin-top: 12px;
  border: 1px solid var(--rule);
  border-radius: 8px;
  padding: 12px 16px;
  background: var(--bg-elev);
}
.masthead-details summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--accent);
}
.masthead-details .details-body {
  margin-top: 10px;
  color: var(--ink-2);
  line-height: 1.65;
}
.masthead-cta-primary {
  margin-top: 16px;
}
.masthead-cta-secondary {
  margin-top: 10px;
}
.masthead-cta-secondary summary {
  cursor: pointer;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--ink-muted);
}
.page-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}
.page-nav a {
  text-decoration: none !important;
}
.page-nav a.is-active {
  background: var(--accent) !important;
  border-color: var(--accent) !important;
  color: #fff !important;
}
.glossary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 14px;
}
.glossary-card {
  background: var(--bg-elev);
  border: 1px solid var(--rule);
  border-radius: 8px;
  padding: 14px 16px;
}
.glossary-card dt {
  font-weight: 700;
  margin-bottom: 6px;
}
.glossary-card dd {
  font-size: 0.88rem;
  color: var(--ink-2);
  margin: 0;
}
.dataset-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-bottom: 12px;
}
.dataset-toolbar .search-input {
  min-width: 220px;
  flex: 1;
}
.scatter-fallback {
  margin-top: 12px;
  font-size: 0.82rem;
  color: var(--ink-muted);
}
.scatter-fallback summary {
  cursor: pointer;
  font-weight: 600;
}
.footer-disclaimer {
  max-width: 920px;
  margin: 0 auto 10px;
  font-size: 0.8rem;
  line-height: 1.55;
}
.footer-meta,
.footer-links {
  margin-top: 6px;
}
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
table.data-table tbody tr.clickable-row {
  cursor: pointer;
}

.rank-cell {
  font-family: var(--mono);
  font-weight: 700;
  color: var(--ink-muted);
}
.rank-top3 {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 0.75rem;
}

/* Inline Score Bar */
.bar-cell {
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: flex-end;
}
.bar-track {
  width: 68px;
  height: 7px;
  background: var(--bg-subtle);
  border-radius: 4px;
  overflow: hidden;
  flex-shrink: 0;
}
.bar-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 4px;
}

/* Heatmap Cell in Tables */
.hm-cell {
  font-family: var(--mono);
  font-size: 0.81rem;
  font-weight: 600;
  text-align: right;
  padding: 4px 7px;
  border-radius: 4px;
}

/* Delta Badges */
.delta-pos {
  color: var(--accent-3);
  font-family: var(--mono);
  font-weight: 600;
}
.delta-neg {
  color: var(--danger);
  font-family: var(--mono);
  font-weight: 600;
}
.delta-zero {
  color: var(--ink-muted);
  font-family: var(--mono);
}

/* --------------------------------------------------------------------------
   Two-Country Direct Duel (modeled after college.html Section 02)
   -------------------------------------------------------------------------- */
.duel-header-grid {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 18px;
  align-items: center;
  margin-bottom: 20px;
}
.duel-side-card {
  background: var(--bg-elev);
  border: 1px solid var(--rule);
  border-radius: 10px;
  padding: 18px 20px;
  box-shadow: var(--card-shadow);
}
.duel-side-card.side-a {
  border-top: 4px solid var(--accent);
}
.duel-side-card.side-b {
  border-top: 4px solid var(--accent-2);
}
.duel-vs-badge {
  font-family: var(--serif);
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--ink-muted);
  background: var(--bg-subtle);
  width: 48px;
  height: 48px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--rule);
}
.duel- butterfly-row {
  display: grid;
  grid-template-columns: 1fr 120px 1fr;
  align-items: center;
  gap: 10px;
  padding: 7px 0;
  border-bottom: 1px dashed var(--rule);
}

/* --------------------------------------------------------------------------
   Two-Column Layout & Cards for Dossier / Simulator / Scatter
   -------------------------------------------------------------------------- */
.grid-2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(460px, 1fr));
  gap: 20px;
  margin-bottom: 22px;
}
.panel-card {
  background: var(--bg-elev);
  border: 1px solid var(--rule);
  border-radius: 10px;
  padding: 20px;
  box-shadow: var(--card-shadow);
}
.panel-title {
  font-family: var(--serif);
  font-size: 1.12rem;
  font-weight: 700;
  margin-bottom: 6px;
  color: var(--ink);
}
.panel-sub {
  font-size: 0.82rem;
  color: var(--ink-muted);
  margin-bottom: 14px;
}

/* Weight Sliders */
.slider-row {
  display: grid;
  grid-template-columns: 115px 1fr 56px;
  align-items: center;
  gap: 10px;
  padding: 6px 0;
  border-bottom: 1px dashed var(--rule);
  font-size: 0.85rem;
}
.slider-row input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
  cursor: pointer;
}

/* Global Search Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(10, 14, 23, 0.65);
  backdrop-filter: blur(4px);
  z-index: 999;
  display: none;
  align-items: flex-start;
  justify-content: center;
  padding: 70px 16px 24px;
}
.modal-backdrop.open {
  display: flex;
}
.search-modal {
  width: 100%;
  max-width: 720px;
  background: var(--bg-elev);
  border: 1px solid var(--rule);
  border-radius: 12px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.35);
  overflow: hidden;
}
.search-modal-header {
  display: flex;
  align-items: center;
  padding: 14px 18px;
  border-bottom: 1px solid var(--rule);
  gap: 10px;
}
.search-modal-input {
  flex: 1;
  border: none;
  background: transparent;
  color: var(--ink);
  font-size: 1.05rem;
  font-family: var(--sans);
  outline: none;
}
.search-modal-results {
  max-height: 460px;
  overflow-y: auto;
  padding: 10px;
}
.search-result-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border-radius: 8px;
  color: var(--ink);
  text-decoration: none !important;
  transition: background 0.12s ease;
}
.search-result-item:hover {
  background: var(--bg-hover);
}

/* Footer */
.site-footer {
  border-top: 1px solid var(--rule);
  padding: 28px 24px calc(28px + env(safe-area-inset-bottom, 0px));
  text-align: center;
  font-size: 0.83rem;
  color: var(--ink-muted);
  background: var(--bg-elev);
}

@media print {
  .topbar,
  .bottom-tabbar,
  .search-trigger-btn,
  .theme-btn,
  .pill-group,
  .controls,
  .tbl-footer,
  .nav-toggle-btn {
    display: none !important;
  }
  body {
    background: #fff;
    color: #000;
  }
  .table-wrap {
    overflow: visible;
    box-shadow: none;
  }
  table.data-table th,
  table.data-table td {
    white-space: normal;
  }
  a[href]::after {
    content: " (" attr(href) ")";
    font-size: 0.7rem;
    color: #666;
  }
}

@media (max-width: 820px) {
  .duel-header-grid {
    grid-template-columns: 1fr;
  }
  .duel-vs-badge {
    margin: 0 auto;
  }
  .grid-2,
  .weight-sim-grid {
    grid-template-columns: 1fr;
  }
  .pillar-grid {
    grid-template-columns: 1fr;
  }
  .topbar-inner {
    padding: 0 12px;
    height: auto;
    min-height: 52px;
    flex-wrap: wrap;
    padding-top: 8px;
    padding-bottom: 8px;
  }
  .brand-title {
    display: none;
  }
  .nav-toggle-btn {
    display: inline-flex;
    margin-left: auto;
  }
  .topnav {
    display: none;
  }
  .topbar-actions {
    width: 100%;
    justify-content: flex-end;
    order: 4;
  }
  .bottom-tabbar {
    display: grid;
  }
  body {
    padding-bottom: 62px;
  }
  .container {
    padding: 20px 14px 56px;
  }
  .search-trigger-btn span:first-child {
    font-size: 0;
  }
  .search-trigger-btn span:first-child::before {
    content: "🔍";
    font-size: 1rem;
  }
}
