.market-summary-card {
  padding: 16px;
  overflow: hidden;
  color: var(--text);
  background: var(--surface);
  border-color: var(--border);
  box-shadow: var(--shadow-card);
}

.market-summary-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.market-summary-head h3 {
  margin: 0;
  color: var(--text);
  font-size: var(--text-lg);
  font-weight: 800;
  letter-spacing: -0.02em;
}

.market-summary-head p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: var(--text-xs);
}

.market-summary-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.market-summary-actions span {
  color: var(--muted);
  font-size: var(--text-xs);
  font-weight: 700;
}

.market-summary-actions .primary-btn {
  padding: 7px 12px;
}

.market-summary-chartbar {
  display: flex;
  align-items: center;
  gap: 4px;
  height: 34px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-bottom: 0;
  border-radius: 12px 12px 0 0;
  background: var(--surface);
  color: var(--text);
  font-size: 12px;
}

.market-summary-back {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--muted);
  font-family: inherit;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: color 0.12s ease;
}

.market-summary-back:hover {
  color: var(--accent);
}

.market-summary-back:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  box-shadow: none;
}

.market-summary-back-icon {
  width: 15px;
  height: 15px;
}

.market-summary-crumb {
  overflow: hidden;
  color: var(--text);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: -0.01em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.market-summary-crumb-sep {
  color: var(--muted);
  font-size: 9px;
}

.market-summary-chartarea {
  position: relative;
}

.market-summary-zoom-float {
  position: absolute;
  top: 50%;
  right: 10px;
  z-index: 8;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  opacity: 0;
  pointer-events: none;
  transform: translate(6px, -50%);
  transition: opacity 0.15s ease, transform 0.15s ease;
}

.market-summary-chartarea.show-zoom .market-summary-zoom-float,
.market-summary-zoom-float:focus-within {
  opacity: 1;
  pointer-events: auto;
  transform: translate(0, -50%);
}

@media (hover: none) {
  .market-summary-zoom-float {
    opacity: 1;
    pointer-events: auto;
    transform: translate(0, -50%);
  }
}

.market-summary-select {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.market-summary-select span {
  color: var(--muted);
  font-size: var(--text-xs);
  font-weight: 700;
}

.market-summary-select select {
  min-height: 32px;
  padding: 4px 28px 4px 10px;
  font-size: 12px;
  font-weight: 600;
}

.market-summary-zoom-pill {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--surface);
  box-shadow: 0 12px 26px -20px rgba(15, 23, 42, 0.5);
}

.market-summary-zoom-btn {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--text);
  font-family: inherit;
  font-size: 18px;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  transition: background 0.12s ease, color 0.12s ease;
}

.market-summary-zoom-btn + .market-summary-zoom-btn {
  border-top: 1px solid var(--border);
}

.market-summary-zoom-btn:hover:not(:disabled) {
  background: var(--surface-soft);
  color: var(--accent);
}

.market-summary-zoom-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
  box-shadow: none;
}

.market-summary-zoom-btn:disabled {
  opacity: 0.38;
  cursor: not-allowed;
}

.market-summary-zoom-reset {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 12px 26px -20px rgba(15, 23, 42, 0.5);
  cursor: pointer;
  transition: background 0.12s ease, color 0.12s ease, opacity 0.12s ease;
}

.market-summary-zoom-reset svg {
  width: 16px;
  height: 16px;
}

.market-summary-zoom-reset:hover:not(:disabled) {
  background: var(--surface-soft);
  color: var(--accent);
}

.market-summary-zoom-reset:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  box-shadow: none;
}

