/* =========================================================================
   Module Opérations (agent A7) — opérations (panier), bons & fiches, journal des mouvements.
   Classes préfixées « ops- » (écran Opérations), « vch- » (bons), « mvt- » (mouvements).
   Couleurs : variables du socle uniquement (clair / sombre).
   ========================================================================= */

/* ------------------------------------------------------------------ Écran Opérations */
.ops { gap: var(--gap-page, 1rem); min-width: 0; }
.ops-types { display: grid; grid-template-columns: repeat(9, minmax(0, 1fr)); gap: .45rem; padding: 2px; margin: -2px; flex-shrink: 0; }
.ops-type { display: flex; align-items: center; gap: .5rem; min-width: 0; min-height: 3rem; padding: .35rem .6rem .35rem .4rem; border: 1px solid var(--line); border-radius: var(--r, 12px); background: var(--bg-elev); color: var(--text-2); font: inherit; font-weight: 650; font-size: .84rem; line-height: 1.2; text-align: left; cursor: pointer; transition: border-color .15s, background .15s, color .15s, box-shadow .15s, transform .15s; }
.ops-type-label { min-width: 0; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.ops-type:hover { border-color: var(--line-strong); color: var(--text); }
.ops-type:active { transform: scale(.98); }
.ops-type.is-active { border-color: var(--brand); color: var(--text); background: var(--brand-soft); box-shadow: inset 0 0 0 1px var(--brand); }
.ops-type:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.ops-type .icon-box { flex-shrink: 0; }

.ops-grid { display: grid; gap: var(--gap-page, 1rem); grid-template-columns: minmax(230px, 280px) minmax(0, 1fr) minmax(300px, 380px); grid-template-rows: minmax(0, 1fr); min-width: 0; }
@media (min-width: 1800px) { .ops-grid { grid-template-columns: minmax(280px, 340px) minmax(0, 1fr) minmax(380px, 480px); } }
.ops-grid > .panel { min-height: 0; overflow: hidden; }
.ops-head { padding: .7rem .9rem; gap: .6rem; flex-wrap: nowrap; min-height: 3.4rem; }
.ops-head .panel-title { font-size: .98rem; min-width: 0; }
.ops-head .panel-title > span:not(.count) { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ops-more-toggle { display: none; flex-shrink: 0; }

.ops-params-body { padding: .9rem; display: flex; flex-direction: column; gap: .9rem; }
.ops-hint { margin: 0; font-size: .84rem; color: var(--text-3); line-height: 1.45; }
.ops-form { display: grid; gap: .8rem; grid-template-columns: minmax(0, 1fr); }
.ops-form .field { gap: .3rem; }
.ops-form .label { font-size: .84rem; }
.ops-form .textarea { min-height: 4.2rem; }
.ops-recent { border-top: 1px solid var(--line); padding-top: .8rem; display: flex; flex-direction: column; gap: .15rem; }
.ops-recent-title { font-size: .76rem; font-weight: 750; text-transform: uppercase; letter-spacing: .05em; color: var(--text-3); margin-bottom: .25rem; }
.ops-recent-row { display: flex; align-items: center; gap: .6rem; padding: .4rem .45rem; border-radius: var(--r-sm); color: inherit; text-decoration: none; min-width: 0; }
.ops-recent-row:hover { background: var(--bg-hover); text-decoration: none; }
.ops-recent-row > .ph { color: var(--text-3); font-size: 1.1rem; flex-shrink: 0; }
.ops-recent-row .cell-strong, .ops-recent-row .cell-sub { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.ops-search { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: center; }
.ops-search-q { grid-column: 1 / -1; }
@media (min-width: 1800px) { .ops-search { grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr) minmax(0, 1fr); } .ops-search-q { grid-column: auto; } }
.ops-search .input, .ops-search .select { min-height: 2.5rem; padding-top: .4rem; padding-bottom: .4rem; }
.ops-source { display: flex; align-items: center; gap: .6rem; padding: .5rem .9rem; border-bottom: 1px solid var(--line); background: var(--bg-sunken); font-size: .82rem; color: var(--text-2); flex-shrink: 0; min-width: 0; }
.ops-source-label { display: inline-flex; align-items: center; gap: .4rem; font-weight: 650; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ops-source-count { margin-left: auto; color: var(--text-3); white-space: nowrap; }
.ops-chip-item { padding-right: .3rem; }
.ops-chip-x { display: inline-grid; place-items: center; width: 1.3rem; height: 1.3rem; border: 0; border-radius: 50%; background: transparent; color: var(--text-3); cursor: pointer; padding: 0; }
.ops-chip-x:hover { background: var(--bg-hover); color: var(--text); }

.ops-rows, .ops-lines { padding: .4rem; display: flex; flex-direction: column; gap: 2px; overscroll-behavior: contain; scrollbar-width: thin; }
.ops-row { display: flex; align-items: center; gap: .7rem; width: 100%; min-height: 3.3rem; padding: .45rem .55rem; border: 1px solid transparent; border-radius: var(--r-sm); background: transparent; color: inherit; font: inherit; text-align: left; cursor: pointer; flex-shrink: 0; transition: background .12s, border-color .12s; }
.ops-row:hover:not(:disabled) { background: var(--bg-hover); }
.ops-row:focus-visible { outline: 2px solid var(--brand); outline-offset: -2px; }
.ops-row:disabled { opacity: .5; cursor: not-allowed; }
.ops-row.is-in-cart { background: var(--brand-soft); border-color: var(--brand-line, var(--line)); }
.ops-row-main, .ops-line-main { display: flex; flex-direction: column; gap: .1rem; min-width: 0; flex: 1 1 auto; }
.ops-row-title { font-weight: 650; font-size: .9rem; line-height: 1.3; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.ops-row-sub { display: flex; align-items: center; gap: .3rem; font-size: .78rem; color: var(--text-3); min-width: 0; white-space: nowrap; overflow: hidden; }
.ops-row-sub > span { overflow: hidden; text-overflow: ellipsis; flex: 0 1 auto; min-width: 0; }
.ops-row-sub > .tabular, .ops-row-sub > .badge, .ops-row-sub > .ops-serial-flag { flex-shrink: 0; }
.ops-serial-flag { display: inline-flex; align-items: center; gap: .2rem; margin-left: .35rem; padding: 0 .4rem; border-radius: var(--r-pill); background: var(--bg-sunken); color: var(--text-2); font-size: .72rem; font-weight: 650; line-height: 1.5; }
.ops-row-side { display: flex; flex-direction: column; align-items: flex-end; gap: .2rem; flex-shrink: 0; }
.ops-row-side .badge { font-size: .7rem; }
.ops-row-qty { text-align: right; line-height: 1.1; white-space: nowrap; }
.ops-row-qty b { font-size: 1rem; font-weight: 750; }
.ops-row-qty small { font-size: .72rem; color: var(--text-3); margin-left: .25rem; }
.ops-row-add { display: grid; place-items: center; width: 2rem; height: 2rem; border-radius: 50%; background: var(--bg-sunken); color: var(--text-2); flex-shrink: 0; font-size: 1rem; transition: background .12s, color .12s; }
.ops-row:hover:not(:disabled) .ops-row-add { background: var(--brand); color: var(--on-brand); }
.ops-row.is-in-cart .ops-row-add { background: var(--success-soft); color: var(--success); }
.ops-more { display: flex; justify-content: center; padding: .6rem; flex-shrink: 0; }
.ops-skeleton { display: flex; flex-direction: column; gap: .5rem; padding: .4rem; }
.ops-skeleton .sk-block { height: 3rem; border-radius: var(--r-sm); }
.ops .empty.is-compact { margin: auto; padding: 1.5rem 1rem; }

.ops-route { display: flex; align-items: center; gap: .45rem; padding: .5rem .9rem; border-bottom: 1px solid var(--line); background: var(--bg-sunken); font-size: .84rem; font-weight: 700; color: var(--text); flex-shrink: 0; }
.ops-route .ph { color: var(--text-3); }
.ops-line { padding: .6rem .6rem .65rem; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--bg-elev); display: flex; flex-direction: column; gap: .5rem; flex-shrink: 0; }
.ops-line + .ops-line { margin-top: .35rem; }
.ops-line-top { display: flex; align-items: flex-start; gap: .5rem; }
.ops-line-top .btn-icon { margin: -.25rem -.3rem 0 0; flex-shrink: 0; }
.ops-line-qty { display: flex; align-items: center; gap: .6rem; }
.ops-stepper { display: inline-flex; align-items: center; gap: .3rem; }
.ops-stepper .input { width: 4.6rem; min-height: 2.4rem; padding: .3rem .4rem; text-align: center; font-weight: 700; -moz-appearance: textfield; appearance: textfield; }
.ops-stepper .input::-webkit-outer-spin-button, .ops-stepper .input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.ops-line-max { font-size: .8rem; color: var(--text-3); }
.ops-line-serials { display: flex; flex-direction: column; align-items: flex-start; gap: .45rem; }
.ops-serial-chips { display: flex; flex-wrap: wrap; gap: .3rem; }
.ops-serial-chips .chip { font-size: .76rem; padding: .15rem .55rem; }
.ops-chip-untracked { border-style: dashed; }
.ops-cart-foot { border-top: 1px solid var(--line); padding: .8rem .9rem; display: flex; flex-direction: column; gap: .65rem; flex-shrink: 0; background: var(--bg-elev); border-radius: 0 0 var(--r-lg) var(--r-lg); }
.ops-totals { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; font-size: .88rem; color: var(--text-2); }
.ops-totals b { color: var(--text); font-size: .98rem; }
.ops-actions { display: flex; gap: .5rem; }
.ops-actions .btn { min-width: 0; }
.ops-error { padding: .6rem .75rem; font-size: .86rem; gap: .55rem; }
.ops-error > .ph { font-size: 1.15rem; }
.ops-cart-close, .ops-bar { display: none; }

/* Sélecteur de n° de série */
.ops-picker { display: flex; flex-direction: column; gap: 1rem; }
.ops-picker-meta { display: flex; align-items: center; flex-wrap: wrap; gap: .6rem; font-size: .88rem; color: var(--text-2); }
.ops-picker-count { margin-left: auto; }
.ops-picker-head { display: flex; align-items: center; justify-content: space-between; gap: .6rem; flex-wrap: wrap; margin-bottom: .5rem; }
.ops-picker-filter { width: min(100%, 15rem); }
.ops-picker-filter .input { min-height: 2.4rem; padding-top: .35rem; padding-bottom: .35rem; }
.ops-picker-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: .35rem; max-height: min(38dvh, 320px); overflow: auto; padding: .4rem; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--bg-sunken); scrollbar-width: thin; }
.ops-picker-none { margin: .4rem; grid-column: 1 / -1; }
.ops-picker-list .ops-skeleton { grid-column: 1 / -1; }
.ops-asset { display: flex; align-items: center; gap: .55rem; min-height: 2.6rem; padding: .35rem .6rem; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--bg-elev); min-width: 0; }
.ops-asset input { margin: 0; }
.ops-asset.is-checked { border-color: var(--brand); background: var(--brand-soft); }
.ops-asset-sn { font-weight: 650; font-size: .86rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ops-asset-tag { margin-left: auto; font-size: .74rem; color: var(--text-3); white-space: nowrap; }
.ops-picker-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 1rem; }
.ops-picker-grid .textarea { min-height: 5.5rem; }
.ops-picker-note { margin: 0; padding: .6rem .8rem; font-size: .86rem; }
.ops-recap { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .5rem; margin: .3rem 0; }
.ops-recap > div { padding: .6rem .7rem; border-radius: var(--r-sm); background: var(--bg-sunken); border: 1px solid var(--line); }
.ops-recap dt { font-size: .74rem; color: var(--text-3); font-weight: 650; }
.ops-recap dd { margin: 0; font-size: 1.25rem; font-weight: 800; }

