/* Fonts are loaded via <link rel="preconnect"> + <link rel="stylesheet"> in index.html
   for non-render-blocking, parallel font fetching. */

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

:root {
  --bg: #15130f;
  --panel: #191711;
  --panel-soft: #1f1c16;
  --card: #17140f;
  --border: #2c2820;
  --border-strong: #463f31;
  --accent: #c9a24b;
  --text: #ece6d8;
  --muted: #9a9284;
  --font-serif: "Spectral", Georgia, serif;
  --font-sans: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --dim: var(--muted);
  --acc: var(--accent);
  --blue: #4488cc;
  --green: #6fae7e;
  --purple: #d8a13f;
}

html, body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  line-height: 1.5;
  overflow: hidden;
  height: 100vh;
  width: 100vw;
  animation: pageFadeIn 0.4s ease forwards;
}

.skipLink {
  position: fixed;
  top: 8px;
  left: 8px;
  z-index: 1000;
  padding: 8px 12px;
  color: var(--bg);
  background: var(--accent);
  font: 700 12px var(--font-sans);
  transform: translateY(-160%);
}

.skipLink:focus {
  transform: translateY(0);
}

:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 3px;
}

.srOnly {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@keyframes pageFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* Top Bar */
#macroTop {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px 10px;
  background: linear-gradient(180deg, var(--panel) 0%, rgba(21,19,15,0.96) 100%);
  backdrop-filter: blur(8px);
  box-shadow: 0 1px 0 rgba(255,255,255,0.05), 0 4px 20px rgba(0,0,0,0.4);
  border-bottom: 1px solid var(--border);
}

#macroTitle {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-sans);
  font-size: 14px;
  font-weight: 500;
  letter-spacing: -0.3px;
  line-height: 1;
  text-shadow: 0 1px 2px rgba(0,0,0,0.3);
}

#macroTitle .logoWrap {
  width: 150px;
  height: 40px;
  border-radius: 1px;
  overflow: hidden;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

#macroTitle .logoWrap .logoImage {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.visuallyHidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

#macroTitle .name {
  font: 700 20px var(--font-serif);
  color: var(--text);
}

#macroTitle .sep {
  color: #505050;
  margin: 0 2px;
}

#macroTitle .tagline {
  font-weight: 500;
  color: var(--muted);
}

#macroTitle .endorsement {
  padding-left: 10px;
  border-left: 1px solid var(--border-strong);
  color: var(--accent);
  font: 600 10px var(--font-mono);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.stats {
  display: flex;
  gap: 24px;
}

.stat {
  text-align: center;
}

.stat span {
  font-size: 8px;
  color: var(--dim);
  letter-spacing: 0.5px;
  text-transform: uppercase;
  display: block;
}

.stat b {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  display: block;
  line-height: 1.2;
  font-family: var(--font-serif);
  font-variant-numeric: tabular-nums;
  background: linear-gradient(135deg, #fff 0%, #b0b0b0 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* Control Bar */
#macroBar {
  position: fixed;
  top: 52px;
  left: 12px;
  z-index: 100;
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  max-width: 74vw;
}

#macroBar button, #macroBar select {
  background: rgba(20,20,20,0.6);
  border: 1px solid #3a3a3a;
  color: #c2c2c2;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  padding: 6px 11px;
  border-radius: 4px;
  cursor: pointer;
  letter-spacing: 0.3px;
  transition: all 0.12s;
  white-space: nowrap;
}

#macroBar button:hover, #macroBar button.on, #macroBar select:hover {
  background: #1a1a1a;
  border-color: var(--acc);
  color: var(--acc);
}

#macroBar .sep {
  width: 1px;
  background: #1a1a1a;
  align-self: stretch;
  margin: 0 4px;
}

/* Search */
#macroSearchWrap {
  position: fixed;
  top: 52px;
  right: 12px;
  z-index: 100;
  width: 260px;
}

