/* ── Design tokens ───────────────────────────────────────────────────────── */
:root {
  /* TU/e brand blue */
  --aut-red:       #006699;
  --aut-red-dark:  #004e73;
  --sublabel:      #72ADD5;
  --aut-white:     #FFFFFF;

  /* UI palette */
  --navy:          #1a2744;
  --navy-dark:     #0f1e3a;
  --blue:          #2563eb;
  --gray-50:       #f8fafc;
  --gray-100:      #f1f5f9;
  --gray-200:      #e2e8f0;
  --gray-300:      #cbd5e1;
  --gray-400:      #94a3b8;
  --gray-500:      #64748b;
  --gray-700:      #374151;
  --gray-900:      #111827;

  /* Shadows & shape */
  --shadow:        0 4px 16px rgba(0,0,0,.08);
  --shadow-lg:     0 8px 32px rgba(0,0,0,.12);
  --shadow-red:    0 4px 20px rgba(0,102,153,.25);
  --radius:        12px;

  /* Typography */
  --font:          -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --font-serif:    'Iowan Old Style', 'Palatino Linotype', 'Palatino', 'Georgia', serif;
  --ink:           #1a2744;
  --accent:        #006699;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: var(--font);
  background: var(--gray-50);
  color: var(--gray-900);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--gray-100); }
::-webkit-scrollbar-thumb { background: var(--gray-300); border-radius: 100px; }

/* ── Navbar ──────────────────────────────────────────────────────────────── */
/* Page-tab bar — a white card that straddles the bottom edge of the hero
   (top half over the blue header, bottom half over the page). It's a sibling of
   the hero pulled up with a negative top margin, so the hero's overflow:hidden
   (which clips the decorative rings) doesn't clip it. */
.navbar {
  position: sticky;
  top: .5rem;
  z-index: 50;
  width: max-content;
  max-width: calc(100% - 2.5rem);
  margin: -24px auto 0;
  display: flex;
  justify-content: center;
  background: #fff;
  border-radius: 14px;
  padding: .4rem .7rem;
  box-shadow: 0 10px 30px rgba(0,78,115,.18);
  border: 1px solid var(--gray-200);
}

/* Flag mark logo */
.nav-logo {
  display: flex;
  align-items: center;
  gap: .9rem;
  text-decoration: none;
}
.nav-flag-mark {
  display: flex;
  flex-direction: column;
  width: 26px;
  height: 22px;
  border-radius: 4px;
  overflow: hidden;
  border: 1px solid rgba(0,0,0,.12);
  flex-shrink: 0;
  box-shadow: 0 1px 4px rgba(0,0,0,.15);
}
.nf-stripe { display: block; flex: 1; }
.nf-red    { background: var(--aut-red-dark); }
.nf-white  { background: #fff; }
.nav-logo-img { height: 32px; width: auto; flex-shrink: 0; display: block; }

.nav-logo-text {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}
.nav-logo-title {
  font-size: .95rem;
  font-weight: 700;
  color: var(--aut-red-dark);
  letter-spacing: -.01em;
}
.nav-logo-sub {
  font-size: .68rem;
  color: var(--sublabel);
  font-weight: 500;
  letter-spacing: .04em;
  text-transform: uppercase;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: .25rem;
}
.nav-links a {
  color: var(--gray-700);
  text-decoration: none;
  font-size: .875rem;
  font-weight: 500;
  letter-spacing: .01em;
  padding-bottom: 2px;
  border-bottom: 2px solid transparent;
  transition: color .18s, border-color .18s;
}
.nav-links a:hover {
  color: var(--aut-red-dark);
  border-bottom-color: var(--aut-red);
}

/* Top-level page tabs (Scientific Output / Funding / Research Organizations / Analysis) */
.nav-tab {
  position: relative;
  appearance: none;
  -webkit-appearance: none;
  border: none;
  background: transparent;
  font-family: var(--font);
  font-size: .9rem;
  font-weight: 600;
  letter-spacing: .01em;
  line-height: 1;
  color: var(--gray-500);
  cursor: pointer;
  padding: .5rem 1rem;
  border-radius: 9px;
  white-space: nowrap;
  transition: color .18s ease, background-color .18s ease;
}
.nav-tab::after {
  content: "";
  position: absolute;
  left: 1rem;
  right: 1rem;
  bottom: 3px;
  height: 2.5px;
  border-radius: 2px;
  background: var(--aut-red);
  transform: scaleX(0);
  transform-origin: center;
  transition: transform .2s ease, background-color .2s ease;
}
.nav-tab:hover { color: var(--aut-red-dark); }
.nav-tab:hover::after { transform: scaleX(1); background: var(--sublabel); }
.nav-tab.active { color: var(--aut-red-dark); font-weight: 700; }
.nav-tab.active::after { transform: scaleX(1); background: var(--aut-red); }
.nav-tab:focus-visible {
  outline: 2px solid var(--aut-red);
  outline-offset: 4px;
  border-radius: 4px;
}

/* ── Hero ────────────────────────────────────────────────────────────────── */
.hero {
  background: var(--aut-red-dark);
  position: relative;
  overflow: hidden;
  color: #fff;
}

/* Decorative concentric rings — top-right */
.hero-ring {
  position: absolute;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,.09);
  pointer-events: none;
}
.hero-ring-1 { width: 560px; height: 560px; top: -180px; right: -140px; }
.hero-ring-2 { width: 380px; height: 380px; top:  -90px; right:  -50px; border-color: rgba(255,255,255,.06); }
.hero-ring-3 { width: 200px; height: 200px; top:   20px; right:   70px; border-color: rgba(255,255,255,.12); }

