/* ==========================================================================
   Inventario — estilos
   ========================================================================== */

:root {
    --fondo: #f6f4f1;
    --superficie: #ffffff;
    --superficie-2: #faf8f6;
    --borde: #e7e1da;
    --borde-fuerte: #d4cbc1;
    --texto: #1f1a17;
    --texto-2: #6b625b;
    --texto-3: #9a9089;
    --acento: #8a4b2a;
    --acento-hover: #723c20;
    --acento-suave: #f5ebe4;
    --ok: #1f7a4d;
    --ok-suave: #e8f5ee;
    --error: #b42318;
    --error-suave: #fdecea;
    --info: #1d5f99;
    --info-suave: #eaf2fa;
    --aviso: #9a5b00;
    --aviso-suave: #fdf4e3;
    --morado: #6b3fa0;
    --morado-suave: #f2ecfa;
    --radio: 10px;
    --radio-sm: 7px;
    --sombra: 0 1px 2px rgba(31, 26, 23, .06), 0 1px 3px rgba(31, 26, 23, .04);
    --sombra-alta: 0 10px 30px rgba(31, 26, 23, .12);
    --sidebar: 248px;
    --fuente: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --mono: ui-monospace, "SFMono-Regular", Consolas, monospace;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 15px/1.5 var(--fuente); color: var(--texto); background: var(--fondo); }