/* Écrans moyens (tablette, petit ordinateur) : paramètres en bandeau, articles | bon */
@media (max-width: 1279px) {
  .ops-grid { grid-template-columns: minmax(0, 1fr) minmax(300px, 380px); grid-template-rows: auto minmax(0, 1fr); }
  .ops-params { grid-column: 1 / -1; }
  .ops-params.fill { flex: 0 0 auto; }
  .ops-params-body { overflow: visible !important; padding: .75rem .9rem; gap: .7rem; }
  .ops-hint { display: none; }
  .ops-form { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
  .ops-form .ops-notes { grid-column: 1 / -1; }
  .ops-more-toggle { display: inline-flex; }
  .ops-types { display: flex; overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch; scroll-snap-type: x proximity; }
  .ops-types::-webkit-scrollbar { display: none; }
  .ops-type { flex: 0 0 auto; white-space: nowrap; padding-right: .85rem; scroll-snap-align: start; }
}

/* Téléphone : page défilante, bon en cours dans une feuille plein écran, barre d'accès en bas */
@media (max-width: 767px) {
  .ops-grid { grid-template-columns: minmax(0, 1fr); grid-template-rows: none; }
  .ops-grid > .panel { overflow: visible; }
  .ops-types { margin: 0 -16px; padding: 2px 16px; }
  .ops { overflow-x: clip; }
  .ops-rows { padding-bottom: 5rem; }
  .ops-row { min-height: 3.6rem; }
  .ops-cart { display: none; position: fixed; inset: 0; z-index: 180; border-radius: 0; border: 0; padding-top: var(--safe-top, 0px); padding-bottom: var(--safe-bottom, 0px); }
  .ops.is-cart-open .ops-cart { display: flex; animation: ops-sheet .28s var(--ease-out, ease-out); }
  .ops-cart .ops-lines { flex: 1 1 auto; min-height: 0; overflow: auto; }
  .ops-cart-foot { border-radius: 0; }
  .ops-cart-close { display: inline-flex; }
  .ops-bar { display: block; position: fixed; left: 0; right: 0; bottom: calc(var(--tabbar-h, 60px) + var(--safe-bottom, 0px)); z-index: 60; padding: .55rem 16px; background: var(--glass, var(--bg-elev)); -webkit-backdrop-filter: var(--glass-blur, none); backdrop-filter: var(--glass-blur, none); border-top: 1px solid var(--line); }
  .ops-bar .btn { justify-content: flex-start; gap: .6rem; }
  .ops-bar-total { margin-left: auto; font-weight: 700; opacity: .85; }
  html.is-kb-open .ops-bar { display: none; }
  .ops-picker-list { grid-template-columns: minmax(0, 1fr); max-height: 34dvh; }
  .ops-asset { min-height: var(--tap, 44px); }
}
@keyframes ops-sheet { from { transform: translateY(18px); opacity: 0; } to { transform: none; opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .ops.is-cart-open .ops-cart { animation: none; } .ops-type, .ops-row, .ops-row-add { transition: none; } }
html[data-effects="off"] .ops.is-cart-open .ops-cart { animation: none; }

/* ------------------------------------------------------------------ Bons & fiches */
.vch-tabs { flex-shrink: 0; }
.vch-notice { padding: .65rem .9rem; font-size: .9rem; flex-shrink: 0; }
.vch-notice .notice-title { display: inline; margin: 0; }
.vch-type { display: inline-flex; align-items: center; gap: .4rem; white-space: nowrap; }
.vch-type .ph { color: var(--text-3); font-size: 1.05rem; }
.vch-route { display: inline-flex; align-items: center; gap: .35rem; font-weight: 650; font-variant-numeric: tabular-nums; white-space: nowrap; }
.vch-route > .ph { color: var(--text-3); font-size: .9rem; }
.vch-route > .is-soft { color: var(--text-2); font-weight: 600; }
.vch-route.is-lg { font-size: .95rem; padding: .15rem .6rem; border-radius: var(--r-pill); background: var(--bg-sunken); border: 1px solid var(--line); }
.vch-meta { display: inline-flex; align-items: center; gap: .35rem; font-size: .88rem; color: var(--text-2); white-space: nowrap; text-decoration: none; }
.vch-meta .ph { color: var(--text-3); font-size: 1rem; }
.vch-meta b { color: var(--text); }
a.vch-meta:hover { color: var(--text); text-decoration: underline; }
.vch-cancel-btn { color: var(--danger); }
.vch-arrow { color: var(--text-3); margin: 0 .2rem; font-size: .85rem; vertical-align: middle; }
.vch-n { width: 2.6rem; }
.vch-cell { display: block; min-width: 0; }
.vch-cell.is-inline { display: inline-flex; align-items: center; flex-wrap: wrap; gap: .25rem; }
.vch-cell > .cell-strong, .vch-cell > .cell-sub { display: block; }
@media (max-width: 680px) {
  .table.is-stacked td.vch-n { display: none; }
  .table.is-stacked td .vch-cell { text-align: right; }
  .table.is-stacked td.col-main .vch-cell { text-align: left; }
  .table.is-stacked td .vch-cell.is-inline { justify-content: flex-end; }
}
.vch-strip { display: flex; align-items: center; gap: .5rem; padding: .55rem 1rem; font-size: .84rem; color: var(--text-2); background: var(--bg-sunken); border-bottom: 1px solid var(--line); flex-shrink: 0; }
.vch-strip .ph { color: var(--text-3); font-size: 1.05rem; flex-shrink: 0; }
.vch-origin { padding: 1rem 1.2rem; display: flex; flex-direction: column; gap: .15rem; }
.vch-origin-text { margin: 0 0 .35rem; color: var(--text-2); font-size: .9rem; }
.vch-origin-item { display: flex; align-items: flex-start; gap: .45rem; padding: .5rem .2rem; border-bottom: 1px solid var(--line); font-weight: 600; line-height: 1.45; }
.vch-origin-item:last-child { border-bottom: 0; }
.vch-origin-item .ph { color: var(--brand); font-size: 1.2rem; flex-shrink: 0; margin-top: .1rem; }
.vch-follow { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 380px), 1fr)); gap: var(--gap-page, 1rem); align-items: start; }
.vch-notes { white-space: pre-line; font-weight: 500; }
.vch-receive-list { display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: var(--r-sm); max-height: min(44dvh, 380px); overflow: auto; scrollbar-width: thin; }
.vch-receive-row { display: flex; align-items: center; gap: .8rem; padding: .55rem .8rem; border-bottom: 1px solid var(--line); }
.vch-receive-row:last-child { border-bottom: 0; }
.vch-receive-qty { display: inline-flex; align-items: center; gap: .45rem; flex-shrink: 0; }
.vch-receive-qty .input { width: 5.2rem; min-height: 2.5rem; padding: .3rem .5rem; text-align: center; font-weight: 700; }
.vch-shortfall { border: 0; padding: 0; margin: 0; display: flex; flex-direction: column; gap: .5rem; }
.vch-shortfall .choice { align-items: flex-start; font-weight: 500; }
.vch-verify { text-align: center; }
.vch-verify-dl { text-align: left; margin: 1rem auto; max-width: 26rem; }

