:root {
  --bg: #ffffff;
  --text: #1a1a1a;
  --muted: #666666;
  --line: #e2e2e2;
  --card: #ffffff;
  --tint: #EFE9F6;
  --tint-text: #4A2F6B;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #161616;
    --text: #ededed;
    --muted: #9a9a9a;
    --line: #333333;
    --card: #1d1d1d;
    --tint: #2c2338;
    --tint-text: #d6cbe5;
  }
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Arial, Helvetica, sans-serif;
  font-size: 14px;
  line-height: 1.5;
}

main {
  max-width: 1320px;
  margin: 0 auto;
  padding: 16px 16px 48px;
}

.note {
  color: var(--muted);
}

.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 16px 24px;
  align-items: end;
  margin: 16px 0;
}

.controls label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 14px;
}

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

table {
  border-collapse: collapse;
  width: 100%;
  font-size: 14px;
}

th, td {
  padding: 6px 8px;
  border-bottom: 1px solid var(--muted);
  text-align: left;
}

td.num, th:not(:first-child) {
  text-align: right;
}

td.num input {
  width: 64px;
  text-align: right;
}

section {
  margin-bottom: 40px;
}

.callout {
  padding: 8px 12px;
  border-left: 3px solid var(--text);
}

td select {
  font: inherit;
}

td.edited select {
  font-weight: 700;
}

.reg-country {
  margin-top: 16px;
}

.reg-item {
  font-size: 14px;
  margin: 8px 0;
}

.reg-item textarea {
  width: 100%;
  box-sizing: border-box;
  font: inherit;
}

.tag {
  font-size: 12px;
  color: var(--muted);
}

#overall-table th:nth-child(2) {
  text-align: left;
}

/* Ranked stacked bar chart of overall scores, one segment per layer.
   Chart style (CLAUDE.md): royal purple and its tints, Arial, no grid lines,
   transparent background, legend because there are three series. */
:root {
  --seg-1: #7851A9;
  --seg-2: #AE97CB;
  --seg-3: #D6CBE5;
}

.bar-chart,
.chart-legend {
  font-family: Arial, Helvetica, sans-serif;
  font-size: 14px;
}

.bar-chart {
  margin: 8px 0 16px;
  background: transparent;
}

.chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 16px;
  list-style: none;
  padding: 0;
  margin: 16px 0 0;
}

.chart-legend li {
  display: flex;
  align-items: center;
  gap: 6px;
}

.swatch {
  display: inline-block;
  width: 12px;
  height: 12px;
}

.seg-1 { background: var(--seg-1); }
.seg-2 { background: var(--seg-2); }
.seg-3 { background: var(--seg-3); }

.bar-row {
  display: grid;
  grid-template-columns: minmax(120px, 200px) 1fr 48px;
  grid-template-areas: "label track value" ". meta meta";
  column-gap: 8px;
  align-items: center;
  margin-bottom: 8px;
}

.bar-label { grid-area: label; }
.bar-track {
  grid-area: track;
  display: flex;
  height: 12px;
}
.bar {
  display: block;
  height: 100%;
}
.bar + .bar {
  box-shadow: inset 1px 0 0 var(--bg); /* hairline between segments */
}
.bar-value { grid-area: value; text-align: right; }
.bar-meta { grid-area: meta; font-size: 12px; color: var(--muted); }

/* Countries not yet ranked: what's missing and where to enter it. */
.needs {
  margin-top: 24px;
  padding: 8px 12px;
  border-left: 3px solid var(--muted);
}

.needs h3 {
  margin: 0;
  font-size: 16px;
}

.needs ul ul {
  font-size: 14px;
  color: var(--muted);
}

details.reference {
  margin-top: 24px;
}

details.reference summary {
  cursor: pointer;
}

/* Fund profile */
.fund-profile .vehicles {
  border: 1px solid var(--muted);
  padding: 8px 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px 24px;
}

.fund-profile .vehicles legend {
  font-size: 14px;
}

#vehicle-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 24px;
  font-size: 14px;
}

.controls select {
  font: inherit;
}

/* Country doesn't clear the fund's USD hurdle */
td.fails {
  font-weight: 700;
}

