/* Dashboard de Clientes frecuentes (Programa de Lealtad).
   Jerarquía: primero el número que importa (hero), luego el resto de métricas,
   después "de un vistazo" y al final qué hacer. Todo con el prefijo `ld-`. */

#loyalty-dashboard-container {
  --ld-card: var(--bg-card-solid);
  --ld-r: 18px;
  --ld-r-lg: 22px;
  --ld-ease: cubic-bezier(.22, 1, .36, 1);
  --ld-spring: cubic-bezier(.34, 1.4, .48, 1);
  --ld-shadow: 0 1px 2px rgba(15, 23, 42, .04), 0 12px 28px -20px rgba(15, 23, 42, .45);
  --ld-shadow-lift: 0 2px 6px rgba(15, 23, 42, .06), 0 26px 50px -26px rgba(15, 23, 42, .5);
  /* Neutro visible sobre card blanca o oscura: sin él, las horas/columnas en
     cero desaparecen y la rejilla deja de leerse como rejilla. */
  --ld-track: rgba(148, 163, 184, .18);
  --ld-heat-empty: rgba(148, 163, 184, .13);
}
:root:not([data-theme="light"]) #loyalty-dashboard-container {
  --ld-shadow: 0 1px 2px rgba(0, 0, 0, .25), 0 14px 34px -22px rgba(0, 0, 0, .8);
  --ld-shadow-lift: 0 2px 8px rgba(0, 0, 0, .3), 0 30px 60px -28px rgba(0, 0, 0, .9);
  --ld-track: rgba(255, 255, 255, .09);
  --ld-heat-empty: rgba(255, 255, 255, .06);
}

/* ── Toolbar: periodo + refresh ─────────────────────────────────────── */
.ld-toolbar { display:flex; align-items:center; gap:10px; margin-bottom:12px; flex-wrap:wrap; }
.ld-shell.is-loading .ld-toolbar, .ld-shell.is-loading .ld-subtabs { opacity:.55; }
.ld-toolbar, .ld-subtabs { transition:opacity .2s ease; }

/* Control segmentado con "thumb" deslizante (periodo y sub-tabs). */
.ld-seg { position:relative; display:inline-flex; gap:2px; padding:4px; border-radius:15px;
  background:var(--bg-input); border:1px solid var(--border); }
.ld-seg-thumb { position:absolute; top:0; left:0; border-radius:11px; opacity:0; z-index:0;
  background:var(--gradient-primary); box-shadow:0 8px 18px -8px rgba(249,115,22,.8);
  transition:transform .45s var(--ld-spring), width .45s var(--ld-spring),
             height .2s ease, opacity .2s ease; }
.ld-seg-btn { position:relative; z-index:1; border:none; background:transparent; color:var(--text-secondary);
  font:inherit; font-size:13px; font-weight:600; padding:8px 15px; border-radius:11px; cursor:pointer;
  white-space:nowrap; transition:color .25s ease, transform .25s var(--ld-ease); }
