@import url('https://fonts.googleapis.com/css2?family=Bricolage+Grotesque:opsz,wght@12..96,300;400;600;800&family=Inter:wght@400;500;600&family=JetBrains+Mono:wght@300;400;500;600;700&display=swap');

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

:root {
  --bg: #0a0a0a;
  --text: #d4d4d4;
  --dim: #505050;
  --acc: #e8453c;
  --blue: #4488cc;
  --green: #4caf50;
  --purple: #9c27b0;
  --panel: rgba(18, 18, 18, 0.98);
  --border: rgba(255, 255, 255, 0.08);
}

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

@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, rgba(15,15,15,0.98) 0%, rgba(10,10,10,0.95) 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 #1a1a1a;
}

#macroTitle {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: 'Inter', sans-serif;
  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: 28px;
  height: 28px;
  border-radius: 4px;
  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;
}

#macroTitle .name {
  font-weight: 600;
  color: #fff;
}

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

#macroTitle .tagline {
  font-weight: 400;
  color: #888;
}

.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: 'Bricolage Grotesque', sans-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: 3px;
  flex-wrap: wrap;
  max-width: 72vw;
}

#macroBar button, #macroBar select {
  background: transparent;
  border: 1px solid #222;
  color: var(--dim);
  font-family: 'JetBrains Mono', monospace;
  font-size: 8px;
  padding: 4px 9px;
  cursor: pointer;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  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 #222;
  color: var(--text);
  font-family: 'JetBrains Mono', monospace;
  font-size: 9px;
  padding: 5px 10px;
  width: 100%;
  outline: none;
}

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

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

#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: 6px 10px;
  font-size: 9px;
  color: #888;
  cursor: pointer;
  border-bottom: 1px solid #1a1a1a;
}

#macroSearchSuggest .suggest-item:hover {
  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%;
  animation: pulse 2s ease-in-out infinite;
}

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

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

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

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.6; transform: scale(0.9); }
}

/* 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;
}

/* Responsive */
@media (max-width: 768px) {
  #macroBar {
    display: none;
  }

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

  #macroSearchWrap {
    top: 12px;
    right: 8px;
    width: calc(100% - 100px);
  }

  #macroStats {
    display: none;
  }

  #macroTop10 {
    display: none !important;
  }

  #sectorFilterPanel,
  #blocFilterPanel {
    left: 8px;
    right: 8px;
    width: auto;
    top: 88px;
  }

  #macroBar {
    display: flex;
    position: fixed;
    bottom: 8px;
    top: auto;
    left: 8px;
    right: 8px;
    justify-content: center;
    max-width: none;
  }

  #macroBar button {
    min-height: 36px;
    min-width: 36px;
  }
}

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