td .tag.solved {
  display: block;
  white-space: nowrap;
}

/* Royal purple controls, matching the chart color */
input[type="range"],
input[type="checkbox"] {
  accent-color: #7851A9;
}

/* Country rows expand to show investor types */
button.expand {
  font: inherit;
  background: none;
  border: none;
  padding: 0;
  color: inherit;
  cursor: pointer;
  text-align: left;
}

button.expand:focus-visible {
  outline: 2px solid #7851A9;
  outline-offset: 2px;
}

tr.detail-row > td {
  background: rgba(120, 81, 169, 0.06);
  padding: 8px 12px 12px;
}

table.types {
  font-size: 13px;
  margin-top: 6px;
}

table.types td:last-child {
  text-align: left;
}

.tag.flag {
  display: block;
}

tr.not-counted td {
  color: var(--muted);
}

tr.country-total td {
  font-weight: 700;
}

#l2-table tr.type-row td:first-child {
  padding-left: 20px;
}

#allocators-table td:nth-child(2),
#allocators-table td:nth-child(3),
#allocators-table th:nth-child(2),
#allocators-table th:nth-child(3) {
  text-align: left;
}

label.check {
  flex-direction: row;
  align-items: center;
}

/* ---- Visual layer (m-visual): steps, result card, table bars, hedge walk.
   Chart style (CLAUDE.md): royal purple #7851A9 and its tints only, Arial,
   no grid lines, transparent background, legend only for the stacked bar. */
.steps ol {
  list-style: none;
  padding: 0;
  margin: 16px 0 24px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.step a,
.step.step-next {
  display: flex;
  flex-direction: column;
  gap: 2px;
  height: 100%;
  box-sizing: border-box;
  padding: 8px 12px;
  border-top: 3px solid var(--seg-1);
  color: inherit;
  text-decoration: none;
}

.step.step-next {
  border-top-color: var(--seg-3);
  color: var(--muted);
}

.step-title {
  font-weight: 700;
}

.step-detail {
  font-size: 13px;
  color: var(--muted);
}

.step a:hover .step-title,
.step a:focus-visible .step-title {
  color: var(--seg-1);
}

@media (max-width: 640px) {
  .steps ol { grid-template-columns: 1fr; }
}

.result-card {
  margin: 16px 0;
  padding: 12px 16px;
  border-left: 6px solid var(--seg-1);
  background: transparent;
}

.result-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 12px;
}

.result-label {
  font-size: 13px;
  color: var(--muted);
}

.result-country {
  font-size: 24px;
  font-weight: 700;
}

.result-score {
  font-family: Arial, Helvetica, sans-serif;
  font-size: 24px;
  color: var(--seg-1);
}

.result-card p {
  margin: 6px 0 0;
}

.result-tie {
  color: var(--muted);
}

/* Overall column: one stacked bar per country, score at the end. */
#overall-table th:last-child { text-align: left; }

td.bar-cell {
  width: 40%;
  min-width: 200px;
  text-align: left;
}

.score-bar {
  display: grid;
  grid-template-columns: minmax(140px, 1fr) auto;
  align-items: center;
  column-gap: 10px; /* gap between the bar and its score label */
  font-family: Arial, Helvetica, sans-serif;
}

/* The old chart rules give .bar-track and .bar-value named grid areas
   ("track", "value") that don't exist in this grid; reset them so the bar
   sits in the first column, starting at the left edge of the cell. */
.score-bar .bar-track {
  grid-area: auto;
  grid-column: 1;
  justify-content: flex-start;
  height: 14px;
  background: transparent;
}

.score-bar .bar-value {
  grid-area: auto;
  grid-column: 2;
  min-width: 36px;
  text-align: right;
}

button.pick {
  font: inherit;
  background: none;
  border: none;
  padding: 0;
  color: inherit;
  cursor: pointer;
  text-align: left;
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
}

button.pick .arrow {
  font-size: 1.5em;
  line-height: 1;
  color: var(--seg-1);
}

button.pick .pick-name {
  text-decoration: underline dotted;
  text-underline-offset: 3px;
}

button.pick:hover .pick-name {
  text-decoration: underline solid;
  color: var(--seg-1);
}

