:root {
  color-scheme: dark;
  --bg: #080b12;
  --panel: rgba(17, 20, 29, 0.92);
  --panel-line: rgba(255, 255, 255, 0.12);
  --text: #f5f7fb;
  --muted: #9ca3b3;
  --tile-gap: 8px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background:
    linear-gradient(rgba(255, 255, 255, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.035) 1px, transparent 1px),
    radial-gradient(circle at top right, rgba(77, 124, 255, 0.12), transparent 34%),
    var(--bg);
  background-size:
    44px 44px,
    44px 44px,
    auto,
    auto;
  color: var(--text);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.stats-shell {
  width: min(1280px, calc(100% - 32px));
  margin: 0 auto;
  padding: 34px 0;
}

.stats-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 28px;
}

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

h1 {
  margin: 0;
  font-size: clamp(2rem, 4vw, 3rem);
  line-height: 1;
  letter-spacing: 0;
}

.back-link {
  border: 1px solid var(--panel-line);
  border-radius: 8px;
  color: var(--text);
  padding: 10px 14px;
  text-decoration: none;
}

.stats-panel {
  border: 1px solid var(--panel-line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.36);
  padding: 24px;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
  color: var(--muted);
  font-weight: 700;
}

.panel-head p {
  margin: 0;
}

.treemap {
  position: relative;
  min-height: 620px;
  border: 1px solid var(--panel-line);
  border-radius: 8px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.045);
}

.category-box {
  position: absolute;
  border: 5px solid rgba(8, 11, 18, 0.9);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.045);
  overflow: hidden;
}

.category-title {
  position: absolute;
  z-index: 2;
  top: 0;
  right: 0;
  left: 0;
  display: flex;
  height: 42px;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 14px;
  background: rgba(8, 11, 18, 0.5);
  color: var(--text);
  font-size: 0.95rem;
  font-weight: 400;
}

.category-title span,
.category-title strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.category-title strong {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 0.78rem;
}

.category-content {
  position: absolute;
  top: 42px;
  right: 0;
  bottom: 0;
  left: 0;
}

.tile {
  position: absolute;
  display: grid;
  place-items: center;
  border: 4px solid rgba(8, 11, 18, 0.86);
  border-radius: 10px;
  color: #080b12;
  overflow: hidden;
  text-align: center;
}

.tile-label {
  display: grid;
  gap: 5px;
  padding: 10px;
}

.tile-symbol {
  font-size: clamp(0.98rem, 2.45vw, 1.72rem);
  font-weight: 800;
  line-height: 1;
}

.tile-percent {
  font-size: clamp(0.78rem, 1.35vw, 1rem);
  font-weight: 400;
}

.tile-profit {
  border-radius: 999px;
  font-size: clamp(0.7rem, 1.15vw, 0.92rem);
  font-weight: 500;
  line-height: 1.15;
}

.tile-profit.profit-up {
  color: #064d32;
}

.tile-profit.profit-down {
  color: #7d1327;
}

.tile-profit.profit-flat {
  color: rgba(8, 11, 18, 0.72);
}

.empty-state {
  display: grid;
  min-height: 620px;
  place-items: center;
  color: var(--muted);
  font-weight: 700;
  text-align: center;
}

@media (max-width: 720px) {
  .stats-topbar,
  .panel-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .stats-panel {
    padding: 14px;
  }

  .treemap,
  .empty-state {
    min-height: 520px;
  }
}
