:root {
  /* Colores de marca (718 Networks) — cromo de interfaz y métricas principales
     (ventas/ARPU son series únicas, así que usar la marca directamente es
     seguro: con 1 serie el color solo no compite con nada). */
  --brand-orange: #e9501c;
  --brand-gold: #f7be0d;
  --brand-gradient: linear-gradient(90deg, var(--brand-orange), var(--brand-gold));

  --color-ventas: var(--brand-orange);
  --color-arpu: var(--brand-gold);
  --color-good: #0ca30c;
  --color-critical: #d03b3b;

  /* Paleta categórica (Tipo de Aplicación / Promoción), validada para
     accesibilidad CVD y contraste — mismo método que el dashboard financiero.
     "Sin dato"/"Sin promoción" usan gris neutro a propósito: no son una
     categoría real, son ausencia de información y no deben competir
     visualmente con las categorías reales. */
  --color-app-estandar: #2a78d6;
  --color-app-premium: #008300;
  --color-app-avand: #e87ba4;
  --color-app-sinapp: #eda100;
  --color-sin-dato: #898781;

  --theme-foreground-focus: var(--brand-orange);
}

@media (prefers-color-scheme: dark) {
  :root {
    --color-app-estandar: #3987e5;
    --color-app-premium: #008300;
    --color-app-avand: #d55181;
    --color-app-sinapp: #c98500;

    --theme-foreground-focus: #ff8145;
  }
}

/* ---------- Marca: barra superior, hero ---------- */

#observablehq-header {
  border-bottom: 2px solid;
  border-image: var(--brand-gradient) 1;
}

.brand-bar {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  width: 100%;
  height: 100%;
}

.brand-bar img {
  height: 22px;
  width: auto;
  display: block;
}

.brand-bar-title {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--theme-foreground-muted);
}

.brand-hero {
  position: relative;
  overflow: hidden;
  border-radius: 12px;
  margin: 0 0 2rem;
  min-height: 132px;
  display: flex;
  align-items: center;
  padding: 1.5rem 2rem;
  isolation: isolate;
}

.brand-hero-bg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 35%;
  filter: blur(9px) saturate(1.15) brightness(0.5);
  transform: scale(1.15);
  z-index: -2;
}

.brand-hero::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background: linear-gradient(115deg, rgba(15, 10, 8, 0.82), rgba(201, 61, 16, 0.45) 70%);
}

.brand-hero-content {
  display: flex;
  align-items: center;
  gap: 1.25rem;
}

.brand-hero-content img {
  height: 52px;
  width: auto;
  flex: none;
}

.brand-hero-text h1 {
  margin: 0;
  padding: 0;
  color: #fff;
  font-size: 1.5rem;
  max-width: none;
}

.brand-hero-text p {
  margin: 0.3rem 0 0;
  color: rgba(255, 255, 255, 0.88);
  font-size: 0.85rem;
}

/* ---------- Fila de filtros ---------- */

.filtros {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 1.5rem;
  margin: 1rem 0 1.5rem;
  padding-bottom: 1rem;
  border-bottom: solid 1px var(--theme-foreground-faintest);
}

.filtros label {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.75rem;
  color: var(--theme-foreground-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* ---------- KPI stat tiles ---------- */

.kpi {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  padding: 1rem 1.25rem;
  position: relative;
  overflow: hidden;
}

.kpi::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--brand-gradient);
}

.kpi-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--theme-foreground-muted);
}

.kpi-value {
  font-size: 1.9rem;
  font-weight: 600;
  line-height: 1.15;
  color: var(--theme-foreground);
}

.kpi-delta {
  font-size: 0.85rem;
  font-weight: 500;
}

.kpi-delta.good { color: var(--color-good); }
.kpi-delta.critical { color: var(--color-critical); }
.kpi-delta.neutral { color: var(--theme-foreground-muted); }

.kpi-sub {
  font-size: 0.78rem;
  color: var(--theme-foreground-muted);
}

/* ---------- Leyenda ---------- */

.leyenda {
  display: flex;
  flex-wrap: wrap;
  gap: 1.1rem;
  margin: 0.25rem 0 0.75rem;
  font-size: 0.8rem;
  color: var(--theme-foreground-muted);
}

.leyenda-item {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.leyenda-marca {
  display: inline-block;
  width: 14px;
  height: 3px;
  border-radius: 2px;
}

.leyenda-marca.area {
  height: 10px;
  border-radius: 2px;
}

/* ---------- Tablas ---------- */

.tabular {
  font-variant-numeric: tabular-nums;
}

/* ---------- Secciones ---------- */

.seccion-titulo {
  margin: 2.5rem 0 0.25rem;
}

.seccion-nota {
  color: var(--theme-foreground-muted);
  font-size: 0.85rem;
  margin: 0 0 1rem;
}