button.pick:focus-visible {
  outline: 2px solid var(--seg-1);
  outline-offset: 2px;
}

tr.selected td {
  box-shadow: inset 0 -2px 0 var(--seg-1);
}

tr.selected button.pick {
  font-weight: 700;
}

tr.selected button.pick .pick-name {
  text-decoration: none;
}

tr.needs-row td {
  color: var(--muted);
}

td.needs-cell {
  text-align: left;
  font-size: 13px;
}

/* Hedge walk: a waterfall of the existing rates values. */
.hedge-walk h3 {
  margin: 24px 0 4px;
}

.walk-chart {
  font-family: Arial, Helvetica, sans-serif;
  font-size: 14px;
  background: transparent;
  margin: 8px 0 16px;
}

.walk-row {
  display: grid;
  grid-template-columns: minmax(150px, 210px) 1fr 64px;
  grid-template-areas: "label track value" ". note note";
  column-gap: 8px;
  align-items: center;
  margin-bottom: 6px;
}

.walk-label { grid-area: label; }

.walk-track {
  grid-area: track;
  position: relative;
  height: 14px;
}

.walk-bar {
  position: absolute;
  top: 0;
  bottom: 0;
}

.walk-value {
  grid-area: value;
  text-align: right;
}

.walk-total .walk-label,
.walk-total .walk-value {
  font-weight: 700;
}

.walk-note {
  grid-area: note;
  font-size: 12px;
  color: var(--muted);
}

/* Visual polish: card flag and top-three line, table hint. */
.result-flag {
  font-size: 12px;
  padding: 1px 6px;
  border: 1px solid var(--seg-2);
  color: var(--seg-1);
  border-radius: 3px;
}

.result-reason,
.result-top3 {
  color: var(--muted);
}

.table-hint {
  margin: 8px 0 4px;
  font-size: 13px;
}

/* Bring your own Preqin (D1): loader panel and summary. */
#preqin-status {
  margin: 8px 0;
  font-weight: 700;
}

#preqin-summary ul {
  font-size: 14px;
  padding-left: 20px;
}

.preqin input[type="file"] {
  font: inherit;
}

/* Allocator shortlist (D2) */
#top-alloc-table th,
#top-alloc-table td {
  text-align: left;
  vertical-align: top;
}

#top-alloc-table td.num {
  text-align: right;
}

#top-alloc-table td.flags .tag.flag {
  display: block;
}

.alloc-block h4 {
  margin: 12px 0 4px;
}

.alloc-top {
  font-size: 14px;
  margin: 4px 0;
}

/* LGPS pool roll-up (D4) */
#top-alloc-table tr.pool-row td {
  font-weight: 700;
}

#top-alloc-table tr.pool-row td .tag {
  font-weight: 400;
}

#top-alloc-table tr.sub-row td {
  color: var(--muted);
  font-size: 13px;
}

#top-alloc-table td.sub-name {
  padding-left: 24px;
}


/* ==== Layout redesign (docs/wireframe.html): top bar, tabs, three columns ==== */
.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}

.topbar-inner {
  max-width: 1320px;
  margin: 0 auto;
  padding: 8px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

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

.tabs {
  display: flex;
  gap: 4px;
}

.tab {
  padding: 6px 12px;
  color: var(--muted);
  text-decoration: none;
  border-bottom: 2px solid transparent;
}

.tab.on {
  color: var(--text);
  border-bottom-color: #7851A9;
}

.tab:focus-visible {
  outline: 2px solid #7851A9;
  outline-offset: 2px;
}

.data-asof {
  font-size: 12px;
  color: var(--muted);
}

.card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--card);
  padding: 12px 16px;
  margin-bottom: 16px;
}

.tab-panel > section.card {
  margin-bottom: 16px;
}

.lbl {
  font-size: 12px;
  color: var(--muted);
  font-weight: 400;
  margin: 0 0 4px;
}

h2.lbl {
  font-size: 12px;
}

/* Ranking tab: fund (left, sticky), ranking (middle), country panel (right). */
.ranking-grid {
  display: grid;
  grid-template-columns: 250px minmax(0, 1fr) 300px;
  gap: 12px;
  align-items: start;
}

