:root {
  color-scheme: dark;
  --bg: #05070b;
  --panel: rgba(9, 16, 26, 0.8);
  --panel-border: rgba(140, 255, 226, 0.15);
  --text: #e7f3ff;
  --muted: #93a4c7;
  --accent: #6df0d1;
  --shadow: 0 30px 80px rgba(0, 0, 0, 0.55);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: radial-gradient(circle at 15% 10%, rgba(12, 39, 53, 0.6), transparent 45%),
    radial-gradient(circle at 80% 20%, rgba(28, 16, 45, 0.6), transparent 50%),
    var(--bg);
  font-family: "Space Grotesk", "Segoe UI", sans-serif;
  color: var(--text);
}

.heatmap-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 32px 48px 12px;
  gap: 24px;
}

.header-actions {
  display: inline-flex;
  align-items: center;
  gap: 12px;
}

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.3em;
  font-size: 0.75rem;
  color: var(--muted);
  margin: 0 0 10px;
}

.heatmap-header h1 {
  margin: 0 0 8px;
  font-size: clamp(2rem, 3vw, 3.2rem);
}

.subtitle {
  margin: 0;
  color: var(--muted);
  max-width: 520px;
}

.ghost-button {
  border: 1px solid rgba(109, 240, 209, 0.35);
  background: rgba(14, 30, 46, 0.65);
  color: var(--text);
  padding: 12px 18px;
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.ghost-button:hover {
  border-color: rgba(109, 240, 209, 0.8);
  box-shadow: 0 0 18px rgba(109, 240, 209, 0.35);
  transform: translateY(-1px);
}

.heatmap-shell {
  display: grid;
  grid-template-columns: minmax(260px, 280px) 1fr;
  gap: 24px;
  padding: 20px 48px 48px;
}

.heatmap-shell.is-collapsed {
  grid-template-columns: 1fr;
}

.heatmap-shell.is-collapsed .controls {
  display: none;
}

.controls {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 18px;
  padding: 22px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.control-block h2 {
  margin: 0 0 8px;
  font-size: 0.95rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.helper {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 0.8rem;
}

.segmented {
  display: flex;
  gap: 6px;
  background: rgba(10, 22, 34, 0.9);
  border-radius: 999px;
  padding: 6px;
  border: 1px solid rgba(140, 255, 226, 0.18);
}

.segment {
  flex: 1;
  border-radius: 999px;
  border: 1px solid transparent;
  padding: 6px 12px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: all 0.2s ease;
}

.segment.active {
  background: rgba(109, 240, 209, 0.18);
  color: var(--text);
  border-color: rgba(109, 240, 209, 0.4);
}

select,
input[type="search"] {
  width: 100%;
  border-radius: 10px;
  background: rgba(12, 20, 32, 0.8);
  color: var(--text);
  border: 1px solid rgba(145, 175, 215, 0.3);
  padding: 10px 12px;
}

.grade-filters,
.sector-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.filter-actions {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
}

.filter-action {
  border: 1px solid rgba(109, 240, 209, 0.3);
  background: rgba(12, 20, 32, 0.7);
  color: var(--text);
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 0.75rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

.filter-action:hover {
  border-color: rgba(109, 240, 209, 0.7);
  box-shadow: 0 0 12px rgba(109, 240, 209, 0.25);
}

.filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(12, 20, 32, 0.8);
  border: 1px solid rgba(145, 175, 215, 0.3);
  cursor: pointer;
  font-size: 0.82rem;
}

.filter-chip input {
  accent-color: var(--accent);
}

.visuals {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.legend {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(5, 12, 20, 0.6);
  border: 1px solid rgba(140, 255, 226, 0.2);
  border-radius: 16px;
  padding: 18px 22px;
  box-shadow: var(--shadow);
}

.legend h3 {
  margin: 0 0 6px;
  font-size: 1rem;
}

.legend p {
  margin: 0;
  color: var(--muted);
}

.legend-scale {
  display: flex;
  gap: 6px;
}

.legend-chip {
  width: 44px;
  height: 24px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.context {
  background: rgba(6, 12, 21, 0.7);
  border: 1px solid rgba(109, 240, 209, 0.2);
  border-radius: 16px;
  padding: 16px 22px;
  box-shadow: var(--shadow);
}

.context-label {
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.2em;
  font-size: 0.7rem;
  color: var(--muted);
}

.context h2 {
  margin: 8px 0 6px;
}

.context-subtitle {
  margin: 0;
  color: var(--muted);
}

.context-total {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 0.8rem;
}

.bars-panel {
  position: relative;
  height: 90px;
  border-radius: 16px;
  overflow: hidden;
  background: rgba(8, 14, 24, 0.7);
  border: 1px solid rgba(109, 240, 209, 0.2);
  box-shadow: var(--shadow);
}

.bars-panel canvas {
  width: 100%;
  height: 100%;
  display: block;
}

.bars-legend {
  position: absolute;
  inset: auto 12px 10px 12px;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 6px;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.2em;
  color: rgba(231, 243, 255, 0.8);
  pointer-events: none;
}

.bars-legend span {
  display: grid;
  place-items: center;
  border-radius: 8px;
  padding: 2px 0;
  background: color-mix(in srgb, var(--chip) 20%, transparent);
  border: 1px solid color-mix(in srgb, var(--chip) 50%, transparent);
  box-shadow: inset 0 0 12px color-mix(in srgb, var(--chip) 35%, transparent);
}

.heatmap-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
}

.tile {
  position: relative;
  padding: 12px;
  border-radius: 16px;
  background: rgba(14, 24, 38, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.08);
  min-height: 96px;
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.tile::before {
  content: "";
  position: absolute;
  inset: -40%;
  background: conic-gradient(from 180deg at 50% 50%, rgba(109, 240, 209, 0.12), transparent 35%, rgba(125, 160, 255, 0.18), transparent 70%);
  opacity: 0;
  z-index: 0;
  animation: tailwind 8s linear infinite;
  transition: opacity 0.3s ease;
}

.tile:hover {
  transform: translateY(-4px);
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4);
}

.tile:hover::before {
  opacity: 1;
}

.tile > * {
  position: relative;
  z-index: 1;
}

.tile .grade {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  font-weight: 600;
  font-size: 0.85rem;
  border: 1px solid rgba(255, 255, 255, 0.25);
  background: rgba(0, 0, 0, 0.2);
}

.tile .name {
  margin: 10px 0 4px;
  font-size: 0.92rem;
}

.tile .meta {
  margin: 0;
  color: rgba(255, 255, 255, 0.7);
  font-size: 0.75rem;
}

.tile::after {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at top right, rgba(255, 255, 255, 0.18), transparent 55%);
  opacity: 0;
  transition: opacity 0.2s ease;
}

.tile:hover::after {
  opacity: 1;
}

.tile.glow {
  animation: pulseGlow 3.4s ease-in-out infinite;
}

.analysis-panel {
  background: rgba(6, 12, 20, 0.72);
  border-radius: 18px;
  border: 1px solid rgba(109, 240, 209, 0.25);
  padding: 18px 22px;
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
}

.analysis-panel::after {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at top right, rgba(109, 240, 209, 0.2), transparent 55%);
  opacity: 0.5;
  pointer-events: none;
}

.analysis-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  position: relative;
  z-index: 1;
}

.analysis-label {
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.2em;
  font-size: 0.7rem;
  color: var(--muted);
}

.analysis-subtitle {
  margin: 4px 0 0;
  color: var(--muted);
}

.analysis-overall {
  margin: 6px 0 0;
  font-size: 0.8rem;
  color: rgba(231, 243, 255, 0.75);
}

.analysis-score {
  display: grid;
  gap: 6px;
  text-align: right;
}

.analysis-grade {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 46px;
  height: 46px;
  border-radius: 14px;
  font-weight: 600;
  font-size: 1.2rem;
  background: rgba(12, 20, 32, 0.8);
  border: 1px solid rgba(109, 240, 209, 0.4);
  box-shadow: 0 0 16px rgba(109, 240, 209, 0.2);
}

.analysis-score-value {
  font-size: 0.8rem;
  color: var(--muted);
}

.dimension-grid {
  margin-top: 16px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  position: relative;
  z-index: 1;
}

.dimension-card {
  border-radius: 14px;
  padding: 12px;
  background: rgba(10, 18, 30, 0.8);
  border: 1px solid rgba(145, 175, 215, 0.25);
  display: grid;
  gap: 6px;
  min-height: 140px;
  position: relative;
  overflow: hidden;
  transition: transform 0.25s ease, box-shadow 0.25s ease;
}

.dimension-card::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(130deg, rgba(109, 240, 209, 0.12), transparent 60%);
  opacity: 0;
  transition: opacity 0.25s ease;
  pointer-events: none;
}

.dimension-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 18px 36px rgba(0, 0, 0, 0.45);
}

.dimension-card:hover::after {
  opacity: 1;
}

.dimension-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.dimension-title {
  margin: 0;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: rgba(231, 243, 255, 0.85);
}

.dimension-grade {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  font-weight: 600;
  font-size: 0.8rem;
  border: 1px solid rgba(255, 255, 255, 0.3);
}

.dimension-score {
  font-size: 0.8rem;
  color: var(--muted);
}

.dimension-description {
  margin: 0;
  font-size: 0.78rem;
  color: rgba(231, 243, 255, 0.75);
  line-height: 1.4;
}

@keyframes pulseGlow {
  0%,
  100% {
    box-shadow: 0 0 12px rgba(255, 255, 255, 0.05);
  }
  50% {
    box-shadow: 0 0 22px rgba(255, 255, 255, 0.18);
  }
}

@keyframes tailwind {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

@media (max-width: 980px) {
  .heatmap-shell {
    grid-template-columns: 1fr;
  }

  .heatmap-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .header-actions {
    width: 100%;
    justify-content: flex-start;
    flex-wrap: wrap;
  }
}