#macroSearch {
  position: static;
  background: #111;
  border: 1px solid #333;
  color: var(--text);
  font-family: 'JetBrains Mono', monospace;
  font-size: 13px;
  padding: 8px 12px;
  width: 100%;
  outline: none;
  border-radius: 4px;
}

#macroSearch:focus {
  border-color: var(--acc);
}

#macroSearch::placeholder {
  color: #888;
}

#macroSearchSuggest {
  position: absolute;
  top: 100%;
  right: 0;
  left: 0;
  background: #111;
  border: 1px solid #222;
  border-top: none;
  display: none;
  max-height: 210px;
  overflow-y: auto;
  z-index: 101;
}

#macroSearchSuggest .suggest-item {
  padding: 8px 11px;
  font-size: 12px;
  color: #b0b0b0;
  cursor: pointer;
  border-bottom: 1px solid #1a1a1a;
}

#macroSearchSuggest .suggest-item:hover,
#macroSearchSuggest .suggest-item.active {
  background: #1a1a1a;
  color: #fff;
}

/* Detail Card */
#macroDetail {
  position: fixed;
  right: 12px;
  top: 92px;
  z-index: 120;
  width: 300px;
  background: linear-gradient(180deg, var(--panel) 0%, rgba(10,10,10,0.96) 100%);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border);
  padding: 12px;
  display: none;
  pointer-events: auto;
  box-shadow: 0 8px 32px rgba(0,0,0,0.4), 0 2px 8px rgba(0,0,0,0.3);
  border-radius: 8px;
  max-height: calc(100vh - 120px);
  overflow-y: auto;
}

#macroDetail.show {
  display: block;
  animation: fadeIn 0.2s ease forwards;
}

#macroDetail::-webkit-scrollbar {
  width: 6px;
}

#macroDetail::-webkit-scrollbar-track {
  background: rgba(255,255,255,0.03);
}

#macroDetail::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.1);
  border-radius: 3px;
}

.detailHeader {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-bottom: 10px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}

.detailFlag {
  width: 40px;
  height: 28px;
  border: 1px solid rgba(255,255,255,0.08);
  background: #0f0f0f;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border-radius: 6px;
  font-size: 20px;
}

.detailName {
  font-family: 'Bricolage Grotesque', sans-serif;
  font-size: 15px;
  font-weight: 700;
  line-height: 1.05;
  background: linear-gradient(135deg, #fff 0%, #d0d0d0 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.detailIso {
  font-size: 9px;
  color: #9a9a9a;
  letter-spacing: 0.7px;
  text-transform: uppercase;
}

.detailStats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 10px;
  padding: 10px;
  background: rgba(255,255,255,0.03);
  border-radius: 6px;
  border: 1px solid rgba(255,255,255,0.05);
}

.detailStat {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.detailStat .label {
  font-size: 8px;
  color: #666;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.detailStat b {
  font-size: 13px;
  font-weight: 600;
  color: #ddd;
}

.detailSection {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid #212121;
}

.sectionTitle {
  font-size: 8px;
  color: #6f6f6f;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  margin-bottom: 6px;
}

.partnerList, .sectorList {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.partnerItem, .sectorItem {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 8px;
  color: #8a8a8a;
  padding: 4px 0;
  border-bottom: 1px solid rgba(255,255,255,0.03);
}

.partnerItem:last-child, .sectorItem:last-child {
  border-bottom: none;
}

.partnerItem b, .sectorItem b {
  color: #ddd;
  font-weight: 600;
}

/* Top 10 Panel */
#macroTop10 {
  position: fixed;
  right: 12px;
  bottom: 12px;
  z-index: 90;
  width: 280px;
  background: rgba(10,10,10,0.95);
  backdrop-filter: blur(8px);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px;
  max-height: 50vh;
  overflow-y: auto;
}

#macroTop10::-webkit-scrollbar {
  width: 4px;
}

#macroTop10::-webkit-scrollbar-track {
  background: transparent;
}

#macroTop10::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.1);
  border-radius: 2px;
}