.ranking-grid > .card {
  margin-bottom: 0;
}

.fund-panel {
  position: sticky;
  top: 56px;
  max-height: calc(100vh - 72px);
  overflow-y: auto;
}

.fund-panel h2,
.panel-h {
  font-size: 15px;
  margin: 0 0 10px;
}

.fund-panel .field {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 12px;
  color: var(--muted);
  margin: 0 0 10px;
}

.fund-panel .field select,
.fund-panel .field input[type="number"] {
  font: inherit;
  font-size: 13px;
  color: var(--text);
  /* Background and border from the theme too: with only the text color set,
     dark mode showed light text on the browser's white default. */
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 3px 6px;
}

.fund-panel .field input[type="range"] {
  width: 100%;
}

.fund-panel .field output {
  color: var(--text);
}

.fund-panel hr {
  border: 0;
  border-top: 1px solid var(--line);
  margin: 12px 0;
}

.fund-panel button {
  font: inherit;
  font-size: 12px;
  margin-bottom: 8px;
}

.fund-panel .note {
  font-size: 12px;
}

.fund-panel .vehicles {
  border: 0;
  padding: 0;
  margin: 0 0 10px;
  display: block;
}

.fund-panel #vehicle-list {
  display: flex;
  flex-direction: column;
  gap: 0;
  font-size: 13px;
}

.veh-note {
  display: block;
  font-size: 11px;
  color: var(--muted);
  margin: -2px 0 6px 22px;
  line-height: 1.35;
}

.fund-panel label.check {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
}

details.more > summary {
  cursor: pointer;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 8px;
}

.presets {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 10px;
}

.chip {
  font-size: 11px;
  padding: 2px 7px;
  border-radius: 4px;
  background: var(--tint);
  color: var(--tint-text);
  border: 1px solid transparent;
}

button.chip {
  font: inherit;
  font-size: 11px;
  cursor: pointer;
  background: transparent;
  border-color: var(--line);
  color: var(--muted);
  margin: 0;
}

button.chip.on {
  background: var(--tint);
  border-color: var(--tint);
  color: var(--tint-text);
}

/* Middle column: headline, three tiles, compact ranking rows. */
.result-card {
  border-left: 0;
  padding: 0;
  margin: 0 0 12px;
}

.result-headline {
  font-size: 20px;
  font-weight: 700;
  margin: 0 0 10px;
}

.tiles {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 8px;
}

.tile {
  font: inherit;
  text-align: left;
  cursor: pointer;
  background: var(--tint);
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 8px 10px;
  color: var(--text);
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.tile.on {
  border-color: #7851A9;
}

.tile:focus-visible {
  outline: 2px solid #7851A9;
  outline-offset: 2px;
}

.tile-head {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.tile-score {
  font-size: 18px;
  font-weight: 700;
  color: #7851A9;
}

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

.tile-reason {
  font-size: 12px;
  color: var(--muted);
}

.tile .result-flag {
  align-self: flex-start;
}

.result-card p {
  margin: 4px 0 0;
  font-size: 12px;
}

.result-card p.result-headline {
  font-size: 20px;
  margin: 0 0 10px;
}

#overall-table th,
#overall-table td {
  border-bottom: 1px solid var(--line);
}

#overall-table td.rank {
  width: 28px;
  color: var(--muted);
}

#overall-table th:nth-child(1),
#overall-table th:nth-child(2) {
  text-align: left;
}

#overall-table td.bar-cell {
  width: auto;
  min-width: 180px;
}

#overall-table tr.selected td {
  background: var(--tint);
  box-shadow: none;
}

#overall-table td .tag.flag.fails {
  font-weight: 700;
}

.more-row td {
  border-bottom: 0;
}

.more-btn {
  font: inherit;
  font-size: 13px;
  background: none;
  border: 0;
  padding: 4px 0;
  color: var(--muted);
  cursor: pointer;
}

.more-btn:hover {
  color: #7851A9;
}

.ranking-main details {
  margin-top: 12px;
  border-top: 1px solid var(--line);
  padding-top: 8px;
}

.ranking-main details > summary {
  cursor: pointer;
  color: var(--muted);
  font-size: 13px;
}

