/* Module Inventory (agent A9) — ajustements et inventaires. Classes préfixées « inv- ». Couleurs : variables du socle uniquement. */

/* ------------------------------------------------------------------ Structure des onglets (liens) */
.inv-tabset > .tab-panels > .inv-panel { gap: .75rem; }
.inv-panel > .inv-notice, .inv-grid > .inv-notice { flex-shrink: 0; padding: .6rem .9rem; align-items: center; }
.inv-notice > .ph { margin-top: 0; font-size: 1.15rem; }
.inv-tab-pending { background: var(--brand); color: var(--on-brand); }
.inv-center { display: grid; place-items: center; }
.inv-pos { color: var(--success); }
.inv-neg { color: var(--danger); }
.inv-ok { color: var(--text-3); }
.inv-stats { flex-shrink: 0; }

@media (min-width: 768px) {
  .inv-grid, .inv-hist, .inv-freq, .inv-count { display: flex; flex-direction: column; gap: .75rem; min-height: 0; flex: 1 1 auto; }
  .inv-grid > *, .inv-hist > *, .inv-freq > *, .inv-count > * { flex-shrink: 0; }
  .inv-grid > .dv.fill, .inv-hist > .dv.fill, .inv-freq > .dv.fill, .inv-count > .dv.fill { flex: 1 1 auto; min-height: 0; }
}
@media (max-width: 767px) {
  .inv-grid, .inv-hist, .inv-freq, .inv-count { display: flex; flex-direction: column; gap: .75rem; }
}

/* ------------------------------------------------------------------ Barre du magasin */
.inv-bar { display: flex; align-items: center; gap: .75rem 1.25rem; flex-wrap: wrap; padding: .6rem .8rem; border: 1px solid var(--line); border-radius: var(--r-panel, 14px); background: var(--bg-elev); }
.inv-wh { display: flex; align-items: center; gap: .6rem; min-width: 0; flex: 1 1 280px; max-width: 460px; }
.inv-wh-icon { display: grid; place-items: center; width: 2.4rem; height: 2.4rem; flex-shrink: 0; border-radius: 10px; background: var(--brand-soft); color: var(--brand-ink); font-size: 1.25rem; }
.inv-wh-select { font-weight: 700; min-width: 0; }
.inv-bar-stats { display: flex; align-items: center; gap: 1.25rem; }
.inv-kpi { display: flex; flex-direction: column; line-height: 1.15; color: inherit; text-decoration: none; }
a.inv-kpi:hover .inv-kpi-value { color: var(--brand-ink); }
.inv-kpi-value { font-size: 1.15rem; font-weight: 800; color: var(--text); }
.inv-kpi-label { font-size: .72rem; font-weight: 600; color: var(--text-3); text-transform: uppercase; letter-spacing: .04em; }
.inv-default-reason { display: flex; align-items: center; gap: .5rem; margin-left: auto; }
.inv-default-label { font-size: .8rem; font-weight: 600; color: var(--text-2); white-space: nowrap; }
.inv-default-reason .select { min-width: 12rem; }
.inv-keys { display: inline-flex; align-items: center; gap: .3rem; margin-left: .6rem; }