a { color: var(--acento); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0; line-height: 1.25; letter-spacing: -.01em; }
h1 { font-size: 1.6rem; }
.h2, .paso h2 { font-size: 1.15rem; }
.h3 { font-size: 1.1rem; margin: 28px 0 12px; }
.h4 { font-size: .95rem; display: flex; align-items: center; gap: 6px; margin-bottom: 10px; }
p { margin: 0 0 8px; }
code { font-family: var(--mono); font-size: .82em; background: var(--superficie-2); border: 1px solid var(--borde); padding: 1px 5px; border-radius: 4px; }
small { font-size: .82rem; }
[hidden] { display: none !important; }
.muted { color: var(--texto-2); }
.nowrap { white-space: nowrap; }
.derecha { text-align: right; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.opcional { font-style: normal; font-weight: 400; color: var(--texto-3); font-size: .8rem; margin-left: 4px; }

.icon { width: 18px; height: 18px; flex: none; }
.icon-lg { width: 28px; height: 28px; }
.icon-xl { width: 44px; height: 44px; color: var(--texto-3); }

/* ---------- Estructura ---------- */

.app { display: flex; min-height: 100vh; }
.sidebar {
    width: var(--sidebar); flex: none; background: var(--superficie); border-right: 1px solid var(--borde);
    display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; padding: 18px 14px;
}
.marca { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 1.05rem; color: var(--texto); padding: 4px 8px 18px; }
.marca:hover { text-decoration: none; }
.marca-logo { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 9px; background: var(--acento); color: #fff; }
.marca-centro { justify-content: center; padding-bottom: 24px; }
.nav { display: flex; flex-direction: column; gap: 2px; flex: 1; overflow-y: auto; }
.nav-titulo { font-size: .72rem; text-transform: uppercase; letter-spacing: .08em; color: var(--texto-3); padding: 18px 10px 6px; }
.nav-link { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: var(--radio-sm); color: var(--texto-2); font-weight: 500; }
.nav-link:hover { background: var(--superficie-2); color: var(--texto); text-decoration: none; }
.nav-link.activo { background: var(--acento-suave); color: var(--acento); }
.sidebar-pie { border-top: 1px solid var(--borde); padding-top: 14px; display: grid; gap: 10px; }
.yo { display: flex; gap: 10px; align-items: center; padding: 0 6px; }
.yo strong { display: block; font-size: .9rem; }
.yo small { color: var(--texto-2); display: block; line-height: 1.3; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--acento-suave); color: var(--acento); display: grid; place-items: center; font-weight: 700; flex: none; }

.principal { flex: 1; min-width: 0; }
.contenido { max-width: 1180px; margin: 0 auto; padding: 28px 32px 120px; }
.barra-movil { display: none; }
.velo { display: none; }

.pantalla-simple { display: grid; place-items: center; min-height: 100vh; padding: 24px 16px; }
.caja-simple { width: 100%; max-width: 400px; }

/* ---------- Cabeceras y avisos ---------- */

.cabecera { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.cabecera p { margin: 4px 0 0; }
.cabecera-sub { margin: 28px 0 12px; align-items: center; }
.cabecera-sub .h3 { margin: 0; }
.volver { display: inline-flex; align-items: center; gap: 4px; font-size: .85rem; color: var(--texto-2); margin-bottom: 6px; }
.acciones { display: flex; gap: 8px; flex-wrap: wrap; }

.aviso { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 11px 14px; border-radius: var(--radio-sm); margin-bottom: 16px; border: 1px solid; font-weight: 500; }
.aviso-ok { background: var(--ok-suave); border-color: #b9e0c9; color: var(--ok); }
.aviso-error { background: var(--error-suave); border-color: #f5c2bd; color: var(--error); }
.aviso-info { background: var(--info-suave); border-color: #c4dbf0; color: var(--info); }
.nota { display: flex; gap: 8px; align-items: center; background: var(--superficie-2); border: 1px dashed var(--borde-fuerte); border-radius: var(--radio-sm); padding: 10px 12px; color: var(--texto-2); margin: 0; }

/* ---------- Botones ---------- */

.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 8px 14px; border-radius: var(--radio-sm);
    border: 1px solid var(--borde-fuerte); background: var(--superficie); color: var(--texto); font: inherit; font-weight: 600; font-size: .9rem;
    cursor: pointer; text-decoration: none; white-space: nowrap; transition: background .15s, border-color .15s;
}
.btn:hover { background: var(--superficie-2); text-decoration: none; }
.btn:focus-visible, .btn-icono:focus-visible { outline: 3px solid rgba(138, 75, 42, .3); outline-offset: 1px; }
.btn-primario { background: var(--acento); border-color: var(--acento); color: #fff; }
.btn-primario:hover { background: var(--acento-hover); border-color: var(--acento-hover); }
.btn-ghost { border-color: transparent; background: transparent; color: var(--texto-2); }
.btn-ghost:hover { background: var(--superficie-2); color: var(--texto); }
.btn-peligro { border-color: #f0b5ae; color: var(--error); }
.btn-peligro:hover { background: var(--error-suave); }
.btn-sm { padding: 5px 10px; font-size: .84rem; }
.btn-lg { padding: 11px 22px; font-size: 1rem; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.btn-icono { display: grid; place-items: center; width: 38px; height: 38px; border-radius: var(--radio-sm); border: 0; background: transparent; color: inherit; cursor: pointer; }
.btn-icono:hover { background: rgba(0, 0, 0, .05); }

/* ---------- Tarjetas ---------- */

.card { background: var(--superficie); border: 1px solid var(--borde); border-radius: var(--radio); box-shadow: var(--sombra); padding: 20px; }
.card + .card { margin-top: 16px; }
.sin-relleno { padding: 0; }
.vacio { text-align: center; padding: 48px 20px; display: grid; justify-items: center; gap: 8px; }
.vacio-sm { padding: 24px; }
.angosto { max-width: 560px; }
.badge { display: inline-block; font-size: .74rem; font-weight: 600; padding: 1px 8px; border-radius: 99px; background: var(--acento-suave); color: var(--acento); }

/* ---------- Formularios ---------- */

.form { display: grid; gap: 16px; }
.campo { display: grid; grid-template-columns: minmax(0, 1fr); gap: 6px; margin: 0 0 16px; border: 0; padding: 0; min-width: 0; }
.campo > * { min-width: 0; }
.form .campo { margin: 0; }
.campo > span, .campo > legend, .etiqueta { font-weight: 600; font-size: .9rem; padding: 0; }
.campo small { color: var(--texto-2); }
input[type=text], input[type=search], input[type=password], input[type=email], input[type=number], input[type=date], select, textarea {
    width: 100%; font: inherit; color: var(--texto); background: var(--superficie); border: 1px solid var(--borde-fuerte);
    border-radius: var(--radio-sm); padding: 9px 11px; min-height: 40px;
}
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--acento); box-shadow: 0 0 0 3px rgba(138, 75, 42, .15); }
input:disabled { background: var(--superficie-2); color: var(--texto-2); }
.con-prefijo { display: flex; }
.con-prefijo span { display: grid; place-items: center; padding: 0 12px; background: var(--superficie-2); border: 1px solid var(--borde-fuerte); border-right: 0; border-radius: var(--radio-sm) 0 0 var(--radio-sm); color: var(--texto-2); }
.con-prefijo input { border-radius: 0 var(--radio-sm) var(--radio-sm) 0; }
.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--acento); }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.grid-2 .campo { margin: 0; }
.ancho { grid-column: 1 / -1; }
.fila-inline { display: flex; gap: 8px; max-width: 360px; }
.campo-error input, .campo-error .opciones { border-color: var(--error); }
.error-campo { color: var(--error); font-size: .85rem; font-weight: 500; }

/* Opciones grandes (radio / checkbox con aspecto de tarjeta) */
.opciones { display: flex; flex-wrap: wrap; gap: 10px; }
.opcion { position: relative; cursor: pointer; }
.opcion input { position: absolute; opacity: 0; pointer-events: none; }
.opcion > span {
    display: flex; flex-direction: column; gap: 2px; min-width: 150px; padding: 11px 14px; border: 1.5px solid var(--borde-fuerte);
    border-radius: var(--radio); background: var(--superficie); transition: border-color .15s, background .15s;
}
.opcion > span small { color: var(--texto-2); }
.opcion:hover > span { border-color: var(--texto-3); }
.opcion input:checked + span { border-color: var(--acento); background: var(--acento-suave); box-shadow: 0 0 0 1px var(--acento); }
.opcion input:focus-visible + span { outline: 3px solid rgba(138, 75, 42, .3); }
.opcion-ubicacion > span { flex-direction: row; align-items: center; gap: 8px; min-width: 130px; }
.opciones-tipo .opcion > span { min-width: 170px; }
.opciones-tipo .opcion > span .icon { margin-bottom: 4px; width: 22px; height: 22px; }
.opcion-ingreso input:checked + span { border-color: var(--ok); background: var(--ok-suave); box-shadow: 0 0 0 1px var(--ok); }
.opcion-venta input:checked + span { border-color: var(--info); background: var(--info-suave); box-shadow: 0 0 0 1px var(--info); }
.opcion-retiro input:checked + span { border-color: var(--aviso); background: var(--aviso-suave); box-shadow: 0 0 0 1px var(--aviso); }
.opcion-traslado input:checked + span { border-color: var(--morado); background: var(--morado-suave); box-shadow: 0 0 0 1px var(--morado); }

/* Chips de colores */
.chips { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; padding: 6px; border: 1px solid var(--borde-fuerte); border-radius: var(--radio-sm); background: var(--superficie); min-height: 44px; cursor: text; }
.chips:focus-within { border-color: var(--acento); box-shadow: 0 0 0 3px rgba(138, 75, 42, .15); }
.chips input { border: 0 !important; box-shadow: none !important; flex: 1; min-width: 180px; padding: 4px 6px; min-height: 30px; }
.chip { display: inline-flex; align-items: center; gap: 4px; background: var(--acento-suave); color: var(--acento); border-radius: 99px; padding: 3px 4px 3px 11px; font-weight: 600; font-size: .88rem; }
.chip button { border: 0; background: transparent; color: inherit; cursor: pointer; display: grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; }
.chip button:hover { background: rgba(138, 75, 42, .15); }
.chip .icon { width: 14px; height: 14px; }

/* Tallas */
.tallas { display: flex; flex-wrap: wrap; gap: 8px; }
.talla { position: relative; cursor: pointer; }
.talla input { position: absolute; opacity: 0; }
.talla span { display: grid; place-items: center; min-width: 52px; height: 42px; padding: 0 12px; border: 1.5px solid var(--borde-fuerte); border-radius: var(--radio-sm); font-weight: 700; background: var(--superficie); color: var(--texto-3); text-decoration: line-through; }
.talla input:checked + span { border-color: var(--acento); background: var(--acento-suave); color: var(--acento); text-decoration: none; }
.talla input:focus-visible + span { outline: 3px solid rgba(138, 75, 42, .3); }

/* Fotos */
.fotos { display: flex; flex-wrap: wrap; gap: 14px; }
.foto-slot { position: relative; width: 190px; height: 190px; border: 2px dashed var(--borde-fuerte); border-radius: var(--radio); display: grid; place-items: center; cursor: pointer; overflow: hidden; background: var(--superficie-2); }
.foto-slot:hover { border-color: var(--acento); }
.foto-slot input[type=file] { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.foto-vacia { display: grid; justify-items: center; gap: 4px; text-align: center; color: var(--texto-2); padding: 12px; pointer-events: none; }
.foto-vacia .icon { color: var(--texto-3); }
.foto-slot img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; pointer-events: none; }
.foto-slot.con-foto { border-style: solid; }
.foto-slot.con-foto .foto-vacia { visibility: hidden; }
.foto-quitar { position: absolute; top: 8px; right: 8px; z-index: 2; width: 30px; height: 30px; border-radius: 50%; border: 0; background: rgba(0, 0, 0, .6); color: #fff; display: grid; place-items: center; cursor: pointer; }

/* Bloques por color (fotos + cantidades) */
.opciones-modo .opcion { flex: 1 1 260px; }
.opciones-modo .opcion > span .icon { width: 22px; height: 22px; margin-bottom: 4px; }
.opciones-modo + [data-modo] { margin-top: 20px; }
.bloques-color { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 330px), 1fr)); gap: 14px; margin-top: 4px; }
.bloque-color { border: 1.5px solid var(--borde-fuerte); border-radius: var(--radio); background: var(--superficie-2); overflow: hidden; min-width: 0; }
.bloque-cabecera { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 8px 8px 14px; background: var(--superficie); border-bottom: 1px solid var(--borde); }
.bloque-cabecera strong { font-size: 1rem; }
.bloque-unico .bloque-cabecera strong { color: var(--texto-2); }
.bloque-cuerpo { padding: 14px; display: grid; gap: 14px; }
.bloques-color > .bloque-color > .fotos { padding: 14px; }
.fotos-sm { gap: 10px; }
.fotos-sm .foto-slot { width: calc(50% - 5px); height: auto; aspect-ratio: 1; }
.fotos-sm .foto-vacia small { display: none; }
.bloque-cant { display: grid; gap: 8px; }
.cant-tallas { display: flex; flex-wrap: wrap; gap: 8px; }
.cant-talla { display: grid; justify-items: center; gap: 4px; }
.cant-talla > span { font-weight: 700; font-size: .82rem; color: var(--texto-2); }
.cant-talla .contador input { width: 44px; }
.cant-talla .contador-btn { width: 30px; }
.colores-existentes { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 6px; font-size: .84rem; color: var(--texto-2); }
.chip-color { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px 2px 3px; border-radius: 99px; background: var(--superficie); border: 1px solid var(--borde); color: var(--texto); font-weight: 600; }
.chip-color img { width: 20px; height: 20px; border-radius: 50%; object-fit: cover; }
.color-fila { display: inline-flex; align-items: center; gap: 8px; }

/* ---------- Asistente (formularios por pasos) ---------- */

.asistente { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; }
/* Los hijos de una grilla no se encogen por defecto: sin esto, una tabla ancha estira toda la página en el celular. */
.asistente > *, .grid-2 > *, .grid-matrices > *, .grid-lateral > *, .ficha > *, .form > * { min-width: 0; }
.paso h2 { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; }
.paso-num { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; background: var(--acento); color: #fff; font-size: .9rem; flex: none; }
.barra-final {
    position: sticky; bottom: 0; z-index: 5; display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap;
    background: var(--superficie); border: 1px solid var(--borde); border-radius: var(--radio); box-shadow: var(--sombra-alta); padding: 14px 18px; margin-top: 8px;
}
.barra-final p { margin: 0; }
.barra-final strong { color: var(--texto); }
.producto-elegido { display: flex; align-items: center; gap: 12px; padding: 12px; border: 1px solid var(--borde); border-radius: var(--radio); background: var(--superficie-2); margin-bottom: 18px; }
.producto-elegido > div { flex: 1; display: grid; }

/* ---------- Inventario ---------- */

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 20px; }
.stat { display: grid; gap: 2px; padding: 16px 18px; background: var(--superficie); border: 1px solid var(--borde); border-radius: var(--radio); color: var(--texto); box-shadow: var(--sombra); }
.stat:hover { text-decoration: none; border-color: var(--borde-fuerte); }
.stat span { display: flex; align-items: center; gap: 6px; color: var(--texto-2); font-size: .85rem; font-weight: 600; }
.stat strong { font-size: 1.9rem; line-height: 1.1; font-variant-numeric: tabular-nums; }
.stat small { color: var(--texto-3); }
.stat.activo { border-color: var(--acento); box-shadow: 0 0 0 1px var(--acento); }
.stat-total strong { color: var(--acento); }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--borde); margin-bottom: 16px; overflow-x: auto; }
.tab { padding: 10px 16px; color: var(--texto-2); font-weight: 600; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tab:hover { color: var(--texto); text-decoration: none; }
.tab.activo { color: var(--acento); border-bottom-color: var(--acento); }

.filtros { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 16px; }
.filtros select { width: auto; }
.buscador { position: relative; flex: 1; min-width: 220px; }
.buscador .icon { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--texto-3); }
.buscador input { padding-left: 36px; }
.buscador-grande input { min-height: 48px; font-size: 1.05rem; }
.fecha { display: inline-flex; align-items: center; gap: 6px; color: var(--texto-2); font-size: .88rem; }
.fecha input { width: auto; }
.conteo { margin: 0 0 8px; font-size: .88rem; }