/* ------------------------------------------------------------------ Journal des mouvements */
.mvt-is-void { opacity: .62; }
.mvt-is-void .qty-num { text-decoration: line-through; }
.mvt-item { max-width: 22rem; }
.mvt-item > * { display: block; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mvt-reason { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 15rem; }
.mvt-ref { white-space: nowrap; }
@media (min-width: 1800px) { .mvt-item { max-width: 34rem; } .mvt-reason { max-width: 24rem; } }
.mvt-flow { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); gap: 1rem; align-items: stretch; flex-shrink: 0; }
.mvt-node { display: flex; flex-direction: column; align-items: flex-start; gap: .25rem; padding: 1rem 1.2rem; border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--bg-elev); box-shadow: var(--shadow-1); min-width: 0; }
.mvt-node-label { font-size: .74rem; font-weight: 750; text-transform: uppercase; letter-spacing: .05em; color: var(--text-3); }
.mvt-node-title { font-size: 1.35rem; font-weight: 800; color: var(--text); font-variant-numeric: tabular-nums; }
a.mvt-node-title:hover { color: var(--brand-ink); }
.mvt-node-title.is-outside { color: var(--text-3); font-weight: 700; }
.mvt-node-sub { font-size: .86rem; color: var(--text-2); margin-bottom: .2rem; }
.mvt-arrow { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .1rem; padding: 0 .4rem; color: var(--text-3); }
.mvt-arrow > .ph { font-size: 1.6rem; color: var(--brand); }
.mvt-arrow-unit { font-size: .76rem; }
@media (max-width: 767px) {
  .mvt-flow { grid-template-columns: minmax(0, 1fr); }
  .mvt-arrow { flex-direction: row; gap: .5rem; padding: 0; }
  .mvt-arrow > .ph { transform: rotate(90deg); }
  .vch-receive-row { flex-wrap: wrap; }
  .vch-meta { white-space: normal; }
}