/* ------------------------------------------------------------------ Grille de saisie */
.inv-table td { vertical-align: middle; padding-block: .4rem; }
.inv-table .cell-sub { margin-top: 0; }
.inv-col-real { width: 9rem; }
.inv-col-diff { width: 6rem; }
.inv-col-reason { width: 15rem; }
.inv-real { width: 7rem; margin-left: auto; text-align: right; font-weight: 700; }
.inv-real::placeholder { color: var(--text-3); font-weight: 500; opacity: .75; }
.inv-real::-webkit-outer-spin-button, .inv-real::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.inv-real { -moz-appearance: textfield; appearance: textfield; }
.inv-diff { font-weight: 800; color: var(--text-3); }
.inv-diff.inv-pos { color: var(--success); }
.inv-diff.inv-neg { color: var(--danger); }
.inv-diff.inv-ok { color: var(--text-3); }
.inv-reason { width: 100%; min-width: 10rem; }
.inv-warn { display: block; margin-top: .25rem; font-size: .76rem; font-weight: 600; line-height: 1.3; color: var(--danger); white-space: normal; }
.inv-warn[hidden] { display: none; }
.inv-row-actions { display: inline-flex; align-items: center; gap: .1rem; }
tr[data-inv-row].is-modified > td { background: color-mix(in srgb, var(--brand-soft) 55%, transparent); }
tr[data-inv-row].is-modified > td:first-child { box-shadow: inset 3px 0 0 var(--brand); }
tr[data-inv-row].is-modified .inv-real { border-color: var(--brand); background: var(--bg-elev); }
tr[data-inv-row].is-blocked > td { background: var(--danger-soft); }
tr[data-inv-row].is-blocked > td:first-child { box-shadow: inset 3px 0 0 var(--danger); }
tr[data-inv-row].is-blocked .inv-real { border-color: var(--danger); }
.inv-row-muted > td { opacity: .62; }
.inv-row-error > td { background: var(--danger-soft); }
.inv-type { text-decoration: none; }
.inv-cell-item { min-width: 14rem; }
.inv-cell-reason { min-width: 10rem; max-width: 22rem; white-space: normal; }
.nowrap { white-space: nowrap; }

