.hm-page {
  width: 100%;
  max-width: var(--content-max);
  margin: 0 auto;
  padding: 20px 24px 48px;
}

/* ── Header ── */

.hm-header {
  padding: var(--space-7) 0 var(--space-6);
}

.hm-back {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-xs);
  color: var(--fg-4);
  text-decoration: none;
  transition: color var(--dur-fast) var(--ease-out);
  margin-bottom: var(--space-3);
}
.hm-back:hover { color: var(--fg-2); }

.hm-eyebrow {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--brand-teal);
  text-transform: uppercase;
  letter-spacing: var(--tracking-caps);
  margin-bottom: var(--space-2);
}

.hm-title {
  font-size: var(--text-4xl);
  font-weight: 700;
  letter-spacing: var(--tracking-display);
  line-height: var(--lh-tight);
  margin-bottom: var(--space-2);
}

.hm-sub {
  font-size: var(--text-sm);
  color: var(--fg-3);
}

/* ── Controls ── */

.hm-filters {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  margin-bottom: var(--space-6);
}

.hm-grid-header {
  display: flex;
  align-items: center;
  margin-bottom: var(--space-2);
}

.hm-export-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--fg-3);
  background: none;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  padding: 4px 10px;
  cursor: pointer;
  transition: color var(--dur-fast) var(--ease-out), border-color var(--dur-fast) var(--ease-out);
}
.hm-export-btn:hover { color: var(--fg-1); border-color: var(--border-strong); }
.hm-export-btn:disabled { opacity: 0.5; cursor: default; }

.hm-legend {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-left: auto;
}

.hm-legend-item {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.hm-legend-loss { color: var(--down-500); }
.hm-legend-gain { color: var(--up-500); }

.hm-legend-bar {
  display: flex;
  gap: 2px;
}

.hm-legend-seg {
  width: 18px;
  height: 10px;
  border-radius: 2px;
}
.hm-leg-loss-hi  { background: rgba(239,68,68,0.65); }
.hm-leg-loss-lo  { background: rgba(239,68,68,0.22); }
.hm-leg-neutral  { background: var(--bg-3); }
.hm-leg-gain-lo  { background: rgba(34,197,94,0.22); }
.hm-leg-gain-hi  { background: rgba(34,197,94,0.65); }

/* ── Loading / Empty ── */

.hm-loading,
.hm-empty {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1;
}

.hm-empty {
  color: var(--fg-4);
  font-size: var(--text-sm);
}

/* ── Grid ── */

.hm-grid {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 0.62;
  overflow: hidden;
  border-radius: var(--radius-lg);
  background: var(--bg-2);
}

/* ── Cell ── */

.hm-cell {
  position: absolute;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border-radius: 3px;
  border: 1px solid rgba(0,0,0,0.2);
  text-decoration: none;
  padding: 4px;
  gap: 6px;
  overflow: hidden;
  box-sizing: border-box;
  transition: filter var(--dur-fast) var(--ease-out);
}
.hm-cell:hover {
  filter: brightness(1.18);
  z-index: 2;
  text-decoration: none;
}

.hm-thumb {
  object-fit: contain;
  flex-shrink: 0;
}

.hm-cell-name {
  font-size: 10px;
  font-weight: 600;
  color: var(--fg-2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
  text-align: center;
  line-height: 1.2;
}

.hm-cell-pct {
  font-family: var(--font-mono);
  font-size: var(--text-lg);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

.hm-cell-val {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--fg-4);
  font-variant-numeric: tabular-nums;
}

/* ── Tooltip ── */

.hm-tooltip {
  position: fixed;
  display: none;
  z-index: 100;
  pointer-events: none;
  background: var(--bg-4);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  padding: 6px 12px;
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--fg-1);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  box-shadow: var(--shadow-md);
  line-height: 1.6;
}

/* ── Mobile ── */

@media (max-width: 600px) {
  .hm-legend { display: none; }
  .hm-page { padding: 16px; }
}