.top10Header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.top10Title {
  font-size: 9px;
  color: #ddd;
  text-transform: uppercase;
  letter-spacing: 0.7px;
  font-weight: 600;
}

#top10Sector {
  background: #111;
  border: 1px solid #222;
  color: var(--text);
  font-family: 'JetBrains Mono', monospace;
  font-size: 8px;
  padding: 3px 6px;
  border-radius: 4px;
  cursor: pointer;
}

#top10Sector:hover {
  border-color: var(--acc);
}

.top10List {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.top10Item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.15s;
}

.top10Item:hover {
  background: rgba(255,255,255,0.06);
  border-color: rgba(255,255,255,0.12);
  transform: translateX(2px);
}

.top10Item .rank {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  font-weight: 700;
  color: #666;
  min-width: 20px;
}

.top10Item .flag {
  font-size: 14px;
  min-width: 20px;
}

.top10Item .info {
  flex: 1;
  min-width: 0;
}

.top10Item .country {
  font-family: 'Inter', sans-serif;
  font-size: 9px;
  font-weight: 600;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.top10Item .value {
  font-family: 'JetBrains Mono', monospace;
  font-size: 8px;
  color: var(--green);
  font-weight: 600;
}

.provBadge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 54px;
  border: 1px solid #2b2b2b;
  border-radius: 10px;
  padding: 2px 6px;
  font-size: 7px;
  text-transform: uppercase;
  letter-spacing: 0.45px;
  color: #a0a0a0;
}

.provBadge.observed {
  border-color: rgba(76, 175, 80, 0.38);
  color: #7ad982;
  background: rgba(76, 175, 80, 0.12);
}

.provBadge.estimated {
  border-color: rgba(255, 159, 67, 0.35);
  color: #ffc177;
  background: rgba(255, 159, 67, 0.12);
}

/* Visualization */
#macroViz {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
}

/* Tooltip */
.tooltip {
  position: fixed;
  z-index: 300;
  background: linear-gradient(180deg, rgba(20,20,20,0.98) 0%, rgba(12,12,12,0.96) 100%);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(255,255,255,0.1);
  box-shadow: 0 8px 32px rgba(0,0,0,0.5), 0 2px 8px rgba(0,0,0,0.4);
  border-radius: 8px;
  padding: 12px 14px;
  display: none;
  max-width: 400px;
  pointer-events: none;
}

.tooltip.show {
  display: block;
}

.tooltipName {
  font-family: 'Bricolage Grotesque', sans-serif;
  font-size: 16px;
  font-weight: 700;
  color: #fff;
  margin-bottom: 6px;
  line-height: 1.2;
  text-shadow: 0 1px 2px rgba(0,0,0,0.3);
}

.tooltipGdp {
  font-size: 9px;
  color: #777;
  letter-spacing: 0.7px;
  text-transform: uppercase;
  margin-bottom: 8px;
}

.tooltipTrade {
  font-size: 10px;
  color: #888;
  line-height: 1.4;
}

/* Footer */
#macroFooter {
  position: fixed;
  left: 12px;
  bottom: 12px;
  z-index: 90;
  display: flex;
  align-items: center;
  gap: 8px;
}

#macroFooter .updateStatus {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 8px;
  color: #666;
}

#macroFooter .statusDot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
}

#macroFooter .statusDot.fresh {
  background: #4caf50;
}

#macroFooter .statusDot.stale {
  background: #ff9800;
}

#macroFooter .statusDot.outdated {
  background: #f44336;
}

/* Loading */
#macroLoading {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1000;
  background: rgba(10,10,10,0.9);
  display: none;
  align-items: center;
  justify-content: center;
  flex-direction: column;
}

#macroLoading.show {
  display: flex;
}

#macroLoading .spinner {
  width: 50px;
  height: 50px;
  border: 3px solid #222;
  border-top-color: var(--acc);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

#macroLoading .text {
  margin-top: 16px;
  font-size: 11px;
  color: #666;
  letter-spacing: 0.5px;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Sector Filter Panel */