.market-summary-zoom-reset:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.market-summary-zoom-level {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.market-summary-heatmap {
  position: relative;
  width: 100%;
  height: min(60vh, 620px);
  min-height: 420px;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 0 0 12px 12px;
  background: var(--surface);
  overscroll-behavior: contain;
  scrollbar-width: none;
}

.market-summary-heatmap::-webkit-scrollbar {
  display: none;
}

.market-summary-heatmap.is-zoomed {
  cursor: grab;
  touch-action: none;
  user-select: none;
}

.market-summary-heatmap.is-panning {
  cursor: grabbing;
}

.market-summary-canvas {
  position: relative;
  width: 100%;
  height: 100%;
}

.market-summary-canvas-inner {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  transform-origin: 0 0;
}

.market-summary-sector {
  position: absolute;
  overflow: hidden;
  background: transparent;
  cursor: pointer;
}

.market-summary-sector-title {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 4px;
  height: 26px;
  padding: 0 2px;
  overflow: hidden;
  border: 0;
  background: transparent;
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: -0.01em;
  text-align: left;
  white-space: nowrap;
  cursor: pointer;
}

.market-summary-sector-title > span:first-child {
  overflow: hidden;
  text-overflow: ellipsis;
}

.market-summary-sector-title:hover {
  color: var(--accent);
}

.market-summary-sector-title:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
  box-shadow: none;
}

.market-summary-sector-arrow {
  flex: none;
  font-size: 16px;
  line-height: 1;
}

.market-summary-tile {
  position: absolute;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--gap, 2px);
  overflow: hidden;
  color: #fff;
  font-variant-numeric: tabular-nums;
  text-align: center;
  text-decoration: none;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.28);
  transition: filter 0.12s ease;
  -webkit-user-drag: none;
}

.market-summary-tile:hover {
  z-index: 4;
  filter: brightness(1.12);
  outline: 2px solid rgba(255, 255, 255, 0.85);
  outline-offset: -2px;
}

.market-summary-tile img {
  flex: none;
  width: var(--logo, 20px);
  height: var(--logo, 20px);
  padding: calc(var(--logo, 20px) * 0.1);
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
  object-fit: contain;
  pointer-events: none;
}

.market-summary-tile .sym,
.market-summary-tile .chg {
  max-width: 100%;
  overflow: hidden;
  line-height: 1.12;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.market-summary-tile .sym {
  font-size: var(--sym, 11px);
  font-weight: 600;
  letter-spacing: -0.01em;
}

.market-summary-tile .chg {
  font-size: var(--chg, 10px);
  font-weight: 600;
}

.market-summary-legend {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 4px;
  margin-top: 12px;
}

.market-summary-legend-item {
  display: grid;
  gap: 5px;
  min-width: 0;
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  cursor: pointer;
}

.market-summary-legend-label {
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
  text-align: center;
  white-space: nowrap;
  transition: opacity 0.12s ease;
}

.market-summary-legend-swatch {
  display: block;
  height: 10px;
  border-radius: 3px;
  transition: opacity 0.12s ease, background 0.12s ease;
}

.market-summary-legend-item:hover .market-summary-legend-swatch {
  outline: 1px solid var(--accent);
  outline-offset: 1px;
}

.market-summary-legend-item:focus-visible {
  border-radius: 6px;
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.market-summary-legend-item.is-off .market-summary-legend-swatch {
  background: var(--surface-muted) !important;
  opacity: 0.6;
}

.market-summary-legend-item.is-off .market-summary-legend-label {
  opacity: 0.45;
  text-decoration: line-through;
}

.market-summary-empty {
  position: absolute;
  inset: 0;
  z-index: 6;
  display: grid;
  place-items: center;
  padding: 24px;
  color: var(--muted);
  background: var(--surface);
  font-size: var(--text-sm);
  text-align: center;
}

.market-summary-status {
  margin: 10px 0 0;
}

@media (max-width: 760px) {
  .market-summary-card {
    padding: 12px;
  }

  .market-summary-heatmap {
    height: 54vh;
    min-height: 340px;
  }

  .market-summary-actions {
    width: 100%;
    justify-content: space-between;
  }

  .market-summary-chartbar {
    height: 32px;
    padding: 0 8px;
    font-size: 11px;
  }

  .market-summary-back,
  .market-summary-crumb {
    font-size: 11px;
  }

  .market-summary-zoom-float {
    right: 8px;
  }

  .market-summary-zoom-btn,
  .market-summary-zoom-reset {
    width: 32px;
    height: 32px;
  }

  .market-summary-legend {
    gap: 2px;
  }

  .market-summary-legend-label {
    font-size: 9px;
  }
}
