/* Portal Vifer v3 · FICHAS DE OFICIO: widgets propios del sector y el cajon "¿De donde sale?" */

/* Ocho cifras: dos filas de cuatro */
.nb-kpis.nb-kpis--8 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 1100px) { .nb-kpis.nb-kpis--8 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.nb-kpi__how { justify-self: start; margin-top: 2px; padding: 2px 0; border: 0; border-bottom: 1px dashed var(--border-cyan-strong); background: none; color: var(--cyan); font: inherit; font-size: 12px; cursor: pointer; }
.nb-kpi__how:hover { color: var(--fg); border-bottom-color: var(--fg); }
.nb-kpi__how:focus-visible { outline: 2px solid var(--cyan); outline-offset: 3px; border-radius: 2px; }

/* Regla de cada coste en la rentabilidad */
.nb-pl__rule { grid-column: 1 / -1; margin-top: -4px; color: var(--fg-dim); font-size: 11.5px; }

/* "¿De donde sale?" */
.of-how__v { margin: 0; color: var(--fg); font-size: 40px; font-weight: 600; letter-spacing: -0.02em; }
.of-how__f { margin: 0; padding: 12px 14px; border-left: 3px solid var(--cyan); border-radius: 0 8px 8px 0; background: rgba(0, 194, 209, 0.06); color: var(--fg); font-size: 15px; line-height: 1.55; }
.of-how__parts { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px 16px; margin: 0; }
.of-how__parts dt { color: var(--fg-muted); font-size: 13.5px; }
.of-how__parts dd { margin: 0; color: var(--fg); text-align: right; }
.of-how__ref { margin: 0; color: var(--fg-muted); font-size: 13px; }
.of-how__ref.is-beat { color: var(--success); } .of-how__ref.is-miss { color: var(--warning); }

/* Tablas de oficio */
.of-tbl td .nb-sw { margin-right: 8px; vertical-align: -1px; }
.of-tbl tr.is-best td:first-child b::after { content: "\2605"; margin-left: 6px; color: var(--cyan); font-size: 11px; }
.of-tbl tfoot td { border-top: 1px solid var(--border-mid); color: var(--fg); font-weight: 600; }
.of-occ { display: inline-block; width: 64px; height: 6px; margin-right: 8px; border-radius: 3px; background: rgba(var(--ink-rgb), 0.07); vertical-align: middle; overflow: hidden; }
.of-occ__bar { display: block; height: 100%; width: 100%; border-radius: 3px; background: var(--cyan); transform: scaleX(var(--p)); transform-origin: left; }

/* Produccion por tratamiento: anillo + tabla */
.of-treat { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 22px; align-items: center; }
@media (max-width: 720px) { .of-treat { grid-template-columns: minmax(0, 1fr); justify-items: center; } .of-treat .table-wrap { width: 100%; } }

/* Presupuestos: barra apilada */
.of-bud { display: flex; height: 14px; border-radius: 7px; overflow: hidden; background: rgba(var(--ink-rgb), 0.06); }
.of-bud__s { flex: var(--w) 0 0; min-width: 2px; }
.of-bud__s.is-accepted, .of-sw--accepted { background: var(--success); }
.of-bud__s.is-pending, .of-sw--pending { background: var(--warning); }
.of-bud__s.is-rejected, .of-sw--rejected { background: #5d6470; }
.of-bud__v { display: flex; align-items: baseline; gap: 10px; margin: 0; color: var(--fg-muted); }
.of-bud__v b { color: var(--warning); font-size: 22px; }

/* Movimiento: las barras crecen al entrar (solo transform) */
@media (prefers-reduced-motion: no-preference) {
  .of-occ__bar { animation: of-grow 700ms cubic-bezier(0.16, 1, 0.3, 1) both; }
  @keyframes of-grow { from { transform: scaleX(0); } }
}

/* Ingenieria de carta: mapa de cuadrantes + tabla */
.of-menu { display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); gap: 18px; align-items: start; }
.of-menu .nb-note { grid-column: 1 / -1; }
@media (max-width: 1100px) { .of-menu { grid-template-columns: minmax(0, 1fr); } }
.of-menu__chart { display: grid; gap: 10px; }
.of-menu__map { width: 100%; height: auto; }
.of-q { stroke: none; }
.of-q.is-star { fill: rgba(77, 213, 153, 0.07); } .of-q.is-horse { fill: rgba(0, 194, 209, 0.06); }
.of-q.is-puzzle { fill: rgba(240, 179, 74, 0.06); } .of-q.is-dog { fill: rgba(229, 103, 91, 0.06); }
.of-q__t { fill: var(--fg-muted); font-size: 12px; font-weight: 600; }
.of-q__l { stroke: var(--border-mid); stroke-dasharray: 4 4; }
.of-pt circle { stroke: var(--surface-1); stroke-width: 2; }
.of-pt__t { fill: var(--surface-1); font: 700 9.5px var(--font-mono, monospace); pointer-events: none; }
.of-chip { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11.5px; font-weight: 600; }
.of-chip.is-star { background: rgba(77, 213, 153, 0.14); color: var(--success); }
.of-chip.is-horse { background: rgba(0, 194, 209, 0.14); color: var(--cyan); }
.of-chip.is-puzzle { background: rgba(240, 179, 74, 0.14); color: var(--warning); }
.of-chip.is-dog { background: rgba(229, 103, 91, 0.14); color: #f08a80; }
@media (prefers-reduced-motion: no-preference) {
  .of-pt { animation: of-pop 520ms cubic-bezier(0.16, 1, 0.3, 1) both; animation-delay: calc(var(--i) * 45ms); transform-box: fill-box; transform-origin: center; }
  @keyframes of-pop { from { opacity: 0; transform: scale(0.2); } }
}

/* Cuando se llena: mapa de calor dia x servicio */
.of-slots { width: 100%; border-collapse: separate; border-spacing: 4px; }
.of-slots th { color: var(--fg-muted); font-size: 12px; font-weight: 500; text-align: center; }
.of-slots tbody th { text-align: left; padding-right: 6px; }
.of-slot { display: table-cell; min-width: 64px; padding: 8px 6px; border-radius: 8px; background: rgba(0, 194, 209, calc(0.05 + var(--v) * 0.5)); text-align: center; vertical-align: middle; }
.of-slot b { display: block; color: var(--fg); font-size: 15px; }
.of-slot span { display: block; color: var(--fg); font-size: 11px; opacity: 0.85; }
.of-slot.is-off { background: rgba(var(--ink-rgb), 0.03); color: var(--fg-dim); }

/* Factura por lineas: margen + coste */
.of-split { display: grid; gap: 10px; margin: 0; padding: 0; list-style: none; }
.of-split li { display: grid; grid-template-columns: 150px minmax(0, 1fr) 96px 170px; gap: 10px; align-items: center; }
@media (max-width: 720px) { .of-split li { grid-template-columns: minmax(0, 1fr) auto; } .of-split__track { grid-column: 1 / -1; grid-row: 2; } }
.of-split__track { display: flex; height: 10px; border-radius: 5px; background: rgba(var(--ink-rgb), 0.06); overflow: hidden; }
.of-split__m, .of-split__c { display: block; height: 100%; flex: var(--p) 0 0; }
.of-split__m, .of-sw--m { background: var(--success); } .of-split__c, .of-sw--c { background: #5d6470; }

/* Retoques: tabla de la carta sin cortes y factura del taller a lo ancho */
.of-menu { grid-template-columns: minmax(0, 0.95fr) minmax(0, 1.15fr); }
.of-chip { white-space: nowrap; }
.of-split li { grid-template-columns: 170px minmax(0, 1fr) 110px 200px; }
@media (max-width: 1100px) { .of-menu { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 720px) { .of-split li { grid-template-columns: minmax(0, 1fr) auto; } }

/* "¿Y si...?": mandos a la izquierda, resultado a la derecha */
.of-sim { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 14px 28px; align-items: start; }
.of-sim .nb-note { grid-column: 1 / -1; }
@media (max-width: 900px) { .of-sim { grid-template-columns: minmax(0, 1fr); } }
.of-sim__ctl { display: grid; gap: 14px; justify-items: start; }
.of-sim__c { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 12px; width: 100%; }
.of-sim__c label { color: var(--fg); font-size: 14px; }
.of-sim__v { color: var(--cyan); font-size: 12.5px; text-align: right; }
.of-sim__range { grid-column: 1 / -1; width: 100%; accent-color: var(--cyan); }
.of-sim__range:focus-visible { outline: 2px solid var(--cyan); outline-offset: 4px; border-radius: 4px; }
.of-sim__out { display: grid; gap: 10px; padding: 16px 18px; border: 1px solid var(--border-cyan); border-radius: 12px; background: linear-gradient(160deg, rgba(0, 194, 209, 0.07), rgba(0, 194, 209, 0.01)); }
.of-sim__row { display: grid; grid-template-columns: minmax(0, 1fr) auto auto auto; gap: 10px; align-items: baseline; color: var(--fg-muted); font-size: 13.5px; }
.of-sim__row b { color: var(--fg); font-size: 16px; }
.of-sim__arrow { color: var(--fg-dim); }
.of-sim__big { display: flex; align-items: baseline; gap: 10px; margin: 4px 0 0; }
.of-sim__big b { font-size: 30px; letter-spacing: -0.02em; }
.of-sim__big.is-up b { color: var(--success); } .of-sim__big.is-down b { color: var(--warning); }
.of-sim__big span { color: var(--fg-muted); font-size: 13px; }
.nb-up { color: var(--success); } .nb-down { color: var(--warning); }

/* Entrada escalonada de los bloques de Mi negocio */
@media (prefers-reduced-motion: no-preference) {
  .nb-in { animation: nb-in 560ms cubic-bezier(0.16, 1, 0.3, 1) both; animation-delay: calc(var(--i, 0) * 55ms); }
  @keyframes nb-in { from { opacity: 0; transform: translateY(14px); } }
}

/* Presupuestos pendientes: paciente y tratamiento juntos, importe, dias y accion en una linea */
.of-bud__list li { grid-template-columns: minmax(0, 1fr) auto auto auto; }
.of-bud__who { display: grid; gap: 1px; min-width: 0; }
.of-bud__who span { font-size: 12px; }

/* Lo que vale la pena hacer */
.of-opp__total { display: flex; align-items: baseline; gap: 12px; margin: 0; }
.of-opp__total b { color: var(--success); font-size: 34px; letter-spacing: -0.02em; }
.of-opp__total span { color: var(--fg-muted); font-size: 14px; }
.of-opp { display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; }
.of-opp__i { display: grid; grid-template-columns: 28px minmax(0, 1fr) auto auto; gap: 14px; align-items: center; padding: 12px 14px; border: 1px solid var(--border-subtle); border-radius: 10px; background: var(--surface-1); }
.of-opp__i:first-child { border-color: rgba(77, 213, 153, 0.35); background: linear-gradient(90deg, rgba(77, 213, 153, 0.07), transparent 60%); }
.of-opp__n { display: grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; background: rgba(77, 213, 153, 0.12); color: var(--success); font-size: 13px; }
.of-opp__b b { color: var(--fg); font-size: 15px; }
.of-opp__how { margin: 3px 0 0; color: var(--fg-muted); font-size: 13px; line-height: 1.45; }
.of-opp__v { color: var(--success); font-size: 18px; font-weight: 600; white-space: nowrap; }
@media (max-width: 720px) { .of-opp__i { grid-template-columns: 28px minmax(0, 1fr); } .of-opp__v, .of-opp__i .btn { grid-column: 2; justify-self: start; } }
@media (prefers-reduced-motion: no-preference) { .of-opp__i { animation: nb-in 520ms cubic-bezier(0.16, 1, 0.3, 1) both; } .of-opp__i:nth-child(2) { animation-delay: 80ms; } .of-opp__i:nth-child(3) { animation-delay: 160ms; } .of-opp__i:nth-child(4) { animation-delay: 240ms; } }
.of-sim__pre { gap: 6px; }
.of-treat__note { grid-column: 1 / -1; }
/* Legibilidad: referencias y notas pequenas, mas claras */
.nb-kpi__b { font-size: 12px; color: var(--fg-muted); }
.nb-note, .nbw__src { color: var(--fg-muted); }

.of-sim__chip { padding: 5px 10px; border: 1px solid var(--border-mid); border-radius: 999px; background: transparent; color: var(--fg); font: inherit; font-size: 12.5px; cursor: pointer; }
.of-sim__chip:hover { border-color: var(--border-cyan-strong); }
.of-sim__chip:focus-visible { outline: 2px solid var(--cyan); outline-offset: 2px; }

/* "¿De donde sale?": desglose, evolucion y supuestos */
.of-split2 { display: grid; gap: 7px; margin: 0; padding: 0; list-style: none; }
.of-split2 li { display: grid; grid-template-columns: minmax(0, 1fr) 120px auto; gap: 10px; align-items: center; font-size: 13.5px; color: var(--fg-muted); }
.of-split2 b { color: var(--fg); text-align: right; }
.of-split2__b { display: block; height: 8px; width: 100%; border-radius: 4px; background: var(--cyan); transform: scaleX(var(--p)); transform-origin: left; }
.of-split2 li.is-neg .of-split2__b { background: var(--warning); }
.of-split2 .of-split__track { height: 8px; }
.of-evo { display: grid; grid-template-columns: auto minmax(0, 1fr) auto auto; gap: 12px; align-items: center; padding: 10px 12px; border: 1px solid var(--border-subtle); border-radius: 10px; }
.of-evo > div { display: grid; gap: 2px; font-size: 12px; } .of-evo > div b { color: var(--fg); font-size: 15px; }
.of-evo .spark { width: 100%; }
.of-evo__d { font-size: 16px; }
.of-how__as summary { color: var(--cyan); font-size: 13px; cursor: pointer; }
.of-how__as ul { margin: 8px 0 0; padding-left: 18px; color: var(--fg-muted); font-size: 13px; line-height: 1.55; }

/* Ronda 3: lista completa con su suma, ventas por hora de personal */
.of-opp__sum { margin: 0; color: var(--fg-muted); font-size: 12.5px; }
.of-opp__list { max-height: 320px; overflow-y: auto; }
.of-splh th, .of-splh td { padding-top: 6px; font-size: 12.5px; text-align: center; color: var(--fg-muted); }
.of-splh td.is-low { color: var(--warning); } .of-splh td.is-high { color: var(--success); }

/* Ronda 4: nada se corta en las tarjetas (360 px) y el texto auxiliar se lee */
.nb-kpi > * { min-width: 0; }
.nb-kpi__l, .nb-kpi__b, .nb-kpi__d, .nb-kpi__d span, .nb-kpi__how { white-space: normal; overflow-wrap: anywhere; }
.nb-kpi__d { flex-wrap: wrap; row-gap: 2px; }
@media (max-width: 420px) { .nb-kpi { padding: 10px 11px; } .nb-kpi__b { font-size: 11.5px; } .nb-kpi__d .tm-dim { font-size: 11px; } }
.of-tbl td, .nb-next li { font-size: 13.5px; }
.of-tbl .tm-dim, .nb-next .tm-dim, .of-bud__who span { color: var(--fg-muted); font-size: 12.5px; }
.of-splh th, .of-splh td { font-size: 13.5px; font-weight: 600; }
