/* Donut chart — vanilla port of DonutChart (stroke arcs, hover, center) */

.donut-chart {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: var(--donut-size, 200px);
  height: var(--donut-size, 200px);
  margin: 10px auto 4px;
}

.donut-chart__svg {
  width: 100%;
  height: 100%;
  display: block;
  overflow: visible;
  transform: rotate(-90deg);
}

.donut-chart__segment {
  transform-box: fill-box;
  transform-origin: center;
  cursor: pointer;
  transition:
    filter 0.2s ease-out,
    transform 0.2s ease-out,
    opacity 0.3s ease-out,
    stroke-dashoffset 1s ease-out;
}

.donut-chart__segment.is-idle {
  opacity: 0;
}

.donut-chart__segment.is-active {
  filter: drop-shadow(0 0 6px var(--donut-seg-glow, currentColor)) brightness(1.1);
  transform: scale(1.03);
}

.donut-chart__center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  pointer-events: none;
  width: calc(var(--donut-size, 200px) - var(--donut-stroke, 20px) * 2.5);
  height: calc(var(--donut-size, 200px) - var(--donut-stroke, 20px) * 2.5);
  margin: auto;
}

.donut-chart__center b {
  font-size: 26px;
  font-weight: 500;
  letter-spacing: -0.03em;
  line-height: 1.1;
  color: var(--fg);
}

.donut-chart__center span {
  font-size: 10px;
  color: var(--fg-3);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-top: 4px;
  max-width: 100%;
}

.panel--devices .legend {
  margin-top: 12px;
}

.d--device-mobile {
  background: var(--gold);
}

.d--device-desktop {
  background: #5080c8;
}

.d--device-tablet {
  background: #7be0ff;
}
/* Funnel chart — vanilla port of FunnelChart + PatternLines (horizontal) */

.funnel-chart {
  position: relative;
  width: 100%;
  overflow: visible;
  user-select: none;
  aspect-ratio: var(--funnel-aspect-w, 2.2) / var(--funnel-aspect-h, 1);
  margin-top: 10px;
  min-height: 0;
}

.funnel-chart__canvas {
  position: absolute;
  inset: 0;
  overflow: visible;
}

.funnel-chart__bands,
.funnel-chart__gridlines {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  display: block;
}

.funnel-chart__segments {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: row;
  align-items: stretch;
  overflow: visible;
  gap: var(--funnel-gap, 4px);
}

.funnel-segment {
  position: relative;
  flex-shrink: 0;
  height: 100%;
  z-index: 1;
  pointer-events: none;
  transition: opacity 0.28s cubic-bezier(0.33, 1, 0.68, 1);
}

.funnel-chart.has-hover .funnel-segment:not(.is-hovered) {
  opacity: 0.4;
}

.funnel-segment.is-hovered {
  z-index: 10;
  opacity: 1 !important;
}

.funnel-segment__grow {
  position: absolute;
  inset: 0;
  overflow: visible;
  transform: scaleX(0) scaleY(0);
  transform-origin: left center;
  transition:
    transform 0.62s cubic-bezier(0.2, 0.75, 0.2, 1),
    opacity 0.28s cubic-bezier(0.33, 1, 0.68, 1);
}

.funnel-chart--in .funnel-segment__grow {
  transform: scaleX(1) scaleY(1);
}

.funnel-segment svg {
  display: block;
  width: 100%;
  height: 100%;
  overflow: visible;
}

.funnel-ring path {
  transform-origin: center center;
  transform-box: fill-box;
  transition: transform 0.38s cubic-bezier(0.34, 1.2, 0.64, 1);
  --ring-boost: 0;
}

.funnel-segment.is-hovered .funnel-ring path {
  transform: scaleY(calc(1 + var(--ring-boost, 0)));
}

.funnel-chart__labels {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 20;
}

.funnel-label {
  position: absolute;
  top: 0;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  cursor: pointer;
  pointer-events: auto;
  transition: opacity 0.28s cubic-bezier(0.33, 1, 0.68, 1);
}

.funnel-chart.has-hover .funnel-label:not(.is-hovered) {
  opacity: 0.4;
}