#sectorFilterPanel {
  position: fixed;
  top: 92px;
  left: 12px;
  z-index: 130;
  background: rgba(10,10,10,0.95);
  border: 1px solid #252525;
  padding: 10px;
  display: none;
  max-width: 280px;
  border-radius: 6px;
}

#sectorFilterPanel.show {
  display: block;
}

#blocFilterPanel {
  position: fixed;
  top: 92px;
  left: 308px;
  z-index: 130;
  background: rgba(10,10,10,0.95);
  border: 1px solid #252525;
  padding: 10px;
  display: none;
  width: 280px;
  border-radius: 6px;
  max-height: 56vh;
  overflow-y: auto;
}

#blocFilterPanel.show {
  display: block;
}

#sectorFilterPanel h3 {
  font-size: 9px;
  color: var(--dim);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}

#blocFilterPanel h3 {
  font-size: 9px;
  color: var(--dim);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}

.sectorChips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 8px;
}

.blocChips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 8px;
}

.sectorChip {
  background: #111;
  border: 1px solid #222;
  color: #888;
  font-size: 8px;
  padding: 4px 8px;
  border-radius: 4px;
  cursor: pointer;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  transition: all 0.12s;
}

.blocChip {
  background: #111;
  border: 1px solid #222;
  color: #888;
  font-size: 8px;
  padding: 4px 8px;
  border-radius: 4px;
  cursor: pointer;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  transition: all 0.12s;
}

.blocChip:hover {
  border-color: var(--bloc-color, #e8453c);
  color: var(--bloc-color, #e8453c);
  background: #1a1a1a;
}

.blocChip.on {
  border-color: var(--bloc-color, #e8453c);
  color: #fff;
  background: rgba(232, 69, 60, 0.15);
}

.sectorChip:hover, .sectorChip.on {
  border-color: var(--acc);
  color: var(--acc);
  background: #1a1a1a;
}

.filterActions {
  display: flex;
  gap: 6px;
}

.filterHint {
  font-size: 8px;
  color: #666;
  margin-bottom: 8px;
  letter-spacing: 0.3px;
}

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

.filterSelectRow label {
  font-size: 8px;
  color: #7b7b7b;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.filterSelectRow select {
  flex: 1;
  background: #121212;
  border: 1px solid #272727;
  color: #c6c6c6;
  font-family: 'JetBrains Mono', monospace;
  font-size: 8px;
  padding: 4px 6px;
  border-radius: 4px;
}

.filterActions button {
  flex: 1;
  background: transparent;
  border: 1px solid #222;
  color: var(--dim);
  font-size: 8px;
  padding: 4px;
  cursor: pointer;
  text-transform: uppercase;
}

.filterActions button:hover {
  border-color: var(--acc);
  color: var(--acc);
}

/* Animations */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Sector Leader Glow */
.sector-leader {
  filter: drop-shadow(0 0 8px currentColor);
  animation: sectorPulse 2s ease-in-out infinite;
}

@keyframes sectorPulse {
  0%, 100% { stroke-width: 1.5; }
  50% { stroke-width: 3; }
}

/* Sector Legend */
#sectorLegend {
  position: fixed;
  left: 12px;
  bottom: 60px;
  z-index: 90;
  background: rgba(10, 10, 10, 0.95);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 6px;
  padding: 10px 12px;
  min-width: 180px;
}

#sectorLegend .legendTitle {
  font-size: 7px;
  color: #666;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 4px;
}

#sectorLegend .legendValue {
  font-family: 'Bricolage Grotesque', sans-serif;
  font-size: 14px;
  font-weight: 700;
  color: #fff;
  margin-bottom: 8px;
}

#sectorLegend .legendStat {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 4px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

#sectorLegend .legendStat:last-child {
  border-bottom: none;
}

#sectorLegend .legendLabel {
  font-size: 8px;
  color: #888;
}

