/* [Pulso-Supabase] 📺 Modo TV 2 — pantalla de oficina con la esencia de Pulso (oscuro, degradado rosa→violeta, línea de pulso).
   Pensado para 16:9 (1366×768 a 4K): todo cabe en una pantalla sin desplazarse. En pantallas angostas se apila y desplaza. */
#cf-tv.tv2 {
  --tv-bg: #06070f; --tv-card: rgba(22, 20, 40, .72); --tv-borde: rgba(168, 85, 247, .18); --tv-t1: #f5f3ff; --tv-t2: #a5a1c2; --tv-t3: #6f6a8f;
  --tv-rosa: #f43f5e; --tv-violeta: #a855f7; --tv-verde: #34d399; --tv-ambar: #fbbf24; --tv-rojo: #fb7185;
  --tv-marca: linear-gradient(135deg, #f43f5e, #a855f7); --gap: clamp(10px, 1.3vw, 22px);
  position: fixed; inset: 0; z-index: 300; overflow: hidden; padding: clamp(14px, 2vw, 34px);
  display: grid; grid-template-rows: auto minmax(0, 1.12fr) minmax(0, 1fr) auto; gap: var(--gap); align-content: stretch;
  color: var(--tv-t1); font-variant-numeric: tabular-nums; color-scheme: dark;
  background: radial-gradient(ellipse 60% 50% at 10% -10%, rgba(244, 63, 94, .18), transparent 70%),
              radial-gradient(ellipse 60% 60% at 105% 110%, rgba(168, 85, 247, .22), transparent 70%), var(--tv-bg);
}
#cf-tv.tv2[hidden] { display: none !important; }
#cf-tv.tv2 > * { position: relative; z-index: 1; min-height: 0; min-width: 0; }
#cf-tv.tv2 .tv2-ecg { position: absolute; z-index: 0; left: 0; right: 0; top: clamp(30px, 5vh, 60px); width: 100%; height: 9vh; opacity: .35; pointer-events: none; }
#cf-tv.tv2 .tv2-ecg path { fill: none; stroke: #e879f9; stroke-width: 2; stroke-linejoin: round; stroke-dasharray: 1400; stroke-dashoffset: 1400; filter: drop-shadow(0 0 6px rgba(232, 121, 249, .8)); animation: tv2-ecg 5s linear infinite; }
@keyframes tv2-ecg { to { stroke-dashoffset: -1400; } }

/* encabezado */
#cf-tv .tv2-top { display: flex; align-items: center; gap: var(--gap); }
#cf-tv .tv2-marca { display: flex; align-items: center; gap: 14px; flex: 1; min-width: 0; }
#cf-tv .tv2-logo { width: clamp(40px, 3.6vw, 64px); aspect-ratio: 1; border-radius: 28%; background: var(--tv-marca); display: grid; place-items: center; box-shadow: 0 10px 30px -10px rgba(244, 63, 94, .7); flex: none; }
#cf-tv .tv2-logo svg { width: 62%; fill: none; stroke: #fff; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
#cf-tv .tv2-marca b { display: block; font-size: clamp(22px, 2vw, 38px); font-weight: 900; letter-spacing: -.02em; line-height: 1; background: var(--tv-marca); -webkit-background-clip: text; background-clip: text; color: transparent; }
#cf-tv .tv2-marca em { display: block; font-style: normal; font-size: clamp(11px, .85vw, 15px); color: var(--tv-t2); letter-spacing: .04em; margin-top: 3px; }
#cf-tv .tv2-vivo { display: inline-flex; align-items: center; gap: 8px; margin-left: 10px; padding: 6px 14px; border-radius: 99px; font-size: clamp(11px, .8vw, 14px); font-weight: 800; letter-spacing: .14em; color: #fecdd3; background: rgba(244, 63, 94, .12); border: 1px solid rgba(244, 63, 94, .35); }
#cf-tv .tv2-vivo i { width: 9px; height: 9px; border-radius: 50%; background: var(--tv-rosa); box-shadow: 0 0 0 0 rgba(244, 63, 94, .7); animation: tv2-late 1.6s ease-out infinite; }
@keyframes tv2-late { 70% { box-shadow: 0 0 0 10px rgba(244, 63, 94, 0); } 100% { box-shadow: 0 0 0 0 rgba(244, 63, 94, 0); } }
#cf-tv .tv2-hora { text-align: right; line-height: 1; }
#cf-tv .tv2-hora b { display: block; font-size: clamp(30px, 3.4vw, 64px); font-weight: 800; letter-spacing: -.03em; }
#cf-tv .tv2-hora span { display: block; margin-top: 4px; font-size: clamp(11px, .85vw, 15px); color: var(--tv-t2); text-transform: capitalize; }
#cf-tv .tv2-x { width: 44px; height: 44px; flex: none; border-radius: 50%; border: 1px solid var(--tv-borde); background: rgba(255, 255, 255, .04); color: var(--tv-t2); font-size: 18px; cursor: pointer; opacity: .45; transition: opacity .2s; }
#cf-tv .tv2-x:hover, #cf-tv .tv2-x:focus-visible { opacity: 1; color: #fff; }

