/* ============================================================
   FinToolbox — Crypto Heatmap (tool-specific)
   Chrome (.hm-*) + insight widgets (.hmx-*) + detail panel (.hm-detail/.bd-*),
   ported from design-reference. Globals (.card .stat-row .tb-seg .aff .tag …)
   live in /css/styles.css.
   ============================================================ */

/* ---------- KPI strip ---------- */
.hm-statrow { margin-bottom: 16px; }
.hm-statrow .stat .v.lg { font-size: 22px; }

/* ---------- Heatmap chrome ---------- */
.hm-wrap {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
  box-shadow: var(--shadow-card);
}
.hm-toolbar {
  display: flex; align-items: center; flex-wrap: wrap; gap: 10px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line-soft);
  background: var(--card-2);
}
.hm-brand {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 12px; font-weight: 700; color: var(--text);
}
.hm-brand-swatch {
  display: inline-flex; border-radius: 4px; overflow: hidden; height: 14px;
  border: 1px solid rgba(255,255,255,0.06);
}
.hm-brand-swatch span { width: 6px; height: 100%; display: block; }
.hm-search {
  display: flex; align-items: center; gap: 6px;
  padding: 4px 8px;
  background: var(--card); border: 1px solid var(--line); border-radius: 7px;
  min-width: 150px; flex: 0 1 200px; color: var(--text-3);
}
.hm-search input { flex: 1; background: transparent; border: 0; outline: 0; color: var(--text); font-size: 12px; }
.hm-count {
  font-size: 11px; color: var(--text-3); margin-left: auto;
  letter-spacing: 0.01em; font-variant-numeric: tabular-nums;
}
.hm-stage { position: relative; background: #0a0c10; overflow: hidden; }
.hm-stage svg { display: block; background: #0a0c10; }
.hm-cell { cursor: pointer; }
.hm-fs-btn {
  position: absolute; top: 10px; right: 12px; z-index: 4;
  width: 30px; height: 30px; display: grid; place-items: center;
  border-radius: 7px; border: 1px solid var(--line);
  background: color-mix(in srgb, var(--card) 80%, transparent);
  color: var(--text-2); cursor: pointer;
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  transition: color 0.12s, background 0.12s;
}
.hm-fs-btn:hover { color: var(--text); background: var(--card); }
.hm-wrap.is-fullscreen {
  position: fixed; inset: 0; z-index: 1000;
  border-radius: 0; border: 0;
  display: flex; flex-direction: column; background: #0a0c10;
}
.hm-wrap.is-fullscreen .hm-stage { flex: 1; height: auto !important; }
.hm-wrap.is-fullscreen .hm-stage svg { height: 100% !important; }
.hm-foot {
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  padding: 8px 14px; border-top: 1px solid var(--line-soft);
  font-size: 11px; background: var(--card-2);
}
.hm-legend { display: inline-flex; gap: 8px; align-items: center; font-size: 11px; color: var(--text-2); margin-left: auto; }
.hm-scale { display: inline-flex; border-radius: 3px; overflow: hidden; border: 1px solid rgba(255,255,255,0.08); height: 10px; }
.hm-scale span { width: 14px; height: 100%; display: block; }

/* ---------- Detail panel (click a tile) ---------- */
.hm-detail {
  position: absolute; top: 14px; left: 14px; width: 340px; max-width: calc(100% - 24px);
  background: color-mix(in srgb, var(--card) 96%, transparent);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--line); border-radius: 12px;
  box-shadow: 0 24px 64px -20px rgba(0,0,0,0.5);
  padding: 14px; display: flex; flex-direction: column; gap: 10px; z-index: 6;
}
.hm-detail .bd-head { display: flex; align-items: center; justify-content: space-between; }
.hm-detail .bd-logo { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; color: #fff; font-weight: 800; font-size: 12px; border: 1px solid var(--line); overflow: hidden; }
.hm-detail .bd-logo img { width: 100%; height: 100%; object-fit: cover; }
.hm-detail .bd-x { width: 24px; height: 24px; border-radius: 6px; background: var(--card-2); border: 1px solid var(--line); color: var(--text-2); font-size: 16px; line-height: 1; cursor: pointer; }
.hm-detail .bd-stats { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; padding: 10px; background: var(--card-2); border: 1px solid var(--line-soft); border-radius: 8px; }
.hm-detail .bd-chart { background: var(--card-2); border-radius: 8px; padding: 6px 4px; }
.hm-detail .bd-tfs { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; }
.hm-detail .bd-tf { text-align: center; padding: 6px 4px; background: var(--card-2); border: 1px solid var(--line-soft); border-radius: 6px; }
.hm-detail .bd-actions { display: flex; gap: 6px; }

/* ---------- Insight widgets (.hmx-*) ---------- */
.hmx-card { margin: 0; }
.hmx-card .card-head h3 { font-size: 13.5px; font-weight: 700; margin: 0; letter-spacing: -0.005em; }
.hmx-card .card-head .sub { font-size: 11px; color: var(--text-3); }

.hmx-sectorbars { display: flex; flex-direction: column; }
.hmx-sectorrow { display: grid; grid-template-columns: 150px 1fr 64px 70px; align-items: center; gap: 12px; padding: 8px 16px; border-bottom: 1px solid var(--line-soft); font-size: 12px; }
.hmx-sectorrow:last-child { border-bottom: 0; }
.hmx-sectorname { display: flex; align-items: center; gap: 8px; color: var(--text); font-weight: 600; }
.hmx-sectordot { width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0; }
.hmx-sectorcount { font-size: 10px; font-weight: 600; color: var(--text-4); background: var(--card-2); padding: 1px 5px; border-radius: 3px; margin-left: 2px; }
.hmx-sectortrack { position: relative; height: 14px; background: var(--card-2); border-radius: 3px; }
.hmx-sectoraxis { position: absolute; left: 50%; top: 0; bottom: 0; width: 1px; background: var(--line); opacity: 0.6; }
.hmx-sectorbar { position: absolute; top: 2px; bottom: 2px; border-radius: 2px; transition: width 0.3s ease; }
.hmx-sectorval { text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; font-size: 12px; }
.hmx-sectormc { text-align: right; color: var(--text-3); font-variant-numeric: tabular-nums; font-size: 11.5px; }

.hmx-movers { display: flex; flex-direction: column; }
.hmx-mover { display: grid; grid-template-columns: 1fr auto auto; align-items: center; gap: 12px; padding: 10px 16px; border-bottom: 1px solid var(--line-soft); }
.hmx-mover:last-child { border-bottom: 0; }
.hmx-mover-l { display: flex; align-items: center; gap: 10px; min-width: 0; }
.hmx-coindot { width: 26px; height: 26px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; color: #fff; font-weight: 800; font-size: 11.5px; flex-shrink: 0; }
.hmx-coinmeta { display: flex; flex-direction: column; min-width: 0; }
.hmx-sym { font-size: 12.5px; font-weight: 700; color: var(--text); letter-spacing: -0.01em; }
.hmx-name { font-size: 11px; color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 130px; }
.hmx-mover-r { display: flex; flex-direction: column; align-items: flex-end; gap: 1px; }
.hmx-price { font-size: 12px; font-weight: 600; color: var(--text); font-variant-numeric: tabular-nums; }
.hmx-pct { font-size: 11.5px; font-weight: 700; font-variant-numeric: tabular-nums; }
.hmx-pct.up { color: var(--green); }
.hmx-pct.down { color: var(--red); }

.hmx-domstack { display: flex; height: 36px; border-radius: 6px; overflow: hidden; background: var(--card-2); margin-bottom: 16px; }
.hmx-domseg { transition: flex 0.3s ease; }
.hmx-domseg + .hmx-domseg { border-left: 1px solid rgba(0,0,0,0.25); }
.hmx-domlegend { display: flex; flex-direction: column; gap: 6px; }
.hmx-domrow { display: grid; grid-template-columns: 14px 1fr 64px 80px; align-items: center; gap: 10px; font-size: 12px; padding: 4px 0; }
.hmx-domdot { width: 10px; height: 10px; border-radius: 2px; }
.hmx-domlabel { color: var(--text); font-weight: 600; }
.hmx-dompct { text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--text); }
.hmx-dommc { text-align: right; color: var(--text-3); font-variant-numeric: tabular-nums; font-size: 11.5px; }

.hmx-breadth-row { display: grid; grid-template-columns: 140px 1fr 80px; align-items: center; gap: 12px; font-size: 12px; }
.hmx-breadth-l { color: var(--text-3); font-weight: 600; }
.hmx-breadth-bar { height: 10px; background: var(--red); border-radius: 2px; overflow: hidden; position: relative; }
.hmx-breadth-up { height: 100%; background: var(--green); }
.hmx-breadth-r { text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; }
.hmx-breadth-pills { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; margin-top: 4px; }
.hmx-pill { background: var(--card-2); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; display: flex; flex-direction: column; gap: 2px; }
.hmx-pill .l { font-size: 10.5px; font-weight: 600; color: var(--text-3); text-transform: uppercase; letter-spacing: 0.05em; }
.hmx-pill .v { font-size: 16px; font-weight: 700; color: var(--text); font-variant-numeric: tabular-nums; }

.hmx-trending { display: flex; flex-direction: column; }
.hmx-trendrow { display: grid; grid-template-columns: 30px 26px 1fr auto 64px; align-items: center; gap: 10px; padding: 9px 16px; border-bottom: 1px solid var(--line-soft); }
.hmx-trendrow:last-child { border-bottom: 0; }
.hmx-trendrank { font-size: 11px; font-weight: 700; color: var(--text-4); font-variant-numeric: tabular-nums; }
.hmx-trendvol { font-size: 11px; color: var(--text-3); font-variant-numeric: tabular-nums; }

/* ---------- Responsive grids ---------- */
.hm-grid-2a { display: grid; grid-template-columns: 1.4fr 1fr; gap: 16px; margin-top: 24px; }
.hm-grid-2b { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 16px; }
@media (max-width: 1100px) {
  .hmx-sectorrow { grid-template-columns: 110px 1fr 60px 64px; gap: 8px; font-size: 11.5px; }
  .hmx-breadth-row { grid-template-columns: 110px 1fr 64px; }
}
@media (max-width: 880px) {
  .hm-grid-2a, .hm-grid-2b { grid-template-columns: 1fr; }
  .hm-detail { width: calc(100% - 24px); }
}

/* ---------- Demo badge ---------- */
.hm-demo-badge {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 10.5px; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase;
  padding: 4px 8px; border-radius: 4px; background: var(--yellow-soft); color: var(--yellow);
}
