/* Market Breadth Dashboard */
html {
  scroll-behavior: smooth;
}

.mb {
  position: relative;
  margin: 0 0 3rem;
  padding: clamp(1.25rem, 3vw, 2rem);
  border: 1px solid #1e2330;
  border-radius: 8px;
  background: #0d1017;
  box-shadow: none;
  overflow: hidden;
  scroll-margin-top: 92px;
}

.mb--focused {
  border-color: #2a3040;
  box-shadow: none;
}

.mb > * {
  position: relative;
  z-index: 1;
}

.mb__header,
.mb__overview,
.mb__lower-grid {
  display: grid;
  gap: 1rem;
}

.mb__header {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
  margin-bottom: 1.15rem;
}

.mb__title-block {
  min-width: 0;
  max-width: 760px;
}

.mb__eyebrow,
.mb__label,
.mb__card-head span,
.mb__section-head span,
.mb__source-pill span,
.mb__kpi-label,
.mb__sector-symbol,
.mb__divergence-level {
  color: #8ea0b7;
  font-size: 0.68rem;
  font-weight: 850;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.mb__eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.45rem;
  color: #67e8f9;
}

.mb__title {
  margin: 0;
  color: #f8fafc;
  font-size: clamp(1.65rem, 3vw, 2.25rem);
  font-weight: 900;
  letter-spacing: 0;
  line-height: 1.05;
}

.mb__subtitle {
  max-width: 680px;
  margin: 0.55rem 0 0;
  color: #a4adbb;
  font-size: 0.95rem;
  line-height: 1.58;
}

.mb__source-pill {
  min-width: 150px;
  padding: 0.7rem 0.85rem;
  border: 1px solid #1e2330;
  border-radius: 8px;
  background: #151a25;
  text-align: right;
}

.mb__source-pill strong {
  display: block;
  margin-top: 0.18rem;
  color: #e2e8f0;
  font-size: 0.86rem;
  font-weight: 850;
}

.mb__overview {
  grid-template-columns: minmax(280px, 0.82fr) minmax(0, 1.18fr);
  margin-bottom: 1rem;
}

.mb__score-panel,
.mb__briefing,
.mb__chart-card,
.mb__sector-panel,
.mb__divergence-panel,
.mb__kpi-card {
  border: 1px solid #1e2330;
  border-radius: 8px;
  background: #0d1017;
}

.mb__score-panel {
  display: flex;
  align-items: center;
  gap: 1rem;
  min-width: 0;
  padding: 1rem;
}

.mb__score-ring {
  --mb-score: 0;
  --mb-color: #64748b;
  position: relative;
  display: grid;
  place-items: center;
  flex: 0 0 118px;
  width: 118px;
  height: 118px;
  border-radius: 50%;
  background:
    radial-gradient(circle at center, rgba(7, 11, 21, 1) 57%, transparent 58%),
    conic-gradient(var(--mb-color) calc(var(--mb-score) * 10%), rgba(51, 65, 85, 0.72) 0);
  box-shadow: none;
}

.mb__score-ring span {
  color: #f8fafc;
  font-size: 2rem;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
}

.mb__score-copy {
  min-width: 0;
}

.mb__score-copy strong {
  display: block;
  margin-top: 0.2rem;
  color: #f8fafc;
  font-size: 1.35rem;
  font-weight: 900;
  line-height: 1.15;
}

.mb__score-copy small,
.mb__briefing p,
.mb__divergence-text,
.mb__sector-detail {
  color: #a8b2c2;
  font-size: 0.86rem;
  line-height: 1.55;
}

.mb__score-copy small {
  display: block;
  margin-top: 0.22rem;
}

.mb__briefing {
  position: relative;
  min-width: 0;
  padding: 1.05rem 1.1rem;
}

.mb__briefing p {
  margin: 0.35rem 0 0;
  color: #d7dde8;
  font-size: 0.98rem;
}

.mb__traffic {
  display: flex;
  gap: 0.38rem;
  margin-top: 0.85rem;
}

.mb__traffic-dot {
  width: 0.72rem;
  height: 0.72rem;
  border-radius: 50%;
  background: rgba(100, 116, 139, 0.5);
}