#sectorLegend .legendStatValue {
  font-family: 'JetBrains Mono', monospace;
  font-size: 9px;
  color: #ddd;
  font-weight: 600;
}

#sectorLegend .legendMeta {
  margin-top: 8px;
  padding-top: 7px;
  border-top: 1px solid rgba(255,255,255,0.07);
  font-size: 7px;
  color: #666;
  line-height: 1.35;
}

/* Sector Chips with Colors */
.sectorChip {
  background: #111;
  border: 1px solid #222;
  color: #888;
  font-size: 8px;
  padding: 4px 8px;
  border-radius: 4px;
  cursor: pointer;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  transition: all 0.12s;
}

.sectorChip:hover {
  border-color: var(--sector-color, #e8453c);
  color: var(--sector-color, #e8453c);
  background: #1a1a1a;
}

.sectorChip.on {
  border-color: var(--sector-color, #e8453c);
  color: #fff;
  background: rgba(232, 69, 60, 0.15);
}

/* Focus states */
button:focus-visible, select:focus-visible, input:focus-visible {
  outline: 1px solid var(--acc);
  outline-offset: 1px;
}

#macroViz g.node:focus {
  outline: none;
}

#macroViz g.node:focus-visible .mc {
  stroke: #fff !important;
  stroke-width: 2.4 !important;
}

#macroViz svg:focus {
  outline: none;
}

/* Detail close button + header layout */
#macroDetail {
  position: fixed;
}

#detailClose {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 24px;
  height: 24px;
  line-height: 1;
  background: transparent;
  border: 1px solid transparent;
  color: #888;
  font-size: 18px;
  cursor: pointer;
  border-radius: 4px;
  z-index: 2;
}

#detailClose:hover {
  color: #fff;
  border-color: #333;
  background: rgba(255,255,255,0.05);
}

.detailHeader {
  padding-right: 26px;
}

.detailHeaderText {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

/* Footer link */
#macroFooter .footerSep {
  color: #444;
}

.footerLink {
  background: transparent;
  border: none;
  color: #7d7d7d;
  font-family: 'JetBrains Mono', monospace;
  font-size: 9px;
  cursor: pointer;
  padding: 0;
  letter-spacing: 0.3px;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.footerLink:hover {
  color: var(--acc);
}

/* Onboarding hint / encoding key */
#macroHint {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 200;
  width: min(380px, calc(100vw - 32px));
  background: linear-gradient(180deg, rgba(20,20,20,0.99) 0%, rgba(12,12,12,0.98) 100%);
  backdrop-filter: blur(14px);
  border: 1px solid rgba(255,255,255,0.1);
  box-shadow: 0 20px 60px rgba(0,0,0,0.6);
  border-radius: 12px;
  padding: 22px 24px;
  display: none;
}

#macroHint.show {
  display: block;
  animation: fadeIn 0.3s ease forwards;
}

#macroHint .hintTitle {
  font-family: 'Bricolage Grotesque', sans-serif;
  font-size: 20px;
  font-weight: 800;
  color: #fff;
  margin-bottom: 4px;
}

#macroHint .hintLead {
  font-family: 'Inter', sans-serif;
  font-size: 12px;
  color: #9aa6b5;
  margin-bottom: 16px;
  line-height: 1.4;
}

#macroHint .hintKey {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px;
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: 8px;
  margin-bottom: 16px;
}

#macroHint .hintKeyRow {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: 'Inter', sans-serif;
  font-size: 11px;
  color: #c2c2c2;
}

#macroHint .hintKeyRow b {
  color: #fff;
  font-weight: 600;
}

.keyDot {
  display: inline-block;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #e8453c, #7a2420);
  flex-shrink: 0;
}

.keyDotBig { width: 18px; height: 18px; }
.keyDotSmall { width: 9px; height: 9px; }

