.pyramid-container {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: var(--glass);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  z-index: 5;
  padding: 60px 20px 80px;
  opacity: 0;
  transition: opacity 0.4s ease;
}

.pyramid-container.visible { opacity: 1; }

.pyramid-title {
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 2px;
}

.pyramid-subtitle {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 20px;
}

.pyramid-chart {
  width: 100%;
  max-width: 600px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.pyramid-row {
  display: flex;
  align-items: center;
  gap: 0;
  height: 22px;
}

.pyramid-val {
  width: 36px;
  font-size: 10px;
  font-variant-numeric: tabular-nums;
  color: var(--text-secondary);
}

.pyramid-val.male { text-align: right; }
.pyramid-val.female { text-align: left; }

.pyramid-label {
  width: 44px;
  text-align: center;
  font-size: 10px;
  font-weight: 600;
  color: var(--text-secondary);
  flex-shrink: 0;
}

.pyramid-bar-wrap {
  flex: 1;
  height: 16px;
  display: flex;
}

.pyramid-bar-wrap.left { justify-content: flex-end; }
.pyramid-bar-wrap.right { justify-content: flex-start; }

.pyramid-bar {
  height: 100%;
  border-radius: 3px;
  transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.pyramid-bar.male { background: #5B9BD5; }
.pyramid-bar.female { background: #E06080; }

.pyramid-legend {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 16px;
  font-size: 11px;
  color: var(--text-secondary);
}

.pyramid-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 3px;
}

.pyramid-dot.male { background: #5B9BD5; }
.pyramid-dot.female { background: #E06080; }

.districts-chart {
  width: 100%;
  max-width: 600px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.district-row {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 26px;
}

.district-label {
  width: 120px;
  font-size: 11px;
  font-weight: 500;
  color: var(--text);
  text-align: right;
  flex-shrink: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.district-bar-wrap {
  flex: 1;
  height: 18px;
  background: var(--surface);
  border-radius: 3px;
  overflow: hidden;
}

.district-stacked {
  display: flex;
  height: 100%;
  border-radius: 3px;
  overflow: hidden;
  transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.district-seg {
  height: 100%;
  min-width: 1px;
}

.district-val {
  width: 70px;
  font-size: 10px;
  font-variant-numeric: tabular-nums;
  color: var(--text-secondary);
  text-align: right;
  flex-shrink: 0;
}

.districts-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  margin-top: 16px;
  max-width: 600px;
}

.districts-legend-item {
  font-size: 10px;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 4px;
}

.districts-legend-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 2px;
  flex-shrink: 0;
}

.mosaic-grid {
  display: grid;
  gap: 2px;
  width: 100%;
  max-width: 600px;
}

.mosaic-cell {
  aspect-ratio: 1;
  border-radius: 2px;
  opacity: 0;
  animation: mosaic-pop 0.3s ease forwards;
}

@keyframes mosaic-pop {
  from { opacity: 0; transform: scale(0); }
  to { opacity: 0.85; transform: scale(1); }
}

.mosaic-cell:hover {
  opacity: 1 !important;
  transform: scale(1.3);
  z-index: 1;
  transition: all 0.15s ease;
}

.mosaic-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 12px;
  margin-top: 16px;
  max-width: 600px;
}

.mosaic-legend-item {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 10px;
}

.mosaic-legend-dot {
  width: 8px;
  height: 8px;
  border-radius: 2px;
  flex-shrink: 0;
}

.mosaic-legend-name {
  color: var(--text);
  font-weight: 500;
}

.mosaic-legend-pct {
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
}

@media (max-width: 640px) {
  .pyramid-container { padding: 50px 12px 70px; }
  .pyramid-val { width: 28px; font-size: 9px; }
  .pyramid-label { width: 36px; font-size: 9px; }
  .district-label { width: 80px; font-size: 10px; }
  .district-val { width: 55px; font-size: 9px; }
  .mosaic-grid { gap: 1px; }
}
