/* mi-treemap.css — "Open S&P Map" overlay (Watchlists tab).
   Iter 25KB — the map rules mirror style.css (Market Overview → Sectors →
   Map), scoped to .mi-spm so nothing else on the dashboard is affected. */

html.mi-spm-open, html.mi-spm-open body { overflow: hidden; }

.mi-spm {
  position: fixed;
  inset: 0;
  z-index: 5000;               /* above topbar (1000) and pills (1200); tooltip is 9999 */
  display: flex;
  align-items: center;
  justify-content: center;
}
.mi-spm[hidden] { display: none; }
.mi-spm-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(6, 8, 12, 0.5);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  opacity: 0;
  transition: opacity 160ms ease;
}
.mi-spm-panel {
  position: relative;
  width: 90vw;
  height: 90vh;
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
  padding: 18px 20px 14px;
  background: #131316;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.6);
  color: #CDCCCA;
  opacity: 0;
  transform: translateY(8px) scale(0.99);
  transition: opacity 160ms ease, transform 160ms ease;
}
.mi-spm.is-open .mi-spm-backdrop,
.mi-spm.is-open .mi-spm-panel { opacity: 1; transform: none; }
@media (prefers-reduced-motion: reduce) {
  .mi-spm-backdrop, .mi-spm-panel { transition: none; }
}

.mi-spm-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 12px;
}
.mi-spm-title {
  margin: 0;
  font-family: 'Inter', sans-serif;
  font-size: 17px;
  font-weight: 600;
  color: #e6e6e6;
}
.mi-spm-controls { display: flex; align-items: center; gap: 12px; }
.mi-spm-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: 1px solid #2a2a30;
  background: transparent;
  color: #b0bec5;
  cursor: pointer;
}
.mi-spm-close:hover { background: #222226; color: #fff; }
.mi-spm-close:focus-visible { outline: 2px solid #4F98A3; outline-offset: 2px; }
.mi-spm-market { align-self: flex-start; margin-bottom: 12px; }

/* Map — fills the space left in the panel */
.mi-spm .treemap-container {
  flex: 1 1 auto;
  min-height: 0;
  width: 100%;
  position: relative;
  overflow: hidden;
  background: #0e0e11;
  border-radius: 6px;
  user-select: none;
}
.mi-spm .company-news-loading,
.mi-spm .company-news-empty {
  padding: 40px 16px;
  text-align: center;
  font-family: 'Inter', sans-serif;
  font-size: 13px;
  color: #797876;
}
.mi-spm .company-news-empty p { margin: 0; }

.mi-spm .tm-sector { position: absolute; box-sizing: border-box; overflow: hidden; }
.mi-spm .tm-sector-label {
  position: absolute; top: 0; left: 0; z-index: 2;
  padding: 2px 5px;
  font-family: 'Inter', sans-serif; font-size: 9px; font-weight: 800;
  color: #fff; letter-spacing: 0.07em;
  background: rgba(0,0,0,0.55);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  pointer-events: none; line-height: 18px; height: 18px; width: 100%; box-sizing: border-box;
}
.mi-spm .tm-industry { position: absolute; box-sizing: border-box; overflow: hidden; }
.mi-spm .tm-industry-label {
  position: absolute; top: 0; left: 0; width: 100%; height: 14px; line-height: 14px;
  padding: 0 3px;
  font-family: 'Inter', sans-serif; font-size: 7.5px; font-weight: 700;
  color: rgba(255,255,255,0.55); letter-spacing: 0.05em;
  background: rgba(0,0,0,0.3);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  pointer-events: none; box-sizing: border-box;
}
.mi-spm .tm-tile { position: absolute; box-sizing: border-box; overflow: hidden; transition: filter 0.1s; }
.mi-spm .tm-tile:hover { filter: brightness(1.18); z-index: 10; }
.mi-spm .tm-tile-ticker {
  font-family: 'Inter', sans-serif; font-weight: 800; color: #fff;
  text-shadow: 0 1px 3px rgba(0,0,0,0.7); line-height: 1.1; text-align: center; pointer-events: none;
}
.mi-spm .tm-tile-pct {
  font-family: 'Inter', sans-serif; font-weight: 600; color: rgba(255,255,255,0.88);
  text-shadow: 0 1px 2px rgba(0,0,0,0.6); line-height: 1.1; text-align: center; pointer-events: none;
}
.mi-spm .tm-tile-logo {
  display: block; object-fit: contain; margin-bottom: 4px; pointer-events: none;
  filter: drop-shadow(0 1px 2px rgba(0,0,0,0.45));
  -webkit-user-drag: none; user-select: none;
}

/* Footer: instructions + legend */
.mi-spm .map-footer {
  display: flex; align-items: flex-end; justify-content: space-between; gap: 24px;
  margin-top: 12px; padding-top: 10px;
  border-top: 1px solid rgba(42,42,48,0.4);
  flex-wrap: wrap;
}
.mi-spm .map-instructions {
  font-family: 'Inter', sans-serif; font-size: 10px; color: #5A5957; line-height: 1.7; flex-shrink: 0;
}
.mi-spm .map-legend { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.mi-spm .map-legend-bar {
  width: 280px; height: 14px; border-radius: 3px;
  background: linear-gradient(to right, #BF1820, #A82424, #782824, #323236, #206A38, #1E8E3E, #18B248);
}
.mi-spm .map-legend-ticks {
  display: flex; justify-content: space-between; width: 280px;
  font-family: 'Inter', sans-serif; font-size: 9px; color: #5A5957;
}

/* Day / Week / YTD toggle */
.mi-spm .map-metric-toggle { display: flex; border: 1px solid #2a2a30; border-radius: 6px; overflow: hidden; }
.mi-spm .map-metric-btn {
  padding: 6px 16px; background: transparent; color: #b0bec5; border: none; cursor: pointer;
  font-family: 'Inter', sans-serif; font-size: 11px; font-weight: 600; letter-spacing: 0.05em;
  transition: all 0.2s;
}
.mi-spm .map-metric-btn.active { background: #4F98A3; color: #131316; }
.mi-spm .map-metric-btn:hover:not(.active) { background: #222226; color: #e0e0e0; }
.mi-spm .map-metric-btn + .map-metric-btn { border-left: 1px solid #2a2a30; }

/* Narrow windows: stack the header, drop the instructions */
@media (max-width: 900px) {
  .mi-spm-panel { width: 96vw; height: 92vh; padding: 14px 12px 10px; }
  .mi-spm-head { flex-wrap: wrap; }
  .mi-spm .map-instructions { display: none; }
  .mi-spm .map-legend-bar, .mi-spm .map-legend-ticks { width: 200px; }
}