.funnel-label.is-hovered {
  opacity: 1 !important;
}

/* spread layout: valor arriba, % centro, etapa abajo */
.funnel-label__top {
  flex: 0 0 18%;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding-bottom: 4px;
}

.funnel-label__mid {
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  justify-content: center;
}

.funnel-label__bot {
  flex: 0 0 18%;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 4px;
}

.funnel-label__value {
  font-size: 12px;
  font-weight: 600;
  color: var(--fg);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.funnel-label__pct {
  font-size: 11px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--fg);
  color: var(--bg);
  box-shadow: 0 1px 3px rgba(28, 18, 8, 0.12);
  font-family: 'Geist Mono', ui-monospace, monospace;
}

.funnel-label__stage {
  font-size: 10px;
  font-weight: 500;
  color: var(--fg-3);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  text-align: center;
  line-height: 1.25;
  max-width: 100%;
  padding: 0 2px;
}

.funnel-chart--in .funnel-label__inner {
  opacity: 1;
}

.funnel-label__inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  height: 100%;
  opacity: 0;
  transition: opacity 0.38s ease-out;
  transition-delay: var(--funnel-lbl-delay, 0s);
}

.panel--funnel .panel__foot {
  margin-top: 12px;
  font-size: 10.5px;
  color: var(--fg-4);
  letter-spacing: 0.06em;
  text-transform: none;
}
/* Panel "en vivo" — distribución nuevos vs. recurrentes */

.panel--live .live__sub {
  margin-bottom: 14px;
}

.audience-type {
  margin-top: 4px;
}

.audience-type__track {
  display: flex;
  flex-direction: row;
  gap: 4px;
  height: 14px;
  width: 100%;
  border-radius: 8px;
  overflow: visible;
}

.audience-type__fillwrap {
  height: 100%;
  border-radius: 6px;
  overflow: hidden;
  width: 0;
  min-width: 0;
  transition: width 0.88s cubic-bezier(0.2, 0.78, 0.2, 1);
}

.audience-type--in .audience-type__fillwrap[data-key='new'] {
  width: var(--new-pct, 32%);
  transition-delay: 0.05s;
}

.audience-type--in .audience-type__fillwrap[data-key='ret'] {
  width: var(--ret-pct, 68%);
  transition-delay: 0.14s;
}

.audience-type__fill {
  height: 100%;
  width: 100%;
  border-radius: 5px;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
}