/* tarjetas */
#cf-tv .tv2-card { background: var(--tv-card); border: 1px solid var(--tv-borde); border-radius: clamp(16px, 1.4vw, 26px); padding: clamp(14px, 1.4vw, 28px); -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px); min-height: 0; min-width: 0; overflow: hidden; display: flex; flex-direction: column; }
#cf-tv .tv2-lbl { font-size: clamp(11px, .85vw, 16px); font-weight: 800; letter-spacing: .12em; text-transform: uppercase; color: var(--tv-t2); }
#cf-tv h3 { margin: 0 0 clamp(8px, 1vh, 16px); font-size: clamp(14px, 1.15vw, 22px); font-weight: 800; display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
#cf-tv h3 small { font-size: .7em; font-weight: 600; color: var(--tv-t3); }

/* fila principal */
#cf-tv .tv2-hero { display: grid; grid-template-columns: 1.25fr .85fr 1.6fr; gap: var(--gap); min-height: 0; }
#cf-tv .tv2-ventas { justify-content: center; position: relative; background: linear-gradient(160deg, rgba(244, 63, 94, .16), rgba(168, 85, 247, .12) 60%, var(--tv-card)); border-color: rgba(244, 63, 94, .3); }
#cf-tv .tv2-big { display: inline-block; align-self: flex-start; font-size: clamp(80px, 11vw, 230px); font-weight: 900; letter-spacing: -.05em; line-height: .95; margin: .04em 0 .06em; background: linear-gradient(180deg, #fff 30%, #f5d0fe); -webkit-background-clip: text; background-clip: text; color: transparent; }
#cf-tv .tv2-sub { display: flex; gap: 18px; flex-wrap: wrap; font-size: clamp(13px, 1.05vw, 20px); color: var(--tv-t2); }
#cf-tv .tv2-sub b { color: var(--tv-t1); }
#cf-tv .tv2-chip { align-self: flex-start; margin-top: clamp(8px, 1.2vh, 16px); padding: 6px 14px; border-radius: 99px; font-size: clamp(12px, .95vw, 18px); font-weight: 800; }
#cf-tv .tv2-chip.up { color: #a7f3d0; background: rgba(52, 211, 153, .12); border: 1px solid rgba(52, 211, 153, .35); }
#cf-tv .tv2-chip.down { color: #fecdd3; background: rgba(251, 113, 133, .1); border: 1px solid rgba(251, 113, 133, .3); }
#cf-tv .tv2-ventas.tv2-late { animation: tv2-golpe .9s ease-out; }
@keyframes tv2-golpe { 0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(244, 63, 94, .6); } 30% { transform: scale(1.025); } 100% { transform: scale(1); box-shadow: 0 0 0 40px rgba(244, 63, 94, 0); } }

