/* Toolbar at the top of every density page: USD toggle + country compare. */
#fap-study-toolbar {
  max-width: 1100px;
  margin: 14px auto 4px;
  padding: 12px 18px;
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
  align-items: center;
  background: #ffffff;
  border: 1px solid #cfd8e3;
  border-radius: 10px;
  font-size: 13px;
  color: #243b53;
}
#fap-study-toolbar .group { display: flex; align-items: center; gap: 8px; }
#fap-study-toolbar label { font-weight: 600; color: #243b53; user-select: none; cursor: pointer; }
#fap-study-toolbar .switch {
  position: relative; display: inline-block; width: 44px; height: 22px; margin-right: 4px;
}
#fap-study-toolbar .switch input { opacity: 0; width: 0; height: 0; }
#fap-study-toolbar .switch .slider {
  position: absolute; cursor: pointer; inset: 0; background: #d0dae6; border-radius: 22px; transition: .15s;
}
#fap-study-toolbar .switch .slider::before {
  content: ''; position: absolute; height: 16px; width: 16px; left: 3px; top: 3px;
  background: #fff; border-radius: 50%; transition: .15s;
  box-shadow: 0 1px 2px rgba(0,0,0,.18);
}
#fap-study-toolbar .switch input:checked + .slider { background: #0974cc; }
#fap-study-toolbar .switch input:checked + .slider::before { transform: translateX(22px); }

#fap-compare-select {
  appearance: none;
  -webkit-appearance: none;
  border: 1px solid #cfd8e3;
  border-radius: 6px;
  background: #f5f9fd url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 8 5'><path fill='%23243b53' d='M0 0h8L4 5z'/></svg>") right 8px center / 8px 5px no-repeat;
  padding: 6px 26px 6px 10px;
  font-size: 13px;
  color: #243b53;
  cursor: pointer;
  min-width: 220px;
}
#fap-compare-select:focus { outline: 2px solid #0974cc; outline-offset: 1px; }

#fap-compare-panel {
  max-width: 1100px;
  margin: 8px auto 18px;
  padding: 16px 22px;
  background: #fff;
  border: 1px solid #cfd8e3;
  border-radius: 10px;
  position: relative;
  font-size: 13px;
  color: #243b53;
}
#fap-compare-panel[hidden] { display: none; }
.fap-compare-head { font-size: 15px; margin-bottom: 10px; color: #243b53; }
.fap-compare-head strong { color: #0974cc; }
.fap-compare-unit { color: #6b7c93; font-weight: 400; font-size: 12px; margin-left: 6px; }
.fap-compare-tbl { width: 100%; border-collapse: collapse; }
.fap-compare-tbl th, .fap-compare-tbl td { padding: 6px 10px; border-bottom: 1px solid #e3eaf1; text-align: right; }
.fap-compare-tbl th:first-child, .fap-compare-tbl td:first-child { text-align: left; color: #6b7c93; font-weight: 500; }
.fap-compare-tbl thead th { background: #f5f9fd; }
.fap-compare-close {
  position: absolute; top: 8px; right: 10px; width: 28px; height: 28px;
  background: transparent; border: none; font-size: 22px; line-height: 24px;
  color: #6b7c93; cursor: pointer; border-radius: 4px;
}
.fap-compare-close:hover { background: #f5f9fd; color: #243b53; }
.fap-compare-loading, .fap-compare-err { color: #6b7c93; padding: 8px 0; }
@media (max-width: 540px) {
  #fap-study-toolbar { gap: 10px; padding: 10px 14px; }
  #fap-compare-select { min-width: 170px; }
}

/* Selected-country chips next to the compare dropdown. */
#fap-compare-chips { display: inline-flex; gap: 6px; flex-wrap: wrap; margin-left: 6px; }
.fap-compare-chip {
  display: inline-flex; align-items: center; gap: 4px;
  background: #eef4fb; border: 1px solid #cfd8e3; color: #243b53;
  border-radius: 999px; padding: 3px 4px 3px 10px; font-size: 12px;
  white-space: nowrap;
}
.fap-compare-chip button {
  background: transparent; border: none; color: #6b7c93;
  font-size: 16px; line-height: 1; padding: 0 6px; cursor: pointer;
  border-radius: 999px;
}
.fap-compare-chip button:hover { background: #d0dae6; color: #243b53; }
#fap-compare-select:disabled { opacity: 0.55; cursor: not-allowed; }

/* Delta-percent badge inside other-country cells. */
.fap-delta { font-weight: 600; font-size: 11px; margin-left: 5px; white-space: nowrap; }
.fap-delta.fap-up   { color: #1b8a52; }
.fap-delta.fap-down { color: #b14335; }
.fap-delta.fap-eq   { color: #6b7c93; font-weight: 500; }
.fap-cell-loading   { color: #6b7c93; }

/* Column-icon tooltips. Replaces the slow browser-native title="" tooltip
 * (~500–1500 ms delay, OS-styled) with an instant CSS one driven by the
 * existing aria-label. study-extras.js strips the matching title= attrs
 * so the browser tooltip never fires. */
.tooltip-toggle { position: relative; display: inline-flex; }
.tooltip-toggle::after {
  content: attr(aria-label);
  position: absolute;
  left: 50%;
  bottom: calc(100% + 6px);
  transform: translateX(-50%);
  background: #243b53;
  color: #fff;
  padding: 4px 8px;
  font: 500 12px/1.3 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  white-space: nowrap;
  border-radius: 3px;
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  transition: opacity 60ms ease, visibility 0s linear 60ms;
  z-index: 50;
}
.tooltip-toggle::before {
  content: "";
  position: absolute;
  left: 50%;
  bottom: calc(100% + 1px);
  transform: translateX(-50%);
  border: 5px solid transparent;
  border-top-color: #243b53;
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  transition: opacity 60ms ease, visibility 0s linear 60ms;
  z-index: 50;
}
.tooltip-toggle:hover::after,
.tooltip-toggle:hover::before,
.tooltip-toggle:focus-visible::after,
.tooltip-toggle:focus-visible::before {
  opacity: 1;
  visibility: visible;
  transition-delay: 0s;
}
