/**
 * Gràfics de les seccions d'anàlisi.
 */

/* Xifres clau --------------------------------------------------------- */
.smc-kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  margin: 0;
}
.smc-kpi {
  background: var(--sm-surface);
  border: 1px solid var(--sm-line);
  border-radius: var(--sm-radius);
  padding: 14px 16px;
  box-shadow: var(--sm-shadow-sm);
}
.smc-kpi dt {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--sm-soft);
  margin: 0 0 4px;
}
.smc-kpi dd {
  margin: 0;
  font-size: 28px;
  font-weight: 700;
  line-height: 1.1;
  color: var(--sm-ink);
  font-variant-numeric: tabular-nums;
}
.smc-kpi small {
  display: block;
  margin-top: 4px;
  font-size: 12px;
  font-weight: 400;
  color: var(--sm-soft);
}

/* Barres horitzontals ------------------------------------------------- */
.smc-bars {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.smc-bar__row {
  display: flex;
  align-items: center;
  gap: 4px;
}
.smc-bar {
  flex: 1;
  min-width: 0;
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-areas: "label value" "track track";
  column-gap: 10px;
  row-gap: 4px;
  padding: 6px 8px;
  border-radius: var(--sm-radius-sm);
  color: var(--sm-ink);
  text-decoration: none;
  font-size: 14px;
  line-height: 1.25;
}
a.smc-bar:hover,
a.smc-bar:focus-visible,
.smc-bar.is-hover {
  background: var(--sm-brand-50);
  color: var(--sm-ink);
}
a.smc-bar:hover .smc-bar__label {
  text-decoration: underline;
  text-underline-offset: 2px;
}
.smc-bar__label {
  grid-area: label;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.smc-bar__value {
  grid-area: value;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.smc-bar__value small {
  font-weight: 400;
  color: var(--sm-soft);
}
.smc-bar__track {
  grid-area: track;
  height: 8px;
  border-radius: 0 4px 4px 0;
  background: #F1EDF3;
}
.smc-bar__fill {
  display: block;
  height: 100%;
  border-radius: 0 4px 4px 0;
  background: var(--c);
  transition: width .5s cubic-bezier(.2, .7, .2, 1);
}
.smc-more {
  margin: 8px 8px 0;
  font-size: 13px;
  color: var(--sm-soft);
}
.smc-empty {
  margin: 8px 0;
  color: var(--sm-soft);
  font-size: 14px;
}

/* Donut --------------------------------------------------------------- */
.smc-donut {
  display: flex;
  align-items: center;
  gap: 20px;
  flex-wrap: wrap;
}
.smc-donut__svg {
  width: 176px;
  height: 176px;
  flex: none;
}
.smc-donut__seg {
  transition: opacity .15s;
}
.smc-donut__svg:hover .smc-donut__seg:not(.is-hover) {
  opacity: .55;
}
.smc-donut__center {
  font-size: 24px;
  font-weight: 700;
  fill: var(--sm-ink);
}
.smc-donut__sub {
  font-size: 11px;
  fill: var(--sm-soft);
}
.smc-legend {
  list-style: none;
  margin: 0;
  padding: 0;
  flex: 1;
  min-width: 160px;
}
.smc-legend a,
.smc-legend li > span {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 6px;
  border-radius: var(--sm-radius-sm);
  color: var(--sm-ink);
  text-decoration: none;
  font-size: 14px;
}
.smc-legend a:hover {
  background: var(--sm-brand-50);
}
.smc-legend__swatch {
  width: 12px;
  height: 12px;
  border-radius: 3px;
  background: var(--c);
  flex: none;
}
.smc-legend__label {
  flex: 1;
}
.smc-legend__value {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.smc-legend__value small {
  font-weight: 400;
  color: var(--sm-soft);
}

/* Histograma ---------------------------------------------------------- */
.smc-hist {
  width: 100%;
  height: auto;
  display: block;
  overflow: visible;
}
.smc-col {
  fill: color-mix(in srgb, var(--c) 55%, #fff);
}
.smc-col.is-hl {
  fill: var(--c);
}
.smc-hit {
  fill: transparent;
}
.smc-hit.is-hover {
  fill: rgba(162, 55, 181, .08);
}
.smc-grid {
  stroke: #EFEBF1;
  stroke-width: 1;
}
.smc-base {
  stroke: #CFC7D4;
  stroke-width: 1;
}
.smc-axis {
  font-size: 12px;
  fill: var(--sm-soft);
  font-variant-numeric: tabular-nums;
}

/* Tooltip ------------------------------------------------------------- */
.smc-tip {
  position: fixed;
  left: 0;
  top: 0;
  z-index: 10000;
  pointer-events: none;
  background: var(--sm-ink);
  color: #fff;
  font-size: 13px;
  line-height: 1.3;
  padding: 6px 10px;
  border-radius: 8px;
  box-shadow: var(--sm-shadow);
  max-width: 320px;
}

@media (prefers-reduced-motion: reduce) {
  .smc-bar__fill {
    transition: none;
  }
}

/* Subtítol (àlies) i barres en dues columnes ------------------------- */
.smc-bar__sub {
  color: var(--sm-soft);
  font-size: 12px;
}
.smc-bars--cols {
  display: block;
  columns: 2 280px;
  column-gap: 20px;
}
.smc-bars--cols .smc-bar__row {
  break-inside: avoid;
  margin-bottom: 2px;
}