#cf-tv .tv2-meta { align-items: center; justify-content: center; text-align: center; gap: 6px; }
#cf-tv .tv2-anillo { position: relative; width: min(100%, 24vh); aspect-ratio: 1; margin: auto 0; }
#cf-tv .tv2-anillo svg { width: 100%; height: 100%; transform: rotate(-90deg); }
#cf-tv .tv2-anillo circle { fill: none; stroke: rgba(255, 255, 255, .07); stroke-width: 11; }
#cf-tv .tv2-anillo circle.v { stroke: url(#tv2g); stroke-linecap: round; transition: stroke-dashoffset 1s ease; filter: drop-shadow(0 0 8px rgba(168, 85, 247, .6)); }
#cf-tv .tv2-anillo.ok circle.v { stroke: var(--tv-verde); filter: drop-shadow(0 0 10px rgba(52, 211, 153, .7)); }
#cf-tv .tv2-anillo > div { position: absolute; inset: 0; display: grid; place-content: center; }
#cf-tv .tv2-anillo b { font-size: clamp(26px, 3vw, 60px); font-weight: 900; letter-spacing: -.03em; line-height: 1; }
#cf-tv .tv2-anillo span { font-size: clamp(11px, .9vw, 16px); color: var(--tv-t2); margin-top: 4px; }
#cf-tv .tv2-meta-txt { margin: 0; font-size: clamp(13px, 1.05vw, 20px); color: var(--tv-t2); }
#cf-tv .tv2-meta-txt b { color: var(--tv-t1); }
#cf-tv .tv2-sinmeta { margin: auto 0; display: grid; gap: 10px; justify-items: center; }
#cf-tv .tv2-sinmeta b { font-size: clamp(36px, 4vw, 70px); }
#cf-tv .tv2-sinmeta p { margin: 0; max-width: 26ch; font-size: clamp(12px, .95vw, 17px); color: var(--tv-t2); line-height: 1.4; }

#cf-tv .tv2-kpis { display: grid; grid-template-columns: 1fr 1fr; grid-template-rows: 1fr 1fr; gap: var(--gap); min-height: 0; }
#cf-tv .tv2-k { justify-content: center; gap: 4px; position: relative; }
#cf-tv .tv2-k::before { content: ''; position: absolute; left: 0; top: 18%; bottom: 18%; width: 4px; border-radius: 0 4px 4px 0; background: var(--tv-violeta); }
#cf-tv .tv2-k.k-fact::before { background: var(--tv-ambar); } #cf-tv .tv2-k.k-gan::before { background: var(--tv-verde); }
#cf-tv .tv2-k.k-ok::before { background: var(--tv-verde); } #cf-tv .tv2-k.k-med::before { background: var(--tv-ambar); } #cf-tv .tv2-k.k-mal::before { background: var(--tv-rojo); } #cf-tv .tv2-k.k-tomar::before { background: var(--tv-rosa); }
#cf-tv .tv2-k b { display: inline-block; align-self: flex-start; font-size: clamp(26px, 3vw, 62px); font-weight: 900; letter-spacing: -.03em; line-height: 1.05; white-space: nowrap; }
#cf-tv .tv2-k.k-gan b { color: #6ee7b7; } #cf-tv .tv2-k.k-fact b { color: #fde68a; }
#cf-tv .tv2-k small { font-size: clamp(11px, .9vw, 17px); color: var(--tv-t2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#cf-tv .tv2-k em { font-style: normal; font-weight: 800; } #cf-tv .tv2-k em.rojo { color: var(--tv-rojo); } #cf-tv .tv2-k em.ok { color: var(--tv-verde); }