.keyRamp {
  width: 30px;
  height: 12px;
  border-radius: 3px;
  background: linear-gradient(90deg, #35597d 0%, #8a6a55 55%, #e8453c 100%);
  flex-shrink: 0;
}

.keyLine {
  width: 28px;
  height: 0;
  border-top: 2px solid rgba(232,69,60,0.6);
  flex-shrink: 0;
}

#macroHint .hintTip {
  font-family: 'Inter', sans-serif;
  font-size: 10.5px;
  color: #7d8794;
  line-height: 1.5;
  margin-bottom: 18px;
}

#macroHint #hintDismiss {
  width: 100%;
  background: var(--acc);
  border: none;
  color: #fff;
  font-family: 'Inter', sans-serif;
  font-size: 12px;
  font-weight: 600;
  padding: 10px;
  border-radius: 6px;
  cursor: pointer;
  letter-spacing: 0.3px;
}

#macroHint #hintDismiss:hover {
  background: #ff5a50;
}

/* About panel */
#aboutPanel {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 200;
  width: min(440px, calc(100vw - 32px));
  max-height: calc(100vh - 48px);
  overflow-y: auto;
  background: linear-gradient(180deg, rgba(18,18,18,0.99) 0%, rgba(10,10,10,0.98) 100%);
  backdrop-filter: blur(14px);
  border: 1px solid rgba(255,255,255,0.1);
  box-shadow: 0 20px 60px rgba(0,0,0,0.6);
  border-radius: 12px;
  padding: 22px 24px;
  display: none;
}

#aboutPanel.show {
  display: block;
  animation: fadeIn 0.25s ease forwards;
}

#aboutPanel h2 {
  font-family: 'Bricolage Grotesque', sans-serif;
  font-size: 18px;
  font-weight: 800;
  color: #fff;
  margin-bottom: 12px;
}

#aboutPanel .aboutLead {
  font-family: 'Inter', sans-serif;
  font-size: 12px;
  color: #b6b6b6;
  line-height: 1.55;
  margin-bottom: 16px;
}

#aboutPanel .aboutBlock {
  margin-bottom: 14px;
}

#aboutPanel .aboutBlockTitle {
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.7px;
  color: #6f7f92;
  margin-bottom: 7px;
  font-weight: 600;
}

#aboutPanel .aboutSources {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

#aboutPanel .aboutRow {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-family: 'Inter', sans-serif;
  font-size: 11px;
  color: #9a9a9a;
  padding: 6px 10px;
  background: rgba(255,255,255,0.03);
  border-radius: 5px;
  border: 1px solid rgba(255,255,255,0.05);
}

#aboutPanel .aboutRow b {
  color: #ddd;
  font-weight: 600;
  text-align: right;
}

#aboutPanel .aboutDisclaimer {
  font-family: 'Inter', sans-serif;
  font-size: 10px;
  color: #6d6d6d;
  line-height: 1.5;
  margin: 14px 0;
  padding-top: 12px;
  border-top: 1px solid rgba(255,255,255,0.07);
}

#aboutPanel .filterActions button {
  flex: 1;
  background: transparent;
  border: 1px solid #333;
  color: #c2c2c2;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  padding: 8px;
  cursor: pointer;
  border-radius: 4px;
}

#aboutPanel .filterActions button:hover {
  border-color: var(--acc);
  color: var(--acc);
}

/* Backdrop for modal panels */
#macroBackdrop {
  position: fixed;
  inset: 0;
  z-index: 190;
  background: rgba(0,0,0,0.55);
  display: none;
}

#macroBackdrop.show {
  display: block;
}

.panelHeading {
  margin: 0 32px 12px 0;
  color: var(--text);
  font: 700 16px var(--font-serif);
  letter-spacing: 0.01em;
}

#macroVizRegion {
  min-width: 0;
}

#releaseProvenance {
  position: fixed;
  left: 12px;
  bottom: 42px;
  z-index: 88;
  width: min(520px, calc(100vw - 24px));
  max-height: 210px;
  overflow: auto;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: 1px;
  background: rgba(25, 23, 17, 0.96);
  box-shadow: 0 18px 54px rgba(0, 0, 0, 0.24);
  color: var(--muted);
  font: 11px/1.45 var(--font-sans);
  overflow-wrap: anywhere;
}

