/* Estilos específicos de la vista: inventario (Productos) y movimientos (kardex).
   Prefijos: .inv-* (productos y modales compartidos) · .mov-* (kardex). */

/* ───────── Comunes ───────── */
.inv-sin-anim, .inv-sin-anim .stagger > * { animation: none !important; }
.inv-sr { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.inv-sin-dato { color: var(--muted); font-style: italic; }
.inv-vacio-btn { margin-top: 14px; }

/* Encabezado: el subtítulo lleva cifras */
.inv-vista .page-header p, .mov-vista .page-header p { font-variant-numeric: tabular-nums; }
.mov-vista .page-header p strong { color: var(--ink); font-weight: 600; }
.inv-vista .page-header .eyebrow, .mov-vista .page-header .eyebrow { margin-bottom: 6px; color: var(--brass); }

/* ───────── KPIs compactos ───────── */
.inv-kpis { gap: 14px; margin-bottom: 26px; }
.inv-kpi { padding: 16px 18px; }
.inv-kpi .kpi-label { font-size: .68rem; padding-right: 40px; }
.inv-kpi .kpi-value { font-size: 1.6rem; margin-top: 6px; white-space: nowrap; }
.inv-kpi .kpi-foot { font-size: .8rem; margin-top: 4px; }
.inv-kpi-alerta { color: var(--amber); font-weight: 600; }
.inv-kpi-icono {
  position: absolute; right: 14px; top: 14px; width: 32px; height: 32px; border-radius: 50%;
  display: grid; place-items: center;
}
.inv-kpi-icono svg { width: 16px; height: 16px; }

/* Icono circular por tipo (KPIs, modales, resumen) */
.tipo-fragancia.inv-kpi-icono, .tipo-fragancia.inv-det-icono { background: var(--c-fragancia-soft); color: var(--c-fragancia); }
.tipo-frasco.inv-kpi-icono, .tipo-frasco.inv-det-icono { background: var(--c-frasco-soft); color: var(--c-frasco); }
.tipo-tercero.inv-kpi-icono, .tipo-tercero.inv-det-icono { background: var(--c-tercero-soft); color: var(--c-tercero); }

/* ───────── Pestañas y barra de herramientas ───────── */
.inv-tabs { margin-bottom: 16px; }
.inv-tabs button.active .count { background: var(--brass-soft); color: #6e4f1c; }
.inv-search { display: block; flex: 1 1 260px; max-width: 440px; }
.inv-search .input { -webkit-appearance: none; appearance: none; }
.inv-search .input::-webkit-search-cancel-button { cursor: pointer; }
.inv-resultado { margin-left: auto; font-variant-numeric: tabular-nums; }

.inv-chip {
  display: inline-flex; align-items: center; gap: 8px; height: 42px; padding: 0 15px;
  border-radius: 999px; border: 1px solid var(--line-2); background: var(--card); color: var(--ink-2);
  font: 600 .86rem var(--font-body); cursor: pointer; white-space: nowrap;
  transition: background .2s, border-color .2s, color .2s;
}
button.inv-chip:hover { border-color: var(--ink-2); }
.inv-chip svg { flex: none; opacity: .8; }
.inv-chip[aria-pressed="true"] { background: var(--amber-soft); border-color: #e7c98d; color: var(--amber); }
.inv-chip-count { min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px; display: grid; place-items: center; font-size: .72rem; background: var(--amber-soft); color: var(--amber); font-variant-numeric: tabular-nums; }
.inv-chip[aria-pressed="true"] .inv-chip-count { background: var(--amber); color: #fff; }
.inv-chip.is-filtro { cursor: default; background: var(--brass-soft); border-color: #e2c993; color: #6e4f1c; padding-right: 5px; max-width: 100%; }
.inv-chip.is-filtro strong { font-weight: 700; overflow: hidden; text-overflow: ellipsis; max-width: 240px; }
.inv-chip.is-filtro button {
  width: 30px; height: 30px; border-radius: 50%; border: 0; background: transparent; color: inherit;
  display: grid; place-items: center; cursor: pointer; transition: background .15s;
}
.inv-chip.is-filtro button:hover { background: rgba(110, 79, 28, .12); }
.inv-chip.is-filtro button svg { width: 15px; height: 15px; }

/* ───────── Tabla de productos ───────── */
.inv-tabla td { padding-top: 14px; padding-bottom: 14px; }
.inv-c-prod { min-width: 220px; }
.inv-nombre {
  border: 0; background: none; padding: 0; margin: 0; text-align: left; cursor: pointer;
  font: 600 .95rem/1.3 var(--font-body); color: var(--ink);
  background-image: linear-gradient(var(--brass), var(--brass)); background-size: 0 1px; background-repeat: no-repeat; background-position: 0 100%;
  transition: background-size .25s var(--ease), color .2s;
}
.inv-nombre:hover, .inv-nombre:focus-visible { color: #6e4f1c; background-size: 100% 1px; outline: none; }
.inv-fila-agotada .inv-nombre { color: var(--ink-2); }

.inv-stock { display: grid; grid-template-columns: auto; gap: 4px; min-width: 120px; max-width: 160px; }
.inv-stock-val { font-weight: 600; white-space: nowrap; }
.inv-stock .cell-sub { font-size: .74rem; }
.inv-bar { position: relative; height: 5px; }
.inv-bar.is-bajo > span { background: linear-gradient(90deg, var(--amber), #c88a2c); }
.inv-bar.is-agotado > span { background: var(--oxblood); }
.inv-bar-min { position: absolute; top: 0; bottom: 0; width: 2px; margin-left: -1px; background: rgba(29, 25, 21, .35); }

.inv-c-precio { white-space: nowrap; }
.inv-libre { color: var(--muted); font-style: italic; border-bottom: 1px dotted var(--line-2); cursor: help; }

.inv-acciones { display: inline-flex; align-items: center; justify-content: flex-end; gap: 2px; }
.inv-btn-ingreso { margin-right: 4px; }
.inv-btn-vender { color: var(--brass); }
.inv-btn-vender:hover:not(:disabled) { --b: var(--brass-soft); }
.inv-acciones .btn svg { width: 16px; height: 16px; }

/* ───────── Formulario de producto (modal) ───────── */
.inv-form { display: flex; flex-direction: column; gap: 18px; }
.inv-form [data-errores]:empty { display: none; }
.inv-form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 16px; }
.inv-span-2 { grid-column: 1 / -1; }
.inv-seg-tipo { display: flex; width: 100%; }
.inv-seg-tipo button { flex: 1; justify-content: center; padding: 9px 10px; }
.inv-seg-tipo button[data-tipo="fragancia"].active { color: var(--c-fragancia); }
.inv-seg-tipo button[data-tipo="frasco"].active { color: var(--c-frasco); }
.inv-seg-tipo button[data-tipo="tercero"].active { color: var(--c-tercero); }
.inv-form-tipo { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 10px 12px; border-radius: 10px; background: var(--paper-2); border: 1px solid var(--line); }
.inv-fieldset { border: 0; margin: 0; padding: 16px 0 0; border-top: 1px solid var(--line); min-width: 0; }
.inv-fieldset legend { padding: 0 10px 0 0; margin-bottom: 12px; color: var(--brass); }
.inv-stock-fijo { display: flex; align-items: center; gap: 10px; height: 42px; font-weight: 700; font-size: 1.05rem; }
.inv-form .hint strong { color: var(--sage); }
.inv-margen-neg, .inv-form .inv-margen-neg strong { color: var(--oxblood); }

/* ───────── Modal de stock ───────── */
.inv-sm { display: flex; flex-direction: column; gap: 16px; }
.inv-sm [data-errores]:empty { display: none; }
.inv-sm-head {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 14px 16px; border-radius: 12px; background: var(--paper-2); border: 1px solid var(--line);
}
.inv-sm-prod { display: flex; align-items: center; gap: 12px; min-width: 0; }
.inv-sm-actual { text-align: right; flex: none; }
.inv-sm-num { font-size: 1.8rem; line-height: 1.1; margin: 2px 0 6px; }
.inv-sm-modos { display: flex; flex-direction: column; gap: 8px; }
.inv-sm-modos .segmented { display: flex; }
.inv-sm-modos .segmented button { flex: 1; justify-content: center; padding: 9px 10px; }
.inv-sm-ayuda { margin: 0; font-size: .82rem; color: var(--muted); }
.inv-sm .input-group .affix:last-child { min-width: 58px; font-size: 1rem; }

.inv-det-icono { width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; flex: none; }
.inv-det-icono svg { width: 20px; height: 20px; }

.inv-preview {
  display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap;
  padding: 12px 14px; border-radius: 10px; border: 1px dashed var(--line-2); background: #fffdf9;
  transition: background .2s, border-color .2s;
}
.inv-preview strong { font-family: var(--font-display); font-size: 1.3rem; font-weight: 500; }
.inv-preview-delta { margin-left: auto; font-weight: 700; padding: 2px 10px; border-radius: 999px; font-size: .85rem; }
.inv-preview.is-pos { border-color: #c4d6bb; background: var(--sage-soft); }
.inv-preview.is-pos .inv-preview-delta { background: var(--sage); color: #fff; }
.inv-preview.is-neg { border-color: #e9c4c6; background: var(--oxblood-soft); }
.inv-preview.is-neg .inv-preview-delta { background: var(--oxblood); color: #fff; }
.inv-preview.is-warn { border-color: #efd8a8; background: var(--amber-soft); color: var(--amber); font-weight: 600; }
.inv-preview.is-warn strong { font-family: var(--font-body); font-size: .95rem; font-weight: 700; }

/* ───────── Modal de detalle ───────── */
.inv-det { display: flex; flex-direction: column; gap: 20px; }
.inv-det-head { display: flex; align-items: flex-start; gap: 16px; }
.inv-det-head .inv-det-icono { width: 52px; height: 52px; }
.inv-det-head .inv-det-icono svg { width: 24px; height: 24px; }
.inv-det-badges { gap: 6px; margin-bottom: 6px; }
.inv-det-nombre { font-size: 1.5rem; line-height: 1.15; }
.inv-det-stock { text-align: right; flex: none; padding-left: 16px; border-left: 1px solid var(--line); }
.inv-det-stock-num { font-size: 2rem; line-height: 1.1; margin: 2px 0; }
.inv-det-datos {
  margin: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: var(--line); gap: 1px;
}
.inv-det-datos > div { background: var(--card); padding: 12px 14px; }
.inv-det-datos dt { font-size: .68rem; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); font-weight: 600; }
.inv-det-datos dd { margin: 4px 0 0; font-weight: 600; }
.inv-det-movs-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: -8px; }
.inv-det-movs { border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.inv-det-movs .empty { padding: 26px 16px; }
.inv-movs-simple { list-style: none; margin: 0; padding: 0; }
.inv-movs-simple li { display: flex; gap: 12px; justify-content: space-between; padding: 10px 14px; border-bottom: 1px solid var(--line); }

/* ═════════════ Movimientos (kardex) ═════════════ */
.mov-toolbar .mov-select { display: block; flex: 0 1 200px; min-width: 160px; }

/* Resumen del producto filtrado */
.mov-resumen { margin-bottom: 20px; }
.mov-res-card { display: flex; align-items: center; justify-content: space-between; gap: 20px; flex-wrap: wrap; padding: 16px 20px; }
.mov-res-prod { display: flex; align-items: center; gap: 14px; min-width: 220px; }
.mov-res-prod .cell-title { font-family: var(--font-display); font-size: 1.25rem; font-weight: 500; }
.mov-res-badges { gap: 6px; margin-bottom: 4px; }
.mov-res-datos { display: flex; gap: 28px; flex-wrap: wrap; }
.mov-res-item .kpi-label { font-size: .66rem; }
.mov-res-valor { font-family: var(--font-display); font-size: 1.35rem; margin-top: 2px; white-space: nowrap; }
.mov-res-valor.is-pos { color: var(--sage); }
.mov-res-valor.is-neg { color: var(--oxblood); }

/* Tabla */
.mov-tabla td { padding-top: 11px; padding-bottom: 11px; }
.mov-c-fecha { white-space: nowrap; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.mov-c-prod { min-width: 200px; }
.mov-tipo-sm { display: flex; align-items: center; gap: 8px; margin-top: 4px; }
.mov-tipo-sm .badge { font-size: .66rem; padding: 2px 7px; }
.mov-tipo-sm .badge svg { width: 11px; height: 11px; }
.mov-c-delta, .mov-c-saldo { white-space: nowrap; }
.mov-c-saldo { color: var(--ink-2); }
.mov-vacio { color: var(--line-2); }
.mov-vacio.small { color: var(--muted); font-style: italic; }

.mov-delta { font-weight: 700; }
.mov-delta.is-pos { color: var(--sage); }
.mov-delta.is-neg { color: var(--oxblood); }

/* Badges por motivo: entradas en salvia, ajustes en ámbar, ventas en tinta, anulaciones en azul frasco */
.mov-badge.mov-inicial { background: var(--brass-soft); color: #6e4f1c; }
.mov-badge.mov-ingreso { background: var(--sage-soft); color: var(--sage); }
.mov-badge.mov-ajuste { background: var(--amber-soft); color: var(--amber); }
.mov-badge.mov-venta { background: var(--paper-2); color: var(--ink); }
.mov-badge.mov-anulacion { background: var(--c-frasco-soft); color: var(--c-frasco); }

.mov-ref {
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 9px; margin: -4px 0;
  border: 1px solid transparent; border-radius: 8px; background: transparent; cursor: pointer;
  font: 600 .86rem var(--font-body); color: #6e4f1c; white-space: nowrap; transition: background .15s, border-color .15s;
}
.mov-ref svg { width: 15px; height: 15px; color: var(--brass); }
.mov-ref:hover, .mov-ref:focus-visible { background: var(--brass-soft); border-color: #e2c993; outline: none; }
.mov-ref-anulada { font-size: .68rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--oxblood); background: var(--oxblood-soft); padding: 1px 6px; border-radius: 999px; }

.mov-c-nota { max-width: 260px; }
.mov-nota { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink-2); font-size: .86rem; }
.mov-nota-sub { max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-top: 3px; }

.mov-compacta th, .mov-compacta td { padding: 10px 12px; }
.mov-compacta .mov-c-fecha { font-size: .86rem; }

.mov-mas { display: flex; align-items: center; justify-content: center; gap: 14px; margin-top: 18px; }
.mov-mas:empty { display: none; }
.mov-mas .btn .muted { font-weight: 500; }

/* ───────── Responsive ───────── */
@media (max-width: 1100px) {
  .inv-kpi .kpi-value { font-size: 1.45rem; }
}

@media (max-width: 860px) {
  .inv-kpis { gap: 10px; margin-bottom: 20px; }
  .inv-kpi { padding: 14px; }
  .inv-kpi .kpi-value { font-size: 1.3rem; }
  .inv-kpi-icono { width: 28px; height: 28px; right: 10px; top: 10px; }
  .inv-vista .page-actions .btn-ghost { display: none; }
  .inv-search { flex-basis: 100%; max-width: none; }
  .inv-resultado { margin-left: 0; }

  /* Tabla de productos → tarjetas */
  .inv-tabla thead { display: none; }
  .inv-tabla, .inv-tabla tbody { display: block; }
  .inv-tabla tr {
    display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px 14px; padding: 16px;
    border-bottom: 1px solid var(--line);
    grid-template-areas: "prod prod" "tipo estado" "stock precio" "acc acc";
  }
  .inv-tabla tr:last-child { border-bottom: 0; }
  .inv-tabla td { display: block; padding: 0; border: 0; }
  .inv-tabla .inv-c-prod { grid-area: prod; min-width: 0; }
  .inv-tabla .inv-c-tipo { grid-area: tipo; }
  .inv-tabla .inv-c-estado { grid-area: estado; text-align: right; }
  .inv-tabla .inv-c-stock { grid-area: stock; }
  .inv-tabla .inv-c-precio { grid-area: precio; align-self: end; }
  .inv-tabla .inv-c-acc { grid-area: acc; text-align: left; padding-top: 8px; border-top: 1px dashed var(--line); }
  .inv-tabla td[data-label]::before { content: attr(data-label); display: block; font-size: .64rem; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); font-weight: 700; margin-bottom: 4px; }
  .inv-stock { max-width: none; }
  .inv-acciones { display: flex; width: 100%; justify-content: flex-start; }
  .inv-acciones .inv-btn-ingreso { order: -1; margin-right: auto; }

  .inv-form-grid { grid-template-columns: 1fr; }
  .inv-seg-tipo button, .inv-sm-modos .segmented button { padding: 9px 6px; font-size: .8rem; }
  .inv-det-head { flex-wrap: wrap; }
  .inv-det-stock { flex-basis: 100%; text-align: left; padding: 12px 0 0; border-left: 0; border-top: 1px solid var(--line); }
  .inv-sm-num { font-size: 1.5rem; }

  /* Kardex → tarjetas */
  .mov-toolbar .mov-select { flex: 1 1 140px; }
  .mov-tabla:not(.mov-compacta) thead { display: none; }
  .mov-tabla:not(.mov-compacta), .mov-tabla:not(.mov-compacta) tbody { display: block; }
  .mov-tabla:not(.mov-compacta) tr {
    display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px 14px; padding: 14px 16px;
    border-bottom: 1px solid var(--line);
    grid-template-areas: "prod delta" "motivo saldo" "fecha ref" "nota nota";
  }
  .mov-tabla:not(.mov-compacta) tr:last-child { border-bottom: 0; }
  .mov-tabla:not(.mov-compacta) td { display: block; padding: 0; border: 0; }
  .mov-tabla:not(.mov-compacta) .mov-c-prod { grid-area: prod; min-width: 0; }
  .mov-tabla:not(.mov-compacta) .mov-c-delta { grid-area: delta; font-size: 1.05rem; }
  .mov-tabla:not(.mov-compacta) .mov-c-motivo { grid-area: motivo; }
  .mov-tabla:not(.mov-compacta) .mov-c-saldo { grid-area: saldo; font-size: .84rem; }
  .mov-tabla:not(.mov-compacta) .mov-c-saldo::before { content: "Queda "; color: var(--muted); }
  .mov-tabla:not(.mov-compacta) .mov-c-fecha { grid-area: fecha; font-size: .82rem; color: var(--muted); }
  .mov-tabla:not(.mov-compacta) .mov-c-ref { grid-area: ref; text-align: right; }
  .mov-tabla:not(.mov-compacta) .mov-c-nota { grid-area: nota; max-width: none; }
  .mov-tabla:not(.mov-compacta) .mov-c-nota:has(.mov-vacio) { display: none; }
  .mov-tabla:not(.mov-compacta) .mov-c-ref:has(.mov-vacio) { visibility: hidden; }
  .mov-nota { white-space: normal; }
  .mov-res-datos { gap: 18px; }
  .mov-mas { flex-direction: column; gap: 10px; }
}

@media (max-width: 520px) {
  .inv-kpi .kpi-label { font-size: .62rem; letter-spacing: .1em; }
  .inv-kpi .kpi-value { font-size: 1.15rem; }
  .inv-sm-head { flex-direction: column; align-items: flex-start; }
  .inv-sm-actual { text-align: left; }
  .inv-chip.is-filtro strong { max-width: 150px; }
}