/* fila de abajo */
#cf-tv .tv2-abajo { display: grid; grid-template-columns: 1.45fr 1fr 1fr; gap: var(--gap); min-height: 0; }
#cf-tv .tv2-graf { flex: 1; min-height: 0; display: flex; flex-direction: column; }
#cf-tv .tv2-graf svg { flex: 1; width: 100%; min-height: 0; overflow: visible; }
#cf-tv .tv2-graf .gl { stroke: rgba(255, 255, 255, .06); stroke-width: 1; }
#cf-tv .tv2-graf .gt { fill: var(--tv-t3); font-size: 11px; }
#cf-tv .tv2-graf rect.b { fill: rgba(168, 85, 247, .55); }
#cf-tv .tv2-graf rect.b.act { fill: url(#tv2g); filter: drop-shadow(0 0 8px rgba(244, 63, 94, .6)); }
#cf-tv .tv2-graf .bv { fill: var(--tv-t1); font-size: 13px; font-weight: 800; text-anchor: middle; }
#cf-tv .tv2-graf .hx { fill: var(--tv-t3); font-size: 12px; text-anchor: middle; } #cf-tv .tv2-graf .hx.act { fill: #fda4af; font-weight: 800; }
#cf-tv .tv2-graf .ay { fill: none; stroke: #fbbf24; stroke-width: 2.5; stroke-dasharray: 6 5; stroke-linejoin: round; opacity: .85; }
#cf-tv .tv2-ley { display: flex; gap: 18px; margin-top: 6px; font-size: clamp(11px, .85vw, 15px); color: var(--tv-t2); }
#cf-tv .tv2-ley i { display: inline-block; width: 14px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: 0; }
#cf-tv .tv2-ley i.b { background: var(--tv-marca); } #cf-tv .tv2-ley i.ay { height: 0; border-top: 3px dashed #fbbf24; border-radius: 0; vertical-align: 3px; }

#cf-tv .tv2-rk, #cf-tv .tv2-fd { list-style: none; margin: 0; padding: 0; display: grid; gap: clamp(6px, .9vh, 12px); }
#cf-tv .tv2-rk li { display: grid; grid-template-columns: 2.2em auto 1fr auto; align-items: center; gap: 12px; font-size: clamp(13px, 1.05vw, 20px); }
#cf-tv .tv2-rk .pos { font-size: 1.2em; text-align: center; font-weight: 900; color: var(--tv-t3); }
#cf-tv .av { width: 2.1em; height: 2.1em; border-radius: 50%; display: grid; place-items: center; font-size: .8em; font-weight: 900; color: #fff; flex: none; background: linear-gradient(135deg, hsl(var(--h) 75% 55%), hsl(calc(var(--h) + 40) 70% 45%)); }
#cf-tv .tv2-rk .nm { min-width: 0; display: grid; gap: 5px; }
#cf-tv .tv2-rk .nm b { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#cf-tv .tv2-rk .nm i { display: block; height: 6px; width: var(--w); border-radius: 99px; background: rgba(168, 85, 247, .5); transition: width .8s ease; }
#cf-tv .tv2-rk .p1 .nm i { background: var(--tv-marca); box-shadow: 0 0 10px rgba(244, 63, 94, .5); }
#cf-tv .tv2-rk .vl { text-align: right; line-height: 1.1; } #cf-tv .tv2-rk .vl b { font-size: 1.35em; font-weight: 900; } #cf-tv .tv2-rk .vl small { display: block; font-size: .7em; color: var(--tv-t2); }

#cf-tv .tv2-fd li { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 12px; padding: clamp(6px, .8vh, 10px) 10px; border-radius: 14px; font-size: clamp(12px, .95vw, 18px); background: rgba(255, 255, 255, .025); }
#cf-tv .tv2-fd li > div { min-width: 0; } #cf-tv .tv2-fd b { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 700; }
#cf-tv .tv2-fd small { display: block; color: var(--tv-t2); font-size: .8em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#cf-tv .tv2-fd em { font-style: normal; font-weight: 900; color: #6ee7b7; }
#cf-tv .tv2-fd li.nueva { background: linear-gradient(90deg, rgba(244, 63, 94, .18), rgba(168, 85, 247, .08)); box-shadow: inset 0 0 0 1px rgba(244, 63, 94, .35); animation: tv2-entra .6s ease-out; }
@keyframes tv2-entra { from { transform: translateY(-10px); opacity: 0; } }
#cf-tv .tv2-vacio { margin: auto 0; color: var(--tv-t3); font-size: clamp(13px, 1vw, 18px); line-height: 1.5; text-align: center; padding: 10px; }