/* Subtle diagonal crosshatch texture */
.hero::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image:
    repeating-linear-gradient( 45deg, transparent, transparent 38px, rgba(255,255,255,.022) 38px, rgba(255,255,255,.022) 39px),
    repeating-linear-gradient(-45deg, transparent, transparent 38px, rgba(255,255,255,.022) 38px, rgba(255,255,255,.022) 39px);
  pointer-events: none;
}

.hero-body {
  padding: 3rem 3rem 3.25rem;
  position: relative;
  z-index: 1;
  max-width: 820px;
  margin: 0 auto;
}

.hero-kicker {
  display: inline-flex;
  align-items: center;
  gap: .6rem;
  font-size: .78rem;
  font-weight: 600;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: rgba(255,255,255,.65);
  margin-bottom: 1.75rem;
}
.hero-kicker-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: rgba(255,255,255,.5);
  flex-shrink: 0;
}

.hero-title {
  font-family: var(--font-serif);
  font-size: clamp(2rem, 4.5vw, 4rem);
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: -.02em;
  margin-bottom: 1.25rem;
  color: #fff;
}
.hero-title em {
  font-style: italic;
  color: rgba(255,255,255,.82);
}

.hero-desc {
  font-size: 1.05rem;
  color: rgba(255,255,255,.65);
  max-width: 540px;
  line-height: 1.7;
}

/* Stats bar — white band (creates Austrian flag red–white–red rhythm) */
.hero-stats-bar {
  background: #fff;
  border-top: 1px solid rgba(0,0,0,.07);
  position: relative;
  z-index: 1;
}
.hero-stats-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 3rem;
  display: flex;
  align-items: stretch;
}
.stat {
  flex: 1;
  text-align: center;
  padding: 1.75rem 1.25rem;
  position: relative;
}
.stat + .stat { border-left: 1px solid var(--gray-200); }
.stat-n {
  display: block;
  font-size: 2.2rem;
  font-weight: 800;
  color: var(--aut-red-dark);
  font-variant-numeric: tabular-nums;
  letter-spacing: -.02em;
  line-height: 1;
  margin-bottom: .4rem;
}
.stat-label {
  font-size: .73rem;
  color: var(--sublabel);
  text-transform: uppercase;
  letter-spacing: .08em;
  font-weight: 600;
}
.stat-year {
  font-size: .65rem;
  color: var(--aut-red-dark);
  font-weight: 500;
  letter-spacing: .04em;
  opacity: .6;
  margin-top: .15rem;
}
.stat-sep { display: none; } /* kept for JS compat, hidden via display */

/* ── Sections ──────────────────────────────────────────────────────────── */
.section { padding: 4.5rem 2.5rem; }
#ranking { padding-top: 2rem; }
.section-alt { background: var(--gray-100); }
.section-inner { max-width: 1440px; margin: 0 auto; }
.section-header { margin-bottom: 1.5rem; }