.ranking-main details.needs {
  border-left: 0;
  padding: 8px 0 0;
}

.ranking-main .calc .note p {
  font-size: 13px;
}

/* Right column: the selected country. */
.country-panel {
  border: 1.5px solid #7851A9;
  position: sticky;
  top: 56px;
  max-height: calc(100vh - 72px);
  overflow-y: auto;
  font-size: 13px;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  font-size: 15px;
}

.panel-close {
  font: inherit;
  background: none;
  border: 0;
  color: var(--muted);
  cursor: pointer;
  padding: 0 4px;
}

.panel-close:focus-visible {
  outline: 2px solid #7851A9;
}

.panel-sub {
  font-size: 12px;
  color: var(--muted);
  margin: 2px 0 8px;
}

.panel-scores {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 2px 8px;
  margin: 0 0 8px;
  font-size: 12px;
}

.panel-scores dt {
  color: var(--muted);
}

.panel-scores dd {
  margin: 0;
}

.panel-section {
  border-top: 1px solid var(--line);
  margin-top: 10px;
  padding-top: 8px;
}

.panel-section > summary {
  cursor: pointer;
  font-size: 12px;
  color: var(--muted);
}

.panel-list {
  list-style: none;
  padding: 0;
  margin: 4px 0;
  font-size: 12px;
  line-height: 1.7;
}

.panel-list .chip {
  margin-left: 4px;
}

.country-panel .detail-content p {
  margin: 4px 0;
  font-size: 12px;
}

.country-panel table.types {
  font-size: 11px;
}

.country-panel .alloc-top {
  padding-left: 18px;
  font-size: 12px;
}

.types-details > summary {
  cursor: pointer;
  font-size: 12px;
  color: var(--muted);
}

/* Hedge walk: vertical waterfall (royal purple and a tint; no grid lines). */
.hedge-walk h3 {
  margin: 10px 0 2px;
}

.walk-svg {
  display: block;
  max-width: 360px;
  background: transparent;
  font-family: Arial, Helvetica, sans-serif;
}

.walk-svg .walk-total-bar { fill: #7851A9; }
.walk-svg .walk-step-bar { fill: #AE97CB; }
.walk-svg .walk-zero { stroke: var(--muted); stroke-width: 0.5; }
.walk-svg .walk-val { font-size: 9px; fill: var(--text); text-anchor: middle; }
.walk-svg .walk-lab { font-size: 9px; fill: var(--muted); text-anchor: middle; }

.walk-notes {
  list-style: none;
  padding: 0;
  margin: 4px 0 0;
  font-size: 11px;
  color: var(--muted);
}

/* Responsive: panel drops below the ranking, then everything stacks. */
@media (max-width: 1099px) {
  .ranking-grid {
    grid-template-columns: 240px minmax(0, 1fr);
  }
  /* The fund panel spans both rows, so the country panel sits right under the ranking. */
  .fund-panel {
    grid-row: 1 / span 2;
  }
  .country-panel {
    grid-column: 2;
    position: static;
    max-height: none;
  }
}

@media (max-width: 760px) {
  /* Phone: ranking first, then the fund settings, then the country panel. */
  .ranking-grid {
    grid-template-columns: minmax(0, 1fr);
  }
  .ranking-main { order: 1; }
  .fund-panel { order: 2; }
  .country-panel { order: 3; }
  .country-panel {
    grid-column: 1;
  }
  .fund-panel {
    grid-row: auto;
    position: static;
    max-height: none;
  }
  .tiles {
    grid-template-columns: minmax(0, 1fr);
  }
  /* Compact top bar that scrolls away: name and date on one line, tabs below. */
  .topbar {
    position: static;
  }
  .topbar-inner {
    padding: 6px 12px;
    gap: 2px 12px;
  }
  .tabs {
    order: 3;
    width: 100%;
    justify-content: space-between;
  }
  .tab {
    padding: 4px 6px;
  }
  .result-headline,
  .result-card p.result-headline {
    font-size: 17px;
  }
  #overall-table td.bar-cell {
    min-width: 0;
  }
  .score-bar {
    grid-template-columns: minmax(60px, 1fr) auto;
    column-gap: 6px;
  }
  #overall-table th:nth-child(3) {
    font-size: 11px;
  }
}