/* pie */
#cf-tv .tv2-pie { display: flex; gap: clamp(14px, 2.4vw, 46px); align-items: center; flex-wrap: wrap; font-size: clamp(12px, .95vw, 18px); color: var(--tv-t2); padding: 0 4px; }
#cf-tv .tv2-pie b { color: var(--tv-t1); margin-left: 6px; }
#cf-tv .tv2-pie .tv2-act { margin-left: auto; color: var(--tv-t3); font-size: .85em; }

/* aviso de venta nueva */
#cf-tv .tv2-aviso { position: absolute; z-index: 5; left: 50%; top: clamp(16px, 2.4vw, 36px); transform: translateX(-50%); padding: clamp(10px, 1.2vw, 18px) clamp(18px, 2vw, 36px); border-radius: 99px; background: var(--tv-marca); color: #fff; font-size: clamp(16px, 1.6vw, 30px); font-weight: 700; box-shadow: 0 20px 50px -12px rgba(244, 63, 94, .8); white-space: nowrap; max-width: 90vw; overflow: hidden; text-overflow: ellipsis; }
#cf-tv .tv2-aviso.on { animation: tv2-aviso 7s ease forwards; }
@keyframes tv2-aviso { 0% { opacity: 0; transform: translate(-50%, -30px) scale(.9); } 8%, 88% { opacity: 1; transform: translate(-50%, 0) scale(1); } 100% { opacity: 0; transform: translate(-50%, -20px); } }

@media (prefers-reduced-motion: reduce) { #cf-tv.tv2 *, #cf-tv.tv2 *::before { animation: none !important; transition: none !important; } #cf-tv .tv2-aviso.on { opacity: 1; } }

/* pantallas angostas o verticales: se apila y se puede desplazar */
@media (max-width: 1000px), (max-aspect-ratio: 1/1) {
  #cf-tv.tv2 { overflow-y: auto; grid-template-rows: none; align-content: start; }
  #cf-tv .tv2-hero, #cf-tv .tv2-abajo { grid-template-columns: 1fr; }
  #cf-tv .tv2-hero { grid-template-columns: 1fr 1fr; } #cf-tv .tv2-ventas { grid-column: 1 / -1; } #cf-tv .tv2-kpis { grid-column: 1 / -1; }
  #cf-tv .tv2-graf svg { height: 220px; flex: none; }
  #cf-tv .tv2-anillo { width: min(100%, 180px); }
  #cf-tv .tv2-vivo { display: none; }
}
@media (max-width: 560px) { #cf-tv .tv2-hero { grid-template-columns: 1fr; } #cf-tv .tv2-marca em { display: none; } }
/* las listas reparten el alto disponible: siempre caben 5 filas sin cortarse */
#cf-tv .tv2-lista { flex: 1; min-height: 0; display: flex; flex-direction: column; }
#cf-tv .tv2-lista > ol, #cf-tv .tv2-lista > ul { flex: 1; min-height: 0; grid-template-rows: repeat(var(--n), minmax(0, 1fr)); align-content: stretch; }
#cf-tv .tv2-rk li, #cf-tv .tv2-fd li { min-height: 0; }
#cf-tv .tv2-hora span { text-transform: none; }
#cf-tv .tv2-hora span::first-letter { text-transform: uppercase; }
html:has(#cf-tv.tv2:not([hidden])) { overflow: hidden; }
@media (max-width: 1000px), (max-aspect-ratio: 1/1) {
  #cf-tv.tv2 > *, #cf-tv .tv2-card, #cf-tv .tv2-kpis, #cf-tv .tv2-hero, #cf-tv .tv2-abajo { min-height: auto; }
  #cf-tv .tv2-kpis { grid-template-rows: none; }
  #cf-tv .tv2-lista > ol, #cf-tv .tv2-lista > ul { grid-template-rows: none; }
  #cf-tv .tv2-rk li, #cf-tv .tv2-fd li { min-height: auto; }
  #cf-tv .tv2-hora b { font-size: 30px; }
}