.mb__traffic-dot.is-active:nth-child(1) { background: #22c55e; }
.mb__traffic-dot.is-active:nth-child(2) { background: #f59e0b; }
.mb__traffic-dot.is-active:nth-child(3) { background: #ef4444; }

.mb__kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.85rem;
  margin-bottom: 1rem;
}

.mb__kpi-card {
  min-width: 0;
  padding: 0.95rem;
  transition: border-color 0.18s ease;
}

.mb__kpi-card:hover {
  border-color: #2a3040;
}

.mb__kpi-top {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  align-items: center;
}

.mb__kpi-value {
  display: block;
  margin-top: 0.55rem;
  color: #f8fafc;
  font-size: clamp(1.45rem, 3vw, 2.1rem);
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

.mb__kpi-status {
  display: inline-flex;
  min-height: 24px;
  align-items: center;
  padding: 0.22rem 0.5rem;
  border-radius: 999px;
  color: #dbeafe;
  background: rgba(59, 130, 246, 0.13);
  font-size: 0.68rem;
  font-weight: 800;
  white-space: nowrap;
}

.mb__kpi-foot {
  margin-top: 0.55rem;
  color: #8390a3;
  font-size: 0.76rem;
  line-height: 1.4;
}

.mb__chart-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
  margin-bottom: 1rem;
}

.mb__chart-card {
  min-width: 0;
  padding: 1rem;
}

.mb__chart-card--wide {
  grid-column: span 2;
}

.mb__card-head,
.mb__section-head {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  align-items: flex-start;
  margin-bottom: 0.75rem;
}

.mb__card-head h3,
.mb__section-head h3 {
  margin: 0.18rem 0 0;
  color: #f8fafc;
  font-size: 1rem;
  font-weight: 850;
  line-height: 1.2;
}

.mb__card-head small {
  display: inline-flex;
  align-items: center;
  min-height: 25px;
  padding: 0.24rem 0.55rem;
  border-radius: 999px;
  color: #cbd5e1;
  background: rgba(148, 163, 184, 0.1);
  font-size: 0.68rem;
  font-weight: 800;
  white-space: nowrap;
}

.mb__chart-wrap {
  position: relative;
  height: 250px;
}

.mb__chart-card:not(.mb__chart-card--wide) .mb__chart-wrap {
  height: 220px;
}

.mb__lower-grid {
  grid-template-columns: minmax(0, 1.2fr) minmax(320px, 0.8fr);
}

.mb__sector-panel,
.mb__divergence-panel {
  min-width: 0;
  padding: 1rem;
}

.mb__sector-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.65rem;
}

.mb__sector-card {
  --mb-sector: #64748b;
  min-width: 0;
  padding: 0.75rem;
  border: 1px solid color-mix(in srgb, var(--mb-sector), transparent 70%);
  border-radius: 8px;
  background: #0d1017;
}

.mb__sector-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.mb__sector-name {
  overflow: hidden;
  color: #f8fafc;
  font-size: 0.86rem;
  font-weight: 850;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mb__sector-symbol {
  color: color-mix(in srgb, var(--mb-sector), white 45%);
}

.mb__sector-bar {
  position: relative;
  height: 7px;
  margin: 0.65rem 0 0.45rem;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.13);
}

.mb__sector-fill {
  width: var(--mb-sector-width, 0%);
  height: 100%;
  border-radius: inherit;
  background: var(--mb-sector);
}

.mb__sector-detail {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  color: #9ca8ba;
  font-size: 0.74rem;
}

.mb__divergence-list {
  display: grid;
  gap: 0.65rem;
}

.mb__divergence-item {
  padding: 0.78rem;
  border: 1px solid #1e2330;
  border-left: 3px solid var(--mb-divergence, #64748b);
  border-radius: 8px;
  background: #0d1017;
}

.mb__divergence-title {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  color: #f8fafc;
  font-size: 0.88rem;
  font-weight: 850;
  line-height: 1.35;
}

.mb__divergence-level {
  flex: 0 0 auto;
  color: var(--mb-divergence, #94a3b8);
}

.mb__divergence-text {
  margin-top: 0.35rem;
  font-size: 0.8rem;
}

.mb [data-tone="strong"] { --mb-tone: #22c55e; }
.mb [data-tone="neutral"] { --mb-tone: #3b82f6; }
.mb [data-tone="fragile"] { --mb-tone: #f59e0b; }
.mb [data-tone="critical"] { --mb-tone: #ef4444; }

@media (max-width: 1100px) {
  .mb__kpi-grid,
  .mb__sector-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .mb__lower-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 820px) {
  .mb {
    padding: 1rem;
    border-radius: 8px;
  }
  .mb__header,
  .mb__overview,
  .mb__chart-grid {
    grid-template-columns: 1fr;
  }
  .mb__source-pill {
    text-align: left;
  }
  .mb__chart-card--wide {
    grid-column: span 1;
  }
  .mb__score-panel {
    align-items: flex-start;
  }
}

@media (max-width: 560px) {
  .mb__score-panel {
    display: grid;
  }
  .mb__kpi-grid,
  .mb__sector-grid {
    grid-template-columns: 1fr;
  }
  .mb__card-head,
  .mb__section-head {
    display: grid;
  }
  .mb__chart-wrap,
  .mb__chart-card:not(.mb__chart-card--wide) .mb__chart-wrap {
    height: 210px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .mb__kpi-card,
  .mb * {
    transition: none !important;
  }
}