/* Cartes (téléphone) */
.inv-cards { --dv-card-min: 290px; }
.inv-card { display: flex; flex-direction: column; gap: .65rem; padding: .85rem .9rem; border: 1px solid var(--line); border-radius: var(--r-panel, 14px); background: var(--bg-elev); min-width: 0; }
.inv-card.is-modified, .inv-card.is-counted.has-diff { border-color: var(--brand); box-shadow: inset 3px 0 0 var(--brand); }
.inv-card.is-blocked { border-color: var(--danger); box-shadow: inset 3px 0 0 var(--danger); }
.inv-card.is-counted:not(.has-diff) { box-shadow: inset 3px 0 0 var(--success-strong, var(--success)); }
.inv-card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: .6rem; }
.inv-card-title { display: flex; flex-direction: column; min-width: 0; }
.inv-card-body { display: grid; grid-template-columns: 1fr 1.2fr 1fr; gap: .6rem; align-items: end; }
.inv-card-cell { display: flex; flex-direction: column; gap: .2rem; min-width: 0; }
.inv-card-cell:last-child { text-align: right; align-items: flex-end; }
.inv-card-label { font-size: .7rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--text-3); }
.inv-card-num { font-size: 1.2rem; font-weight: 800; min-height: var(--tap, 44px); display: flex; align-items: center; }
.inv-card .inv-real { width: 100%; margin: 0; text-align: center; font-size: 1.15rem; min-height: var(--tap, 44px); }
.inv-card-foot { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.inv-card-foot > [data-inv-reason-slot] { flex: 1 1 10rem; min-width: 0; }
.inv-card-foot > [data-inv-reason-slot]:empty { display: none; }
.inv-card-foot > .inv-warn { flex: 1 1 100%; margin: 0; }
.inv-card-more { margin-left: auto; }
.inv-card-note { width: 100%; }

/* ------------------------------------------------------------------ Barre de validation du lot */
.inv-pending { display: flex; align-items: center; justify-content: space-between; gap: .75rem 1.25rem; flex-wrap: wrap; padding: .65rem .9rem; border: 1px solid var(--line); border-radius: var(--r-panel, 14px); background: var(--bg-elev); transition: border-color .2s, box-shadow .2s; }
.inv-pending.is-on { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.inv-pending.has-error { border-color: var(--danger); box-shadow: 0 0 0 3px var(--danger-soft); }
.inv-pending-info { display: flex; align-items: center; gap: .75rem; min-width: 0; }
.inv-pending-icon { display: grid; place-items: center; width: 2.3rem; height: 2.3rem; flex-shrink: 0; border-radius: 50%; background: var(--bg-sunken); color: var(--text-2); font-size: 1.2rem; }
.inv-pending.is-on .inv-pending-icon { background: var(--brand-soft); color: var(--brand-ink); }
.inv-pending-text { display: flex; flex-direction: column; line-height: 1.3; min-width: 0; }
.inv-pending-actions { display: flex; align-items: center; gap: .5rem; margin-left: auto; }
@media (max-width: 767px) {
  .inv-pending { position: sticky; bottom: calc(var(--tabbar-h, 60px) + var(--safe-bottom, 0px) + .5rem); z-index: 14; box-shadow: var(--shadow-pop); }
  html.is-kb-open .inv-pending { bottom: .5rem; }
  .inv-pending-actions { flex: 1 1 100%; }
  .inv-pending-actions > .btn-primary { flex: 1; }
  .inv-bar { padding: .55rem .65rem; }
  .inv-wh { flex-basis: 100%; max-width: none; }
  html.has-inv-pending .fab { display: none; }
  .inv-pending:not(.is-on) { display: none; }
}

/* ------------------------------------------------------------------ Récapitulatif du lot */
.inv-recap { display: flex; flex-direction: column; gap: 1rem; }
.inv-recap-head { display: grid; grid-template-columns: 2fr repeat(3, 1fr); gap: .75rem 1.25rem; padding: .8rem 1rem; border-radius: var(--r, 12px); background: var(--bg-sunken); }
.inv-recap > * { flex-shrink: 0; }
.inv-recap-list { max-height: min(44dvh, 25rem); overflow-y: auto; border: 1px solid var(--line); border-radius: var(--r, 12px); }
.inv-recap-row { display: grid; grid-template-columns: minmax(0, 2.2fr) minmax(6.5rem, .9fr) 4.5rem minmax(11rem, 1.5fr) 2.4rem; gap: .5rem 1rem; align-items: center; padding: .5rem .8rem; }
.inv-recap-row + .inv-recap-row { border-top: 1px solid var(--line); }
.inv-recap-cols { position: sticky; top: 0; z-index: 1; background: var(--bg-sunken); font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--text-3); padding-block: .45rem; }
.inv-recap-cols > :nth-child(2), .inv-recap-cols > :nth-child(3), .inv-recap-change, .inv-recap-diff { text-align: right; }
.inv-recap-info { min-width: 0; }
.inv-recap-change .ph { font-size: .85rem; color: var(--text-3); vertical-align: -1px; }
.inv-recap-diff { font-weight: 800; }
.inv-recap-row.inv-row-error { background: var(--danger-soft); }
.inv-recap-note { margin: 0; display: flex; gap: .4rem; align-items: flex-start; }
.inv-recap-note .ph { color: var(--success); font-size: 1.05rem; flex-shrink: 0; margin-top: .1rem; }
@media (max-width: 767px) {
  .inv-recap-head { grid-template-columns: 1fr 1fr; }
  .inv-recap-list { max-height: none; overflow: visible; }
  .inv-recap-cols { display: none; }
  .inv-recap-row { grid-template-columns: minmax(0, 1fr) auto 2.4rem; grid-template-areas: "info info x" "change diff diff" "reason reason reason"; gap: .45rem .75rem; padding: .75rem .8rem; }
  .inv-recap-info { grid-area: info; } .inv-recap-change { grid-area: change; text-align: left; } .inv-recap-diff { grid-area: diff; font-size: 1.1rem; }
  .inv-recap-reason { grid-area: reason; } .inv-recap-x { grid-area: x; }
}

/* ------------------------------------------------------------------ Formulaire « Corriger » */
.inv-cx { overflow: hidden; }
.inv-cx-body { display: grid; grid-template-columns: 15.5rem minmax(0, 1fr); min-height: 0; flex: 1 1 auto; overflow: hidden; }
.inv-cx-types { overflow-y: auto; padding: .9rem .7rem; border-right: 1px solid var(--line); background: var(--bg-sunken); display: flex; flex-direction: column; gap: .8rem; }
.inv-cx-group { display: flex; flex-direction: column; gap: .15rem; }
.inv-cx-group-title { padding: 0 .55rem .2rem; font-size: .68rem; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; color: var(--text-3); }
.inv-cx-type { display: flex; align-items: center; gap: .6rem; width: 100%; padding: .42rem .55rem; border: 0; border-radius: 9px; background: transparent; color: var(--text-2); font: inherit; font-size: .88rem; font-weight: 600; text-align: left; cursor: pointer; transition: background .12s, color .12s; }
.inv-cx-type:hover { background: var(--bg-hover); color: var(--text); }
.inv-cx-type.is-active { background: var(--bg-elev); color: var(--text); box-shadow: 0 0 0 1px var(--brand), var(--shadow-1); }
.inv-cx-type:focus-visible { outline: 2px solid var(--brand); outline-offset: 1px; }
.inv-cx-type-icon { display: grid; place-items: center; width: 1.8rem; height: 1.8rem; flex-shrink: 0; border-radius: 8px; font-size: 1.05rem; background: var(--bg-elev); color: var(--text-2); box-shadow: inset 0 0 0 1px var(--line); }
.inv-cx-type-icon.tone-brand { color: var(--brand-ink); background: var(--brand-soft); box-shadow: none; }
.inv-cx-type-icon.tone-success { color: var(--success); background: var(--success-soft); box-shadow: none; }
.inv-cx-type-icon.tone-danger { color: var(--danger); background: var(--danger-soft); box-shadow: none; }
.inv-cx-type-icon.tone-warning, .inv-cx-type-icon.tone-orange { color: var(--warning); background: var(--warning-soft); box-shadow: none; }
.inv-cx-type-icon.tone-info { color: var(--info); background: var(--info-soft); box-shadow: none; }
.inv-cx-type-icon.tone-violet { color: var(--violet, var(--info)); background: var(--violet-soft, var(--info-soft)); box-shadow: none; }
.inv-cx-form { overflow-y: auto; padding: 1.1rem 1.25rem; display: flex; flex-direction: column; gap: .9rem; min-width: 0; }
.inv-cx-hint { display: flex; align-items: center; gap: .75rem; padding: .65rem .8rem; border-radius: var(--r, 12px); background: var(--bg-sunken); }
.inv-cx-hint .inv-cx-type-icon { width: 2.3rem; height: 2.3rem; font-size: 1.25rem; }
.inv-cx-grid { gap: .9rem 1rem; }
.inv-cx-grid > .field[style*="display: none"] { display: none; }
.inv-cx-levels { display: flex; align-items: center; gap: .4rem; flex-wrap: wrap; }
.inv-cx-levels .chip { gap: .4rem; cursor: pointer; }
.inv-seg { display: flex; flex-wrap: wrap; width: 100%; }
.inv-seg > button { flex: 1 1 auto; }
.inv-ac { position: relative; }
.inv-ac-list { position: absolute; left: 0; right: 0; top: 100%; z-index: 30; margin-top: .3rem; max-height: 17rem; overflow-y: auto; padding: .3rem; border: 1px solid var(--line-strong); border-radius: var(--r, 12px); background: var(--bg-elev); box-shadow: var(--shadow-pop); }
.inv-ac-item { display: flex; flex-direction: column; width: 100%; padding: .5rem .65rem; border: 0; border-radius: 8px; background: transparent; color: var(--text); font: inherit; text-align: left; cursor: pointer; }
.inv-ac-item:hover, .inv-ac-item.is-active { background: var(--bg-hover); }
.inv-picked { display: flex; align-items: center; gap: .7rem; padding: .5rem .5rem .5rem .8rem; border: 1px solid var(--line-strong); border-radius: var(--r-control, 9px); background: var(--bg-sunken); min-width: 0; }
.inv-picked > .ph { font-size: 1.25rem; color: var(--brand-ink); flex-shrink: 0; }
.inv-picked .grow { min-width: 0; }
.inv-asset-filter { max-width: 17rem; }
.inv-assets { display: grid; grid-template-columns: repeat(auto-fill, minmax(13rem, 1fr)); gap: .3rem; max-height: 11.5rem; overflow-y: auto; margin-top: .45rem; padding: .4rem; border: 1px solid var(--line); border-radius: var(--r, 12px); background: var(--bg-sunken); }
.inv-asset { display: grid; grid-template-columns: auto 1fr; column-gap: .55rem; align-items: center; padding: .35rem .55rem; border-radius: 8px; background: var(--bg-elev); cursor: pointer; min-height: 2.6rem; }
.inv-asset input { grid-row: span 2; width: 1.05rem; height: 1.05rem; accent-color: var(--brand); }
.inv-asset .cell-sub { grid-column: 2; }
.inv-asset:has(input:checked) { box-shadow: inset 0 0 0 1.5px var(--brand); }
.inv-assets-empty { grid-column: 1 / -1; padding: .6rem; text-align: center; }
.inv-serials { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .86rem; }
.inv-cx-check { align-items: flex-start; }
.inv-cx-confirm { display: flex; flex-direction: column; gap: 1rem; }
.inv-cx-recap { display: grid; grid-template-columns: 1fr; margin: 0; border: 1px solid var(--line); border-radius: var(--r, 12px); overflow: hidden; }
.inv-cx-recap > div { display: grid; grid-template-columns: minmax(9rem, 14rem) 1fr; gap: 1rem; padding: .6rem .9rem; }
.inv-cx-recap > div + div { border-top: 1px solid var(--line); }
.inv-cx-recap dt { font-size: .82rem; font-weight: 600; color: var(--text-2); }
.inv-cx-recap dd { margin: 0; font-weight: 650; overflow-wrap: anywhere; }
@media (max-width: 767px) {
  .inv-cx-body { grid-template-columns: 1fr; overflow-y: auto; }
  .inv-cx-form { overflow: visible; padding: 1rem; }
  .inv-cx-recap > div { grid-template-columns: 1fr; gap: .15rem; }
  .inv-asset-filter { max-width: 11rem; }
}

/* ------------------------------------------------------------------ Écarts fréquents */
.inv-freq-bars { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: .75rem 1.5rem; padding: .8rem 1rem; border: 1px solid var(--line); border-radius: var(--r-panel, 14px); background: var(--bg-elev); }

/* ------------------------------------------------------------------ Inventaires */
.inv-st-progress { display: flex; align-items: center; gap: .6rem; min-width: 8rem; }
.inv-st-progress .progress { flex: 1; }
.inv-count-bar { display: flex; align-items: center; gap: .75rem 1.5rem; flex-wrap: wrap; padding: .6rem .9rem; border: 1px solid var(--line); border-radius: var(--r-panel, 14px); background: var(--bg-elev); }
.inv-count-progress { flex: 1 1 14rem; min-width: 10rem; }
.inv-count-save { display: inline-flex; align-items: center; gap: .35rem; font-size: .8rem; font-weight: 600; color: var(--text-3); }
.inv-count-save .ph { font-size: 1rem; }
.inv-count-save.is-ok { color: var(--success); }
.inv-count-actions { display: flex; align-items: center; gap: .5rem; margin-left: auto; flex-wrap: wrap; }
tr[data-inv-line].is-counted > td:first-child { box-shadow: inset 3px 0 0 var(--success-strong, var(--success)); }
tr[data-inv-line].has-diff > td { background: color-mix(in srgb, var(--warning-soft) 70%, transparent); }
tr[data-inv-line].has-diff > td:first-child { box-shadow: inset 3px 0 0 var(--warning); }
.inv-note { min-width: 9rem; }
.inv-same { white-space: nowrap; }
.inv-resume { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 1rem; align-content: start; }
.inv-resume .panel-body { display: flex; flex-direction: column; gap: .8rem; }
.inv-dl { display: grid; grid-template-columns: auto 1fr; gap: .45rem 1.2rem; margin: 0; }
.inv-dl dt { color: var(--text-2); font-size: .86rem; }
.inv-dl dd { margin: 0; font-weight: 650; text-align: right; overflow-wrap: anywhere; }
.inv-accuracy { display: flex; align-items: center; gap: .5rem 1rem; flex-wrap: wrap; }
.inv-accuracy-value { font-size: 2.2rem; font-weight: 850; line-height: 1; white-space: nowrap; }
.inv-diff-list { display: flex; flex-direction: column; }
.inv-diff-list > div { display: flex; align-items: center; justify-content: space-between; gap: .75rem; padding: .45rem 0; }
.inv-diff-list > div + div { border-top: 1px solid var(--line); }
.inv-sn-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(11rem, 1fr)); gap: .3rem; max-height: 15rem; overflow-y: auto; padding: .4rem; border: 1px solid var(--line); border-radius: var(--r, 12px); background: var(--bg-sunken); }
.inv-sn-total { display: flex; align-items: baseline; gap: .5rem; }
.inv-sn-total strong { font-size: 1.6rem; font-weight: 850; }
.inv-scope-choices { --min: 130px; }

