/* Cotizador 3D dentro del diálogo "Pieza 3D" de una cotización: estilos de la propuesta aprobada por AVG (avg.css,
   bloque .cz-*) con los tokens del sistema. Lección de la propuesta que se conserva: la columna del visor lleva
   minmax(0, 1fr); si no, el canvas de Three.js ensancha la grilla en celular. */
/* Casi pantalla completa: el visor aprovecha todo el ancho y el alto disponibles. */
.cz-dialog { width: calc(100vw - 24px); height: calc(100dvh - 24px); max-width: none; max-height: none; padding: 0; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); color: var(--ink); }
.cz-dialog::backdrop { background: rgba(7, 17, 28, .55); }
.cz-dialog__head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.cz-dialog__head h2 { margin: 0; font-size: 1.05rem; }
.cz-dialog__foot { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; border-top: 1px solid var(--line); background: var(--surface-2); }
.cz-dialog__price { display: grid; gap: 2px; }
.cz-dialog__price strong { font-size: 1.15rem; font-variant-numeric: tabular-nums; }
.cz-incomplete { margin: 0; max-width: 46ch; color: var(--warn); background: var(--warn-soft); border-radius: var(--radius-sm); padding: 6px 10px; font-weight: 600; }
.cz-dialog[open] { display: flex; flex-direction: column; }
.cz-dialog__head-btns { display: flex; gap: 8px; }
.cz-dialog[data-paso="tarjetas"] .cz-change { display: none; }
/* Tres columnas: parámetros | visor | resumen y costos. Fila acotada: cada columna se desplaza sola y el visor
   nunca queda más alto que el diálogo. */