.lista-productos { display: grid; gap: 10px; }
.producto { background: var(--superficie); border: 1px solid var(--borde); border-radius: var(--radio); box-shadow: var(--sombra); overflow: hidden; }
.producto-fila { display: flex; align-items: center; gap: 14px; width: 100%; padding: 12px 14px; background: none; border: 0; font: inherit; color: inherit; text-align: left; cursor: pointer; }
.producto-fila:hover { background: var(--superficie-2); }
.producto-info { flex: 1; min-width: 0; display: grid; gap: 3px; }
.producto-info strong { font-size: 1rem; }
.producto-info small { color: var(--texto-2); }
.producto-cant { display: flex; gap: 6px; }
.por-talla { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 3px; }
.talla-cant { display: inline-flex; align-items: center; gap: 5px; padding: 1px 8px 1px 2px; border-radius: 6px; background: var(--ok-suave); color: var(--ok); font-size: .82rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.talla-cant b { display: grid; place-items: center; min-width: 26px; height: 20px; padding: 0 4px; border-radius: 4px; background: var(--superficie); color: var(--texto); font-size: .72rem; }
.talla-cant.cero { background: var(--superficie-2); color: var(--texto-3); }
.cant { display: grid; justify-items: center; min-width: 70px; padding: 4px 10px; border-radius: var(--radio-sm); background: var(--superficie-2); }
.cant small { font-size: .7rem; color: var(--texto-2); text-transform: uppercase; letter-spacing: .04em; }
.cant strong { font-size: 1.2rem; font-variant-numeric: tabular-nums; }
.cant-total { background: var(--acento-suave); }
.cant-total strong { color: var(--acento); }
.cant.cero strong { color: var(--error); opacity: .7; }
.chevron { color: var(--texto-3); transition: transform .2s; }
.producto-fila[aria-expanded=true] .chevron { transform: rotate(180deg); }
.producto-detalle { border-top: 1px solid var(--borde); padding: 16px; background: var(--superficie-2); display: grid; gap: 12px; }

.mini { display: grid; place-items: center; flex: none; background: var(--superficie-2); border: 1px solid var(--borde); border-radius: var(--radio-sm); overflow: hidden; color: var(--texto-3); }
.mini img { width: 100%; height: 100%; object-fit: cover; }
.mini-xs { width: 26px; height: 26px; border-radius: 5px; }
.mini-xs .icon { width: 14px; height: 14px; }
.mini-sm { width: 34px; height: 34px; }
.mini-md { width: 54px; height: 54px; }
.mini-lg { width: 100%; aspect-ratio: 1; }
.mini-lg .icon { width: 36px; height: 36px; }

/* Tabla color × talla */
.tabla-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.matriz { border-collapse: separate; border-spacing: 0; background: var(--superficie); border: 1px solid var(--borde); border-radius: var(--radio-sm); min-width: 100%; }
.matriz th, .matriz td { padding: 8px 12px; border-bottom: 1px solid var(--borde); }
.matriz thead th { background: var(--superficie-2); font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--texto-2); }
.matriz tbody th { text-align: left; font-weight: 600; white-space: nowrap; }
.matriz tr:last-child > * { border-bottom: 0; }
.matriz tfoot th, .matriz tfoot td { background: var(--superficie-2); font-weight: 700; border-top: 1px solid var(--borde); border-bottom: 0; }
.matriz td.cero strong { color: var(--texto-3); font-weight: 500; }
/* La columna de colores queda fija al desplazar la tabla hacia el costado (muchas tallas en celular). */
.matriz tr > th:first-child { position: sticky; left: 0; z-index: 1; background: var(--superficie); box-shadow: 1px 0 0 var(--borde); }
.matriz thead tr > th:first-child, .matriz tfoot tr > th:first-child { background: var(--superficie-2); }
.tabla-scroll + .campo { margin-top: 16px; }
.matriz .total { font-weight: 700; background: var(--superficie-2); }
.desglose { display: flex; flex-wrap: wrap; gap: 0 6px; justify-content: flex-end; color: var(--texto-2); font-size: .72rem; }
.desglose span { white-space: nowrap; }
.leyenda { display: flex; gap: 14px; color: var(--texto-3); font-size: .78rem; margin: 6px 0 0; }