/* Libellés secondaires hors tableau (les classes .cell-* du socle ne valent que dans .table) */
:is(.inv-cx, .inv-card, .inv-recap, .inv-sn, .inv-resume, .inv-count-bar, .inv-reverse) .cell-sub { display: block; font-size: .8rem; font-weight: 500; color: var(--text-3); }
:is(.inv-cx, .inv-card, .inv-recap, .inv-sn, .inv-resume, .inv-count-bar, .inv-reverse) .cell-strong { font-weight: 650; color: var(--text); }
.inv-cx-check .cell-sub { margin-top: .1rem; }

@media (max-width: 767px) { .inv-head-adjust > .toolbar { display: none; } }

/* Historique : lignes compactes, libellé d'article sur une ligne */
.inv-hist-table td { padding-block: .45rem; vertical-align: middle; }
.inv-hist-table .inv-cell-item .cell-strong { display: block; max-width: min(22rem, 24vw); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.inv-hist-table .inv-cell-reason { max-width: 17rem; }
.inv-hist-status { margin-top: .2rem; }
.inv-hist-status .ph { vertical-align: -1px; }
.inv-hist-table .inv-row-muted > td { opacity: 1; color: var(--text-3); }
.inv-hist-table .inv-row-muted .cell-strong, .inv-hist-table .inv-row-muted .qty { color: var(--text-3); }
.inv-hist-table .inv-row-muted .badge { opacity: .7; }

/* Colonne d'actions toujours atteignable quand le tableau défile horizontalement (tablette) */
.inv-hist-table :is(th, td).col-actions, .inv-table :is(th, td).col-actions { position: sticky; right: 0; background: var(--bg-elev); }
.inv-hist-table thead th.col-actions, .inv-table thead th.col-actions { background: var(--bg-sunken); }
tr[data-inv-row].is-modified > td.col-actions { background: color-mix(in srgb, var(--brand-soft) 55%, var(--bg-elev)); }
tr[data-inv-row].is-blocked > td.col-actions { background: color-mix(in srgb, var(--danger-soft) 100%, var(--bg-elev)); }
tr[data-inv-line].has-diff > td.col-actions { background: color-mix(in srgb, var(--warning-soft) 70%, var(--bg-elev)); }
@media (max-width: 1100px) {
  .inv-col-reason { width: 11rem; }
  .inv-reason { min-width: 8.5rem; }
  .inv-table td:first-child .cell-strong { display: block; max-width: 17rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .inv-hist-table .inv-cell-item .cell-strong { max-width: 14rem; }
  .inv-hist-table .inv-cell-reason { max-width: 12rem; }
}
/* Tablette : le motif de chaque ligne se choisit dans le récapitulatif (motif par défaut appliqué), le tableau reste lisible sans défilement horizontal */
@media (min-width: 768px) and (max-width: 1023px) {
  .inv-table .inv-col-reason { display: none; }
  .inv-table :is(th, td) { padding-inline: .6rem; }
  .inv-col-real { width: 7.5rem; }
  .inv-real { width: 6rem; }
  .inv-table td:first-child .cell-strong { max-width: 13.5rem; }
  .inv-table td:first-child .cell-sub { max-width: 13.5rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .inv-note { min-width: 6rem; }
}
/* Tablette avec barre d'onglets : le bouton « Corriger » de l'en-tête suffit, le bouton flottant ne masque pas la barre de validation */
@media (min-width: 768px) and (max-width: 900px) { body:has(.inv-head-adjust) .fab { display: none; } }