/* Anchored headings clear the sticky top bar. */
.tab-panel h2,
.tab-panel h3,
.tab-panel {
  scroll-margin-top: 60px;
}

/* The screen-reader summary must not widen the page on phones. */
.visually-hidden * {
  position: absolute !important;
  width: 1px;
  height: 1px;
  margin: 0;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* Long source names and links in notes wrap instead of widening the page. */
.tab-panel p,
.tab-panel li {
  overflow-wrap: anywhere;
}

.tab-panel td li,
.tab-panel td p {
  overflow-wrap: normal;
}

/* ==== World map (js/map.js): tints of #7851A9, greys, hairline borders ==== */
:root {
  --map-out: #ececec;
  --map-needs: #b3b3b3;
  --map-border: #ffffff;
}

@media (prefers-color-scheme: dark) {
  :root {
    --map-out: #2a2a2a;
    --map-needs: #5c5c5c;
    --map-border: #161616;
  }
}

.map-figure {
  margin: 0 0 12px;
}

.map-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}

.map-wrap {
  position: relative;
}

.world-map {
  display: block;
  width: 100%;
  height: auto;
  background: transparent;
}

.world-map .cty {
  fill: var(--map-out);
  stroke: var(--map-border);
  stroke-width: 0.6;
  vector-effect: non-scaling-stroke;
}

.world-map .cty.needs,
.world-map .cty-dot.needs {
  fill: var(--map-needs);
}

.world-map .cty.ranked,
.world-map .cty.needs,
.world-map .cty-dot {
  cursor: pointer;
}

.world-map .cty-dot {
  stroke: var(--map-border);
  stroke-width: 1;
  vector-effect: non-scaling-stroke;
}

.world-map .selected {
  stroke: var(--text);
  stroke-width: 1.5;
}

.world-map .cty.screened:hover,
.world-map .cty-dot:hover {
  stroke: var(--text);
  stroke-width: 1;
}

.world-map [tabindex]:focus {
  outline: none;
}

.world-map [tabindex]:focus-visible {
  stroke: #7851A9;
  stroke-width: 2.5;
}

.map-tip {
  position: absolute;
  z-index: 2;
  pointer-events: none;
  background: var(--card);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 3px 7px;
  font-size: 12px;
  white-space: nowrap;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.12);
}

.map-legend {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--muted);
  font-family: Arial, Helvetica, sans-serif;
}

.map-legend-bar {
  display: inline-block;
  width: 90px;
  height: 8px;
  background: linear-gradient(to right, rgb(227, 217, 239), #7851A9);
}

.map-zoom {
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: 4px;
  overflow: hidden;
}

.map-zoom button {
  font: inherit;
  font-size: 12px;
  background: transparent;
  color: var(--muted);
  border: 0;
  padding: 2px 10px;
  cursor: pointer;
}

.map-zoom button[aria-pressed="true"] {
  background: var(--tint);
  color: var(--tint-text);
}

.map-zoom button:focus-visible {
  outline: 2px solid #7851A9;
  outline-offset: -2px;
}

.map-figure figcaption {
  font-size: 11px;
  margin-top: 2px;
}

/* ==== Allocator drop-downs, chip filters, upload button, map zoom ==== */
.topbar-right {
  display: inline-flex;
  align-items: center;
  gap: 12px;
}

.upload-btn {
  font: inherit;
  font-size: 13px;
  padding: 4px 10px;
  border-radius: 4px;
  border: 1px solid #7851A9;
  background: #7851A9;
  color: #ffffff;
  cursor: pointer;
}

.upload-btn:hover {
  background: #6a4797;
}

.upload-btn:focus-visible,
#preqin-file:focus-visible {
  outline: 2px solid #7851A9;
  outline-offset: 2px;
}

/* Chips: multi-select filters with counts. */
.alloc-chips {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 8px 0 12px;
}

.chip-group {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 6px;
}

.chip-title {
  font-size: 12px;
  color: var(--muted);
  min-width: 92px;
}

button.filter-chip {
  font-size: 12px;
  padding: 2px 8px;
  border-radius: 12px;
}