/* Anchos de los paneles: por defecto o los que elija el usuario (columnas.js, --cz-izq / --cz-der); acotados para que el visor quede con ~40 % o más. */
.cz-cfg { --cz-izq: clamp(400px, 26vw, 420px); --cz-der: 320px; position: relative; flex: 1; display: grid; grid-template-columns: var(--cz-col-izq, min(var(--cz-izq), 36%)) minmax(0, 1fr) var(--cz-col-der, min(var(--cz-der), 25%)); grid-template-rows: minmax(0, 1fr); min-height: 0; overflow: hidden; }
.cz-panel { border-right: 1px solid var(--line); background: var(--surface-2); overflow-y: auto; scrollbar-width: thin; }
.cz-prods { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 4px; padding: 12px; border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 2; background: var(--surface-2); }
.cz-prod { padding: 8px 4px; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); background: var(--surface); color: var(--ink-2); font-size: .78rem; font-weight: 700; cursor: pointer; }
.cz-prod[aria-pressed="true"] { background: var(--av-pri); border-color: var(--av-pri); color: #fff; }
.cz-prod:focus-visible, .cz-tools button:focus-visible { outline: 3px solid var(--av-acc); outline-offset: 1px; }
.cz-grp { border: 0; margin: 0; padding: 12px 16px 14px; border-bottom: 1px solid var(--line); display: grid; gap: 10px; min-width: 0; }
/* Compacto (Cotizaciones): panel de parámetros más denso. */
.is-compact .cz-grp { padding: 8px 12px 10px; gap: 7px; }
.is-compact .cz-fld { gap: 3px; }
.is-compact .cz-sel { padding: 5px 8px; min-height: 32px; }
.is-compact .cz-prods { padding: 8px; }
.is-compact .cz-prod { padding: 6px 4px; }
.cz-grp legend { float: left; width: 100%; font-weight: 700; font-size: .72rem; letter-spacing: .08em; text-transform: uppercase; color: var(--soft-ink); padding: 0; }
.cz-fld { display: grid; gap: 5px; min-width: 0; }
.cz-fld > span { display: flex; justify-content: space-between; align-items: baseline; font-size: .78rem; font-weight: 600; color: var(--ink-2); }
.cz-fld output { color: var(--ink); font-weight: 700; font-variant-numeric: tabular-nums; }
.cz-sel { width: 100%; font-size: .85rem; color: var(--ink); background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--radius-sm); padding: 7px 9px; }
.cz-rng input[type="range"] { width: 100%; accent-color: var(--av-pri); height: 22px; cursor: pointer; }
.cz-seg { display: flex; flex-wrap: wrap; gap: 4px; }
.cz-seg label { position: relative; cursor: pointer; }
.cz-seg input, .cz-sws input { position: absolute; opacity: 0; pointer-events: none; }
.cz-seg span { display: inline-block; padding: 6px 10px; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); background: var(--surface); font-size: .8rem; font-weight: 600; color: var(--ink-2); white-space: nowrap; }
.cz-seg input:checked + span { background: var(--av-pri); border-color: var(--av-pri); color: #fff; }
.cz-seg input:focus-visible + span, .cz-sw input:focus-visible + span { outline: 3px solid var(--av-acc); outline-offset: 1px; }
.cz-sws { display: flex; flex-wrap: wrap; gap: 6px; }
.cz-sw { position: relative; cursor: pointer; }
.cz-sw span { display: block; width: 28px; height: 28px; border-radius: var(--radius-sm); background: var(--sw); border: 1px solid rgba(20, 32, 51, .3); box-shadow: inset 0 0 0 2px var(--surface); }
.cz-sw em { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.cz-sw input:checked + span { outline: 2px solid var(--av-pri); outline-offset: 2px; }
.cz-check { display: inline-flex; align-items: center; gap: 6px; font-size: .8rem; font-weight: 600; color: var(--ink-2); cursor: pointer; }
.cz-check input { accent-color: var(--av-pri); width: 16px; height: 16px; }
/* AVG: listas (tramos de un eje, perforaciones radiales): una fila por elemento, con sus números y casillas. */
.cz-lista__filas { display: grid; gap: 6px; }
.cz-lista__fila { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 6px 8px; padding: 6px 8px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface); }
.cz-lista__fila > b { align-self: center; font-size: .75rem; color: var(--muted); min-width: 1.2em; }
.cz-lista__num { display: grid; gap: 2px; font-size: .7rem; font-weight: 600; color: var(--ink-2); }
.cz-lista__num input { width: 74px; padding: 5px 6px; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); font-size: .82rem; }
.cz-lista__num input[readonly] { background: var(--surface-2); color: var(--muted); }
.cz-lista__fila .cz-check { font-size: .74rem; }
.cz-lista__del, .cz-lista__add { border: 1px solid var(--line-strong); background: var(--surface); border-radius: var(--radius-sm); padding: 4px 9px; font-size: .75rem; font-weight: 600; cursor: pointer; color: var(--ink); }
.cz-lista__del { margin-left: auto; }
.cz-lista__add { justify-self: start; }
.cz-lista__del:disabled, .cz-lista__add:disabled { opacity: .5; cursor: not-allowed; }
.cz-lista__nota { margin: 0; font-size: .74rem; color: var(--muted); }
.cz-lista__txt input { width: 180px; }
.cz-lista__num select { padding: 5px 6px; font-size: .8rem; }
.cz-texto { resize: vertical; min-height: 4.5em; font-family: inherit; }
.cz-stage { display: flex; flex-direction: column; min-width: 0; min-height: 0; overflow: hidden; }
/* Pestañas Modelo 3D / Plano: solo cuando la pieza dibuja su plano en vivo (data-plano="1", lo pone motor.js). */
.cz-tabs { display: none; gap: 4px; padding: 8px 12px; border-bottom: 1px solid var(--line); background: var(--surface); }
.cz-dialog[data-plano="1"] .cz-tabs { display: flex; }
.cz-tabs button { border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink-2); border-radius: var(--radius-sm); padding: 5px 14px; font: inherit; font-size: .82rem; font-weight: 600; cursor: pointer; }
.cz-tabs button[aria-selected="true"] { background: var(--av-pri); border-color: var(--av-pri); color: #fff; }
.cz-tabs button:focus-visible { outline: 3px solid var(--av-acc); outline-offset: 1px; }
.cz-dialog[data-plano="1"][data-tab="plano"] .cz-view { display: none; }
.cz-dialog:not([data-tab="plano"]) .cz-plano { display: none; }
.cz-view { position: relative; flex: 1; min-height: 0; background: radial-gradient(120% 90% at 50% 0%, #ffffff 0%, #E9EFF6 70%, #DCE5EF 100%); }
.cz-viewport { position: absolute; inset: 0; }
.cz-viewport canvas { display: block; width: 100% !important; height: 100% !important; outline: none; cursor: grab; }
.cz-fallback { position: absolute; inset: 0; display: grid; place-items: center; margin: 0; color: var(--muted); padding: 2rem; text-align: center; }
.cz-viewport.is-ready .cz-fallback { display: none; }
.cz-tools { position: absolute; display: flex; gap: 4px; flex-wrap: wrap; z-index: 2; }
.cz-tools-l { top: 12px; left: 12px; }
.cz-tools-r { top: 12px; right: 12px; }
.cz-tools button { border: 1px solid var(--line-strong); background: rgba(255, 255, 255, .92); color: var(--ink); border-radius: var(--radius-sm); padding: 6px 11px; font-size: .75rem; font-weight: 600; cursor: pointer; }
/* Cámara: botones de ~28 px, semitransparentes, en la esquina superior izquierda. */
.cz-cam { gap: 3px; max-width: calc(100% - 250px); }
.cz-cam button { display: inline-flex; align-items: center; justify-content: center; min-width: 28px; height: 28px; padding: 0 6px; background: rgba(255, 255, 255, .72); border-color: rgba(125, 138, 153, .6); font-size: .72rem; }
.cz-cam button:hover { background: #fff; border-color: var(--line-strong); }
.cz-cam button .ico { width: 17px; height: 17px; }
.cz-cam .itip__btn { width: 28px; height: 28px; margin: 0; padding: 0; border: 0; background: rgba(255, 255, 255, .72); }
.cz-tools button[aria-pressed="true"] { background: var(--av-pri); border-color: var(--av-pri); color: #fff; }
.cz-dimbadge { position: absolute; left: 12px; bottom: 12px; z-index: 2; background: var(--av-ink); color: #fff; font-size: .75rem; font-weight: 600; padding: 6px 11px; border-radius: var(--radius-sm); font-variant-numeric: tabular-nums; }
.cz-res { padding: 14px 16px 16px; display: grid; gap: 12px; align-content: start; grid-auto-rows: max-content; border-left: 1px solid var(--line); background: var(--surface-2); overflow-y: auto; scrollbar-width: thin; }
.cz-res #cz-titulo { margin: 0; font-weight: 600; color: var(--ink); }
.cz-res .cz-cot-wrap { background: var(--surface); }
/* Columna derecha angosta: sin la columna «Unitario»; el precio unitario va bajo la cantidad. */
.cz-cot td .cz-cot-pu { display: none; }
@media (min-width: 1201px) {
    .cz-res .cz-cot th:nth-child(3), .cz-res .cz-cot td:nth-child(3) { display: none; }
    .cz-res .cz-cot .cz-cot-pu { display: block; }
    .cz-res .cz-cot th, .cz-res .cz-cot td { padding: 7px 8px; }
}
.cz-avisos { display: grid; gap: 6px; }
.cz-aviso { margin: 0; font-size: .8rem; line-height: 1.4; color: var(--warn); background: var(--warn-soft); border-radius: var(--radius-sm); padding: 7px 10px; }
.cz-aviso::before { content: "Ajuste de taller · "; font-weight: 700; }
.cz-kpis { margin: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.cz-kpis > div { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; min-width: 0; }
.cz-kpis dt { font-size: .68rem; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.cz-kpis dd { margin: 2px 0 0; font-weight: 800; font-size: 1.05rem; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cz-cot-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); }
.cz-cot { width: 100%; border-collapse: collapse; font-size: .8rem; }
.cz-cot th { text-align: left; background: var(--surface-2); font-size: .68rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); padding: 8px 10px; border-bottom: 1px solid var(--line); }
.cz-cot td { padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.cz-cot td span { display: block; color: var(--muted); font-size: .74rem; }
.cz-r { text-align: right; white-space: nowrap; }
.cz-cot th.cz-r { text-align: right; }

/* Línea 3D en la tabla de la cotización */
.qline__thumb { display: block; width: 96px; height: 56px; object-fit: contain; border-radius: var(--radius-sm); background: radial-gradient(120% 90% at 50% 0%, #fff 0%, #E9EFF6 100%); border: 1px solid var(--line); }
.qline__3d { display: flex; gap: 10px; align-items: flex-start; }

/* Como la propuesta: en pantallas angostas la barra derecha baja para no montarse sobre la de vistas. */
@media (max-width: 760px) {
    /* Celular: la cámara arriba (puede ocupar dos filas) y las acciones del modelo abajo a la derecha. */
    .cz-cam { max-width: calc(100% - 20px); }
    .cz-tools-r { top: auto; bottom: 12px; }
}

/* Pantallas medianas: el resumen baja bajo el visor (columna derecha con desplazamiento). */
@media (max-width: 1200px) {
    .cz-cfg { grid-template-columns: var(--cz-col-izq, min(var(--cz-izq), 50%)) minmax(0, 1fr); grid-template-rows: minmax(0, 1fr) var(--cz-row-der, minmax(0, 38%)); }
    .cz-panel { grid-row: 1 / span 2; }
    .cz-res { grid-column: 2; border-left: 0; border-top: 1px solid var(--line); }
    .cz-kpis { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
@media (max-width: 900px) {
    .cz-dialog { height: auto; max-height: calc(100dvh - 24px); overflow-y: auto; }
    .cz-dialog[open] { display: block; }
    .cz-cfg { grid-template-columns: minmax(0, 1fr); grid-template-rows: none; overflow: visible; }
    .cz-panel { grid-row: auto; border-right: 0; border-bottom: 1px solid var(--line); max-height: 42vh; }
    .cz-res { grid-column: auto; overflow: visible; }
    .cz-view { flex: none; height: 320px; }
    .cz-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