/* ── Intro / About section ─────────────────────────────────────────────── */
.section-intro {
  background: linear-gradient(180deg, #fafbfc 0%, #f4f6f9 100%);
  padding: 3.5rem 2.5rem 4rem;
  border-top: 1px solid rgba(0,0,0,.04);
  border-bottom: 1px solid rgba(0,0,0,.04);
}
.intro-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.5rem;
  max-width: 1200px;
  margin: 0 auto;
}
.intro-card {
  background: #fff;
  border-radius: 12px;
  padding: 1.75rem 1.6rem 1.5rem;
  box-shadow: 0 2px 12px rgba(15,30,58,.06);
  border-top: 3px solid var(--aut-red, #c8102e);
  display: flex;
  flex-direction: column;
}
.intro-eyebrow {
  font-size: .7rem;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--aut-red, #c8102e);
  margin-bottom: .5rem;
}
.intro-heading {
  font-size: 1.1rem;
  font-weight: 700;
  line-height: 1.3;
  color: var(--navy-dark, #0f1e3a);
  margin: 0 0 .75rem;
}
.intro-body {
  font-size: .9rem;
  line-height: 1.65;
  color: #444;
  margin: 0 0 1rem;
  flex-grow: 1;
}
.intro-links {
  display: flex;
  flex-wrap: wrap;
  gap: .4rem .9rem;
  margin-top: auto;
  padding-top: .25rem;
  border-top: 1px solid rgba(0,0,0,.06);
}
.intro-link {
  font-size: .82rem;
  font-weight: 600;
  color: var(--aut-red, #c8102e);
  text-decoration: none;
  padding: .35rem 0;
  transition: opacity .15s, transform .15s;
}
.intro-link:hover { opacity: .75; transform: translateX(2px); }

@media (max-width: 960px) {
  .intro-grid { grid-template-columns: repeat(2, 1fr); }
  .intro-card:last-child { grid-column: 1 / -1; }
}
@media (max-width: 640px) {
  .section-intro { padding: 2.5rem 1.25rem 3rem; }
  .intro-grid { grid-template-columns: 1fr; gap: 1rem; }
  .intro-card:last-child { grid-column: auto; }
}

/* Austrian red headings throughout */
.section-header h2 {
  font-family: var(--font-serif);
  font-size: 2rem;
  font-weight: 700;
  color: var(--aut-red-dark);
  letter-spacing: -.015em;
}
.section-header h2::after {
  content: '';
  display: block;
  width: 44px;
  height: 3px;
  background: var(--aut-red);
  border-radius: 100px;
  margin-top: .6rem;
}
.section-sub {
  margin-top: .65rem;
  color: var(--gray-500);
  font-size: .9rem;
  max-width: 920px;
  line-height: 1.65;
}

/* ── Prose (Background page) ─────────────────────────────────────────────── */
.prose {
  max-width: 760px;
  margin-top: 2rem;
}
.prose h3 {
  font-family: var(--font-serif);
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--aut-red-dark);
  margin: 2rem 0 .6rem;
}
.prose h3:first-child { margin-top: 0; }
.prose p {
  color: var(--gray-700);
  font-size: .98rem;
  line-height: 1.75;
  margin-bottom: 1rem;
}
.prose .cite {
  color: var(--aut-red);
  text-decoration: none;
  font-weight: 600;
  font-size: .82em;
  vertical-align: super;
  line-height: 0;
  padding: 0 .1em;
}
.prose .cite:hover { text-decoration: underline; }
.prose-refs-head {
  border-top: 1px solid var(--gray-200);
  padding-top: 1.5rem;
  margin-top: 2.5rem !important;
}
.prose-refs {
  margin: 0;
  padding-left: 1.4rem;
  color: var(--gray-500);
  font-size: .85rem;
  line-height: 1.7;
}
.prose-refs li { margin-bottom: .35rem; padding-left: .2rem; }
.prose-refs li:target { background: rgba(0,102,153,.08); border-radius: 4px; }
.prose-refs a {
  color: var(--aut-red);
  text-decoration: none;
  word-break: break-word;
}
.prose-refs a:hover { text-decoration: underline; }

/* ── Top% selector (under ranking heading) ──────────────────────────────── */
.top-selector-wrap {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}
.top-selector-label {
  font-size: .72rem;
  font-weight: 700;
  color: var(--sublabel);
  text-transform: uppercase;
  letter-spacing: .08em;
  white-space: nowrap;
}
.top-buttons {
  display: inline-flex;
  background: var(--gray-100);
  border: 1.5px solid var(--gray-200);
  border-radius: 100px;
  padding: 3px;
  gap: 2px;
}
.top-btn {
  border: none;
  background: transparent;
  color: var(--gray-500);
  font-size: .8rem;
  font-weight: 600;
  padding: .38em 1.25em;
  border-radius: 100px;
  cursor: pointer;
  transition: all .2s;
  font-family: var(--font);
}
.top-btn:hover { color: var(--aut-red-dark); background: rgba(0,102,153,.07); }
.top-btn.active {
  background: var(--aut-red-dark);
  color: #fff;
  box-shadow: 0 2px 8px rgba(0,102,153,.35);
}
.ranking-selector { margin: 1.25rem 0 1.5rem; }
.field-system-selector { margin: 1.25rem 0 1.25rem; }

/* ── Field chips (Field Rankings page) ──────────────────────────────────── */
.field-chips {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
  margin-bottom: 1.5rem;
}
.field-chip {
  border: 1.5px solid var(--gray-200);
  background: #fff;
  color: var(--gray-700);
  font-size: .82rem;
  font-weight: 600;
  font-family: var(--font);
  padding: .45em 1em;
  border-radius: 100px;
  cursor: pointer;
  transition: background .18s, color .18s, border-color .18s, box-shadow .18s;
  white-space: nowrap;
}
.field-chip:hover { border-color: var(--aut-red); color: var(--aut-red-dark); }
.field-chip .field-chip-count {
  margin-left: .5em;
  font-weight: 500;
  opacity: .6;
  font-variant-numeric: tabular-nums;
}
.field-chip.active {
  background: var(--aut-red-dark);
  color: #fff;
  border-color: var(--aut-red-dark);
  box-shadow: 0 2px 8px rgba(0,102,153,.3);
}
.field-chip.active .field-chip-count { opacity: .8; }

/* ── Form controls ──────────────────────────────────────────────────────── */
.search-input, .filter-select {
  padding: .55em .95em;
  border: 1.5px solid var(--gray-200);
  border-radius: 8px;
  font-size: .875rem;
  background: #fff;
  color: var(--gray-900);
  font-family: var(--font);
  transition: border-color .18s, box-shadow .18s;
  outline: none;
}
.search-input:focus, .filter-select:focus {
  border-color: var(--aut-red);
  box-shadow: 0 0 0 3px rgba(0,102,153,.1);
}
.filter-select { cursor: pointer; }

/* ── Table controls ─────────────────────────────────────────────────────── */
.table-controls { display: flex; gap: .75rem; align-items: center; margin-bottom: 1rem; flex-wrap: wrap; }
.table-controls .search-input { flex: 1; min-width: 180px; max-width: 300px; }
.record-count { margin-left: auto; font-size: .82rem; color: var(--gray-400); }

/* ── Research subfields ─────────────────────────────────────────────────── */
.subfield-view[hidden] { display: none; }
.subfield-controls, .subfield-cascade { align-items: flex-end; }
.subfield-pick { display: inline-flex; flex-direction: column; gap: .3rem; }
.subfield-pick-label {
  font-size: .72rem;
  font-weight: 700;
  color: var(--sublabel);
  text-transform: uppercase;
  letter-spacing: .08em;
}
.subfield-pick .filter-select { min-width: 230px; max-width: 380px; }
.subfield-sort-selector { margin-left: auto; }
.subfield-context { display: block; font-size: .7rem; color: var(--gray-400); margin-top: .12rem; }

/* ── Ranking table ──────────────────────────────────────────────────────── */
/* Tables scroll natively inside a capped-height box: the wheel scrolls the table
   and chains to the page at the top/bottom (no click-to-activate, no trapping).
   A visible scrollbar plus a bottom fade (toggled by initScrollFade via
   .has-more-below) make it clear there are more rows below. */
.table-wrapper { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow-lg); overflow: hidden; position: relative; }
.table-scroll { max-height: 640px; overflow-y: auto; overflow-x: auto; }
.table-scroll::-webkit-scrollbar { width: 11px; height: 11px; }
.table-scroll::-webkit-scrollbar-track { background: var(--gray-100); }
.table-scroll::-webkit-scrollbar-thumb { background: var(--gray-300); border-radius: 100px; border: 2px solid var(--gray-100); }
.table-scroll::-webkit-scrollbar-thumb:hover { background: var(--gray-400); }
.table-wrapper::after {
  content: '';
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 40px;
  background: linear-gradient(rgba(255,255,255,0), rgba(255,255,255,.97));
  pointer-events: none;
  opacity: 0;
  transition: opacity .2s ease;
  border-radius: 0 0 var(--radius) var(--radius);
}
.table-wrapper.has-more-below::after { opacity: 1; }
.data-table { width: 100%; border-collapse: collapse; font-size: .875rem; }
.data-table thead { background: var(--aut-red-dark); color: #fff; }
.data-table th { padding: .85em 1.2em; text-align: left; font-weight: 600; font-size: .75rem; letter-spacing: .06em; text-transform: uppercase; white-space: nowrap; user-select: none; }
.data-table th.sortable { cursor: pointer; }
.data-table th.sortable:hover { background: rgba(255,255,255,.1); }
.data-table th.sortable:not(.sort-desc):not(.sort-asc)::after { content: ' \2195'; opacity: .65; }
.data-table th.sort-desc::after { content: ' \2193'; }
.data-table th.sort-asc::after  { content: ' \2191'; }
.data-table th.th-num { text-align: right; }

/* ── Header info-icon tooltip ───────────────────────────────────────────── */
.th-info {
  position: relative;
  display: inline-block;
  margin-left: .4em;
  vertical-align: baseline;
  cursor: help;
  outline: none;
}
.th-info-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: rgba(255,255,255,.25);
  color: #fff;
  font-family: Georgia, 'Times New Roman', serif;
  font-style: italic;
  font-weight: 700;
  font-size: 10px;
  line-height: 1;
  text-transform: none;
  letter-spacing: 0;
  transition: background .15s, transform .15s;
}
/* Hover only where a real hover pointer exists (desktop) — prevents sticky
   :hover on touch screens. Touch uses tap-to-toggle (.is-open, set in main.js);
   keyboard uses :focus-visible (never triggered by a mouse/touch press). */
@media (hover: hover) {
  .th-info:hover .th-info-icon { background: #fff; color: var(--aut-red-dark); transform: scale(1.1); }
}
.th-info:focus-visible .th-info-icon,
.th-info.is-open .th-info-icon { background: #fff; color: var(--aut-red-dark); transform: scale(1.1); }
.th-tooltip {
  position: absolute;
  top: calc(100% + 10px);
  right: -8px;
  min-width: 240px;
  max-width: 320px;
  width: max-content;
  padding: .85rem 1rem;
  background: #fff;
  color: #333;
  font-family: inherit;
  font-size: .8rem;
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
  line-height: 1.5;
  text-align: left;
  white-space: normal;
  border-radius: 8px;
  border-top: 3px solid var(--aut-red, #c8102e);
  box-shadow: 0 8px 24px rgba(15,30,58,.25);
  visibility: hidden;
  opacity: 0;
  transform: translateY(-4px);
  transition: opacity .18s ease, transform .18s ease, visibility .18s;
  transition-delay: 0s;
  z-index: 100;
  pointer-events: none;
}
.th-tooltip::before {
  content: '';
  position: absolute;
  top: -8px;
  right: 10px;
  border: 5px solid transparent;
  border-top: 0;
  border-bottom-color: var(--aut-red, #c8102e);
}
.th-tooltip strong {
  display: block;
  color: var(--navy-dark, #0f1e3a);
  font-size: .82rem;
  font-weight: 700;
  margin-bottom: .35rem;
}
@media (hover: hover) {
  .th-info:hover .th-tooltip {
    visibility: visible;
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
  }
}
.th-info:focus-visible .th-tooltip,
.th-info.is-open .th-tooltip {
  visibility: visible;
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}
/* While scrolling, force every header tooltip hidden — overrides the hover/focus/
   open show rules above. Higher specificity (0,3,1) beats them without !important;
   the class is added/removed in main.js (debounced ~200ms after scroll stops). */
body.is-scrolling .th-info .th-tooltip {
  visibility: hidden;
  opacity: 0;
  transition: none;
}
/* Disable the hover delay once the tooltip is already showing (touch tap / pin) */
.th-info.is-open .th-tooltip { transition-delay: 0s; }
/* The first numeric column (P) sits leftmost — flip the tooltip to grow leftward
   so it doesn't poke past the right edge of narrower tables either. */
[data-sort="P"] .th-tooltip { right: auto; left: -8px; }
[data-sort="P"] .th-tooltip::before { right: auto; left: 10px; }
.data-table td { padding: .72em 1.2em; border-bottom: 1px solid var(--gray-100); vertical-align: middle; }
.data-table tbody tr:nth-child(even) { background: #fafbfc; }
.data-table tbody tr:hover { background: #f0f7fa; }
.data-table tbody tr:last-child td { border-bottom: none; }
.td-rank { text-align: center; font-weight: 700; color: var(--aut-red-dark); font-size: .82rem; min-width: 48px; width: 48px; }
.td-name  { min-width: 200px; }
.td-ror   { white-space: nowrap; }
.ror-link {
  font-size: .75rem;
  font-weight: 600;
  color: var(--aut-red-dark);
  text-decoration: none;
  border: 1px solid var(--aut-red-dark);
  border-radius: 4px;
  padding: .15em .55em;
  opacity: .75;
  transition: opacity .15s, background .15s, color .15s;
  display: inline-block;
}
.ror-link:hover {
  opacity: 1;
  background: var(--aut-red-dark);
  color: #fff;
}
.inst-name { font-weight: 500; }
.td-type  { white-space: nowrap; }
.td-num   { text-align: right; font-variant-numeric: tabular-nums; }
.td-highlight { font-weight: 700; color: var(--aut-red-dark); }

/* Small-sample rows: too few publications for reliable proportion (PP) figures.
   Subtly de-emphasised, with a caution badge next to the institution name. */
.tr-low-sample { background: rgba(180, 83, 9, .045); }
.tr-low-sample:hover { background: rgba(180, 83, 9, .08); }
.tr-low-sample .inst-name { color: var(--gray-500); }
.low-sample-flag {
  display: inline-block;
  margin-left: .5em;
  font-size: .62rem;
  font-weight: 700;
  letter-spacing: .03em;
  text-transform: uppercase;
  color: #b45309;
  background: #fef3c7;
  border: 1px solid #fde68a;
  padding: .1em .55em;
  border-radius: 100px;
  vertical-align: middle;
  white-space: nowrap;
}

/* Always-visible legend under tables that use the small-sample badge — explains
   the badge with zero delay and no tooltip clipping inside the scroll area. */
.table-note { margin: .85rem 0 0; font-size: .8rem; color: var(--gray-500); line-height: 1.55; }
.table-note .low-sample-flag { margin-left: 0; }

/* Type badges */
.type-badge { display: inline-block; font-size: .73rem; font-weight: 600; padding: .22em .75em; border-radius: 100px; white-space: nowrap; }
.type-res         { background: #dbeafe; color: #1d4ed8; }
.type-npo         { background: #ede9fe; color: #5b21b6; }
.type-uni_public  { background: #d1fae5; color: #065f46; }
.type-uni_fh      { background: #ccfbf1; color: #0f766e; }
.type-uni_private { background: #fef3c7; color: #92400e; }
.type-gov         { background: #cffafe; color: #155e75; }
.type-med         { background: #fee2e2; color: #991b1b; }
.type-comp        { background: var(--gray-100); color: var(--gray-500); }

/* ── Bar controls ───────────────────────────────────────────────────────── */
.bar-controls { display: flex; gap: 1.25rem; margin-bottom: 1.75rem; flex-wrap: wrap; align-items: flex-end; }
.control-group { display: flex; flex-direction: column; gap: .35rem; }
.control-group label { font-size: .72rem; font-weight: 700; color: var(--sublabel); text-transform: uppercase; letter-spacing: .07em; }
.control-group .search-input { min-width: 220px; }
.control-group .filter-select { min-width: 220px; }

/* ── Chart containers ───────────────────────────────────────────────────── */
.chart-container { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.5rem; overflow-x: auto; }
.chart-container-bar { padding: 1.5rem 1rem 1rem; }

/* ── D3 shared ──────────────────────────────────────────────────────────── */
.axis-label { font-size: 12px; fill: var(--gray-500); font-family: var(--font); }
.tick text { font-family: var(--font) !important; font-size: 11px !important; }
.grid-lines .domain { display: none; }
.grid-lines .tick line { display: none; }
.grid-lines line { stroke: #e2e8f0; stroke-dasharray: 3 3; }

/* ── D3 Tooltip ─────────────────────────────────────────────────────────── */
.d3-tooltip {
  position: fixed;
  pointer-events: none;
  background: rgba(13,18,32,.96);
  color: #fff;
  border-radius: 10px;
  padding: .75em 1.05em;
  font-size: .8rem;
  line-height: 1.65;
  z-index: 9999;
  opacity: 0;
  transition: opacity .12s;
  max-width: 300px;
  box-shadow: 0 6px 28px rgba(0,0,0,.3);
  font-family: var(--font);
  border: 1px solid rgba(255,255,255,.07);
}
.d3-tooltip .tt-title { font-weight: 700; font-size: .88rem; margin-bottom: .3em; padding-bottom: .3em; border-bottom: 1px solid rgba(255,255,255,.14); }
.d3-tooltip .tt-row { display: flex; justify-content: space-between; gap: 1.2em; }
.d3-tooltip .tt-row span:first-child { color: rgba(255,255,255,.52); }
.d3-tooltip .tt-row span:last-child  { font-weight: 600; }

/* ── Legend ─────────────────────────────────────────────────────────────── */
.legend-wrap { display: flex; flex-direction: column; gap: .45rem; min-width: 155px; padding: .5rem 0; }
.legend-item { display: flex; align-items: center; gap: .5rem; font-size: .8rem; color: var(--gray-700); }
.legend-swatch { width: 11px; height: 11px; flex-shrink: 0; border-radius: 2px; }
.legend-size-note {
  font-size: .8rem;
  color: var(--gray-500);
  line-height: 1.6;
  max-width: 170px;
  padding: .5rem 0;
  border-left: 3px solid var(--aut-red);
  padding-left: .75rem;
}
.legend-size-note strong { color: var(--aut-red-dark); }

/* ── No data ────────────────────────────────────────────────────────────── */
.no-data-msg { padding: 3rem; text-align: center; color: var(--gray-400); font-size: .95rem; font-style: italic; }

/* ── Footer ─────────────────────────────────────────────────────────────── */
.footer {
  background: var(--navy-dark, #0f1e3a);
  color: rgba(255,255,255,.45);
  padding: 0;
}
.footer-flag {
  display: flex;
  height: 8px;
}
.footer-flag-stripe { flex: 1; }
.ff-red   { background: var(--aut-red-dark); }
.ff-white { background: rgba(255,255,255,.9); }
.footer-inner {
  max-width: 900px;
  margin: 0 auto;
  padding: 2.5rem 2rem;
  text-align: center;
}
.footer-title { font-size: 1rem; font-weight: 600; color: rgba(255,255,255,.7); margin-bottom: .6rem; }
.footer-contributors {
  font-size: .85rem;
  color: rgba(255,255,255,.55);
  margin-bottom: .4rem;
  line-height: 1.7;
}
.footer-contrib-label {
  display: block;
  font-size: .65rem;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--aut-red);
  margin-bottom: .2rem;
}
.footer-copy {
  font-size: .75rem;
  color: rgba(255,255,255,.28);
  margin-top: .5rem;
}
.footer-legal { margin-top: .5rem; }
.footer-legal-link {
  background: none;
  border: 0;
  padding: 0;
  font: inherit;
  cursor: pointer;
  font-size: .75rem;
  color: rgba(255,255,255,.35);
  text-decoration: underline;
  text-underline-offset: 2px;
}
.footer-legal-link:hover { color: rgba(255,255,255,.65); }

/* ── Modal ──────────────────────────────────────────────────────────────── */
.modal { position: fixed; inset: 0; z-index: 1000; display: flex; align-items: center; justify-content: center; padding: 1.5rem; }
.modal[hidden] { display: none; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(15, 30, 58, .55); backdrop-filter: blur(2px); }
.modal-dialog {
  position: relative;
  background: #fff;
  max-width: 560px;
  width: 100%;
  max-height: 85vh;
  overflow-y: auto;
  padding: 2.5rem 2.25rem 2rem;
  border-radius: 12px;
  box-shadow: 0 20px 60px rgba(15,30,58,.35);
  border-top: 4px solid var(--aut-red, #c8102e);
}
.modal-close {
  position: absolute;
  top: .5rem;
  right: .75rem;
  background: none;
  border: 0;
  font-size: 1.75rem;
  line-height: 1;
  color: var(--gray-400, #999);
  cursor: pointer;
  padding: .25rem .5rem;
  border-radius: 4px;
}
.modal-close:hover { color: var(--navy-dark, #0f1e3a); background: rgba(0,0,0,.04); }
.modal-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--navy-dark, #0f1e3a);
  margin: 0 0 1.25rem;
  padding-bottom: .5rem;
  border-bottom: 1px solid rgba(0,0,0,.08);
}
.modal-subhead {
  font-size: .75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--aut-red, #c8102e);
  margin: 1.4rem 0 .35rem;
}
.modal-dialog p { font-size: .9rem; line-height: 1.65; color: #333; margin: 0 0 .5rem; }
.modal-dialog a { color: var(--aut-red, #c8102e); text-decoration: underline; }
.modal-dialog a:hover { opacity: .8; }
.modal-address { font-style: normal; font-size: .9rem; line-height: 1.7; color: #333; }
body.modal-open { overflow: hidden; }

/* ── Background section ─────────────────────────────────────────────────── */
.section-background .section-inner { max-width: 880px; }
.background-body {
  font-size: .95rem;
  line-height: 1.75;
  color: #333;
}
.background-body p { margin: 0 0 1.25rem; }
.background-subhead {
  font-size: .8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--aut-red, #c8102e);
  margin: 2rem 0 .75rem;
  padding-bottom: .35rem;
  border-bottom: 1px solid rgba(0,0,0,.08);
}
.background-subhead:first-child { margin-top: 0; }
.background-body sup { font-size: .7em; line-height: 0; vertical-align: super; }
.background-body sup a {
  color: var(--aut-red, #c8102e);
  text-decoration: none;
  font-weight: 600;
  padding: 0 1px;
}
.background-body sup a:hover { text-decoration: underline; }
.background-refs {
  font-size: .85rem;
  line-height: 1.65;
  color: #555;
  padding-left: 1.5rem;
  margin: 0;
}
.background-refs li { margin-bottom: .4rem; scroll-margin-top: 90px; }
.background-refs li:target { background: rgba(200,16,46,.08); border-radius: 3px; }
.background-refs a { color: var(--aut-red, #c8102e); text-decoration: none; word-break: break-word; }
.background-refs a:hover { text-decoration: underline; }

/* ── Loading ────────────────────────────────────────────────────────────── */
.loading-indicator { display: flex; align-items: center; justify-content: center; padding: 3rem; color: var(--gray-400); font-size: .95rem; gap: .75rem; }
.spinner { width: 20px; height: 20px; border: 2px solid var(--gray-200); border-top-color: var(--aut-red); border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── EU benchmark toggle (sits next to the Top 1/5/10 buttons) ──────────── */
.eu-toggle {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  font-size: .82rem;
  font-weight: 600;
  color: var(--gray-700);
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
}
.eu-toggle input {
  width: 16px;
  height: 16px;
  accent-color: var(--aut-red);
  cursor: pointer;
  margin: 0;
  flex-shrink: 0;
}
.eu-toggle:hover { color: var(--aut-red-dark); }
.tr-eu {
  background: linear-gradient(90deg, rgba(0,102,153,.05) 0%, transparent 60%) !important;
  border-left: 3px solid var(--aut-red) !important;
}

/* ── Institution comparison (side-by-side) ──────────────────────────────── */
/* Two keyboard-pickable columns: an optional filter field + a clickable listbox. */
.compare-pickers {
  display: flex;
  gap: 1.5rem;
  margin: 1.25rem 0 1.75rem;
}
.compare-pick { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: .5rem; }
.compare-filter { width: 100%; }
.compare-listbox {
  width: 100%;
  border: 1.5px solid var(--gray-200);
  border-radius: 8px;
  padding: .25rem;
  background: #fff;
  font-family: var(--font);
  font-size: .85rem;
  color: var(--gray-900);
  outline: none;
}
.compare-listbox:focus { border-color: var(--aut-red); box-shadow: 0 0 0 3px rgba(0,102,153,.1); }
.compare-listbox option { padding: .35em .55em; border-radius: 5px; cursor: pointer; }
.compare-listbox option:checked { background: var(--aut-red-dark); color: #fff; }

.compare-result { overflow-x: auto; }
.compare-table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.compare-table thead th {
  text-align: left;
  padding: .7em 1em;
  font-size: .82rem;
  font-weight: 700;
  color: var(--aut-red-dark);
  border-bottom: 2px solid var(--gray-200);
  vertical-align: bottom;
}
.compare-table thead th.cmp-metric-h {
  font-size: .7rem;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--sublabel);
}
.compare-table td { padding: .6em 1em; border-bottom: 1px solid var(--gray-100); vertical-align: middle; }
.compare-table tbody tr:last-child td { border-bottom: none; }
.compare-table td.cmp-metric { font-weight: 600; color: var(--gray-700); white-space: nowrap; }
.cmp-cell { display: flex; flex-direction: column; gap: .3rem; }
.cmp-val { font-weight: 700; color: var(--gray-900); font-variant-numeric: tabular-nums; }
.cmp-bar { height: 7px; background: var(--gray-100); border-radius: 100px; overflow: hidden; }
.cmp-bar > span { display: block; height: 100%; border-radius: 100px; min-width: 2px; transition: width .35s ease; }
@media (max-width: 640px) {
  .compare-pickers { flex-direction: column; }
}
.tr-eu:hover { background: rgba(0,102,153,.09) !important; }
.type-eu { background: var(--aut-red-dark); color: #fff; }
.eu-flag { margin-right: .3rem; }
.eu-country {
  font-size: .7rem;
  color: var(--gray-400);
  margin-left: .45rem;
  font-style: italic;
  white-space: nowrap;
}
.eu-popup {
  position: absolute;
  bottom: calc(100% + 10px);
  left: 50%;
  transform: translateX(-50%) translateY(4px);
  background: #1a2744;
  color: #fff;
  font-size: .76rem;
  line-height: 1.45;
  padding: .5rem .9rem;
  border-radius: 8px;
  max-width: 210px;
  text-align: center;
  pointer-events: none;
  opacity: 0;
  transition: opacity .2s ease, transform .2s ease;
  z-index: 400;
  box-shadow: 0 4px 18px rgba(0,0,0,.28);
  border-left: 3px solid var(--aut-red);
}
.eu-popup::before {
  content: '';
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 6px solid transparent;
  border-top-color: #1a2744;
}
.eu-popup.is-visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
.eu-btn-hint {
  font-size: .63rem;
  color: var(--sublabel);
  text-align: center;
  margin-top: .25rem;
  letter-spacing: .04em;
  text-transform: uppercase;
  font-weight: 600;
}

/* ── Responsive ─────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  /* On mobile the tab bar sits just below the hero (no straddle) and wraps. */
  .navbar { margin: .85rem auto 0; max-width: calc(100% - 2rem); flex-wrap: wrap; }
  .nav-links { flex-wrap: wrap; justify-content: center; gap: .15rem; }
  .hero-body { padding: 2.25rem 1.5rem 2.25rem; }
  .hero-title { font-size: 2.4rem; }
  .hero-stats-inner { padding: 0 1.25rem; flex-direction: column; }
  .stat + .stat { border-left: none; border-top: 1px solid var(--gray-200); }
  .section { padding: 3rem 1.25rem; }
  .bar-controls { flex-direction: column; }
  .table-controls { flex-direction: column; align-items: stretch; }
  .table-controls .search-input { max-width: none; }
  .record-count { margin-left: 0; }
  .top-selector-wrap { flex-direction: column; align-items: flex-start; gap: .6rem; }
  /* Tighter tables on mobile: smaller cell padding + a narrower name column so
     columns aren't spread out and less horizontal scrolling is needed. */
  .data-table { font-size: .82rem; }
  .data-table th, .data-table td { padding-left: .5rem; padding-right: .5rem; }
  .td-name { min-width: 120px; }
  /* Cap the scroll height to the screen so the table never dominates a phone. */
  .table-scroll { max-height: 65vh; }
  .compare-table th, .compare-table td { padding-left: .5rem; padding-right: .5rem; }
  /* Let long metric labels wrap on phones so the comparison table fits. */
  .compare-table td.cmp-metric { white-space: normal; }
}