button.filter-chip .chip-count {
  color: var(--muted);
  font-size: 11px;
}

button.filter-chip.on .chip-count {
  color: var(--tint-text);
}

button.filter-chip:focus-visible,
.link-btn:focus-visible {
  outline: 2px solid #7851A9;
  outline-offset: 1px;
}

.link-btn {
  font: inherit;
  font-size: 12px;
  background: none;
  border: 0;
  padding: 2px 4px;
  color: #7851A9;
  text-decoration: underline;
  cursor: pointer;
}

.clear-filters {
  align-self: flex-start;
}

/* Drop-down under a country row. */
#overall-table tr.dropdown-row > td {
  background: var(--tint);
  padding: 8px 12px 10px 36px;
  border-bottom: 1px solid var(--line);
}

.dropdown .chip-group {
  margin-bottom: 6px;
}

.dropdown .chip-title {
  min-width: 0;
}

.dd-list {
  margin: 0 0 6px;
  padding-left: 18px;
  font-size: 13px;
}

.dd-list li {
  margin: 3px 0;
}

.dd-list li > span {
  display: inline-block;
  margin-right: 8px;
}

.dd-meta {
  color: var(--muted);
  font-size: 12px;
}

.dd-score {
  font-weight: 700;
  color: #7851A9;
  font-size: 12px;
}

.dd-all {
  font-size: 13px;
  color: #7851A9;
}

.dd-empty {
  margin: 2px 0 6px;
}

.dropdown-in-needs {
  background: var(--tint);
  padding: 6px 10px;
  margin: 4px 0 8px;
  border-radius: 4px;
}

.see-all {
  margin: 8px 0 0;
  font-size: 13px;
}

.see-all a {
  color: #7851A9;
}

/* Map zoom buttons and panning. */
.map-head {
  flex-wrap: wrap;
}

.map-zoom-steps button {
  min-width: 28px;
  font-size: 14px;
  line-height: 1.3;
}

.map-zoom-steps button:disabled {
  opacity: 0.4;
  cursor: default;
}

.world-map:focus-visible {
  outline: 2px solid #7851A9;
  outline-offset: 2px;
}

.world-map.zoomed {
  touch-action: none;
  cursor: grab;
}

.world-map.zoomed.dragging {
  cursor: grabbing;
}

@media (max-width: 760px) {
  .topbar-right {
    gap: 8px;
  }
  .upload-btn {
    font-size: 12px;
    padding: 3px 8px;
  }
  .chip-title {
    min-width: 0;
    width: 100%;
  }
  #overall-table tr.dropdown-row > td {
    padding-left: 12px;
  }
}

/* The hidden attribute always wins over display rules (e.g. .controls { display: flex }). */
[hidden] {
  display: none !important;
}

details.alloc-method {
  margin: 4px 0 10px;
}

details.alloc-method > summary {
  cursor: pointer;
  font-size: 13px;
  color: var(--muted);
}

/* "Largest pools": the # header lines up with its right-aligned numbers. */
#allocators-table th:first-child {
  text-align: right;
}

/* ==== Wide layout (up to 1800px), top band, score columns, Compare ==== */
main,
.topbar-inner {
  max-width: 1800px;
}

/* Fund panel full height on the left; the band (map + where to raise) to its
   right; below it the ranking and the country panel, which get the extra width. */
.ranking-grid {
  grid-template-columns: 260px minmax(0, 3fr) minmax(320px, 2fr);
  grid-template-areas:
    "fund band band"
    "fund main panel";
}

.ranking-grid > .fund-panel { grid-area: fund; grid-row: 1 / span 2; }
.ranking-grid > .top-band { grid-area: band; }
.ranking-grid > .ranking-main { grid-area: main; }
.ranking-grid > .country-panel { grid-area: panel; }

.top-band {
  display: grid;
  grid-template-columns: minmax(0, 2.2fr) minmax(280px, 1fr);
  gap: 16px;
  align-items: start;
}

.top-band .map-figure {
  margin: 0;
}

/* Cards stacked in the band's right column on wide screens. */
.top-band .tiles {
  grid-template-columns: minmax(0, 1fr);
}

.tile {
  padding: 0;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  position: relative;
}