/* Tabla de entrada de cantidades */
.matriz-entrada td { text-align: center; vertical-align: top; }
.contador { display: inline-flex; align-items: center; border: 1px solid var(--borde-fuerte); border-radius: var(--radio-sm); overflow: hidden; background: var(--superficie); }
.contador input { width: 56px; border: 0 !important; border-radius: 0; text-align: center; padding: 6px 2px; min-height: 38px; font-weight: 700; font-size: 1rem; -moz-appearance: textfield; }
.contador input::-webkit-outer-spin-button, .contador input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.contador input:focus { box-shadow: none; background: var(--acento-suave); }
.contador-btn { width: 34px; min-height: 38px; border: 0; background: var(--superficie-2); color: var(--texto-2); font-size: 1.1rem; cursor: pointer; }
.contador-btn:hover { background: var(--acento-suave); color: var(--acento); }
.contador.con-valor { border-color: var(--acento); }
.contador.excede { border-color: var(--error); box-shadow: 0 0 0 2px var(--error-suave); }
.disp { display: block; margin-top: 4px; color: var(--texto-2); font-size: .74rem; }
.disp.cero { color: var(--error); }

/* ---------- Ficha de producto ---------- */

.ficha { display: grid; grid-template-columns: minmax(0, 340px) minmax(0, 1fr); gap: 20px; align-items: start; }
.colores-galeria { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 200px), 1fr)); gap: 14px; align-items: start; }
.color-card { margin: 0; background: var(--superficie); border: 1px solid var(--borde); border-radius: var(--radio); overflow: hidden; box-shadow: var(--sombra); }
.color-fotos { display: grid; grid-template-columns: 1fr; gap: 2px; background: var(--borde); }
.color-fotos.dos { grid-template-columns: 1fr 1fr; }
.color-fotos img { display: block; width: 100%; aspect-ratio: 1; object-fit: cover; }
.color-fotos .foto-placeholder { border: 0; border-radius: 0; aspect-ratio: 1; background: var(--superficie-2); }
.color-card figcaption { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 10px 12px; }
.ficha-fotos { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.ficha-fotos a:only-child { grid-column: 1 / -1; }
.ficha-fotos img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: var(--radio); border: 1px solid var(--borde); display: block; }
.foto-placeholder { grid-column: 1 / -1; aspect-ratio: 4 / 3; display: grid; place-content: center; justify-items: center; gap: 6px; background: var(--superficie); border: 1px dashed var(--borde-fuerte); border-radius: var(--radio); color: var(--texto-3); }
.datos { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; margin: 0 0 18px; }
.datos dt { font-size: .78rem; color: var(--texto-2); text-transform: uppercase; letter-spacing: .04em; }
.datos dd { margin: 2px 0 0; font-weight: 600; }
.grid-matrices { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(300px, 100%), 1fr)); gap: 16px; }
.grid-matrices .card + .card { margin-top: 0; }
.plegable { margin-top: 20px; }
.plegable summary { cursor: pointer; font-weight: 600; display: flex; align-items: center; gap: 8px; list-style: none; }
.plegable summary::-webkit-details-marker { display: none; }
.plegable[open] summary { margin-bottom: 16px; }
.zona-peligro { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-top: 32px; padding: 16px 18px; border: 1px solid #f0c8c3; border-radius: var(--radio); background: #fffafa; }
.zona-peligro p { margin: 2px 0 0; }

/* ---------- Movimientos ---------- */

.grid-tarjetas { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 14px; }
.tarjeta-producto { display: grid; gap: 4px; padding: 10px; background: var(--superficie); border: 1px solid var(--borde); border-radius: var(--radio); color: var(--texto); box-shadow: var(--sombra); }
.tarjeta-producto:hover { border-color: var(--acento); text-decoration: none; }
.tarjeta-producto small { color: var(--texto-2); }
.tarjeta-producto .mini { margin-bottom: 6px; }
.disponible { font-size: .8rem; font-weight: 600; color: var(--ok); }
.disponible.cero { color: var(--error); }

.tabla { width: 100%; border-collapse: collapse; }
.tabla th { text-align: left; font-size: .76rem; text-transform: uppercase; letter-spacing: .04em; color: var(--texto-2); background: var(--superficie-2); padding: 10px 14px; border-bottom: 1px solid var(--borde); white-space: nowrap; }
.tabla td { padding: 10px 14px; border-bottom: 1px solid var(--borde); vertical-align: middle; }
.tabla tr:last-child td { border-bottom: 0; }
.tabla tr.inactivo td { opacity: .55; }
.celda-producto { display: flex; align-items: center; gap: 8px; color: var(--texto); font-weight: 600; }
.nota-celda { max-width: 280px; color: var(--texto-2); font-size: .88rem; }
.tipo { display: inline-block; padding: 2px 10px; border-radius: 99px; font-size: .78rem; font-weight: 700; }
.tipo-ingreso { background: var(--ok-suave); color: var(--ok); }
.tipo-venta { background: var(--info-suave); color: var(--info); }
.tipo-retiro { background: var(--aviso-suave); color: var(--aviso); }
.tipo-traslado { background: var(--morado-suave); color: var(--morado); }
.rol { display: inline-block; padding: 2px 10px; border-radius: 99px; font-size: .78rem; font-weight: 700; background: var(--superficie-2); color: var(--texto-2); }
.rol-admin { background: var(--acento-suave); color: var(--acento); }
.estado-ok { color: var(--ok); font-weight: 600; }
.paginacion { display: flex; justify-content: center; align-items: center; gap: 14px; margin-top: 16px; }

.grid-lateral { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 16px; align-items: start; }
.grid-lateral .card + .card { margin-top: 0; }
.detalle-error { text-align: left; white-space: pre-wrap; font-size: .75rem; max-height: 300px; overflow: auto; background: var(--superficie-2); padding: 10px; border-radius: var(--radio-sm); width: 100%; }

/* ---------- Celular ---------- */

@media (max-width: 900px) {
    .sidebar { position: fixed; left: 0; top: 0; z-index: 30; transform: translateX(-100%); transition: transform .2s; box-shadow: var(--sombra-alta); }
    .menu-abierto .sidebar { transform: none; }
    .menu-abierto .velo { display: block; position: fixed; inset: 0; z-index: 20; background: rgba(0, 0, 0, .35); }
    .barra-movil { display: flex; align-items: center; justify-content: space-between; gap: 8px; position: sticky; top: 0; z-index: 10; background: var(--superficie); border-bottom: 1px solid var(--borde); padding: 8px 10px; }
    .barra-movil strong { flex: 1; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
    .contenido { padding: 18px 16px 110px; }
    .cabecera h1 { display: none; }
    .cabecera .volver + h1 { display: block; font-size: 1.3rem; }
    .grid-2, .ficha, .grid-lateral { grid-template-columns: minmax(0, 1fr); }
    .datos { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 640px) {
    .producto-fila { flex-wrap: wrap; }
    .producto-info { flex-basis: calc(100% - 100px); }
    .producto-cant { width: 100%; }
    .cant { flex: 1; min-width: 0; }
    .chevron { display: none; }
    .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .stat-total { grid-column: 1 / -1; }
    .cabecera .acciones { width: 100%; }
    .cabecera .acciones .btn { flex: 1 1 auto; }
    .stat strong { font-size: 1.5rem; }
    .opciones .opcion { flex: 1 1 140px; }
    .opcion > span { min-width: 0; }
    .opciones-tipo .opcion { flex: 1 1 calc(50% - 10px); }
    .opciones-tipo .opcion > span { min-width: 0; }
    .filtros select, .filtros .btn { flex: 1 1 auto; }
    .foto-slot { width: calc(50% - 7px); height: auto; aspect-ratio: 1; }
    .barra-final { position: fixed; left: 0; right: 0; bottom: 0; border-radius: 0; margin: 0; padding: 12px 16px; }
    .barra-final .btn-lg { flex: 1; }
    .zona-peligro { flex-direction: column; align-items: stretch; }
    .contador input { width: 44px; }
    .contador-btn { width: 30px; }
}