.audience-type__fill--new {
  background: linear-gradient(90deg, #5a9eb8, #7be0ff);
  box-shadow: 0 0 0 1px rgba(28, 18, 8, 0.06) inset;
}

.audience-type__fill--return {
  background: linear-gradient(90deg, #6b4a18, var(--gold));
  box-shadow: 0 0 0 1px rgba(28, 18, 8, 0.06) inset;
}

.audience-type__pct {
  font-size: 10px;
  font-weight: 700;
  font-family: 'Geist Mono', ui-monospace, monospace;
  letter-spacing: 0.02em;
  color: rgba(250, 248, 244, 0.95);
  text-shadow: 0 1px 2px rgba(28, 18, 8, 0.25);
  white-space: nowrap;
  padding: 0 4px;
  opacity: 0;
  transition: opacity 0.35s ease 0.45s;
}

.audience-type--in .audience-type__pct {
  opacity: 1;
}

.audience-type__legend {
  list-style: none;
  padding: 0;
  margin: 16px 0 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.audience-type__legend li {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: var(--fg-2);
}

.audience-type__legend li b {
  margin-left: auto;
  font-family: 'Geist Mono', ui-monospace, monospace;
  color: var(--fg);
  font-weight: 600;
}

.audience-type__legend .audience-type__n {
  font-size: 12px;
  font-family: 'Geist Mono', ui-monospace, monospace;
  color: var(--fg-3);
  min-width: 2.5em;
  text-align: right;
}

.audience-type__dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.audience-type__dot--new {
  background: linear-gradient(135deg, #5a9eb8, #7be0ff);
}

.audience-type__dot--return {
  background: var(--gold);
}

.panel--live .live__foot {
  flex-wrap: wrap;
  gap: 8px 12px;
  line-height: 1.35;
  flex-direction: column;
  align-items: flex-start;
  justify-content: flex-start;
}
/* Páginas top — gráfico vanilla inspirado en ChartContainer + tooltip/leyenda Recharts/shadcn */

[data-chart='pages-top'] {
  --color-views: #8c6020;
  --color-views-muted: rgba(140, 96, 32, 0.35);
  --chart-grid: rgba(28, 18, 8, 0.08);
  --chart-tooltip-border: rgba(28, 18, 8, 0.12);
  --chart-tooltip-bg: rgba(250, 248, 244, 0.98);
  --chart-tooltip-shadow: 0 12px 40px rgba(28, 18, 8, 0.12);
}

.page-chart {
  position: relative;
  width: 100%;
  margin-top: 10px;
  aspect-ratio: 16 / 8;
  min-height: 150px;
  max-height: 220px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  font-size: 11px;
  color: var(--fg-2);
}

.page-chart__frame {
  position: relative;
  flex: 1;
  min-height: 0;
  width: 100%;
}

.page-chart__svg {
  width: 100%;
  height: 100%;
  display: block;
  overflow: visible;
}

.page-chart__grid line {
  stroke: var(--chart-grid);
  stroke-width: 1;
}

.page-chart__axis text {
  fill: var(--fg-3);
  font-family: 'Geist Mono', ui-monospace, monospace;
  font-size: 10px;
}

.page-chart__path-label {
  fill: var(--fg-2);
  font-family: 'Geist Mono', ui-monospace, monospace;
  font-size: 11px;
}

.page-chart__value-label {
  fill: var(--fg);
  font-family: 'Geist Mono', ui-monospace, monospace;
  font-size: 11px;
  font-weight: 600;
}

.page-chart__bar-wrap {
  transform: scaleX(0);
  transform-box: fill-box;
  transform-origin: left center;
  transition: transform 0.72s cubic-bezier(0.2, 0.75, 0.2, 1);
  cursor: crosshair;
}

.page-chart--in .page-chart__bar-wrap {
  transform: scaleX(1);
}

.page-chart__bar {
  filter: drop-shadow(0 1px 2px rgba(28, 18, 8, 0.08));
}

.page-chart__tip {
  position: absolute;
  z-index: 30;
  min-width: 8.5rem;
  padding: 8px 11px;
  border-radius: 10px;
  border: 1px solid var(--chart-tooltip-border);
  background: var(--chart-tooltip-bg);
  box-shadow: var(--chart-tooltip-shadow);
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.15s ease;
}

.page-chart__tip.is-on {
  opacity: 1;
  visibility: visible;
}

.page-chart__tip-label {
  font-weight: 600;
  font-size: 11px;
  color: var(--fg);
  margin-bottom: 6px;
  font-family: 'Geist Mono', ui-monospace, monospace;
}

.page-chart__tip-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  line-height: 1.2;
}

.page-chart__tip-row span:first-child {
  color: var(--fg-3);
  font-size: 11px;
}

.page-chart__tip-row span:last-child {
  font-family: 'Geist Mono', ui-monospace, monospace;
  font-weight: 600;
  font-size: 11px;
  color: var(--fg);
  font-variant-numeric: tabular-nums;
}

.page-chart__tip-dot {
  width: 8px;
  height: 8px;
  border-radius: 2px;
  background: var(--color-views);
  flex-shrink: 0;
}

.page-chart__legend {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding-top: 10px;
  color: var(--fg-3);
  font-size: 11px;
}

.page-chart__legend-dot {
  width: 8px;
  height: 8px;
  border-radius: 2px;
  background: var(--color-views);
  flex-shrink: 0;
}
/* Mapa de calor — horas pico (layout horizontal ancho, paleta SIGNO/) */

.panel--rank.panel--peak {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.peak-heat-root {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.peak-heat__scale {
  flex: 1;
  height: 6px;
  border-radius: 99px;
  background: linear-gradient(to right, #ede9e0, #d4b896, #8c6020);
  max-width: 100%;
}

.peak-heat {
  display: flex;
  flex-direction: row;
  align-items: stretch;
  gap: 12px;
  margin-top: 10px;
  flex: 1;
  min-height: 160px;
  max-height: 260px;
}

.peak-heat__left {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.peak-heat__header {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr);
  gap: 6px 8px;
  align-items: end;
}

.peak-heat__corner {
  grid-column: 1;
}

.peak-heat__hours {
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  gap: 4px;
  text-align: center;
}

.peak-heat__hours span {
  font-size: 9px;
  letter-spacing: 0.04em;
  color: var(--fg-4);
  font-family: 'Geist Mono', ui-monospace, monospace;
  text-transform: uppercase;
}

.peak-heat__rows {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
  min-height: 0;
}

.peak-heat__row {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr);
  gap: 8px;
  align-items: stretch;
  flex: 1;
  min-height: 0;
}

.peak-heat__day {
  font-size: 10px;
  font-weight: 500;
  color: var(--fg-3);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding-right: 2px;
}

.peak-heat__cells {
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  gap: 4px;
  min-height: 0;
}

.peak-heat__cell {
  border: none;
  padding: 0;
  margin: 0;
  appearance: none;
  -webkit-appearance: none;
  border-radius: 4px;
  min-height: 6px;
  min-width: 0;
  opacity: 0;
  transform: scale(0.94);
  transition:
    opacity 0.35s ease,
    transform 0.35s ease,
    box-shadow 0.2s ease,
    filter 0.2s ease;
  box-shadow: inset 0 0 0 1px rgba(28, 18, 8, 0.04);
  cursor: default;
}

.peak-heat--in .peak-heat__cell {
  opacity: 1;
  transform: scale(1);
}

.peak-heat__cell:hover {
  filter: brightness(1.06);
  box-shadow:
    inset 0 0 0 1px rgba(28, 18, 8, 0.08),
    0 0 0 2px rgba(140, 96, 32, 0.2);
  z-index: 2;
}

.peak-heat__cell:focus-visible {
  filter: brightness(1.06);
  box-shadow:
    inset 0 0 0 1px rgba(28, 18, 8, 0.08),
    0 0 0 2px rgba(140, 96, 32, 0.2);
  z-index: 2;
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}

.peak-heat__legend-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  width: 28px;
  flex-shrink: 0;
  padding-top: 22px;
}

.peak-heat__legend-track {
  flex: 1;
  width: 10px;
  min-height: 72px;
  border-radius: 5px;
  background: linear-gradient(to top, #8c6020, #d4b896, #ede9e0);
  box-shadow: inset 0 0 0 1px rgba(28, 18, 8, 0.08);
}

.peak-heat__legend-cap {
  font-size: 8px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--fg-4);
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  line-height: 1;
}

.panel--peak .panel__foot--legend {
  margin-top: 12px;
}

.peak-heat__tip {
  position: fixed;
  z-index: 100;
  padding: 7px 10px;
  border-radius: 8px;
  border: 1px solid var(--line-2);
  background: rgba(250, 248, 244, 0.98);
  box-shadow: 0 10px 32px rgba(28, 18, 8, 0.12);
  font-size: 11px;
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.12s ease;
  max-width: 220px;
}

.peak-heat__tip.is-on {
  opacity: 1;
  visibility: visible;
}

.peak-heat__tip strong {
  display: block;
  font-family: 'Geist Mono', ui-monospace, monospace;
  color: var(--fg);
  margin-bottom: 4px;
}

.peak-heat__tip span {
  color: var(--fg-3);
}

@media (max-width: 520px) {
  .peak-heat {
    flex-direction: column;
    max-height: none;
  }

  .peak-heat__legend-col {
    flex-direction: row;
    width: 100%;
    padding-top: 0;
    justify-content: center;
    gap: 12px;
  }

  .peak-heat__legend-track {
    width: min(200px, 60%);
    height: 10px;
    min-height: 0;
    background: linear-gradient(to right, #ede9e0, #d4b896, #8c6020);
  }

  .peak-heat__legend-cap {
    writing-mode: horizontal-tb;
    transform: none;
  }
}