.tile-open {
  font: inherit;
  text-align: left;
  background: none;
  border: 0;
  padding: 8px 10px 6px;
  color: inherit;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.tile-open:focus-visible {
  outline: 2px solid #7851A9;
  outline-offset: -2px;
}

.tile > .chip-tip {
  margin: 0 10px 8px;
  align-self: flex-start;
}

.result-line {
  font-size: 12px;
  color: var(--muted);
}

/* Chip with its explanation in a tooltip (hover, focus or tap). */
.chip-tip {
  position: relative;
  display: inline-block;
}

button.result-flag {
  font: inherit;
  font-size: 12px;
  background: transparent;
  cursor: help;
}

.chip-tip-text {
  display: none;
  position: absolute;
  z-index: 6;
  left: 0;
  top: calc(100% + 4px);
  width: max-content;
  max-width: 260px;
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--card);
  color: var(--text);
  font-size: 12px;
  line-height: 1.4;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.12);
}

.chip-tip:hover .chip-tip-text,
.chip-tip:focus-within .chip-tip-text,
.chip-tip.open .chip-tip-text {
  display: block;
}

/* Component score columns next to the stacked bar. */
#overall-table th.comp-col,
#overall-table td.comp-col {
  width: 44px;
  text-align: right;
  padding-left: 4px;
  padding-right: 4px;
  font-family: Arial, Helvetica, sans-serif;
}

#overall-table th.comp-col {
  font-size: 12px;
  color: var(--muted);
  cursor: help;
}

#overall-table td.comp-col.fails {
  font-weight: 700;
}

/* Wider, sticky country panel; waterfall drawn in pixels with 13px text. */
.country-panel {
  font-size: 13px;
}

.walk-svg {
  max-width: none;
  overflow: visible;
}

.walk-svg .walk-val,
.walk-svg .walk-lab {
  font-size: 13px;
}

.walk-notes {
  font-size: 12px;
}

.panel-tools {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.panel-compare-btn {
  font: inherit;
  font-size: 12px;
  padding: 2px 8px;
  border-radius: 4px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--text);
  cursor: pointer;
}

.panel-compare-btn[aria-pressed="true"] {
  background: var(--tint);
  color: var(--tint-text);
  border-color: var(--tint);
}

.panel-compare-btn:focus-visible {
  outline: 2px solid #7851A9;
  outline-offset: 1px;
}

.panel-compare {
  border-bottom: 1px solid var(--line);
  padding-bottom: 10px;
  margin-bottom: 10px;
}

/* Compare side by side on wide screens: the panel column widens. */
.ranking-grid.comparing {
  grid-template-columns: 260px minmax(0, 1fr) minmax(320px, 1.6fr);
}

@media (min-width: 1500px) {
  .ranking-grid.comparing .panel-columns {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 16px;
  }
  .ranking-grid.comparing .panel-compare {
    border-bottom: 0;
    border-right: 1px solid var(--line);
    padding: 0 16px 0 0;
    margin: 0;
  }
}

/* Below 1200px: the band stacks (map above the cards, which sit side by side). */
@media (max-width: 1199px) {
  .top-band {
    grid-template-columns: minmax(0, 1fr);
  }
  .top-band .tiles {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

/* Below 1100px: fund panel left, everything else in one column to its right. */
@media (max-width: 1099px) {
  .ranking-grid,
  .ranking-grid.comparing {
    grid-template-columns: 240px minmax(0, 1fr);
    grid-template-areas:
      "fund band"
      "fund main"
      "fund panel";
  }
  .ranking-grid > .fund-panel { grid-area: fund; grid-row: 1 / span 3; }
  .ranking-grid > .country-panel { grid-area: panel; grid-column: auto; position: static; max-height: none; }
}

/* Phone: one column; band, ranking, fund settings, panel. Score columns hidden. */
@media (max-width: 760px) {
  .ranking-grid,
  .ranking-grid.comparing {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas:
      "band"
      "main"
      "fund"
      "panel";
  }
  .ranking-grid > .fund-panel { grid-area: fund; grid-row: auto; }
  .top-band .tiles {
    grid-template-columns: minmax(0, 1fr);
  }
  #overall-table .comp-col {
    display: none;
  }
}
