/* Página: Tableau (para empresas). Identidad propia: arrastrar a los estantes.
   Píldoras azules para dimensiones, verdes para métricas, naranja de acento y paleta divergente. */
.c-tableau { --tb-dim: #4e79a7; --tb-mea: #3f8f3a; --tb-or: #c25e0c; --tb-orb: #f28e2b; --tb-r2: #d9622b; --tb-r1: #f2a65e; --tb-g1: #86aed6; --tb-g2: #3f6fa0; --mono: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace; }
:root[data-theme="dark"] .c-tableau { --tb-or: #f6a35a; --tb-dim: #5b8cc0; --tb-mea: #4fa748; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .c-tableau { --tb-or: #f6a35a; --tb-dim: #5b8cc0; --tb-mea: #4fa748; } }

.c-tableau .c-hero h1 { font-size: clamp(2.2rem, 1.3rem + 2.9vw, 3.6rem); max-width: 17ch; }
.c-tableau h1 em, .c-tableau h2 em { color: var(--tb-or); }
.c-solo-emp { display: inline-flex; align-items: center; gap: 8px; margin: 0; padding: 5px 12px 5px 6px; border-radius: 6px; font-size: .8rem; font-weight: 600; color: var(--ink); background: var(--surface); border: 1px solid var(--line); }
.c-solo-emp::before { content: "Abc"; padding: 1px 6px; border-radius: 4px; font-size: .66rem; color: #fff; background: var(--tb-dim); }

/* Numeración como píldora de dimensión */
.c-tableau .cs-step-n { justify-self: start; padding: 3px 12px; border-radius: 999px; background: var(--tb-dim); color: #fff; font-size: .76rem; }
.c-tableau .cs-step.on .cs-step-n { background: var(--tb-mea); }

/* Píldoras y estantes */
.tb-pill { display: inline-flex; align-items: center; padding: 4px 12px; border-radius: 999px; font-size: .74rem; font-weight: 600; color: #fff; white-space: nowrap; box-shadow: 0 2px 6px -2px rgba(0, 0, 0, .3); }
.tb-pill.dim { background: var(--tb-dim); } .tb-pill.mea { background: var(--tb-mea); }
.tb-pill.calc { background: var(--tb-mea); outline: 2px dashed color-mix(in srgb, var(--tb-mea) 60%, transparent); outline-offset: 2px; }
.tb-row { display: grid; grid-template-columns: 74px 1fr; align-items: center; gap: 8px; }
.tb-lab { font-size: .72rem; font-weight: 600; color: var(--muted); }
.tb-slot { display: flex; min-height: 30px; align-items: center; padding: 3px 6px; border-radius: 8px; background: var(--bg); border: 1px solid var(--line); }

/* ---------- Portada ---------- */
.tb-shelf { position: absolute; left: -26px; bottom: -30px; width: min(76%, 330px); display: grid; gap: 7px; padding: 12px; border-radius: 14px; background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow); animation: c-in .8s .5s cubic-bezier(.2, .8, .2, 1) both; }
.tb-fly { animation: tb-fly 6s 1.2s ease-in-out infinite; }
@keyframes tb-fly { 0% { transform: translate(-40px, -70px) rotate(-6deg); opacity: 0; } 12% { opacity: 1; } 30%, 88% { transform: none; opacity: 1; } 100% { transform: none; opacity: 0; } }
.tb-minibars { display: flex; align-items: flex-end; gap: 10px; height: 56px; margin-top: 4px; padding: 0 6px; border-bottom: 1px solid var(--line); }
.tb-minibars i { flex: 1; height: var(--h); border-radius: 3px 3px 0 0; background: var(--tb-dim); transform-origin: bottom; animation: tb-grow 6s 1.2s ease-in-out infinite; }
.tb-minibars i:nth-child(2) { animation-delay: 1.3s; } .tb-minibars i:nth-child(3) { animation-delay: 1.4s; } .tb-minibars i:nth-child(4) { animation-delay: 1.5s; }
@keyframes tb-grow { 0%, 24% { transform: scaleY(.04); } 40%, 92% { transform: none; } 100% { transform: scaleY(.04); } }

/* ---------- Historia ---------- */
.tb-stage { font-size: .86rem; }
.c-tableau .s1 { background: none; }
.c-tableau .s2, .c-tableau .s4 { display: block; }
.c-tableau .s5 { padding: 7%; }

/* Escena 1: tabla cruzada */
.tb-xt { border-radius: 10px; overflow: hidden; border: 1px solid var(--line); background: var(--bg); font-family: var(--mono); font-size: .72rem; color: var(--muted); }
.tb-xt > div { display: grid; grid-template-columns: 1.1fr repeat(5, 1fr); border-top: 1px solid var(--line); }
.tb-xt > .h { border-top: 0; color: var(--ink); font-weight: 600; background: var(--surface); }
.tb-xt span { padding: 7px 6px; text-align: right; border-left: 1px solid var(--line); }
.tb-xt span:first-child { text-align: left; border-left: 0; color: var(--ink); font-family: var(--f-body); font-weight: 600; }
.tb-ask { position: absolute; right: 7%; bottom: 7%; max-width: 64%; padding: 10px 14px; border-radius: 14px 14px 4px 14px; background: var(--ink); color: var(--bg); font-weight: 600; font-size: .84rem; line-height: 1.35; --d: .4s; }
.cs-stage:not([data-step="1"]) .s1 .tb-xt { opacity: 0; transform: translateY(16px); }
.cs-stage:not([data-step="1"]) .s1 .tb-ask { opacity: 0; transform: scale(.9); }

/* Escena 2: fuentes */
.tb-cap { display: block; font-size: .72rem; font-weight: 600; color: var(--muted); margin-bottom: 8px; }
.tb-join { display: flex; align-items: center; justify-content: center; gap: 10px; padding: 14px; border-radius: 12px; background: var(--bg); border: 1px solid var(--line); }
.tb-src { display: flex; align-items: center; gap: 8px; padding: 8px 12px; border-radius: 8px; background: var(--surface); border: 1px solid var(--line); font-weight: 600; font-size: .8rem; }
.tb-ico { display: grid; place-items: center; min-width: 24px; height: 24px; padding: 0 3px; border-radius: 5px; font-size: .6rem; font-weight: 700; color: var(--tb-dim); background: color-mix(in srgb, var(--tb-dim) 15%, var(--surface)); }
.tb-ico.x { background: #1d7044; color: #fff; font-size: .78rem; }
.tb-venn { width: 54px; height: 34px; flex: none; }
.tb-venn circle { fill: color-mix(in srgb, var(--tb-orb) 35%, transparent); stroke: var(--tb-orb); stroke-width: 2; }
.tb-preview { margin-top: 12px; border-radius: 10px; overflow: hidden; border: 1px solid var(--line); background: var(--surface); font-size: .72rem; --d: .2s; }
.tb-preview > div { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); border-top: 1px solid var(--line); }
.tb-preview > .h { border-top: 0; font-weight: 600; }
.tb-preview .h span:nth-child(-n+2) { color: var(--tb-dim); } .tb-preview .h span:nth-child(n+3) { color: var(--tb-mea); }
.tb-preview .h span:last-child { color: var(--tb-or); }
.tb-preview span { padding: 6px 8px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tb-preview > div:not(.h) span:nth-child(n+3) { font-family: var(--mono); text-align: right; }
.tb-mode { display: flex; gap: 6px; margin: 12px 0 0; --d: .35s; }
.tb-mode span { padding: 5px 12px; border-radius: 999px; font-size: .72rem; font-weight: 600; border: 1px solid var(--line); color: var(--muted); }
.tb-mode .on { color: #fff; background: var(--tb-dim); border-color: var(--tb-dim); }
.cs-stage:not([data-step="2"]) .s2 > * { opacity: 0; transform: translateY(16px); }

/* Escena 3: panel de datos y cálculo */
.c-tableau .s3 { display: grid; grid-template-columns: minmax(0, .8fr) minmax(0, 1.3fr); gap: 14px; align-items: start; }
.tb-pane { display: grid; gap: 5px; padding: 12px; border-radius: 12px; background: var(--bg); border: 1px solid var(--line); }
.tb-pane small { font-size: .68rem; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; margin-top: 4px; }
.tb-f { padding: 4px 8px; border-radius: 6px; font-size: .74rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tb-f.dim { color: var(--tb-dim); background: color-mix(in srgb, var(--tb-dim) 12%, var(--surface)); }
.tb-f.mea { color: var(--tb-mea); background: color-mix(in srgb, var(--tb-mea) 12%, var(--surface)); }
.tb-f.calc { outline: 1.5px dashed var(--tb-mea); transition: opacity .4s 1.2s, transform .4s 1.2s; }
.cs-stage:not([data-step="3"]) .tb-f.calc { opacity: 0; transform: translateX(-8px); transition-delay: 0s; }
.tb-calc { display: grid; gap: 10px; padding: 14px; border-radius: 12px; background: var(--surface); border: 1px solid var(--line); box-shadow: 0 14px 30px -20px rgba(16, 42, 67, .5); --d: .2s; }
.tb-calc header { font-size: .76rem; color: var(--muted); } .tb-calc header b { color: var(--ink); }
.tb-calc code { display: block; padding: 10px; border-radius: 8px; background: var(--bg); border: 1px solid var(--line); font-family: var(--mono); font-size: .76rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tb-calc code i { font-style: normal; color: var(--tb-dim); font-weight: 700; }
.tb-fn { display: flex; flex-wrap: wrap; gap: 4px; margin: 0; }
.tb-fn span { padding: 2px 8px; border-radius: 4px; font-size: .66rem; background: var(--bg); border: 1px solid var(--line); color: var(--muted); }
.tb-valid { font-size: .74rem; font-weight: 600; color: var(--tb-mea); }
.cs-stage:not([data-step="3"]) .s3 .tb-pane, .cs-stage:not([data-step="3"]) .s3 .tb-calc { opacity: 0; transform: translateY(16px); }

/* Escenas 4 y 5: gráfico */
.tb-shelves { display: grid; gap: 7px; }
.tb-drop { transition: transform .8s cubic-bezier(.2, .8, .2, 1), opacity .4s; }
.tb-drop.d2 { transition-delay: .45s; }
.cs-stage:not([data-step="4"]) .tb-drop { opacity: 0; transform: translate(60px, 50px) rotate(6deg); }
.tb-chart { position: relative; margin-top: 14px; height: 62%; padding: 10px 12px 26px; border-radius: 12px; background: var(--bg); border: 1px solid var(--line); }
.tb-bars { display: flex; align-items: flex-end; gap: 6%; height: 100%; border-bottom: 1px solid var(--line); }
.tb-bars i { position: relative; flex: 1; height: var(--h); background: var(--c, var(--tb-dim)); transform-origin: bottom; transition: transform .8s cubic-bezier(.2, .8, .2, 1), background-color .6s; }
.tb-bars em { position: absolute; left: 50%; bottom: -20px; translate: -50% 0; font-style: normal; font-size: .64rem; color: var(--muted); white-space: nowrap; }
.s4 .tb-bars i { transition-delay: 1.1s; }
.s4 .tb-bars i:nth-child(2) { transition-delay: 1.15s; } .s4 .tb-bars i:nth-child(3) { transition-delay: 1.2s; } .s4 .tb-bars i:nth-child(4) { transition-delay: 1.25s; } .s4 .tb-bars i:nth-child(5) { transition-delay: 1.3s; } .s4 .tb-bars i:nth-child(6) { transition-delay: 1.35s; }
.cs-stage:not([data-step="4"]) .s4 .tb-bars i { transform: scaleY(0); }
.cs-stage:not([data-step="4"]) .s4 .tb-chart { opacity: 0; }
.tb-marks { display: flex; align-items: center; gap: 8px; }
.tb-mk { padding: 4px 10px; border-radius: 6px; border: 1px solid var(--line); background: var(--bg); font-size: .72rem; font-weight: 600; }
.tb-mk::before { content: ""; display: inline-block; width: 10px; height: 10px; margin-right: 6px; border-radius: 2px; vertical-align: -1px; background: linear-gradient(90deg, var(--tb-r2), var(--tb-g2)); }
.tb-heat i { transition: background-color .7s .5s; }
.cs-stage:not([data-step="5"]) .tb-heat i { background: var(--tb-dim); }
.tb-tip { position: absolute; right: 8%; top: 8%; max-width: 46%; padding: 8px 10px; border-radius: 8px; background: var(--ink); color: var(--bg); font-size: .74rem; line-height: 1.35; box-shadow: var(--shadow); transition: opacity .5s 1.2s, transform .5s 1.2s; }
.cs-stage:not([data-step="5"]) .tb-tip { opacity: 0; transform: translateY(8px); transition-delay: 0s; }
.tb-legend { display: flex; justify-content: flex-end; gap: 12px; margin: 10px 0 0; font-size: .7rem; color: var(--muted); --d: .6s; }
.tb-legend span::before { content: ""; display: inline-block; width: 10px; height: 10px; margin-right: 5px; border-radius: 2px; vertical-align: -1px; }
.tb-legend .r::before { background: var(--tb-r2); } .tb-legend .g::before { background: var(--tb-g2); }
.cs-stage:not([data-step="5"]) .s5 .tb-marks, .cs-stage:not([data-step="5"]) .s5 .tb-legend { opacity: 0; transform: translateY(10px); }

/* ---------- Programa y recorrido ---------- */
.c-tableau .unit-n { color: var(--tb-or); }
.c-tableau .unit li::before { background: var(--tb-dim); }
.c-tableau .unit:nth-child(odd) li::before { background: var(--tb-mea); }
.tb-units { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.c-tableau .gain-list span { -webkit-text-stroke-color: var(--tb-or); }
.tb-road { grid-template-columns: 1.4fr 1fr 1fr; }
.tb-dots { display: grid; grid-template-columns: repeat(10, 1fr); gap: 4px; margin-bottom: 6px; }
.tb-dots i { height: 14px; border-radius: 999px; background: var(--line); transition: background-color .3s; }
.road-leg.on .tb-dots i { background: var(--tb-dim); }
.road-leg.on .tb-dots i:nth-child(n+6) { background: var(--tb-mea); transition-delay: .15s; }

@media (max-width: 1000px) { .tb-units { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 900px) {
  .tb-shelf { left: -8px; bottom: -24px; }
  .tb-road { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 560px) {
  .tb-units { grid-template-columns: minmax(0, 1fr); }
  .tb-stage { font-size: .72rem; }
  .tb-shelf { width: 80%; padding: 9px; gap: 5px; } .tb-minibars { height: 36px; }
  .tb-row { grid-template-columns: 58px 1fr; gap: 4px; } .tb-lab { font-size: .6rem; } .tb-slot { min-height: 24px; }
  .tb-pill { font-size: .62rem; padding: 3px 8px; }
  .tb-xt { font-size: .54rem; } .tb-xt span { padding: 4px 3px; }
  .tb-ask { font-size: .66rem; padding: 6px 10px; max-width: 76%; bottom: 5%; }
  .tb-cap { margin-bottom: 4px; } .tb-join { padding: 8px; gap: 6px; } .tb-src { font-size: .62rem; padding: 5px 7px; gap: 5px; } .tb-ico { min-width: 18px; height: 18px; font-size: .5rem; } .tb-venn { width: 36px; }
  .tb-preview { margin-top: 6px; font-size: .56rem; } .tb-preview span { padding: 3px 4px; }
  .tb-mode { margin-top: 6px; } .tb-mode span { font-size: .6rem; padding: 3px 8px; }
  .c-tableau .s3 { gap: 6px; } .tb-pane { padding: 6px; gap: 3px; } .tb-pane small { font-size: .52rem; } .tb-f { font-size: .58rem; padding: 2px 5px; }
  .tb-calc { padding: 8px; gap: 6px; } .tb-calc header { font-size: .6rem; } .tb-calc code { font-size: .56rem; padding: 6px; white-space: normal; } .tb-fn span { font-size: .52rem; padding: 1px 5px; } .tb-valid { font-size: .6rem; }
  .tb-chart { margin-top: 8px; height: 58%; padding: 6px 8px 20px; } .tb-bars em { font-size: .52rem; bottom: -16px; }
  .tb-tip { font-size: .6rem; max-width: 58%; padding: 5px 7px; } .tb-mk { font-size: .6rem; } .tb-legend { margin-top: 6px; font-size: .58rem; }
}
@media (prefers-reduced-motion: reduce) {
  .tb-shelf, .tb-fly, .tb-minibars i { animation: none !important; }
  .tb-drop, .tb-bars i, .tb-heat i, .tb-tip, .tb-f.calc, .tb-dots i { transition: none !important; }
}