.releaseHeader,
.releaseFacts {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.releaseHeader {
  padding-bottom: 8px;
  margin-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

#releaseProvenanceTitle {
  color: var(--text);
  font: 700 15px var(--font-serif);
}

.releaseFacts {
  justify-content: flex-start;
  flex-wrap: wrap;
  margin-bottom: 7px;
}

.releaseFact {
  min-width: 0;
}

.releaseLabel {
  display: block;
  color: var(--accent);
  font: 600 9px var(--font-mono);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

#releaseDate,
#releaseCoverage {
  color: var(--text);
  font-family: var(--font-mono);
}

#releaseMethodology {
  margin-bottom: 7px;
}

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

.releaseSource {
  min-width: 0;
}

.releaseSource b {
  color: var(--text);
  font-weight: 600;
}

/* Responsive */
@media (max-width: 768px) {
  /* Fixed-height header so every other fixed panel can anchor predictably */
  #macroTop {
    height: 46px;
    padding: 8px 12px;
    align-items: center;
  }

  #macroTitle {
    font-size: 12px;
    flex-wrap: nowrap;
    min-width: 0;
  }

  #macroTitle .name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  /* Collapse vendor|product to just the product name on phones */
  #macroTitle .sep,
  #macroTitle .tagline {
    display: none;
  }

  #macroStats {
    display: none;
  }

  /* Search sits BELOW the header band, full width — no more overlap */
  #macroSearchWrap {
    top: 54px;
    right: 8px;
    left: 8px;
    width: auto;
  }

  #macroDetail {
    width: calc(100% - 16px);
    right: 8px;
    left: 8px;
    top: 96px !important;
    max-height: calc(100vh - 170px);
  }

  #macroTop10 {
    display: none !important;
  }

  #sectorFilterPanel,
  #blocFilterPanel {
    left: 8px;
    right: 8px;
    width: auto;
    max-width: none;
    top: 96px;
  }

  #macroBar {
    display: flex;
    position: fixed;
    bottom: 8px;
    top: auto;
    left: 8px;
    right: 8px;
    justify-content: center;
    flex-wrap: wrap;
    max-width: none;
    gap: 6px;
    background: rgba(10,10,10,0.88);
    padding: 7px;
    border-radius: 10px;
    backdrop-filter: blur(8px);
    border: 1px solid var(--border);
  }

  #macroBar button {
    min-height: 38px;
    font-size: 11px;
  }

  #macroBar .sep {
    display: none;
  }

  /* Keep the lower-left legend/footer clear of the bottom control bar */
  #sectorLegend {
    display: none;
  }

  #macroFooter {
    bottom: 62px;
  }

  /* Pin modals to both side margins on phones — robust vertical-only centering */
  #macroHint,
  #aboutPanel {
    left: 12px;
    right: 12px;
    width: auto;
    transform: translateY(-50%);
  }
}

@media (max-width: 768px) {
  #macroTitle .logoWrap {
    width: 118px;
    height: 32px;
  }

  #macroTitle .endorsement {
    display: none;
  }

  #releaseProvenance {
    left: 8px;
    right: 8px;
    bottom: 38px;
    width: auto;
    max-height: 160px;
    padding: 9px 10px;
  }

  .releaseSources {
    grid-template-columns: 1fr;
  }
}

@media print {
  #macroTop, #macroBar, #macroSearchWrap, #macroDetail,
  #macroFooter, #releaseProvenance, #sectorFilterPanel, #blocFilterPanel, #macroTop10 {
    display: none !important;
  }
  #macroViz {
    position: static;
    width: 100%;
    height: 600px;
  }
  body {
    background: white;
    color: black;
    overflow: visible;
  }
}

/* Respect reduced-motion preferences */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }

  #macroFooter .statusDot,
  .sector-leader {
    animation: none !important;
  }
}