.ld-seg-btn:hover { color:var(--text); }
.ld-seg-btn.is-active { color:#fff; }
.ld-seg-btn:active { transform:scale(.96); }

.ld-refresh { margin-left:auto; width:38px; height:38px; display:grid; place-items:center;
  border-radius:12px; border:1px solid var(--border); background:var(--ld-card);
  color:var(--text-secondary); cursor:pointer; box-shadow:var(--ld-shadow);
  transition:color .2s, transform .25s var(--ld-ease), border-color .2s; }
.ld-refresh:hover { color:var(--primary); transform:rotate(-12deg);
  border-color:color-mix(in srgb, var(--primary) 40%, var(--border)); }
@keyframes ldSpin { to { transform:rotate(360deg); } }
.ld-refresh.is-spinning svg { animation:ldSpin .9s var(--ld-ease); }

/* ── Sub-tabs ───────────────────────────────────────────────────────── */
.ld-subtabs { display:flex; width:100%; overflow-x:auto; margin-bottom:16px;
  scrollbar-width:none; }
.ld-subtabs::-webkit-scrollbar { display:none; }
.ld-subtab { display:inline-flex; align-items:center; gap:7px; flex:1 0 auto; justify-content:center; }
.ld-subtab svg { width:16px; height:16px; opacity:.9;
  transition:transform .35s var(--ld-spring); }
.ld-subtab:hover svg { transform:translateY(-1px) scale(1.08); }

/* ── HERO: el número que importa ────────────────────────────────────── */
.ld-hero { position:relative; overflow:hidden; display:grid; gap:22px; align-items:center;
  grid-template-columns:minmax(240px, .78fr) minmax(0, 1.22fr);
  background:var(--ld-card); border:1px solid var(--border); border-radius:var(--ld-r-lg);
  padding:22px 24px; margin-bottom:14px; box-shadow:var(--ld-shadow);
  transition:box-shadow .35s var(--ld-ease), border-color .35s ease; }
.ld-hero:hover { box-shadow:var(--ld-shadow-lift);
  border-color:color-mix(in srgb, var(--primary) 26%, var(--border)); }
.ld-hero-blob { position:absolute; top:-140px; left:-120px; width:340px; height:340px; border-radius:50%;
  background:radial-gradient(circle, color-mix(in srgb, var(--primary) 22%, transparent), transparent 68%);
  pointer-events:none; animation:ldFloat 9s ease-in-out infinite; }
@keyframes ldFloat {
  0%, 100% { transform:translate(0, 0) scale(1); }
  50% { transform:translate(18px, 14px) scale(1.08); }
}
.ld-hero-copy { position:relative; z-index:1; min-width:0; }
.ld-hero-eyebrow { display:inline-flex; align-items:center; gap:7px; font-size:11.5px; font-weight:700;
  letter-spacing:.06em; text-transform:uppercase; color:var(--text-muted); margin-bottom:10px; }
.ld-livedot { width:7px; height:7px; border-radius:50%; background:var(--primary);
  box-shadow:0 0 0 0 color-mix(in srgb, var(--primary) 60%, transparent); animation:ldPing 2.4s ease-out infinite; }
@keyframes ldPing {
  0% { box-shadow:0 0 0 0 color-mix(in srgb, var(--primary) 55%, transparent); }
  70% { box-shadow:0 0 0 9px transparent; }
  100% { box-shadow:0 0 0 0 transparent; }
}
.ld-hero-fig { display:flex; align-items:baseline; gap:10px; flex-wrap:wrap; }
.ld-hero-num { font-size:clamp(42px, 4.6vw, 58px); font-weight:800; line-height:.92; letter-spacing:-.045em;
  font-variant-numeric:tabular-nums;
  background:linear-gradient(125deg, var(--primary-light), var(--primary) 55%, var(--primary-dark));
  -webkit-background-clip:text; background-clip:text; color:transparent; }
.ld-hero-unit { display:inline-flex; align-items:center; font-size:17px; font-weight:600; color:var(--text-secondary); }
.ld-hero-delta { display:flex; align-items:center; gap:9px; margin-top:12px; flex-wrap:wrap; }
.ld-hero-vs { font-size:11.5px; color:var(--text-muted); }
.ld-hero-story { margin:12px 0 0; font-size:14px; line-height:1.55; color:var(--text-secondary); max-width:44ch; }
.ld-hero-story b { color:var(--text); font-weight:700; }
.ld-hero-chart { position:relative; align-self:end; min-width:0; margin:0 -25px -23px 0; }

@media (max-width:860px) {
  .ld-hero { grid-template-columns:1fr; gap:14px; }
  .ld-hero-chart { margin:0 -25px -23px -25px; }
}

/* ── KPI cards ──────────────────────────────────────────────────────── */
.ld-kpis { display:grid; grid-template-columns:repeat(auto-fit, minmax(186px, 1fr)); gap:12px;
  margin-bottom:14px; }
.ld-kpis-4 { grid-template-columns:repeat(auto-fit, minmax(206px, 1fr)); }
@media (max-width:520px) { .ld-kpis, .ld-kpis-4 { grid-template-columns:repeat(2, 1fr); } }

.ld-kpi { position:relative; background:var(--ld-card); border:1px solid var(--border);
  border-radius:var(--ld-r); padding:15px 16px 16px; box-shadow:var(--ld-shadow);
  transition:transform .32s var(--ld-ease), box-shadow .32s var(--ld-ease), border-color .32s ease; }
.ld-kpi:hover, .ld-kpi:focus-within { transform:translateY(-4px); box-shadow:var(--ld-shadow-lift);
  border-color:color-mix(in srgb, var(--ld-accent) 42%, var(--border)); z-index:5; }
/* Baño de color de la esquina: `inset:0` para que nunca se salga de la card
   (así no hace falta overflow:hidden y los globos de ayuda pueden asomarse). */
.ld-kpi-wash { position:absolute; inset:0; border-radius:inherit; pointer-events:none; opacity:.6;
  background:radial-gradient(140px 140px at 100% 0%,
    color-mix(in srgb, var(--ld-accent) 30%, transparent), transparent 72%);
  transition:opacity .32s ease; }
.ld-kpi:hover .ld-kpi-wash { opacity:1; }
.ld-kpi-top { position:relative; display:flex; align-items:center; justify-content:space-between;
  margin-bottom:12px; gap:8px; }
.ld-kpi-icon { width:34px; height:34px; display:grid; place-items:center; border-radius:11px;
  background:color-mix(in srgb, var(--ld-accent) 15%, transparent); color:var(--ld-accent);
  transition:transform .4s var(--ld-spring); }
.ld-kpi:hover .ld-kpi-icon { transform:scale(1.1) rotate(-5deg); }
.ld-kpi-icon svg { width:17px; height:17px; }
.ld-kpi-value { position:relative; font-size:28px; font-weight:800; letter-spacing:-.035em; color:var(--text);
  line-height:1; font-variant-numeric:tabular-nums; }
.ld-kpi-label { position:relative; display:flex; align-items:center; font-size:12.5px; font-weight:500;
  color:var(--text-secondary); margin-top:6px; }

/* ── Delta ──────────────────────────────────────────────────────────── */
.ld-delta { display:inline-flex; align-items:center; gap:4px; font-size:11.5px; font-weight:700;
  padding:4px 9px; border-radius:999px; white-space:nowrap; line-height:1; }
.ld-delta svg { flex:0 0 auto; }
.ld-delta-up { color:#16A34A; background:color-mix(in srgb, #22C55E 15%, transparent); }
.ld-delta-down { color:#EF4444; background:color-mix(in srgb, #EF4444 15%, transparent); }
.ld-delta-new { color:#3B82F6; background:color-mix(in srgb, #3B82F6 15%, transparent); }
:root:not([data-theme="light"]) .ld-delta-up { color:#4ADE80; }

/* ── "De un vistazo" (tira de 4) ────────────────────────────────────── */
.ld-pulse { display:grid; grid-template-columns:repeat(4, 1fr); gap:12px; margin-bottom:14px; }
@media (max-width:860px) { .ld-pulse { grid-template-columns:repeat(2, 1fr); } }
@media (max-width:420px) { .ld-pulse { grid-template-columns:1fr; } }

.ld-pulse-card { position:relative; display:flex; align-items:center; gap:12px; width:100%; text-align:left;
  background:var(--ld-card); border:1px solid var(--border); border-radius:16px; padding:13px 14px;
  box-shadow:var(--ld-shadow); font:inherit; color:inherit;
  transition:transform .3s var(--ld-ease), box-shadow .3s var(--ld-ease), border-color .3s ease; }
.ld-pulse-card:hover, .ld-pulse-card:focus-within { transform:translateY(-3px);
  box-shadow:var(--ld-shadow-lift); z-index:5;
  border-color:color-mix(in srgb, var(--ld-accent) 40%, var(--border)); }
.ld-pulse-card.is-clickable { cursor:pointer; }
.ld-pulse-ic { width:38px; height:38px; flex:0 0 auto; display:grid; place-items:center; border-radius:12px;
  background:color-mix(in srgb, var(--ld-accent) 15%, transparent); color:var(--ld-accent);
  transition:transform .4s var(--ld-spring); }
.ld-pulse-card:hover .ld-pulse-ic { transform:scale(1.09) rotate(-5deg); }
.ld-pulse-ic svg { width:18px; height:18px; }
.ld-pulse-txt { display:block; min-width:0; flex:1; }
.ld-pulse-val { display:block; font-size:18px; font-weight:800; color:var(--text); letter-spacing:-.025em;
  line-height:1.15; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.ld-pulse-lbl { display:flex; align-items:center; font-size:11.5px; color:var(--text-secondary); margin-top:2px; }
.ld-pulse-go { flex:0 0 auto; color:var(--text-muted); display:grid; place-items:center;
  transition:transform .3s var(--ld-ease), color .3s ease; }
.ld-pulse-card:hover .ld-pulse-go { transform:translateX(3px); color:var(--ld-accent); }

/* ── Qué puedes hacer (acciones sugeridas) ──────────────────────────── */
.ld-tips-head { font-size:12px; font-weight:700; letter-spacing:.07em; text-transform:uppercase;
  color:var(--text-muted); margin:20px 0 10px; }
.ld-tips { display:grid; grid-template-columns:repeat(auto-fit, minmax(240px, 1fr)); gap:12px; }
.ld-tip-card { position:relative; overflow:hidden; display:flex; flex-direction:column; align-items:flex-start;
  gap:6px; text-align:left; padding:16px; border-radius:var(--ld-r); cursor:pointer; font:inherit;
  background:var(--ld-card); border:1px solid var(--border); box-shadow:var(--ld-shadow);
  transition:transform .3s var(--ld-ease), box-shadow .3s var(--ld-ease), border-color .3s ease; }
.ld-tip-card::after { content:''; position:absolute; inset:0 auto 0 0; width:3px;
  background:var(--ld-accent); opacity:.85; }
.ld-tip-card:hover { transform:translateY(-4px); box-shadow:var(--ld-shadow-lift);
  border-color:color-mix(in srgb, var(--ld-accent) 42%, var(--border)); }
.ld-tip-ic { width:34px; height:34px; display:grid; place-items:center; border-radius:11px; margin-bottom:2px;
  background:color-mix(in srgb, var(--ld-accent) 15%, transparent); color:var(--ld-accent);
  transition:transform .4s var(--ld-spring); }
.ld-tip-card:hover .ld-tip-ic { transform:scale(1.1) rotate(-5deg); }
.ld-tip-title { font-size:14px; font-weight:700; color:var(--text); line-height:1.3; }
.ld-tip-body { font-size:12.5px; color:var(--text-secondary); line-height:1.5; }
.ld-tip-cta { display:inline-flex; align-items:center; gap:3px; margin-top:4px; font-size:12.5px;
  font-weight:700; color:var(--ld-accent); }
.ld-tip-cta svg { transition:transform .3s var(--ld-ease); }
.ld-tip-card:hover .ld-tip-cta svg { transform:translateX(3px); }

/* ── Tooltip de ayuda ("?" junto a métricas con jerga) ──────────────── */
.ld-help { display:inline-grid; place-items:center; width:15px; height:15px; flex:0 0 auto;
  border-radius:50%; border:1px solid var(--border); color:var(--text-muted); font-size:10px;
  font-weight:700; cursor:help; margin-left:5px; position:relative; vertical-align:middle;
  line-height:1; user-select:none; transition:color .15s, border-color .15s, background .15s; }
.ld-help:hover, .ld-help:focus-visible { color:var(--primary); border-color:var(--primary);
  background:color-mix(in srgb, var(--primary) 10%, transparent); outline:none; }
.ld-tip { position:absolute; bottom:calc(100% + 8px); right:-2px; width:max-content; max-width:230px;
  background:var(--ld-card); color:var(--text-secondary); border:1px solid var(--border);
  border-radius:12px; padding:10px 12px; font-size:12px; font-weight:500; line-height:1.45;
  text-align:left; box-shadow:var(--shadow-lg); opacity:0; visibility:hidden; pointer-events:none;
  transform:translateY(6px) scale(.97); transform-origin:bottom right;
  transition:opacity .2s var(--ld-ease), transform .2s var(--ld-ease); z-index:60; white-space:normal; }
.ld-tip::after { content:''; position:absolute; top:100%; right:8px; border:6px solid transparent;
  border-top-color:var(--ld-card); }
.ld-help:hover .ld-tip, .ld-help:focus .ld-tip { opacity:1; visibility:visible; transform:none; }

/* ── Cards genéricas ────────────────────────────────────────────────── */
.ld-card { background:var(--ld-card); border:1px solid var(--border); border-radius:var(--ld-r);
  padding:16px 18px; margin-bottom:12px; box-shadow:var(--ld-shadow);
  transition:border-color .3s ease, box-shadow .3s var(--ld-ease); }
.ld-card:hover { border-color:color-mix(in srgb, var(--primary) 24%, var(--border));
  box-shadow:var(--ld-shadow-lift); }
.ld-card-head { display:flex; align-items:center; justify-content:space-between; margin-bottom:14px; gap:10px; }
.ld-card-head h3 { font-size:15px; font-weight:700; color:var(--text); margin:0; display:inline-flex;
  align-items:center; letter-spacing:-.01em; }
.ld-card-sub { font-size:12px; color:var(--text-muted); font-weight:500; }
.ld-grid { display:grid; grid-template-columns:1fr 1fr; gap:12px; }
@media (max-width:860px) { .ld-grid { grid-template-columns:1fr; } }
.ld-chart-foot { margin-top:10px; font-size:12px; color:var(--text-muted); text-align:right; }

/* ── Animación de entrada (escalonada por JS) ───────────────────────── */
@keyframes ldReveal { from { opacity:0; transform:translateY(14px) scale(.985); } to { opacity:1; transform:none; } }
/* `backwards`: muestra el estado inicial durante el delay y luego revierte al
   estilo base, sin persistir el transform (así el hover-lift sigue funcionando). */
.ld-reveal { animation:ldReveal .5s var(--ld-ease) backwards; }

/* ── Trazado animado de líneas ──────────────────────────────────────── */
/* El dash del trazo lo calcula el JS (animateLines): el SVG se estira con
   preserveAspectRatio="none" y el trazo no escala, así que un dasharray fijo
   en CSS dejaría la curva cortada a medias. */
@keyframes ldFade { to { opacity:1; } }
.ld-line-area { opacity:0; animation:ldFade 1s ease .3s forwards; }

@media (prefers-reduced-motion: reduce) {
  .ld-reveal, .ld-line-area, .ld-heat-cell, .ld-hero-blob, .ld-livedot { animation:none; }
  .ld-line-area { opacity:1; }
  .ld-kpi, .ld-card, .ld-pulse-card, .ld-tip-card, .ld-hero, .ld-seg-thumb { transition:none; }
  .ld-bar-col .ld-bar-fill { transition:none; }
}

/* ── Mini stats / highlights ────────────────────────────────────────── */
.ld-highlights { display:grid; grid-template-columns:repeat(2, 1fr); gap:10px; }
.ld-mini { background:var(--glass); border:1px solid var(--border); border-radius:14px; padding:13px 15px;
  border-left:3px solid var(--ld-accent); }
.ld-mini-value { font-size:20px; font-weight:800; color:var(--text); letter-spacing:-.03em; }
.ld-mini-label { font-size:11.5px; color:var(--text-secondary); margin-top:3px; }

/* ── Barras de progreso ─────────────────────────────────────────────── */
.ld-bar-track { background:var(--ld-track); border-radius:20px; overflow:hidden; height:9px; width:100%; }
.ld-bar-track-sm { height:7px; }
.ld-bar-fill { height:100%; border-radius:20px; background:var(--gradient-primary); }

/* ── Barras verticales (weekday / cohortes) ─────────────────────────── */
.ld-bars { display:flex; align-items:flex-end; gap:6px; height:164px; }
.ld-bar-col { position:relative; flex:1; display:flex; flex-direction:column; align-items:center;
  height:100%; padding-top:4px; border-radius:12px; cursor:pointer; outline:none;
  transition:background .2s ease; }
.ld-bar-col:hover, .ld-bar-col:focus-visible { background:var(--glass); }
/* Carril fantasma a altura completa: sin él las barras bajas quedan flotando
   en el vacío y no se ve contra qué máximo se comparan. */
.ld-bar-col .ld-bar-track { flex:1; width:100%; max-width:40px; display:flex; align-items:flex-end;
  background:var(--ld-track); border-radius:10px; }
.ld-bar-col .ld-bar-fill { width:100%; border-radius:10px 10px 6px 6px;
  background:linear-gradient(180deg, #A78BFA, #7C3AED);
  transition:height .75s cubic-bezier(.22,1.18,.36,1), filter .2s ease, transform .2s ease; }
.ld-bar-col .ld-bar-fill.is-peak { background:linear-gradient(180deg, var(--primary-light), var(--primary-dark));
  box-shadow:0 6px 18px -8px color-mix(in srgb, var(--primary) 90%, transparent); }
.ld-bar-col:hover .ld-bar-fill, .ld-bar-col:focus-visible .ld-bar-fill { filter:brightness(1.12); }
.ld-bar-val { font-size:12.5px; font-weight:700; color:var(--text); margin-top:8px;
  font-variant-numeric:tabular-nums; }
.ld-bar-label { font-size:11px; color:var(--text-secondary); margin-top:2px; }
.ld-bar-col.is-peak-col .ld-bar-label { color:var(--primary); font-weight:700; }
/* Globo al pasar el cursor/foco sobre la columna. */
.ld-bar-tip { position:absolute; bottom:calc(100% - 2px); left:50%; transform:translate(-50%, 5px);
  width:max-content; max-width:180px; background:var(--ld-card); color:var(--text);
  border:1px solid var(--border); border-radius:10px; padding:7px 11px; font-size:11.5px; font-weight:600;
  box-shadow:var(--shadow-lg); opacity:0; visibility:hidden; pointer-events:none; z-index:6;
  transition:opacity .2s var(--ld-ease), transform .2s var(--ld-ease); white-space:nowrap; }
.ld-bar-tip::after { content:''; position:absolute; top:100%; left:50%; transform:translateX(-50%);
  border:5px solid transparent; border-top-color:var(--ld-card); }
.ld-bar-col:hover .ld-bar-tip, .ld-bar-col:focus-visible .ld-bar-tip {
  opacity:1; visibility:visible; transform:translate(-50%, 0); }
/* Variante para pocas columnas (cohortes): centradas y con el carril visible,
   porque son porcentajes y hay que ver cuánto falta para el 100%. */
.ld-bars-few { justify-content:center; gap:22px; }
.ld-bars-few .ld-bar-col { flex:0 1 104px; }
.ld-bars-few .ld-bar-track { background:var(--ld-track); max-width:52px; }

/* ── Valor del cliente (3 cards en una fila) ────────────────────────── */
.ld-value-cards { display:grid; grid-template-columns:repeat(3, 1fr); gap:10px; }
@media (max-width:520px) { .ld-value-cards { grid-template-columns:1fr; } }
.ld-vstat { display:flex; align-items:center; gap:12px; background:var(--glass);
  border:1px solid var(--border); border-radius:14px; padding:13px 14px;
  border-left:3px solid var(--ld-accent);
  transition:transform .3s var(--ld-ease), border-color .3s ease; }
.ld-vstat:hover { transform:translateY(-3px);
  border-color:color-mix(in srgb, var(--ld-accent) 45%, var(--border)); }
.ld-vstat-ic { width:38px; height:38px; flex:0 0 auto; display:grid; place-items:center; border-radius:12px;
  background:color-mix(in srgb, var(--ld-accent) 15%, transparent); color:var(--ld-accent); }
.ld-vstat-ic svg { width:19px; height:19px; }
.ld-vstat-val { font-size:20px; font-weight:800; color:var(--text); letter-spacing:-.03em; line-height:1.05;
  font-variant-numeric:tabular-nums; }
.ld-vstat-lbl { font-size:11.5px; color:var(--text-secondary); margin-top:3px; }

/* ── Donut ──────────────────────────────────────────────────────────── */
.ld-donut-wrap { display:flex; align-items:center; gap:20px; flex-wrap:wrap; }
.ld-donut { position:relative; width:160px; height:160px; flex:0 0 auto; }
.ld-donut-center { position:absolute; inset:0; display:flex; flex-direction:column;
  align-items:center; justify-content:center; pointer-events:none; }
.ld-donut-big { font-size:25px; font-weight:800; color:var(--text); letter-spacing:-.035em;
  transition:color .2s ease; }
.ld-donut-small { font-size:11px; color:var(--text-secondary); margin-top:2px; text-align:center; }
/* Hover por segmento: resalta el activo, atenúa el resto. */
.ld-arc[data-label] { cursor:pointer; transition:opacity .2s ease, stroke-width .2s var(--ld-spring); }
.ld-donut.is-hover .ld-arc[data-label]:not(.is-active) { opacity:.28; }
.ld-arc.is-active { stroke-width:18; }
.ld-donut-legend { flex:1; min-width:170px; display:flex; flex-direction:column; gap:9px; }
.ld-legend-row { display:flex; align-items:center; gap:9px; font-size:13px; padding:3px 0; }
.ld-dot { width:11px; height:11px; border-radius:4px; flex:0 0 auto; }
.ld-legend-label { color:var(--text-secondary); flex:1; }
.ld-legend-val { color:var(--text); font-weight:700; font-variant-numeric:tabular-nums; }

/* ── Line chart ─────────────────────────────────────────────────────── */
.ld-line-wrap { width:100%; }
.ld-line-plot { position:relative; cursor:crosshair; touch-action:none; }
.ld-line { display:block; width:100%; }
.ld-line-x { display:flex; justify-content:space-between; margin-top:8px; padding:0 2px; }
.ld-line-x span { font-size:11px; color:var(--text-muted); white-space:nowrap; font-variant-numeric:tabular-nums; }

/* Crosshair interactivo: línea guía, punto y globo que siguen al cursor. */
.ld-line-vline { position:absolute; top:0; bottom:0; width:1px; transform:translateX(-.5px);
  background:linear-gradient(180deg, color-mix(in srgb, var(--ld-line, #3B82F6) 55%, transparent), transparent);
  pointer-events:none; }
.ld-line-dot { position:absolute; width:11px; height:11px; border-radius:50%;
  background:var(--ld-line, #3B82F6); border:2.5px solid var(--ld-card);
  transform:translate(-50%, -50%); pointer-events:none;
  box-shadow:0 0 0 4px rgba(var(--ld-line-rgb, 59,130,246), .2); }
.ld-line-tip { position:absolute; top:-2px; transform:translate(-50%, -100%); pointer-events:none;
  background:var(--ld-card); border:1px solid var(--border); border-radius:10px; padding:6px 10px;
  box-shadow:var(--shadow-lg); text-align:center; white-space:nowrap; z-index:5; }
.ld-line-tip-v { display:block; font-size:14px; font-weight:800; color:var(--text); line-height:1.1;
  font-variant-numeric:tabular-nums; }
.ld-line-tip-d { display:block; font-size:10.5px; color:var(--text-muted); margin-top:1px; }
/* Variante "flush": la gráfica se pega al borde de la card (hero). */
.ld-line-wrap.is-flush .ld-line-tip { top:8px; transform:translate(-50%, 0); }

/* ── Heatmap ────────────────────────────────────────────────────────── */
.ld-heat { position:relative; font-size:0; }
.ld-heat-cols, .ld-heat-row { display:flex; align-items:center; gap:3px; margin-bottom:3px; }
.ld-heat-rl { width:32px; flex:0 0 32px; font-size:10.5px; color:var(--text-secondary); font-weight:600; }
@keyframes ldCell { from { opacity:0; transform:scale(.35); } to { opacity:1; transform:none; } }
.ld-heat-cell { flex:1; aspect-ratio:1; min-width:0; border-radius:4px; cursor:pointer;
  animation:ldCell .45s var(--ld-ease) backwards; animation-delay:calc(var(--i) * 2.6ms);
  transition:transform .15s var(--ld-spring), box-shadow .15s ease; }
.ld-heat-cell.has-v:hover { transform:scale(1.45); position:relative; z-index:3;
  box-shadow:0 0 0 2px var(--primary), 0 6px 14px -6px rgba(0,0,0,.5); }
.ld-heat-col-lbl { flex:1; font-size:9px; color:var(--text-muted); text-align:left; }
.ld-heat-legend { display:flex; align-items:center; gap:9px; margin-top:12px; font-size:11px;
  color:var(--text-secondary); }
.ld-heat-grad { flex:1; max-width:150px; height:8px; border-radius:8px;
  background:linear-gradient(90deg, var(--glass), rgba(249,115,22,1)); }
.ld-heat-tip { position:absolute; transform:translate(-50%, calc(-100% - 8px)); pointer-events:none;
  background:var(--ld-card); border:1px solid var(--border); border-radius:9px; padding:6px 10px;
  font-size:11.5px; font-weight:600; color:var(--text); white-space:nowrap; z-index:8;
  box-shadow:var(--shadow-lg); }

/* ── Podio de mejores clientes ──────────────────────────────────────── */
.ld-podium { display:grid; grid-template-columns:1fr 1.16fr 1fr; gap:10px; align-items:end;
  margin-bottom:6px; }
@media (max-width:560px) { .ld-podium { grid-template-columns:1fr; } }
.ld-pod { position:relative; overflow:hidden; display:flex; flex-direction:column; align-items:center;
  text-align:center; gap:3px; padding:14px 10px 14px; border-radius:16px;
  background:var(--glass); border:1px solid var(--border);
  transition:transform .3s var(--ld-ease), border-color .3s ease; }
.ld-pod:hover { transform:translateY(-3px); }
.ld-pod-1 { padding-top:20px; padding-bottom:18px;
  background:linear-gradient(180deg, color-mix(in srgb, #F59E0B 16%, transparent), transparent 70%);
  border-color:color-mix(in srgb, #F59E0B 38%, var(--border)); }
.ld-pod-medal { font-size:18px; line-height:1; }
.ld-pod-1 .ld-pod-medal { font-size:24px; }
.ld-pod-av { display:block; margin:4px 0 4px; }
.ld-pod .ld-avatar { width:48px; height:48px; }
.ld-pod-1 .ld-avatar { width:60px; height:60px;
  box-shadow:0 0 0 3px color-mix(in srgb, #F59E0B 45%, transparent); }
.ld-pod-name { font-size:13px; font-weight:700; color:var(--text); max-width:100%;
  white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.ld-pod-pts { font-size:15px; font-weight:800; color:var(--primary); letter-spacing:-.02em; }
.ld-pod-1 .ld-pod-pts { font-size:17px; }
.ld-pod-sub { font-size:11px; color:var(--text-muted); }
.ld-pod-step { position:absolute; left:0; right:0; bottom:0; height:3px;
  background:linear-gradient(90deg, transparent, var(--text-muted), transparent); opacity:.35; }
.ld-pod-1 .ld-pod-step { height:4px; opacity:.9;
  background:linear-gradient(90deg, transparent, #F59E0B, transparent); }

/* ── Personas (churn / top customers) ───────────────────────────────── */
.ld-toplist { display:flex; flex-direction:column; margin-top:8px; }
.ld-person { display:flex; align-items:center; gap:11px; padding:10px 8px; border-radius:12px;
  transition:background .2s ease; }
.ld-person:hover { background:var(--glass); }
.ld-person + .ld-person { border-top:1px solid var(--border); }
.ld-avatar { width:38px; height:38px; border-radius:50%; object-fit:cover; flex:0 0 auto;
  background:var(--glass-strong); }
.ld-avatar-fb { display:grid; place-items:center; font-weight:700; font-size:15px;
  color:var(--primary-dark);
  background:linear-gradient(135deg, color-mix(in srgb, var(--primary) 24%, transparent),
    color-mix(in srgb, #8B5CF6 22%, transparent)); }
:root:not([data-theme="light"]) .ld-avatar-fb { color:var(--primary-light); }
.ld-person-info { flex:1; min-width:0; }
.ld-person-name { font-size:13.5px; font-weight:600; color:var(--text); white-space:nowrap;
  overflow:hidden; text-overflow:ellipsis; }
.ld-person-sub { font-size:11.5px; color:var(--text-muted); margin-top:2px; }
.ld-person-chips { display:flex; gap:10px; font-size:11.5px; color:var(--text-secondary); margin-top:3px; }
.ld-person-last { font-size:11px; color:var(--text-muted); white-space:nowrap; }
.ld-rank { width:24px; height:24px; flex:0 0 auto; display:grid; place-items:center; border-radius:8px;
  font-size:12px; font-weight:800; background:var(--glass-strong); color:var(--text-secondary); }
.ld-rank-1 { background:linear-gradient(135deg, #FFD700, #FBBF24); color:#3b2f00; }
.ld-badge { font-size:11px; font-weight:700; padding:4px 9px; border-radius:999px; white-space:nowrap; }
.ld-badge-danger { color:#EF4444; background:color-mix(in srgb, #EF4444 14%, transparent); }

/* ── Recompensas / dispositivos ─────────────────────────────────────── */
.ld-reward, .ld-device { display:flex; align-items:center; gap:12px; padding:11px 0;
  border-bottom:1px solid var(--border); }
.ld-reward:last-child, .ld-device:last-child { border-bottom:none; }
.ld-reward-img { width:44px; height:44px; border-radius:12px; object-fit:cover; flex:0 0 auto;
  background:var(--glass-strong); }
.ld-reward-img-fb { display:grid; place-items:center; color:var(--text-secondary); }
.ld-reward-info, .ld-device-info { flex:1; min-width:0; }
.ld-reward-top, .ld-device-top { display:flex; justify-content:space-between; align-items:baseline;
  margin-bottom:6px; gap:10px; }
.ld-reward-name, .ld-device-name { font-size:13.5px; font-weight:600; color:var(--text);
  white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.ld-reward-count, .ld-device-count { font-size:14px; font-weight:800; color:var(--primary); flex:0 0 auto; }
.ld-reward-sub, .ld-device-sub { font-size:11.5px; color:var(--text-muted); margin-top:5px; }

/* ── Insight (interpretación de la economía del programa) ───────────── */
.ld-insight { display:flex; gap:13px; align-items:flex-start; border:1px solid var(--border);
  border-left-width:3px; border-radius:var(--ld-r); padding:15px 17px; margin-bottom:14px;
  background:var(--ld-card); box-shadow:var(--ld-shadow); }
.ld-insight-icon { width:34px; height:34px; flex:0 0 auto; display:grid; place-items:center;
  border-radius:11px; }
.ld-insight-title { font-size:14px; font-weight:700; color:var(--text); margin-bottom:4px; }
.ld-insight-body { font-size:13px; color:var(--text-secondary); line-height:1.55; }
.ld-insight-body b { color:var(--text); font-weight:700; }
.ld-insight-foot { font-size:12px; color:var(--text-muted); line-height:1.5; margin-top:10px;
  padding-top:10px; border-top:1px solid var(--border); }
.ld-insight-foot b { color:var(--text-secondary); }
.ld-insight-warn { border-left-color:#EF4444; }
.ld-insight-warn .ld-insight-icon { background:color-mix(in srgb, #EF4444 14%, transparent); color:#EF4444; }
.ld-insight-info { border-left-color:#3B82F6; }
.ld-insight-info .ld-insight-icon { background:color-mix(in srgb, #3B82F6 14%, transparent); color:#3B82F6; }
.ld-insight-ok { border-left-color:#22C55E; }
.ld-insight-ok .ld-insight-icon { background:color-mix(in srgb, #22C55E 14%, transparent); color:#22C55E; }

/* ── Estados ────────────────────────────────────────────────────────── */
.ld-empty { text-align:center; padding:52px 20px; color:var(--text-secondary); }
.ld-empty-icon { width:60px; height:60px; margin:0 auto 16px; display:grid; place-items:center;
  border-radius:18px; background:var(--glass); color:var(--primary); }
.ld-empty-icon svg { width:28px; height:28px; }
.ld-empty h3 { font-size:17px; color:var(--text); margin:0 0 6px; }
.ld-empty p { font-size:13.5px; margin:0; max-width:340px; margin-inline:auto; }
.ld-empty-mini { text-align:center; padding:26px; color:var(--text-muted); font-size:13px; }
.ld-boot > .skeleton:first-child { margin-bottom:14px; }
